Decouple smx-bean support base classes from smx-bean BeanEndpoint class to
facilitate deployment of bean classes to container classpath if desired
--------------------------------------------------------------------------------------------------------------------------------------------------
Key: SM-1469
URL: https://issues.apache.org/activemq/browse/SM-1469
Project: ServiceMix
Issue Type: Improvement
Components: servicemix-bean
Affects Versions: 3.2.1
Reporter: Ron Gavlin
I would like the ability to place commonly used smx-bean classes that extend
the new bean support abstract classes on the container classpath to ease
packaging and deployment. The following patch decouples the bean support
classes from the BeanEndpoint class to facilitate this activity.
Index: src/main/java/org/apache/servicemix/bean/support/BeanSupport.java
===================================================================
--- src/main/java/org/apache/servicemix/bean/support/BeanSupport.java
(revision 677808)
+++ src/main/java/org/apache/servicemix/bean/support/BeanSupport.java
(working copy)
@@ -29,6 +29,7 @@
import javax.jbi.messaging.MessagingException;
import javax.jbi.messaging.NormalizedMessage;
import javax.jbi.messaging.RobustInOnly;
+import javax.jbi.servicedesc.ServiceEndpoint;
import javax.management.ObjectName;
import javax.xml.namespace.QName;
@@ -35,7 +36,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.servicemix.JbiConstants;
-import org.apache.servicemix.bean.BeanEndpoint;
import org.apache.servicemix.components.util.CopyTransformer;
import org.apache.servicemix.components.util.MessageHelper;
import org.apache.servicemix.components.util.MessageTransformer;
@@ -58,7 +58,7 @@
private DeliveryChannel channel;
@Resource
- private BeanEndpoint beanEndpoint;
+ private ServiceEndpoint serviceEndpoint;
private ObjectName extensionMBeanName;
private MessageExchangeFactory exchangeFactory;
@@ -112,12 +112,12 @@
this.context = context;
}
- public BeanEndpoint getBeanEndpoint() {
- return beanEndpoint;
+ public ServiceEndpoint getServiceEndpoint() {
+ return serviceEndpoint;
}
- public void setBeanEndpoint(BeanEndpoint beanEndpoint) {
- this.beanEndpoint = beanEndpoint;
+ public void setServiceEndpoint(ServiceEndpoint serviceEndpoint) {
+ this.serviceEndpoint = serviceEndpoint;
}
/**
@@ -409,8 +409,8 @@
protected QName getService() {
QName service = null;
- if (beanEndpoint != null) {
- service = beanEndpoint.getService();
+ if (serviceEndpoint != null) {
+ service = serviceEndpoint.getServiceName();
}
return service;
}
@@ -417,8 +417,8 @@
protected String getEndpoint() {
String endpoint = null;
- if (beanEndpoint != null) {
- endpoint = beanEndpoint.getEndpoint();
+ if (serviceEndpoint != null) {
+ endpoint = serviceEndpoint.getEndpointName();
}
return endpoint;
}
Index: src/main/java/org/apache/servicemix/bean/BeanEndpoint.java
===================================================================
--- src/main/java/org/apache/servicemix/bean/BeanEndpoint.java (revision
677808)
+++ src/main/java/org/apache/servicemix/bean/BeanEndpoint.java (working copy)
@@ -92,7 +92,8 @@
private ThreadLocal<Request> currentRequest = new ThreadLocal<Request>();
private ComponentContext context;
private DeliveryChannel channel;
-
+ private ServiceEndpoint serviceEndpoint;
+
public BeanEndpoint() {
}
@@ -99,6 +100,7 @@
public BeanEndpoint(BeanComponent component, ServiceEndpoint
serviceEndpoint) {
super(component, serviceEndpoint);
this.applicationContext = component.getApplicationContext();
+ this.serviceEndpoint = serviceEndpoint;
}
public void start() throws Exception {
@@ -105,6 +107,9 @@
super.start();
context = new EndpointComponentContext(this);
channel = context.getDeliveryChannel();
+ if (serviceEndpoint == null) {
+ serviceEndpoint = context.getEndpoint(getService(),
getEndpoint());
+ }
Object pojo = getBean();
if (pojo != null) {
injectBean(pojo);
@@ -346,6 +351,8 @@
ReflectionUtils.setField(f, target, ctx);
} else if
(DeliveryChannel.class.isAssignableFrom(f.getType())) {
ReflectionUtils.setField(f, target, ch);
+ } else if
(ServiceEndpoint.class.isAssignableFrom(f.getType())) {
+ ReflectionUtils.setField(f, target,
BeanEndpoint.this.serviceEndpoint);
}
}
}
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.