CAMEL-7997: camel-scr should be an OSGi bundle. Add feature to install it.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/d3a69dc8 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/d3a69dc8 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/d3a69dc8 Branch: refs/heads/master Commit: d3a69dc8185e96982ebaea4d31a5eb34f052d316 Parents: 733e4cb Author: Claus Ibsen <davscl...@apache.org> Authored: Sun Nov 9 09:31:19 2014 +0100 Committer: Claus Ibsen <davscl...@apache.org> Committed: Sun Nov 9 09:31:30 2014 +0100 ---------------------------------------------------------------------- components/camel-scr/pom.xml | 117 ++++++++++--------- .../apache/camel/scr/AbstractCamelRunner.java | 16 +-- .../features/src/main/resources/features.xml | 9 +- 3 files changed, 78 insertions(+), 64 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/d3a69dc8/components/camel-scr/pom.xml ---------------------------------------------------------------------- diff --git a/components/camel-scr/pom.xml b/components/camel-scr/pom.xml index 0e495dc..418505e 100644 --- a/components/camel-scr/pom.xml +++ b/components/camel-scr/pom.xml @@ -15,66 +15,71 @@ See the License for the specific language governing permissions and limitations under the License. --> -<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> +<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>components</artifactId> - <groupId>org.apache.camel</groupId> - <version>2.15-SNAPSHOT</version> - </parent> + <parent> + <artifactId>components</artifactId> + <groupId>org.apache.camel</groupId> + <version>2.15-SNAPSHOT</version> + </parent> - <artifactId>camel-scr</artifactId> - <name>Camel :: SCR</name> - <description>Camel SCR support</description> - <packaging>jar</packaging> + <artifactId>camel-scr</artifactId> + <name>Camel :: SCR</name> + <description>Camel SCR support</description> + <packaging>bundle</packaging> - <dependencies> - <dependency> - <groupId>org.apache.camel</groupId> - <artifactId>camel-core</artifactId> - </dependency> - <dependency> - <groupId>org.apache.camel</groupId> - <artifactId>camel-core-osgi</artifactId> - </dependency> - <dependency> - <groupId>org.apache.felix</groupId> - <artifactId>org.apache.felix.framework</artifactId> - <version>${felix-framework-version}</version> - </dependency> - <dependency> - <groupId>org.apache.felix</groupId> - <artifactId>org.apache.felix.scr.annotations</artifactId> - <version>${felix-scr-annotations-version}</version> - </dependency> + <properties> + <camel.osgi.export.pkg>org.apache.camel.scr.*</camel.osgi.export.pkg> + </properties> - <!-- logging --> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-api</artifactId> - </dependency> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-log4j12</artifactId> - </dependency> - <dependency> - <groupId>log4j</groupId> - <artifactId>log4j</artifactId> - </dependency> + <dependencies> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-core</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-core-osgi</artifactId> + </dependency> + <dependency> + <groupId>org.apache.felix</groupId> + <artifactId>org.apache.felix.framework</artifactId> + <version>${felix-framework-version}</version> + </dependency> + <dependency> + <groupId>org.apache.felix</groupId> + <artifactId>org.apache.felix.scr.annotations</artifactId> + <version>${felix-scr-annotations-version}</version> + </dependency> - <!-- testing --> - <dependency> - <groupId>org.apache.camel</groupId> - <artifactId>camel-test</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>commons-lang</groupId> - <artifactId>commons-lang</artifactId> - <version>${commons-lang-version}</version> - <scope>test</scope> - </dependency> - </dependencies> + <!-- logging --> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-log4j12</artifactId> + </dependency> + <dependency> + <groupId>log4j</groupId> + <artifactId>log4j</artifactId> + </dependency> + + <!-- testing --> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-test</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>commons-lang</groupId> + <artifactId>commons-lang</artifactId> + <version>${commons-lang-version}</version> + <scope>test</scope> + </dependency> + </dependencies> </project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/d3a69dc8/components/camel-scr/src/main/java/org/apache/camel/scr/AbstractCamelRunner.java ---------------------------------------------------------------------- diff --git a/components/camel-scr/src/main/java/org/apache/camel/scr/AbstractCamelRunner.java b/components/camel-scr/src/main/java/org/apache/camel/scr/AbstractCamelRunner.java index e1fa67c..e4d6e93 100644 --- a/components/camel-scr/src/main/java/org/apache/camel/scr/AbstractCamelRunner.java +++ b/components/camel-scr/src/main/java/org/apache/camel/scr/AbstractCamelRunner.java @@ -53,6 +53,11 @@ public abstract class AbstractCamelRunner implements Runnable { public static final int START_DELAY = 5000; public static final String PROPERTY_PREFIX = "camel.scr.properties.prefix"; + // Configured fields + // TODO: can we make these private and have getter/setter + public String camelContextId = "camel-runner-default"; + public volatile boolean active; + protected Logger log = LoggerFactory.getLogger(getClass()); protected ModelCamelContext context; protected SimpleRegistry registry = new SimpleRegistry(); @@ -62,9 +67,6 @@ public abstract class AbstractCamelRunner implements Runnable { private volatile boolean activated; private volatile boolean started; - // Configured fields - private String camelContextId = "camel-runner-default"; - private volatile boolean active; public synchronized void activate(final BundleContext bundleContext, final Map<String, String> props) throws Exception { if (activated) { @@ -199,7 +201,7 @@ public abstract class AbstractCamelRunner implements Runnable { } started = true; } catch (Exception e) { - log.error("Failed to start Camel context. Will try again when more Camel components have been registered.", e); + log.warn("Failed to start Camel context. Will try again when more Camel components have been registered.", e); } } @@ -235,7 +237,7 @@ public abstract class AbstractCamelRunner implements Runnable { public static <T> T configure(final CamelContext context, final T target, final Logger log) { Class clazz = target.getClass(); - log.debug("Configuring " + clazz.getName()); + log.debug("Configuring {}", clazz.getName()); Collection<Field> fields = new ArrayList<Field>(); fields.addAll(Arrays.asList(clazz.getDeclaredFields())); fields.addAll(Arrays.asList(clazz.getFields())); @@ -246,10 +248,10 @@ public abstract class AbstractCamelRunner implements Runnable { // Try to convert the value and set the field Object convertedValue = convertValue(propertyValue, field.getGenericType()); ReflectionHelper.setField(field, target, convertedValue); - log.debug("Set field " + field.getName() + " with value " + propertyValue); + log.debug("Set field {} with value {}", field.getName(), propertyValue); } } catch (Exception e) { - log.debug("Field " + field.getName() + " skipped: " + e.getMessage()); + log.debug("Error setting field " + field.getName() + " due: " + e.getMessage() + ". This exception is ignored.", e); } } return target; http://git-wip-us.apache.org/repos/asf/camel/blob/d3a69dc8/platforms/karaf/features/src/main/resources/features.xml ---------------------------------------------------------------------- diff --git a/platforms/karaf/features/src/main/resources/features.xml b/platforms/karaf/features/src/main/resources/features.xml index 2c2551c..975a605 100644 --- a/platforms/karaf/features/src/main/resources/features.xml +++ b/platforms/karaf/features/src/main/resources/features.xml @@ -208,7 +208,7 @@ </feature> <feature name='camel-cache' version='${project.version}' resolver='(obr)' start-level='50'> <feature version='${project.version}'>camel-core</feature> - <feature>transaction</feature> + <feature>transaction</feature> <bundle dependency='true'>mvn:net.sf.ehcache/ehcache/${ehcache-version}</bundle> <bundle dependency='true'>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.jdom/${jdom-bundle-version}</bundle> <bundle>mvn:org.apache.camel/camel-cache/${project.version}</bundle> @@ -1107,6 +1107,13 @@ <bundle dependency='true'>mvn:commons-io/commons-io/${commons-io-version}</bundle> <bundle>mvn:org.apache.camel/camel-schematron/${project.version}</bundle> </feature> + <feature name='camel-scr' version='${project.version}' resolver='(obr)' start-level='50'> + <feature version='${project.version}'>camel-core</feature> + <feature>scr</feature> + <feature>eventadmin</feature> + <bundle dependency='true'>mvn:org.apache.camel/camel-core-osgi/${project.version}</bundle> + <bundle>mvn:org.apache.camel/camel-scr/${project.version}</bundle> + </feature> <feature name='camel-script-jruby' version='${project.version}' resolver='(obr)' start-level='50'> <bundle>mvn:http://scriptengines.googlecode.com/svn/m2-repo/!com.google.code.scriptengines/scriptengines-jruby/${scriptengines-version}</bundle> <bundle dependency='true'>mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.scripting-api-1.0/${servicemix-specs-version}</bundle>