You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by dj...@apache.org on 2005/01/29 20:35:41 UTC
svn commit: r149067 - in geronimo/trunk/modules: axis-builder/src/java/org/apache/geronimo/axis/builder axis-builder/src/test/org/apache/geronimo/axis/builder axis/src/java/org/apache/geronimo/axis/client
Author: djencks
Date: Sat Jan 29 11:35:40 2005
New Revision: 149067
URL: http://svn.apache.org/viewcvs?view=rev&rev=149067
Log:
Process more of the jaxrpc mapping file when setting up service-refs. Intermediate checkin.
Modified:
geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/AxisBuilder.java
geronimo/trunk/modules/axis-builder/src/test/org/apache/geronimo/axis/builder/ServiceReferenceTest.java
geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/client/SEIFactoryImpl.java
geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/client/ServiceImpl.java
geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/client/ServiceReference.java
Modified: geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/AxisBuilder.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/AxisBuilder.java?view=diff&rev=149067&p1=geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/AxisBuilder.java&r1=149066&p2=geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/AxisBuilder.java&r2=149067
==============================================================================
--- geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/AxisBuilder.java (original)
+++ geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/AxisBuilder.java Sat Jan 29 11:35:40 2005
@@ -50,6 +50,7 @@
import javax.wsdl.extensions.soap.SOAPOperation;
import javax.wsdl.factory.WSDLFactory;
import javax.wsdl.xml.WSDLReader;
+import javax.wsdl.xml.WSDLLocator;
import javax.xml.namespace.QName;
import net.sf.cglib.core.DefaultGeneratorStrategy;
@@ -86,6 +87,9 @@
import org.apache.geronimo.naming.reference.DeserializingReference;
import org.apache.geronimo.xbeans.j2ee.JavaWsdlMappingDocument;
import org.apache.geronimo.xbeans.j2ee.JavaWsdlMappingType;
+import org.apache.geronimo.xbeans.j2ee.ServiceEndpointInterfaceMappingType;
+import org.apache.geronimo.xbeans.j2ee.ServiceEndpointMethodMappingType;
+import org.apache.geronimo.xbeans.j2ee.MethodParamPartsMappingType;
import org.apache.xmlbeans.XmlException;
import org.objectweb.asm.Type;
import org.xml.sax.InputSource;
@@ -94,7 +98,7 @@
* @version $Rev: $ $Date: $
*/
public class AxisBuilder implements ServiceReferenceBuilder {
- private static final Class[] SERVICE_CONSTRUCTOR_TYPES = new Class[]{Map.class};
+ private static final Class[] SERVICE_CONSTRUCTOR_TYPES = new Class[]{Map.class, Map.class};
private static final URI ENHANCED_LOCATION = URI.create("cglib/");
private static final SOAPConstants SOAP_VERSION = SOAPConstants.SOAP11_CONSTANTS;
@@ -113,21 +117,22 @@
Class enhanced = enhancer.createClass();
saveClass(deploymentContext, enhanced.getName(), strategy.getClassBytes());
- return new ServiceReference(enhanced, null, null);
+ return new ServiceReference(enhanced, null, null, null);
}
public Object createService(Class serviceInterface, URI wsdlURI, URI jaxrpcMappingURI, QName serviceQName, Map portComponentRefMap, List handlers, DeploymentContext deploymentContext, Module module, ClassLoader classLoader) throws DeploymentException {
JarFile moduleFile = module.getModuleFile();
- InputStream wsdlInputStream = null;
- try {
- wsdlInputStream = moduleFile.getInputStream(moduleFile.getEntry(wsdlURI.toString()));
- } catch (IOException e) {
- throw new DeploymentException("Could not open stream to wsdl file", e);
- }
+ JarWSDLLocator wsdlLocator = new JarWSDLLocator(moduleFile, wsdlURI);
+// InputStream wsdlInputStream = null;
+// try {
+// wsdlInputStream = moduleFile.getInputStream(moduleFile.getEntry(wsdlURI.toString()));
+// } catch (IOException e) {
+// throw new DeploymentException("Could not open stream to wsdl file", e);
+// }
//TODO trying to read in the doc from the wsdlFile directly doesn't work in running geronimo, but does work in
//unit tests. You get a java.net.UnknownServiceException with message "no content-type". Perhaps something
//is wrong with the geronimo url handler??
- InputSource inputSource = new InputSource(wsdlInputStream);
+// InputSource inputSource = new InputSource(wsdlInputStream);
WSDLFactory wsdlFactory = null;
try {
wsdlFactory = WSDLFactory.newInstance();
@@ -135,10 +140,10 @@
throw new DeploymentException("Could not create WSDLFactory", e);
}
WSDLReader wsdlReader = wsdlFactory.newWSDLReader();
- wsdlReader.setFeature("javax.wsdl.importDocuments", false);
+// wsdlReader.setFeature("javax.wsdl.importDocuments", true);
Definition definition = null;
try {
- definition = wsdlReader.readWSDL(null, inputSource);
+ definition = wsdlReader.readWSDL(wsdlLocator);
} catch (WSDLException e) {
throw new DeploymentException("Failed to read wsdl document", e);
}
@@ -174,18 +179,17 @@
return reference;
}
- public javax.xml.rpc.Service createService(Class serviceInterface, Definition definition, JavaWsdlMappingType mapping, QName serviceQName, SOAPConstants soapVersion, DeploymentContext context, Module module, ClassLoader classloader) throws DeploymentException {
- Map seiFactoryMap = new HashMap();
- ServiceImpl serviceInstance = createService(serviceInterface, seiFactoryMap, context, module, classloader);
- if (serviceQName != null) {
- buildSEIFactoryMap(serviceInterface, definition, mapping, serviceQName, soapVersion, seiFactoryMap, serviceInstance, context, module, classloader);
- }
+ public Object createService(Class serviceInterface, Definition definition, JavaWsdlMappingType mapping, QName serviceQName, SOAPConstants soapVersion, DeploymentContext context, Module module, ClassLoader classloader) throws DeploymentException {
+ Map seiPortNameToFactoryMap = new HashMap();
+ Map seiClassNameToFactoryMap = new HashMap();
+ Object serviceInstance = createService(serviceInterface, seiPortNameToFactoryMap, seiClassNameToFactoryMap, context, module, classloader);
+ buildSEIFactoryMap(serviceInterface, definition, mapping, serviceQName, soapVersion, seiPortNameToFactoryMap, seiClassNameToFactoryMap, serviceInstance, context, module, classloader);
return serviceInstance;
}
- public ServiceImpl createService(Class serviceInterface, Map seiFactoryMap, DeploymentContext deploymentContext, Module module, ClassLoader classLoader) throws DeploymentException {
+ public Object createService(Class serviceInterface, Map seiPortNameToFactoryMap, Map seiClassNameToFactoryMap, DeploymentContext deploymentContext, Module module, ClassLoader classLoader) throws DeploymentException {
- Callback callback = new ServiceMethodInterceptor(seiFactoryMap);
+ Callback callback = new ServiceMethodInterceptor(seiPortNameToFactoryMap);
Callback[] methodInterceptors = new Callback[]{SerializableNoOp.INSTANCE, callback};
Enhancer enhancer = new Enhancer();
@@ -209,16 +213,25 @@
Enhancer.registerCallbacks(serviceClass, methodInterceptors);
FastConstructor constructor = FastClass.create(serviceClass).getConstructor(SERVICE_CONSTRUCTOR_TYPES);
try {
- return (ServiceImpl) constructor.newInstance(new Object[]{seiFactoryMap});
+ return constructor.newInstance(new Object[]{seiPortNameToFactoryMap, seiClassNameToFactoryMap});
} catch (InvocationTargetException e) {
throw new DeploymentException("Could not construct service instance", e.getTargetException());
}
}
- public Map buildSEIFactoryMap(Class serviceInterface, Definition definition, JavaWsdlMappingType mapping, QName serviceQName, SOAPConstants soapVersion, Map seiFactoryMap, ServiceImpl serviceImpl, DeploymentContext context, Module module, ClassLoader classloader) throws DeploymentException {
+ public void buildSEIFactoryMap(Class serviceInterface, Definition definition, JavaWsdlMappingType mapping, QName serviceQName, SOAPConstants soapVersion, Map seiPortNameToFactoryMap, Map seiClassNameToFactoryMap, Object serviceImpl, DeploymentContext context, Module module, ClassLoader classloader) throws DeploymentException {
//find the service we are working with
- javax.wsdl.Service service = definition.getService(serviceQName);
+ javax.wsdl.Service service;
+ if (serviceQName != null) {
+ service = definition.getService(serviceQName);
+ } else {
+ Map services = definition.getServices();
+ if (services.size() != 1) {
+ throw new DeploymentException("no serviceQName supplied, and there are " + services.size() + " services");
+ }
+ service = (javax.wsdl.Service) services.values().iterator().next();
+ }
if (service == null) {
throw new DeploymentException("No service wsdl for supplied service qname " + serviceQName);
}
@@ -229,40 +242,105 @@
Map.Entry entry = (Map.Entry) iterator.next();
String portName = (String) entry.getKey();
Port port = (Port) entry.getValue();
- Class serviceEndpointInterface = getServiceEndpointInterface(serviceInterface, port);
- Class enhancedServiceEndpointClass = enhanceServiceEndpointInterface(serviceEndpointInterface, context, module, classloader);
-
- SOAPAddress soapAddress = (SOAPAddress) getExtensibilityElement(SOAPAddress.class, port.getExtensibilityElements());
- String locationURIString = soapAddress.getLocationURI();
- URL location = null;
- try {
- location = new URL(locationURIString);
- } catch (MalformedURLException e) {
- throw new DeploymentException("Could not construct web service location URL from " + locationURIString);
- }
-
Binding binding = port.getBinding();
SOAPBinding soapBinding = (SOAPBinding) getExtensibilityElement(SOAPBinding.class, binding.getExtensibilityElements());
// String transportURI = soapBinding.getTransportURI();
String portStyleString = soapBinding.getStyle();
Style portStyle = Style.getStyle(portStyleString);
PortType portType = binding.getPortType();
- //port type corresponds to SEI
- List operations = portType.getOperations();
- OperationInfo[] operationInfos = new OperationInfo[FastClass.create(enhancedServiceEndpointClass).getMaxIndex() + 1];
- for (Iterator ops = operations.iterator(); ops.hasNext();) {
- Operation operation = (Operation) ops.next();
- Method method = getMethodForOperation(enhancedServiceEndpointClass, operation);
- BindingOperation bindingOperation = binding.getBindingOperation(operation.getName(), operation.getInput().getName(), operation.getOutput().getName());
- OperationInfo operationInfo = buildOperationInfo(method, bindingOperation, portStyle, soapVersion);
- int methodIndex = getSuperIndex(enhancedServiceEndpointClass, method);
- operationInfos[methodIndex] = operationInfo;
- }
- List typeMappings = new ArrayList();
- SEIFactory seiFactory = createSEIFactory(enhancedServiceEndpointClass, serviceImpl, typeMappings, location, operationInfos, context, classloader);
- seiFactoryMap.put(portName, seiFactory);
+ SOAPAddress soapAddress = (SOAPAddress) getExtensibilityElement(SOAPAddress.class, port.getExtensibilityElements());
+ String locationURIString = soapAddress.getLocationURI();
+ URL location = null;
+ try {
+ location = new URL(locationURIString);
+ } catch (MalformedURLException e) {
+ throw new DeploymentException("Could not construct web service location URL from " + locationURIString);
+ }
+
+ SEIFactory seiFactory;
+
+ Class serviceEndpointInterface = null;
+ ServiceEndpointInterfaceMappingType[] endpointMappings = mapping.getServiceEndpointInterfaceMappingArray();
+ if (endpointMappings.length == 0) {
+ serviceEndpointInterface = getServiceEndpointInterfaceLightweight(serviceInterface, port);
+ Class enhancedServiceEndpointClass = enhanceServiceEndpointInterface(serviceEndpointInterface, context, module, classloader);
+
+ //port type corresponds to SEI
+ List operations = portType.getOperations();
+ OperationInfo[] operationInfos = new OperationInfo[FastClass.create(enhancedServiceEndpointClass).getMaxIndex() + 1];
+ for (Iterator ops = operations.iterator(); ops.hasNext();) {
+ Operation operation = (Operation) ops.next();
+ Method method = getMethodForOperation(enhancedServiceEndpointClass, operation);
+ BindingOperation bindingOperation = binding.getBindingOperation(operation.getName(), operation.getInput().getName(), operation.getOutput() == null? null: operation.getOutput().getName());
+ OperationInfo operationInfo = buildOperationInfo(method, bindingOperation, portStyle, soapVersion);
+ int methodIndex = getSuperIndex(enhancedServiceEndpointClass, method);
+ operationInfos[methodIndex] = operationInfo;
+ }
+ List typeMappings = new ArrayList();
+ seiFactory = createSEIFactory(enhancedServiceEndpointClass, serviceImpl, typeMappings, location, operationInfos, context, classloader);
+ } else {
+ QName portTypeQName = portType.getQName();
+ ServiceEndpointInterfaceMappingType endpointMapping = getServiceEndpointInterfaceMapping(endpointMappings, portTypeQName);
+ String fqcn = endpointMapping.getServiceEndpointInterface().getStringValue();
+ try {
+ serviceEndpointInterface = classloader.loadClass(fqcn);
+ } catch (ClassNotFoundException e) {
+ throw new DeploymentException("Could not load service endpoint interface", e);
+ }
+ Class enhancedServiceEndpointClass = enhanceServiceEndpointInterface(serviceEndpointInterface, context, module, classloader);
+
+ //port type corresponds to SEI
+ List operations = portType.getOperations();
+ ServiceEndpointMethodMappingType[] methodMappings = endpointMapping.getServiceEndpointMethodMappingArray();
+ OperationInfo[] operationInfos = new OperationInfo[FastClass.create(enhancedServiceEndpointClass).getMaxIndex() + 1];
+ for (Iterator ops = operations.iterator(); ops.hasNext();) {
+ Operation operation = (Operation) ops.next();
+ BindingOperation bindingOperation = binding.getBindingOperation(operation.getName(), operation.getInput().getName(), operation.getOutput() == null? null: operation.getOutput().getName());
+ ServiceEndpointMethodMappingType methodMapping = getMethodMappingForOperation(operation, methodMappings);
+ String javaMethodName = methodMapping.getJavaMethodName().getStringValue().trim();
+ Class[] types = getParameterTypes(methodMapping, classloader);
+ Method method = null;
+ try {
+ method = serviceEndpointInterface.getMethod(javaMethodName, types);
+ } catch (NoSuchMethodException e) {
+ throw new DeploymentException("Could not find method for operation", e);
+ }
+ OperationInfo operationInfo = buildOperationInfo(method, bindingOperation, portStyle, soapVersion);
+ int methodIndex = getSuperIndex(enhancedServiceEndpointClass, method);
+ operationInfos[methodIndex] = operationInfo;
+ }
+ List typeMappings = new ArrayList();
+ seiFactory = createSEIFactory(enhancedServiceEndpointClass, serviceImpl, typeMappings, location, operationInfos, context, classloader);
+ }
+ seiPortNameToFactoryMap.put(portName, seiFactory);
+ seiClassNameToFactoryMap.put(serviceEndpointInterface.getName(), seiFactory);
}
- return seiFactoryMap;
+ }
+
+ private Class[] getParameterTypes(ServiceEndpointMethodMappingType methodMapping, ClassLoader classloader) throws DeploymentException {
+ MethodParamPartsMappingType[] paramMappings = methodMapping.getMethodParamPartsMappingArray();
+ Class[] types = new Class[paramMappings.length];
+ for (int i = 0; i < paramMappings.length; i++) {
+ MethodParamPartsMappingType paramMapping = paramMappings[i];
+ String paramType = paramMapping.getParamType().getStringValue().trim();
+ try {
+ types[i] = classloader.loadClass(paramType);
+ } catch (ClassNotFoundException e) {
+ throw new DeploymentException("Could not load param type", e);
+ }
+ }
+ return types;
+ }
+
+ private ServiceEndpointMethodMappingType getMethodMappingForOperation(Operation operation, ServiceEndpointMethodMappingType[] methodMappings) throws DeploymentException {
+ String operationName = operation.getName();
+ for (int i = 0; i < methodMappings.length; i++) {
+ ServiceEndpointMethodMappingType methodMapping = methodMappings[i];
+ if (operationName.equals(methodMapping.getWsdlOperation())) {
+ return methodMapping;
+ }
+ }
+ throw new DeploymentException("No method found for operation named " + operationName);
}
private Method getMethodForOperation(Class enhancedServiceEndpointClass, Operation operation) throws DeploymentException {
@@ -284,7 +362,7 @@
return found;
}
- private Class getServiceEndpointInterface(Class serviceInterface, Port port) throws DeploymentException {
+ private Class getServiceEndpointInterfaceLightweight(Class serviceInterface, Port port) throws DeploymentException {
Method[] methods = serviceInterface.getMethods();
String methodName = "get" + port.getName();
String serviceEndpointInterfaceShortName = port.getBinding().getPortType().getQName().getLocalPart();
@@ -304,6 +382,17 @@
throw new DeploymentException("Could not find service endpoint interface for port named " + port.getName());
}
+ private ServiceEndpointInterfaceMappingType getServiceEndpointInterfaceMapping(ServiceEndpointInterfaceMappingType[] endpointMappings, QName portTypeQName) throws DeploymentException {
+ for (int i = 0; i < endpointMappings.length; i++) {
+ ServiceEndpointInterfaceMappingType endpointMapping = endpointMappings[i];
+ QName testPortQName = endpointMapping.getWsdlPortType().getQNameValue();
+ if (portTypeQName.equals(testPortQName)) {
+ return endpointMapping;
+ }
+ }
+ throw new DeploymentException("Could not find service endpoint interface for port named " + portTypeQName);
+ }
+
private ExtensibilityElement getExtensibilityElement(Class clazz, List extensibilityElements) throws DeploymentException {
for (Iterator iterator = extensibilityElements.iterator(); iterator.hasNext();) {
ExtensibilityElement extensibilityElement = (ExtensibilityElement) iterator.next();
@@ -325,10 +414,14 @@
// throw new DeploymentException("Package " + packageName + " was not mapped in jaxrpc mapping file");
// }
- public SEIFactory createSEIFactory(Class enhancedServiceEndpointClass, ServiceImpl serviceImpl, List typeMappings, URL location, OperationInfo[] operationInfos, DeploymentContext deploymentContext, ClassLoader classLoader) throws DeploymentException {
+ public SEIFactory createSEIFactory(Class enhancedServiceEndpointClass, Object serviceImpl, List typeMappings, URL location, OperationInfo[] operationInfos, DeploymentContext deploymentContext, ClassLoader classLoader) throws DeploymentException {
- SEIFactory factory = new SEIFactoryImpl(enhancedServiceEndpointClass, operationInfos, serviceImpl, typeMappings, location);
- return factory;
+ try {
+ SEIFactory factory = new SEIFactoryImpl(enhancedServiceEndpointClass, operationInfos, serviceImpl, typeMappings, location, classLoader);
+ return factory;
+ } catch (ClassNotFoundException e) {
+ throw new DeploymentException("Could not load GenericServiceEndpoint from application classloader", e);
+ }
}
public Class enhanceServiceEndpointInterface(Class serviceEndpointInterface, DeploymentContext deploymentContext, Module module, ClassLoader classLoader) throws DeploymentException {
@@ -354,6 +447,8 @@
}
public OperationInfo buildOperationInfo(Method method, BindingOperation bindingOperation, Style defaultStyle, SOAPConstants soapVersion) throws DeploymentException {
+
+ //TODO how can bindingOperation be null?
Operation operation = bindingOperation.getOperation();
String operationName = operation.getName();
List order = operation.getParameterOrdering();
@@ -363,7 +458,7 @@
QName returnQName = null;
Message inputMessage = operation.getInput().getMessage();
- Message outputMessage = operation.getOutput().getMessage();
+ Message outputMessage = operation.getOutput() == null? null: operation.getOutput().getMessage();
if (order == null || order.size() == 0) {
if (outputMessage != null && outputMessage.getParts().size() > 1) {
@@ -467,6 +562,48 @@
public byte[] getClassBytes() {
return classBytes;
+ }
+ }
+
+ static class JarWSDLLocator implements WSDLLocator {
+
+ private final JarFile moduleFile;
+ private final URI wsdlURI;
+ private URI latestImportURI;
+
+ public JarWSDLLocator(JarFile moduleFile, URI wsdlURI) {
+ this.moduleFile = moduleFile;
+ this.wsdlURI = wsdlURI;
+ }
+
+ public InputSource getBaseInputSource() {
+ InputStream wsdlInputStream = null;
+ try {
+ wsdlInputStream = moduleFile.getInputStream(moduleFile.getEntry(wsdlURI.toString()));
+ } catch (IOException e) {
+ throw new RuntimeException("Could not open stream to wsdl file", e);
+ }
+ return new InputSource(wsdlInputStream);
+ }
+
+ public String getBaseURI() {
+ return wsdlURI.toString();
+ }
+
+ public InputSource getImportInputSource(String parentLocation, String relativeLocation) {
+ URI parentURI = URI.create(parentLocation);
+ latestImportURI = parentURI.resolve(relativeLocation);
+ InputStream importInputStream = null;
+ try {
+ importInputStream = moduleFile.getInputStream(moduleFile.getEntry(latestImportURI.toString()));
+ } catch (IOException e) {
+ throw new RuntimeException("Could not open stream to import file", e);
+ }
+ return new InputSource(importInputStream);
+ }
+
+ public String getLatestImportURI() {
+ return latestImportURI.toString();
}
}
Modified: geronimo/trunk/modules/axis-builder/src/test/org/apache/geronimo/axis/builder/ServiceReferenceTest.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/axis-builder/src/test/org/apache/geronimo/axis/builder/ServiceReferenceTest.java?view=diff&rev=149067&p1=geronimo/trunk/modules/axis-builder/src/test/org/apache/geronimo/axis/builder/ServiceReferenceTest.java&r1=149066&p2=geronimo/trunk/modules/axis-builder/src/test/org/apache/geronimo/axis/builder/ServiceReferenceTest.java&r2=149067
==============================================================================
--- geronimo/trunk/modules/axis-builder/src/test/org/apache/geronimo/axis/builder/ServiceReferenceTest.java (original)
+++ geronimo/trunk/modules/axis-builder/src/test/org/apache/geronimo/axis/builder/ServiceReferenceTest.java Sat Jan 29 11:35:40 2005
@@ -127,9 +127,12 @@
public void testServiceProxy() throws Exception {
//construct the SEI proxy
Map portMap = new HashMap();
- portMap.put("MockPort", new MockSEIFactory());
+ MockSEIFactory factory = new MockSEIFactory();
+ portMap.put("MockPort", factory);
+ Map seiClassNameToFactoryMap = new HashMap();
+ seiClassNameToFactoryMap.put(MockPort.class.getName(), factory);
AxisBuilder builder = new AxisBuilder();
- Service service = builder.createService(MockService.class, portMap, context, module, isolatedCl);
+ Object service = builder.createService(MockService.class, portMap, seiClassNameToFactoryMap, context, module, isolatedCl);
assertTrue(service instanceof MockService);
MockService mockService = (MockService) service;
MockPort mockPort = mockService.getMockPort();
@@ -139,7 +142,7 @@
public void testServiceEndpointProxy() throws Exception {
AxisBuilder builder = new AxisBuilder();
- ServiceImpl serviceInstance = new ServiceImpl(null);
+ ServiceImpl serviceInstance = new ServiceImpl(null, null);
List typeMappings = new ArrayList();
URL location = new URL("http://geronimo.apache.org/ws");
@@ -204,6 +207,10 @@
assertTrue(proxy instanceof InteropLab);
InteropTestPortType interopTestPort = ((InteropLab) proxy).getinteropTestPort();
assertNotNull(interopTestPort);
+ testInteropPort(interopTestPort);
+ }
+
+ private void testInteropPort(InteropTestPortType interopTestPort) throws java.rmi.RemoteException {
if (runExternalWSTest) {
System.out.println("Running external ws test");
int result = interopTestPort.echoInteger(1);
@@ -231,16 +238,25 @@
Object proxy = reference.getContent();
assertNotNull(proxy);
assertTrue(proxy instanceof InteropLab);
- InteropTestPortType interopTestPort = ((InteropLab) proxy).getinteropTestPort();
+
+ InteropLab interopLab = ((InteropLab) proxy);
+ InteropTestPortType interopTestPort = interopLab.getinteropTestPort();
assertNotNull(interopTestPort);
- if (runExternalWSTest) {
- System.out.println("Running external ws test");
- int result = interopTestPort.echoInteger(1);
- assertEquals(result, 1);
- } else {
- System.out.println("Skipping external ws test");
- }
+ testInteropPort(interopTestPort);
+
+ //test more dynamically
+ Remote sei = interopLab.getPort(InteropTestPortType.class);
+ assertNotNull(sei);
+ assertTrue(sei instanceof InteropTestPortType);
+ testInteropPort((InteropTestPortType) sei);
+
+ Remote sei2 = interopLab.getPort(new QName("http://tempuri.org/4s4c/1/3/wsdl/def/interopLab", "interopTestPort"), null);
+ assertNotNull(sei2);
+ assertTrue(sei2 instanceof InteropTestPortType);
+ testInteropPort((InteropTestPortType) sei2);
}
+
+
private OperationInfo buildOperationInfoForMockOperation(AxisBuilder builder) throws NoSuchMethodException, DeploymentException, WSDLException {
Class portClass = MockPort.class;
Modified: geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/client/SEIFactoryImpl.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/client/SEIFactoryImpl.java?view=diff&rev=149067&p1=geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/client/SEIFactoryImpl.java&r1=149066&p2=geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/client/SEIFactoryImpl.java&r2=149067
==============================================================================
--- geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/client/SEIFactoryImpl.java (original)
+++ geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/client/SEIFactoryImpl.java Sat Jan 29 11:35:40 2005
@@ -20,6 +20,7 @@
import java.rmi.Remote;
import java.io.Serializable;
import java.io.ObjectStreamException;
+import java.io.InvalidClassException;
import java.util.List;
import java.net.URL;
import javax.xml.rpc.ServiceException;
@@ -39,21 +40,23 @@
private final Class serviceEndpointClass;
private final OperationInfo[] operationInfos;
private transient final FastConstructor constructor;
- private final ServiceImpl serviceImpl;
+ private final Object serviceImpl;
private final List typeMappings;
private final URL location;
- public SEIFactoryImpl(Class serviceEndpointClass, OperationInfo[] operationInfos, ServiceImpl serviceImpl, List typeMappings, URL location) {
+ public SEIFactoryImpl(Class serviceEndpointClass, OperationInfo[] operationInfos, Object serviceImpl, List typeMappings, URL location, ClassLoader classLoader) throws ClassNotFoundException {
this.serviceEndpointClass = serviceEndpointClass;
this.operationInfos = operationInfos;
- this.constructor = FastClass.create(serviceEndpointClass).getConstructor(SERVICE_ENDPOINT_CONSTRUCTOR_TYPES);
+ Class[] constructorTypes = new java.lang.Class[0];
+ constructorTypes = classLoader == null? SERVICE_ENDPOINT_CONSTRUCTOR_TYPES: new Class[] {classLoader.loadClass(GenericServiceEndpoint.class.getName())};
+ this.constructor = FastClass.create(serviceEndpointClass).getConstructor(constructorTypes);
this.serviceImpl = serviceImpl;
this.typeMappings = typeMappings;
this.location = location;
}
public Remote createServiceEndpoint() throws ServiceException {
- Service service = serviceImpl.getService();
+ Service service = ((ServiceImpl)serviceImpl).getService();
GenericServiceEndpoint serviceEndpoint = new GenericServiceEndpoint(service, typeMappings, location);
Callback callback = new ServiceEndpointMethodInterceptor(serviceEndpoint, operationInfos);
Callback[] callbacks = new Callback[]{SerializableNoOp.INSTANCE, callback};
@@ -67,6 +70,10 @@
}
private Object readResolve() throws ObjectStreamException {
- return new SEIFactoryImpl(serviceEndpointClass, operationInfos, serviceImpl, typeMappings, location);
+ try {
+ return new SEIFactoryImpl(serviceEndpointClass, operationInfos, serviceImpl, typeMappings, location, null);
+ } catch (ClassNotFoundException e) {
+ throw new InvalidClassException(GenericServiceEndpoint.class.getName(), "this is impossible");
+ }
}
}
Modified: geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/client/ServiceImpl.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/client/ServiceImpl.java?view=diff&rev=149067&p1=geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/client/ServiceImpl.java&r1=149066&p2=geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/client/ServiceImpl.java&r2=149067
==============================================================================
--- geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/client/ServiceImpl.java (original)
+++ geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/client/ServiceImpl.java Sat Jan 29 11:35:40 2005
@@ -33,15 +33,17 @@
/**
- * @version $Rev$ $Date$
+ * @version $Revision:$ $Date:$
*/
public class ServiceImpl implements javax.xml.rpc.Service, Serializable {
private transient Service delegate;
+ private Map seiClassNameToFactoryMap;
private final Map portToImplementationMap;
- public ServiceImpl(Map portToImplementationMap) {
+ public ServiceImpl(Map portToImplementationMap, Map seiClassNameToFactoryMap) {
this.portToImplementationMap = portToImplementationMap;
+ this.seiClassNameToFactoryMap = seiClassNameToFactoryMap;
this.delegate = new Service();
}
@@ -49,27 +51,15 @@
if (qName != null) {
String portName = qName.getLocalPart();
Remote port = internalGetPort(portName);
- if (port != null) {
- return port;
- }
- }
- String fqcn = portClass.getName();
- String portName = fqcn.substring(fqcn.lastIndexOf('.'));
- Remote port = internalGetPort(portName);
- if (port != null) {
return port;
}
- return delegate.getPort(qName, portClass);
+ return getPort(portClass);
}
public Remote getPort(Class portClass) throws ServiceException {
String fqcn = portClass.getName();
- String portName = fqcn.substring(fqcn.lastIndexOf('.'));
- Remote port = internalGetPort(portName);
- if (port != null) {
- return port;
- }
- return delegate.getPort(portClass);
+ Remote port = internalGetPortFromClassName(fqcn);
+ return port;
}
public Call[] getCalls(QName qName) throws ServiceException {
@@ -81,7 +71,7 @@
}
public Call createCall(QName qName, QName qName1) throws ServiceException {
- return delegate.createCall(qName, qName1);
+ return delegate.createCall(qName, qName1);
}
public Call createCall(QName qName, String s) throws ServiceException {
@@ -114,9 +104,20 @@
Remote internalGetPort(String portName) throws ServiceException {
if (portToImplementationMap.containsKey(portName)) {
- return (Remote) portToImplementationMap.get(portName);
+ SEIFactory seiFactory = (SEIFactory) portToImplementationMap.get(portName);
+ Remote port = seiFactory.createServiceEndpoint();
+ return port;
+ }
+ throw new ServiceException("No port for portname: " + portName);
+ }
+
+ Remote internalGetPortFromClassName(String className) throws ServiceException {
+ if (seiClassNameToFactoryMap.containsKey(className)) {
+ SEIFactory seiFactory = (SEIFactory) seiClassNameToFactoryMap.get(className);
+ Remote port = seiFactory.createServiceEndpoint();
+ return port;
}
- return null;
+ throw new ServiceException("no port for class " + className);
}
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
Modified: geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/client/ServiceReference.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/client/ServiceReference.java?view=diff&rev=149067&p1=geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/client/ServiceReference.java&r1=149066&p2=geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/client/ServiceReference.java&r2=149067
==============================================================================
--- geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/client/ServiceReference.java (original)
+++ geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/client/ServiceReference.java Sat Jan 29 11:35:40 2005
@@ -30,25 +30,27 @@
* @version $Rev: $ $Date: $
*/
public class ServiceReference extends SimpleAwareReference {
- private final static Class[] CONSTRUCTOR_TYPES = new Class[] {Map.class};
+ private final static Class[] CONSTRUCTOR_TYPES = new Class[] {Map.class, Map.class};
private final Class serviceClass;
private final Callback[] methodInterceptors;
- private final Map ports;
+ private final Map portNameToFactoryMap;
+ private final Map seiClassNameToFactoryMap;
//THIS IS NOT SERIALIZABLE!
private final FastConstructor constructor;
- public ServiceReference(Class serviceClass, MethodInterceptor methodInterceptor, Map ports) {
+ public ServiceReference(Class serviceClass, MethodInterceptor methodInterceptor, Map portNameToFactoryMap, Map seiClassNameToFactoryMap) {
this.serviceClass = serviceClass;
this.methodInterceptors = new Callback[] {SerializableNoOp.INSTANCE, methodInterceptor};
- this.ports = ports;
+ this.portNameToFactoryMap = portNameToFactoryMap;
+ this.seiClassNameToFactoryMap = seiClassNameToFactoryMap;
this.constructor = FastClass.create(serviceClass).getConstructor(CONSTRUCTOR_TYPES);
}
public Object getContent() {
try {
Enhancer.registerCallbacks(serviceClass, methodInterceptors);
- Object serviceInstance = constructor.newInstance(new Object[] {ports});
+ Object serviceInstance = constructor.newInstance(new Object[] {portNameToFactoryMap, seiClassNameToFactoryMap});
return serviceInstance;
} catch (InvocationTargetException e) {
throw new RuntimeException("Could not create instance", e);