You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2015/10/22 12:00:40 UTC
[2/2] camel git commit: Fixed example to not pull in JARs that are
not in maven central. Also the example is a bad example of OSGi and Camel so
remove that.
Fixed example to not pull in JARs that are not in maven central. Also the example is a bad example of OSGi and Camel so remove that.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/dd466beb
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/dd466beb
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/dd466beb
Branch: refs/heads/camel-2.16.x
Commit: dd466beb8a1456f269f5055698cca00ffbc7bd36
Parents: 46d0c42
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Oct 22 12:02:39 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Oct 22 12:03:04 2015 +0200
----------------------------------------------------------------------
examples/camel-example-guice-jms/README.txt | 7 +-
examples/camel-example-guice-jms/pom.xml | 43 ---------
.../camel/example/guice/jms/MyActivator.java | 47 ----------
.../camel/example/guice/jms/MyOSGiModule.java | 63 --------------
.../guice/jms/OSGiCamelContextProvider.java | 92 --------------------
.../src/main/resources/features.xml | 42 ---------
6 files changed, 5 insertions(+), 289 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/dd466beb/examples/camel-example-guice-jms/README.txt
----------------------------------------------------------------------
diff --git a/examples/camel-example-guice-jms/README.txt b/examples/camel-example-guice-jms/README.txt
index fb378f3..1c71ba8 100644
--- a/examples/camel-example-guice-jms/README.txt
+++ b/examples/camel-example-guice-jms/README.txt
@@ -8,13 +8,16 @@ The example consumes messages from a queue and writes them to the file
system.
You will need to compile this example first:
+
mvn compile
-To run the example type
+To run the example type:
+
mvn exec:java
Alternatively to run the example you can also make use of the Guice Maven
-Plugin provided by Camel, so you can instead type
+Plugin provided by Camel, so you can instead type:
+
mvn guice:run
See the POM of this example about how to make use of this Maven Plugin
http://git-wip-us.apache.org/repos/asf/camel/blob/dd466beb/examples/camel-example-guice-jms/pom.xml
----------------------------------------------------------------------
diff --git a/examples/camel-example-guice-jms/pom.xml b/examples/camel-example-guice-jms/pom.xml
index 9cf08fc..753be5b 100644
--- a/examples/camel-example-guice-jms/pom.xml
+++ b/examples/camel-example-guice-jms/pom.xml
@@ -25,18 +25,9 @@
</parent>
<artifactId>camel-example-guice-jms</artifactId>
- <packaging>bundle</packaging>
<name>Camel :: Example :: Guice :: JMS</name>
<description>An example showing how to work with Camel, Guice and JMS</description>
- <properties>
- <camel.osgi.export.pkg>org.apache.camel.example.guice.jms.*</camel.osgi.export.pkg>
- <camel.osgi.import.additional>
- org.apache.activemq.xbean,org.apache.activemq.broker,org.apache.activemq.pool
- </camel.osgi.import.additional>
- <camel.osgi.activator>org.apache.camel.example.guice.jms.MyActivator</camel.osgi.activator>
- </properties>
-
<dependencies>
<dependency>
<groupId>org.apache.camel</groupId>
@@ -62,18 +53,6 @@
<artifactId>activemq-client</artifactId>
</dependency>
- <!-- osgi -->
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.springframework.osgi</groupId>
- <artifactId>spring-osgi-core</artifactId>
- <scope>provided</scope>
- </dependency>
-
<!-- lets use log4j -->
<dependency>
<groupId>org.slf4j</groupId>
@@ -95,28 +74,6 @@
<build>
<plugins>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>build-helper-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>attach-artifacts</id>
- <phase>package</phase>
- <goals>
- <goal>attach-artifact</goal>
- </goals>
- <configuration>
- <artifacts>
- <artifact>
- <file>target/classes/features.xml</file>
- <type>xml</type>
- <classifier>features</classifier>
- </artifact>
- </artifacts>
- </configuration>
- </execution>
- </executions>
- </plugin>
<!-- Allows the example to be run via 'mvn compile exec:java' -->
<plugin>
http://git-wip-us.apache.org/repos/asf/camel/blob/dd466beb/examples/camel-example-guice-jms/src/main/java/org/apache/camel/example/guice/jms/MyActivator.java
----------------------------------------------------------------------
diff --git a/examples/camel-example-guice-jms/src/main/java/org/apache/camel/example/guice/jms/MyActivator.java b/examples/camel-example-guice-jms/src/main/java/org/apache/camel/example/guice/jms/MyActivator.java
deleted file mode 100644
index c8e386a..0000000
--- a/examples/camel-example-guice-jms/src/main/java/org/apache/camel/example/guice/jms/MyActivator.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.camel.example.guice.jms;
-
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-import org.apache.camel.CamelContext;
-import org.apache.camel.impl.DefaultCamelContext;
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-
-public class MyActivator implements BundleActivator {
- protected CamelContext camelContext;
-
- public void start(BundleContext context) throws Exception {
- Injector injector = Guice.createInjector(new MyOSGiModule(context));
-
- camelContext = injector.getInstance(CamelContext.class);
- if (camelContext instanceof DefaultCamelContext) {
- if (!((DefaultCamelContext)camelContext).isStarted()) {
- camelContext.start();
- }
- }
- }
-
- public void stop(BundleContext context) throws Exception {
- // stop the camel context
- if (camelContext != null) {
- camelContext.stop();
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/dd466beb/examples/camel-example-guice-jms/src/main/java/org/apache/camel/example/guice/jms/MyOSGiModule.java
----------------------------------------------------------------------
diff --git a/examples/camel-example-guice-jms/src/main/java/org/apache/camel/example/guice/jms/MyOSGiModule.java b/examples/camel-example-guice-jms/src/main/java/org/apache/camel/example/guice/jms/MyOSGiModule.java
deleted file mode 100644
index 35d998a..0000000
--- a/examples/camel-example-guice-jms/src/main/java/org/apache/camel/example/guice/jms/MyOSGiModule.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.camel.example.guice.jms;
-
-import java.io.IOException;
-import java.net.URL;
-import java.util.Properties;
-
-import com.google.inject.name.Names;
-import org.apache.camel.CamelContext;
-import org.osgi.framework.BundleContext;
-
-/**
- * Configures the CamelContext, RouteBuilder, Component and Endpoint instances using
- * Guice within OSGi platform
- *
- * @version
- */
-public class MyOSGiModule extends MyModule {
- private OSGiCamelContextProvider provider;
- private Properties properties;
-
- MyOSGiModule(BundleContext bundleContext) throws IOException {
- provider = new OSGiCamelContextProvider(bundleContext);
- properties = new Properties();
- URL jndiPropertiesUrl;
- if (bundleContext != null) {
- jndiPropertiesUrl = bundleContext.getBundle().getEntry("camel.properties");
- } else {
- jndiPropertiesUrl = this.getClass().getResource("/camel.properties");
- }
- if (jndiPropertiesUrl != null) {
- properties.load(jndiPropertiesUrl.openStream());
- }
- }
-
- @Override
- protected void configureCamelContext() {
- bind(CamelContext.class).toProvider(provider).asEagerSingleton();
- }
-
- @Override
- protected void configure() {
- // loading the properties into Guice Context
- Names.bindProperties(binder(), properties);
- super.configure();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/dd466beb/examples/camel-example-guice-jms/src/main/java/org/apache/camel/example/guice/jms/OSGiCamelContextProvider.java
----------------------------------------------------------------------
diff --git a/examples/camel-example-guice-jms/src/main/java/org/apache/camel/example/guice/jms/OSGiCamelContextProvider.java b/examples/camel-example-guice-jms/src/main/java/org/apache/camel/example/guice/jms/OSGiCamelContextProvider.java
deleted file mode 100644
index ce07efb..0000000
--- a/examples/camel-example-guice-jms/src/main/java/org/apache/camel/example/guice/jms/OSGiCamelContextProvider.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.camel.example.guice.jms;
-import java.util.Properties;
-import java.util.Set;
-
-import javax.naming.Context;
-
-import com.google.inject.Inject;
-import com.google.inject.Injector;
-import com.google.inject.Provider;
-import com.google.inject.ProvisionException;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.RoutesBuilder;
-import org.apache.camel.guice.jndi.JndiBindings;
-import org.apache.camel.guice.jndi.internal.JndiContext;
-import org.apache.camel.impl.DefaultCamelContext;
-import org.apache.camel.impl.JndiRegistry;
-import org.apache.camel.osgi.CamelContextFactory;
-import org.osgi.framework.BundleContext;
-
-public class OSGiCamelContextProvider implements Provider<CamelContext> {
- private final CamelContextFactory factory;
- @Inject
- private Set<RoutesBuilder> routeBuilders;
- @Inject
- private Injector injector;
-
- public OSGiCamelContextProvider(BundleContext context) {
- // In this we can support to run this provider with or without OSGI
- if (context != null) {
- factory = new CamelContextFactory();
- factory.setBundleContext(context);
- } else {
- factory = null;
- }
- }
-
- protected Context getJndiContext() {
- try {
- JndiContext context = new JndiContext(null);
- if (injector != null) {
- //Feed the empty properties to get the code work
- JndiBindings.bindInjectorAndBindings(context, injector, new Properties());
- }
- return context;
- } catch (Exception e) {
- throw new ProvisionException("Failed to create JNDI bindings. Reason: " + e, e);
- }
- }
-
- // set the JndiRegistry to the camel context
- protected void updateRegistry(DefaultCamelContext camelContext) {
- camelContext.setRegistry(new JndiRegistry(getJndiContext()));
- }
-
- public CamelContext get() {
- DefaultCamelContext camelContext;
- if (factory != null) {
- camelContext = factory.createContext();
- } else {
- camelContext = new DefaultCamelContext();
- }
- if (routeBuilders != null) {
- for (RoutesBuilder builder : routeBuilders) {
- try {
- camelContext.addRoutes(builder);
- } catch (Exception e) {
- throw new ProvisionException("Failed to add the router. Reason: " + e, e);
- }
- }
- }
- updateRegistry(camelContext);
- return camelContext;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/dd466beb/examples/camel-example-guice-jms/src/main/resources/features.xml
----------------------------------------------------------------------
diff --git a/examples/camel-example-guice-jms/src/main/resources/features.xml b/examples/camel-example-guice-jms/src/main/resources/features.xml
deleted file mode 100644
index 28e87bb..0000000
--- a/examples/camel-example-guice-jms/src/main/resources/features.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You 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.
--->
-<features>
- <repository>mvn:org.apache.camel.karaf/apache-camel/${project.version}/xml/features</repository>
-
- <feature name='activemq-feature' version='${project.version}'>
- <bundle>mvn:org.apache.geronimo.specs/geronimo-jta_1.1_spec/1.1.1</bundle>
- <bundle>mvn:org.apache.geronimo.specs/geronimo-jms_1.1_spec/1.1.1</bundle>
- <bundle>mvn:org.apache.geronimo.specs/geronimo-j2ee-management_1.1_spec/1.0.1</bundle>
- <bundle>mvn:org.apache.geronimo.specs/geronimo-j2ee-connector_1.5_spec/2.0.0</bundle>
- <bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-pool/1.5.4_1</bundle>
- <bundle>mvn:org.apache.xbean/xbean-spring/3.4.3</bundle>
- <bundle>mvn:org.apache.activemq/kahadb/${activemq-version}</bundle>
- <bundle>mvn:org.apache.activemq/activemq-core/${activemq-version}</bundle>
- <bundle>mvn:org.apache.activemq/activemq-ra/${activemq-version}</bundle>
- <bundle>mvn:org.apache.activemq/activemq-pool/${activemq-version}</bundle>
- <bundle>mvn:org.apache.activemq/activemq-camel/${activemq-version}</bundle>
- </feature>
-
- <feature name='camel-example-guice-jms' version='${project.version}'>
- <feature version="${project.version}">camel</feature>
- <feature version="${project.version}">camel-guice</feature>
- <feature version="${project.version}">camel-jms</feature>
- <bundle>mvn:org.apache.camel/camel-example-guice-jms/${project.version}</bundle>
- </feature>
-
-</features>
\ No newline at end of file