diff --git a/kumuluz-se/pom.xml b/kumuluz-se/pom.xml new file mode 100644 index 00000000..8978b7e2 --- /dev/null +++ b/kumuluz-se/pom.xml @@ -0,0 +1,60 @@ + + 4.0.0 + + kumuluzee-samples + com.kumuluz.ee.samples + 3.6.0-SNAPSHOT + + + kumuluz-se-sample + + KumuluzEE SE sample + JavaSE usage with KumuluzEE + + + + + com.kumuluz.ee + kumuluzee-bom + ${kumuluzee.version} + pom + import + + + + + + + com.kumuluz.ee + kumuluzee-core + + + com.kumuluz.ee + kumuluzee-cdi-weld-se + + + com.kumuluz.ee + kumuluzee-loader + true + + + + + + + com.kumuluz.ee + kumuluzee-maven-plugin + ${kumuluzee.version} + + + package + + repackage + + + + + + \ No newline at end of file diff --git a/kumuluz-se/src/main/java/com/kumuluz/se/samples/ConfigProps.java b/kumuluz-se/src/main/java/com/kumuluz/se/samples/ConfigProps.java new file mode 100644 index 00000000..c8b55f6a --- /dev/null +++ b/kumuluz-se/src/main/java/com/kumuluz/se/samples/ConfigProps.java @@ -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; + } +} diff --git a/kumuluz-se/src/main/java/com/kumuluz/se/samples/UserBean.java b/kumuluz-se/src/main/java/com/kumuluz/se/samples/UserBean.java new file mode 100644 index 00000000..0d1774e8 --- /dev/null +++ b/kumuluz-se/src/main/java/com/kumuluz/se/samples/UserBean.java @@ -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!"); + } +} diff --git a/kumuluz-se/src/main/resources/META-INF/beans.xml b/kumuluz-se/src/main/resources/META-INF/beans.xml new file mode 100644 index 00000000..db1d5581 --- /dev/null +++ b/kumuluz-se/src/main/resources/META-INF/beans.xml @@ -0,0 +1,6 @@ + + \ No newline at end of file diff --git a/kumuluz-se/src/main/resources/config.yml b/kumuluz-se/src/main/resources/config.yml new file mode 100644 index 00000000..06310ae2 --- /dev/null +++ b/kumuluz-se/src/main/resources/config.yml @@ -0,0 +1,2 @@ +my-props: + property: Running SE envinronment! \ No newline at end of file diff --git a/pom.xml b/pom.xml index 4eb566f0..4fcb3301 100644 --- a/pom.xml +++ b/pom.xml @@ -54,6 +54,7 @@ kumuluzee-amqp-rabbitmq kumuluzee-version kumuluzee-feature-flags-unleash + kumuluz-se pom