You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by gn...@apache.org on 2007/03/07 21:43:10 UTC
svn commit: r515741 - in
/incubator/servicemix/trunk/common/servicemix-common/src/main/java/org/apache/servicemix/common:
AsyncBaseLifeCycle.java Endpoint.java EndpointSupport.java
xbean/XBeanServiceUnit.java
Author: gnodet
Date: Wed Mar 7 12:43:09 2007
New Revision: 515741
URL: http://svn.apache.org/viewvc?view=rev&rev=515741
Log:
SM-871: optimize wsdl-first example
Modified:
incubator/servicemix/trunk/common/servicemix-common/src/main/java/org/apache/servicemix/common/AsyncBaseLifeCycle.java
incubator/servicemix/trunk/common/servicemix-common/src/main/java/org/apache/servicemix/common/Endpoint.java
incubator/servicemix/trunk/common/servicemix-common/src/main/java/org/apache/servicemix/common/EndpointSupport.java
incubator/servicemix/trunk/common/servicemix-common/src/main/java/org/apache/servicemix/common/xbean/XBeanServiceUnit.java
Modified: incubator/servicemix/trunk/common/servicemix-common/src/main/java/org/apache/servicemix/common/AsyncBaseLifeCycle.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/common/servicemix-common/src/main/java/org/apache/servicemix/common/AsyncBaseLifeCycle.java?view=diff&rev=515741&r1=515740&r2=515741
==============================================================================
--- incubator/servicemix/trunk/common/servicemix-common/src/main/java/org/apache/servicemix/common/AsyncBaseLifeCycle.java (original)
+++ incubator/servicemix/trunk/common/servicemix-common/src/main/java/org/apache/servicemix/common/AsyncBaseLifeCycle.java Wed Mar 7 12:43:09 2007
@@ -473,9 +473,9 @@
private void doProcess(Endpoint ep, ExchangeProcessor processor, MessageExchange exchange) throws Exception {
ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
try {
- if (ep != null && ep.getServiceUnit().getConfigurationClassLoader() != null) {
- ClassLoader classLoader = ep.getServiceUnit().getConfigurationClassLoader();
- Thread.currentThread().setContextClassLoader(classLoader);
+ ClassLoader cl = (ep != null) ? ep.getServiceUnit().getConfigurationClassLoader() : null;
+ if (cl != null) {
+ Thread.currentThread().setContextClassLoader(cl);
}
// Read the correlation id from the exchange and set it in the correlation id property
String correlationID = (String)exchange.getProperty(JbiConstants.CORRELATION_ID);
Modified: incubator/servicemix/trunk/common/servicemix-common/src/main/java/org/apache/servicemix/common/Endpoint.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/common/servicemix-common/src/main/java/org/apache/servicemix/common/Endpoint.java?view=diff&rev=515741&r1=515740&r2=515741
==============================================================================
--- incubator/servicemix/trunk/common/servicemix-common/src/main/java/org/apache/servicemix/common/Endpoint.java (original)
+++ incubator/servicemix/trunk/common/servicemix-common/src/main/java/org/apache/servicemix/common/Endpoint.java Wed Mar 7 12:43:09 2007
@@ -34,6 +34,7 @@
protected Definition definition;
protected ServiceUnit serviceUnit;
protected Log logger;
+ private String key;
public Endpoint() {
}
@@ -56,6 +57,7 @@
*/
public void setEndpoint(String endpoint) {
this.endpoint = endpoint;
+ this.key = null;
}
/**
* @return Returns the service.
@@ -68,6 +70,7 @@
*/
public void setService(QName service) {
this.service = service;
+ this.key = null;
}
/**
* @return Returns the role.
@@ -143,6 +146,19 @@
public void setDefinition(Definition definition) {
this.definition = definition;
+ }
+
+ String getKey() {
+ if (key == null) {
+ if (service == null) {
+ throw new IllegalArgumentException("Endpoint: " + this + " has no service name defined");
+ }
+ if (endpoint == null) {
+ throw new IllegalArgumentException("Endpoint: " + this + " has no endpoint name defined");
+ }
+ key = EndpointSupport.getKey(service, endpoint);
+ }
+ return key;
}
}
Modified: incubator/servicemix/trunk/common/servicemix-common/src/main/java/org/apache/servicemix/common/EndpointSupport.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/common/servicemix-common/src/main/java/org/apache/servicemix/common/EndpointSupport.java?view=diff&rev=515741&r1=515740&r2=515741
==============================================================================
--- incubator/servicemix/trunk/common/servicemix-common/src/main/java/org/apache/servicemix/common/EndpointSupport.java (original)
+++ incubator/servicemix/trunk/common/servicemix-common/src/main/java/org/apache/servicemix/common/EndpointSupport.java Wed Mar 7 12:43:09 2007
@@ -31,15 +31,7 @@
}
public static String getKey(Endpoint endpoint) {
- QName serviceName = endpoint.getService();
- if (serviceName == null) {
- throw new IllegalArgumentException("Endpoint: " + endpoint + " has no service name defined");
- }
- String endpointName = endpoint.getEndpoint();
- if (endpointName == null) {
- throw new IllegalArgumentException("Endpoint: " + endpoint + " has no endpoint name defined");
- }
- return getKey(serviceName, endpointName);
+ return endpoint.getKey();
}
}
Modified: incubator/servicemix/trunk/common/servicemix-common/src/main/java/org/apache/servicemix/common/xbean/XBeanServiceUnit.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/common/servicemix-common/src/main/java/org/apache/servicemix/common/xbean/XBeanServiceUnit.java?view=diff&rev=515741&r1=515740&r2=515741
==============================================================================
--- incubator/servicemix/trunk/common/servicemix-common/src/main/java/org/apache/servicemix/common/xbean/XBeanServiceUnit.java (original)
+++ incubator/servicemix/trunk/common/servicemix-common/src/main/java/org/apache/servicemix/common/xbean/XBeanServiceUnit.java Wed Mar 7 12:43:09 2007
@@ -28,6 +28,7 @@
private Kernel kernel;
private ServiceName configuration;
+ private ClassLoader classLoader;
/**
* @return Returns the kernel.
@@ -56,21 +57,22 @@
*/
public void shutDown() throws JBIException {
super.shutDown();
+ classLoader = null;
if (kernel != null) {
kernel.destroy();
}
}
public ClassLoader getConfigurationClassLoader() {
- ClassLoader cl = null;
- if (kernel != null) {
+ if (classLoader == null && kernel != null && configuration != null) {
try {
ServiceFactory sf = kernel.getServiceFactory(configuration);
- cl = sf.getClassLoader();
+ classLoader = sf.getClassLoader();
} catch (ServiceNotFoundException e) {
// This should never happen
}
- }
+ }
+ ClassLoader cl = classLoader;
if (cl == null) {
cl = Thread.currentThread().getContextClassLoader();
}