commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hamm...@apache.org
Subject cvs commit: jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl/classretrievers JarFileClassRetriever.java
Date Sat, 26 Jan 2002 13:51:34 GMT
hammant     02/01/26 05:51:34

  Modified:    altrmi   build.xml tests.xml
               altrmi/src/java/org/apache/commons/altrmi/client/impl/stream
                        StreamInvocationHandler.java
               altrmi/src/java/org/apache/commons/altrmi/common
                        ClassReply.java
               altrmi/src/java/org/apache/commons/altrmi/server/impl
                        AbstractServer.java
               altrmi/src/java/org/apache/commons/altrmi/server/impl/classretrievers
                        JarFileClassRetriever.java
  Log:
  Fixed remote class retrieval
  
  Revision  Changes    Path
  1.4       +2 -2      jakarta-commons-sandbox/altrmi/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/build.xml,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- build.xml	25 Jan 2002 16:40:13 -0000	1.3
  +++ build.xml	26 Jan 2002 13:51:34 -0000	1.4
  @@ -3,7 +3,7 @@
   
   <!--
           "Alternative (to) RMI" component of the Jakarta Commons Subproject
  -        $Id: build.xml,v 1.3 2002/01/25 16:40:13 hammant Exp $
  +        $Id: build.xml,v 1.4 2002/01/26 13:51:34 hammant Exp $
   -->
   
   
  @@ -220,7 +220,7 @@
               basedir="${build.home}/classes"
              manifest="src/conf/MANIFEST-generator.MF">
         <include name="org/apache/commons/altrmi/generator/**"/>
  -      <include name="org/apache/commons/altrmi/compiler/**"/>
  +      <include name="org/apache/commons/altrmi/javacompiler/**"/>
       </jar> 
                  
     </target>
  
  
  
  1.3       +1 -26     jakarta-commons-sandbox/altrmi/tests.xml
  
  Index: tests.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/tests.xml,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- tests.xml	25 Jan 2002 16:40:13 -0000	1.2
  +++ tests.xml	26 Jan 2002 13:51:34 -0000	1.3
  @@ -3,7 +3,7 @@
   
   <!--
           "Alt (to) RMI" component of the Jakarta Commons Subproject
  -        $Id: tests.xml,v 1.2 2002/01/25 16:40:13 hammant Exp $
  +        $Id: tests.xml,v 1.3 2002/01/26 13:51:34 hammant Exp $
   -->
   
   
  @@ -95,31 +95,6 @@
           <pathelement location="${build.home}/classes"/>
         </classpath>
       </altrmiinterfaces>        
  -
  -    <!--
  -    <javac  srcdir="${build.home}/genjava"
  -               destdir="${build.home}/classes2"
  -                 debug="${compile.debug}"
  -           deprecation="${compile.deprecation}"
  -              optimize="${compile.optimize}">
  -          <classpath refid="compile.classpath"/>
  -    </javac>
  -    
  -
  -  
  -    <altrmiclassintern gendir="${build.home}/genjava2" 
  -        sourceclassdir="${build.home}/classes2/"
  -        publishedname="Hello" />  
  -
  -    <javac  srcdir="${build.home}/genjava2"
  -               destdir="${build.home}/classes3"
  -                 debug="${compile.debug}"
  -           deprecation="${compile.deprecation}"
  -              optimize="${compile.optimize}">
  -          <classpath refid="compile.classpath"/>
  -    </javac>
  -    
  -    -->
     
     </target>
   
  
  
  
  1.4       +2 -2      jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/client/impl/stream/StreamInvocationHandler.java
  
  Index: StreamInvocationHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/client/impl/stream/StreamInvocationHandler.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- StreamInvocationHandler.java	21 Jan 2002 20:10:34 -0000	1.3
  +++ StreamInvocationHandler.java	26 Jan 2002 13:51:34 -0000	1.4
  @@ -37,7 +37,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 abstract class StreamInvocationHandler extends AbstractClientInvocationHandler {
   
  @@ -123,7 +123,7 @@
                       } catch (IOException ioe) {
                           if (ioe instanceof SocketException
                                   | ioe instanceof EOFException
  -                                | ioe.getMessage().equals("Read end dead")
  +                                | (ioe.getMessage() != null && ioe.getMessage().equals("Read
end dead") )
                                   ) {
                               int retryConnectTries = 0;
   
  
  
  
  1.4       +5 -5      jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/common/ClassReply.java
  
  Index: ClassReply.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/common/ClassReply.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ClassReply.java	18 Jan 2002 11:03:20 -0000	1.3
  +++ ClassReply.java	26 Jan 2002 13:51:34 -0000	1.4
  @@ -20,7 +20,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 final class ClassReply extends AltrmiReply {
   
  @@ -97,8 +97,8 @@
        * @exception IOException Includes any I/O exceptions that may occur
        */
       public void writeExternal(ObjectOutput out) throws IOException {
  -        out.write(mBeanClassBytes);
  -        out.write(mInterfaceImplClassBytes);
  +        out.writeObject(mBeanClassBytes);
  +        out.writeObject(mInterfaceImplClassBytes);
       }
   
       /**
  @@ -114,7 +114,7 @@
        *              restored cannot be found.
        */
       public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
{
  -        in.read(mBeanClassBytes);
  -        in.read(mInterfaceImplClassBytes);
  +        mBeanClassBytes = (byte[]) in.readObject();
  +        mInterfaceImplClassBytes = (byte[]) in.readObject();
       }
   }
  
  
  
  1.12      +4 -4      jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl/AbstractServer.java
  
  Index: AbstractServer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl/AbstractServer.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- AbstractServer.java	25 Jan 2002 16:40:14 -0000	1.11
  +++ AbstractServer.java	26 Jan 2002 13:51:34 -0000	1.12
  @@ -57,7 +57,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.11 $
  + * @version $Revision: 1.12 $
    */
   public abstract class AbstractServer extends AbstractMethodHandler implements AltrmiServer
{
   
  @@ -360,15 +360,15 @@
               //TODO a decent ref number for main?
               return new LookupReply(new Long(0));
           } else if (request.getRequestCode() == AltrmiRequest.CLASSREQUEST) {
  +            ClassRequest cr = (ClassRequest) request;
  +            String publishedThing = cr.getPublishedServiceName() + "_" + cr.getObjectName();
               try {
  -                ClassRequest cr = (ClassRequest) request;
  -                String publishedThing = cr.getPublishedServiceName() + "_" + cr.getObjectName();
   
                   return new ClassReply(mClassRetriever.getBeanBytes(publishedThing),
                                         mClassRetriever
                                             .getInterfaceImplementationBytes(publishedThing));
               } catch (ClassRetrievalException e) {
  -                return new RequestFailedReply(e.getMessage());
  +                return new ExceptionReply(new ClassNotFoundException("AltRMI Server exception
- " + publishedThing + " not found"));
               }
           } else if (request.getRequestCode() == AltrmiRequest.OPENCONNECTIONREQUEST) {
               Long session = getNewSession();
  
  
  
  1.3       +15 -4     jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl/classretrievers/JarFileClassRetriever.java
  
  Index: JarFileClassRetriever.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl/classretrievers/JarFileClassRetriever.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- JarFileClassRetriever.java	21 Jan 2002 15:38:21 -0000	1.2
  +++ JarFileClassRetriever.java	26 Jan 2002 13:51:34 -0000	1.3
  @@ -27,7 +27,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 JarFileClassRetriever extends AbstractClassRetriever {
   
  @@ -41,6 +41,7 @@
        *
        */
       public JarFileClassRetriever(URL urlOfJarFile) {
  +        System.out.println("URL1 " + urlOfJarFile);
           mURLClassLoader = new URLClassLoader(new URL[]{ urlOfJarFile });
       }
   
  @@ -52,6 +53,7 @@
        *
        */
       public JarFileClassRetriever(URL[] urlsOfJarFiles) {
  +        System.out.println("URL2 " + urlsOfJarFiles[0]);
           mURLClassLoader = new URLClassLoader(urlsOfJarFiles);
       }
   
  @@ -66,6 +68,8 @@
        */
       public JarFileClassRetriever(String[] pathsOfJarFiles) throws MalformedURLException
{
   
  +        System.out.println("URL3 " + pathsOfJarFiles[0]);
  +
           URL[] urls = new URL[pathsOfJarFiles.length];
   
           for (int i = 0; i < pathsOfJarFiles.length; i++) {
  @@ -85,6 +89,9 @@
        *
        */
       public JarFileClassRetriever(String pathOfJarFile) throws MalformedURLException {
  +
  +        System.out.println("URL4 " + pathOfJarFile);
  +
           mURLClassLoader = new URLClassLoader(new URL[]{ new File(pathOfJarFile).toURL()
});
       }
   
  @@ -101,15 +108,19 @@
        */
       public byte[] getThingBytes(String thingName) throws ClassRetrievalException {
   
  +        thingName = thingName.replace('.','/') + ".class";
  +
           try {
  -            URL rsc = mURLClassLoader.findResource(thingName);
  -            InputStream is = rsc.openStream();
  +            InputStream is = mURLClassLoader.getResourceAsStream(thingName);
  +            if (is == null) {
  +                throw new ClassRetrievalException("Generated class not found in Jar on
server");
  +            }
               byte[] bytes = new byte[is.available()];
  -
               is.read(bytes);
   
               return bytes;
           } catch (java.io.IOException e) {
  +            e.printStackTrace();
               throw new ClassRetrievalException("Generated class not found in Jar on server");
           }
       }
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message