You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by ha...@apache.org on 2002/04/18 08:35:41 UTC

cvs commit: jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl AbstractAltrmiFactory.java ClientClassAltrmiFactory.java ServerClassAltrmiFactory.java

hammant     02/04/17 23:35:41

  Modified:    altrmi/src/java/org/apache/excalibur/altrmi/client/impl
                        AbstractAltrmiFactory.java
                        ClientClassAltrmiFactory.java
                        ServerClassAltrmiFactory.java
  Log:
  lookup fixed for authenication and refactored to parent class
  
  Revision  Changes    Path
  1.3       +67 -1     jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/AbstractAltrmiFactory.java
  
  Index: AbstractAltrmiFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/AbstractAltrmiFactory.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AbstractAltrmiFactory.java	10 Apr 2002 23:36:58 -0000	1.2
  +++ AbstractAltrmiFactory.java	18 Apr 2002 06:35:41 -0000	1.3
  @@ -21,6 +21,10 @@
   import org.apache.excalibur.altrmi.common.OpenConnectionReply;
   import org.apache.excalibur.altrmi.common.ListRequest;
   import org.apache.excalibur.altrmi.common.ListReply;
  +import org.apache.excalibur.altrmi.common.AltrmiAuthentication;
  +import org.apache.excalibur.altrmi.common.NotPublishedReply;
  +import org.apache.excalibur.altrmi.common.ExceptionReply;
  +import org.apache.excalibur.altrmi.common.LookupReply;
   
   import java.util.HashMap;
   import java.util.Vector;
  @@ -34,7 +38,8 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.2 $
  + * @author Peter Royal <a href="mailto:proyal@managingpartners.com">proyal@managingpartners.com</a>
  + * @version $Revision: 1.3 $
    */
   public abstract class AbstractAltrmiFactory implements AltrmiFactory {
   
  @@ -96,6 +101,67 @@
               //TODO
           }
       }
  +
  +    /**
  +     * Method lookup
  +     *
  +     *
  +     * @param publishedServiceName
  +     * @param altrmiAuthentication
  +     *
  +     * @return
  +     *
  +     * @throws AltrmiConnectionException
  +     *
  +     */
  +    public Object lookup(String publishedServiceName, AltrmiAuthentication altrmiAuthentication)
  +            throws AltrmiConnectionException {
  +
  +        AltrmiReply ar =
  +            mHostContext.getInvocationHandler()
  +                .handleInvocation(new LookupRequest(publishedServiceName, altrmiAuthentication, mSession));
  +
  +        if (ar.getReplyCode() >= AltrmiReply.PROBLEMREPLY) {
  +            if (ar instanceof NotPublishedReply) {
  +                throw new AltrmiConnectionException("Service " + publishedServiceName
  +                                                    + " not published");
  +            } else if (ar instanceof ExceptionReply) {
  +                ExceptionReply er = (ExceptionReply) ar;
  +
  +                throw (AltrmiConnectionException) er.getReplyException();
  +            } else {
  +                throw new AltrmiConnectionException("Problem doing lookup on service");
  +            }
  +        } else if (ar instanceof ExceptionReply) {
  +            ExceptionReply er = (ExceptionReply) ar;
  +            Throwable t = er.getReplyException();
  +
  +            if (t instanceof AltrmiConnectionException) {
  +                throw (AltrmiConnectionException) t;
  +            } else if (t instanceof Error) {
  +                throw (Error) t;
  +            } else if (t instanceof RuntimeException) {
  +                throw (RuntimeException) t;
  +            } else {
  +                throw new AltrmiConnectionException("Problem doing lookup on service [exception: "
  +                                                    + t.getMessage() + "]");
  +            }
  +        } else if (!(ar instanceof LookupReply)) {
  +            throw new UnsupportedOperationException("Unexpected reply to lookup [reply: " + ar + "]");
  +        }
  +
  +        LookupReply lr = (LookupReply) ar;
  +        DefaultProxyHelper baseObj = new DefaultProxyHelper(this,
  +                                                        mHostContext.getInvocationHandler(),
  +                                                        publishedServiceName, "Main",
  +                                                        lr.getReferenceID(), mSession);
  +        Object retVal = getInstance(publishedServiceName, "Main", baseObj, isBeanOnly());
  +
  +        baseObj.registerImplObject(retVal);
  +
  +        return retVal;
  +     }
  +
   
       protected abstract Class getFacadeClass(String publishedServiceName, String objectName, boolean beanOnly) throws AltrmiConnectionException, ClassNotFoundException;
   
  
  
  
  1.3       +2 -56     jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/ClientClassAltrmiFactory.java
  
  Index: ClientClassAltrmiFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/ClientClassAltrmiFactory.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ClientClassAltrmiFactory.java	10 Apr 2002 23:36:58 -0000	1.2
  +++ ClientClassAltrmiFactory.java	18 Apr 2002 06:35:41 -0000	1.3
  @@ -8,20 +8,10 @@
    */
   package org.apache.excalibur.altrmi.client.impl;
   
  -
  -
  -import org.apache.excalibur.altrmi.client.AltrmiFactory;
  -import org.apache.excalibur.altrmi.client.AltrmiHostContext;
   import org.apache.excalibur.altrmi.common.AltrmiConnectionException;
  -import org.apache.excalibur.altrmi.common.LookupReply;
  -import org.apache.excalibur.altrmi.common.LookupRequest;
  -import org.apache.excalibur.altrmi.common.AltrmiReply;
  -import org.apache.excalibur.altrmi.common.NotPublishedReply;
  -import org.apache.excalibur.altrmi.common.AltrmiAuthentication;
  -import org.apache.excalibur.altrmi.common.ExceptionReply;
   
  -import java.lang.reflect.Constructor;
   import java.lang.reflect.InvocationTargetException;
  +import java.lang.reflect.Constructor;
   
   
   /**
  @@ -29,7 +19,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.2 $
  + * @version $Revision: 1.3 $
    */
   public class ClientClassAltrmiFactory extends AbstractAltrmiFactory {
   
  @@ -47,50 +37,6 @@
   //    public ClientClassAltrmiFactory(boolean beanOnly, ClassLoader classLoader) {
     //      super(beanOnly, classLoader);
       //}
  -
  -    /**
  -     * Method lookup
  -     *
  -     *
  -     * @param publishedServiceName
  -     * @param altrmiAuthentication
  -     *
  -     * @return
  -     *
  -     * @throws AltrmiConnectionException
  -     *
  -     */
  -    public Object lookup(String publishedServiceName, AltrmiAuthentication altrmiAuthentication)
  -            throws AltrmiConnectionException {
  -
  -        AltrmiReply ar =
  -            mHostContext.getInvocationHandler()
  -                .handleInvocation(new LookupRequest(publishedServiceName, altrmiAuthentication, mSession));
  -
  -        if (ar.getReplyCode() >= AltrmiReply.PROBLEMREPLY) {
  -            if (ar instanceof NotPublishedReply) {
  -                throw new AltrmiConnectionException("Service " + publishedServiceName
  -                                                    + " not published");
  -            } else if (ar instanceof ExceptionReply) {
  -                ExceptionReply er = (ExceptionReply) ar;
  -
  -                throw (AltrmiConnectionException) er.getReplyException();
  -            } else {
  -                throw new AltrmiConnectionException("Problem doing lookup on service");
  -            }
  -        }
  -
  -        LookupReply lr = (LookupReply) ar;
  -        DefaultProxyHelper baseObj = new DefaultProxyHelper(this,
  -                                                        mHostContext.getInvocationHandler(),
  -                                                        publishedServiceName, "Main",
  -                                                        lr.getReferenceID(), mSession);
  -        Object retVal = getInstance(publishedServiceName, "Main", baseObj, isBeanOnly());
  -
  -        baseObj.registerImplObject(retVal);
  -
  -        return retVal;
  -    }
   
       protected Class getFacadeClass(String publishedServiceName, String objectName, boolean beanOnly) throws AltrmiConnectionException, ClassNotFoundException {
           String code = "2";
  
  
  
  1.4       +4 -60     jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/ServerClassAltrmiFactory.java
  
  Index: ServerClassAltrmiFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/ServerClassAltrmiFactory.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ServerClassAltrmiFactory.java	10 Apr 2002 23:36:58 -0000	1.3
  +++ ServerClassAltrmiFactory.java	18 Apr 2002 06:35:41 -0000	1.4
  @@ -8,25 +8,15 @@
    */
   package org.apache.excalibur.altrmi.client.impl;
   
  -
  -
  -import org.apache.excalibur.altrmi.client.AltrmiFactory;
  -import org.apache.excalibur.altrmi.client.AltrmiHostContext;
  -import org.apache.excalibur.altrmi.common.ClassReply;
   import org.apache.excalibur.altrmi.common.AltrmiConnectionException;
  -import org.apache.excalibur.altrmi.common.ClassRequest;
  -import org.apache.excalibur.altrmi.common.NotPublishedException;
  -import org.apache.excalibur.altrmi.common.LookupReply;
  -import org.apache.excalibur.altrmi.common.LookupRequest;
  +import org.apache.excalibur.altrmi.common.ClassReply;
   import org.apache.excalibur.altrmi.common.AltrmiReply;
  -import org.apache.excalibur.altrmi.common.NotPublishedReply;
  +import org.apache.excalibur.altrmi.common.ClassRequest;
   import org.apache.excalibur.altrmi.common.RequestFailedReply;
  -import org.apache.excalibur.altrmi.common.AltrmiAuthentication;
  -import org.apache.excalibur.altrmi.common.ExceptionReply;
   import org.apache.excalibur.altrmi.common.ClassRetrievalFailedReply;
  +import org.apache.excalibur.altrmi.common.NotPublishedException;
   
   import java.util.HashMap;
  -
   import java.lang.reflect.Constructor;
   import java.lang.reflect.InvocationTargetException;
   
  @@ -36,7 +26,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.3 $
  + * @version $Revision: 1.4 $
    */
   public class ServerClassAltrmiFactory extends AbstractAltrmiFactory {
   
  @@ -52,52 +42,6 @@
        */
       public ServerClassAltrmiFactory(boolean beanOnly) {
           super(beanOnly);
  -    }
  -
  -
  -    /**
  -     * Method lookup
  -     *
  -     *
  -     * @param publishedServiceName
  -     * @param altrmiAuthentication
  -     *
  -     * @return
  -     *
  -     * @throws AltrmiConnectionException
  -     *
  -     */
  -    public Object lookup(String publishedServiceName, AltrmiAuthentication altrmiAuthentication)
  -            throws AltrmiConnectionException {
  -
  -        AltrmiReply ar =
  -            mHostContext.getInvocationHandler()
  -                .handleInvocation(new LookupRequest(publishedServiceName, altrmiAuthentication,
  -                                                    mSession));
  -
  -        if (ar.getReplyCode() >= AltrmiReply.PROBLEMREPLY) {
  -            if (ar instanceof NotPublishedReply) {
  -                throw new AltrmiConnectionException("Service " + publishedServiceName
  -                                                    + " not published");
  -            } else if (ar instanceof ExceptionReply) {
  -                ExceptionReply er = (ExceptionReply) ar;
  -
  -                throw (AltrmiConnectionException) er.getReplyException();
  -            } else {
  -                throw new AltrmiConnectionException("Problem doing lookup on service");
  -            }
  -        }
  -
  -        LookupReply lr = (LookupReply) ar;
  -        DefaultProxyHelper baseObj = new DefaultProxyHelper(this,
  -                                                        mHostContext.getInvocationHandler(),
  -                                                        publishedServiceName, "Main",
  -                                                        lr.getReferenceID(), mSession);
  -        Object retVal = getInstance(publishedServiceName, "Main", baseObj, isBeanOnly());
  -
  -        baseObj.registerImplObject(retVal);
  -
  -        return retVal;
       }
   
       protected Class getFacadeClass(String publishedServiceName, String objectName, boolean beanOnly) throws AltrmiConnectionException, ClassNotFoundException{
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>