Author: david.lloyd(a)jboss.com
Date: 2009-11-12 18:57:01 -0500 (Thu, 12 Nov 2009)
New Revision: 5589
Modified:
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/EndpointImpl.java
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/ServiceRegistrationListener.java
Log:
Allow specification of default classloader for a service, defaulting to the classloader of
the client listener
Modified:
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/EndpointImpl.java
===================================================================
---
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/EndpointImpl.java 2009-11-12
00:52:52 UTC (rev 5588)
+++
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/EndpointImpl.java 2009-11-12
23:57:01 UTC (rev 5589)
@@ -233,6 +233,7 @@
private Class<I> requestType;
private Class<O> replyType;
private ClientListener<? super I, ? extends O> clientListener;
+ private ClassLoader classLoader;
private OptionMap optionMap = OptionMap.EMPTY;
public ServiceBuilder<I, O> setGroupName(final String groupName) {
@@ -275,6 +276,11 @@
return this;
}
+ public ServiceBuilder<I, O> setClassLoader(final ClassLoader classLoader)
{
+ this.classLoader = classLoader;
+ return this;
+ }
+
public ServiceBuilder<I, O> setOptionMap(final OptionMap optionMap) {
if (optionMap == null) {
throw new NullPointerException("optionMap is null");
@@ -353,6 +359,10 @@
serviceInfo.setOptionMap(optionMap);
serviceInfo.setRegistrationHandle(handle);
serviceInfo.setRequestHandlerConnector(requestHandlerConnector);
+ serviceInfo.setRequestClass(requestType);
+ serviceInfo.setReplyClass(replyType);
+ final ClassLoader classLoader = this.classLoader;
+ serviceInfo.setServiceClassLoader(classLoader == null ?
clientListener.getClass().getClassLoader() : classLoader);
executor.execute(new Runnable() {
public void run() {
final
Iterator<Map.Entry<Registration,ServiceRegistrationListener>> iter =
serviceListenerRegistrations;
Modified:
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/ServiceRegistrationListener.java
===================================================================
---
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/ServiceRegistrationListener.java 2009-11-12
00:52:52 UTC (rev 5588)
+++
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/ServiceRegistrationListener.java 2009-11-12
23:57:01 UTC (rev 5589)
@@ -49,6 +49,9 @@
final class ServiceInfo implements Cloneable {
private String serviceType;
private String groupName;
+ private ClassLoader serviceClassLoader;
+ private Class<?> requestClass;
+ private Class<?> replyClass;
private RequestHandlerConnector requestHandlerConnector;
private Registration registrationHandle;
private OptionMap optionMap;
@@ -96,6 +99,60 @@
}
/**
+ * Get the service's default classloader.
+ *
+ * @return the classloader
+ */
+ public ClassLoader getServiceClassLoader() {
+ return serviceClassLoader;
+ }
+
+ /**
+ * Set the service's default classloader.
+ *
+ * @param serviceClassLoader the classloader
+ */
+ public void setServiceClassLoader(final ClassLoader serviceClassLoader) {
+ this.serviceClassLoader = serviceClassLoader;
+ }
+
+ /**
+ * Get the request class.
+ *
+ * @return the request class
+ */
+ public Class<?> getRequestClass() {
+ return requestClass;
+ }
+
+ /**
+ * Set the request class.
+ *
+ * @param requestClass the request class
+ */
+ public void setRequestClass(final Class<?> requestClass) {
+ this.requestClass = requestClass;
+ }
+
+ /**
+ * Get the reply class.
+ *
+ * @return the reply class
+ */
+ public Class<?> getReplyClass() {
+ return replyClass;
+ }
+
+ /**
+ * Set the reply class.
+ *
+ * @param replyClass the reply class
+ */
+ public void setReplyClass(final Class<?> replyClass) {
+ this.replyClass = replyClass;
+ }
+
+ /**
* Get the option map.
*
* @return the option map
Show replies by date