dims 2002/06/14 06:27:18 Modified: java/samples/jaxrpc GetInfo.java java/src/org/apache/axis/client Call.java java/src/org/apache/axis/wsdl/toJava JavaStubWriter.java java/test/properties TestScopedProperties.java Log: TCK is VERY FINICKY about setProperty/getProperty/removeProperty works... Revision Changes Path 1.3 +4 -2 xml-axis/java/samples/jaxrpc/GetInfo.java Index: GetInfo.java =================================================================== RCS file: /home/cvs/xml-axis/java/samples/jaxrpc/GetInfo.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- GetInfo.java 11 Jun 2002 14:53:49 -0000 1.2 +++ GetInfo.java 14 Jun 2002 13:27:17 -0000 1.3 @@ -93,8 +93,10 @@ call.addParameter("symbol", XMLType.XSD_STRING, ParameterMode.IN); call.addParameter("info", XMLType.XSD_STRING, ParameterMode.IN); call.setReturnType(XMLType.XSD_STRING); - call.setProperty(Call.USERNAME_PROPERTY, opts.getUser()); - call.setProperty(Call.PASSWORD_PROPERTY, opts.getPassword()); + if(opts.getUser()!=null) + call.setProperty(Call.USERNAME_PROPERTY, opts.getUser()); + if(opts.getPassword()!=null) + call.setProperty(Call.PASSWORD_PROPERTY, opts.getPassword()); String res = (String) call.invoke(new Object[] {args[0], args[1]}); 1.136 +54 -60 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.135 retrieving revision 1.136 diff -u -r1.135 -r1.136 --- Call.java 13 Jun 2002 19:23:15 -0000 1.135 +++ Call.java 14 Jun 2002 13:27:17 -0000 1.136 @@ -153,7 +153,8 @@ // Collection of properties to store and put in MessageContext at // invoke() time. Known ones are stored in actual variables for // efficiency/type-consistency. Unknown ones are in myProperties. - private Hashtable myProperties = new Hashtable(); + private Hashtable callProperties = new Hashtable(); + private Hashtable scopedProperties= new Hashtable(); private String username = null; private String password = null; private boolean maintainSession = false; @@ -255,8 +256,7 @@ */ public void setProperty(String name, Object value) { if (name == null || value == null) { - return; - // Is this right? Shouldn't we throw an exception like: throw new IllegalArgumentException(); + throw new IllegalArgumentException(); } else if (name.equals(USERNAME_PROPERTY)) { if (!(value instanceof String)) { @@ -343,8 +343,9 @@ transport.setTransportName((String) value); } else { - myProperties.put(name, value); + throw new IllegalArgumentException(); } + callProperties.put(name, value); } // setProperty /** @@ -354,60 +355,63 @@ * @return Object value of the property - or null */ public Object getProperty(String name) { - if (name != null) { - if (name.equals(USERNAME_PROPERTY)) { - return getUsername(); - } - else if (name.equals(PASSWORD_PROPERTY)) { - return getPassword(); - } - else if (name.equals(SESSION_MAINTAIN_PROPERTY)) { - return new Boolean(getMaintainSession()); - } - else if (name.equals(OPERATION_STYLE_PROPERTY)) { - return getOperationStyle().getName(); - } - else if (name.equals(SOAPACTION_USE_PROPERTY)) { - return new Boolean(useSOAPAction()); - } - else if (name.equals(SOAPACTION_URI_PROPERTY)) { - return getSOAPActionURI(); - } - else if (name.equals(ENCODINGSTYLE_URI_PROPERTY)) { - return getEncodingStyle(); - } - else if (name.equals(TRANSPORT_NAME)) { - return transportName; - } - else { - return myProperties.get(name); - } + if (name != null) + return callProperties.get(name); + return null; + } // getProperty + + /** + * Removes (if set) the named property. + * + * @param name name of the property to remove + */ + public void removeProperty(String name) { + if ( name == null || callProperties == null ) return ; + callProperties.remove( name ); + } // removeProperty + + public void setScopedProperty(String name, Object value) { + if (name == null || value == null) { + throw new IllegalArgumentException(); } - else { - return null; + scopedProperties.put(name, value); + } // setScopedProperty + + public Object getScopedProperty(String name) { + if (name != null) { + return scopedProperties.get(name); } - } + return null; + } // getScopedProperty + + public void removeScopedProperty(String name) { + if ( name == null || scopedProperties == null ) return ; + scopedProperties.remove( name ); + } // removeScopedProperty /** * Configurable properties supported by this Call object. */ - private static ArrayList propertyNames = null; + private static ArrayList propertyNames = new ArrayList(); + static { + propertyNames.add(USERNAME_PROPERTY); + propertyNames.add(PASSWORD_PROPERTY); + propertyNames.add(SESSION_MAINTAIN_PROPERTY); + propertyNames.add(OPERATION_STYLE_PROPERTY); + propertyNames.add(SOAPACTION_USE_PROPERTY); + propertyNames.add(SOAPACTION_URI_PROPERTY); + propertyNames.add(ENCODINGSTYLE_URI_PROPERTY); + propertyNames.add(TRANSPORT_NAME); + } public Iterator getPropertyNames() { - if (propertyNames == null) { - propertyNames = new ArrayList(); - propertyNames.add(USERNAME_PROPERTY); - propertyNames.add(PASSWORD_PROPERTY); - propertyNames.add(SESSION_MAINTAIN_PROPERTY); - propertyNames.add(OPERATION_STYLE_PROPERTY); - propertyNames.add(SOAPACTION_USE_PROPERTY); - propertyNames.add(SOAPACTION_URI_PROPERTY); - propertyNames.add(ENCODINGSTYLE_URI_PROPERTY); - propertyNames.add(TRANSPORT_NAME); - } return propertyNames.iterator(); } + public boolean isPropertySupported(String name) { + return propertyNames.contains(name); + } + /** * Set the username. */ @@ -530,16 +534,6 @@ return encodingStyle; } - /** - * Removes (if set) the named property. - * - * @param name name of the property to remove - */ - public void removeProperty(String name) { - if ( name == null || myProperties == null ) return ; - myProperties.remove( name ); - } - /** * Sets the endpoint address of the target service port. This address must * correspond to the transport specified in the binding for this Call @@ -1898,9 +1892,9 @@ SOAPService svc = msgContext.getService(); if (svc != null) { - svc.setPropertyParent(myProperties); + svc.setPropertyParent(scopedProperties); } else { - msgContext.setPropertyParent(myProperties); + msgContext.setPropertyParent(scopedProperties); } } @@ -2016,7 +2010,7 @@ // Set the service so that it defers missing property gets to the // Call. So when client-side Handlers get at the MessageContext, // the property scoping will be MC -> SOAPService -> Call - service.setPropertyParent(myProperties); + service.setPropertyParent(scopedProperties); } } 1.71 +6 -3 xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaStubWriter.java Index: JavaStubWriter.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaStubWriter.java,v retrieving revision 1.70 retrieving revision 1.71 diff -u -r1.70 -r1.71 --- JavaStubWriter.java 11 Jun 2002 14:54:01 -0000 1.70 +++ JavaStubWriter.java 14 Jun 2002 13:27:17 -0000 1.71 @@ -200,7 +200,10 @@ pw.println(" java.util.Enumeration keys = super.cachedProperties.keys();"); pw.println(" while (keys.hasMoreElements()) {"); pw.println(" String key = (String) keys.nextElement();"); - pw.println(" call.setProperty(key, super.cachedProperties.get(key));"); + pw.println(" if(call.isPropertySupported(key))"); + pw.println(" call.setProperty(key, super.cachedProperties.get(key));"); + pw.println(" else"); + pw.println(" call.setScopedProperty(key, super.cachedProperties.get(key));"); pw.println(" }"); if (types.size() > 0) { pw.println(" // " + JavaUtils.getMessage("typeMap00")); @@ -542,9 +545,9 @@ // Turn off encoding pw.println(" call.setEncodingStyle(null);"); // turn off multirefs - pw.println(" call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE);"); + pw.println(" call.setScopedProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE);"); // turn off XSI types - pw.println(" call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE);"); + pw.println(" call.setScopedProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE);"); } // Style: document, RPC, or wrapped 1.2 +2 -2 xml-axis/java/test/properties/TestScopedProperties.java Index: TestScopedProperties.java =================================================================== RCS file: /home/cvs/xml-axis/java/test/properties/TestScopedProperties.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- TestScopedProperties.java 18 Mar 2002 04:03:36 -0000 1.1 +++ TestScopedProperties.java 14 Jun 2002 13:27:18 -0000 1.2 @@ -143,7 +143,7 @@ // Set a property on the Call which we expect to be available via // the MessageContext in the client-side handler. - call.setProperty(PROP_NAME, CLIENT_VALUE); + call.setScopedProperty(PROP_NAME, CLIENT_VALUE); LocalTransport transport = new LocalTransport(server); transport.setRemoteService("service"); @@ -209,7 +209,7 @@ // Set a property on the Call which we expect to be available via // the MessageContext in the client-side handler. - call.setProperty(PROP_NAME, CLIENT_VALUE); + call.setScopedProperty(PROP_NAME, CLIENT_VALUE); LocalTransport transport = new LocalTransport(server); transport.setRemoteService("service");