Author: cmueller
Date: Thu Aug 5 15:26:12 2010
New Revision: 982662
URL: http://svn.apache.org/viewvc?rev=982662&view=rev
Log:
CAMEL-2752: Pluggable UUID generator
Added:
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/CamelContextFactoryBeanTest.java
(with props)
Modified:
camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsProducer.java
Modified:
camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java?rev=982662&r1=982661&r2=982662&view=diff
==============================================================================
---
camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
(original)
+++
camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
Thu Aug 5 15:26:12 2010
@@ -77,6 +77,7 @@ import org.apache.camel.spi.PackageScanF
import org.apache.camel.spi.ProcessorFactory;
import org.apache.camel.spi.ShutdownStrategy;
import org.apache.camel.spi.ThreadPoolProfile;
+import org.apache.camel.spi.UuidGenerator;
import org.apache.camel.util.CamelContextHelper;
import org.apache.camel.util.EndpointHelper;
import org.apache.camel.util.ObjectHelper;
@@ -156,12 +157,12 @@ public abstract class AbstractCamelConte
LOG.info("Using custom ProcessorFactory: " + processorFactory);
getContext().setProcessorFactory(processorFactory);
}
-
Debugger debugger = getBeanForType(Debugger.class);
if (debugger != null) {
LOG.info("Using custom Debugger: " + debugger);
getContext().setDebugger(debugger);
}
+ lookupUuidGenerator();
// set the custom registry if defined
initCustomRegistry(getContext());
@@ -320,6 +321,16 @@ public abstract class AbstractCamelConte
installRoutes();
}
+ // TODO: workaround for source check failure in the afterPropertiesSet()
method:
+ // Executable statement count is 101 (max allowed is 100)
+ private void lookupUuidGenerator() {
+ UuidGenerator uuidGenerator = getBeanForType(UuidGenerator.class);
+ if (uuidGenerator != null) {
+ LOG.info("Using custom UuidGenerator: " + uuidGenerator);
+ getContext().setUuidGenerator(uuidGenerator);
+ }
+ }
+
protected abstract void initCustomRegistry(T context);
private void initOnExceptions(List<ProcessorDefinition> abstracts,
List<ProcessorDefinition> upper) {
Modified:
camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsProducer.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsProducer.java?rev=982662&r1=982661&r2=982662&view=diff
==============================================================================
---
camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsProducer.java
(original)
+++
camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsProducer.java
Thu Aug 5 15:26:12 2010
@@ -30,8 +30,9 @@ import org.apache.camel.component.jms.Jm
import org.apache.camel.component.jms.reply.ReplyManager;
import
org.apache.camel.component.jms.reply.UseMessageIdAsCorrelationIdMessageSentCallback;
import org.apache.camel.impl.DefaultAsyncProducer;
+import org.apache.camel.impl.DefaultUuidGenerator;
+import org.apache.camel.spi.UuidGenerator;
import org.apache.camel.util.ObjectHelper;
-import org.apache.camel.util.UuidGenerator;
import org.apache.camel.util.ValueHolder;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -336,12 +337,11 @@ public class JmsProducer extends Default
super.doStart();
if (uuidGenerator == null) {
// use the default generator
- uuidGenerator = UuidGenerator.get();
+ uuidGenerator = new DefaultUuidGenerator();
}
}
protected void doStop() throws Exception {
super.doStop();
}
-
-}
+}
\ No newline at end of file
Added:
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/CamelContextFactoryBeanTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/CamelContextFactoryBeanTest.java?rev=982662&view=auto
==============================================================================
---
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/CamelContextFactoryBeanTest.java
(added)
+++
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/CamelContextFactoryBeanTest.java
Thu Aug 5 15:26:12 2010
@@ -0,0 +1,59 @@
+/**
+ * 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.spring;
+
+import junit.framework.TestCase;
+
+import org.apache.camel.impl.DefaultUuidGenerator;
+import org.apache.camel.impl.SimpleUuidGenerator;
+import org.apache.camel.spi.UuidGenerator;
+import org.springframework.context.support.StaticApplicationContext;
+
+/**
+ * @version $Revision: $
+ */
+public class CamelContextFactoryBeanTest extends TestCase {
+
+ private CamelContextFactoryBean factory;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ factory = new CamelContextFactoryBean();
+ factory.setId("camelContext");
+ }
+
+ public void testGetDefaultUuidGenerator() throws Exception {
+ factory.setApplicationContext(new StaticApplicationContext());
+ factory.afterPropertiesSet();
+
+ UuidGenerator uuidGenerator = factory.getContext().getUuidGenerator();
+
+ assertTrue(uuidGenerator instanceof DefaultUuidGenerator);
+ }
+
+ public void testGetCustomUuidGenerator() throws Exception {
+ StaticApplicationContext applicationContext = new
StaticApplicationContext();
+ applicationContext.registerSingleton("uuidGenerator",
SimpleUuidGenerator.class);
+ factory.setApplicationContext(applicationContext);
+ factory.afterPropertiesSet();
+
+ UuidGenerator uuidGenerator = factory.getContext().getUuidGenerator();
+
+ assertTrue(uuidGenerator instanceof SimpleUuidGenerator);
+ }
+}
\ No newline at end of file
Propchange:
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/CamelContextFactoryBeanTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/CamelContextFactoryBeanTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain