You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xmlrpc-auto@ws.apache.org by jo...@apache.org on 2006/11/23 22:36:42 UTC

svn commit: r478678 - in /webservices/xmlrpc/trunk: client/src/main/java/org/apache/xmlrpc/client/util/ClientFactory.java pom.xml src/changes/changes.xml

Author: jochen
Date: Thu Nov 23 13:36:41 2006
New Revision: 478678

URL: http://svn.apache.org/viewvc?view=rev&rev=478678
Log:
The ClientFactory is now able to use a custom name for
the remote handler. So far, it was always using the
interface name.
PR: XMLRPC-126
Submitted-by: Eugene Prokopiev, prokopiev@stc.donpac.ru

Modified:
    webservices/xmlrpc/trunk/client/src/main/java/org/apache/xmlrpc/client/util/ClientFactory.java
    webservices/xmlrpc/trunk/pom.xml
    webservices/xmlrpc/trunk/src/changes/changes.xml

Modified: webservices/xmlrpc/trunk/client/src/main/java/org/apache/xmlrpc/client/util/ClientFactory.java
URL: http://svn.apache.org/viewvc/webservices/xmlrpc/trunk/client/src/main/java/org/apache/xmlrpc/client/util/ClientFactory.java?view=diff&rev=478678&r1=478677&r2=478678
==============================================================================
--- webservices/xmlrpc/trunk/client/src/main/java/org/apache/xmlrpc/client/util/ClientFactory.java (original)
+++ webservices/xmlrpc/trunk/client/src/main/java/org/apache/xmlrpc/client/util/ClientFactory.java Thu Nov 23 13:36:41 2006
@@ -84,9 +84,14 @@
         objectMethodLocal = pObjectMethodLocal;
     }
 
-    /** Creates an object, which is implementing the given interface.
+    /**
+     * Creates an object, which is implementing the given interface.
      * The objects methods are internally calling an XML-RPC server
-     * by using the factories client.
+     * by using the factories client; shortcut for
+     * <pre>
+     *   newInstance(Thread.currentThread().getContextClassLoader(),
+     *     pClass)
+     * </pre>
      */
     public Object newInstance(Class pClass) {
         return newInstance(Thread.currentThread().getContextClassLoader(), pClass);
@@ -94,15 +99,34 @@
 
     /** Creates an object, which is implementing the given interface.
      * The objects methods are internally calling an XML-RPC server
+     * by using the factories client; shortcut for
+     * <pre>
+     *   newInstance(pClassLoader, pClass, pClass.getName())
+     * </pre>
+     */
+    public Object newInstance(ClassLoader pClassLoader, Class pClass) {
+        return newInstance(pClassLoader, pClass, pClass.getName());
+    }
+
+    /** Creates an object, which is implementing the given interface.
+     * The objects methods are internally calling an XML-RPC server
      * by using the factories client.
+     * @param pClassLoader The class loader, which is being used for
+     *   loading classes, if required.
+     * @param pClass Interface, which is being implemented.
+     * @param pRemoteName Handler name, which is being used when
+     *   calling the server. This is used for composing the
+     *   method name. For example, if <code>pRemoteName</code>
+     *   is "Foo" and you want to invoke the method "bar" in
+     *   the handler, then the full method name would be "Foo.bar".
      */
-    public Object newInstance(ClassLoader pClassLoader, final Class pClass) {
-        return Proxy.newProxyInstance(pClassLoader, new Class[]{pClass}, new InvocationHandler(){
+    public Object newInstance(ClassLoader pClassLoader, final Class pClass, final String pRemoteName) {
+       return Proxy.newProxyInstance(pClassLoader, new Class[]{pClass}, new InvocationHandler(){
             public Object invoke(Object pProxy, Method pMethod, Object[] pArgs) throws Throwable {
                 if (isObjectMethodLocal()  &&  pMethod.getDeclaringClass().equals(Object.class)) {
                     return pMethod.invoke(pProxy, pArgs);
                 }
-                String methodName = pClass.getName() + "." + pMethod.getName();
+                String methodName = pRemoteName + "." + pMethod.getName();
                 Object result;
                 try {
                     result = client.execute(methodName, pArgs);

Modified: webservices/xmlrpc/trunk/pom.xml
URL: http://svn.apache.org/viewvc/webservices/xmlrpc/trunk/pom.xml?view=diff&rev=478678&r1=478677&r2=478678
==============================================================================
--- webservices/xmlrpc/trunk/pom.xml (original)
+++ webservices/xmlrpc/trunk/pom.xml Thu Nov 23 13:36:41 2006
@@ -178,6 +178,10 @@
             <email>matt@knowledgeview.co.uk</email>
         </contributor>
         <contributor>
+            <name>Eugene Prokopiev</name>
+            <email>prokopiev@stc.donpac.ru</email>
+        </contributor>
+        <contributor>
             <name>Ken Weiner</name>
             <email>kweiner@gmail.com</email>
         </contributor>

Modified: webservices/xmlrpc/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/webservices/xmlrpc/trunk/src/changes/changes.xml?view=diff&rev=478678&r1=478677&r2=478678
==============================================================================
--- webservices/xmlrpc/trunk/src/changes/changes.xml (original)
+++ webservices/xmlrpc/trunk/src/changes/changes.xml Thu Nov 23 13:36:41 2006
@@ -39,6 +39,11 @@
         This should allow users to prevent remote invocation of certain methods,
         for example initialization stuff.
       </action>
+      <action dev="jochen" type="add" issue="XMLRPC-126"
+          due-to="Eugene Prokopiev" due-to-email="prokopiev@stc.donpac.ru">
+        The ClientFactory is now able to use a custom name for the remote
+        handler. So far, it was always using the interface name.
+      </action>
     </release>
     <release version="3.0.1-SNAPSHOT" date="Not yet released">
       <action dev="jochen" type="fix">