diff --git a/bom/pom.xml b/bom/pom.xml index e8896766..ac8cfd6a 100644 --- a/bom/pom.xml +++ b/bom/pom.xml @@ -88,11 +88,21 @@ kumuluzee-el-uel ${project.version} + + com.kumuluz.ee + kumuluzee-cdi-common + ${project.version} + com.kumuluz.ee kumuluzee-cdi-weld ${project.version} + + com.kumuluz.ee + kumuluzee-cdi-weld-se + ${project.version} + com.kumuluz.ee kumuluzee-jpa-eclipselink diff --git a/components/cdi/common/pom.xml b/components/cdi/common/pom.xml new file mode 100644 index 00000000..bead64cd --- /dev/null +++ b/components/cdi/common/pom.xml @@ -0,0 +1,43 @@ + + 4.0.0 + + com.kumuluz.ee + kumuluzee-cdi + 3.7.0-SNAPSHOT + + kumuluzee-cdi-common + + KumuluzEE CDI Commons + KumuluzEE generic support for CDI + + + + com.kumuluz.ee + kumuluzee-common + + + + javax.enterprise + cdi-api + provided + + + javax.interceptor + javax.interceptor-api + + + javax.el + javax.el-api + + + org.jboss + jandex + + + org.jboss.logging + jboss-logging + + + \ No newline at end of file diff --git a/components/cdi/weld/src/main/java/com/kumuluz/ee/configuration/cdi/ConfigBundle.java b/components/cdi/common/src/main/java/com/kumuluz/ee/configuration/cdi/ConfigBundle.java similarity index 100% rename from components/cdi/weld/src/main/java/com/kumuluz/ee/configuration/cdi/ConfigBundle.java rename to components/cdi/common/src/main/java/com/kumuluz/ee/configuration/cdi/ConfigBundle.java diff --git a/components/cdi/weld/src/main/java/com/kumuluz/ee/configuration/cdi/ConfigValue.java b/components/cdi/common/src/main/java/com/kumuluz/ee/configuration/cdi/ConfigValue.java similarity index 100% rename from components/cdi/weld/src/main/java/com/kumuluz/ee/configuration/cdi/ConfigValue.java rename to components/cdi/common/src/main/java/com/kumuluz/ee/configuration/cdi/ConfigValue.java diff --git a/components/cdi/weld/src/main/java/com/kumuluz/ee/configuration/cdi/interceptors/ConfigBundleInterceptor.java b/components/cdi/common/src/main/java/com/kumuluz/ee/configuration/cdi/interceptors/ConfigBundleInterceptor.java similarity index 100% rename from components/cdi/weld/src/main/java/com/kumuluz/ee/configuration/cdi/interceptors/ConfigBundleInterceptor.java rename to components/cdi/common/src/main/java/com/kumuluz/ee/configuration/cdi/interceptors/ConfigBundleInterceptor.java diff --git a/components/cdi/weld/src/main/java/com/kumuluz/ee/configuration/cdi/producers/ConfigurationUtilProducer.java b/components/cdi/common/src/main/java/com/kumuluz/ee/configuration/cdi/producers/ConfigurationUtilProducer.java similarity index 100% rename from components/cdi/weld/src/main/java/com/kumuluz/ee/configuration/cdi/producers/ConfigurationUtilProducer.java rename to components/cdi/common/src/main/java/com/kumuluz/ee/configuration/cdi/producers/ConfigurationUtilProducer.java diff --git a/components/cdi/weld/src/main/java/com/kumuluz/ee/configuration/cdi/producers/EeConfigProducer.java b/components/cdi/common/src/main/java/com/kumuluz/ee/configuration/cdi/producers/EeConfigProducer.java similarity index 100% rename from components/cdi/weld/src/main/java/com/kumuluz/ee/configuration/cdi/producers/EeConfigProducer.java rename to components/cdi/common/src/main/java/com/kumuluz/ee/configuration/cdi/producers/EeConfigProducer.java diff --git a/components/cdi/weld/src/main/java/com/kumuluz/ee/runtime/cdi/producers/EeRuntimeProducer.java b/components/cdi/common/src/main/java/com/kumuluz/ee/runtime/cdi/producers/EeRuntimeProducer.java similarity index 100% rename from components/cdi/weld/src/main/java/com/kumuluz/ee/runtime/cdi/producers/EeRuntimeProducer.java rename to components/cdi/common/src/main/java/com/kumuluz/ee/runtime/cdi/producers/EeRuntimeProducer.java diff --git a/components/cdi/common/src/main/resources/META-INF/beans.xml b/components/cdi/common/src/main/resources/META-INF/beans.xml new file mode 100644 index 00000000..de235f6c --- /dev/null +++ b/components/cdi/common/src/main/resources/META-INF/beans.xml @@ -0,0 +1,5 @@ + + + \ No newline at end of file diff --git a/components/cdi/pom.xml b/components/cdi/pom.xml index 06e37827..f0c1357b 100644 --- a/components/cdi/pom.xml +++ b/components/cdi/pom.xml @@ -14,7 +14,9 @@ KumuluzEE CDI component + common weld + weld-se kumuluzee-cdi diff --git a/components/cdi/weld-se/pom.xml b/components/cdi/weld-se/pom.xml new file mode 100644 index 00000000..bd1f77ea --- /dev/null +++ b/components/cdi/weld-se/pom.xml @@ -0,0 +1,27 @@ + + 4.0.0 + + com.kumuluz.ee + kumuluzee-cdi + 3.7.0-SNAPSHOT + + kumuluzee-cdi-weld-se + + KumuluzEE CDI Weld SE + KumuluzEE CDI component implemented by Weld for JavaSE environments + + + + com.kumuluz.ee + kumuluzee-cdi-common + + + + org.jboss.weld.se + weld-se-core + ${weld.version} + + + \ No newline at end of file diff --git a/components/cdi/weld-se/src/main/java/com/kumuluz/ee/cdi/CdiSeComponent.java b/components/cdi/weld-se/src/main/java/com/kumuluz/ee/cdi/CdiSeComponent.java new file mode 100644 index 00000000..d6f5fb36 --- /dev/null +++ b/components/cdi/weld-se/src/main/java/com/kumuluz/ee/cdi/CdiSeComponent.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2014-2017 Kumuluz and/or its affiliates + * and other contributors as indicated by the @author tags and + * the contributor list. + * + * Licensed under the MIT License (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://opensource.org/licenses/MIT + * + * The software is provided "AS IS", WITHOUT WARRANTY OF ANY KIND, express or + * implied, including but not limited to the warranties of merchantability, + * fitness for a particular purpose and noninfringement. in no event shall the + * authors or copyright holders be liable for any claim, damages or other + * liability, whether in an action of contract, tort or otherwise, arising from, + * out of or in connection with the software or the use or other dealings in the + * software. See the License for the specific language governing permissions and + * limitations under the License. +*/ +package com.kumuluz.ee.cdi; + +import com.kumuluz.ee.common.Component; +import com.kumuluz.ee.common.config.EeConfig; +import com.kumuluz.ee.common.dependencies.EeComponentDef; +import com.kumuluz.ee.common.dependencies.EeComponentType; +import com.kumuluz.ee.common.wrapper.KumuluzServerWrapper; + +import java.util.logging.Logger; + +/** + * @author Yog Sothoth + * @since 3.5.0 + */ +@EeComponentDef(name = "Weld SE", type = EeComponentType.CDI) +public class CdiSeComponent implements Component { + private Logger log = Logger.getLogger(CdiSeComponent.class.getSimpleName()); + + @Override + public void init(KumuluzServerWrapper server, EeConfig eeConfig) { + } + + @Override + public void load() { + log.info("Initiating Weld SE"); + } +} diff --git a/components/cdi/weld-se/src/main/java/com/kumuluz/se/server/SeServer.java b/components/cdi/weld-se/src/main/java/com/kumuluz/se/server/SeServer.java new file mode 100644 index 00000000..6dc74d5c --- /dev/null +++ b/components/cdi/weld-se/src/main/java/com/kumuluz/se/server/SeServer.java @@ -0,0 +1,94 @@ +package com.kumuluz.se.server; + +import java.util.logging.Logger; + +import javax.enterprise.inject.se.SeContainer; +import javax.enterprise.inject.se.SeContainerInitializer; + +import com.kumuluz.ee.common.KumuluzServer; +import com.kumuluz.ee.common.config.ServerConfig; +import com.kumuluz.ee.common.dependencies.ServerDef; + +/** + * NoOp Kumuluz server that serves as CDI SE container + * + * @author Yog Sothoth + * + */ +@ServerDef(value = "CDI No-Web server") +public class SeServer implements KumuluzServer { + private static final Logger LOG = Logger.getLogger(SeServer.class.getSimpleName()); + + private final SeContainerInitializer initializer = SeContainerInitializer.newInstance(); + private SeContainer ctx; + private ServerConfig serverConfig; + + /* + * (non-Javadoc) + * + * @see com.kumuluz.ee.common.KumuluzServer#initServer() + */ + @Override + public void initServer() { + LOG.info("Initializing SE server"); + try { + this.ctx = initializer.initialize(); + } catch (UnsupportedOperationException uoe) { + throw new IllegalStateException("Can't start CDI SE within a servlet environment"); + } + + Runtime.getRuntime().addShutdownHook(new Thread(this::stopServer)); + } + + /* + * (non-Javadoc) + * + * @see com.kumuluz.ee.common.KumuluzServer#startServer() + */ + @Override + public void startServer() { + LOG.info("Starting SE server"); + + if (ctx.getBeanManager() == null) { + throw new IllegalStateException("CDI Bean Manager isn't initialized"); + } + } + + /* + * (non-Javadoc) + * + * @see com.kumuluz.ee.common.KumuluzServer#stopServer() + */ + @Override + public void stopServer() { + LOG.info("Stopping SE server"); + + synchronized (ctx) { + if (ctx.isRunning()) { + ctx.close(); + } + } + } + + /* + * (non-Javadoc) + * + * @see + * com.kumuluz.ee.common.KumuluzServer#setServerConfig(com.kumuluz.ee.common. + * config.ServerConfig) + */ + @Override + public void setServerConfig(ServerConfig serverConfig) { + this.serverConfig = serverConfig; + } + + /* + * (non-Javadoc) + * + * @see com.kumuluz.ee.common.KumuluzServer#getServerConfig() + */ + @Override + public ServerConfig getServerConfig() { + return serverConfig; + } +} diff --git a/components/cdi/weld-se/src/main/resources/META-INF/beans.xml b/components/cdi/weld-se/src/main/resources/META-INF/beans.xml new file mode 100644 index 00000000..de235f6c --- /dev/null +++ b/components/cdi/weld-se/src/main/resources/META-INF/beans.xml @@ -0,0 +1,5 @@ + + + \ No newline at end of file diff --git a/components/cdi/weld-se/src/main/resources/META-INF/services/com.kumuluz.ee.common.Component b/components/cdi/weld-se/src/main/resources/META-INF/services/com.kumuluz.ee.common.Component new file mode 100644 index 00000000..fe894ec6 --- /dev/null +++ b/components/cdi/weld-se/src/main/resources/META-INF/services/com.kumuluz.ee.common.Component @@ -0,0 +1 @@ +com.kumuluz.ee.cdi.CdiSeComponent \ No newline at end of file diff --git a/components/cdi/weld-se/src/main/resources/META-INF/services/com.kumuluz.ee.common.KumuluzServer b/components/cdi/weld-se/src/main/resources/META-INF/services/com.kumuluz.ee.common.KumuluzServer new file mode 100644 index 00000000..7430e2ac --- /dev/null +++ b/components/cdi/weld-se/src/main/resources/META-INF/services/com.kumuluz.ee.common.KumuluzServer @@ -0,0 +1 @@ +com.kumuluz.se.server.SeServer \ No newline at end of file diff --git a/components/cdi/weld/pom.xml b/components/cdi/weld/pom.xml index 0c5b14b1..65fe928e 100644 --- a/components/cdi/weld/pom.xml +++ b/components/cdi/weld/pom.xml @@ -15,20 +15,11 @@ kumuluzee-cdi-weld - - com.kumuluz.ee - kumuluzee-common - - - - javax.interceptor - javax.interceptor-api - - - javax.el - javax.el-api - - + + com.kumuluz.ee + kumuluzee-cdi-common + + org.jboss.weld.servlet weld-servlet-core @@ -52,14 +43,6 @@ - - org.jboss - jandex - - - org.jboss.logging - jboss-logging - org.glassfish.jersey.ext.cdi @@ -83,7 +66,5 @@ - - \ No newline at end of file diff --git a/pom.xml b/pom.xml index ab7f4c6b..604808b9 100644 --- a/pom.xml +++ b/pom.xml @@ -183,11 +183,21 @@ ${project.version} pom + + com.kumuluz.ee + kumuluzee-cdi-common + ${project.version} + com.kumuluz.ee kumuluzee-cdi-weld ${project.version} + + com.kumuluz.ee + kumuluzee-cdi-weld-se + ${project.version} + com.kumuluz.ee kumuluzee-jpa