gdaniels 2002/10/16 21:40:19 Modified: java/src/org/apache/axis/client Call.java java/src/org/apache/axis/deployment/wsdd WSDDDeployment.java WSDDService.java java/src/org/apache/axis/encoding TypeMappingRegistry.java TypeMappingRegistryImpl.java java/test/RPCDispatch TestSerializedRPC.java Log: Add getOrMakeTypeMapping() method to TypeMappingRegistry. This allows us to refactor a common block of code into a responsibility of the TMR. Revision Changes Path 1.187 +1 -8 xml-axis/java/src/org/apache/axis/client/Call.java Index: Call.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/client/Call.java,v retrieving revision 1.186 retrieving revision 1.187 diff -u -r1.186 -r1.187 --- Call.java 14 Oct 2002 16:51:03 -0000 1.186 +++ Call.java 17 Oct 2002 04:40:19 -0000 1.187 @@ -1792,14 +1792,7 @@ TypeMappingRegistry tmr = msgContext.getTypeMappingRegistry(); // If a TypeMapping is not available, add one. - TypeMapping tm = (TypeMapping) tmr.getTypeMapping(getEncodingStyle()); - TypeMapping defaultTM = (TypeMapping) tmr.getDefaultTypeMapping(); - if (tm == null || tm == defaultTM ) { - tm = (TypeMapping) tmr.createTypeMapping(); - tm.setSupportedEncodings(new String[] {getEncodingStyle()}); - tmr.register(getEncodingStyle(), tm); - } - return tm; + return tmr.getOrMakeTypeMapping(getEncodingStyle()); } /** 1.52 +1 -7 xml-axis/java/src/org/apache/axis/deployment/wsdd/WSDDDeployment.java Index: WSDDDeployment.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/deployment/wsdd/WSDDDeployment.java,v retrieving revision 1.51 retrieving revision 1.52 diff -u -r1.51 -r1.52 --- WSDDDeployment.java 30 Sep 2002 21:38:49 -0000 1.51 +++ WSDDDeployment.java 17 Oct 2002 04:40:19 -0000 1.52 @@ -323,13 +323,7 @@ if (encodingStyle == null) { encodingStyle = Constants.URI_DEFAULT_SOAP_ENC; } - TypeMapping tm = (TypeMapping) tmr.getTypeMapping(encodingStyle); - TypeMapping df = (TypeMapping) tmr.getDefaultTypeMapping(); - if (tm == null || tm == df) { - tm = (TypeMapping) tmr.createTypeMapping(); - tm.setSupportedEncodings(new String[] {encodingStyle}); - tmr.register(encodingStyle, tm); - } + TypeMapping tm = tmr.getOrMakeTypeMapping(encodingStyle); SerializerFactory ser = null; DeserializerFactory deser = null; 1.97 +1 -7 xml-axis/java/src/org/apache/axis/deployment/wsdd/WSDDService.java Index: WSDDService.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/deployment/wsdd/WSDDService.java,v retrieving revision 1.96 retrieving revision 1.97 diff -u -r1.96 -r1.97 --- WSDDService.java 9 Oct 2002 19:06:29 -0000 1.96 +++ WSDDService.java 17 Oct 2002 04:40:19 -0000 1.97 @@ -529,13 +529,7 @@ if (encodingStyle == null) { encodingStyle = use.getEncoding(); } - TypeMapping tm = (TypeMapping) tmr.getTypeMapping(encodingStyle); - TypeMapping df = (TypeMapping) tmr.getDefaultTypeMapping(); - if (tm == null || tm == df) { - tm = (TypeMapping) tmr.createTypeMapping(); - tm.setSupportedEncodings(new String[] {encodingStyle}); - tmr.register(encodingStyle, tm); - } + TypeMapping tm = tmr.getOrMakeTypeMapping(encodingStyle); desc.setTypeMappingRegistry(tmr); desc.setTypeMapping(tm); 1.51 +10 -0 xml-axis/java/src/org/apache/axis/encoding/TypeMappingRegistry.java Index: TypeMappingRegistry.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/TypeMappingRegistry.java,v retrieving revision 1.50 retrieving revision 1.51 diff -u -r1.50 -r1.51 --- TypeMappingRegistry.java 1 Feb 2002 22:08:26 -0000 1.50 +++ TypeMappingRegistry.java 17 Oct 2002 04:40:19 -0000 1.51 @@ -68,6 +68,16 @@ * their corresponding types in the secondary TMR. */ public void delegate(TypeMappingRegistry secondaryTMR); + + /** + * Obtain a type mapping for the given namespaceURI. If no specific + * mapping exists for this namespaceURI, we will create and register + * one before returning it. + * + * @param namespaceURI + * @return a registered TypeMapping for the given namespaceURI + */ + public TypeMapping getOrMakeTypeMapping(String namespaceURI); } 1.18 +22 -0 xml-axis/java/src/org/apache/axis/encoding/TypeMappingRegistryImpl.java Index: TypeMappingRegistryImpl.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/TypeMappingRegistryImpl.java,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- TypeMappingRegistryImpl.java 30 Sep 2002 03:36:06 -0000 1.17 +++ TypeMappingRegistryImpl.java 17 Oct 2002 04:40:19 -0000 1.18 @@ -313,6 +313,28 @@ } return tm; } + + /** + * Obtain a type mapping for the given namespaceURI. If no specific + * mapping exists for this namespaceURI, we will create and register + * one before returning it. + * + * @param namespaceURI + * @return a registered TypeMapping for the given namespaceURI + */ + public TypeMapping getOrMakeTypeMapping(String namespaceURI) { + TypeMapping del = (TypeMapping) mapTM.get(namespaceURI); + TypeMapping tm = null; + if (del != null) { + tm = del.getDelegate(); + } + if (tm == null) { + tm = (TypeMapping)createTypeMapping(); + tm.setSupportedEncodings(new String[] {namespaceURI}); + register(namespaceURI, tm); + } + return tm; + } /** * Unregisters the TypeMapping for the namespace. 1.37 +4 -7 xml-axis/java/test/RPCDispatch/TestSerializedRPC.java Index: TestSerializedRPC.java =================================================================== RCS file: /home/cvs/xml-axis/java/test/RPCDispatch/TestSerializedRPC.java,v retrieving revision 1.36 retrieving revision 1.37 diff -u -r1.36 -r1.37 --- TestSerializedRPC.java 9 Sep 2002 14:50:35 -0000 1.36 +++ TestSerializedRPC.java 17 Oct 2002 04:40:19 -0000 1.37 @@ -68,11 +68,8 @@ BeanDeserializerFactory df = new BeanDeserializerFactory(javaType, xmlType); TypeMappingRegistry tmr = engine.getTypeMappingRegistry(); - TypeMapping tm = (TypeMapping) tmr.getTypeMapping(Constants.URI_DEFAULT_SOAP_ENC); - if (tm == null || tm == tmr.getDefaultTypeMapping()) { - tm = (TypeMapping) tmr.createTypeMapping(); - tmr.register(Constants.URI_DEFAULT_SOAP_ENC, tm); - } + TypeMapping tm = + tmr.getOrMakeTypeMapping(Constants.URI_DEFAULT_SOAP_ENC); tm.register(javaType, xmlType, sf, df); ServiceDesc desc = new ServiceDesc(); @@ -92,8 +89,8 @@ /** * Invoke a given RPC method, and return the result - * @param soapAction action to be performed - * @param request XML body of the request + * @param method action to be performed + * @param bodyStr XML body of the request * @return Deserialized result */ private final Object rpc(String method, String bodyStr,