Added additional libs property
parent
ab8d285968
commit
716363aec4
|
@ -31,9 +31,9 @@ public interface CamelSEConfigMBean {
|
|||
|
||||
public String getIncludeCamelLibs();
|
||||
|
||||
public void setExcludeCamelLibs(String excludeLibs);
|
||||
public void setAdditionalLibs(String additionalLibs);
|
||||
|
||||
public String getExcludeCamelLibs();
|
||||
public String getAdditionalLibs();
|
||||
|
||||
public static class CamelSEConfigMBeanImpl implements CamelSEConfigMBean {
|
||||
|
||||
|
@ -42,7 +42,7 @@ public interface CamelSEConfigMBean {
|
|||
//private static final String PROP_CAMEL_HOME = "camel.home";
|
||||
private static final String PROP_CAMEL_HOME = "CamelHome";
|
||||
//private static final String PROP_EXCLUDE_CAMEL_LIBS = "exclude.camel.libs";
|
||||
private static final String PROP_EXCLUDE_CAMEL_LIBS = "ExcludeCamelLibs";
|
||||
private static final String PROP_ADDITIONAL_LIBS = "AdditionalLibs";
|
||||
//private static final String PROP_INCLUDE_CAMEL_LIBS = "include.camel.libs";
|
||||
private static final String PROP_INCLUDE_CAMEL_LIBS = "IncludeCamelLibs";
|
||||
|
||||
|
@ -79,7 +79,7 @@ public interface CamelSEConfigMBean {
|
|||
public void setInitialConfigurations(ComponentConfig props) {
|
||||
setCamelHome(props.getProperty(PROP_CAMEL_HOME).getValue());
|
||||
setIncludeCamelLibs(props.getProperty(PROP_INCLUDE_CAMEL_LIBS).getValue());
|
||||
setExcludeCamelLibs(props.getProperty(PROP_EXCLUDE_CAMEL_LIBS).getValue());
|
||||
setAdditionalLibs(props.getProperty(PROP_ADDITIONAL_LIBS).getValue());
|
||||
}
|
||||
|
||||
private File createConfigFile(String configRootPath) {
|
||||
|
@ -193,13 +193,13 @@ public interface CamelSEConfigMBean {
|
|||
return this.mConfigProps.getProperty(PROP_INCLUDE_CAMEL_LIBS, "");
|
||||
}
|
||||
|
||||
public void setExcludeCamelLibs(String excludeLibs) {
|
||||
this.mConfigProps.setProperty(PROP_EXCLUDE_CAMEL_LIBS, excludeLibs);
|
||||
public void setAdditionalLibs(String excludeLibs) {
|
||||
this.mConfigProps.setProperty(PROP_ADDITIONAL_LIBS, excludeLibs);
|
||||
this.saveProperties(mConfigFile, mConfigProps);
|
||||
}
|
||||
|
||||
public String getExcludeCamelLibs() {
|
||||
return this.mConfigProps.getProperty(PROP_EXCLUDE_CAMEL_LIBS, "");
|
||||
public String getAdditionalLibs() {
|
||||
return this.mConfigProps.getProperty(PROP_ADDITIONAL_LIBS, "");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -48,6 +48,7 @@ import java.lang.reflect.Method;
|
|||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.util.Arrays;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javax.jbi.management.DeploymentException;
|
||||
|
@ -132,7 +133,7 @@ public class CamelSEServiceUnit extends ServiceUnit {
|
|||
}
|
||||
String camelHome = configMBean.getCamelHome();
|
||||
String includes = configMBean.getIncludeCamelLibs();
|
||||
String excludes = configMBean.getExcludeCamelLibs();
|
||||
String additional = configMBean.getAdditionalLibs();
|
||||
|
||||
if ( camelHome == null || camelHome.trim().length() == 0 ) {
|
||||
return cp;
|
||||
|
@ -144,8 +145,8 @@ public class CamelSEServiceUnit extends ServiceUnit {
|
|||
return cp;
|
||||
}
|
||||
List<String> includePaths = getPaths(camelHome, includes);
|
||||
List<String> excludePaths = getPaths(camelHome, excludes);
|
||||
includePaths.removeAll(excludePaths);
|
||||
String[] additionalPaths = additional.split(",");
|
||||
includePaths.addAll(Arrays.asList(additionalPaths));
|
||||
for ( String path : includePaths ) {
|
||||
try {
|
||||
URL pathURL = (new File(path)).toURL();
|
||||
|
|
|
@ -1,436 +1,436 @@
|
|||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package org.openesb.components.camelse.camel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import org.apache.camel.CamelContext;
|
||||
import org.apache.camel.Endpoint;
|
||||
import org.apache.camel.Exchange;
|
||||
import org.apache.camel.ExchangePattern;
|
||||
import org.apache.camel.Message;
|
||||
import org.apache.camel.impl.MessageSupport;
|
||||
import org.apache.camel.spi.Synchronization;
|
||||
import org.apache.camel.spi.UnitOfWork;
|
||||
import org.apache.camel.util.ExchangeHelper;
|
||||
import org.apache.camel.util.ObjectHelper;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Vishnu
|
||||
*/
|
||||
public abstract class JBIAbstractExchange implements Exchange{
|
||||
|
||||
|
||||
protected final CamelContext context;
|
||||
private Map<String, Object> properties;
|
||||
private Message in;
|
||||
private Message out;
|
||||
private Exception exception;
|
||||
private String exchangeId;
|
||||
private UnitOfWork unitOfWork;
|
||||
private ExchangePattern pattern;
|
||||
private Endpoint fromEndpoint;
|
||||
private String fromRouteId;
|
||||
private List<Synchronization> onCompletions;
|
||||
|
||||
public JBIAbstractExchange(CamelContext context) {
|
||||
this(context, ExchangePattern.InOnly);
|
||||
}
|
||||
|
||||
public JBIAbstractExchange(CamelContext context, ExchangePattern pattern) {
|
||||
this.context = context;
|
||||
this.pattern = pattern;
|
||||
}
|
||||
|
||||
public JBIAbstractExchange(Exchange parent) {
|
||||
this(parent.getContext(), parent.getPattern());
|
||||
this.fromEndpoint = parent.getFromEndpoint();
|
||||
this.fromRouteId = parent.getFromRouteId();
|
||||
this.unitOfWork = parent.getUnitOfWork();
|
||||
}
|
||||
|
||||
public JBIAbstractExchange(Endpoint fromEndpoint) {
|
||||
this(fromEndpoint, ExchangePattern.InOnly);
|
||||
}
|
||||
|
||||
public JBIAbstractExchange(Endpoint fromEndpoint, ExchangePattern pattern) {
|
||||
this(fromEndpoint.getCamelContext(), pattern);
|
||||
this.fromEndpoint = fromEndpoint;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Exchange[" + (out == null ? in : out) + "]";
|
||||
}
|
||||
|
||||
public Exchange copy() {
|
||||
JBIAbstractExchange exchange = newInstance();
|
||||
|
||||
if (hasProperties()) {
|
||||
exchange.setProperties(safeCopy(getProperties()));
|
||||
}
|
||||
|
||||
exchange.setIn(getIn().copy());
|
||||
if (hasOut()) {
|
||||
exchange.setOut(getOut().copy());
|
||||
}
|
||||
exchange.setException(getException());
|
||||
return exchange;
|
||||
}
|
||||
|
||||
public abstract JBIAbstractExchange newInstance() ;
|
||||
|
||||
private static Map<String, Object> safeCopy(Map<String, Object> properties) {
|
||||
if (properties == null) {
|
||||
return null;
|
||||
}
|
||||
return new ConcurrentHashMap<String, Object>(properties);
|
||||
}
|
||||
|
||||
public CamelContext getContext() {
|
||||
return context;
|
||||
}
|
||||
|
||||
public Object getProperty(String name) {
|
||||
if (properties != null) {
|
||||
return properties.get(name);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Object getProperty(String name, Object defaultValue) {
|
||||
Object answer = getProperty(name);
|
||||
return answer != null ? answer : defaultValue;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T getProperty(String name, Class<T> type) {
|
||||
Object value = getProperty(name);
|
||||
if (value == null) {
|
||||
// lets avoid NullPointerException when converting to boolean for null values
|
||||
if (boolean.class.isAssignableFrom(type)) {
|
||||
return (T) Boolean.FALSE;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// eager same instance type test to avoid the overhead of invoking the type converter
|
||||
// if already same type
|
||||
if (type.isInstance(value)) {
|
||||
return type.cast(value);
|
||||
}
|
||||
|
||||
return ExchangeHelper.convertToType(this, type, value);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T getProperty(String name, Object defaultValue, Class<T> type) {
|
||||
Object value = getProperty(name, defaultValue);
|
||||
if (value == null) {
|
||||
// lets avoid NullPointerException when converting to boolean for null values
|
||||
if (boolean.class.isAssignableFrom(type)) {
|
||||
return (T) Boolean.FALSE;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// eager same instance type test to avoid the overhead of invoking the type converter
|
||||
// if already same type
|
||||
if (type.isInstance(value)) {
|
||||
return type.cast(value);
|
||||
}
|
||||
|
||||
return ExchangeHelper.convertToType(this, type, value);
|
||||
}
|
||||
|
||||
public void setProperty(String name, Object value) {
|
||||
if (value != null) {
|
||||
// avoid the NullPointException
|
||||
getProperties().put(name, value);
|
||||
} else {
|
||||
// if the value is null, we just remove the key from the map
|
||||
if (name != null) {
|
||||
getProperties().remove(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Object removeProperty(String name) {
|
||||
if (!hasProperties()) {
|
||||
return null;
|
||||
}
|
||||
return getProperties().remove(name);
|
||||
}
|
||||
|
||||
public Map<String, Object> getProperties() {
|
||||
if (properties == null) {
|
||||
properties = new ConcurrentHashMap<String, Object>();
|
||||
}
|
||||
return properties;
|
||||
}
|
||||
|
||||
public boolean hasProperties() {
|
||||
return properties != null && !properties.isEmpty();
|
||||
}
|
||||
|
||||
public void setProperties(Map<String, Object> properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
public Message getIn() {
|
||||
if (in == null) {
|
||||
in = createInMessage();
|
||||
configureMessage(in);
|
||||
}
|
||||
return in;
|
||||
}
|
||||
|
||||
public <T> T getIn(Class<T> type) {
|
||||
Message in = getIn();
|
||||
|
||||
// eager same instance type test to avoid the overhead of invoking the type converter
|
||||
// if already same type
|
||||
if (type.isInstance(in)) {
|
||||
return type.cast(in);
|
||||
}
|
||||
|
||||
// fallback to use type converter
|
||||
return context.getTypeConverter().convertTo(type, this, in);
|
||||
}
|
||||
|
||||
public void setIn(Message in) {
|
||||
this.in = in;
|
||||
configureMessage(in);
|
||||
}
|
||||
|
||||
public Message getOut() {
|
||||
// lazy create
|
||||
if (out == null) {
|
||||
out = (in != null && in instanceof MessageSupport)
|
||||
? ((MessageSupport)in).newInstance() : createOutMessage();
|
||||
configureMessage(out);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
public <T> T getOut(Class<T> type) {
|
||||
if (!hasOut()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Message out = getOut();
|
||||
|
||||
// eager same instance type test to avoid the overhead of invoking the type converter
|
||||
// if already same type
|
||||
if (type.isInstance(out)) {
|
||||
return type.cast(out);
|
||||
}
|
||||
|
||||
// fallback to use type converter
|
||||
return context.getTypeConverter().convertTo(type, this, out);
|
||||
}
|
||||
|
||||
public boolean hasOut() {
|
||||
return out != null;
|
||||
}
|
||||
|
||||
public void setOut(Message out) {
|
||||
this.out = out;
|
||||
configureMessage(out);
|
||||
}
|
||||
|
||||
public Exception getException() {
|
||||
return exception;
|
||||
}
|
||||
|
||||
public <T> T getException(Class<T> type) {
|
||||
return ObjectHelper.getException(type, exception);
|
||||
}
|
||||
|
||||
public void setException(Throwable t) {
|
||||
if (t == null) {
|
||||
this.exception = null;
|
||||
} else if (t instanceof Exception) {
|
||||
this.exception = (Exception) t;
|
||||
} else {
|
||||
// wrap throwable into an exception
|
||||
this.exception = ObjectHelper.wrapCamelExecutionException(this, t);
|
||||
}
|
||||
}
|
||||
|
||||
public ExchangePattern getPattern() {
|
||||
return pattern;
|
||||
}
|
||||
|
||||
public void setPattern(ExchangePattern pattern) {
|
||||
this.pattern = pattern;
|
||||
}
|
||||
|
||||
public Endpoint getFromEndpoint() {
|
||||
return fromEndpoint;
|
||||
}
|
||||
|
||||
public void setFromEndpoint(Endpoint fromEndpoint) {
|
||||
this.fromEndpoint = fromEndpoint;
|
||||
}
|
||||
|
||||
public String getFromRouteId() {
|
||||
return fromRouteId;
|
||||
}
|
||||
|
||||
public void setFromRouteId(String fromRouteId) {
|
||||
this.fromRouteId = fromRouteId;
|
||||
}
|
||||
|
||||
public String getExchangeId() {
|
||||
if (exchangeId == null) {
|
||||
exchangeId = createExchangeId();
|
||||
}
|
||||
return exchangeId;
|
||||
}
|
||||
|
||||
public void setExchangeId(String id) {
|
||||
this.exchangeId = id;
|
||||
}
|
||||
|
||||
public boolean isFailed() {
|
||||
return (hasOut() && getOut().isFault()) || getException() != null;
|
||||
}
|
||||
|
||||
public boolean isTransacted() {
|
||||
UnitOfWork uow = getUnitOfWork();
|
||||
if (uow != null) {
|
||||
return uow.isTransacted();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public Boolean isExternalRedelivered() {
|
||||
Boolean answer = null;
|
||||
|
||||
// check property first, as the implementation details to know if the message
|
||||
// was externally redelivered is message specific, and thus the message implementation
|
||||
// could potentially change during routing, and therefore later we may not know if the
|
||||
// original message was externally redelivered or not, therefore we store this detail
|
||||
// as a exchange property to keep it around for the lifecycle of the exchange
|
||||
if (hasProperties()) {
|
||||
answer = getProperty(Exchange.EXTERNAL_REDELIVERED, null, Boolean.class);
|
||||
}
|
||||
|
||||
if (answer == null) {
|
||||
// lets avoid adding methods to the Message API, so we use the
|
||||
// DefaultMessage to allow component specific messages to extend
|
||||
// and implement the isExternalRedelivered method.
|
||||
JBIBridgeMessage msg = getIn(JBIBridgeMessage.class);
|
||||
if (msg != null) {
|
||||
answer = msg.isTransactedRedelivered();
|
||||
// store as property to keep around
|
||||
setProperty(Exchange.EXTERNAL_REDELIVERED, answer);
|
||||
}
|
||||
}
|
||||
|
||||
return answer;
|
||||
}
|
||||
|
||||
public boolean isRollbackOnly() {
|
||||
return Boolean.TRUE.equals(getProperty(Exchange.ROLLBACK_ONLY)) || Boolean.TRUE.equals(getProperty(Exchange.ROLLBACK_ONLY_LAST));
|
||||
}
|
||||
|
||||
public UnitOfWork getUnitOfWork() {
|
||||
return unitOfWork;
|
||||
}
|
||||
|
||||
public void setUnitOfWork(UnitOfWork unitOfWork) {
|
||||
this.unitOfWork = unitOfWork;
|
||||
if (onCompletions != null) {
|
||||
// now an unit of work has been assigned so add the on completions
|
||||
// we might have registered already
|
||||
for (Synchronization onCompletion : onCompletions) {
|
||||
unitOfWork.addSynchronization(onCompletion);
|
||||
}
|
||||
// cleanup the temporary on completion list as they now have been registered
|
||||
// on the unit of work
|
||||
onCompletions.clear();
|
||||
onCompletions = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void addOnCompletion(Synchronization onCompletion) {
|
||||
if (unitOfWork == null) {
|
||||
// unit of work not yet registered so we store the on completion temporary
|
||||
// until the unit of work is assigned to this exchange by the UnitOfWorkProcessor
|
||||
if (onCompletions == null) {
|
||||
onCompletions = new ArrayList<Synchronization>();
|
||||
}
|
||||
onCompletions.add(onCompletion);
|
||||
} else {
|
||||
getUnitOfWork().addSynchronization(onCompletion);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean containsOnCompletion(Synchronization onCompletion) {
|
||||
if (unitOfWork != null) {
|
||||
// if there is an unit of work then the completions is moved there
|
||||
return unitOfWork.containsSynchronization(onCompletion);
|
||||
} else {
|
||||
// check temporary completions if no unit of work yet
|
||||
return onCompletions != null && onCompletions.contains(onCompletion);
|
||||
}
|
||||
}
|
||||
|
||||
public void handoverCompletions(Exchange target) {
|
||||
if (onCompletions != null) {
|
||||
for (Synchronization onCompletion : onCompletions) {
|
||||
target.addOnCompletion(onCompletion);
|
||||
}
|
||||
// cleanup the temporary on completion list as they have been handed over
|
||||
onCompletions.clear();
|
||||
onCompletions = null;
|
||||
} else if (unitOfWork != null) {
|
||||
// let unit of work handover
|
||||
unitOfWork.handoverSynchronization(target);
|
||||
}
|
||||
}
|
||||
|
||||
public List<Synchronization> handoverCompletions() {
|
||||
List<Synchronization> answer = null;
|
||||
if (onCompletions != null) {
|
||||
answer = new ArrayList<Synchronization>(onCompletions);
|
||||
onCompletions.clear();
|
||||
onCompletions = null;
|
||||
}
|
||||
return answer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures the message after it has been set on the exchange
|
||||
*/
|
||||
protected void configureMessage(Message message) {
|
||||
if (message instanceof MessageSupport) {
|
||||
MessageSupport messageSupport = (MessageSupport)message;
|
||||
messageSupport.setExchange(this);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
protected String createExchangeId() {
|
||||
String answer = null;
|
||||
if (in != null) {
|
||||
answer = in.createExchangeId();
|
||||
}
|
||||
if (answer == null) {
|
||||
answer = context.getUuidGenerator().generateUuid();
|
||||
}
|
||||
return answer;
|
||||
}
|
||||
|
||||
protected abstract Message createInMessage() ;
|
||||
|
||||
protected abstract Message createOutMessage() ;
|
||||
}
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package org.openesb.components.camelse.camel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import org.apache.camel.CamelContext;
|
||||
import org.apache.camel.Endpoint;
|
||||
import org.apache.camel.Exchange;
|
||||
import org.apache.camel.ExchangePattern;
|
||||
import org.apache.camel.Message;
|
||||
import org.apache.camel.impl.MessageSupport;
|
||||
import org.apache.camel.spi.Synchronization;
|
||||
import org.apache.camel.spi.UnitOfWork;
|
||||
import org.apache.camel.util.ExchangeHelper;
|
||||
import org.apache.camel.util.ObjectHelper;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Vishnu
|
||||
*/
|
||||
public abstract class JBIAbstractExchange implements Exchange{
|
||||
|
||||
|
||||
protected final CamelContext context;
|
||||
private Map<String, Object> properties;
|
||||
private Message in;
|
||||
private Message out;
|
||||
private Exception exception;
|
||||
private String exchangeId;
|
||||
private UnitOfWork unitOfWork;
|
||||
private ExchangePattern pattern;
|
||||
private Endpoint fromEndpoint;
|
||||
private String fromRouteId;
|
||||
private List<Synchronization> onCompletions;
|
||||
|
||||
public JBIAbstractExchange(CamelContext context) {
|
||||
this(context, ExchangePattern.InOnly);
|
||||
}
|
||||
|
||||
public JBIAbstractExchange(CamelContext context, ExchangePattern pattern) {
|
||||
this.context = context;
|
||||
this.pattern = pattern;
|
||||
}
|
||||
|
||||
public JBIAbstractExchange(Exchange parent) {
|
||||
this(parent.getContext(), parent.getPattern());
|
||||
this.fromEndpoint = parent.getFromEndpoint();
|
||||
this.fromRouteId = parent.getFromRouteId();
|
||||
this.unitOfWork = parent.getUnitOfWork();
|
||||
}
|
||||
|
||||
public JBIAbstractExchange(Endpoint fromEndpoint) {
|
||||
this(fromEndpoint, ExchangePattern.InOnly);
|
||||
}
|
||||
|
||||
public JBIAbstractExchange(Endpoint fromEndpoint, ExchangePattern pattern) {
|
||||
this(fromEndpoint.getCamelContext(), pattern);
|
||||
this.fromEndpoint = fromEndpoint;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Exchange[" + (out == null ? in : out) + "]";
|
||||
}
|
||||
|
||||
public Exchange copy() {
|
||||
JBIAbstractExchange exchange = newInstance();
|
||||
|
||||
if (hasProperties()) {
|
||||
exchange.setProperties(safeCopy(getProperties()));
|
||||
}
|
||||
|
||||
exchange.setIn(getIn().copy());
|
||||
if (hasOut()) {
|
||||
exchange.setOut(getOut().copy());
|
||||
}
|
||||
exchange.setException(getException());
|
||||
return exchange;
|
||||
}
|
||||
|
||||
public abstract JBIAbstractExchange newInstance() ;
|
||||
|
||||
private static Map<String, Object> safeCopy(Map<String, Object> properties) {
|
||||
if (properties == null) {
|
||||
return null;
|
||||
}
|
||||
return new ConcurrentHashMap<String, Object>(properties);
|
||||
}
|
||||
|
||||
public CamelContext getContext() {
|
||||
return context;
|
||||
}
|
||||
|
||||
public Object getProperty(String name) {
|
||||
if (properties != null) {
|
||||
return properties.get(name);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Object getProperty(String name, Object defaultValue) {
|
||||
Object answer = getProperty(name);
|
||||
return answer != null ? answer : defaultValue;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T getProperty(String name, Class<T> type) {
|
||||
Object value = getProperty(name);
|
||||
if (value == null) {
|
||||
// lets avoid NullPointerException when converting to boolean for null values
|
||||
if (boolean.class.isAssignableFrom(type)) {
|
||||
return (T) Boolean.FALSE;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// eager same instance type test to avoid the overhead of invoking the type converter
|
||||
// if already same type
|
||||
if (type.isInstance(value)) {
|
||||
return type.cast(value);
|
||||
}
|
||||
|
||||
return ExchangeHelper.convertToType(this, type, value);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T getProperty(String name, Object defaultValue, Class<T> type) {
|
||||
Object value = getProperty(name, defaultValue);
|
||||
if (value == null) {
|
||||
// lets avoid NullPointerException when converting to boolean for null values
|
||||
if (boolean.class.isAssignableFrom(type)) {
|
||||
return (T) Boolean.FALSE;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// eager same instance type test to avoid the overhead of invoking the type converter
|
||||
// if already same type
|
||||
if (type.isInstance(value)) {
|
||||
return type.cast(value);
|
||||
}
|
||||
|
||||
return ExchangeHelper.convertToType(this, type, value);
|
||||
}
|
||||
|
||||
public void setProperty(String name, Object value) {
|
||||
if (value != null) {
|
||||
// avoid the NullPointException
|
||||
getProperties().put(name, value);
|
||||
} else {
|
||||
// if the value is null, we just remove the key from the map
|
||||
if (name != null) {
|
||||
getProperties().remove(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Object removeProperty(String name) {
|
||||
if (!hasProperties()) {
|
||||
return null;
|
||||
}
|
||||
return getProperties().remove(name);
|
||||
}
|
||||
|
||||
public Map<String, Object> getProperties() {
|
||||
if (properties == null) {
|
||||
properties = new ConcurrentHashMap<String, Object>();
|
||||
}
|
||||
return properties;
|
||||
}
|
||||
|
||||
public boolean hasProperties() {
|
||||
return properties != null && !properties.isEmpty();
|
||||
}
|
||||
|
||||
public void setProperties(Map<String, Object> properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
public Message getIn() {
|
||||
if (in == null) {
|
||||
in = createInMessage();
|
||||
configureMessage(in);
|
||||
}
|
||||
return in;
|
||||
}
|
||||
|
||||
public <T> T getIn(Class<T> type) {
|
||||
Message in = getIn();
|
||||
|
||||
// eager same instance type test to avoid the overhead of invoking the type converter
|
||||
// if already same type
|
||||
if (type.isInstance(in)) {
|
||||
return type.cast(in);
|
||||
}
|
||||
|
||||
// fallback to use type converter
|
||||
return context.getTypeConverter().convertTo(type, this, in);
|
||||
}
|
||||
|
||||
public void setIn(Message in) {
|
||||
this.in = in;
|
||||
configureMessage(in);
|
||||
}
|
||||
|
||||
public Message getOut() {
|
||||
// lazy create
|
||||
if (out == null) {
|
||||
out = (in != null && in instanceof MessageSupport)
|
||||
? ((MessageSupport)in).newInstance() : createOutMessage();
|
||||
configureMessage(out);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
public <T> T getOut(Class<T> type) {
|
||||
if (!hasOut()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Message out = getOut();
|
||||
|
||||
// eager same instance type test to avoid the overhead of invoking the type converter
|
||||
// if already same type
|
||||
if (type.isInstance(out)) {
|
||||
return type.cast(out);
|
||||
}
|
||||
|
||||
// fallback to use type converter
|
||||
return context.getTypeConverter().convertTo(type, this, out);
|
||||
}
|
||||
|
||||
public boolean hasOut() {
|
||||
return out != null;
|
||||
}
|
||||
|
||||
public void setOut(Message out) {
|
||||
this.out = out;
|
||||
configureMessage(out);
|
||||
}
|
||||
|
||||
public Exception getException() {
|
||||
return exception;
|
||||
}
|
||||
|
||||
public <T> T getException(Class<T> type) {
|
||||
return ObjectHelper.getException(type, exception);
|
||||
}
|
||||
|
||||
public void setException(Throwable t) {
|
||||
if (t == null) {
|
||||
this.exception = null;
|
||||
} else if (t instanceof Exception) {
|
||||
this.exception = (Exception) t;
|
||||
} else {
|
||||
// wrap throwable into an exception
|
||||
this.exception = ObjectHelper.wrapCamelExecutionException(this, t);
|
||||
}
|
||||
}
|
||||
|
||||
public ExchangePattern getPattern() {
|
||||
return pattern;
|
||||
}
|
||||
|
||||
public void setPattern(ExchangePattern pattern) {
|
||||
this.pattern = pattern;
|
||||
}
|
||||
|
||||
public Endpoint getFromEndpoint() {
|
||||
return fromEndpoint;
|
||||
}
|
||||
|
||||
public void setFromEndpoint(Endpoint fromEndpoint) {
|
||||
this.fromEndpoint = fromEndpoint;
|
||||
}
|
||||
|
||||
public String getFromRouteId() {
|
||||
return fromRouteId;
|
||||
}
|
||||
|
||||
public void setFromRouteId(String fromRouteId) {
|
||||
this.fromRouteId = fromRouteId;
|
||||
}
|
||||
|
||||
public String getExchangeId() {
|
||||
if (exchangeId == null) {
|
||||
exchangeId = createExchangeId();
|
||||
}
|
||||
return exchangeId;
|
||||
}
|
||||
|
||||
public void setExchangeId(String id) {
|
||||
this.exchangeId = id;
|
||||
}
|
||||
|
||||
public boolean isFailed() {
|
||||
return (hasOut() && getOut().isFault()) || getException() != null;
|
||||
}
|
||||
|
||||
public boolean isTransacted() {
|
||||
UnitOfWork uow = getUnitOfWork();
|
||||
if (uow != null) {
|
||||
return uow.isTransacted();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public Boolean isExternalRedelivered() {
|
||||
Boolean answer = null;
|
||||
|
||||
// check property first, as the implementation details to know if the message
|
||||
// was externally redelivered is message specific, and thus the message implementation
|
||||
// could potentially change during routing, and therefore later we may not know if the
|
||||
// original message was externally redelivered or not, therefore we store this detail
|
||||
// as a exchange property to keep it around for the lifecycle of the exchange
|
||||
if (hasProperties()) {
|
||||
answer = getProperty(Exchange.EXTERNAL_REDELIVERED, null, Boolean.class);
|
||||
}
|
||||
|
||||
if (answer == null) {
|
||||
// lets avoid adding methods to the Message API, so we use the
|
||||
// DefaultMessage to allow component specific messages to extend
|
||||
// and implement the isExternalRedelivered method.
|
||||
JBIBridgeMessage msg = getIn(JBIBridgeMessage.class);
|
||||
if (msg != null) {
|
||||
answer = msg.isTransactedRedelivered();
|
||||
// store as property to keep around
|
||||
setProperty(Exchange.EXTERNAL_REDELIVERED, answer);
|
||||
}
|
||||
}
|
||||
|
||||
return answer;
|
||||
}
|
||||
|
||||
public boolean isRollbackOnly() {
|
||||
return Boolean.TRUE.equals(getProperty(Exchange.ROLLBACK_ONLY)) || Boolean.TRUE.equals(getProperty(Exchange.ROLLBACK_ONLY_LAST));
|
||||
}
|
||||
|
||||
public UnitOfWork getUnitOfWork() {
|
||||
return unitOfWork;
|
||||
}
|
||||
|
||||
public void setUnitOfWork(UnitOfWork unitOfWork) {
|
||||
this.unitOfWork = unitOfWork;
|
||||
if (onCompletions != null) {
|
||||
// now an unit of work has been assigned so add the on completions
|
||||
// we might have registered already
|
||||
for (Synchronization onCompletion : onCompletions) {
|
||||
unitOfWork.addSynchronization(onCompletion);
|
||||
}
|
||||
// cleanup the temporary on completion list as they now have been registered
|
||||
// on the unit of work
|
||||
onCompletions.clear();
|
||||
onCompletions = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void addOnCompletion(Synchronization onCompletion) {
|
||||
if (unitOfWork == null) {
|
||||
// unit of work not yet registered so we store the on completion temporary
|
||||
// until the unit of work is assigned to this exchange by the UnitOfWorkProcessor
|
||||
if (onCompletions == null) {
|
||||
onCompletions = new ArrayList<Synchronization>();
|
||||
}
|
||||
onCompletions.add(onCompletion);
|
||||
} else {
|
||||
getUnitOfWork().addSynchronization(onCompletion);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean containsOnCompletion(Synchronization onCompletion) {
|
||||
if (unitOfWork != null) {
|
||||
// if there is an unit of work then the completions is moved there
|
||||
return unitOfWork.containsSynchronization(onCompletion);
|
||||
} else {
|
||||
// check temporary completions if no unit of work yet
|
||||
return onCompletions != null && onCompletions.contains(onCompletion);
|
||||
}
|
||||
}
|
||||
|
||||
public void handoverCompletions(Exchange target) {
|
||||
if (onCompletions != null) {
|
||||
for (Synchronization onCompletion : onCompletions) {
|
||||
target.addOnCompletion(onCompletion);
|
||||
}
|
||||
// cleanup the temporary on completion list as they have been handed over
|
||||
onCompletions.clear();
|
||||
onCompletions = null;
|
||||
} else if (unitOfWork != null) {
|
||||
// let unit of work handover
|
||||
unitOfWork.handoverSynchronization(target);
|
||||
}
|
||||
}
|
||||
|
||||
public List<Synchronization> handoverCompletions() {
|
||||
List<Synchronization> answer = null;
|
||||
if (onCompletions != null) {
|
||||
answer = new ArrayList<Synchronization>(onCompletions);
|
||||
onCompletions.clear();
|
||||
onCompletions = null;
|
||||
}
|
||||
return answer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures the message after it has been set on the exchange
|
||||
*/
|
||||
protected void configureMessage(Message message) {
|
||||
if (message instanceof MessageSupport) {
|
||||
MessageSupport messageSupport = (MessageSupport)message;
|
||||
messageSupport.setExchange(this);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
protected String createExchangeId() {
|
||||
String answer = null;
|
||||
if (in != null) {
|
||||
answer = in.createExchangeId();
|
||||
}
|
||||
if (answer == null) {
|
||||
answer = context.getUuidGenerator().generateUuid();
|
||||
}
|
||||
return answer;
|
||||
}
|
||||
|
||||
protected abstract Message createInMessage() ;
|
||||
|
||||
protected abstract Message createOutMessage() ;
|
||||
}
|
||||
|
|
|
@ -1,72 +1,72 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
|
||||
<!--
|
||||
Document : jbi.xml
|
||||
Created on : July 10, 2013, 14:22 AM
|
||||
Author : vishnu
|
||||
Description: JBI Component installation descriptor.
|
||||
-->
|
||||
<jbi xmlns="http://java.sun.com/xml/ns/jbi" xmlns:config="http://www.sun.com/jbi/Configuration/V1.0" xmlns:logging="http://www.sun.com/jbi/descriptor/logging" xmlns:ver="http://www.sun.com/jbi/descriptor/identification" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0">
|
||||
<component bootstrap-class-loader-delegation="self-first" component-class-loader-delegation="self-first" type="service-engine">
|
||||
<identification>
|
||||
<name>camel-jbi-se</name>
|
||||
<description>JBI Service Engine that runs Apache Camel Applications in a JBI Container like OpenESB</description>
|
||||
<ver:VersionInfo build-number="@datetimestamp@" specification-version="@specversion@"/>
|
||||
</identification>
|
||||
<!-- FQN of the implementation class for javax.jbi.component.Component interface -->
|
||||
<component-class-name>org.openesb.components.camelse.CamelSERuntime</component-class-name>
|
||||
<!-- component runtime classpath for component execution classloader -->
|
||||
<component-class-path>
|
||||
<path-element>lib/camelseimpl.jar</path-element>
|
||||
<path-element>lib/wsdl4j.jar</path-element>
|
||||
<path-element>lib/camel-core.jar</path-element>
|
||||
<path-element>lib/camel-spring.jar</path-element>
|
||||
<path-element>lib/spring-aop.jar</path-element>
|
||||
<path-element>lib/spring-beans.jar</path-element>
|
||||
<path-element>lib/spring-context.jar</path-element>
|
||||
<path-element>lib/spring-core.jar</path-element>
|
||||
<path-element>lib/slf4j-api.jar</path-element>
|
||||
<path-element>lib/commons-logging.jar</path-element>
|
||||
<path-element>lib/spring-asm.jar</path-element>
|
||||
<path-element>lib/spring-expression.jar</path-element>
|
||||
<path-element>lib/slf4j-nop.jar</path-element>
|
||||
<path-element>lib/camel-jms.jar</path-element>
|
||||
<path-element>lib/spring-tx.jar</path-element>
|
||||
<path-element>lib/spring-jms.jar</path-element>
|
||||
<path-element>lib/activemq-all.jar</path-element>
|
||||
</component-class-path>
|
||||
<!-- FQN of the implementation class for javax.jbi.component.Bootstrap interface -->
|
||||
<bootstrap-class-name>org.openesb.components.camelse.CamelSEInstaller</bootstrap-class-name>
|
||||
<!-- component installation time classpath for component bootstrap classloader -->
|
||||
<bootstrap-class-path>
|
||||
|
||||
<path-element>lib/camelseimpl.jar</path-element>
|
||||
<path-element>lib/wsdl4j.jar</path-element>
|
||||
<path-element>lib/camel-core.jar</path-element>
|
||||
<path-element>lib/camel-spring.jar</path-element>
|
||||
<path-element>lib/spring-aop.jar</path-element>
|
||||
<path-element>lib/spring-beans.jar</path-element>
|
||||
<path-element>lib/spring-context.jar</path-element>
|
||||
<path-element>lib/spring-core.jar</path-element>
|
||||
<path-element>lib/slf4j-api.jar</path-element>
|
||||
<path-element>lib/commons-logging.jar</path-element>
|
||||
<path-element>lib/spring-asm.jar</path-element>
|
||||
<path-element>lib/spring-expression.jar</path-element>
|
||||
<path-element>lib/slf4j-nop.jar</path-element>
|
||||
<path-element>lib/camel-jms.jar</path-element>
|
||||
<path-element>lib/spring-tx.jar</path-element>
|
||||
<path-element>lib/spring-jms.jar</path-element>
|
||||
<path-element>lib/activemq-all.jar</path-element>
|
||||
</bootstrap-class-path>
|
||||
-->
|
||||
<jbi xmlns="http://java.sun.com/xml/ns/jbi" xmlns:config="http://www.sun.com/jbi/Configuration/V1.0" xmlns:logging="http://www.sun.com/jbi/descriptor/logging" xmlns:ver="http://www.sun.com/jbi/descriptor/identification" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0">
|
||||
<component bootstrap-class-loader-delegation="self-first" component-class-loader-delegation="self-first" type="service-engine">
|
||||
<identification>
|
||||
<name>camel-jbi-se</name>
|
||||
<description>JBI Service Engine that runs Apache Camel Applications in a JBI Container like OpenESB</description>
|
||||
<ver:VersionInfo build-number="@datetimestamp@" specification-version="@specversion@"/>
|
||||
</identification>
|
||||
<!-- FQN of the implementation class for javax.jbi.component.Component interface -->
|
||||
<component-class-name>org.openesb.components.camelse.CamelSERuntime</component-class-name>
|
||||
<!-- component runtime classpath for component execution classloader -->
|
||||
<component-class-path>
|
||||
<path-element>lib/camelseimpl.jar</path-element>
|
||||
<path-element>lib/wsdl4j.jar</path-element>
|
||||
<path-element>lib/camel-core.jar</path-element>
|
||||
<path-element>lib/camel-spring.jar</path-element>
|
||||
<path-element>lib/spring-aop.jar</path-element>
|
||||
<path-element>lib/spring-beans.jar</path-element>
|
||||
<path-element>lib/spring-context.jar</path-element>
|
||||
<path-element>lib/spring-core.jar</path-element>
|
||||
<path-element>lib/slf4j-api.jar</path-element>
|
||||
<path-element>lib/commons-logging.jar</path-element>
|
||||
<path-element>lib/spring-asm.jar</path-element>
|
||||
<path-element>lib/spring-expression.jar</path-element>
|
||||
<path-element>lib/slf4j-nop.jar</path-element>
|
||||
<path-element>lib/camel-jms.jar</path-element>
|
||||
<path-element>lib/spring-tx.jar</path-element>
|
||||
<path-element>lib/spring-jms.jar</path-element>
|
||||
<path-element>lib/activemq-all.jar</path-element>
|
||||
</component-class-path>
|
||||
<!-- FQN of the implementation class for javax.jbi.component.Bootstrap interface -->
|
||||
<bootstrap-class-name>org.openesb.components.camelse.CamelSEInstaller</bootstrap-class-name>
|
||||
<!-- component installation time classpath for component bootstrap classloader -->
|
||||
<bootstrap-class-path>
|
||||
|
||||
<path-element>lib/camelseimpl.jar</path-element>
|
||||
<path-element>lib/wsdl4j.jar</path-element>
|
||||
<path-element>lib/camel-core.jar</path-element>
|
||||
<path-element>lib/camel-spring.jar</path-element>
|
||||
<path-element>lib/spring-aop.jar</path-element>
|
||||
<path-element>lib/spring-beans.jar</path-element>
|
||||
<path-element>lib/spring-context.jar</path-element>
|
||||
<path-element>lib/spring-core.jar</path-element>
|
||||
<path-element>lib/slf4j-api.jar</path-element>
|
||||
<path-element>lib/commons-logging.jar</path-element>
|
||||
<path-element>lib/spring-asm.jar</path-element>
|
||||
<path-element>lib/spring-expression.jar</path-element>
|
||||
<path-element>lib/slf4j-nop.jar</path-element>
|
||||
<path-element>lib/camel-jms.jar</path-element>
|
||||
<path-element>lib/spring-tx.jar</path-element>
|
||||
<path-element>lib/spring-jms.jar</path-element>
|
||||
<path-element>lib/activemq-all.jar</path-element>
|
||||
</bootstrap-class-path>
|
||||
<!-- jbi shared libraries this component is dependent on. The classpaths of these
|
||||
shared libraries will be available to component runtime classloader -->
|
||||
shared libraries will be available to component runtime classloader -->
|
||||
<!--
|
||||
<shared-library>sun-wsdl-library</shared-library>
|
||||
-->
|
||||
<config:Configuration>
|
||||
<config:Property defaultValue="" displayDescription="Apache Camel Installation Directory" displayName="Apache Camel Home" isApplicationRestartRequired="true" isComponentRestartRequired="false" name="CamelHome" showDisplay="all" type="xsd:string"/>
|
||||
<config:Property defaultValue="" displayDescription="comma(,) separated names of Apache Camel Libraries to include in the Camel application classpath" displayName="Included Camel Libraries" isApplicationRestartRequired="true" isComponentRestartRequired="false" name="IncludeCamelLibs" showDisplay="all" type="xsd:string"/>
|
||||
<config:Property defaultValue="" displayDescription="comma(,) separated names of Apache Camel Libraries to exclude from the Camel application classpath" displayName="Excluded Camel Libraries" isApplicationRestartRequired="true" isComponentRestartRequired="false" name="ExcludeCamelLibs" showDisplay="all" type="xsd:string"/>
|
||||
</config:Configuration>
|
||||
</component>
|
||||
</jbi>
|
||||
-->
|
||||
<config:Configuration>
|
||||
<config:Property defaultValue="" displayDescription="Apache Camel Installation Directory" displayName="Apache Camel Home" isApplicationRestartRequired="true" isComponentRestartRequired="false" name="CamelHome" showDisplay="all" type="xsd:string"/>
|
||||
<config:Property defaultValue="" displayDescription="comma(,) separated names of Apache Camel Libraries to include in the Camel application classpath" displayName="Included Camel Libraries" isApplicationRestartRequired="true" isComponentRestartRequired="false" name="IncludeCamelLibs" showDisplay="all" type="xsd:string"/>
|
||||
<config:Property defaultValue="" displayDescription="comma(,) separated full path of the jar files to include in the Camel application classpath" displayName="Additional Libraries" isApplicationRestartRequired="true" isComponentRestartRequired="false" name="AdditionalLibs" showDisplay="all" type="xsd:string"/>
|
||||
</config:Configuration>
|
||||
</component>
|
||||
</jbi>
|
||||
|
|
Loading…
Reference in New Issue