diff --git a/appserver/packager/microprofile-package/pom.xml b/appserver/packager/microprofile-package/pom.xml index 420a7052d50..5fddd69fb51 100644 --- a/appserver/packager/microprofile-package/pom.xml +++ b/appserver/packager/microprofile-package/pom.xml @@ -2,7 +2,7 @@ diff --git a/appserver/payara-appserver-modules/microprofile/config/pom.xml b/appserver/payara-appserver-modules/microprofile/config/pom.xml index 92c76d6ef3f..c2b5dadb84a 100644 --- a/appserver/payara-appserver-modules/microprofile/config/pom.xml +++ b/appserver/payara-appserver-modules/microprofile/config/pom.xml @@ -63,11 +63,26 @@ microprofile-config-service ${project.version} + + fish.payara.server.internal.payara-appserver-modules + microprofile-connector + ${project.version} + fish.payara.server.internal.common internal-api ${project.version} + + fish.payara.server.internal.web + web-glue + ${project.version} + + + fish.payara.server.internal.web + weld-integration + ${project.version} + jakarta.annotation jakarta.annotation-api diff --git a/appserver/payara-appserver-modules/microprofile/config/src/main/java/fish/payara/microprofile/config/activation/ConfigApplicationContainer.java b/appserver/payara-appserver-modules/microprofile/config/src/main/java/fish/payara/microprofile/config/activation/ConfigApplicationContainer.java new file mode 100644 index 00000000000..d8e64ac57ab --- /dev/null +++ b/appserver/payara-appserver-modules/microprofile/config/src/main/java/fish/payara/microprofile/config/activation/ConfigApplicationContainer.java @@ -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; + } + +} diff --git a/appserver/payara-appserver-modules/microprofile/config/src/main/java/fish/payara/microprofile/config/activation/ConfigContainer.java b/appserver/payara-appserver-modules/microprofile/config/src/main/java/fish/payara/microprofile/config/activation/ConfigContainer.java new file mode 100644 index 00000000000..c91e3034f46 --- /dev/null +++ b/appserver/payara-appserver-modules/microprofile/config/src/main/java/fish/payara/microprofile/config/activation/ConfigContainer.java @@ -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> getDeployer() { + return ConfigDeployer.class; + } + + @Override + public String getName() { + return "ConfigContainer"; + } + +} diff --git a/appserver/payara-appserver-modules/microprofile/config/src/main/java/fish/payara/microprofile/config/activation/ConfigDeployer.java b/appserver/payara-appserver-modules/microprofile/config/src/main/java/fish/payara/microprofile/config/activation/ConfigDeployer.java new file mode 100644 index 00000000000..cb0b29f8aa2 --- /dev/null +++ b/appserver/payara-appserver-modules/microprofile/config/src/main/java/fish/payara/microprofile/config/activation/ConfigDeployer.java @@ -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 { + + @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> 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) { + } + +} diff --git a/appserver/payara-appserver-modules/microprofile/config/src/main/java/fish/payara/microprofile/config/activation/ConfigSniffer.java b/appserver/payara-appserver-modules/microprofile/config/src/main/java/fish/payara/microprofile/config/activation/ConfigSniffer.java new file mode 100644 index 00000000000..c3bf0625ac1 --- /dev/null +++ b/appserver/payara-appserver-modules/microprofile/config/src/main/java/fish/payara/microprofile/config/activation/ConfigSniffer.java @@ -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[] getAnnotationTypes() { + return null; + } + + @Override + protected Class getContainersClass() { + return ConfigContainer.class; + } + + @Override + public String getModuleType() { + return "config"; + } + +} diff --git a/appserver/payara-appserver-modules/microprofile/config/src/main/java/fish/payara/microprofile/config/cdi/CDIExtension.java b/appserver/payara-appserver-modules/microprofile/config/src/main/java/fish/payara/microprofile/config/cdi/ConfigCdiExtension.java similarity index 99% rename from appserver/payara-appserver-modules/microprofile/config/src/main/java/fish/payara/microprofile/config/cdi/CDIExtension.java rename to appserver/payara-appserver-modules/microprofile/config/src/main/java/fish/payara/microprofile/config/cdi/ConfigCdiExtension.java index e0ba844a37f..7582a53f76c 100644 --- a/appserver/payara-appserver-modules/microprofile/config/src/main/java/fish/payara/microprofile/config/cdi/CDIExtension.java +++ b/appserver/payara-appserver-modules/microprofile/config/src/main/java/fish/payara/microprofile/config/cdi/ConfigCdiExtension.java @@ -58,7 +58,7 @@ * CDI extension that implements the Microprofile Config API ConfigProperty injection * @author Steve Millidge */ -public class CDIExtension implements Extension { +public class ConfigCdiExtension implements Extension { public void validateInjectionPoint(@Observes ProcessInjectionPoint pip) { diff --git a/appserver/payara-appserver-modules/microprofile/config/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension b/appserver/payara-appserver-modules/microprofile/config/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension deleted file mode 100644 index 61878986fdb..00000000000 --- a/appserver/payara-appserver-modules/microprofile/config/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension +++ /dev/null @@ -1 +0,0 @@ -fish.payara.microprofile.config.cdi.CDIExtension \ No newline at end of file diff --git a/appserver/payara-appserver-modules/microprofile/fault-tolerance/pom.xml b/appserver/payara-appserver-modules/microprofile/fault-tolerance/pom.xml index c7b0163fe03..b1fc9439c17 100644 --- a/appserver/payara-appserver-modules/microprofile/fault-tolerance/pom.xml +++ b/appserver/payara-appserver-modules/microprofile/fault-tolerance/pom.xml @@ -2,7 +2,7 @@ + + 4.0.0 + + + fish.payara.server.internal.payara-appserver-modules + microprofile + 5.2020.7-SNAPSHOT + + + microprofile-connector + glassfish-jar + + Microprofile - Connector + + + + fish.payara.server.internal.common + internal-api + ${project.version} + + + fish.payara.server.internal.deployment + deployment-common + ${project.version} + + + + + fish.payara.server.internal.web + gf-web-connector + ${project.version} + + + fish.payara.server.internal.ejb + gf-ejb-connector + ${project.version} + + + fish.payara.server.internal.deployment + dol + ${project.version} + + + diff --git a/appserver/payara-appserver-modules/microprofile/microprofile-connector/src/main/java/fish/payara/microprofile/connector/MicroProfileApplicationContainer.java b/appserver/payara-appserver-modules/microprofile/microprofile-connector/src/main/java/fish/payara/microprofile/connector/MicroProfileApplicationContainer.java new file mode 100644 index 00000000000..129bcd4688e --- /dev/null +++ b/appserver/payara-appserver-modules/microprofile/microprofile-connector/src/main/java/fish/payara/microprofile/connector/MicroProfileApplicationContainer.java @@ -0,0 +1,88 @@ +/* + * 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.connector; + +import org.glassfish.api.deployment.ApplicationContainer; +import org.glassfish.api.deployment.ApplicationContext; +import org.glassfish.api.deployment.DeploymentContext; + +public abstract class MicroProfileApplicationContainer implements ApplicationContainer { + + protected final DeploymentContext ctx; + protected final ClassLoader appClassLoader; + protected final String appName; + + public MicroProfileApplicationContainer(DeploymentContext ctx) { + this.ctx = ctx; + this.appClassLoader = ctx.getFinalClassLoader(); + this.appName = ctx.getArchiveHandler().getDefaultApplicationName(ctx.getSource(), ctx); + } + + @Override + public ClassLoader getClassLoader() { + return appClassLoader; + } + + @Override + public Object getDescriptor() { + return ctx.getModuleMetaData(Object.class); + } + + @Override + public boolean start(ApplicationContext ctx) throws Exception { + return true; + } + + @Override + public boolean stop(ApplicationContext ctx) { + return true; + } + + @Override + public boolean resume() throws Exception { + return true; + } + + @Override + public boolean suspend() { + return true; + } + +} diff --git a/appserver/payara-appserver-modules/microprofile/microprofile-connector/src/main/java/fish/payara/microprofile/connector/MicroProfileContainer.java b/appserver/payara-appserver-modules/microprofile/microprofile-connector/src/main/java/fish/payara/microprofile/connector/MicroProfileContainer.java new file mode 100644 index 00000000000..bf13008bb3f --- /dev/null +++ b/appserver/payara-appserver-modules/microprofile/microprofile-connector/src/main/java/fish/payara/microprofile/connector/MicroProfileContainer.java @@ -0,0 +1,48 @@ +/* + * 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.connector; + +import org.glassfish.api.container.Container; +import org.jvnet.hk2.annotations.Contract; + +@Contract +public abstract class MicroProfileContainer implements Container { + +} diff --git a/appserver/payara-appserver-modules/microprofile/microprofile-connector/src/main/java/fish/payara/microprofile/connector/MicroProfileDeployer.java b/appserver/payara-appserver-modules/microprofile/microprofile-connector/src/main/java/fish/payara/microprofile/connector/MicroProfileDeployer.java new file mode 100644 index 00000000000..627137cac05 --- /dev/null +++ b/appserver/payara-appserver-modules/microprofile/microprofile-connector/src/main/java/fish/payara/microprofile/connector/MicroProfileDeployer.java @@ -0,0 +1,69 @@ +/* + * 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.connector; + +import org.glassfish.api.deployment.Deployer; +import org.glassfish.api.deployment.DeploymentContext; +import org.glassfish.api.deployment.MetaData; + +public abstract class MicroProfileDeployer + implements Deployer +{ + + @Override + public MetaData getMetaData() { + return null; + } + + @Override + public V loadMetaData(Class clazz, DeploymentContext deploymentContext) { + return null; + } + + @Override + public boolean prepare(DeploymentContext ctx) { + return true; + } + + @Override + public void clean(DeploymentContext ctx) { + } + +} diff --git a/appserver/payara-appserver-modules/microprofile/microprofile-connector/src/main/java/fish/payara/microprofile/connector/MicroProfileSniffer.java b/appserver/payara-appserver-modules/microprofile/microprofile-connector/src/main/java/fish/payara/microprofile/connector/MicroProfileSniffer.java new file mode 100644 index 00000000000..8e5c023ad12 --- /dev/null +++ b/appserver/payara-appserver-modules/microprofile/microprofile-connector/src/main/java/fish/payara/microprofile/connector/MicroProfileSniffer.java @@ -0,0 +1,157 @@ +/* + * 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.connector; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.logging.Logger; + +import com.sun.enterprise.module.HK2Module; + +import org.glassfish.api.container.Sniffer; +import org.glassfish.api.deployment.DeploymentContext; +import org.glassfish.api.deployment.archive.ArchiveType; +import org.glassfish.api.deployment.archive.ReadableArchive; +import org.glassfish.web.sniffer.WarType; +import org.jvnet.hk2.annotations.Contract; + +@Contract +public abstract class MicroProfileSniffer implements Sniffer { + + private static final Logger LOGGER = Logger.getLogger(MicroProfileSniffer.class.getName()); + + @Override + public boolean handles(DeploymentContext context) { + final ReadableArchive archive = context.getSource(); + + final String archivePath = archive.getURI().getPath(); + // Ignore system applications + if (archivePath.contains("glassfish/lib/install")) { + return false; + } + if (archivePath.contains("h2db/bin")) { + return false; + } + if (archivePath.contains("mq/lib")) { + return false; + } + + return handles(archive); + } + + protected abstract Class getContainersClass(); + + @Override + public final String[] getContainersNames() { + final String[] result = new String[1]; + result[0] = getContainersClass().getName(); + return result; + } + + @Override + public boolean handles(ReadableArchive archive) { + return false; + } + + @Override + public final String[] getURLPatterns() { + return new String[0]; + } + + @Override + public final String[] getAnnotationNames(DeploymentContext ctx) { + final Class[] types = getAnnotationTypes(); + if (types == null) { + return null; + } + final String[] names = new String[types.length]; + for (int i = 0; i < names.length; i++) { + names[i] = types[i].getName(); + } + return names; + } + + @Override + public final HK2Module[] setup(String containerHome, Logger logger) throws IOException { + return new HK2Module[0]; + } + + @Override + public final void tearDown() { + } + + @Override + public final boolean supportsArchiveType(ArchiveType type) { + final String extension = (type == null)? null : type.getExtension(); + switch (extension) { + //case EarType.ARCHIVE_EXTENSION: + case WarType.ARCHIVE_EXTENSION: + //case EjbType.ARCHIVE_EXTENSION: + return true; + default: + LOGGER.fine("Unsupported ArchiveType: " + extension); + } + return false; + } + + @Override + public final String[] getIncompatibleSnifferTypes() { + final String[] types = new String[1]; + types[0] = "connector"; + return types; + } + + @Override + public final boolean isJavaEE() { + return false; + } + + @Override + public final boolean isUserVisible() { + return true; + } + + @Override + public Map getDeploymentConfigurations(ReadableArchive archive) throws IOException { + return new HashMap<>(); + } + +} diff --git a/appserver/payara-appserver-modules/microprofile/openapi/pom.xml b/appserver/payara-appserver-modules/microprofile/openapi/pom.xml index 519ca1f42aa..f31c289845b 100644 --- a/appserver/payara-appserver-modules/microprofile/openapi/pom.xml +++ b/appserver/payara-appserver-modules/microprofile/openapi/pom.xml @@ -2,7 +2,7 @@ opentracing-jaxws microprofile-common + microprofile-connector diff --git a/appserver/tests/payara-samples/test-utils/src/main/resources/arquillian.xml b/appserver/tests/payara-samples/test-utils/src/main/resources/arquillian.xml index d0d2827ee78..b6f8bc98f61 100644 --- a/appserver/tests/payara-samples/test-utils/src/main/resources/arquillian.xml +++ b/appserver/tests/payara-samples/test-utils/src/main/resources/arquillian.xml @@ -8,6 +8,7 @@ ${payara.domain.name} + true diff --git a/appserver/web/gf-web-connector/src/main/java/org/glassfish/web/sniffer/WarDetector.java b/appserver/web/gf-web-connector/src/main/java/org/glassfish/web/sniffer/WarDetector.java index d67a8a3cb42..d54dbca4c00 100644 --- a/appserver/web/gf-web-connector/src/main/java/org/glassfish/web/sniffer/WarDetector.java +++ b/appserver/web/gf-web-connector/src/main/java/org/glassfish/web/sniffer/WarDetector.java @@ -45,9 +45,7 @@ import org.glassfish.api.deployment.archive.ArchiveHandler; import org.glassfish.api.deployment.archive.ArchiveType; import org.glassfish.api.deployment.archive.ReadableArchive; -import org.glassfish.deployment.common.DeploymentUtils; import com.sun.enterprise.deployment.deploy.shared.Util; -import org.glassfish.web.WarType; import javax.inject.Inject; import org.jvnet.hk2.annotations.Service; diff --git a/appserver/web/gf-web-connector/src/main/java/org/glassfish/web/WarType.java b/appserver/web/gf-web-connector/src/main/java/org/glassfish/web/sniffer/WarType.java similarity index 98% rename from appserver/web/gf-web-connector/src/main/java/org/glassfish/web/WarType.java rename to appserver/web/gf-web-connector/src/main/java/org/glassfish/web/sniffer/WarType.java index 047b489a47d..374fe20bd51 100644 --- a/appserver/web/gf-web-connector/src/main/java/org/glassfish/web/WarType.java +++ b/appserver/web/gf-web-connector/src/main/java/org/glassfish/web/sniffer/WarType.java @@ -39,7 +39,7 @@ */ -package org.glassfish.web; +package org.glassfish.web.sniffer; import org.glassfish.api.deployment.archive.ArchiveType; diff --git a/appserver/web/gf-web-connector/src/main/java/org/glassfish/web/sniffer/WebSniffer.java b/appserver/web/gf-web-connector/src/main/java/org/glassfish/web/sniffer/WebSniffer.java index 3380cfab0de..b547b183813 100644 --- a/appserver/web/gf-web-connector/src/main/java/org/glassfish/web/sniffer/WebSniffer.java +++ b/appserver/web/gf-web-connector/src/main/java/org/glassfish/web/sniffer/WebSniffer.java @@ -47,7 +47,6 @@ import org.glassfish.deployment.common.DeploymentUtils; import org.glassfish.hk2.api.ServiceLocator; import org.glassfish.internal.deployment.GenericSniffer; -import org.glassfish.web.WarType; import javax.inject.Inject; import org.jvnet.hk2.annotations.Service; diff --git a/appserver/web/web-glue/src/main/java/org/glassfish/web/deployment/archivist/WebArchivist.java b/appserver/web/web-glue/src/main/java/org/glassfish/web/deployment/archivist/WebArchivist.java index 6fd0043e593..c26d185263a 100644 --- a/appserver/web/web-glue/src/main/java/org/glassfish/web/deployment/archivist/WebArchivist.java +++ b/appserver/web/web-glue/src/main/java/org/glassfish/web/deployment/archivist/WebArchivist.java @@ -61,7 +61,7 @@ import org.glassfish.deployment.common.DeploymentUtils; import org.glassfish.hk2.api.PerLookup; import org.glassfish.web.LogFacade; -import org.glassfish.web.WarType; +import org.glassfish.web.sniffer.WarType; import org.glassfish.web.deployment.descriptor.*; import org.glassfish.web.deployment.io.WebDeploymentDescriptorFile; import org.glassfish.web.deployment.util.*; diff --git a/appserver/web/web-glue/src/main/java/org/glassfish/web/deployment/io/runtime/GFWebRuntimeDDFile.java b/appserver/web/web-glue/src/main/java/org/glassfish/web/deployment/io/runtime/GFWebRuntimeDDFile.java index 113bd960fb6..b239cf754b3 100644 --- a/appserver/web/web-glue/src/main/java/org/glassfish/web/deployment/io/runtime/GFWebRuntimeDDFile.java +++ b/appserver/web/web-glue/src/main/java/org/glassfish/web/deployment/io/runtime/GFWebRuntimeDDFile.java @@ -41,14 +41,14 @@ package org.glassfish.web.deployment.io.runtime; import static com.sun.enterprise.deployment.io.DescriptorConstants.GF_WEB_JAR_ENTRY; -import static org.glassfish.web.WarType.ARCHIVE_TYPE; +import static org.glassfish.web.sniffer.WarType.ARCHIVE_TYPE; import java.util.List; import java.util.Map; import org.glassfish.deployment.common.Descriptor; import org.glassfish.hk2.api.PerLookup; -import org.glassfish.web.WarType; +import org.glassfish.web.sniffer.WarType; import org.glassfish.web.deployment.descriptor.WebBundleDescriptorImpl; import org.glassfish.web.deployment.node.runtime.gf.GFWebBundleRuntimeNode; import org.jvnet.hk2.annotations.Service; diff --git a/appserver/web/web-glue/src/main/java/org/glassfish/web/deployment/io/runtime/PayaraWebRuntimeDDFile.java b/appserver/web/web-glue/src/main/java/org/glassfish/web/deployment/io/runtime/PayaraWebRuntimeDDFile.java index bcae0af5da6..c194ff61b36 100644 --- a/appserver/web/web-glue/src/main/java/org/glassfish/web/deployment/io/runtime/PayaraWebRuntimeDDFile.java +++ b/appserver/web/web-glue/src/main/java/org/glassfish/web/deployment/io/runtime/PayaraWebRuntimeDDFile.java @@ -43,7 +43,7 @@ package org.glassfish.web.deployment.io.runtime; import static com.sun.enterprise.deployment.io.DescriptorConstants.PAYARA_WEB_JAR_ENTRY; -import static org.glassfish.web.WarType.ARCHIVE_TYPE; +import static org.glassfish.web.sniffer.WarType.ARCHIVE_TYPE; import java.util.List; import java.util.Map; diff --git a/appserver/web/web-glue/src/main/java/org/glassfish/web/deployment/io/runtime/WebRuntimeDDFile.java b/appserver/web/web-glue/src/main/java/org/glassfish/web/deployment/io/runtime/WebRuntimeDDFile.java index 271131b94b0..0b2a017a84e 100644 --- a/appserver/web/web-glue/src/main/java/org/glassfish/web/deployment/io/runtime/WebRuntimeDDFile.java +++ b/appserver/web/web-glue/src/main/java/org/glassfish/web/deployment/io/runtime/WebRuntimeDDFile.java @@ -47,7 +47,7 @@ import org.glassfish.deployment.common.Descriptor; import org.glassfish.hk2.api.PerLookup; -import org.glassfish.web.WarType; +import org.glassfish.web.sniffer.WarType; import org.glassfish.web.deployment.descriptor.WebBundleDescriptorImpl; import org.glassfish.web.deployment.node.runtime.gf.WebBundleRuntimeNode; import org.jvnet.hk2.annotations.Service; diff --git a/appserver/web/web-glue/src/main/java/org/glassfish/web/deployment/node/WebBundleNode.java b/appserver/web/web-glue/src/main/java/org/glassfish/web/deployment/node/WebBundleNode.java index 950c569bd9c..196a0c01597 100644 --- a/appserver/web/web-glue/src/main/java/org/glassfish/web/deployment/node/WebBundleNode.java +++ b/appserver/web/web-glue/src/main/java/org/glassfish/web/deployment/node/WebBundleNode.java @@ -59,7 +59,7 @@ import java.util.Map; import java.util.Set; -import org.glassfish.web.WarType; +import org.glassfish.web.sniffer.WarType; import org.glassfish.web.deployment.descriptor.WebBundleDescriptorImpl; import org.glassfish.web.deployment.xml.WebTagNames; import org.w3c.dom.Node; diff --git a/appserver/web/weld-integration/src/main/java/org/glassfish/weld/DeploymentImpl.java b/appserver/web/weld-integration/src/main/java/org/glassfish/weld/DeploymentImpl.java index a732e980157..8b74ec829bf 100644 --- a/appserver/web/weld-integration/src/main/java/org/glassfish/weld/DeploymentImpl.java +++ b/appserver/web/weld-integration/src/main/java/org/glassfish/weld/DeploymentImpl.java @@ -37,7 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ -// Portions Copyright [2016-2019] [Payara Foundation and/or its affiliates] +// Portions Copyright [2016-2020] [Payara Foundation and/or its affiliates] package org.glassfish.weld; @@ -51,6 +51,7 @@ import java.net.URL; import java.util.*; import java.util.concurrent.CopyOnWriteArrayList; +import java.util.function.Supplier; import java.util.logging.Logger; import javax.enterprise.inject.spi.Extension; @@ -73,6 +74,7 @@ import org.jboss.weld.bootstrap.spi.BeansXml; import org.jboss.weld.bootstrap.spi.CDI11Deployment; import org.jboss.weld.bootstrap.spi.Metadata; +import org.jboss.weld.bootstrap.spi.helpers.MetadataImpl; import com.sun.enterprise.deployment.EjbDescriptor; import com.sun.enterprise.deployment.util.DOLUtils; @@ -476,7 +478,7 @@ public Iterable> getExtensions() { HashSet scannedClassLoaders = new HashSet<>(); // ensure we don't add the same extension twice - HashMap> loadedExtensions = new HashMap<>(); + HashMap,Metadata> loadedExtensions = new HashMap<>(); for (BeanDeploymentArchive bda : bdas) { if (!(bda instanceof RootBeanDeploymentArchive)) { @@ -496,6 +498,17 @@ public Iterable> getExtensions() { } } } + + // Load sniffer extensions + @SuppressWarnings("unchecked") + Iterable> snifferExtensions = context.getTransientAppMetaData(WeldDeployer.SNIFFER_EXTENSIONS, Iterable.class); + for (Supplier extensionCreator : snifferExtensions) { + final Extension extension = extensionCreator.get(); + final Class extensionClass = extension.getClass(); + final Metadata extensionMetadata = new MetadataImpl(extension, extensionClass.getName()); + extnList.add(extensionMetadata); + } + extnList.addAll(dynamicExtensions); extensions = extnList; return extnList; diff --git a/appserver/web/weld-integration/src/main/java/org/glassfish/weld/WeldDeployer.java b/appserver/web/weld-integration/src/main/java/org/glassfish/weld/WeldDeployer.java index fbffd26606b..a586c72dba6 100644 --- a/appserver/web/weld-integration/src/main/java/org/glassfish/weld/WeldDeployer.java +++ b/appserver/web/weld-integration/src/main/java/org/glassfish/weld/WeldDeployer.java @@ -76,6 +76,7 @@ import java.util.Optional; import java.util.ServiceLoader; import java.util.Set; +import java.util.function.Supplier; import java.util.logging.Logger; import java.util.stream.Collectors; @@ -151,6 +152,7 @@ public class WeldDeployer extends SimpleDeployer>()); + + return super.prepare(context); + } + /** * Processing in this method is performed for each module that is in the process of being loaded by * the container. diff --git a/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/server/SnifferManagerImpl.java b/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/server/SnifferManagerImpl.java index 785cb70657a..eafb961674e 100644 --- a/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/server/SnifferManagerImpl.java +++ b/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/server/SnifferManagerImpl.java @@ -37,6 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ +// Portions Copyright [2020] Payara Foundation and/or affiliates package com.sun.enterprise.v3.server; @@ -52,13 +53,14 @@ import org.glassfish.internal.deployment.SnifferManager; import com.sun.enterprise.util.LocalStringManagerImpl; -import java.lang.annotation.Annotation; import java.net.URI; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Comparator; import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; /** * Provide convenience methods to deal with {@link Sniffer}s in the system. @@ -67,7 +69,9 @@ */ @Service public class SnifferManagerImpl implements SnifferManager { - final private static LocalStringManagerImpl localStrings = new LocalStringManagerImpl(SnifferManagerImpl.class); + + private static final Logger LOGGER = Logger.getLogger(SnifferManager.class.getName()); + private static final LocalStringManagerImpl localStrings = new LocalStringManagerImpl(SnifferManagerImpl.class); @Inject protected ServiceLocator habitat; @@ -171,7 +175,17 @@ private List getApplicableSniffers(DeploymentContext cont Collection elements = ((AnnotationType) type).allAnnotatedTypes(); for (AnnotatedElement element : elements) { if (checkPath) { - Type t = (element instanceof Member?((Member) element).getDeclaringType():(Type) element); + Type t; + if (element instanceof Member) { + t = ((Member) element).getDeclaringType(); + } else if (element instanceof Type) { + t = (Type) element; + } else if (element instanceof ParameterizedType) { + t = ((ParameterizedType) element).getType(); + } else { + LOGGER.log(Level.WARNING, "Unrecognised type: {0}.", element); + continue; + } if (t.wasDefinedIn(uris)) { result.add(sniffer); break; diff --git a/nucleus/payara-modules/nucleus-microprofile/pom.xml b/nucleus/payara-modules/nucleus-microprofile/pom.xml index 10e424ddb49..4549f7a030e 100644 --- a/nucleus/payara-modules/nucleus-microprofile/pom.xml +++ b/nucleus/payara-modules/nucleus-microprofile/pom.xml @@ -2,7 +2,7 @@