diff --git a/.gitignore b/.gitignore index 705e4d3..e882453 100644 --- a/.gitignore +++ b/.gitignore @@ -7,5 +7,5 @@ release.properties dependency-reduced-pom.xml buildNumber.properties .idea -*.log +*.log* *.iml \ No newline at end of file diff --git a/demos/openalt-2015/pom.xml b/demos/openalt-2015/pom.xml index 30911af..5993c3b 100644 --- a/demos/openalt-2015/pom.xml +++ b/demos/openalt-2015/pom.xml @@ -3,7 +3,7 @@ io.silverware.demos demos-parent - 1.0-SNAPSHOT + 1.0 openalt-2015 jar diff --git a/demos/pom.xml b/demos/pom.xml index ad73578..5f597ef 100644 --- a/demos/pom.xml +++ b/demos/pom.xml @@ -2,7 +2,7 @@ 4.0.0 io.silverware.demos demos-parent - 1.0-SNAPSHOT + 1.0 pom SilverWare Demos Parent Parent pom of SilverWare Demos. @@ -115,6 +115,8 @@ lib/ + ${project.version} + ${project.version} diff --git a/quickstarts/camel-cdi-helloworld/README.md b/quickstarts/camel-cdi-helloworld/README.md new file mode 100644 index 0000000..020fb74 --- /dev/null +++ b/quickstarts/camel-cdi-helloworld/README.md @@ -0,0 +1,4 @@ +Shows integration of Camel and CDI using camel-cdi component. + +mvn clean package +mvn exec:exec \ No newline at end of file diff --git a/quickstarts/camel-cdi-helloworld/log4j2.xml b/quickstarts/camel-cdi-helloworld/log4j2.xml new file mode 100644 index 0000000..b02aef5 --- /dev/null +++ b/quickstarts/camel-cdi-helloworld/log4j2.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/quickstarts/camel-cdi-helloworld/pom.xml b/quickstarts/camel-cdi-helloworld/pom.xml new file mode 100644 index 0000000..248531e --- /dev/null +++ b/quickstarts/camel-cdi-helloworld/pom.xml @@ -0,0 +1,46 @@ + + 4.0.0 + + io.silverware.demos.quickstarts + quickstarts-parent + 1.0 + + camel-cdi-helloworld + jar + + + io.silverware + microservices + + + io.silverware + cdi-microservice-provider + + + io.silverware + camel-microservice-provider + + + io.silverware + camel-cdi-integration + + + org.apache.camel + camel-stream + + + org.testng + testng + test + + + + + + org.apache.maven.plugins + maven-dependency-plugin + ${version.maven.dependency.plugin} + + + + \ No newline at end of file diff --git a/quickstarts/camel-cdi-helloworld/src/main/java/io/silverware/demos/quickstarts/cdi/CamelCdiMicroservice.java b/quickstarts/camel-cdi-helloworld/src/main/java/io/silverware/demos/quickstarts/cdi/CamelCdiMicroservice.java new file mode 100644 index 0000000..ae2d2b8 --- /dev/null +++ b/quickstarts/camel-cdi-helloworld/src/main/java/io/silverware/demos/quickstarts/cdi/CamelCdiMicroservice.java @@ -0,0 +1,59 @@ +/* + * -----------------------------------------------------------------------\ + * SilverWare + *   + * Copyright (C) 2010 - 2013 the original author or authors. + *   + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * -----------------------------------------------------------------------/ + */ +package io.silverware.demos.quickstarts.cdi; + +import io.silverware.microservices.annotations.Microservice; +import io.silverware.microservices.providers.cdi.MicroservicesStartedEvent; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import javax.annotation.PostConstruct; +import javax.enterprise.event.Observes; + +/** + * @author Martin Večeřa + */ +@Microservice("camelCdiMicroservice") +public class CamelCdiMicroservice { + + private static final Logger log = LogManager.getLogger(CamelCdiMicroservice.class); + + public CamelCdiMicroservice() { + log.info("CamelCdiMicroservice constructor"); + } + + @PostConstruct + public void onInit() { + log.info("CamelCdiMicroservice PostConstruct " + this.getClass().getName()); + } + + public void hello() { + log.info("CamelCdiMicroservice Hello"); + } + + public String sayHello(final String msg) { + return "Answering '" + msg + "' with 'How do you do!'"; + } + + public void eventObserver(@Observes MicroservicesStartedEvent event) { + log.info("CamelCdiMicroservice MicroservicesStartedEvent"); + } +} \ No newline at end of file diff --git a/quickstarts/camel-cdi-helloworld/src/main/java/io/silverware/demos/quickstarts/cdi/CamelCdiRoute.java b/quickstarts/camel-cdi-helloworld/src/main/java/io/silverware/demos/quickstarts/cdi/CamelCdiRoute.java new file mode 100644 index 0000000..f0a11a6 --- /dev/null +++ b/quickstarts/camel-cdi-helloworld/src/main/java/io/silverware/demos/quickstarts/cdi/CamelCdiRoute.java @@ -0,0 +1,37 @@ +/* + * -----------------------------------------------------------------------\ + * SilverWare + *   + * Copyright (C) 2010 - 2013 the original author or authors. + *   + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * -----------------------------------------------------------------------/ + */ +package io.silverware.demos.quickstarts.cdi; + +import org.apache.camel.builder.RouteBuilder; + +/** + * @author Martin Večeřa + */ +public class CamelCdiRoute extends RouteBuilder { + + @Override + public void configure() throws Exception { + from("timer://foo?period=2000") + .setBody().simple("Hello from Camel Timer!") + .beanRef("camelCdiMicroservice", "sayHello") + .to("log:test").to("stream:out"); + } + +} \ No newline at end of file diff --git a/quickstarts/camel-cdi-helloworld/src/main/resources/META-INF/beans.xml b/quickstarts/camel-cdi-helloworld/src/main/resources/META-INF/beans.xml new file mode 100644 index 0000000..e69de29 diff --git a/quickstarts/camel-helloworld-xml/README.md b/quickstarts/camel-helloworld-xml/README.md index f407f9d..709a625 100644 --- a/quickstarts/camel-helloworld-xml/README.md +++ b/quickstarts/camel-helloworld-xml/README.md @@ -1,2 +1,4 @@ +Microservice represented by Apache Camel as a route specified in an XML file. + mvn clean package java -jar target/camel-helloworld-*.jar diff --git a/quickstarts/camel-helloworld-xml/log4j2.xml b/quickstarts/camel-helloworld-xml/log4j2.xml new file mode 100644 index 0000000..b02aef5 --- /dev/null +++ b/quickstarts/camel-helloworld-xml/log4j2.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/quickstarts/camel-helloworld-xml/pom.xml b/quickstarts/camel-helloworld-xml/pom.xml index 20912f0..f78a688 100644 --- a/quickstarts/camel-helloworld-xml/pom.xml +++ b/quickstarts/camel-helloworld-xml/pom.xml @@ -3,7 +3,7 @@ io.silverware.demos.quickstarts quickstarts-parent - 1.0-SNAPSHOT + 1.0 camel-helloworld-xml jar diff --git a/quickstarts/camel-helloworld/README.md b/quickstarts/camel-helloworld/README.md index f407f9d..7df90c3 100644 --- a/quickstarts/camel-helloworld/README.md +++ b/quickstarts/camel-helloworld/README.md @@ -1,2 +1,4 @@ +Microservice represented by Apache Camel as a route specified in a Java class. + mvn clean package java -jar target/camel-helloworld-*.jar diff --git a/quickstarts/camel-helloworld/log4j2.xml b/quickstarts/camel-helloworld/log4j2.xml new file mode 100644 index 0000000..b02aef5 --- /dev/null +++ b/quickstarts/camel-helloworld/log4j2.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/quickstarts/camel-helloworld/pom.xml b/quickstarts/camel-helloworld/pom.xml index 104e69f..6afe366 100644 --- a/quickstarts/camel-helloworld/pom.xml +++ b/quickstarts/camel-helloworld/pom.xml @@ -3,7 +3,7 @@ io.silverware.demos.quickstarts quickstarts-parent - 1.0-SNAPSHOT + 1.0 camel-helloworld jar diff --git a/quickstarts/camel-jetty-cdi/README.md b/quickstarts/camel-jetty-cdi/README.md new file mode 100644 index 0000000..c250388 --- /dev/null +++ b/quickstarts/camel-jetty-cdi/README.md @@ -0,0 +1,4 @@ +Exposes a CDI service with a REST interface using Camel Jetty component. + +mvn clean package +mvn exec:exec \ No newline at end of file diff --git a/quickstarts/camel-jetty-cdi/log4j2.xml b/quickstarts/camel-jetty-cdi/log4j2.xml new file mode 100644 index 0000000..b02aef5 --- /dev/null +++ b/quickstarts/camel-jetty-cdi/log4j2.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/quickstarts/camel-jetty-cdi/pom.xml b/quickstarts/camel-jetty-cdi/pom.xml new file mode 100644 index 0000000..3636d07 --- /dev/null +++ b/quickstarts/camel-jetty-cdi/pom.xml @@ -0,0 +1,41 @@ + + 4.0.0 + + io.silverware.demos.quickstarts + quickstarts-parent + 1.0 + + camel-jetty-cdi + jar + + + io.silverware + microservices + + + io.silverware + cdi-microservice-provider + + + io.silverware + camel-microservice-provider + + + io.silverware + camel-cdi-integration + + + org.apache.camel + camel-jetty + + + + + + org.apache.maven.plugins + maven-dependency-plugin + ${version.maven.dependency.plugin} + + + + \ No newline at end of file diff --git a/quickstarts/camel-jetty-cdi/src/main/java/io/silverware/demos/quickstarts/cdi/CamelCdiMicroservice.java b/quickstarts/camel-jetty-cdi/src/main/java/io/silverware/demos/quickstarts/cdi/CamelCdiMicroservice.java new file mode 100644 index 0000000..ae2d2b8 --- /dev/null +++ b/quickstarts/camel-jetty-cdi/src/main/java/io/silverware/demos/quickstarts/cdi/CamelCdiMicroservice.java @@ -0,0 +1,59 @@ +/* + * -----------------------------------------------------------------------\ + * SilverWare + *   + * Copyright (C) 2010 - 2013 the original author or authors. + *   + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * -----------------------------------------------------------------------/ + */ +package io.silverware.demos.quickstarts.cdi; + +import io.silverware.microservices.annotations.Microservice; +import io.silverware.microservices.providers.cdi.MicroservicesStartedEvent; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import javax.annotation.PostConstruct; +import javax.enterprise.event.Observes; + +/** + * @author Martin Večeřa + */ +@Microservice("camelCdiMicroservice") +public class CamelCdiMicroservice { + + private static final Logger log = LogManager.getLogger(CamelCdiMicroservice.class); + + public CamelCdiMicroservice() { + log.info("CamelCdiMicroservice constructor"); + } + + @PostConstruct + public void onInit() { + log.info("CamelCdiMicroservice PostConstruct " + this.getClass().getName()); + } + + public void hello() { + log.info("CamelCdiMicroservice Hello"); + } + + public String sayHello(final String msg) { + return "Answering '" + msg + "' with 'How do you do!'"; + } + + public void eventObserver(@Observes MicroservicesStartedEvent event) { + log.info("CamelCdiMicroservice MicroservicesStartedEvent"); + } +} \ No newline at end of file diff --git a/quickstarts/camel-jetty-cdi/src/main/java/io/silverware/demos/quickstarts/cdi/CamelCdiRoute.java b/quickstarts/camel-jetty-cdi/src/main/java/io/silverware/demos/quickstarts/cdi/CamelCdiRoute.java new file mode 100644 index 0000000..6cc934f --- /dev/null +++ b/quickstarts/camel-jetty-cdi/src/main/java/io/silverware/demos/quickstarts/cdi/CamelCdiRoute.java @@ -0,0 +1,35 @@ +/* + * -----------------------------------------------------------------------\ + * SilverWare + *   + * Copyright (C) 2010 - 2013 the original author or authors. + *   + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * -----------------------------------------------------------------------/ + */ +package io.silverware.demos.quickstarts.cdi; + +import org.apache.camel.builder.RouteBuilder; + +/** + * @author Martin Večeřa + */ +public class CamelCdiRoute extends RouteBuilder { + + @Override + public void configure() throws Exception { + from("jetty:http://localhost:8082/camel") + .beanRef("camelCdiMicroservice", "sayHello"); + } + +} \ No newline at end of file diff --git a/quickstarts/camel-jetty-cdi/src/main/resources/META-INF/beans.xml b/quickstarts/camel-jetty-cdi/src/main/resources/META-INF/beans.xml new file mode 100644 index 0000000..e69de29 diff --git a/quickstarts/cdi-helloworld/README.md b/quickstarts/cdi-helloworld/README.md index 400792f..5931c60 100644 --- a/quickstarts/cdi-helloworld/README.md +++ b/quickstarts/cdi-helloworld/README.md @@ -1,2 +1,4 @@ +Sample CDI Microservice demonstrating lifecycle events and handlers. + mvn clean package java -jar target/cdi-helloworld-*.jar diff --git a/quickstarts/cdi-helloworld/log4j2.xml b/quickstarts/cdi-helloworld/log4j2.xml new file mode 100644 index 0000000..b02aef5 --- /dev/null +++ b/quickstarts/cdi-helloworld/log4j2.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/quickstarts/cdi-helloworld/pom.xml b/quickstarts/cdi-helloworld/pom.xml index c8f03d4..c968a76 100644 --- a/quickstarts/cdi-helloworld/pom.xml +++ b/quickstarts/cdi-helloworld/pom.xml @@ -3,7 +3,7 @@ io.silverware.demos.quickstarts quickstarts-parent - 1.0-SNAPSHOT + 1.0 cdi-helloworld jar diff --git a/quickstarts/cdi-helloworld/src/main/java/io/silverware/demos/quickstarts/cdi/CdiHelloWorldMicroservice.java b/quickstarts/cdi-helloworld/src/main/java/io/silverware/demos/quickstarts/cdi/CdiHelloWorldMicroservice.java index be5bff4..93c1320 100644 --- a/quickstarts/cdi-helloworld/src/main/java/io/silverware/demos/quickstarts/cdi/CdiHelloWorldMicroservice.java +++ b/quickstarts/cdi-helloworld/src/main/java/io/silverware/demos/quickstarts/cdi/CdiHelloWorldMicroservice.java @@ -31,7 +31,7 @@ import org.apache.logging.log4j.Logger; /** - * @author Martin Večeřa + * @author Martin Večeřa */ @Microservice public class CdiHelloWorldMicroservice { diff --git a/quickstarts/deltaspike-config/README.md b/quickstarts/deltaspike-config/README.md new file mode 100644 index 0000000..2f87394 --- /dev/null +++ b/quickstarts/deltaspike-config/README.md @@ -0,0 +1,13 @@ +This quickstart shows integration with Apache DeltaSpike + +$ mvn clean package +$ mvn exec:exec + +To fully utilize the DeltaSpike configuration mechanism try running the resulting jar file manually with various options. +Note: The logging property is there to bridge JUL to Log4j2 to get you a nicer output. + +$ java -Djava.util.logging.manager=org.apache.logging.log4j.jul.LogManager -Ddb.port.mysql=111 -Ddb.port.postgresql=112 -Ddb.vendor=postgresql -jar deltaspike-config-*.jar + +$ java -Djava.util.logging.manager=org.apache.logging.log4j.jul.LogManager -Ddb.port.mysql=4406 -Ddb.port.postgresql=6543 -Ddb.vendor=mysql -jar deltaspike-config-*.jar + +See how the configuration property 'dbPort' differs in the output. \ No newline at end of file diff --git a/quickstarts/deltaspike-config/log4j2.xml b/quickstarts/deltaspike-config/log4j2.xml new file mode 100644 index 0000000..b02aef5 --- /dev/null +++ b/quickstarts/deltaspike-config/log4j2.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/quickstarts/deltaspike-config/pom.xml b/quickstarts/deltaspike-config/pom.xml new file mode 100644 index 0000000..ce756fa --- /dev/null +++ b/quickstarts/deltaspike-config/pom.xml @@ -0,0 +1,41 @@ + + 4.0.0 + + io.silverware.demos.quickstarts + quickstarts-parent + 1.0 + + deltaspike-config + jar + + + io.silverware + microservices + + + io.silverware + cdi-microservice-provider + + + org.apache.deltaspike.core + deltaspike-core-api + + + org.apache.deltaspike.core + deltaspike-core-impl + + + org.apache.logging.log4j + log4j-jul + + + + + + org.apache.maven.plugins + maven-dependency-plugin + ${version.maven.dependency.plugin} + + + + \ No newline at end of file diff --git a/quickstarts/deltaspike-config/src/main/java/io/silverware/demos/quickstarts/deltaspike/DeltaSpikeMicroservice.java b/quickstarts/deltaspike-config/src/main/java/io/silverware/demos/quickstarts/deltaspike/DeltaSpikeMicroservice.java new file mode 100644 index 0000000..01e166b --- /dev/null +++ b/quickstarts/deltaspike-config/src/main/java/io/silverware/demos/quickstarts/deltaspike/DeltaSpikeMicroservice.java @@ -0,0 +1,64 @@ +/* + * -----------------------------------------------------------------------\ + * SilverWare + *   + * Copyright (C) 2010 - 2013 the original author or authors. + *   + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * -----------------------------------------------------------------------/ + */ +package io.silverware.demos.quickstarts.deltaspike; + +import io.silverware.microservices.annotations.Microservice; +import io.silverware.microservices.providers.cdi.MicroservicesStartedEvent; + +import org.apache.deltaspike.core.api.config.ConfigProperty; +import org.apache.deltaspike.core.api.config.ConfigResolver; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import javax.annotation.PostConstruct; +import javax.enterprise.event.Observes; +import javax.inject.Inject; + +/** + * @author Martin Večeřa + */ +@Microservice +public class DeltaSpikeMicroservice { + + private static final Logger log = LogManager.getLogger(DeltaSpikeMicroservice.class); + + @Inject + @ConfigProperty(name = "db.port", defaultValue = "3306", parameterizedBy = "db.vendor") + private Integer dbPort; + + public DeltaSpikeMicroservice() { + log.info("DeltaSpikeMicroservice constructor"); + } + + @PostConstruct + public void onInit() { + log.info("DeltaSpikeMicroservice PostConstruct " + this.getClass().getName()); + Integer apiDbPort = ConfigResolver.resolve("db.port").as(Integer.class).parameterizedBy("db.vendor").withDefault(3306).getValue(); + log.info("dbPort inject: {}, api: {}", dbPort, apiDbPort); + } + + public void hello() { + log.info("DeltaSpikeMicroservice Hello"); + } + + public void eventObserver(@Observes MicroservicesStartedEvent event) { + log.info("DeltaSpikeMicroservice MicroservicesStartedEvent"); + } +} \ No newline at end of file diff --git a/quickstarts/deltaspike-config/src/main/resources/META-INF/beans.xml b/quickstarts/deltaspike-config/src/main/resources/META-INF/beans.xml new file mode 100644 index 0000000..e69de29 diff --git a/quickstarts/pom.xml b/quickstarts/pom.xml index 8545209..16ee836 100644 --- a/quickstarts/pom.xml +++ b/quickstarts/pom.xml @@ -2,7 +2,7 @@ 4.0.0 io.silverware.demos.quickstarts quickstarts-parent - 1.0-SNAPSHOT + 1.0 pom SilverWare Quickstarts Parent Parent pom of SilverWare Quickstarts. @@ -27,8 +27,12 @@ UTF-8 + 1.8 - 2.14.1 + + 2.16.1 + 1.5.2 + 2.5 3.2 2.18.1 @@ -42,6 +46,9 @@ cdi-helloworld camel-helloworld camel-helloworld-xml + deltaspike-config + camel-cdi-helloworld + camel-jetty-cdi @@ -56,9 +63,37 @@ org.apache.camel camel-stream ${version.apache.camel} + + + org.apache.camel + camel-cdi + ${version.apache.camel} + + + org.apache.camel + camel-jetty + ${version.apache.camel} + + + org.apache.deltaspike.core + deltaspike-core-api + ${version.apache.deltaspike} + compile + + + org.apache.deltaspike.core + deltaspike-core-impl + ${version.apache.deltaspike} + runtime + + + org.apache.logging.log4j + log4j-jul + + @@ -118,6 +153,8 @@ lib/ + ${project.version} + ${project.version} @@ -144,6 +181,24 @@ ${version.maven.surefire} 1 + + org.apache.logging.log4j.jul.LogManager + org.apache.logging.log4j.jcl.Log4jLog + + + + + org.codehaus.mojo + exec-maven-plugin + + java + + -Djava.util.logging.manager=org.apache.logging.log4j.jul.LogManager + -Dorg.apache.commons.logging.Log=org.apache.logging.log4j.jcl.Log4jLog + -ea + -jar + ${project.build.directory}/${project.build.finalName}.jar + @@ -153,7 +208,7 @@ silverware-qs-${project.artifactId} java:8 - ["java", "-jar", "/root/${project.build.finalName}.jar"] + ["java", "-Dlog4j.configurationFile=log4j2.xml", "-Djava.util.logging.manager=org.apache.logging.log4j.jul.LogManager", "org.apache.commons.logging.Log=org.apache.logging.log4j.jcl.Log4jLog", "-jar", "/root/${project.build.finalName}.jar"] /root/