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

Kumuluz SE sample #25

Open
wants to merge 2 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
60 changes: 60 additions & 0 deletions kumuluz-se/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<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>
<artifactId>kumuluzee-samples</artifactId>
<groupId>com.kumuluz.ee.samples</groupId>
<version>3.6.0-SNAPSHOT</version>
</parent>

<artifactId>kumuluz-se-sample</artifactId>

<name>KumuluzEE SE sample</name>
<description>JavaSE usage with KumuluzEE</description>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.kumuluz.ee</groupId>
<artifactId>kumuluzee-bom</artifactId>
<version>${kumuluzee.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>com.kumuluz.ee</groupId>
<artifactId>kumuluzee-core</artifactId>
</dependency>
<dependency>
<groupId>com.kumuluz.ee</groupId>
<artifactId>kumuluzee-cdi-weld-se</artifactId>
</dependency>
<dependency>
<groupId>com.kumuluz.ee</groupId>
<artifactId>kumuluzee-loader</artifactId>
<optional>true</optional>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>com.kumuluz.ee</groupId>
<artifactId>kumuluzee-maven-plugin</artifactId>
<version>${kumuluzee.version}</version>
<executions>
<execution>
<id>package</id>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build></project>
19 changes: 19 additions & 0 deletions kumuluz-se/src/main/java/com/kumuluz/se/samples/ConfigProps.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.kumuluz.se.samples;

import javax.enterprise.context.ApplicationScoped;

import com.kumuluz.ee.configuration.cdi.ConfigBundle;

@ApplicationScoped
@ConfigBundle("my-props")
public class ConfigProps {
private String property;

public String getProperty() {
return property;
}

public void setProperty(String property) {
this.property = property;
}
}
36 changes: 36 additions & 0 deletions kumuluz-se/src/main/java/com/kumuluz/se/samples/UserBean.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.kumuluz.se.samples;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.logging.Logger;

import javax.annotation.PostConstruct;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.context.Initialized;
import javax.enterprise.event.Observes;
import javax.inject.Inject;

@ApplicationScoped
public class UserBean {
private static final Logger LOGGER = Logger.getLogger(UserBean.class.getCanonicalName());

private final ScheduledExecutorService exec = Executors.newScheduledThreadPool(1);

@Inject
private ConfigProps properties;

@PostConstruct
public void afterConstruct() {
//Your app has to continuously do stuff, otherwise Weld will terminate it
exec.scheduleAtFixedRate(this::alive, 1, 1, TimeUnit.SECONDS);
}

public void onInit(@Observes @Initialized(ApplicationScoped.class) Object init) {
LOGGER.info(properties.getProperty());
}

private void alive() {
LOGGER.info("I'm alive!");
}
}
6 changes: 6 additions & 0 deletions kumuluz-se/src/main/resources/META-INF/beans.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<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 kumuluz-se/src/main/resources/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
my-props:
property: Running SE envinronment!
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
<module>kumuluzee-amqp-rabbitmq</module>
<module>kumuluzee-version</module>
<module>kumuluzee-feature-flags-unleash</module>
<module>kumuluz-se</module>
</modules>

<packaging>pom</packaging>
Expand Down