Author: gnodet
Date: Wed Dec 20 05:35:50 2006
New Revision: 489085
URL: http://svn.apache.org/viewvc?view=rev&rev=489085
Log:
SM-257: WSDL 2 support with Apache Woden (to retrieve interfaces from endpoint
descriptions)
SM-611: Reduce non-optional core dependencies: WSDL4J and Woden are optional
deps
Added:
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/support/
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/support/EndpointProcessor.java
(with props)
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/support/SUDescriptorProcessor.java
(with props)
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/support/WSDL1Processor.java
(with props)
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/support/WSDL2Processor.java
(with props)
Modified:
incubator/servicemix/trunk/core/servicemix-core/pom.xml
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/EndpointRegistry.java
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/servicedesc/InternalEndpoint.java
Modified: incubator/servicemix/trunk/core/servicemix-core/pom.xml
URL:
http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/pom.xml?view=diff&rev=489085&r1=489084&r2=489085
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/pom.xml (original)
+++ incubator/servicemix/trunk/core/servicemix-core/pom.xml Wed Dec 20 05:35:50
2006
@@ -166,6 +166,13 @@
<dependency>
<groupId>wsdl4j</groupId>
<artifactId>wsdl4j</artifactId>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.woden</groupId>
+ <artifactId>woden</artifactId>
+ <version>${woden-version}</version>
+ <optional>true</optional>
</dependency>
<dependency>
<groupId>jaxen</groupId>
Modified:
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/EndpointRegistry.java
URL:
http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/EndpointRegistry.java?view=diff&rev=489085&r1=489084&r2=489085
==============================================================================
---
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/EndpointRegistry.java
(original)
+++
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/EndpointRegistry.java
Wed Dec 20 05:35:50 2006
@@ -20,6 +20,7 @@
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -28,27 +29,17 @@
import javax.jbi.servicedesc.ServiceEndpoint;
import javax.management.JMException;
import javax.management.ObjectName;
-import javax.wsdl.Definition;
-import javax.wsdl.Port;
-import javax.wsdl.PortType;
-import javax.wsdl.Service;
-import javax.wsdl.factory.WSDLFactory;
-import javax.wsdl.xml.WSDLReader;
import javax.xml.namespace.QName;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.servicemix.jbi.deployment.Provides;
-import org.apache.servicemix.jbi.deployment.Services;
import org.apache.servicemix.jbi.event.EndpointEvent;
import org.apache.servicemix.jbi.event.EndpointListener;
+import org.apache.servicemix.jbi.framework.support.EndpointProcessor;
import org.apache.servicemix.jbi.servicedesc.AbstractServiceEndpoint;
import org.apache.servicemix.jbi.servicedesc.ExternalEndpoint;
import org.apache.servicemix.jbi.servicedesc.InternalEndpoint;
import org.apache.servicemix.jbi.servicedesc.LinkedEndpoint;
-import org.w3c.dom.Document;
-
-import com.ibm.wsdl.Constants;
import edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap;
@@ -73,6 +64,8 @@
private Map interfaceConnections;
+ private List endpointProcessors;
+
/**
* Constructor
*
@@ -85,6 +78,24 @@
this.externalEndpoints = new ConcurrentHashMap();
this.linkedEndpoints = new ConcurrentHashMap();
this.interfaceConnections = new ConcurrentHashMap();
+ this.endpointProcessors = getEndpointProcessors();
+ }
+
+ protected List getEndpointProcessors() {
+ List l = new ArrayList();
+ String[] classes = {
"org.apache.servicemix.jbi.framework.support.SUDescriptorProcessor",
+
"org.apache.servicemix.jbi.framework.support.WSDL1Processor",
+
"org.apache.servicemix.jbi.framework.support.WSDL2Processor" };
+ for (int i = 0; i < classes.length; i++) {
+ try {
+ EndpointProcessor p = (EndpointProcessor)
Class.forName(classes[i]).newInstance();
+ p.init(registry);
+ l.add(p);
+ } catch (Throwable e) {
+ logger.warn("Disabled endpoint processor '" + classes[i] + "':
" + e);
+ }
+ }
+ return l;
}
public ServiceEndpoint[] getEndpointsForComponent(ComponentNameSpace cns) {
@@ -183,10 +194,11 @@
if (provider.getActivationSpec().getInterfaceName() != null) {
serviceEndpoint.addInterface(provider.getActivationSpec().getInterfaceName());
}
- // Get interface from SU jbi descriptor
- retrieveInterfaceFromSUDescriptor(serviceEndpoint);
- // Get interfaces from WSDL
- retrieveInterfacesFromDescription(serviceEndpoint);
+ // Get interfaces
+ for (Iterator it = endpointProcessors.iterator(); it.hasNext();) {
+ EndpointProcessor p = (EndpointProcessor) it.next();
+ p.process(serviceEndpoint);
+ }
// Set remote namespaces
if (registered != null) {
InternalEndpoint[] remote = registered.getRemoteEndpoints();
@@ -209,102 +221,14 @@
*/
public void unregisterInternalEndpoint(ComponentContext provider,
InternalEndpoint serviceEndpoint) {
if (serviceEndpoint.isClustered()) {
+ fireEvent(serviceEndpoint,
EndpointEvent.INTERNAL_ENDPOINT_UNREGISTERED);
// set endpoint to be no more local
serviceEndpoint.setComponentName(null);
} else {
String key = getKey(serviceEndpoint);
internalEndpoints.remove(key);
unregisterEndpoint(serviceEndpoint);
- }
- fireEvent(serviceEndpoint,
EndpointEvent.INTERNAL_ENDPOINT_UNREGISTERED);
- }
-
- /**
- * Retrieve interface implemented by the given endpoint using the SU jbi
descriptors.
- *
- * @param serviceEndpoint the endpoint being checked
- */
- protected void retrieveInterfaceFromSUDescriptor(InternalEndpoint
serviceEndpoint) {
- ServiceUnitLifeCycle[] sus =
registry.getDeployedServiceUnits(serviceEndpoint.getComponentNameSpace().getName());
- for (int i = 0; i < sus.length; i++) {
- Services services = sus[i].getServices();
- if (services != null) {
- Provides[] provides = services.getProvides();
- if (provides != null) {
- for (int j = 0; j < provides.length; j++) {
- if (provides[j].getInterfaceName() != null &&
-
serviceEndpoint.getServiceName().equals(provides[j].getServiceName()) &&
-
serviceEndpoint.getEndpointName().equals(provides[j].getEndpointName())) {
- if (logger.isDebugEnabled()) {
- logger.debug("Endpoint " + serviceEndpoint + "
is provided by SU " + sus[i].getName());
- logger.debug("Endpoint " + serviceEndpoint + "
implements interface " + provides[j].getInterfaceName());
- }
-
serviceEndpoint.addInterface(provides[j].getInterfaceName());
- }
- }
- }
- }
- }
- }
-
- /**
- * Retrieve interfaces implemented by the given endpoint using its WSDL
description.
- *
- * @param serviceEndpoint the endpoint being checked
- */
- protected void retrieveInterfacesFromDescription(InternalEndpoint
serviceEndpoint) {
- try {
- Document document =
registry.getEndpointDescriptor(serviceEndpoint);
- if (document == null) {
- if (logger.isDebugEnabled()) {
- logger.debug("Endpoint " + serviceEndpoint + " has no
service description");
- }
- return;
- }
- WSDLReader reader = WSDLFactory.newInstance().newWSDLReader();
- reader.setFeature(Constants.FEATURE_VERBOSE, false);
- Definition definition = reader.readWSDL(null, document);
- // Check if the wsdl is only a port type
- // In these cases, only the port type is used, as the service name
and endpoint name
- // are provided on the jbi endpoint
- if (definition.getPortTypes().keySet().size() == 1 &&
- definition.getServices().keySet().size() == 0) {
- PortType portType = (PortType)
definition.getPortTypes().values().iterator().next();
- QName interfaceName = portType.getQName();
- if (logger.isDebugEnabled()) {
- logger.debug("Endpoint " + serviceEndpoint + " implements
interface " + interfaceName);
- }
- serviceEndpoint.addInterface(interfaceName);
- } else {
- Service service =
definition.getService(serviceEndpoint.getServiceName());
- if (service == null) {
- logger.info("Endpoint " + serviceEndpoint + " has a
service description, but no matching service found in " +
definition.getServices().keySet());
- return;
- }
- Port port = service.getPort(serviceEndpoint.getEndpointName());
- if (port == null) {
- logger.info("Endpoint " + serviceEndpoint + " has a
service description, but no matching endpoint found in " +
service.getPorts().keySet());
- return;
- }
- if (port.getBinding() == null) {
- logger.info("Endpoint " + serviceEndpoint + " has a
service description, but no binding found");
- return;
- }
- if (port.getBinding().getPortType() == null) {
- logger.info("Endpoint " + serviceEndpoint + " has a
service description, but no port type found");
- return;
- }
- QName interfaceName =
port.getBinding().getPortType().getQName();
- if (logger.isDebugEnabled()) {
- logger.debug("Endpoint " + serviceEndpoint + " implements
interface " + interfaceName);
- }
- serviceEndpoint.addInterface(interfaceName);
- }
- } catch (Exception e) {
- logger.warn("Error retrieving interfaces from service description:
" + e.getMessage());
- if (logger.isDebugEnabled()) {
- logger.debug("Error retrieving interfaces from service
description", e);
- }
+ fireEvent(serviceEndpoint,
EndpointEvent.INTERNAL_ENDPOINT_UNREGISTERED);
}
}
@@ -331,9 +255,14 @@
* @param remote
*/
public void unregisterRemoteEndpoint(InternalEndpoint remote) {
- InternalEndpoint endpoint = (InternalEndpoint)
internalEndpoints.get(getKey(remote));
+ String key = getKey(remote);
+ InternalEndpoint endpoint = (InternalEndpoint)
internalEndpoints.get(key);
if (endpoint != null) {
endpoint.removeRemoteEndpoint(remote);
+ if (!endpoint.isClustered() && !endpoint.isLocal()) {
+ internalEndpoints.remove(key);
+ unregisterEndpoint(endpoint);
+ }
fireEvent(remote, EndpointEvent.REMOTE_ENDPOINT_UNREGISTERED);
}
}
Added:
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/support/EndpointProcessor.java
URL:
http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/support/EndpointProcessor.java?view=auto&rev=489085
==============================================================================
---
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/support/EndpointProcessor.java
(added)
+++
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/support/EndpointProcessor.java
Wed Dec 20 05:35:50 2006
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.jbi.framework.support;
+
+import org.apache.servicemix.jbi.framework.Registry;
+import org.apache.servicemix.jbi.servicedesc.InternalEndpoint;
+
+/**
+ * An endpoint processor is usually used to retrieve the interfaces
+ * implemented by the given endpoint.
+ *
+ * @author gnodet
+ */
+public interface EndpointProcessor {
+
+ /**
+ * Initialize the processor
+ *
+ * @param registry
+ */
+ void init(Registry registry);
+
+ /**
+ * Post process the endpoint.
+ *
+ * @param serviceEndpoint the endpoint
+ */
+ void process(InternalEndpoint serviceEndpoint);
+
+}
Propchange:
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/support/EndpointProcessor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/support/EndpointProcessor.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange:
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/support/EndpointProcessor.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/support/SUDescriptorProcessor.java
URL:
http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/support/SUDescriptorProcessor.java?view=auto&rev=489085
==============================================================================
---
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/support/SUDescriptorProcessor.java
(added)
+++
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/support/SUDescriptorProcessor.java
Wed Dec 20 05:35:50 2006
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.jbi.framework.support;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.servicemix.jbi.deployment.Provides;
+import org.apache.servicemix.jbi.deployment.Services;
+import org.apache.servicemix.jbi.framework.Registry;
+import org.apache.servicemix.jbi.framework.ServiceUnitLifeCycle;
+import org.apache.servicemix.jbi.servicedesc.InternalEndpoint;
+
+/**
+ * Retrieve interface implemented by the given endpoint using the SU jbi
descriptors.
+ *
+ * @author gnodet
+ */
+public class SUDescriptorProcessor implements EndpointProcessor {
+
+ private static final Log logger =
LogFactory.getLog(SUDescriptorProcessor.class);
+
+ private Registry registry;
+
+ public void init(Registry registry) {
+ this.registry = registry;
+ }
+
+ /**
+ * Retrieve interface implemented by the given endpoint using the SU jbi
descriptors.
+ *
+ * @param serviceEndpoint the endpoint being checked
+ */
+ public void process(InternalEndpoint serviceEndpoint) {
+ ServiceUnitLifeCycle[] sus =
registry.getDeployedServiceUnits(serviceEndpoint.getComponentNameSpace().getName());
+ for (int i = 0; i < sus.length; i++) {
+ Services services = sus[i].getServices();
+ if (services != null) {
+ Provides[] provides = services.getProvides();
+ if (provides != null) {
+ for (int j = 0; j < provides.length; j++) {
+ if (provides[j].getInterfaceName() != null &&
+
serviceEndpoint.getServiceName().equals(provides[j].getServiceName()) &&
+
serviceEndpoint.getEndpointName().equals(provides[j].getEndpointName())) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Endpoint " + serviceEndpoint + "
is provided by SU " + sus[i].getName());
+ logger.debug("Endpoint " + serviceEndpoint + "
implements interface " + provides[j].getInterfaceName());
+ }
+
serviceEndpoint.addInterface(provides[j].getInterfaceName());
+ }
+ }
+ }
+ }
+ }
+ }
+
+}
Propchange:
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/support/SUDescriptorProcessor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/support/SUDescriptorProcessor.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange:
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/support/SUDescriptorProcessor.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/support/WSDL1Processor.java
URL:
http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/support/WSDL1Processor.java?view=auto&rev=489085
==============================================================================
---
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/support/WSDL1Processor.java
(added)
+++
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/support/WSDL1Processor.java
Wed Dec 20 05:35:50 2006
@@ -0,0 +1,119 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.jbi.framework.support;
+
+import javax.wsdl.Definition;
+import javax.wsdl.Port;
+import javax.wsdl.PortType;
+import javax.wsdl.Service;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLReader;
+import javax.xml.namespace.QName;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.servicemix.jbi.framework.Registry;
+import org.apache.servicemix.jbi.servicedesc.InternalEndpoint;
+import org.w3c.dom.Document;
+
+import com.ibm.wsdl.Constants;
+
+/**
+ * Retrieve interface implemented by the given endpoint using the WSDL 1
description.
+ *
+ * @author gnodet
+ */
+public class WSDL1Processor implements EndpointProcessor {
+
+ public static final String WSDL1_NAMESPACE =
"http://schemas.xmlsoap.org/wsdl/";
+
+ private static final Log logger = LogFactory.getLog(WSDL1Processor.class);
+
+ private Registry registry;
+
+ public void init(Registry registry) {
+ this.registry = registry;
+ }
+
+ /**
+ * Retrieve interface implemented by the given endpoint using the WSDL 1
description.
+ *
+ * @param serviceEndpoint the endpoint being checked
+ */
+ public void process(InternalEndpoint serviceEndpoint) {
+ try {
+ Document document =
registry.getEndpointDescriptor(serviceEndpoint);
+ if (document == null || document.getDocumentElement() == null) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Endpoint " + serviceEndpoint + " has no
service description");
+ }
+ return;
+ }
+ if
(!WSDL1_NAMESPACE.equals(document.getDocumentElement().getNamespaceURI())) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Endpoint " + serviceEndpoint + " has a non
WSDL1 service description");
+ }
+ return;
+ }
+ WSDLReader reader = WSDLFactory.newInstance().newWSDLReader();
+ reader.setFeature(Constants.FEATURE_VERBOSE, false);
+ Definition definition = reader.readWSDL(null, document);
+ // Check if the wsdl is only a port type
+ // In these cases, only the port type is used, as the service name
and endpoint name
+ // are provided on the jbi endpoint
+ if (definition.getPortTypes().keySet().size() == 1 &&
+ definition.getServices().keySet().size() == 0) {
+ PortType portType = (PortType)
definition.getPortTypes().values().iterator().next();
+ QName interfaceName = portType.getQName();
+ if (logger.isDebugEnabled()) {
+ logger.debug("Endpoint " + serviceEndpoint + " implements
interface " + interfaceName);
+ }
+ serviceEndpoint.addInterface(interfaceName);
+ } else {
+ Service service =
definition.getService(serviceEndpoint.getServiceName());
+ if (service == null) {
+ logger.info("Endpoint " + serviceEndpoint + " has a
service description, but no matching service found in " +
definition.getServices().keySet());
+ return;
+ }
+ Port port = service.getPort(serviceEndpoint.getEndpointName());
+ if (port == null) {
+ logger.info("Endpoint " + serviceEndpoint + " has a
service description, but no matching endpoint found in " +
service.getPorts().keySet());
+ return;
+ }
+ if (port.getBinding() == null) {
+ logger.info("Endpoint " + serviceEndpoint + " has a
service description, but no binding found");
+ return;
+ }
+ if (port.getBinding().getPortType() == null) {
+ logger.info("Endpoint " + serviceEndpoint + " has a
service description, but no port type found");
+ return;
+ }
+ QName interfaceName =
port.getBinding().getPortType().getQName();
+ if (logger.isDebugEnabled()) {
+ logger.debug("Endpoint " + serviceEndpoint + " implements
interface " + interfaceName);
+ }
+ serviceEndpoint.addInterface(interfaceName);
+ }
+ } catch (Exception e) {
+ logger.warn("Error retrieving interfaces from service description:
" + e.getMessage());
+ if (logger.isDebugEnabled()) {
+ logger.debug("Error retrieving interfaces from service
description", e);
+ }
+ }
+ }
+
+}
Propchange:
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/support/WSDL1Processor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/support/WSDL1Processor.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange:
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/support/WSDL1Processor.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/support/WSDL2Processor.java
URL:
http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/support/WSDL2Processor.java?view=auto&rev=489085
==============================================================================
---
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/support/WSDL2Processor.java
(added)
+++
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/support/WSDL2Processor.java
Wed Dec 20 05:35:50 2006
@@ -0,0 +1,121 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.jbi.framework.support;
+
+import javax.xml.namespace.QName;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.servicemix.jbi.framework.Registry;
+import org.apache.servicemix.jbi.servicedesc.InternalEndpoint;
+import org.apache.woden.WSDLReader;
+import org.apache.woden.internal.DOMWSDLReader;
+import org.apache.woden.internal.DOMWSDLSource;
+import org.apache.woden.types.NCName;
+import org.apache.woden.wsdl20.Description;
+import org.apache.woden.wsdl20.Endpoint;
+import org.apache.woden.wsdl20.Interface;
+import org.apache.woden.wsdl20.Service;
+import org.apache.woden.wsdl20.xml.DescriptionElement;
+import org.w3c.dom.Document;
+
+/**
+ * Retrieve interface implemented by the given endpoint using the WSDL 2
description.
+ *
+ * @author gnodet
+ */
+public class WSDL2Processor implements EndpointProcessor {
+
+ public static final String WSDL2_NAMESPACE =
"http://www.w3.org/2006/01/wsdl";
+
+
+ private static final Log logger = LogFactory.getLog(WSDL1Processor.class);
+
+ private Registry registry;
+
+ public void init(Registry registry) {
+ this.registry = registry;
+ }
+
+ /**
+ * Retrieve interface implemented by the given endpoint using the WSDL 2
description.
+ *
+ * @param serviceEndpoint the endpoint being checked
+ */
+ public void process(InternalEndpoint serviceEndpoint) {
+ try {
+ Document document =
registry.getEndpointDescriptor(serviceEndpoint);
+ if (document == null || document.getDocumentElement() == null) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Endpoint " + serviceEndpoint + " has no
service description");
+ }
+ return;
+ }
+ if
(!WSDL2_NAMESPACE.equals(document.getDocumentElement().getNamespaceURI())) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Endpoint " + serviceEndpoint + " has a non
WSDL2 service description");
+ }
+ return;
+ }
+ WSDLReader reader = new DOMWSDLReader();
+ DOMWSDLSource source = (DOMWSDLSource) reader.createWSDLSource();
+ source.setSource(document);
+ DescriptionElement descElement = reader.readWSDL(source);
+ Description desc = descElement.toComponent();
+ // Check if the wsdl is only a port type
+ // In these cases, only the port type is used, as the service name
and endpoint name
+ // are provided on the jbi endpoint
+ if (desc.getInterfaces().length == 1 && desc.getServices().length
== 0) {
+ Interface itf = desc.getInterfaces()[0];
+ QName interfaceName = itf.getName();
+ if (logger.isDebugEnabled()) {
+ logger.debug("Endpoint " + serviceEndpoint + " implements
interface " + interfaceName);
+ }
+ serviceEndpoint.addInterface(interfaceName);
+ } else {
+ Service service =
desc.getService(serviceEndpoint.getServiceName());
+ if (service == null) {
+ logger.info("Endpoint " + serviceEndpoint + " has a
service description, but no matching service found in " + desc.getServices());
+ return;
+ }
+ Endpoint endpoint = service.getEndpoint(new
NCName(serviceEndpoint.getEndpointName()));
+ if (endpoint == null) {
+ logger.info("Endpoint " + serviceEndpoint + " has a
service description, but no matching endpoint found in " +
service.getEndpoints());
+ return;
+ }
+ if (endpoint.getBinding() == null) {
+ logger.info("Endpoint " + serviceEndpoint + " has a
service description, but no binding found");
+ return;
+ }
+ if (endpoint.getBinding().getInterface() == null) {
+ logger.info("Endpoint " + serviceEndpoint + " has a
service description, but no port type found");
+ return;
+ }
+ QName interfaceName =
endpoint.getBinding().getInterface().getName();
+ if (logger.isDebugEnabled()) {
+ logger.debug("Endpoint " + serviceEndpoint + " implements
interface " + interfaceName);
+ }
+ serviceEndpoint.addInterface(interfaceName);
+ }
+ } catch (Exception e) {
+ logger.warn("Error retrieving interfaces from service description:
" + e.getMessage());
+ if (logger.isDebugEnabled()) {
+ logger.debug("Error retrieving interfaces from service
description", e);
+ }
+ }
+ }
+}
Propchange:
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/support/WSDL2Processor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/support/WSDL2Processor.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange:
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/support/WSDL2Processor.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified:
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/servicedesc/InternalEndpoint.java
URL:
http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/servicedesc/InternalEndpoint.java?view=diff&rev=489085&r1=489084&r2=489085
==============================================================================
---
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/servicedesc/InternalEndpoint.java
(original)
+++
incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/servicedesc/InternalEndpoint.java
Wed Dec 20 05:35:50 2006
@@ -16,10 +16,10 @@
*/
package org.apache.servicemix.jbi.servicedesc;
-import java.util.ArrayList;
import java.util.HashMap;
-import java.util.List;
+import java.util.HashSet;
import java.util.Map;
+import java.util.Set;
import javax.xml.namespace.QName;
@@ -40,7 +40,7 @@
private String endpointName;
private QName serviceName;
- private List interfaces = new ArrayList();
+ private Set interfaces = new HashSet();
private transient Map remotes = new HashMap();