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 1 commit
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
5 changes: 5 additions & 0 deletions bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@
<artifactId>kumuluzee-javamail-ri</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.kumuluz.ee</groupId>
<artifactId>kumuluz-server-se</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down
11 changes: 11 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<module>common</module>
<module>core</module>
<module>servlet</module>
<module>se</module>
<module>components</module>
<module>bom</module>
<module>profiles</module>
Expand Down Expand Up @@ -345,6 +346,16 @@
<version>${project.version}</version>
<type>maven-plugin</type>
</dependency>
<dependency>
<groupId>com.kumuluz.ee</groupId>
<artifactId>kumuluz-se</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.kumuluz.ee</groupId>
<artifactId>kumuluz-server-se</artifactId>
<version>${project.version}</version>
</dependency>

<!-- Java EE specification dependencies-->
<dependency>
Expand Down
22 changes: 22 additions & 0 deletions se/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<parent>
<artifactId>kumuluzee</artifactId>
<groupId>com.kumuluz.ee</groupId>
<version>3.6.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>pom</packaging>

<modules>
<module>server</module>
</modules>

<name>KumuluzEE for SE</name>
<description>KumuluzEE support for running within Java SE env</description>

<artifactId>kumuluz-se</artifactId>

</project>
60 changes: 60 additions & 0 deletions se/server/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="UTF-8"?>
<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>
<artifactId>kumuluz-server-se</artifactId>
ikonkere marked this conversation as resolved.
Show resolved Hide resolved
<parent>
<artifactId>kumuluz-se</artifactId>
<groupId>com.kumuluz.ee</groupId>
<version>3.6.0-SNAPSHOT</version>
</parent>

<name>KumuluzEE SE server</name>
<description>KumuluzEE server for Java SE env</description>

<dependencies>
<dependency>
ikonkere marked this conversation as resolved.
Show resolved Hide resolved
<groupId>com.kumuluz.ee</groupId>
ikonkere marked this conversation as resolved.
Show resolved Hide resolved
<artifactId>kumuluzee-cdi-weld</artifactId>
<exclusions>
<exclusion>
<groupId>org.glassfish.jersey.ext.cdi</groupId>
<artifactId>jersey-cdi1x</artifactId>
</exclusion>
<exclusion>
<groupId>org.glassfish.jersey.ext.cdi</groupId>
<artifactId>jersey-cdi1x-ban-custom-hk2-binding</artifactId>
</exclusion>
<exclusion>
<groupId>org.jboss.weld.servlet</groupId>
<artifactId>weld-servlet-core</artifactId>
</exclusion>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
</exclusion>
<exclusion>
<groupId>javax.transaction</groupId>
<artifactId>javax.transaction-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.jboss.weld.se</groupId>
<artifactId>weld-se-core</artifactId>
<version>${weld.version}</version>
</dependency>
<dependency>
<groupId>com.kumuluz.ee</groupId>
<artifactId>kumuluzee-loader</artifactId>
<optional>true</optional>
</dependency>
<dependency>
ikonkere marked this conversation as resolved.
Show resolved Hide resolved
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
92 changes: 92 additions & 0 deletions se/server/src/main/java/com/kumuluz/se/server/SeServer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
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.EeComponentDependency;
import com.kumuluz.ee.common.dependencies.EeComponentType;
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")
@EeComponentDependency(EeComponentType.CDI)
public class SeServer implements KumuluzServer {
private static final Logger log = Logger.getLogger(SeServer.class.getSimpleName());
ikonkere marked this conversation as resolved.
Show resolved Hide resolved

private final SeContainerInitializer initializer =
ikonkere marked this conversation as resolved.
Show resolved Hide resolved
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;
ikonkere marked this conversation as resolved.
Show resolved Hide resolved
}

/*
* (non-Javadoc)
* @see com.kumuluz.ee.common.KumuluzServer#getServerConfig()
*/
@Override
public ServerConfig getServerConfig() {
return serverConfig;
ikonkere marked this conversation as resolved.
Show resolved Hide resolved
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
com.kumuluz.se.server.SeServer