You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ch...@apache.org on 2007/08/07 23:33:12 UTC
svn commit: r563665 [9/11] - in /activemq/camel/trunk:
camel-core/src/main/java/org/apache/camel/converter/jaxp/
camel-core/src/test/java/org/apache/camel/processor/
components/camel-activemq/src/main/java/org/apache/camel/component/activemq/
component...
Modified: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelBeanPostProcessor.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelBeanPostProcessor.java?view=diff&rev=563665&r1=563664&r2=563665
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelBeanPostProcessor.java (original)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelBeanPostProcessor.java Tue Aug 7 14:33:00 2007
@@ -1,5 +1,4 @@
/**
- *
* 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.
@@ -7,7 +6,7 @@
* (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
+ * 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,
@@ -17,6 +16,14 @@
*/
package org.apache.camel.spring;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+
import org.apache.camel.CamelContextAware;
import org.apache.camel.CamelTemplate;
import org.apache.camel.Consumer;
@@ -29,37 +36,34 @@
import org.apache.camel.component.bean.BeanProcessor;
import org.apache.camel.spring.util.ReflectionUtils;
import org.apache.camel.util.ObjectHelper;
-import static org.apache.camel.util.ObjectHelper.isNotNullAndNonEmpty;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlTransient;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
+import static org.apache.camel.util.ObjectHelper.isNotNullAndNonEmpty;
/**
- * A post processor to perform injection of {@link Endpoint} and {@link Producer} instances together with binding
- * methods annotated with {@link @MessageDriven} to a Camel consumer.
- *
+ * A post processor to perform injection of {@link Endpoint} and
+ * {@link Producer} instances together with binding methods annotated with
+ * {@link @MessageDriven} to a Camel consumer.
+ *
* @version $Revision: 1.1 $
*/
@XmlRootElement(name = "beanPostProcessor")
@XmlAccessorType(XmlAccessType.FIELD)
public class CamelBeanPostProcessor implements BeanPostProcessor, ApplicationContextAware {
- private static final transient Log log = LogFactory.getLog(CamelBeanPostProcessor.class);
+ private static final transient Log LOG = LogFactory.getLog(CamelBeanPostProcessor.class);
@XmlTransient
private SpringCamelContext camelContext;
@XmlTransient
private ApplicationContext applicationContext;
- //private List<Consumer> consumers = new ArrayList<Consumer>();
+
+ // private List<Consumer> consumers = new ArrayList<Consumer>();
public CamelBeanPostProcessor() {
}
@@ -68,11 +72,10 @@
injectFields(bean);
injectMethods(bean);
if (bean instanceof CamelContextAware) {
- CamelContextAware contextAware = (CamelContextAware) bean;
+ CamelContextAware contextAware = (CamelContextAware)bean;
if (camelContext == null) {
- log.warn("No CamelContext defined yet so cannot inject into: " + bean);
- }
- else {
+ LOG.warn("No CamelContext defined yet so cannot inject into: " + bean);
+ } else {
contextAware.setCamelContext(camelContext);
}
}
@@ -84,7 +87,7 @@
}
// Properties
- //-------------------------------------------------------------------------
+ // -------------------------------------------------------------------------
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
this.applicationContext = applicationContext;
@@ -99,11 +102,12 @@
}
// Implementation methods
- //-------------------------------------------------------------------------
+ // -------------------------------------------------------------------------
/**
- * A strategy method to allow implementations to perform some custom JBI based injection of the POJO
- *
+ * A strategy method to allow implementations to perform some custom JBI
+ * based injection of the POJO
+ *
* @param bean the bean to be injected
*/
protected void injectFields(final Object bean) {
@@ -133,9 +137,8 @@
Class<?>[] parameterTypes = method.getParameterTypes();
if (parameterTypes != null) {
if (parameterTypes.length != 1) {
- log.warn("Ignoring badly annotated method for injection due to incorrect number of parameters: " + method);
- }
- else {
+ LOG.warn("Ignoring badly annotated method for injection due to incorrect number of parameters: " + method);
+ } else {
Object value = getEndpointInjectionValue(annoation, parameterTypes[0]);
ObjectHelper.invokeMethod(method, bean, value);
}
@@ -148,31 +151,22 @@
@SuppressWarnings("unchecked")
public void doWith(Method method) throws IllegalArgumentException, IllegalAccessException {
/*
-
- TODO support callbacks?
-
- if (method.getAnnotation(Callback.class) != null) {
- try {
- Expression e = ExpressionFactory.createExpression(
- method.getAnnotation(Callback.class).condition());
- JexlContext jc = JexlHelper.createContext();
- jc.getVars().put("this", obj);
- Object r = e.evaluate(jc);
- if (!(r instanceof Boolean)) {
- throw new RuntimeException("Expression did not returned a boolean value but: " + r);
- }
- Boolean oldVal = req.getCallbacks().get(method);
- Boolean newVal = (Boolean) r;
- if ((oldVal == null || !oldVal) && newVal) {
- req.getCallbacks().put(method, newVal);
- method.invoke(obj, new Object[0]);
- // TODO: handle return value and sent it as the answer
- }
- } catch (Exception e) {
- throw new RuntimeException("Unable to invoke callback", e);
- }
- }
- */
+ * TODO support callbacks? if
+ * (method.getAnnotation(Callback.class) != null) { try {
+ * Expression e = ExpressionFactory.createExpression(
+ * method.getAnnotation(Callback.class).condition());
+ * JexlContext jc = JexlHelper.createContext();
+ * jc.getVars().put("this", obj); Object r = e.evaluate(jc); if
+ * (!(r instanceof Boolean)) { throw new
+ * RuntimeException("Expression did not returned a boolean value
+ * but: " + r); } Boolean oldVal =
+ * req.getCallbacks().get(method); Boolean newVal = (Boolean) r;
+ * if ((oldVal == null || !oldVal) && newVal) {
+ * req.getCallbacks().put(method, newVal); method.invoke(obj,
+ * new Object[0]); // TODO: handle return value and sent it as
+ * the answer } } catch (Exception e) { throw new
+ * RuntimeException("Unable to invoke callback", e); } }
+ */
}
});
}
@@ -180,20 +174,19 @@
protected void consumerInjection(Method method, Object bean) {
MessageDriven annotation = method.getAnnotation(MessageDriven.class);
if (annotation != null) {
- log.info("Creating a consumer for: " + annotation);
+ LOG.info("Creating a consumer for: " + annotation);
// lets bind this method to a listener
Endpoint endpoint = getEndpointInjection(annotation.uri(), annotation.name());
if (endpoint != null) {
try {
Processor processor = createConsumerProcessor(bean, method, endpoint);
- log.info("Created processor: " + processor);
+ LOG.info("Created processor: " + processor);
Consumer consumer = endpoint.createConsumer(processor);
consumer.start();
addConsumer(consumer);
- }
- catch (Exception e) {
- log.warn(e);
+ } catch (Exception e) {
+ LOG.warn(e);
throw new RuntimeCamelException(e);
}
}
@@ -201,7 +194,8 @@
}
/**
- * Create a processor which invokes the given method when an incoming message exchange is received
+ * Create a processor which invokes the given method when an incoming
+ * message exchange is received
*/
protected Processor createConsumerProcessor(final Object pojo, final Method method, final Endpoint endpoint) {
BeanProcessor answer = new BeanProcessor(pojo, getCamelContext());
@@ -210,8 +204,8 @@
}
protected void addConsumer(Consumer consumer) {
- log.debug("Adding consumer: " + consumer);
- //consumers.add(consumer);
+ LOG.debug("Adding consumer: " + consumer);
+ // consumers.add(consumer);
}
/**
@@ -222,16 +216,13 @@
if (endpoint != null) {
if (type.isInstance(endpoint)) {
return endpoint;
- }
- else if (type.isAssignableFrom(Producer.class)) {
+ } else if (type.isAssignableFrom(Producer.class)) {
try {
return endpoint.createProducer();
- }
- catch (Exception e) {
+ } catch (Exception e) {
throw new RuntimeCamelException(e);
}
- }
- else if (type.isAssignableFrom(CamelTemplate.class)) {
+ } else if (type.isAssignableFrom(CamelTemplate.class)) {
return new CamelTemplate(getCamelContext(), endpoint);
}
}
@@ -242,16 +233,14 @@
Endpoint endpoint = null;
if (isNotNullAndNonEmpty(uri)) {
endpoint = camelContext.getEndpoint(uri);
- }
- else {
+ } else {
if (isNotNullAndNonEmpty(name)) {
- endpoint = (Endpoint) applicationContext.getBean(name);
+ endpoint = (Endpoint)applicationContext.getBean(name);
if (endpoint == null) {
throw new NoSuchBeanDefinitionException(name);
}
- }
- else {
- log.warn("No uri or name specified on @EndpointInject annotation!");
+ } else {
+ LOG.warn("No uri or name specified on @EndpointInject annotation!");
}
}
return endpoint;
Modified: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java?view=diff&rev=563665&r1=563664&r2=563665
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java (original)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java Tue Aug 7 14:33:00 2007
@@ -1,5 +1,4 @@
/**
- *
* 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.
@@ -7,7 +6,7 @@
* (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
+ * 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,
@@ -17,6 +16,16 @@
*/
package org.apache.camel.spring;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElements;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+
import org.apache.camel.RuntimeCamelException;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.model.IdentifiedType;
@@ -24,6 +33,7 @@
import org.apache.camel.model.RouteType;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.InitializingBean;
@@ -33,33 +43,22 @@
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlElements;
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlTransient;
-import java.util.ArrayList;
-import java.util.List;
-
/**
- * A Spring {@link FactoryBean} to create and initialize a {@link SpringCamelContext}
- * and install routes either explicitly configured in Spring XML or found by searching the classpath for Java classes
- * which extend {@link RouteBuilder} using the nested {@link #setPackages(String[])}.
- *
+ * A Spring {@link FactoryBean} to create and initialize a
+ * {@link SpringCamelContext} and install routes either explicitly configured in
+ * Spring XML or found by searching the classpath for Java classes which extend
+ * {@link RouteBuilder} using the nested {@link #setPackages(String[])}.
+ *
* @version $Revision$
*/
@XmlRootElement(name = "camelContext")
@XmlAccessorType(XmlAccessType.FIELD)
public class CamelContextFactoryBean extends IdentifiedType implements RouteContainer, FactoryBean, InitializingBean, DisposableBean, ApplicationContextAware, ApplicationListener {
- private static final Log log = LogFactory.getLog(CamelContextFactoryBean.class);
+ private static final Log LOG = LogFactory.getLog(CamelContextFactoryBean.class);
@XmlElement(name = "package", required = false)
private String[] packages = {};
- @XmlElements({
- @XmlElement(name = "beanPostProcessor", type = CamelBeanPostProcessor.class, required = false),
- @XmlElement(name = "proxy", type = CamelProxyFactoryType.class, required = false),
- @XmlElement(name = "export", type = CamelServiceExporterType.class, required = false)
- })
+ @XmlElements({@XmlElement(name = "beanPostProcessor", type = CamelBeanPostProcessor.class, required = false), @XmlElement(name = "proxy", type = CamelProxyFactoryType.class, required = false),
+ @XmlElement(name = "export", type = CamelServiceExporterType.class, required = false) })
private List beans;
@XmlElement(name = "endpoint", required = false)
private List<EndpointFactoryBean> endpoints;
@@ -91,7 +90,7 @@
// lets force any lazy creation
getContext();
- log.debug("Found JAXB created routes: " + getRoutes());
+ LOG.debug("Found JAXB created routes: " + getRoutes());
findRouteBuiders();
installRoutes();
@@ -102,29 +101,27 @@
}
public void onApplicationEvent(ApplicationEvent event) {
- if (log.isDebugEnabled()) {
- log.debug("Publishing event: " + event);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Publishing event: " + event);
}
if (event instanceof ContextRefreshedEvent) {
- // now lets start the CamelContext so that all its possible dependencies are initailized
+ // now lets start the CamelContext so that all its possible
+ // dependencies are initailized
try {
- log.debug("Starting the context now!");
+ LOG.debug("Starting the context now!");
getContext().start();
- }
- catch (Exception e) {
+ } catch (Exception e) {
throw new RuntimeCamelException(e);
}
}
-/*
- if (context != null) {
- context.onApplicationEvent(event);
- }
-*/
+ /*
+ * if (context != null) { context.onApplicationEvent(event); }
+ */
}
// Properties
- //-------------------------------------------------------------------------
+ // -------------------------------------------------------------------------
public SpringCamelContext getContext() throws Exception {
if (context == null) {
context = new SpringCamelContext(getApplicationContext());
@@ -149,14 +146,16 @@
}
/**
- * Set a single {@link RouteBuilder} to be used to create the default routes on startup
+ * Set a single {@link RouteBuilder} to be used to create the default routes
+ * on startup
*/
public void setRouteBuilder(RouteBuilder routeBuilder) {
this.routeBuilder = routeBuilder;
}
/**
- * Set a collection of {@link RouteBuilder} instances to be used to create the default routes on startup
+ * Set a collection of {@link RouteBuilder} instances to be used to create
+ * the default routes on startup
*/
public void setRouteBuilders(RouteBuilder[] builders) {
for (RouteBuilder builder : builders) {
@@ -177,9 +176,11 @@
}
/**
- * Sets the package names to be recursively searched for Java classes which extend {@link RouteBuilder} to be auto-wired up to the
- * {@link SpringCamelContext} as a route. Note that classes are excluded if they are specifically configured in the spring.xml
- *
+ * Sets the package names to be recursively searched for Java classes which
+ * extend {@link RouteBuilder} to be auto-wired up to the
+ * {@link SpringCamelContext} as a route. Note that classes are excluded if
+ * they are specifically configured in the spring.xml
+ *
* @param packages the package names which are recursively searched
*/
public void setPackages(String[] packages) {
@@ -187,7 +188,7 @@
}
// Implementation methods
- //-------------------------------------------------------------------------
+ // -------------------------------------------------------------------------
/**
* Strategy to install all available routes into the context
@@ -205,7 +206,8 @@
}
/**
- * Strategy method to try find {@link RouteBuilder} instances on the classpath
+ * Strategy method to try find {@link RouteBuilder} instances on the
+ * classpath
*/
protected void findRouteBuiders() throws Exception, InstantiationException {
if (packages != null && packages.length > 0) {
Modified: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelProxyFactoryType.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelProxyFactoryType.java?view=diff&rev=563665&r1=563664&r2=563665
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelProxyFactoryType.java (original)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelProxyFactoryType.java Tue Aug 7 14:33:00 2007
@@ -1,4 +1,4 @@
-/*
+/**
* 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.
@@ -16,10 +16,10 @@
*/
package org.apache.camel.spring;
-import org.apache.camel.model.IdentifiedType;
-
-import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.apache.camel.model.IdentifiedType;
/**
* @version $Revision: $
Modified: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelServiceExporterType.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelServiceExporterType.java?view=diff&rev=563665&r1=563664&r2=563665
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelServiceExporterType.java (original)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelServiceExporterType.java Tue Aug 7 14:33:00 2007
@@ -1,4 +1,4 @@
-/*
+/**
* 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.
@@ -16,10 +16,10 @@
*/
package org.apache.camel.spring;
-import org.apache.camel.model.IdentifiedType;
-
-import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.apache.camel.model.IdentifiedType;
/**
* @version $Revision: $
Modified: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelTemplateFactoryBean.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelTemplateFactoryBean.java?view=diff&rev=563665&r1=563664&r2=563665
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelTemplateFactoryBean.java (original)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelTemplateFactoryBean.java Tue Aug 7 14:33:00 2007
@@ -1,4 +1,4 @@
-/*
+/**
* 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.
@@ -16,23 +16,24 @@
*/
package org.apache.camel.spring;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+
import org.apache.camel.CamelContext;
import org.apache.camel.CamelContextAware;
import org.apache.camel.CamelTemplate;
import org.apache.camel.Endpoint;
+
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.InitializingBean;
-import javax.xml.bind.annotation.XmlTransient;
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAttribute;
-
/**
- * A Spring {@link FactoryBean} for creating a new {@link CamelTemplate} instance
- * with a minimum of XML
- *
+ * A Spring {@link FactoryBean} for creating a new {@link CamelTemplate}
+ * instance with a minimum of XML
+ *
* @version $Revision: $
*/
@XmlRootElement(name = "camelTemplate")
@@ -55,8 +56,7 @@
Endpoint endpoint = context.getEndpoint(defaultEndpoint);
if (endpoint == null) {
throw new IllegalArgumentException("No endpoint found for URI: " + defaultEndpoint);
- }
- else {
+ } else {
return new CamelTemplate(context, endpoint);
}
}
@@ -71,9 +71,8 @@
return true;
}
-
// Properties
- //-------------------------------------------------------------------------
+ // -------------------------------------------------------------------------
public CamelContext getCamelContext() {
return camelContext;
}
@@ -87,7 +86,8 @@
}
/**
- * Sets the default endpoint URI used by default for sending message exchanges
+ * Sets the default endpoint URI used by default for sending message
+ * exchanges
*/
public void setDefaultEndpoint(String defaultEndpoint) {
this.defaultEndpoint = defaultEndpoint;
Modified: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/EndpointFactoryBean.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/EndpointFactoryBean.java?view=diff&rev=563665&r1=563664&r2=563665
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/EndpointFactoryBean.java (original)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/EndpointFactoryBean.java Tue Aug 7 14:33:00 2007
@@ -1,5 +1,4 @@
/**
- *
* 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.
@@ -7,7 +6,7 @@
* (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
+ * 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,
@@ -17,17 +16,19 @@
*/
package org.apache.camel.spring;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+
import org.apache.camel.CamelContext;
import org.apache.camel.Endpoint;
import org.apache.camel.model.IdentifiedType;
-import static org.apache.camel.util.ObjectHelper.notNull;
+
import org.springframework.beans.factory.FactoryBean;
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlTransient;
+import static org.apache.camel.util.ObjectHelper.notNull;
/**
* A {@link FactoryBean} which instantiates {@link Endpoint} objects
Modified: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/Main.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/Main.java?view=diff&rev=563665&r1=563664&r2=563665
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/Main.java (original)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/Main.java Tue Aug 7 14:33:00 2007
@@ -1,4 +1,4 @@
-/*
+/**
* 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.
@@ -16,12 +16,6 @@
*/
package org.apache.camel.spring;
-import org.apache.camel.impl.ServiceSupport;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.springframework.context.support.AbstractApplicationContext;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
@@ -29,25 +23,27 @@
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicBoolean;
+import org.apache.camel.impl.ServiceSupport;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.springframework.context.support.AbstractApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
/**
- * A command line tool for booting up a CamelContext using an
- * optional Spring ApplicationContext
- *
+ * A command line tool for booting up a CamelContext using an optional Spring
+ * ApplicationContext
+ *
* @version $Revision: $
*/
public class Main extends ServiceSupport {
- private static final Log log = LogFactory.getLog(Main.class);
+ private static final Log LOG = LogFactory.getLog(Main.class);
private String applicationContextUri = "META-INF/spring/*.xml";
private AbstractApplicationContext applicationContext;
private List<Option> options = new ArrayList<Option>();
private CountDownLatch latch = new CountDownLatch(1);
private AtomicBoolean completed = new AtomicBoolean(false);
- public static void main(String[] args) {
- Main main = new Main();
- main.run(args);
- }
-
public Main() {
addOption(new Option("h", "help", "Displays the help screen") {
protected void doProcess(String arg, LinkedList<String> remainingArgs) {
@@ -63,6 +59,11 @@
});
}
+ public static void main(String[] args) {
+ Main main = new Main();
+ main.run(args);
+ }
+
/**
* Parses the command line arguments then runs the program
*/
@@ -80,9 +81,8 @@
start();
waitUntilCompleted();
stop();
- }
- catch (Exception e) {
- log.error("Failed: " + e, e);
+ } catch (Exception e) {
+ LOG.error("Failed: " + e, e);
}
}
}
@@ -103,8 +103,7 @@
System.out.println();
for (Option option : options) {
- System.out.println(" " + option.getAbbreviation() + " or " + option.getFullName()
- + " = " + option.getDescription());
+ System.out.println(" " + option.getAbbreviation() + " or " + option.getFullName() + " = " + option.getDescription());
}
}
@@ -189,8 +188,7 @@
System.err.println("Expected fileName for ");
showOptions();
completed();
- }
- else {
+ } else {
String parameter = remainingArgs.removeFirst();
doProcess(arg, parameter, remainingArgs);
}
@@ -200,7 +198,7 @@
}
// Properties
- //-------------------------------------------------------------------------
+ // -------------------------------------------------------------------------
public AbstractApplicationContext getApplicationContext() {
return applicationContext;
}
@@ -218,9 +216,9 @@
}
// Implementation methods
- //-------------------------------------------------------------------------
+ // -------------------------------------------------------------------------
protected void doStart() throws Exception {
- log.info("Apache Camel " + getVersion() + " starting");
+ LOG.info("Apache Camel " + getVersion() + " starting");
if (applicationContext == null) {
applicationContext = createDefaultApplicationContext();
}
@@ -232,7 +230,7 @@
}
protected void doStop() throws Exception {
- log.info("Apache Camel terminating");
+ LOG.info("Apache Camel terminating");
if (applicationContext != null) {
applicationContext.close();
@@ -243,8 +241,7 @@
while (!completed.get()) {
try {
latch.await();
- }
- catch (InterruptedException e) {
+ } catch (InterruptedException e) {
// ignore
}
}
Modified: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/RouteBuilderFinder.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/RouteBuilderFinder.java?view=diff&rev=563665&r1=563664&r2=563665
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/RouteBuilderFinder.java (original)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/RouteBuilderFinder.java Tue Aug 7 14:33:00 2007
@@ -1,5 +1,4 @@
/**
- *
* 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.
@@ -7,7 +6,7 @@
* (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
+ * 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,
@@ -17,14 +16,15 @@
*/
package org.apache.camel.spring;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.util.ResolverUtil;
-import org.springframework.context.ApplicationContext;
-
import java.lang.reflect.Modifier;
import java.util.List;
import java.util.Map;
import java.util.Set;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.util.ResolverUtil;
+
+import org.springframework.context.ApplicationContext;
/**
* A helper class which will find all {@link RouteBuilder} instances on the classpath
Modified: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/SpringCamelContext.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/SpringCamelContext.java?view=diff&rev=563665&r1=563664&r2=563665
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/SpringCamelContext.java (original)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/SpringCamelContext.java Tue Aug 7 14:33:00 2007
@@ -1,5 +1,4 @@
/**
- *
* 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.
@@ -7,7 +6,7 @@
* (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
+ * 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,
@@ -17,7 +16,6 @@
*/
package org.apache.camel.spring;
-import org.apache.camel.CamelContext;
import org.apache.camel.Endpoint;
import org.apache.camel.Processor;
import org.apache.camel.RuntimeCamelException;
@@ -34,6 +32,7 @@
import org.apache.camel.spring.spi.SpringInjector;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
@@ -47,15 +46,17 @@
import org.springframework.context.support.ClassPathXmlApplicationContext;
/**
- * A Spring aware implementation of {@link CamelContext} which will automatically register itself with Springs lifecycle
- * methods plus allows spring to be used to customize a any
- * <a href="http://activemq.apache.org/camel/type-converter.html">Type Converters</a> as well as supporting accessing components
- * and beans via the Spring {@link ApplicationContext}
- *
+ * A Spring aware implementation of {@link CamelContext} which will
+ * automatically register itself with Springs lifecycle methods plus allows
+ * spring to be used to customize a any <a
+ * href="http://activemq.apache.org/camel/type-converter.html">Type Converters</a>
+ * as well as supporting accessing components and beans via the Spring
+ * {@link ApplicationContext}
+ *
* @version $Revision$
*/
public class SpringCamelContext extends DefaultCamelContext implements InitializingBean, DisposableBean, ApplicationContextAware, ApplicationListener {
- private static final transient Log log = LogFactory.getLog(SpringCamelContext.class);
+ private static final transient Log LOG = LogFactory.getLog(SpringCamelContext.class);
private ApplicationContext applicationContext;
private EventEndpoint eventEndpoint;
@@ -70,7 +71,7 @@
// lets try and look up a configured camel context in the context
String[] names = applicationContext.getBeanNamesForType(SpringCamelContext.class);
if (names.length == 1) {
- return (SpringCamelContext) applicationContext.getBean(names[0], SpringCamelContext.class);
+ return (SpringCamelContext)applicationContext.getBean(names[0], SpringCamelContext.class);
}
SpringCamelContext answer = new SpringCamelContext();
answer.setApplicationContext(applicationContext);
@@ -91,35 +92,33 @@
}
public void onApplicationEvent(ApplicationEvent event) {
- if (log.isDebugEnabled()) {
- log.debug("Publishing event: " + event);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Publishing event: " + event);
}
if (event instanceof ContextRefreshedEvent) {
- // now lets start the CamelContext so that all its possible dependencies are initailized
+ // now lets start the CamelContext so that all its possible
+ // dependencies are initailized
try {
- log.debug("Starting the CamelContext now that the ApplicationContext has started");
+ LOG.debug("Starting the CamelContext now that the ApplicationContext has started");
start();
- }
- catch (Exception e) {
+ } catch (Exception e) {
throw new RuntimeCamelException(e);
}
if (eventEndpoint != null) {
eventEndpoint.onApplicationEvent(event);
}
- }
- else {
+ } else {
if (eventEndpoint != null) {
eventEndpoint.onApplicationEvent(event);
- }
- else {
- log.warn("No eventEndpoint enabled for event: " + event);
+ } else {
+ LOG.warn("No eventEndpoint enabled for event: " + event);
}
}
}
// Properties
- //-----------------------------------------------------------------------
+ // -----------------------------------------------------------------------
public ApplicationContext getApplicationContext() {
return applicationContext;
@@ -142,7 +141,7 @@
}
// Implementation methods
- //-----------------------------------------------------------------------
+ // -----------------------------------------------------------------------
@Override
protected void doStart() throws Exception {
@@ -154,7 +153,7 @@
@Override
protected Injector createInjector() {
- return new SpringInjector((AbstractRefreshableApplicationContext) getApplicationContext());
+ return new SpringInjector((AbstractRefreshableApplicationContext)getApplicationContext());
}
@Override
Modified: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/SpringRouteBuilder.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/SpringRouteBuilder.java?view=diff&rev=563665&r1=563664&r2=563665
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/SpringRouteBuilder.java (original)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/SpringRouteBuilder.java Tue Aug 7 14:33:00 2007
@@ -1,5 +1,4 @@
/**
- *
* 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.
@@ -7,7 +6,7 @@
* (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
+ * 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,
@@ -20,12 +19,14 @@
import org.apache.camel.CamelContext;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.spring.spi.TransactionInterceptor;
+
import org.springframework.context.ApplicationContext;
import org.springframework.transaction.support.TransactionTemplate;
/**
- * An extension of the {@link RouteBuilder} to provide some additional helper methods
- *
+ * An extension of the {@link RouteBuilder} to provide some additional helper
+ * methods
+ *
* @version $Revision: 1.1 $
*/
public abstract class SpringRouteBuilder extends RouteBuilder {
@@ -36,22 +37,24 @@
}
/**
- * Looks up the bean with the given name in the application context and returns it, or throws an exception if the
- * bean is not present or is not of the given type
- *
- * @param type the type of the bean
+ * Looks up the bean with the given name in the application context and
+ * returns it, or throws an exception if the bean is not present or is not
+ * of the given type
+ *
+ * @param type the type of the bean
* @param beanName the name of the bean in the application context
* @return the bean
*/
public <T> T bean(Class<T> type, String beanName) {
ApplicationContext context = getApplicationContext();
- return (T) context.getBean(beanName, type);
+ return (T)context.getBean(beanName, type);
}
/**
- * Looks up the bean with the given type in the application context and returns it, or throws an exception if the
- * bean is not present or there are multiple possible beans to choose from for the given type
- *
+ * Looks up the bean with the given type in the application context and
+ * returns it, or throws an exception if the bean is not present or there
+ * are multiple possible beans to choose from for the given type
+ *
* @param type the type of the bean
* @return the bean
*/
@@ -62,9 +65,8 @@
int count = names.length;
if (count == 1) {
// lets instantiate the single bean
- return (T) context.getBean(names[0]);
- }
- else if (count > 1) {
+ return (T)context.getBean(names[0]);
+ } else if (count > 1) {
throw new IllegalArgumentException("Too many beans in the application context of type: " + type + ". Found: " + count);
}
}
@@ -72,19 +74,19 @@
}
/**
- * Returns the application context which has been configured via the {@link #setApplicationContext(ApplicationContext)}
- * method or from the underlying {@link SpringCamelContext}
- *
+ * Returns the application context which has been configured via the
+ * {@link #setApplicationContext(ApplicationContext)} method or from the
+ * underlying {@link SpringCamelContext}
+ *
* @return
*/
public ApplicationContext getApplicationContext() {
if (applicationContext == null) {
CamelContext camelContext = getContext();
if (camelContext instanceof SpringCamelContext) {
- SpringCamelContext springCamelContext = (SpringCamelContext) camelContext;
+ SpringCamelContext springCamelContext = (SpringCamelContext)camelContext;
return springCamelContext.getApplicationContext();
- }
- else {
+ } else {
throw new IllegalArgumentException("This SpringBuilder is not being used with a SpringCamelContext and there is no applicationContext property configured");
}
}
Modified: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/BeanDefinitionParser.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/BeanDefinitionParser.java?view=diff&rev=563665&r1=563664&r2=563665
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/BeanDefinitionParser.java (original)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/BeanDefinitionParser.java Tue Aug 7 14:33:00 2007
@@ -1,5 +1,4 @@
/**
- *
* 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.
@@ -7,7 +6,7 @@
* (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
+ * 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,
@@ -17,8 +16,9 @@
*/
package org.apache.camel.spring.handler;
-import org.springframework.beans.factory.xml.AbstractSimpleBeanDefinitionParser;
import org.w3c.dom.Element;
+
+import org.springframework.beans.factory.xml.AbstractSimpleBeanDefinitionParser;
/**
* A base class for a parser for a bean.
Modified: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java?view=diff&rev=563665&r1=563664&r2=563665
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java (original)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java Tue Aug 7 14:33:00 2007
@@ -1,5 +1,4 @@
/**
- *
* 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.
@@ -7,7 +6,7 @@
* (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
+ * 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,
@@ -17,6 +16,17 @@
*/
package org.apache.camel.spring.handler;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Unmarshaller;
+
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
import org.apache.camel.builder.xml.XPathBuilder;
import org.apache.camel.spring.CamelBeanPostProcessor;
import org.apache.camel.spring.CamelContextFactoryBean;
@@ -24,7 +34,7 @@
import org.apache.camel.spring.remoting.CamelProxyFactoryBean;
import org.apache.camel.spring.remoting.CamelServiceExporter;
import org.apache.camel.util.ObjectHelper;
-import static org.apache.camel.util.ObjectHelper.isNotNullAndNonEmpty;
+
import org.springframework.beans.factory.BeanDefinitionStoreException;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.RuntimeBeanReference;
@@ -33,15 +43,8 @@
import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.util.xml.DomUtils;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Unmarshaller;
-import java.util.HashSet;
-import java.util.Set;
+import static org.apache.camel.util.ObjectHelper.isNotNullAndNonEmpty;
public class CamelNamespaceHandler extends NamespaceHandlerSupport {
public static final String JAXB_PACKAGES = "org.apache.camel.spring:org.apache.camel.model:org.apache.camel.model.language";
@@ -66,7 +69,8 @@
String contextId = element.getAttribute("id");
- // lets avoid folks having to explicitly give an ID to a camel context
+ // lets avoid folks having to explicitly give an ID to a camel
+ // context
if (ObjectHelper.isNullOrBlank(contextId)) {
contextId = "camelContext";
element.setAttribute("id", contextId);
@@ -75,7 +79,7 @@
// now lets parse the routes
Object value = parseUsingJaxb(element, parserContext);
if (value instanceof CamelContextFactoryBean) {
- CamelContextFactoryBean factoryBean = (CamelContextFactoryBean) value;
+ CamelContextFactoryBean factoryBean = (CamelContextFactoryBean)value;
builder.addPropertyValue("routes", factoryBean.getRoutes());
if (factoryBean.getPackages().length > 0) {
@@ -85,33 +89,32 @@
boolean createdBeanPostProcessor = false;
NodeList list = element.getChildNodes();
- for (int size = list.getLength(), i = 0; i < size; i++) {
+ int size = list.getLength();
+ for (int i = 0; i < size; i++) {
Node child = list.item(i);
if (child instanceof Element) {
- Element childElement = (Element) child;
+ Element childElement = (Element)child;
String localName = child.getLocalName();
if (localName.equals("beanPostProcessor")) {
createBeanPostProcessor(parserContext, contextId, childElement);
createdBeanPostProcessor = true;
- }
- else if (localName.equals("endpoint")) {
+ } else if (localName.equals("endpoint")) {
BeanDefinition definition = endpointParser.parse(childElement, parserContext);
String id = childElement.getAttribute("id");
if (isNotNullAndNonEmpty(id)) {
// TODO we can zap this?
definition.getPropertyValues().addPropertyValue("context", new RuntimeBeanReference(contextId));
- //definition.getPropertyValues().addPropertyValue("context", builder.getBeanDefinition());
+ // definition.getPropertyValues().addPropertyValue("context",
+ // builder.getBeanDefinition());
parserContext.registerComponent(new BeanComponentDefinition(definition, id));
}
- }
- else if (localName.equals("proxy")) {
+ } else if (localName.equals("proxy")) {
BeanDefinition definition = proxyParser.parse(childElement, parserContext);
String id = childElement.getAttribute("id");
if (isNotNullAndNonEmpty(id)) {
parserContext.registerComponent(new BeanComponentDefinition(definition, id));
}
- }
- else if (localName.equals("export")) {
+ } else if (localName.equals("export")) {
BeanDefinition definition = exportParser.parse(childElement, parserContext);
String id = childElement.getAttribute("id");
if (isNotNullAndNonEmpty(id)) {
@@ -165,16 +168,15 @@
try {
Unmarshaller unmarshaller = getJaxbContext().createUnmarshaller();
return unmarshaller.unmarshal(element);
- }
- catch (JAXBException e) {
+ } catch (JAXBException e) {
throw new BeanDefinitionStoreException("Failed to parse JAXB element: " + e, e);
}
}
protected JAXBContext getJaxbContext() throws JAXBException {
if (jaxbContext == null) {
- jaxbContext = JAXBContext.newInstance(JAXB_PACKAGES);
+ jaxbContext = JAXBContext.newInstance(JAXB_PACKAGES);
}
return jaxbContext;
}
-}
\ No newline at end of file
+}
Modified: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/LazyLoadingBeanDefinitionParser.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/LazyLoadingBeanDefinitionParser.java?view=diff&rev=563665&r1=563664&r2=563665
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/LazyLoadingBeanDefinitionParser.java (original)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/LazyLoadingBeanDefinitionParser.java Tue Aug 7 14:33:00 2007
@@ -1,5 +1,4 @@
/**
- *
* 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.
@@ -7,7 +6,7 @@
* (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
+ * 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,
@@ -18,7 +17,6 @@
package org.apache.camel.spring.handler;
import org.apache.camel.util.ObjectHelper;
-import org.apache.camel.spring.handler.BeanDefinitionParser;
/**
* A {@link BeanDefinitionParser} which lazy loads the type on which it creates to allow the schema to be loosly coupled
Modified: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/ScriptDefinitionParser.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/ScriptDefinitionParser.java?view=diff&rev=563665&r1=563664&r2=563665
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/ScriptDefinitionParser.java (original)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/ScriptDefinitionParser.java Tue Aug 7 14:33:00 2007
@@ -1,5 +1,4 @@
/**
- *
* 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.
@@ -7,7 +6,7 @@
* (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
+ * 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,
@@ -17,10 +16,11 @@
*/
package org.apache.camel.spring.handler;
+import org.w3c.dom.Element;
+
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.util.xml.DomUtils;
-import org.w3c.dom.Element;
/**
* A parser of the various scripting language expressions
Modified: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/package-info.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/package-info.java?view=diff&rev=563665&r1=563664&r2=563665
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/package-info.java (original)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/package-info.java Tue Aug 7 14:33:00 2007
@@ -1,5 +1,4 @@
/**
- *
* 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.
@@ -7,7 +6,7 @@
* (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
+ * 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,
Modified: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/remoting/CamelProxyFactoryBean.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/remoting/CamelProxyFactoryBean.java?view=diff&rev=563665&r1=563664&r2=563665
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/remoting/CamelProxyFactoryBean.java (original)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/remoting/CamelProxyFactoryBean.java Tue Aug 7 14:33:00 2007
@@ -1,5 +1,4 @@
/**
- *
* 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.
@@ -7,7 +6,7 @@
* (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
+ * 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,
@@ -21,12 +20,13 @@
import org.apache.camel.CamelContextAware;
import org.apache.camel.Endpoint;
import org.apache.camel.component.bean.ProxyHelper;
+
import org.springframework.beans.factory.FactoryBean;
import org.springframework.remoting.support.UrlBasedRemoteAccessor;
/**
* A {@link FactoryBean} to create a Proxy to a a Camel Pojo Endpoint.
- *
+ *
* @author chirino
*/
public class CamelProxyFactoryBean extends UrlBasedRemoteAccessor implements FactoryBean, CamelContextAware {
@@ -50,38 +50,31 @@
}
this.serviceProxy = ProxyHelper.createProxy(endpoint, getServiceInterface());
- }
- catch (Exception e) {
+ } catch (Exception e) {
throw new IllegalArgumentException(e);
}
}
-
public Class getServiceInterface() {
return super.getServiceInterface();
}
-
public String getServiceUrl() {
return super.getServiceUrl();
}
-
public Object getObject() throws Exception {
return serviceProxy;
}
-
public Class getObjectType() {
return getServiceInterface();
}
-
public boolean isSingleton() {
return true;
}
-
public Endpoint getEndpoint() {
return endpoint;
}
@@ -89,7 +82,6 @@
public void setEndpoint(Endpoint endpoint) {
this.endpoint = endpoint;
}
-
public CamelContext getCamelContext() {
return camelContext;
Modified: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/remoting/CamelServiceExporter.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/remoting/CamelServiceExporter.java?view=diff&rev=563665&r1=563664&r2=563665
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/remoting/CamelServiceExporter.java (original)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/remoting/CamelServiceExporter.java Tue Aug 7 14:33:00 2007
@@ -1,5 +1,4 @@
/**
- *
* 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.
@@ -7,7 +6,7 @@
* (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
+ * 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,
@@ -23,14 +22,15 @@
import org.apache.camel.Endpoint;
import org.apache.camel.component.bean.BeanProcessor;
import org.apache.camel.util.CamelContextHelper;
-import static org.apache.camel.util.ObjectHelper.notNull;
+
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.DisposableBean;
-import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.remoting.support.RemoteExporter;
+
+import static org.apache.camel.util.ObjectHelper.notNull;
/**
* A {@link FactoryBean} to create a proxy to a service exposing a given {@link #getServiceInterface()}
Modified: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/remoting/SendBeforeInterceptor.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/remoting/SendBeforeInterceptor.java?view=diff&rev=563665&r1=563664&r2=563665
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/remoting/SendBeforeInterceptor.java (original)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/remoting/SendBeforeInterceptor.java Tue Aug 7 14:33:00 2007
@@ -1,4 +1,4 @@
-/*
+/**
* 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.
@@ -18,15 +18,18 @@
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
+
import org.apache.camel.CamelContext;
import org.apache.camel.CamelContextAware;
import org.apache.camel.Endpoint;
import org.apache.camel.Producer;
import org.apache.camel.component.bean.CamelInvocationHandler;
import org.apache.camel.util.CamelContextHelper;
-import static org.apache.camel.util.ObjectHelper.notNull;
+
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
+
+import static org.apache.camel.util.ObjectHelper.notNull;
/**
* A Spring interceptor which sends a message exchange to an endpoint before the method is invoked
Modified: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/spi/ApplicationContextRegistry.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/spi/ApplicationContextRegistry.java?view=diff&rev=563665&r1=563664&r2=563665
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/spi/ApplicationContextRegistry.java (original)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/spi/ApplicationContextRegistry.java Tue Aug 7 14:33:00 2007
@@ -1,5 +1,4 @@
/**
- *
* 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.
@@ -7,7 +6,7 @@
* (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
+ * 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,
@@ -18,13 +17,14 @@
package org.apache.camel.spring.spi;
import org.apache.camel.spi.Registry;
+
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.context.ApplicationContext;
/**
* A {@link Registry} implementation which looks up the objects in the Spring
* {@link ApplicationContext}
- *
+ *
* @version $Revision: 1.1 $
*/
public class ApplicationContextRegistry implements Registry {
@@ -38,8 +38,7 @@
try {
Object value = applicationContext.getBean(name, type);
return type.cast(value);
- }
- catch (NoSuchBeanDefinitionException e) {
+ } catch (NoSuchBeanDefinitionException e) {
return null;
}
}
@@ -47,9 +46,8 @@
public Object lookup(String name) {
try {
return applicationContext.getBean(name);
- }
- catch (NoSuchBeanDefinitionException e) {
+ } catch (NoSuchBeanDefinitionException e) {
return null;
}
}
-}
\ No newline at end of file
+}
Modified: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/spi/BeanInjector.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/spi/BeanInjector.java?view=diff&rev=563665&r1=563664&r2=563665
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/spi/BeanInjector.java (original)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/spi/BeanInjector.java Tue Aug 7 14:33:00 2007
@@ -1,5 +1,4 @@
/**
- *
* 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.
@@ -7,7 +6,7 @@
* (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
+ * 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,
Modified: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/spi/SpringComponentResolver.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/spi/SpringComponentResolver.java?view=diff&rev=563665&r1=563664&r2=563665
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/spi/SpringComponentResolver.java (original)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/spi/SpringComponentResolver.java Tue Aug 7 14:33:00 2007
@@ -1,5 +1,4 @@
/**
- *
* 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.
@@ -7,7 +6,7 @@
* (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
+ * 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,
@@ -20,14 +19,17 @@
import org.apache.camel.CamelContext;
import org.apache.camel.Component;
import org.apache.camel.spi.ComponentResolver;
-import static org.apache.camel.util.ObjectHelper.notNull;
+
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.context.ApplicationContext;
+import static org.apache.camel.util.ObjectHelper.notNull;
+
/**
- * An implementation of {@link ComponentResolver} which tries to find a Camel {@link Component}
- * in the Spring {@link ApplicationContext} first; if its not there it defaults to the auto-discovery mechanism.
- *
+ * An implementation of {@link ComponentResolver} which tries to find a Camel
+ * {@link Component} in the Spring {@link ApplicationContext} first; if its not
+ * there it defaults to the auto-discovery mechanism.
+ *
* @version $Revision$
*/
public class SpringComponentResolver implements ComponentResolver {
@@ -44,15 +46,13 @@
Object bean = null;
try {
bean = applicationContext.getBean(name);
- }
- catch (NoSuchBeanDefinitionException e) {
+ } catch (NoSuchBeanDefinitionException e) {
// ignore its not an error
}
if (bean != null) {
if (bean instanceof Component) {
- return (Component) bean;
- }
- else {
+ return (Component)bean;
+ } else {
throw new IllegalArgumentException("Bean with name: " + name + " in spring context is not a Component: " + bean);
}
}
Modified: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/spi/SpringConverters.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/spi/SpringConverters.java?view=diff&rev=563665&r1=563664&r2=563665
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/spi/SpringConverters.java (original)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/spi/SpringConverters.java Tue Aug 7 14:33:00 2007
@@ -1,5 +1,4 @@
/**
- *
* 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.
@@ -7,7 +6,7 @@
* (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
+ * 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,
@@ -17,18 +16,21 @@
*/
package org.apache.camel.spring.spi;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+import org.aopalliance.intercept.MethodInvocation;
+
import org.apache.camel.Converter;
import org.apache.camel.component.bean.BeanInvocation;
+
import org.springframework.core.io.ByteArrayResource;
import org.springframework.core.io.FileSystemResource;
import org.springframework.core.io.Resource;
import org.springframework.core.io.UrlResource;
-import org.aopalliance.intercept.MethodInvocation;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
/**
* Some Spring based
@@ -37,7 +39,11 @@
* @version $Revision$
*/
@Converter
-public class SpringConverters {
+public final class SpringConverters {
+
+ private SpringConverters() {
+ }
+
@Converter
public static InputStream toInputStream(Resource resource) throws IOException {
return resource.getInputStream();
Modified: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/spi/SpringInjector.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/spi/SpringInjector.java?view=diff&rev=563665&r1=563664&r2=563665
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/spi/SpringInjector.java (original)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/spi/SpringInjector.java Tue Aug 7 14:33:00 2007
@@ -1,5 +1,4 @@
/**
- *
* 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.
@@ -7,7 +6,7 @@
* (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
+ * 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,
@@ -17,10 +16,10 @@
*/
package org.apache.camel.spring.spi;
-import org.apache.camel.impl.ReflectionInjector;
import org.apache.camel.spi.Injector;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
import org.springframework.context.support.AbstractRefreshableApplicationContext;
@@ -30,10 +29,10 @@
* @version $Revision$
*/
public class SpringInjector implements Injector {
- private static final transient Log log = LogFactory.getLog(SpringInjector.class);
+ private static final transient Log LOG = LogFactory.getLog(SpringInjector.class);
private final AbstractRefreshableApplicationContext applicationContext;
private int autowireMode = AutowireCapableBeanFactory.AUTOWIRE_CONSTRUCTOR;
- private boolean dependencyCheck = false;
+ private boolean dependencyCheck;
public SpringInjector(AbstractRefreshableApplicationContext applicationContext) {
this.applicationContext = applicationContext;
Modified: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/spi/SpringTransactionPolicy.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/spi/SpringTransactionPolicy.java?view=diff&rev=563665&r1=563664&r2=563665
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/spi/SpringTransactionPolicy.java (original)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/spi/SpringTransactionPolicy.java Tue Aug 7 14:33:00 2007
@@ -1,5 +1,4 @@
/**
- *
* 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.
@@ -7,7 +6,7 @@
* (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
+ * 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,
@@ -29,7 +28,7 @@
* @version $Revision: 1.1 $
*/
public class SpringTransactionPolicy<E> implements Policy<E> {
- private static final transient Log log = LogFactory.getLog(SpringTransactionPolicy.class);
+ private static final transient Log LOG = LogFactory.getLog(SpringTransactionPolicy.class);
private TransactionTemplate template;
public SpringTransactionPolicy(TransactionTemplate template) {
@@ -39,7 +38,7 @@
public Processor wrap(Processor processor) {
final TransactionTemplate transactionTemplate = getTemplate();
if (transactionTemplate == null) {
- log.warn("No TransactionTemplate available so transactions will not be enabled!");
+ LOG.warn("No TransactionTemplate available so transactions will not be enabled!");
return processor;
}
Modified: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/spi/TransactionInterceptor.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/spi/TransactionInterceptor.java?view=diff&rev=563665&r1=563664&r2=563665
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/spi/TransactionInterceptor.java (original)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/spi/TransactionInterceptor.java Tue Aug 7 14:33:00 2007
@@ -1,5 +1,4 @@
/**
- *
* 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.
@@ -7,7 +6,7 @@
* (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
+ * 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,
@@ -18,11 +17,11 @@
package org.apache.camel.spring.spi;
import org.apache.camel.Exchange;
-import org.apache.camel.Processor;
import org.apache.camel.RuntimeCamelException;
import org.apache.camel.processor.DelegateProcessor;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.support.TransactionCallbackWithoutResult;
@@ -32,7 +31,7 @@
* @version $Revision: 1.1 $
*/
public class TransactionInterceptor extends DelegateProcessor {
- private static final transient Log log = LogFactory.getLog(TransactionInterceptor.class);
+ private static final transient Log LOG = LogFactory.getLog(TransactionInterceptor.class);
private final TransactionTemplate transactionTemplate;
public TransactionInterceptor(TransactionTemplate transactionTemplate) {
@@ -40,20 +39,19 @@
}
public void process(final Exchange exchange) {
- log.info("transaction begin");
+ LOG.info("transaction begin");
transactionTemplate.execute(new TransactionCallbackWithoutResult() {
protected void doInTransactionWithoutResult(TransactionStatus status) {
try {
processNext(exchange);
- }
- catch (Exception e) {
+ } catch (Exception e) {
throw new RuntimeCamelException(e);
}
}
});
- log.info("transaction commit");
+ LOG.info("transaction commit");
}
@Override
@@ -62,22 +60,32 @@
}
private String propagationBehaviorToString(int propagationBehavior) {
+ String rc;
switch (propagationBehavior) {
- case TransactionDefinition.PROPAGATION_MANDATORY:
- return "PROPAGATION_MANDATORY";
- case TransactionDefinition.PROPAGATION_NESTED:
- return "PROPAGATION_NESTED";
- case TransactionDefinition.PROPAGATION_NEVER:
- return "PROPAGATION_NEVER";
- case TransactionDefinition.PROPAGATION_NOT_SUPPORTED:
- return "PROPAGATION_NOT_SUPPORTED";
- case TransactionDefinition.PROPAGATION_REQUIRED:
- return "PROPAGATION_REQUIRED";
- case TransactionDefinition.PROPAGATION_REQUIRES_NEW:
- return "PROPAGATION_REQUIRES_NEW";
- case TransactionDefinition.PROPAGATION_SUPPORTS:
- return "PROPAGATION_SUPPORTS";
+ case TransactionDefinition.PROPAGATION_MANDATORY:
+ rc = "PROPAGATION_MANDATORY";
+ break;
+ case TransactionDefinition.PROPAGATION_NESTED:
+ rc = "PROPAGATION_NESTED";
+ break;
+ case TransactionDefinition.PROPAGATION_NEVER:
+ rc = "PROPAGATION_NEVER";
+ break;
+ case TransactionDefinition.PROPAGATION_NOT_SUPPORTED:
+ rc = "PROPAGATION_NOT_SUPPORTED";
+ break;
+ case TransactionDefinition.PROPAGATION_REQUIRED:
+ rc = "PROPAGATION_REQUIRED";
+ break;
+ case TransactionDefinition.PROPAGATION_REQUIRES_NEW:
+ rc = "PROPAGATION_REQUIRES_NEW";
+ break;
+ case TransactionDefinition.PROPAGATION_SUPPORTS:
+ rc = "PROPAGATION_SUPPORTS";
+ break;
+ default:
+ rc = "UNKOWN";
}
- return "UNKOWN";
+ return rc;
}
}
Modified: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/util/MainRunner.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/util/MainRunner.java?view=diff&rev=563665&r1=563664&r2=563665
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/util/MainRunner.java (original)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/util/MainRunner.java Tue Aug 7 14:33:00 2007
@@ -1,4 +1,4 @@
-/*
+/**
* 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.
@@ -16,49 +16,47 @@
*/
package org.apache.camel.spring.util;
-import static org.apache.camel.util.ObjectHelper.name;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.camel.util.ObjectHelper;
-import org.springframework.beans.factory.InitializingBean;
-
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.Arrays;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.springframework.beans.factory.InitializingBean;
+
+import static org.apache.camel.util.ObjectHelper.name;
+
/**
* A simple helper bean for running main classes from within the spring.xml
- * usually asynchronous in a background thread; which is useful for demos
- * such as running Swing programs in the same JVM.
- *
+ * usually asynchronous in a background thread; which is useful for demos such
+ * as running Swing programs in the same JVM.
+ *
* @version $Revision: $
*/
public class MainRunner implements InitializingBean, Runnable {
- private static final Log log = LogFactory.getLog(MainRunner.class);
+ private static final Log LOG = LogFactory.getLog(MainRunner.class);
private Class main;
private String[] args = {};
private boolean asyncRun = true;
- private long delay = 0;
+ private long delay;
public String toString() {
- return "MainRunner(" + name(main) + " " + Arrays.asList(getArgs()) +")";
+ return "MainRunner(" + name(main) + " " + Arrays.asList(getArgs()) + ")";
}
public void run() {
try {
runMethodWithoutCatchingExceptions();
- }
- catch (NoSuchMethodException e) {
- log.error("Class: " + name(main) + " does not have a main method: " + e, e);
- }
- catch (IllegalAccessException e) {
- log.error("Failed to run: " + this + ". Reason: " + e, e);
- }
- catch (InvocationTargetException e) {
+ } catch (NoSuchMethodException e) {
+ LOG.error("Class: " + name(main) + " does not have a main method: " + e, e);
+ } catch (IllegalAccessException e) {
+ LOG.error("Failed to run: " + this + ". Reason: " + e, e);
+ } catch (InvocationTargetException e) {
Throwable throwable = e.getTargetException();
- log.error("Failed to run: " + this + ". Reason: " + throwable, throwable);
+ LOG.error("Failed to run: " + this + ". Reason: " + throwable, throwable);
}
}
@@ -66,9 +64,8 @@
if (delay > 0) {
try {
Thread.sleep(delay);
- }
- catch (InterruptedException e) {
- log.info("Caught: " + e, e);
+ } catch (InterruptedException e) {
+ LOG.info("Caught: " + e, e);
}
}
Method method = main.getMethod("main", String[].class);
@@ -118,8 +115,7 @@
if (isAsyncRun()) {
Thread thread = new Thread(this, "Thread for: " + this);
thread.start();
- }
- else {
+ } else {
runMethodWithoutCatchingExceptions();
}
}