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

Java SE support #150

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 10 additions & 0 deletions bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,21 @@
<artifactId>kumuluzee-el-uel</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.kumuluz.ee</groupId>
<artifactId>kumuluzee-cdi-common</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.kumuluz.ee</groupId>
<artifactId>kumuluzee-cdi-weld</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.kumuluz.ee</groupId>
<artifactId>kumuluzee-cdi-weld-se</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.kumuluz.ee</groupId>
<artifactId>kumuluzee-jpa-eclipselink</artifactId>
Expand Down
43 changes: 43 additions & 0 deletions components/cdi/common/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.kumuluz.ee</groupId>
<artifactId>kumuluzee-cdi</artifactId>
<version>3.7.0-SNAPSHOT</version>
</parent>
<artifactId>kumuluzee-cdi-common</artifactId>

<name>KumuluzEE CDI Commons</name>
<description>KumuluzEE generic support for CDI</description>

<dependencies>
<dependency>
<groupId>com.kumuluz.ee</groupId>
<artifactId>kumuluzee-common</artifactId>
</dependency>

<dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.interceptor</groupId>
<artifactId>javax.interceptor-api</artifactId>
</dependency>
<dependency>
<groupId>javax.el</groupId>
<artifactId>javax.el-api</artifactId>
</dependency>
<dependency>
<groupId>org.jboss</groupId>
<artifactId>jandex</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging</artifactId>
</dependency>
</dependencies>
</project>
5 changes: 5 additions & 0 deletions components/cdi/common/src/main/resources/META-INF/beans.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
bean-discovery-mode="annotated">
</beans>
2 changes: 2 additions & 0 deletions components/cdi/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
<description>KumuluzEE CDI component</description>

<modules>
<module>common</module>
<module>weld</module>
<module>weld-se</module>
</modules>

<artifactId>kumuluzee-cdi</artifactId>
Expand Down
27 changes: 27 additions & 0 deletions components/cdi/weld-se/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.kumuluz.ee</groupId>
<artifactId>kumuluzee-cdi</artifactId>
<version>3.7.0-SNAPSHOT</version>
</parent>
<artifactId>kumuluzee-cdi-weld-se</artifactId>

<name>KumuluzEE CDI Weld SE</name>
<description>KumuluzEE CDI component implemented by Weld for JavaSE environments</description>

<dependencies>
<dependency>
<groupId>com.kumuluz.ee</groupId>
<artifactId>kumuluzee-cdi-common</artifactId>
</dependency>

<dependency>
<groupId>org.jboss.weld.se</groupId>
<artifactId>weld-se-core</artifactId>
<version>${weld.version}</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -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");
}
}
Original file line number Diff line number Diff line change
@@ -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;
}
}
5 changes: 5 additions & 0 deletions components/cdi/weld-se/src/main/resources/META-INF/beans.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
bean-discovery-mode="annotated">
</beans>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
com.kumuluz.ee.cdi.CdiSeComponent
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
com.kumuluz.se.server.SeServer
29 changes: 5 additions & 24 deletions components/cdi/weld/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,11 @@
<artifactId>kumuluzee-cdi-weld</artifactId>

<dependencies>
<dependency>
<groupId>com.kumuluz.ee</groupId>
<artifactId>kumuluzee-common</artifactId>
</dependency>

<dependency>
<groupId>javax.interceptor</groupId>
<artifactId>javax.interceptor-api</artifactId>
</dependency>
<dependency>
<groupId>javax.el</groupId>
<artifactId>javax.el-api</artifactId>
</dependency>

<dependency>
<groupId>com.kumuluz.ee</groupId>
<artifactId>kumuluzee-cdi-common</artifactId>
</dependency>

<dependency>
<groupId>org.jboss.weld.servlet</groupId>
<artifactId>weld-servlet-core</artifactId>
Expand All @@ -52,14 +43,6 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.jboss</groupId>
<artifactId>jandex</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging</artifactId>
</dependency>

<dependency>
<groupId>org.glassfish.jersey.ext.cdi</groupId>
Expand All @@ -83,7 +66,5 @@
</exclusion>
</exclusions>
</dependency>

</dependencies>

</project>
10 changes: 10 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,21 @@
<version>${project.version}</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>com.kumuluz.ee</groupId>
<artifactId>kumuluzee-cdi-common</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.kumuluz.ee</groupId>
<artifactId>kumuluzee-cdi-weld</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.kumuluz.ee</groupId>
<artifactId>kumuluzee-cdi-weld-se</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.kumuluz.ee</groupId>
<artifactId>kumuluzee-jpa</artifactId>
Expand Down