Author: ropalka
Date: 2012-02-16 09:04:49 -0500 (Thu, 16 Feb 2012)
New Revision: 15670
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/client/ServiceImpl.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/client/ServiceProxy.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/metadata/umdm/ServiceMetaData.java
Log:
[JBWS-3438] make JAX-RPC generated proxies to be de/serializable
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/client/ServiceImpl.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/client/ServiceImpl.java 2012-02-16
13:57:55 UTC (rev 15669)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/client/ServiceImpl.java 2012-02-16
14:04:49 UTC (rev 15670)
@@ -21,6 +21,11 @@
*/
package org.jboss.ws.core.jaxrpc.client;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.io.Serializable;
import java.lang.reflect.Proxy;
import java.net.URL;
import java.rmi.Remote;
@@ -73,30 +78,38 @@
* @author Thomas.Diesler(a)jboss.org
* @since 10-Oct-2004
*/
-public class ServiceImpl implements ServiceExt
+public class ServiceImpl implements ServiceExt, Serializable, Externalizable
{
private static final ResourceBundle bundle =
BundleUtils.getBundle(ServiceImpl.class);
// provide logging
private static final Logger log = Logger.getLogger(ServiceImpl.class);
// The service meta data that is associated with this JAXRPC Service
- private ServiceMetaData serviceMetaData;
+ private transient ServiceMetaData serviceMetaData;
+ private QName serviceName;
// The optional WSDL location
private URL wsdlLocation;
+ private URL mappingURL;
+ private URL securityURL;
+ private JavaWsdlMapping mappingConfig;
+ private WSSecurityConfiguration securityConfig;
// The <service-ref> meta data
private UnifiedServiceRefMetaData usrMetaData;
// The handler registry
- private HandlerRegistryImpl handlerRegistry;
+ private transient HandlerRegistryImpl handlerRegistry;
+ public ServiceImpl() {
+ // for deserialization only
+ }
+
/**
* Construct a Service without WSDL meta data
*/
public ServiceImpl(QName serviceName)
{
- UnifiedMetaData wsMetaData = new UnifiedMetaData(new ResourceLoaderAdapter());
- serviceMetaData = new ServiceMetaData(wsMetaData, serviceName);
- handlerRegistry = new HandlerRegistryImpl(serviceMetaData);
+ this.serviceName = serviceName;
+ init();
}
/**
@@ -104,13 +117,11 @@
*/
public ServiceImpl(QName serviceName, URL wsdlURL, URL mappingURL, URL securityURL)
{
+ this.serviceName = serviceName;
this.wsdlLocation = wsdlURL;
- JAXRPCClientMetaDataBuilder builder = new JAXRPCClientMetaDataBuilder();
-
- ClassLoader ctxClassLoader = SecurityActions.getContextClassLoader();
-
- serviceMetaData = builder.buildMetaData(serviceName, wsdlURL, mappingURL,
securityURL, null, ctxClassLoader);
- handlerRegistry = new HandlerRegistryImpl(serviceMetaData);
+ this.mappingURL = mappingURL;
+ this.securityURL = securityURL;
+ init();
}
/**
@@ -118,16 +129,55 @@
*/
public ServiceImpl(QName serviceName, URL wsdlURL, JavaWsdlMapping mappingURL,
WSSecurityConfiguration securityConfig, UnifiedServiceRefMetaData usrMetaData)
{
+ this.serviceName = serviceName;
this.wsdlLocation = wsdlURL;
+ this.mappingConfig = mappingURL;
+ this.securityConfig = securityConfig;
this.usrMetaData = usrMetaData;
+ init();
+ }
- JAXRPCClientMetaDataBuilder builder = new JAXRPCClientMetaDataBuilder();
- ClassLoader ctxClassLoader = SecurityActions.getContextClassLoader();
+ public void writeExternal(final ObjectOutput out) throws IOException {
+ out.writeObject(serviceName);
+ out.writeObject(wsdlLocation);
+ out.writeObject(mappingURL);
+ out.writeObject(securityURL);
+ out.writeObject(mappingConfig);
+ out.writeObject(securityConfig);
+ out.writeObject(usrMetaData);
+ }
- serviceMetaData = builder.buildMetaData(serviceName, wsdlURL, mappingURL,
securityConfig, usrMetaData, ctxClassLoader);
- handlerRegistry = new HandlerRegistryImpl(serviceMetaData);
+ public void readExternal(final ObjectInput in) throws IOException,
ClassNotFoundException {
+ serviceName = (QName)in.readObject();
+ wsdlLocation = (URL)in.readObject();
+ mappingURL = (URL)in.readObject();
+ securityURL = (URL)in.readObject();
+ mappingConfig = (JavaWsdlMapping)in.readObject();
+ securityConfig = (WSSecurityConfiguration)in.readObject();
+ usrMetaData = (UnifiedServiceRefMetaData)in.readObject();
+ init();
}
+ private void init() {
+ if ((wsdlLocation == null) && (mappingURL == null) && (securityURL
== null) && (securityConfig == null) && (mappingConfig == null) &&
(usrMetaData == null)) {
+ UnifiedMetaData wsMetaData = new UnifiedMetaData(new
ResourceLoaderAdapter());
+ serviceMetaData = new ServiceMetaData(wsMetaData, serviceName);
+ handlerRegistry = new HandlerRegistryImpl(serviceMetaData);
+ return;
+ }
+ if ((mappingURL != null) || (securityURL != null)) {
+ JAXRPCClientMetaDataBuilder builder = new JAXRPCClientMetaDataBuilder();
+ ClassLoader ctxClassLoader = SecurityActions.getContextClassLoader();
+ serviceMetaData = builder.buildMetaData(serviceName, wsdlLocation, mappingURL,
securityURL, null, ctxClassLoader);
+ handlerRegistry = new HandlerRegistryImpl(serviceMetaData);
+ return;
+ }
+ JAXRPCClientMetaDataBuilder builder = new JAXRPCClientMetaDataBuilder();
+ ClassLoader ctxClassLoader = SecurityActions.getContextClassLoader();
+ serviceMetaData = builder.buildMetaData(serviceName, wsdlLocation, mappingConfig,
securityConfig, usrMetaData, ctxClassLoader);
+ handlerRegistry = new HandlerRegistryImpl(serviceMetaData);
+ }
+
public ServiceMetaData getServiceMetaData()
{
return serviceMetaData;
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/client/ServiceProxy.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/client/ServiceProxy.java 2012-02-16
13:57:55 UTC (rev 15669)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/client/ServiceProxy.java 2012-02-16
14:04:49 UTC (rev 15670)
@@ -21,6 +21,11 @@
*/
package org.jboss.ws.core.jaxrpc.client;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.io.Serializable;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@@ -44,7 +49,7 @@
* @author Thomas.Diesler(a)jboss.org
* @since 15-May-2004
*/
-public class ServiceProxy implements InvocationHandler
+public class ServiceProxy implements InvocationHandler, Serializable, Externalizable
{
private static final ResourceBundle bundle =
BundleUtils.getBundle(ServiceProxy.class);
// provide logging
@@ -52,17 +57,22 @@
// The underlying jaxrpc service
private ServiceImpl jaxrpcService;
+ private Class siClass;
// The methods from java.lang.Object
- private List objectMethods = new ArrayList();
+ private transient List objectMethods = new ArrayList();
// The methods from javax.xml.rpc.Service
- private List jaxrpcServiceMethods = new ArrayList();
+ private transient List jaxrpcServiceMethods = new ArrayList();
// The methods from the service interface, in case of javax.xml.rpc.Service it is
empty
- private List serviceInterfaceMethods = new ArrayList();
+ private transient List serviceInterfaceMethods = new ArrayList();
// The cached getPort method
- private Method getPortMethod;
+ private transient Method getPortMethod;
+ public ServiceProxy() {
+ // for deserialization only
+ }
+
/**
* Construct a client side service proxy.
* <p/>
@@ -74,26 +84,30 @@
public ServiceProxy(ServiceImpl service, Class siClass)
{
this.jaxrpcService = service;
+ this.siClass = siClass;
+ init();
+ }
- // initialize java.lang.Object methods
- objectMethods.addAll(Arrays.asList(Object.class.getMethods()));
+ private void init() {
+ // initialize java.lang.Object methods
+ objectMethods.addAll(Arrays.asList(Object.class.getMethods()));
- // initialize javax.xml.rpc.Service methods
- jaxrpcServiceMethods.addAll(Arrays.asList(ServiceExt.class.getMethods()));
+ // initialize javax.xml.rpc.Service methods
+ jaxrpcServiceMethods.addAll(Arrays.asList(ServiceExt.class.getMethods()));
- // initialize SI methods
- if (siClass.getName().equals("javax.xml.rpc.Service") == false)
- serviceInterfaceMethods.addAll(Arrays.asList(siClass.getDeclaredMethods()));
+ // initialize SI methods
+ if (siClass.getName().equals("javax.xml.rpc.Service") == false)
+ serviceInterfaceMethods.addAll(Arrays.asList(siClass.getDeclaredMethods()));
- // initialize special ws4ee methods
- try
- {
- getPortMethod = Service.class.getMethod("getPort", new
Class[]{Class.class});
- }
- catch (NoSuchMethodException e)
- {
- throw new JAXRPCException(e.toString());
- }
+ // initialize special ws4ee methods
+ try
+ {
+ getPortMethod = Service.class.getMethod("getPort", new
Class[]{Class.class});
+ }
+ catch (NoSuchMethodException e)
+ {
+ throw new JAXRPCException(e.toString());
+ }
}
/**
@@ -159,4 +173,16 @@
log.error(BundleUtils.getMessage(bundle, "SERVICE_ERROR"), th);
throw th;
}
+
+ public void writeExternal(final ObjectOutput out) throws IOException {
+ out.writeObject(jaxrpcService);
+ out.writeObject(siClass);
+ }
+
+ public void readExternal(final ObjectInput in) throws IOException,
ClassNotFoundException {
+ jaxrpcService = (ServiceImpl)in.readObject();
+ siClass = (Class)in.readObject();
+ init();
+ }
+
}
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/metadata/umdm/ServiceMetaData.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/metadata/umdm/ServiceMetaData.java 2012-02-16
13:57:55 UTC (rev 15669)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/metadata/umdm/ServiceMetaData.java 2012-02-16
14:04:49 UTC (rev 15670)
@@ -22,6 +22,7 @@
package org.jboss.ws.metadata.umdm;
import java.io.IOException;
+import java.io.Serializable;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
@@ -60,7 +61,7 @@
* @author Thomas.Diesler(a)jboss.org
* @since 12-May-2005
*/
-public class ServiceMetaData implements InitalizableMetaData
+public class ServiceMetaData implements InitalizableMetaData, Serializable
{
private static final ResourceBundle bundle =
BundleUtils.getBundle(ServiceMetaData.class);
// provide logging