You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by jc...@apache.org on 2005/08/25 07:26:36 UTC
svn commit: r239995 - in /jakarta/commons/sandbox/proxy/trunk: ./
src/java/org/apache/commons/proxy/provider/
src/test/org/apache/commons/proxy/provider/
src/test/org/apache/commons/proxy/util/
Author: jcarman
Date: Wed Aug 24 22:26:30 2005
New Revision: 239995
URL: http://svn.apache.org/viewcvs?rev=239995&view=rev
Log:
Adding JaxRpcProvider.
Added:
jakarta/commons/sandbox/proxy/trunk/src/java/org/apache/commons/proxy/provider/JaxRpcProvider.java
jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/provider/TestJaxRpcProvider.java
jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/util/QuoteService.java
Modified:
jakarta/commons/sandbox/proxy/trunk/build.xml
jakarta/commons/sandbox/proxy/trunk/commons-proxy.iml
Modified: jakarta/commons/sandbox/proxy/trunk/build.xml
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/proxy/trunk/build.xml?rev=239995&r1=239994&r2=239995&view=diff
==============================================================================
--- jakarta/commons/sandbox/proxy/trunk/build.xml (original)
+++ jakarta/commons/sandbox/proxy/trunk/build.xml Wed Aug 24 22:26:30 2005
@@ -57,8 +57,14 @@
<target name="get-dependencies">
<runtime-dependency groupId="aopalliance" version="1.0"/>
<runtime-dependency groupId="cglib" artifactId="cglib-full" version="2.0.2"/>
+ <runtime-dependency groupId="commons-logging" version="1.0.4" />
<runtime-dependency groupId="burlap" version="2.1.7"/>
<runtime-dependency groupId="hessian" version="3.0.1"/>
+ <runtime-dependency groupId="axis" version="1.2.1" />
+ <runtime-dependency groupId="axis" artifactId="axis-jaxrpc" version="1.2.1" />
+ <runtime-dependency groupId="axis" artifactId="axis-saaj" version="1.2.1" />
+ <runtime-dependency groupId="axis" artifactId="axis-wsdl4j" version="1.5.1" />
+ <runtime-dependency groupId="commons-discovery" version="0.2" />
<runtime-dependency groupId="javassist" version="3.0"/>
<build-dependency groupId="junit" version="3.8.1"/>
</target>
Modified: jakarta/commons/sandbox/proxy/trunk/commons-proxy.iml
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/proxy/trunk/commons-proxy.iml?rev=239995&r1=239994&r2=239995&view=diff
==============================================================================
--- jakarta/commons/sandbox/proxy/trunk/commons-proxy.iml (original)
+++ jakarta/commons/sandbox/proxy/trunk/commons-proxy.iml Wed Aug 24 22:26:30 2005
@@ -66,6 +66,60 @@
<SOURCES />
</library>
</orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/lib/runtime/axis/axis-jaxrpc.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/lib/runtime/axis/axis.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/lib/runtime/commons-logging/commons-logging.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/lib/runtime/commons-discovery/commons-discovery.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/lib/runtime/axis/axis-saaj.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/lib/runtime/axis/axis-wsdl4j.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
<orderEntryProperties />
</component>
</module>
Added: jakarta/commons/sandbox/proxy/trunk/src/java/org/apache/commons/proxy/provider/JaxRpcProvider.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/proxy/trunk/src/java/org/apache/commons/proxy/provider/JaxRpcProvider.java?rev=239995&view=auto
==============================================================================
--- jakarta/commons/sandbox/proxy/trunk/src/java/org/apache/commons/proxy/provider/JaxRpcProvider.java (added)
+++ jakarta/commons/sandbox/proxy/trunk/src/java/org/apache/commons/proxy/provider/JaxRpcProvider.java Wed Aug 24 22:26:30 2005
@@ -0,0 +1,129 @@
+/*
+ * Copyright 2005 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.commons.proxy.provider;
+
+import org.apache.commons.proxy.ObjectProvider;
+import org.apache.commons.proxy.exception.ObjectProviderException;
+
+import javax.xml.namespace.QName;
+import javax.xml.rpc.Service;
+import javax.xml.rpc.ServiceException;
+import javax.xml.rpc.ServiceFactory;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+/**
+ * Returns a proxy for a JAX-RPC-based service.
+ *
+ * @author James Carman
+ * @version 1.0
+ */
+public class JaxRpcProvider<T> implements ObjectProvider<T>
+{
+ private final Class<? extends T> serviceInterface;
+ private String url;
+ private String serviceNamespaceUri;
+ private String serviceLocalPart;
+ private String servicePrefix;
+ private String portNamespaceUri;
+ private String portLocalPart;
+ private String portPrefix;
+
+ public JaxRpcProvider( Class<? extends T> serviceInterface )
+ {
+ this.serviceInterface = serviceInterface;
+ }
+
+ public T getObject()
+ {
+ try
+ {
+ final Service service = ( url == null ? ServiceFactory.newInstance().createService( getServiceQName() ) : ServiceFactory.newInstance().createService( new URL( url ), getServiceQName() ) );
+ final QName portQName = getPortQName();
+ return serviceInterface.cast( portQName == null ? service.getPort( serviceInterface ) : service.getPort( portQName, serviceInterface ) );
+ }
+ catch( ServiceException e )
+ {
+ throw new ObjectProviderException( "Unable to create JAX-RPC service proxy.", e );
+ }
+ catch( MalformedURLException e )
+ {
+ throw new ObjectProviderException( "Invalid URL given.", e );
+ }
+ }
+
+ private QName getQName( String namespaceUri, String localPart, String prefix )
+ {
+ if( namespaceUri != null && localPart != null && prefix != null )
+ {
+ return new QName( namespaceUri, localPart, prefix );
+ }
+ else if( namespaceUri != null && localPart != null )
+ {
+ return new QName( namespaceUri, localPart );
+ }
+ else if( localPart != null )
+ {
+ return new QName( localPart );
+ }
+ return null;
+ }
+
+ private QName getServiceQName()
+ {
+ return getQName( serviceNamespaceUri, serviceLocalPart, servicePrefix );
+ }
+
+ private QName getPortQName()
+ {
+ return getQName( portNamespaceUri, portLocalPart, portPrefix );
+ }
+
+ public void setPortNamespaceUri( String portNamespaceUri )
+ {
+ this.portNamespaceUri = portNamespaceUri;
+ }
+
+ public void setPortLocalPart( String portLocalPart )
+ {
+ this.portLocalPart = portLocalPart;
+ }
+
+ public void setPortPrefix( String portPrefix )
+ {
+ this.portPrefix = portPrefix;
+ }
+
+ public void setServiceNamespaceUri( String serviceNamespaceUri )
+ {
+ this.serviceNamespaceUri = serviceNamespaceUri;
+ }
+
+ public void setServiceLocalPart( String serviceLocalPart )
+ {
+ this.serviceLocalPart = serviceLocalPart;
+ }
+
+ public void setServicePrefix( String servicePrefix )
+ {
+ this.servicePrefix = servicePrefix;
+ }
+
+ public void setUrl( String url )
+ {
+ this.url = url;
+ }
+}
Added: jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/provider/TestJaxRpcProvider.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/provider/TestJaxRpcProvider.java?rev=239995&view=auto
==============================================================================
--- jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/provider/TestJaxRpcProvider.java (added)
+++ jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/provider/TestJaxRpcProvider.java Wed Aug 24 22:26:30 2005
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2005 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.commons.proxy.provider;
+import junit.framework.TestCase;
+import org.apache.commons.proxy.util.QuoteService;
+
+public class TestJaxRpcProvider extends TestCase
+{
+ public void testGetObject() throws Exception
+ {
+ final JaxRpcProvider provider = new JaxRpcProvider<QuoteService>( QuoteService.class );
+ provider.setUrl( "http://services.xmethods.net/soap/urn:xmethods-delayed-quotes.wsdl" );
+ provider.setServiceNamespaceUri( "http://www.themindelectric.com/wsdl/net.xmethods.services.stockquote.StockQuote/" );
+ provider.setServiceLocalPart( "net.xmethods.services.stockquote.StockQuoteService" );
+ provider.setPortLocalPart( "net.xmethods.services.stockquote.StockQuotePort" );
+ final QuoteService quote = ( QuoteService )provider.getObject();
+ assertNotNull( quote );
+ }
+}
\ No newline at end of file
Added: jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/util/QuoteService.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/util/QuoteService.java?rev=239995&view=auto
==============================================================================
--- jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/util/QuoteService.java (added)
+++ jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/util/QuoteService.java Wed Aug 24 22:26:30 2005
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2005 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.commons.proxy.util;
+
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+
+/**
+ * @author James Carman
+ * @version 1.0
+ */
+public interface QuoteService extends Remote
+{
+ public float getQuote( String symbol ) throws RemoteException;
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org