[prev in list] [next in list] [prev in thread] [next in thread] 

List:       juddi-cvs
Subject:    svn commit: r1177045 - in /juddi/trunk/juddi-client: pom.xml
From:       tcunning () apache ! org
Date:       2011-09-28 20:20:13
Message-ID: 20110928202013.64B712388994 () eris ! apache ! org
[Download RAW message or body]

Author: tcunning
Date: Wed Sep 28 20:20:12 2011
New Revision: 1177045

URL: http://svn.apache.org/viewvc?rev=1177045&view=rev
Log:
JUDDI-530
Add custom CXF interceptor and a SAPRegistryJAXWSTransport.

Added:
    juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/transport/SAPRegistryJAXWSTransport.java
  juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/transport/XMLDeclarationWritingInterceptor.java
 Modified:
    juddi/trunk/juddi-client/pom.xml

Modified: juddi/trunk/juddi-client/pom.xml
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-client/pom.xml?rev=1177045&r1=1177044&r2=1177045&view=diff
 ==============================================================================
--- juddi/trunk/juddi-client/pom.xml (original)
+++ juddi/trunk/juddi-client/pom.xml Wed Sep 28 20:20:12 2011
@@ -25,6 +25,10 @@
   <artifactId>juddi-client</artifactId>
   <packaging>bundle</packaging>
   <name>jUDDI Client side Code</name>
+  <properties>
+    <cxf.version>2.3.6</cxf.version>
+  </properties>
+
   <dependencies>
     <dependency>
         <groupId>org.apache.juddi</groupId>
@@ -36,7 +40,7 @@
         <artifactId>commons-configuration</artifactId>
         <version>1.6</version>
      </dependency>
-	 <dependency>
+      <dependency>
 		<groupId>javax.servlet</groupId>
 		<artifactId>servlet-api</artifactId>
 		<version>2.5</version>
@@ -46,8 +50,23 @@
     	<groupId>wsdl4j</groupId>
     	<artifactId>wsdl4j</artifactId>
     	<version>1.6.2</version>
-	</dependency>
-	 
-	 
+    </dependency>
+
+    <dependency>
+        <groupId>org.apache.cxf</groupId>
+        <artifactId>cxf-rt-frontend-jaxws</artifactId>
+        <version>${cxf.version}</version>
+    </dependency>
+    <dependency>
+        <groupId>org.apache.cxf</groupId>
+        <artifactId>cxf-rt-transports-http</artifactId>
+        <version>${cxf.version}</version>
+        <exclusions>
+            <exclusion>
+                <groupId>cglib</groupId>
+                <artifactId>cglib</artifactId>
+            </exclusion>
+       </exclusions>
+    </dependency>
   </dependencies> 
 </project>

Added: juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/transport/SAPRegistryJAXWSTransport.java
                
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/transport/SAPRegistryJAXWSTransport.java?rev=1177045&view=auto
 ==============================================================================
--- juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/transport/SAPRegistryJAXWSTransport.java \
                (added)
+++ juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/transport/SAPRegistryJAXWSTransport.java \
Wed Sep 28 20:20:12 2011 @@ -0,0 +1,264 @@
+/*
+ * Copyright 2001-2009 The Apache Software Foundation.
+ * 
+ * Licensed 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.juddi.v3.client.transport;
+
+import java.util.Map;
+import java.util.Properties;
+
+import javax.xml.ws.BindingProvider;
+
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.juddi.v3.client.JUDDIApiService;
+import org.apache.juddi.v3.client.UDDIService;
+import org.apache.juddi.v3.client.config.Property;
+import org.apache.juddi.v3.client.config.UDDIClerkManager;
+import org.apache.juddi.v3.client.config.UDDIClientContainer;
+import org.apache.juddi.v3_service.JUDDIApiPortType;
+import org.uddi.v3_service.UDDICustodyTransferPortType;
+import org.uddi.v3_service.UDDIInquiryPortType;
+import org.uddi.v3_service.UDDIPublicationPortType;
+import org.uddi.v3_service.UDDISecurityPortType;
+import org.uddi.v3_service.UDDISubscriptionListenerPortType;
+import org.uddi.v3_service.UDDISubscriptionPortType;
+
+import org.apache.cxf.endpoint.Client;
+import org.apache.cxf.frontend.ClientProxy;
+
+/**
+ * Add a special JAXWSTransport for use with the SAP Registry.     Need to add
+ * a CXF interceptor because SAP does not like the default XML declaration.
+ * 
+ * @author Tom Cunningham <tcunning@apache.org>
+ *
+ */
+public class SAPRegistryJAXWSTransport extends JAXWSTransport {
+	
+	public SAPRegistryJAXWSTransport() {
+		super();
+	}
+		
+	public SAPRegistryJAXWSTransport(String nodeName) {
+		super(nodeName);	
+	}
+	
+	public SAPRegistryJAXWSTransport(String managerName, String nodeName) {
+		super(managerName, nodeName);
+	}
+	
+	public UDDIInquiryPortType getUDDIInquiryService(String endpointURL) throws \
TransportException { +
+		if (inquiryService==null) {
+			try {
+				if (endpointURL==null)  {
+					UDDIClerkManager manager = \
UDDIClientContainer.getUDDIClerkManager(managerName); +					endpointURL = \
manager.getClientConfig().getUDDINode(nodeName).getInquiryUrl(); +				}
+				UDDIService service = new UDDIService();
+				inquiryService = service.getUDDIInquiryPort();
+				Map<String, Object> requestContext = ((BindingProvider) \
inquiryService).getRequestContext(); \
+				requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointURL); \
+				setCredentials(requestContext); +				
+				XMLDeclarationWritingInterceptor xmldwi = new \
XMLDeclarationWritingInterceptor();				 +				Client cxfClient = \
ClientProxy.getClient(inquiryService); \
+				cxfClient.getInInterceptors().add(xmldwi); +			} catch (Exception e) {
+				throw new TransportException(e.getMessage(), e);
+			}
+		}
+		return inquiryService;
+	}
+	
+	public UDDISecurityPortType getUDDISecurityService(String endpointURL) throws \
TransportException { +
+		if (securityService==null) {
+			try {
+				if (endpointURL==null)  {
+					UDDIClerkManager manager = \
UDDIClientContainer.getUDDIClerkManager(managerName); +					endpointURL = \
manager.getClientConfig().getUDDINode(nodeName).getSecurityUrl(); +				}
+				UDDIService service = new UDDIService();
+				securityService = service.getUDDISecurityPort();
+				Map<String, Object> requestContext = ((BindingProvider) \
securityService).getRequestContext(); \
+				requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointURL); \
+				setCredentials(requestContext); +
+				XMLDeclarationWritingInterceptor xmldwi = new \
XMLDeclarationWritingInterceptor();				 +				Client cxfClient = \
ClientProxy.getClient(securityService); \
+				cxfClient.getInInterceptors().add(xmldwi); +
+			} catch (Exception e) {
+				throw new TransportException(e.getMessage(), e);
+			}
+		}
+		return securityService;
+	}
+	
+	public UDDIPublicationPortType getUDDIPublishService(String endpointURL) throws \
TransportException { +
+		if (publishService==null) {
+			try {
+				if (endpointURL==null)  {
+					UDDIClerkManager manager = \
UDDIClientContainer.getUDDIClerkManager(managerName); +					endpointURL = \
manager.getClientConfig().getUDDINode(nodeName).getPublishUrl(); +				}
+				UDDIService service = new UDDIService();
+				publishService = service.getUDDIPublicationPort();
+				Map<String, Object> requestContext = ((BindingProvider) \
publishService).getRequestContext(); \
+				requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointURL); \
+				setCredentials(requestContext); +
+				XMLDeclarationWritingInterceptor xmldwi = new \
XMLDeclarationWritingInterceptor();				 +				Client cxfClient = \
ClientProxy.getClient(publishService); \
+				cxfClient.getInInterceptors().add(xmldwi); +
+			} catch (Exception e) {
+				throw new TransportException(e.getMessage(), e);
+			}
+		}
+		return publishService;
+	}
+	
+	public UDDISubscriptionPortType getUDDISubscriptionService(String endpointURL) \
throws TransportException { +
+		if (subscriptionService==null) {
+			try {
+				if (endpointURL==null)  {
+					UDDIClerkManager manager = \
UDDIClientContainer.getUDDIClerkManager(managerName); +					endpointURL = \
manager.getClientConfig().getUDDINode(nodeName).getSubscriptionUrl(); +				}
+				UDDIService service = new UDDIService();
+				subscriptionService = service.getUDDISubscriptionPort();
+				Map<String, Object> requestContext = ((BindingProvider) \
subscriptionService).getRequestContext(); \
+				requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointURL); \
+				setCredentials(requestContext); +
+				XMLDeclarationWritingInterceptor xmldwi = new \
XMLDeclarationWritingInterceptor();				 +				Client cxfClient = \
ClientProxy.getClient(subscriptionService); \
+				cxfClient.getInInterceptors().add(xmldwi); +
+			} catch (Exception e) {
+				throw new TransportException(e.getMessage(), e);
+			}
+		}
+		return subscriptionService;
+	}
+	
+	public UDDISubscriptionListenerPortType getUDDISubscriptionListenerService(String \
endpointURL) throws TransportException { +		if (subscriptionListenerService == null) \
{ +			try {
+				if (endpointURL==null)  {
+					UDDIClerkManager manager = \
UDDIClientContainer.getUDDIClerkManager(managerName); +					endpointURL = \
manager.getClientConfig().getUDDINode(nodeName).getSubscriptionListenerUrl(); +				}
+				UDDIService service = new UDDIService();
+				subscriptionListenerService = service.getUDDISubscriptionListenerPort();
+				Map<String, Object> requestContext = ((BindingProvider) \
subscriptionListenerService).getRequestContext(); \
+				requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointURL); \
+				setCredentials(requestContext); +
+				XMLDeclarationWritingInterceptor xmldwi = new \
XMLDeclarationWritingInterceptor();				 +				Client cxfClient = \
ClientProxy.getClient(subscriptionListenerService); \
+				cxfClient.getInInterceptors().add(xmldwi); +
+			} catch (Exception e) {
+				throw new TransportException(e.getMessage(), e);
+			}
+		}
+		return subscriptionListenerService;
+	}
+	
+	public UDDICustodyTransferPortType getUDDICustodyTransferService(String \
endpointURL) throws TransportException { +		if (custodyTransferService == null) {
+			try {
+				if (endpointURL==null)  {
+					UDDIClerkManager manager = \
UDDIClientContainer.getUDDIClerkManager(managerName); +					endpointURL = \
manager.getClientConfig().getUDDINode(nodeName).getCustodyTransferUrl(); +				}
+				UDDIService service = new UDDIService();
+				custodyTransferService = service.getUDDICustodyPort();
+				Map<String, Object> requestContext = ((BindingProvider) \
custodyTransferService).getRequestContext(); \
+				requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointURL); \
+				setCredentials(requestContext); +
+				XMLDeclarationWritingInterceptor xmldwi = new \
XMLDeclarationWritingInterceptor();				 +				Client cxfClient = \
ClientProxy.getClient(custodyTransferService); \
+				cxfClient.getInInterceptors().add(xmldwi); +
+			} catch (Exception e) {
+				throw new TransportException(e.getMessage(), e);
+			}
+		}
+		return custodyTransferService;
+	}
+	
+	/**
+	 * This is a jUDDI specific API
+	 */
+	public JUDDIApiPortType getJUDDIApiService(String endpointURL) throws \
TransportException { +		if (publisherService == null) {
+			try {
+				if (endpointURL==null)  {
+					UDDIClerkManager manager = \
UDDIClientContainer.getUDDIClerkManager(managerName); +					endpointURL = \
manager.getClientConfig().getUDDINode(nodeName).getJuddiApiUrl(); +				}
+				JUDDIApiService service = new JUDDIApiService();
+				publisherService = (JUDDIApiPortType) service.getPort(JUDDIApiPortType.class);
+				Map<String, Object> requestContext = ((BindingProvider) \
publisherService).getRequestContext(); \
+				requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointURL); \
+				setCredentials(requestContext); +			} catch (Exception e) {
+				throw new TransportException(e.getMessage(), e);
+			}
+		}
+		return publisherService;
+	}
+
+	public String getNodeName() {
+		return nodeName;
+	}
+
+	public void setNodeName(String nodeName) {
+		this.nodeName = nodeName;
+	}
+	
+	/**
+	 * Sets the credentials on the RequestContext if the services are protected
+	 * by Basic Authentication. The username and password are obtained from the 
+	 * uddi.xml.
+	 * 
+	 * @param requestContext
+	 * @throws ConfigurationException
+	 */
+	private void setCredentials(Map<String, Object> requestContext) throws \
ConfigurationException { +		UDDIClerkManager manager = \
UDDIClientContainer.getUDDIClerkManager(managerName); +		Properties properties = \
manager.getClientConfig().getUDDINode(nodeName).getProperties(); +		String username = \
null; +		String password = null;
+		if (properties.containsKey(Property.BASIC_AUTH_USERNAME)) {
+			username = properties.getProperty(Property.BASIC_AUTH_USERNAME);
+		}
+		if (properties.containsKey(Property.BASIC_AUTH_PASSWORD)) {
+			password = properties.getProperty(Property.BASIC_AUTH_PASSWORD);
+		}
+		if (username!=null && password!=null) {
+			requestContext.put(BindingProvider.USERNAME_PROPERTY, username);
+			requestContext.put(BindingProvider.PASSWORD_PROPERTY, password);
+		}
+	}
+
+}

Added: juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/transport/XMLDeclarationWritingInterceptor.java
                
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-client/src/main/java/org/apache/ju \
ddi/v3/client/transport/XMLDeclarationWritingInterceptor.java?rev=1177045&view=auto \
                ==============================================================================
                
--- juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/transport/XMLDeclarationWritingInterceptor.java \
                (added)
+++ juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/transport/XMLDeclarationWritingInterceptor.java \
Wed Sep 28 20:20:12 2011 @@ -0,0 +1,47 @@
+/*
+ * Copyright 2001-2009 The Apache Software Foundation.
+ * 
+ * Licensed 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.juddi.v3.client.transport;
+
+import org.apache.cxf.binding.soap.SoapMessage;
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.interceptor.StaxOutInterceptor;
+import org.apache.cxf.binding.soap.interceptor.AbstractSoapInterceptor;
+import java.io.OutputStream;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.Phase;
+import org.apache.cxf.phase.AbstractPhaseInterceptor;
+
+/**
+ * Add a CXF interceptor to add the XML declaration.
+ * 
+ * * @author Tom Cunningham <tcunning@apache.org>
+ *
+ */
+public class XMLDeclarationWritingInterceptor extends \
AbstractPhaseInterceptor<SoapMessage> { +	
+    public XMLDeclarationWritingInterceptor () { 
+        super(Phase.PRE_STREAM); 
+        addBefore(StaxOutInterceptor.class.getName());
+    } 
+
+    @Override 
+    public void handleMessage(SoapMessage message) throws Fault { 
+    	message.put("org.apache.cxf.stax.force-start-document", Boolean.TRUE);      
+    } 
+} 



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@juddi.apache.org
For additional commands, e-mail: commits-help@juddi.apache.org


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic