Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FISH-327 Implement MicroProfile Sniffers #4966

Merged
merged 31 commits into from
Nov 20, 2020
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
28b73bd
FISH-327 Implement MicroProfile Connector Module
MattGill98 Oct 26, 2020
d007311
FISH-327 Implement MicroProfile OpenAPI Sniffer
MattGill98 Oct 26, 2020
023866b
FISH-327 Implement MicroProfile Metrics Sniffer
MattGill98 Oct 26, 2020
372c734
FISH-327 Implement MicroProfile Health Sniffer
MattGill98 Oct 26, 2020
49ae71f
FISH-327 Implement MicroProfile Fault Tolerance Sniffer
MattGill98 Oct 26, 2020
d95d8fc
FISH-327 Implement MicroProfile JWT Auth Sniffer
MattGill98 Oct 27, 2020
4592003
FISH-327 Implement MicroProfile Config Sniffer
MattGill98 Oct 27, 2020
f2f4e9c
FISH-327 Fix MP Connectors
MattGill98 Oct 27, 2020
e038a32
FISH-327 Fix MP Sniffer ClassLoading Issue
MattGill98 Oct 27, 2020
f33dee3
FISH-327 Rename Generic CDI Extension Classes
MattGill98 Oct 27, 2020
a1989ca
FISH-327 Code cleanup to use Array Literals
MattGill98 Oct 27, 2020
b28880f
FISH-327 Remove WarType injection
MattGill98 Oct 27, 2020
f95f02d
Merge branch 'master' of https://github.com/payara/Payara into FISH-327
MattGill98 Oct 30, 2020
ea94978
Merge branch 'master' of https://github.com/payara/Payara into FISH-327
MattGill98 Oct 30, 2020
14ea1c7
Make Arquillian runners debuggable by default
MattGill98 Nov 3, 2020
bba4a79
FISH-327 Fix MP Config Source Creation
MattGill98 Nov 3, 2020
0b4efd9
FISH-327 Remove unnecessary app container overrides
MattGill98 Nov 3, 2020
bbc361a
Partial revert "FISH-327 Implement MicroProfile OpenAPI Sniffer"
MattGill98 Nov 5, 2020
b7ddab0
Partial revert "FISH-327 Implement MicroProfile Metrics Sniffer"
MattGill98 Nov 5, 2020
b9c54c2
Partial revert "FISH-327 Implement MicroProfile Health Sniffer"
MattGill98 Nov 5, 2020
37c08ba
FISH-327 Add new 'activation' folders
MattGill98 Nov 5, 2020
8af6f29
FISH-327 Fix extensions loading twice
MattGill98 Nov 9, 2020
aca8745
FISH-327 Fix Health Extension
MattGill98 Nov 9, 2020
f8ce23f
Merge branch 'master' of https://github.com/payara/Payara into FISH-327
MattGill98 Nov 13, 2020
c2d687a
FISH-327 Add Sniffer Extention MetaData Earlier
MattGill98 Nov 17, 2020
b85f974
FISH-327 Add OpenAPI YAML Files to Sniffer
MattGill98 Nov 18, 2020
de0f852
FISH-327 Fix Health CDI Extension
MattGill98 Nov 18, 2020
65178a0
FISH-327 Fix Config Sniffer
MattGill98 Nov 18, 2020
5af66d0
FISH-327 Fix Metrics TCK
MattGill98 Nov 18, 2020
5247791
FISH-327 Fix Metrics Sniffer
MattGill98 Nov 19, 2020
671da19
FISH-327 Fix Missing Copyright Headers
MattGill98 Nov 20, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion appserver/packager/microprofile-package/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!--
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) [2016-2019] Payara Foundation and/or its affiliates. All rights reserved.
* Copyright (c) [2016-2020] Payara Foundation and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
Expand Down Expand Up @@ -131,6 +131,11 @@
<artifactId>microprofile-common</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>fish.payara.server.internal.payara-appserver-modules</groupId>
<artifactId>microprofile-connector</artifactId>
<version>${project.version}</version>
</dependency>

<!-- Config -->
<dependency>
Expand Down
15 changes: 15 additions & 0 deletions appserver/payara-appserver-modules/microprofile/config/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,26 @@
<artifactId>microprofile-config-service</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>fish.payara.server.internal.payara-appserver-modules</groupId>
<artifactId>microprofile-connector</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>fish.payara.server.internal.common</groupId>
<artifactId>internal-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>fish.payara.server.internal.web</groupId>
<artifactId>web-glue</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>fish.payara.server.internal.web</groupId>
<artifactId>weld-integration</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) [2020] Payara Foundation and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
* https://github.com/payara/Payara/blob/master/LICENSE.txt
* See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
* file and include the License file at glassfish/legal/LICENSE.txt.
*
* GPL Classpath Exception:
* The Payara Foundation designates this particular file as subject to the "Classpath"
* exception as provided by the Payara Foundation in the GPL Version 2 section of the License
* file that accompanied this code.
*
* Modifications:
* If applicable, add the following below the License Header, with the fields
* enclosed by brackets [] replaced by your own identifying information:
* "Portions Copyright [year] [name of copyright owner]"
*
* Contributor(s):
* If you wish your version of this file to be governed by only the CDDL or
* only the GPL Version 2, indicate your decision by adding "[Contributor]
* elects to include this software in this distribution under the [CDDL or GPL
* Version 2] license." If you don't indicate a single choice of license, a
* recipient has the option to distribute your version of this file under
* either the CDDL, the GPL Version 2 or to extend the choice of license to
* its licensees as provided above. However, if you add GPL Version 2 code
* and therefore, elected the GPL Version 2 license, then the option applies
* only if the new code is made subject to such option by the copyright
* holder.
*/
package fish.payara.microprofile.config.activation;

import org.eclipse.microprofile.config.ConfigProvider;
import org.glassfish.api.deployment.ApplicationContext;
import org.glassfish.api.deployment.DeploymentContext;

import fish.payara.microprofile.connector.MicroProfileApplicationContainer;

public class ConfigApplicationContainer extends MicroProfileApplicationContainer {

protected ConfigApplicationContainer(DeploymentContext deploymentContext) {
super(deploymentContext);
}

@Override
public boolean start(ApplicationContext ctx) throws Exception {
// Needed to make sure that the Config Sources are created at the right stage during deployment
ConfigProvider.getConfig();
return true;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) [2020] Payara Foundation and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
* https://github.com/payara/Payara/blob/master/LICENSE.txt
* See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
* file and include the License file at glassfish/legal/LICENSE.txt.
*
* GPL Classpath Exception:
* The Payara Foundation designates this particular file as subject to the "Classpath"
* exception as provided by the Payara Foundation in the GPL Version 2 section of the License
* file that accompanied this code.
*
* Modifications:
* If applicable, add the following below the License Header, with the fields
* enclosed by brackets [] replaced by your own identifying information:
* "Portions Copyright [year] [name of copyright owner]"
*
* Contributor(s):
* If you wish your version of this file to be governed by only the CDDL or
* only the GPL Version 2, indicate your decision by adding "[Contributor]
* elects to include this software in this distribution under the [CDDL or GPL
* Version 2] license." If you don't indicate a single choice of license, a
* recipient has the option to distribute your version of this file under
* either the CDDL, the GPL Version 2 or to extend the choice of license to
* its licensees as provided above. However, if you add GPL Version 2 code
* and therefore, elected the GPL Version 2 license, then the option applies
* only if the new code is made subject to such option by the copyright
* holder.
*/
package fish.payara.microprofile.config.activation;

import org.glassfish.api.deployment.Deployer;
import org.glassfish.hk2.api.PerLookup;
import org.jvnet.hk2.annotations.Service;

import fish.payara.microprofile.connector.MicroProfileContainer;

@Service(name = "fish.payara.microprofile.config.activation.ConfigContainer")
@PerLookup
public class ConfigContainer extends MicroProfileContainer {

@Override
public Class<? extends Deployer<?, ?>> getDeployer() {
return ConfigDeployer.class;
}

@Override
public String getName() {
return "ConfigContainer";
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) [2020] Payara Foundation and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
* https://github.com/payara/Payara/blob/master/LICENSE.txt
* See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
* file and include the License file at glassfish/legal/LICENSE.txt.
*
* GPL Classpath Exception:
* The Payara Foundation designates this particular file as subject to the "Classpath"
* exception as provided by the Payara Foundation in the GPL Version 2 section of the License
* file that accompanied this code.
*
* Modifications:
* If applicable, add the following below the License Header, with the fields
* enclosed by brackets [] replaced by your own identifying information:
* "Portions Copyright [year] [name of copyright owner]"
*
* Contributor(s):
* If you wish your version of this file to be governed by only the CDDL or
* only the GPL Version 2, indicate your decision by adding "[Contributor]
* elects to include this software in this distribution under the [CDDL or GPL
* Version 2] license." If you don't indicate a single choice of license, a
* recipient has the option to distribute your version of this file under
* either the CDDL, the GPL Version 2 or to extend the choice of license to
* its licensees as provided above. However, if you add GPL Version 2 code
* and therefore, elected the GPL Version 2 license, then the option applies
* only if the new code is made subject to such option by the copyright
* holder.
*/
package fish.payara.microprofile.config.activation;

import java.util.Collection;
import java.util.function.Supplier;

import javax.enterprise.inject.spi.Extension;

import org.eclipse.microprofile.config.Config;
import org.eclipse.microprofile.config.inject.ConfigProperty;
import org.glassfish.api.deployment.DeploymentContext;
import org.glassfish.hk2.api.PerLookup;
import org.glassfish.hk2.classmodel.reflect.Type;
import org.glassfish.hk2.classmodel.reflect.Types;
import org.glassfish.weld.WeldDeployer;
import org.jvnet.hk2.annotations.Service;

import fish.payara.microprofile.config.cdi.ConfigCdiExtension;
import fish.payara.microprofile.connector.MicroProfileDeployer;

@Service
@PerLookup
public class ConfigDeployer extends MicroProfileDeployer<ConfigContainer, ConfigApplicationContainer> {

@Override
@SuppressWarnings("unchecked")
public ConfigApplicationContainer load(ConfigContainer container,
DeploymentContext deploymentContext) {

// Perform annotation scanning to see if CDI extension is required here
// This is performed here so that the ApplicationContainer executes regardless of CDI extension state
final Types types = deploymentContext.getTransientAppMetaData(Types.class.getName(), Types.class);

final Type annotationType = types.getBy(ConfigProperty.class.getName());
final Type classType = types.getBy(Config.class.getName());
final boolean annotationFound = annotationType != null;
final boolean classFound = classType != null;

if (annotationFound || classFound) {
// Register the CDI extension
final Collection<Supplier<Extension>> snifferExtensions = deploymentContext.getTransientAppMetaData(WeldDeployer.SNIFFER_EXTENSIONS, Collection.class);
if (snifferExtensions != null) {
snifferExtensions.add(ConfigCdiExtension::new);
}
}

return new ConfigApplicationContainer(deploymentContext);
}

@Override
public void unload(ConfigApplicationContainer applicationContainer, DeploymentContext ctx) {
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) [2020] Payara Foundation and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
* https://github.com/payara/Payara/blob/master/LICENSE.txt
* See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
* file and include the License file at glassfish/legal/LICENSE.txt.
*
* GPL Classpath Exception:
* The Payara Foundation designates this particular file as subject to the "Classpath"
* exception as provided by the Payara Foundation in the GPL Version 2 section of the License
* file that accompanied this code.
*
* Modifications:
* If applicable, add the following below the License Header, with the fields
* enclosed by brackets [] replaced by your own identifying information:
* "Portions Copyright [year] [name of copyright owner]"
*
* Contributor(s):
* If you wish your version of this file to be governed by only the CDDL or
* only the GPL Version 2, indicate your decision by adding "[Contributor]
* elects to include this software in this distribution under the [CDDL or GPL
* Version 2] license." If you don't indicate a single choice of license, a
* recipient has the option to distribute your version of this file under
* either the CDDL, the GPL Version 2 or to extend the choice of license to
* its licensees as provided above. However, if you add GPL Version 2 code
* and therefore, elected the GPL Version 2 license, then the option applies
* only if the new code is made subject to such option by the copyright
* holder.
*/
package fish.payara.microprofile.config.activation;

import java.lang.annotation.Annotation;

import org.glassfish.api.deployment.archive.ReadableArchive;
import org.glassfish.hk2.api.PerLookup;
import org.jvnet.hk2.annotations.Service;

import fish.payara.microprofile.connector.MicroProfileSniffer;

@Service
@PerLookup
public class ConfigSniffer extends MicroProfileSniffer {

@Override
public boolean handles(ReadableArchive archive) {
// Defer annotation processing to the deployer to make sure the ConfigProvider is started correctly
return true;
}

@Override
public Class<? extends Annotation>[] getAnnotationTypes() {
return null;
}

@Override
protected Class<?> getContainersClass() {
return ConfigContainer.class;
}

@Override
public String getModuleType() {
return "config";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
* CDI extension that implements the Microprofile Config API ConfigProperty injection
* @author Steve Millidge <Payara Services Limited>
*/
public class CDIExtension implements Extension {
public class ConfigCdiExtension implements Extension {

public void validateInjectionPoint(@Observes ProcessInjectionPoint<?, ?> pip) {

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!--
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.

Copyright (c) [2017-2019] Payara Foundation and/or its affiliates. All rights reserved.
Copyright (c) [2017-2020] Payara Foundation and/or its affiliates. All rights reserved.

The contents of this file are subject to the terms of either the GNU
General Public License Version 2 only ("GPL") or the Common Development
Expand Down Expand Up @@ -80,6 +80,11 @@
<artifactId>microprofile-metrics</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>fish.payara.server.internal.payara-appserver-modules</groupId>
<artifactId>microprofile-connector</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>fish.payara.server.internal.common</groupId>
<artifactId>internal-api</artifactId>
Expand Down
Loading