Author: sanka Date: Mon Jun 9 06:02:29 2008 New Revision: 18229 URL: http://wso2.org/svn/browse/wso2?view=rev&revision=18229
Log: Modified: branches/wsas/java/2.3/axis2-1.4-patched/modules/kernel/src/org/apache/axis2/deployment/util/Utils.java branches/wsas/java/2.3/axis2-1.4-patched/modules/kernel/src/org/apache/axis2/description/AxisMessage.java branches/wsas/java/2.3/axis2-1.4-patched/modules/kernel/src/org/apache/axis2/description/AxisService.java branches/wsas/java/2.3/axis2-1.4-patched/modules/kernel/src/org/apache/axis2/description/PolicySubject.java branches/wsas/java/2.3/axis2-1.4-patched/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java Modified: branches/wsas/java/2.3/axis2-1.4-patched/modules/kernel/src/org/apache/axis2/deployment/util/Utils.java URL: http://wso2.org/svn/browse/wso2/branches/wsas/java/2.3/axis2-1.4-patched/modules/kernel/src/org/apache/axis2/deployment/util/Utils.java?rev=18229&r1=18228&r2=18229&view=diff ============================================================================== --- branches/wsas/java/2.3/axis2-1.4-patched/modules/kernel/src/org/apache/axis2/deployment/util/Utils.java (original) +++ branches/wsas/java/2.3/axis2-1.4-patched/modules/kernel/src/org/apache/axis2/deployment/util/Utils.java Mon Jun 9 06:02:29 2008 @@ -1563,4 +1563,99 @@ } } } + + public static boolean isSoap11Binding(AxisBinding binding) { + String type = binding.getType(); + if (Java2WSDLConstants.TRANSPORT_URI.equals(type) + || WSDL2Constants.URI_WSDL2_SOAP.equals(type)) { + String v = (String) binding + .getProperty(WSDL2Constants.ATTR_WSOAP_VERSION); + if (SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(v)) { + return true; + } + } + return false; + } + + public static boolean isSoap12Binding(AxisBinding binding) { + String type = binding.getType(); + if (Java2WSDLConstants.TRANSPORT_URI.equals(type) + || WSDL2Constants.URI_WSDL2_SOAP.equals(type)) { + String v = (String) binding + .getProperty(WSDL2Constants.ATTR_WSOAP_VERSION); + if (SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(v)) { + return true; + } + } + return false; + } + + public static boolean isHttpBinding(AxisBinding binding) { + String type = binding.getType(); + if (WSDL2Constants.URI_WSDL2_HTTP.equals(type)) { + return true; + } + return false; + } + + public static AxisBinding getSoap11Binding(AxisService service) { + for (Iterator iterator = service.getEndpoints().values().iterator(); iterator + .hasNext();) { + AxisEndpoint endpoint = (AxisEndpoint) iterator.next(); + AxisBinding binding = endpoint.getBinding(); + + if (isSoap11Binding(binding)) { + return binding; + } + } + return null; + } + + public static AxisBinding getSoap12Binding(AxisService service) { + for (Iterator iterator = service.getEndpoints().values().iterator(); iterator + .hasNext();) { + AxisEndpoint endpoint = (AxisEndpoint) iterator.next(); + AxisBinding binding = endpoint.getBinding(); + + if (isSoap12Binding(binding)) { + return binding; + } + } + return null; + } + + public static AxisBinding getHttpBinding(AxisService service) { + for (Iterator iterator = service.getEndpoints().values().iterator(); iterator + .hasNext();) { + AxisEndpoint endpoint = (AxisEndpoint) iterator.next(); + AxisBinding binding = endpoint.getBinding(); + + if (isHttpBinding(binding)) { + return binding; + } + } + return null; + } + + public static AxisBindingOperation getBindingOperation(AxisBinding binding, AxisOperation operation) { + QName opName = operation.getName(); + for (Iterator bindingOps = binding.getChildren(); bindingOps.hasNext();) { + AxisBindingOperation bindingOp = (AxisBindingOperation) bindingOps.next(); + if (opName.equals(bindingOp.getName())) { + return bindingOp; + } + } + return null; + } + + public static AxisBindingMessage getBindingMessage(AxisBindingOperation bindingOperation, AxisMessage message) { + String msgName = message.getName(); + for (Iterator bindingMessages = bindingOperation.getChildren(); bindingMessages.hasNext();) { + AxisBindingMessage bindingMessage = (AxisBindingMessage) bindingMessages.next(); + if (msgName.equals(bindingMessage.getName())) { + return bindingMessage; + } + } + return null; + } } Modified: branches/wsas/java/2.3/axis2-1.4-patched/modules/kernel/src/org/apache/axis2/description/AxisMessage.java URL: http://wso2.org/svn/browse/wso2/branches/wsas/java/2.3/axis2-1.4-patched/modules/kernel/src/org/apache/axis2/description/AxisMessage.java?rev=18229&r1=18228&r2=18229&view=diff ============================================================================== --- branches/wsas/java/2.3/axis2-1.4-patched/modules/kernel/src/org/apache/axis2/description/AxisMessage.java (original) +++ branches/wsas/java/2.3/axis2-1.4-patched/modules/kernel/src/org/apache/axis2/description/AxisMessage.java Mon Jun 9 06:02:29 2008 @@ -34,40 +34,39 @@ import javax.xml.namespace.QName; import java.util.ArrayList; +import java.util.Date; import java.util.Iterator; import java.util.List; - /** - * This class represents the messages in WSDL. There can be message element in services.xml - * which are represented by this class. + * This class represents the messages in WSDL. There can be message element in + * services.xml which are represented by this class. */ public class AxisMessage extends AxisDescription { - private ArrayList handlerChain; - private String name; - private ArrayList soapHeaders; - - //to keep data in WSDL message reference and to keep the Java2WSDL data - // such as SchemaElementName , direction etc. - private QName elementQname; - private String direction; - private String messagePartName; - - // To store deploy-time module refs - private ArrayList modulerefs; - private String partName = Java2WSDLConstants.PARAMETERS; - - // private PolicyInclude policyInclude; - - //To chcek whether the message is wrapped or unwrapped - private boolean wrapped = true; - - private Policy effectivePolicy = null; - - private boolean policyCalculated = false; + private ArrayList handlerChain; + private String name; + private ArrayList soapHeaders; + + // to keep data in WSDL message reference and to keep the Java2WSDL data + // such as SchemaElementName , direction etc. + private QName elementQname; + private String direction; + private String messagePartName; + + // To store deploy-time module refs + private ArrayList modulerefs; + private String partName = Java2WSDLConstants.PARAMETERS; + + // private PolicyInclude policyInclude; + + // To chcek whether the message is wrapped or unwrapped + private boolean wrapped = true; - public String getMessagePartName() { + private Policy effectivePolicy = null; + private Date lastPolicyCalcuatedTime = null; + + public String getMessagePartName() { return messagePartName; } @@ -76,177 +75,176 @@ } public AxisMessage() { - soapHeaders = new ArrayList(); - handlerChain = new ArrayList(); - modulerefs = new ArrayList(); - } - - public ArrayList getMessageFlow() { - return handlerChain; - } - - public boolean isParameterLocked(String parameterName) { - - // checking the locked value of parent - boolean locked = false; - - if (getParent() != null) { - locked = getParent().isParameterLocked(parameterName); - } - - if (locked) { - return true; - } else { - Parameter parameter = getParameter(parameterName); - - return (parameter != null) && parameter.isLocked(); - } - } - - public void setMessageFlow(ArrayList operationFlow) { - this.handlerChain = operationFlow; - } - - public String getDirection() { - return direction; - } - - public void setDirection(String direction) { - this.direction = direction; - } - - public QName getElementQName() { - return this.elementQname; - } - - public void setElementQName(QName element) { - this.elementQname = element; - } - - public Object getKey() { - return this.elementQname; - } - - public XmlSchemaElement getSchemaElement() { - XmlSchemaElement xmlSchemaElement = null; - AxisService service = getAxisOperation().getAxisService(); - ArrayList schemas = service.getSchema(); - for (Iterator schemaIter = schemas.iterator(); schemaIter.hasNext();){ - xmlSchemaElement = getSchemaElement((XmlSchema) schemaIter.next()); - if (xmlSchemaElement != null){ - break; - } - } - return xmlSchemaElement; - } - - private XmlSchemaElement getSchemaElement(XmlSchema schema) { - XmlSchemaElement xmlSchemaElement = null; - if (schema != null) { - xmlSchemaElement = schema.getElementByName(this.elementQname); - if (xmlSchemaElement == null) { - // try to find in an import or an include - XmlSchemaObjectCollection includes = schema.getIncludes(); - if (includes != null) { - Iterator includesIter = includes.getIterator(); - Object object; - while (includesIter.hasNext()) { - object = includesIter.next(); - if (object instanceof XmlSchemaImport) { - XmlSchema schema1 = ((XmlSchemaImport) object).getSchema(); - xmlSchemaElement = getSchemaElement(schema1); - } - if (object instanceof XmlSchemaInclude) { - XmlSchema schema1 = ((XmlSchemaInclude) object).getSchema(); - xmlSchemaElement = getSchemaElement(schema1); - } - if (xmlSchemaElement != null){ - break; - } - } - } - } - } - return xmlSchemaElement; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - /** - * This will return a list of WSDLExtensibilityAttribute - */ - public List getExtensibilityAttributes() { - // TODO : Deepal implement this properly. - - // the list should contain list of WSDLExtensibilityAttribute - return new ArrayList(0); - } - - public void addSoapHeader(SOAPHeaderMessage soapHeaderMessage) { - soapHeaders.add(soapHeaderMessage); - } - - public ArrayList getSoapHeaders - () { - return soapHeaders; - } - - /** - * We do not support adding module operations when engaging a module to an AxisMessage - * - * @param axisModule AxisModule to engage - * @param engager - * @throws AxisFault something went wrong - */ - public void onEngage(AxisModule axisModule, AxisDescription engager) throws AxisFault { - PhaseResolver phaseResolver = new PhaseResolver(getAxisConfiguration()); - phaseResolver.engageModuleToMessage(this, axisModule); - } - - public ArrayList getModulerefs() { - return modulerefs; - } - - public void addModuleRefs(String moduleName) { - modulerefs.add(moduleName); - } - - public AxisOperation getAxisOperation(){ - return (AxisOperation)parent; - } - - - public String getPartName() { - return partName; - } - - public void setPartName(String partName) { - this.partName = partName; - } - - - public boolean isWrapped() { - return wrapped; - } - - public void setWrapped(boolean wrapped) { - this.wrapped = wrapped; - } - - public Policy getEffectivePolicy() { - if (getPolicySubject().isUpdated()) { - effectivePolicy = calculateEffectivePolicy(); + soapHeaders = new ArrayList(); + handlerChain = new ArrayList(); + modulerefs = new ArrayList(); + } + + public ArrayList getMessageFlow() { + return handlerChain; + } + + public boolean isParameterLocked(String parameterName) { + + // checking the locked value of parent + boolean locked = false; + + if (getParent() != null) { + locked = getParent().isParameterLocked(parameterName); + } + + if (locked) { + return true; } else { - if (effectivePolicy == null && !policyCalculated) { - effectivePolicy = calculateEffectivePolicy(); + Parameter parameter = getParameter(parameterName); + + return (parameter != null) && parameter.isLocked(); + } + } + + public void setMessageFlow(ArrayList operationFlow) { + this.handlerChain = operationFlow; + } + + public String getDirection() { + return direction; + } + + public void setDirection(String direction) { + this.direction = direction; + } + + public QName getElementQName() { + return this.elementQname; + } + + public void setElementQName(QName element) { + this.elementQname = element; + } + + public Object getKey() { + return this.elementQname; + } + + public XmlSchemaElement getSchemaElement() { + XmlSchemaElement xmlSchemaElement = null; + AxisService service = getAxisOperation().getAxisService(); + ArrayList schemas = service.getSchema(); + for (Iterator schemaIter = schemas.iterator(); schemaIter.hasNext();) { + xmlSchemaElement = getSchemaElement((XmlSchema) schemaIter.next()); + if (xmlSchemaElement != null) { + break; + } + } + return xmlSchemaElement; + } + + private XmlSchemaElement getSchemaElement(XmlSchema schema) { + XmlSchemaElement xmlSchemaElement = null; + if (schema != null) { + xmlSchemaElement = schema.getElementByName(this.elementQname); + if (xmlSchemaElement == null) { + // try to find in an import or an include + XmlSchemaObjectCollection includes = schema.getIncludes(); + if (includes != null) { + Iterator includesIter = includes.getIterator(); + Object object; + while (includesIter.hasNext()) { + object = includesIter.next(); + if (object instanceof XmlSchemaImport) { + XmlSchema schema1 = ((XmlSchemaImport) object) + .getSchema(); + xmlSchemaElement = getSchemaElement(schema1); + } + if (object instanceof XmlSchemaInclude) { + XmlSchema schema1 = ((XmlSchemaInclude) object) + .getSchema(); + xmlSchemaElement = getSchemaElement(schema1); + } + if (xmlSchemaElement != null) { + break; + } + } + } } } + return xmlSchemaElement; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + /** + * This will return a list of WSDLExtensibilityAttribute + */ + public List getExtensibilityAttributes() { + // TODO : Deepal implement this properly. + + // the list should contain list of WSDLExtensibilityAttribute + return new ArrayList(0); + } + + public void addSoapHeader(SOAPHeaderMessage soapHeaderMessage) { + soapHeaders.add(soapHeaderMessage); + } + + public ArrayList getSoapHeaders() { + return soapHeaders; + } + + /** + * We do not support adding module operations when engaging a module to an + * AxisMessage + * + * @param axisModule + * AxisModule to engage + * @param engager + * @throws AxisFault + * something went wrong + */ + public void onEngage(AxisModule axisModule, AxisDescription engager) + throws AxisFault { + PhaseResolver phaseResolver = new PhaseResolver(getAxisConfiguration()); + phaseResolver.engageModuleToMessage(this, axisModule); + } + + public ArrayList getModulerefs() { + return modulerefs; + } + + public void addModuleRefs(String moduleName) { + modulerefs.add(moduleName); + } + + public AxisOperation getAxisOperation() { + return (AxisOperation) parent; + } + + public String getPartName() { + return partName; + } + + public void setPartName(String partName) { + this.partName = partName; + } + + public boolean isWrapped() { + return wrapped; + } + + public void setWrapped(boolean wrapped) { + this.wrapped = wrapped; + } + + public Policy getEffectivePolicy() { + if (lastPolicyCalcuatedTime == null || isPolicyUpdated()) { + effectivePolicy = calculateEffectivePolicy(); + } return effectivePolicy; } @@ -282,36 +280,37 @@ } Policy result = PolicyUtil.getMergedPolicy(policyList, axisService); - policyCalculated = true; + lastPolicyCalcuatedTime = new Date(); return result; } - + public boolean isPolicyUpdated() { // AxisMessage - PolicySubject policySubject = getPolicySubject(); - if (policySubject.isUpdated()) { + if (getPolicySubject().getLastUpdatedTime().after( + lastPolicyCalcuatedTime)) { return true; } - // AxisOperation - AxisOperation axisOperation = getAxisOperation(); + AxisOperation axisOperation = (AxisOperation) parent; if (axisOperation != null - && axisOperation.getPolicySubject().isUpdated()) { + && axisOperation.getPolicySubject().getLastUpdatedTime().after( + lastPolicyCalcuatedTime)) { return true; } - // AxisService AxisService axisService = (axisOperation == null) ? null : axisOperation.getAxisService(); - if (axisService != null && axisService.getPolicySubject().isUpdated()) { + if (axisService != null + && axisService.getPolicySubject().getLastUpdatedTime().after( + lastPolicyCalcuatedTime)) { return true; } - // AxisConfiguration AxisConfiguration axisConfiguration = (axisService == null) ? null : axisService.getAxisConfiguration(); if (axisConfiguration != null - && axisConfiguration.getPolicySubject().isUpdated()) { + && axisConfiguration.getPolicySubject().getLastUpdatedTime() + .after(lastPolicyCalcuatedTime)) { return true; } return false; Modified: branches/wsas/java/2.3/axis2-1.4-patched/modules/kernel/src/org/apache/axis2/description/AxisService.java URL: http://wso2.org/svn/browse/wso2/branches/wsas/java/2.3/axis2-1.4-patched/modules/kernel/src/org/apache/axis2/description/AxisService.java?rev=18229&r1=18228&r2=18229&view=diff ============================================================================== --- branches/wsas/java/2.3/axis2-1.4-patched/modules/kernel/src/org/apache/axis2/description/AxisService.java (original) +++ branches/wsas/java/2.3/axis2-1.4-patched/modules/kernel/src/org/apache/axis2/description/AxisService.java Mon Jun 9 06:02:29 2008 @@ -1359,14 +1359,95 @@ for (int i = 0; i < list.size(); i++) { Object extensibilityEle = list.get(i); if (extensibilityEle instanceof SOAPAddress) { - ((SOAPAddress) extensibilityEle) - .setLocationURI(endpoint.calculateEndpointURL()); + SOAPAddress soapAddress = (SOAPAddress) extensibilityEle; + String existingAddress = soapAddress.getLocationURI(); + if (existingAddress == null + || existingAddress + .equals("REPLACE_WITH_ACTUAL_URL")) { + if (endpoint != null) { + ((SOAPAddress) extensibilityEle) + .setLocationURI(endpoint + .calculateEndpointURL()); + } else { + ((SOAPAddress) extensibilityEle) + .setLocationURI(getEPRs()[0]); + } + } else { + if (requestIP == null) { + if (endpoint != null) { + ((SOAPAddress) extensibilityEle) + .setLocationURI(endpoint + .calculateEndpointURL()); + } else { + ((SOAPAddress) extensibilityEle) + .setLocationURI(getLocationURI( + getEPRs(), existingAddress)); + } + } else { + if (endpoint != null) { + ((SOAPAddress) extensibilityEle) + .setLocationURI(endpoint + .calculateEndpointURL()); + } else { + ((SOAPAddress) extensibilityEle) + .setLocationURI(getLocationURI( + calculateEPRs(requestIP), + existingAddress)); + } + } + } } else if (extensibilityEle instanceof SOAP12Address) { - ((SOAP12Address) extensibilityEle) - .setLocationURI(endpoint.calculateEndpointURL()); + SOAP12Address soapAddress = (SOAP12Address) extensibilityEle; + String exsistingAddress = soapAddress.getLocationURI(); + if (requestIP == null) { + if (endpoint != null) { + ((SOAP12Address) extensibilityEle) + .setLocationURI(endpoint + .calculateEndpointURL()); + + } else { + ((SOAP12Address) extensibilityEle) + .setLocationURI(getLocationURI( + getEPRs(), exsistingAddress)); + } + } else { + if (endpoint != null) { + ((SOAP12Address) extensibilityEle) + .setLocationURI(endpoint + .calculateEndpointURL()); + } else { + ((SOAP12Address) extensibilityEle) + .setLocationURI(getLocationURI( + calculateEPRs(requestIP), + exsistingAddress)); + + } + } } else if (extensibilityEle instanceof HTTPAddress) { - ((HTTPAddress) extensibilityEle) - .setLocationURI(endpoint.calculateEndpointURL()); + HTTPAddress httpAddress = (HTTPAddress) extensibilityEle; + String exsistingAddress = httpAddress.getLocationURI(); + if (requestIP == null) { + if (endpoint != null) { + ((HTTPAddress) extensibilityEle) + .setLocationURI(endpoint + .calculateEndpointURL()); + } else { + ((HTTPAddress) extensibilityEle) + .setLocationURI(getLocationURI( + getEPRs(), exsistingAddress)); + } + } else { + if (endpoint != null) { + ((HTTPAddress) extensibilityEle) + .setLocationURI(endpoint + .calculateEndpointURL()); + } else { + ((HTTPAddress) extensibilityEle) + .setLocationURI(getLocationURI( + calculateEPRs(requestIP), + exsistingAddress)); + } + } } // TODO : change the Endpoint refrence addess as well. } Modified: branches/wsas/java/2.3/axis2-1.4-patched/modules/kernel/src/org/apache/axis2/description/PolicySubject.java URL: http://wso2.org/svn/browse/wso2/branches/wsas/java/2.3/axis2-1.4-patched/modules/kernel/src/org/apache/axis2/description/PolicySubject.java?rev=18229&r1=18228&r2=18229&view=diff ============================================================================== --- branches/wsas/java/2.3/axis2-1.4-patched/modules/kernel/src/org/apache/axis2/description/PolicySubject.java (original) +++ branches/wsas/java/2.3/axis2-1.4-patched/modules/kernel/src/org/apache/axis2/description/PolicySubject.java Mon Jun 9 06:02:29 2008 @@ -51,6 +51,7 @@ public void attachPolicyReference(PolicyReference reference) { attachedPolicyComponents.put(reference.getURI(), reference); + setLastUpdatedTime(new Date()); } public void attachPolicyComponents(List policyComponents) { @@ -75,7 +76,7 @@ public void attachPolicyComponent(String key, PolicyComponent policyComponent) { attachedPolicyComponents.put(key, policyComponent); - lastUpdatedTime = new Date(); + setLastUpdatedTime(new Date()); if (!isUpdated()) { setUpdated(true); Modified: branches/wsas/java/2.3/axis2-1.4-patched/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java URL: http://wso2.org/svn/browse/wso2/branches/wsas/java/2.3/axis2-1.4-patched/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java?rev=18229&r1=18228&r2=18229&view=diff ============================================================================== --- branches/wsas/java/2.3/axis2-1.4-patched/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java (original) +++ branches/wsas/java/2.3/axis2-1.4-patched/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java Mon Jun 9 06:02:29 2008 @@ -473,6 +473,7 @@ for (Iterator iterator = wsdl4jPorts.values().iterator(); iterator.hasNext();) { port = (Port) iterator.next(); + System.err.println("Populating port : " + port.getName()); // if the user has picked a port then we have to process only that port if ((this.portName == null) || (this.portName.equals(port.getName()))) { // we process the port only if it has the same port type as the selected binding _______________________________________________ Wsas-java-dev mailing list [email protected] http://wso2.org/cgi-bin/mailman/listinfo/wsas-java-dev
