You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@synapse.apache.org by ru...@apache.org on 2008/06/22 10:17:38 UTC
svn commit: r670319 - in
/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/endpoints/utils:
LoadbalanceAlgorithmFactory.java WSDL11EndpointBuilder.java
WSDL20EndpointBuilder.java
Author: ruwan
Date: Sun Jun 22 01:17:38 2008
New Revision: 670319
URL: http://svn.apache.org/viewvc?rev=670319&view=rev
Log:
Reformatting Endpoint config util classes
Uncommented the WSDL2 endpoint definition creation since the axis2 trunk fully supports WSDL2
Modified:
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/endpoints/utils/LoadbalanceAlgorithmFactory.java
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/endpoints/utils/WSDL11EndpointBuilder.java
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/endpoints/utils/WSDL20EndpointBuilder.java
Modified: synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/endpoints/utils/LoadbalanceAlgorithmFactory.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/endpoints/utils/LoadbalanceAlgorithmFactory.java?rev=670319&r1=670318&r2=670319&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/endpoints/utils/LoadbalanceAlgorithmFactory.java (original)
+++ synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/endpoints/utils/LoadbalanceAlgorithmFactory.java Sun Jun 22 01:17:38 2008
@@ -34,12 +34,14 @@
*/
public class LoadbalanceAlgorithmFactory {
- public static LoadbalanceAlgorithm createLoadbalanceAlgorithm(OMElement loadbalanceElement, ArrayList endpoints) {
+ public static LoadbalanceAlgorithm createLoadbalanceAlgorithm(OMElement loadbalanceElement,
+ ArrayList endpoints) {
LoadbalanceAlgorithm algorithm = null;
String algorithmName = "roundRobin";
- OMAttribute algoAttribute = loadbalanceElement.getAttribute(new QName(null, XMLConfigConstants.ALGORITHM_NAME));
+ OMAttribute algoAttribute = loadbalanceElement.getAttribute(new QName(
+ null, XMLConfigConstants.ALGORITHM_NAME));
if(algoAttribute != null) {
algorithmName = algoAttribute.getAttributeValue();
}
Modified: synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/endpoints/utils/WSDL11EndpointBuilder.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/endpoints/utils/WSDL11EndpointBuilder.java?rev=670319&r1=670318&r2=670319&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/endpoints/utils/WSDL11EndpointBuilder.java (original)
+++ synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/endpoints/utils/WSDL11EndpointBuilder.java Sun Jun 22 01:17:38 2008
@@ -47,7 +47,6 @@
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.util.List;
/**
* Builds the EndpointDefinition containing the details for an epr using a WSDL 1.1 document.
@@ -67,8 +66,8 @@
*
* @return EndpointDefinition containing the information retrieved from the WSDL
*/
- public EndpointDefinition createEndpointDefinitionFromWSDL
- (String baseUri, OMElement wsdl, String service, String port) {
+ public EndpointDefinition createEndpointDefinitionFromWSDL(String baseUri, OMElement wsdl,
+ String service, String port) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
@@ -101,67 +100,40 @@
return null;
}
- /**
- * Creates an EndpointDefinition for WSDL endpoint from a WSDL document residing in the given URI.
- *
- * @param wsdlURI URI of the WSDL document
- * @param service Service of the endpoint
- * @param port Port of the endpoint
- *
- * @return EndpointDefinition containing the information retrieved from the WSDL
- */
- private EndpointDefinition createEndpointDefinitionFromWSDL
- (String wsdlURI, String service, String port) {
-
- try {
- WSDLFactory fac = WSDLFactory.newInstance();
- WSDLReader reader = fac.newWSDLReader();
- Definition definition = reader.readWSDL(wsdlURI);
-
- return createEndpointDefinitionFromWSDL(definition, service, port);
-
- } catch (WSDLException e) {
- handleException("Error retrieving the WSDL definition from the WSDL URI.");
- }
-
- return null;
- }
-
- private EndpointDefinition createEndpointDefinitionFromWSDL
- (Definition definition, String serviceName, String portName) {
+ private EndpointDefinition createEndpointDefinitionFromWSDL(Definition definition,
+ String serviceName, String portName) {
if (definition == null) {
- handleException("WSDL is not specified.");
+ handleException("WSDL document is not specified.");
}
if (serviceName == null) {
- handleException("Service of the WSDL document is not specified.");
+ handleException("Service name of the WSDL document is not specified.");
}
if (portName == null) {
- handleException("Port of the WSDL document is not specified.");
+ handleException("Port name of the WSDL document is not specified.");
}
String serviceURL = null;
// get soap version from wsdl port and update endpoint definition below
// so that correct soap version is used when endpoint is called
- String format = null;
+ String format = null;
+ assert definition != null;
String tns = definition.getTargetNamespace();
Service service = definition.getService(new QName(tns, serviceName));
if (service != null) {
Port port = service.getPort(portName);
if (port != null) {
- List ext = port.getExtensibilityElements();
- for (int i = 0; i < ext.size(); i++) {
- Object o = ext.get(i);
- if (o instanceof SOAPAddress) {
- SOAPAddress address = (SOAPAddress) o;
+ for (Object obj : port.getExtensibilityElements()) {
+ if (obj instanceof SOAPAddress) {
+ SOAPAddress address = (SOAPAddress) obj;
serviceURL = address.getLocationURI();
format = SynapseConstants.FORMAT_SOAP11;
break;
- } else if (o instanceof SOAP12Address) {
- SOAP12Address address = (SOAP12Address) o;
+ } else if (obj instanceof SOAP12Address) {
+ SOAP12Address address = (SOAP12Address) obj;
serviceURL = address.getLocationURI();
format = SynapseConstants.FORMAT_SOAP12;
break;
@@ -178,7 +150,7 @@
} else if (SynapseConstants.FORMAT_SOAP12.equals(format)) {
endpointDefinition.setForceSOAP12(true);
} else {
- handleException("format value -\"" + format + "\" not yet implemented");
+ handleException("format value '" + format + "' not yet implemented");
}
endpointDefinition.setFormat(format);
Modified: synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/endpoints/utils/WSDL20EndpointBuilder.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/endpoints/utils/WSDL20EndpointBuilder.java?rev=670319&r1=670318&r2=670319&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/endpoints/utils/WSDL20EndpointBuilder.java (original)
+++ synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/endpoints/utils/WSDL20EndpointBuilder.java Sun Jun 22 01:17:38 2008
@@ -19,21 +19,20 @@
package org.apache.synapse.config.xml.endpoints.utils;
-import org.apache.synapse.endpoints.utils.EndpointDefinition;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.synapse.SynapseException;
-import org.apache.axiom.om.OMElement;
+import org.apache.synapse.endpoints.utils.EndpointDefinition;
+import org.apache.woden.WSDLException;
import org.apache.woden.WSDLFactory;
import org.apache.woden.WSDLReader;
-import org.apache.woden.WSDLException;
import org.apache.woden.types.NCName;
-import org.apache.woden.wsdl20.xml.DescriptionElement;
import org.apache.woden.wsdl20.Description;
-import org.apache.woden.wsdl20.Service;
import org.apache.woden.wsdl20.Endpoint;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.apache.woden.wsdl20.Service;
import javax.xml.namespace.QName;
+import java.net.URI;
/**
* Currently this class is not used as Woden is dependent on Xerces, which is not included in the
@@ -44,19 +43,18 @@
*/
public class WSDL20EndpointBuilder {
-/* COMMENT DUE TO BUILD FAILURE - TO BE FIXED LATER WHEN WSDL 2.0 SUPPORT IS OFFICIALLY IN
private static Log log = LogFactory.getLog(WSDL20EndpointBuilder.class);
- public EndpointDefinition createEndpointDefinitionFromWSDL
- (String wsdlURI, String serviceName, String portName) {
+ public EndpointDefinition createEndpointDefinitionFromWSDL(String wsdlURI, String serviceName,
+ String portName) {
try {
WSDLFactory fac = WSDLFactory.newInstance();
WSDLReader reader = fac.newWSDLReader();
reader.setFeature(WSDLReader.FEATURE_VALIDATION, false);
- DescriptionElement descriptionElement = reader.readWSDL(wsdlURI);
- return createEndpointDefinitionFromWSDL(descriptionElement, serviceName, portName);
+ Description description = reader.readWSDL(wsdlURI);
+ return createEndpointDefinitionFromWSDL(description, serviceName, portName);
} catch (WSDLException e) {
handleException("Couldn't process the given WSDL document.");
@@ -65,24 +63,23 @@
return null;
}
- private EndpointDefinition createEndpointDefinitionFromWSDL
- (DescriptionElement dElement, String serviceName, String portName) {
+ private EndpointDefinition createEndpointDefinitionFromWSDL(Description description,
+ String serviceName, String portName) {
- if (dElement == null) {
- throw new SynapseException("WSDL is not specified.");
+ if (description == null) {
+ throw new SynapseException("WSDL document is not specified.");
}
if (serviceName == null) {
- throw new SynapseException("Service is not specified.");
+ throw new SynapseException("Service name of the WSDL document is not specified.");
}
if (portName == null) {
- throw new SynapseException("Port is not specified.");
+ throw new SynapseException("Port name of the WSDL document is not specified.");
}
- Description description = dElement.toComponent();
- String tns = dElement.getTargetNamespace().toString();
- Service service = description.getService(new QName(tns, serviceName));
+ URI tns = description.toElement().getTargetNamespace();
+ Service service = description.getService(new QName(tns.toString(), serviceName));
if (service != null) {
Endpoint wsdlEndpoint = service.getEndpoint(new NCName(portName));
if (wsdlEndpoint != null) {
@@ -105,5 +102,5 @@
private static void handleException(String msg) {
log.error(msg);
throw new SynapseException(msg);
- }*/
+ }
}