OW2 Consortium
Search OW2 Mail Archive: 

Advanced Search - Powered by Google


Mail Archive Home | fractal-commits List | March 2006 Index

<--  Date Index  --> <--  Thread Index  -->

CVS update of aokell (9 files)


    Date: Sunday, March 26, 2006 @ 14:24:34
  Author: seintur
    Path: /cvsroot/fractal/aokell

Modified: 
features/fcinterface/rt/src/org/objectweb/fractal/aokell/lib/asm/ASMGeneratorForBoundableInterface.java
          
          
features/fcinterface/rt/src/org/objectweb/fractal/aokell/lib/asm/ASMGeneratorForImplementedInterface.java
          
          
features/fcinterface/rt/src/org/objectweb/fractal/aokell/lib/asm/DelegatorClassLoader.java
          
          
features/fcinterface/rt/src/org/objectweb/fractal/aokell/lib/interf/DelegatorHelper.java
           src/org/objectweb/fractal/aokell/AOKell.java
          
src/org/objectweb/fractal/aokell/lib/control/component/CompositeComponentImpl.java
          
          src/org/objectweb/fractal/aokell/lib/factory/GenericFactoryImpl.java
          
          src/org/objectweb/fractal/aokell/lib/factory/TypeFactoryImpl.java
          
          src/org/objectweb/fractal/aokell/lib/type/InterfaceTypeImpl.java

Bug fix for remote downlaoding of communication stub code with RMIClassLoader.


-----------------------------------------------------------------------------------------------------------+
 
features/fcinterface/rt/src/org/objectweb/fractal/aokell/lib/asm/ASMGeneratorForBoundableInterface.java
   |    7 +
 
features/fcinterface/rt/src/org/objectweb/fractal/aokell/lib/asm/ASMGeneratorForImplementedInterface.java
 |    7 +
 
features/fcinterface/rt/src/org/objectweb/fractal/aokell/lib/asm/DelegatorClassLoader.java
                |   38 +++++++--
 
features/fcinterface/rt/src/org/objectweb/fractal/aokell/lib/interf/DelegatorHelper.java
                  |    4 -
 src/org/objectweb/fractal/aokell/AOKell.java                                 
                             |   39 ++++++++--
 
src/org/objectweb/fractal/aokell/lib/control/component/CompositeComponentImpl.java
                        |    2 
 src/org/objectweb/fractal/aokell/lib/factory/GenericFactoryImpl.java         
                             |   12 +--
 src/org/objectweb/fractal/aokell/lib/factory/TypeFactoryImpl.java            
                             |    2 
 src/org/objectweb/fractal/aokell/lib/type/InterfaceTypeImpl.java             
                             |    2 
 9 files changed, 87 insertions(+), 26 deletions(-)


Index: 
aokell/features/fcinterface/rt/src/org/objectweb/fractal/aokell/lib/asm/ASMGeneratorForBoundableInterface.java
diff -u 
aokell/features/fcinterface/rt/src/org/objectweb/fractal/aokell/lib/asm/ASMGeneratorForBoundableInterface.java:1.3
 
aokell/features/fcinterface/rt/src/org/objectweb/fractal/aokell/lib/asm/ASMGeneratorForBoundableInterface.java:1.4
--- 
aokell/features/fcinterface/rt/src/org/objectweb/fractal/aokell/lib/asm/ASMGeneratorForBoundableInterface.java:1.3
  Tue Mar  7 13:11:49 2006
+++ 
aokell/features/fcinterface/rt/src/org/objectweb/fractal/aokell/lib/asm/ASMGeneratorForBoundableInterface.java
      Sun Mar 26 14:24:33 2006
@@ -24,6 +24,7 @@
 package org.objectweb.fractal.aokell.lib.asm;
 
 import java.io.IOException;
+import java.io.InputStream;
 import java.util.HashSet;
 import java.util.Set;
 
@@ -35,6 +36,7 @@
 import org.objectweb.asm.FieldVisitor;
 import org.objectweb.asm.MethodVisitor;
 import org.objectweb.asm.Opcodes;
+import org.objectweb.fractal.aokell.AOKell;
 import org.objectweb.fractal.aokell.lib.InterfaceImpl;
 import org.objectweb.fractal.aokell.lib.interf.AOKellGeneratedItf;
 import org.objectweb.fractal.aokell.lib.interf.ClassDefinition;
@@ -100,7 +102,10 @@
             new CompositeClassVisitor(cw,targetSignature,delegateSignature);
         ClassReader cr;
         try {
-            cr = new ClassReader(delegateClassname);
+            InputStream is =
+                AOKell.getResourceAsStream(
+                        delegateClassname.replace('.','/')+".class" );
+            cr = new ClassReader(is);
         }
         catch( IOException e ) {
             throw new RuntimeException(e);
Index: 
aokell/features/fcinterface/rt/src/org/objectweb/fractal/aokell/lib/asm/ASMGeneratorForImplementedInterface.java
diff -u 
aokell/features/fcinterface/rt/src/org/objectweb/fractal/aokell/lib/asm/ASMGeneratorForImplementedInterface.java:1.3
 
aokell/features/fcinterface/rt/src/org/objectweb/fractal/aokell/lib/asm/ASMGeneratorForImplementedInterface.java:1.4
--- 
aokell/features/fcinterface/rt/src/org/objectweb/fractal/aokell/lib/asm/ASMGeneratorForImplementedInterface.java:1.3
        Tue Mar  7 13:11:49 2006
+++ 
aokell/features/fcinterface/rt/src/org/objectweb/fractal/aokell/lib/asm/ASMGeneratorForImplementedInterface.java
    Sun Mar 26 14:24:33 2006
@@ -24,6 +24,7 @@
 package org.objectweb.fractal.aokell.lib.asm;
 
 import java.io.IOException;
+import java.io.InputStream;
 import java.util.HashSet;
 import java.util.Set;
 
@@ -35,6 +36,7 @@
 import org.objectweb.asm.FieldVisitor;
 import org.objectweb.asm.MethodVisitor;
 import org.objectweb.asm.Opcodes;
+import org.objectweb.fractal.aokell.AOKell;
 import org.objectweb.fractal.aokell.lib.InterfaceImpl;
 import org.objectweb.fractal.aokell.lib.interf.AOKellGeneratedItf;
 import org.objectweb.fractal.aokell.lib.interf.ClassDefinition;
@@ -136,7 +138,10 @@
             new DFIIClassVisitor(cw,targetSignature,delegateSignature);
         ClassReader cr;
         try {
-            cr = new ClassReader(delegateClassname);
+            InputStream is =
+                AOKell.getResourceAsStream(
+                        delegateClassname.replace('.','/')+".class" );
+            cr = new ClassReader(is);
         }
         catch( IOException e ) {
             throw new RuntimeException(delegateClassname+": "+e);
Index: 
aokell/features/fcinterface/rt/src/org/objectweb/fractal/aokell/lib/asm/DelegatorClassLoader.java
diff -u 
aokell/features/fcinterface/rt/src/org/objectweb/fractal/aokell/lib/asm/DelegatorClassLoader.java:1.1
 
aokell/features/fcinterface/rt/src/org/objectweb/fractal/aokell/lib/asm/DelegatorClassLoader.java:1.2
--- 
aokell/features/fcinterface/rt/src/org/objectweb/fractal/aokell/lib/asm/DelegatorClassLoader.java:1.1
       Sat Feb 11 06:43:57 2006
+++ 
aokell/features/fcinterface/rt/src/org/objectweb/fractal/aokell/lib/asm/DelegatorClassLoader.java
   Sun Mar 26 14:24:33 2006
@@ -34,17 +34,41 @@
  */
 public class DelegatorClassLoader extends ClassLoader {
     
-    /**
-     * Implementation of the Singleton pattern.
-     * @return the singleton instance of this class
+    /*
+     * Thread.currentThread().setContextClassLoader() is needed as a parent 
of
+     * this class loader to provide a correct behavior with the 
RMIClassLoader
+     * used by fractalrmi.
+     * 
+     * RMIClassLoader is needed when one remotely downloads code (e.g. 
+     * communication stubs) with the java.rmi.server.codebase property.
      */
-    public static DelegatorClassLoader get() { return dcl; }
-    private static DelegatorClassLoader dcl = new DelegatorClassLoader();
-    
+
     private DelegatorClassLoader() {
-        super();
+        super(Thread.currentThread().getContextClassLoader());
+    }
+    
+    /** Return the singleton instance of this class. */
+    public static DelegatorClassLoader get() {
+        if( singleton == null ||
+            singleton.getParent() !=
+                Thread.currentThread().getContextClassLoader() ) {
+            
+            /*
+             * The context class loader may change, for example, when 
fractalrmi
+             * uses the java.rmi.server.coebase property.
+             * 
+             * @see org.objectweb.fractal.aokell.AOKell#setLoader(Object) for
+             * the explanation on the use of
+             * Thread.currentThread().getContextClassLoader().
+             */
+            
+            singleton = new DelegatorClassLoader();
+        }
+        return singleton;
     }
     
+    private static DelegatorClassLoader singleton;;
+    
     public ClassDefinition load(String name, byte[] b) {
         return new ClassDefinition( defineClass(name,b,0,b.length), b );
     }
Index: 
aokell/features/fcinterface/rt/src/org/objectweb/fractal/aokell/lib/interf/DelegatorHelper.java
diff -u 
aokell/features/fcinterface/rt/src/org/objectweb/fractal/aokell/lib/interf/DelegatorHelper.java:1.1
 
aokell/features/fcinterface/rt/src/org/objectweb/fractal/aokell/lib/interf/DelegatorHelper.java:1.2
--- 
aokell/features/fcinterface/rt/src/org/objectweb/fractal/aokell/lib/interf/DelegatorHelper.java:1.1
 Tue Mar  7 13:11:49 2006
+++ 
aokell/features/fcinterface/rt/src/org/objectweb/fractal/aokell/lib/interf/DelegatorHelper.java
     Sun Mar 26 14:24:34 2006
@@ -74,7 +74,7 @@
             System.getProperty(AOKell.USE_GENERATED_CACHE_PROP_NAME,null);
         if( cachedir != null ) {
             try {
-                return AOKell.getLoader().loadClass(targetClassname);
+                return AOKell.loadClass(targetClassname);
             }
             catch( ClassNotFoundException cnfe) {}
         }
@@ -102,7 +102,7 @@
         }
         
         // Defensive programming. Check a frequently encountered problem.
-        Class itf = AOKell.getLoader().loadClass(javaItfSignature);
+        Class itf = AOKell.loadClass(javaItfSignature);
         if( ! itf.isAssignableFrom(cd.cl) ) {
             throw new RuntimeException(
                     "Content class "+cd.cl.getName()+
Index: aokell/src/org/objectweb/fractal/aokell/AOKell.java
diff -u aokell/src/org/objectweb/fractal/aokell/AOKell.java:1.6 
aokell/src/org/objectweb/fractal/aokell/AOKell.java:1.7
--- aokell/src/org/objectweb/fractal/aokell/AOKell.java:1.6     Fri Mar 24 
10:41:58 2006
+++ aokell/src/org/objectweb/fractal/aokell/AOKell.java Sun Mar 26 14:24:34 
2006
@@ -24,6 +24,8 @@
 package org.objectweb.fractal.aokell;
 
 
+import java.io.InputStream;
+
 import org.objectweb.fractal.aokell.lib.factory.GenericFactoryImpl;
 import org.objectweb.fractal.aokell.lib.type.ComponentTypeImpl;
 import org.objectweb.fractal.aokell.lib.type.InterfaceTypeImpl;
@@ -120,17 +122,42 @@
                 });
     
     final public static Object CONTROLLER_DESC = "bootstrap";
+
     
-    /** The loader used by AOKell to load classes. */
-    private static ClassLoader loader = ClassLoader.getSystemClassLoader();
-    
+    // ------------------------------------------------------------------
+    // Class and ressource loading primitives
+    // ------------------------------------------------------------------
+    
+    /*
+     * Thread.currentThread().setContextClassLoader() is needed to provide a
+     * correct behavior with the RMIClassLoader used by fractalrmi.
+     * 
+     * RMIClassLoader is needed when one remotely downloads code (e.g.
+     * communication stubs) with the java.rmi.server.codebase property.
+     */
+
     /**
      * Set the loader to be used by AOKell for loading classes.
+     * 
+     * @param cl  the loader.
+     *      This parameter must implement ClassLoader. It is declared as an
+     *      Object in order to be compliant with the J2ME version of AOKell.
      */
-    public static void setLoader( ClassLoader cl ) { loader=cl; }
+    public static void setLoader( Object cl ) {
+        Thread.currentThread().setContextClassLoader( (ClassLoader) cl );
+    }
+
+    /**
+     * Load a class.
+     */
+    public static Class loadClass(String name) throws ClassNotFoundException 
{
+        return 
Thread.currentThread().getContextClassLoader().loadClass(name);
+    }
     
     /**
-     * Return the loader used by AOKell for loading classes.
+     * Load a ressource.
      */
-    public static ClassLoader getLoader() { return loader; }
+    public static InputStream getResourceAsStream( String name ) {
+        return 
Thread.currentThread().getContextClassLoader().getResourceAsStream(name);
+    }
 }
Index: 
aokell/src/org/objectweb/fractal/aokell/lib/control/component/CompositeComponentImpl.java
diff -u 
aokell/src/org/objectweb/fractal/aokell/lib/control/component/CompositeComponentImpl.java:1.3
 
aokell/src/org/objectweb/fractal/aokell/lib/control/component/CompositeComponentImpl.java:1.4
--- 
aokell/src/org/objectweb/fractal/aokell/lib/control/component/CompositeComponentImpl.java:1.3
       Tue Mar  7 13:11:49 2006
+++ 
aokell/src/org/objectweb/fractal/aokell/lib/control/component/CompositeComponentImpl.java
   Sun Mar 26 14:24:34 2006
@@ -62,7 +62,7 @@
              */
             Class jit = null;
             try {
-                jit = AOKell.getLoader().loadClass(it.getFcItfSignature());
+                jit = AOKell.loadClass(it.getFcItfSignature());
             }
             catch( ClassNotFoundException cnfe ) {
                 /*
Index: 
aokell/src/org/objectweb/fractal/aokell/lib/factory/GenericFactoryImpl.java
diff -u 
aokell/src/org/objectweb/fractal/aokell/lib/factory/GenericFactoryImpl.java:1.3
 
aokell/src/org/objectweb/fractal/aokell/lib/factory/GenericFactoryImpl.java:1.4
--- 
aokell/src/org/objectweb/fractal/aokell/lib/factory/GenericFactoryImpl.java:1.3
     Thu Mar 23 13:40:44 2006
+++ 
aokell/src/org/objectweb/fractal/aokell/lib/factory/GenericFactoryImpl.java 
Sun Mar 26 14:24:34 2006
@@ -61,7 +61,7 @@
         }
         else {
             try {
-                Class cl = AOKell.getLoader().loadClass(gfClassName);
+                Class cl = AOKell.loadClass(gfClassName);
                 singleton = (GenericFactoryImpl) cl.newInstance();
             }
             catch( Exception e ) {
@@ -157,7 +157,7 @@
          */
         Class cl;
         try {
-            cl = AOKell.getLoader().loadClass(contentDescStr);
+            cl = AOKell.loadClass(contentDescStr);
         }
         catch(ClassNotFoundException cnfe) {
             throw new InstantiationException(
@@ -200,7 +200,7 @@
         for (int i = 0; i < its.length; i++) {
             String itSignature = its[i].getFcItfSignature();
             try {
-                AOKell.getLoader().loadClass(itSignature);
+                AOKell.loadClass(itSignature);
             }
             catch(ClassNotFoundException cnfe) {
                 throw new InstantiationException(
@@ -295,7 +295,7 @@
     throws InstantiationException {
         
         try {
-            return AOKell.getLoader().loadClass(contentDescStr);
+            return AOKell.loadClass(contentDescStr);
         }
         catch(ClassNotFoundException cnfe) {
             throw new InstantiationException(
@@ -321,7 +321,7 @@
                 // but we need the class here anyway
                 Class itClass;
                 try {
-                    itClass = AOKell.getLoader().loadClass(itSignature);
+                    itClass = AOKell.loadClass(itSignature);
                 }
                 catch(ClassNotFoundException cnfe) {
                     throw new InstantiationException(
@@ -357,7 +357,7 @@
                 // but we need the class here anyway
                 Class itClass;
                 try {
-                    itClass = AOKell.getLoader().loadClass(itSignature);
+                    itClass = AOKell.loadClass(itSignature);
                 }
                 catch(ClassNotFoundException cnfe) {
                     throw new InstantiationException(
Index: 
aokell/src/org/objectweb/fractal/aokell/lib/factory/TypeFactoryImpl.java
diff -u 
aokell/src/org/objectweb/fractal/aokell/lib/factory/TypeFactoryImpl.java:1.1 
aokell/src/org/objectweb/fractal/aokell/lib/factory/TypeFactoryImpl.java:1.2
--- 
aokell/src/org/objectweb/fractal/aokell/lib/factory/TypeFactoryImpl.java:1.1  
      Sat Feb 11 06:43:53 2006
+++ aokell/src/org/objectweb/fractal/aokell/lib/factory/TypeFactoryImpl.java  
  Sun Mar 26 14:24:34 2006
@@ -143,7 +143,7 @@
             // ------------------------
             String signature = itf.getFcItfSignature();
             try {
-                Class cl = AOKell.getLoader().loadClass(signature);
+                Class cl = AOKell.loadClass(signature);
                 if( ! cl.isInterface() )
                     throw new InstantiationException(
                             signature+": not an interface");
Index: aokell/src/org/objectweb/fractal/aokell/lib/type/InterfaceTypeImpl.java
diff -u 
aokell/src/org/objectweb/fractal/aokell/lib/type/InterfaceTypeImpl.java:1.2 
aokell/src/org/objectweb/fractal/aokell/lib/type/InterfaceTypeImpl.java:1.3
--- 
aokell/src/org/objectweb/fractal/aokell/lib/type/InterfaceTypeImpl.java:1.2 
Sat Feb 25 22:22:16 2006
+++ aokell/src/org/objectweb/fractal/aokell/lib/type/InterfaceTypeImpl.java   
  Sun Mar 26 14:24:34 2006
@@ -169,7 +169,7 @@
         if( fcItfClass != null )
             return fcItfClass;
         
-        fcItfClass = AOKell.getLoader().loadClass(getFcItfSignature());
+        fcItfClass = AOKell.loadClass(getFcItfSignature());
         return fcItfClass;
     }
 



<--  Date Index  --> <--  Thread Index  -->

Reply via email to:

Powered by MHonArc.

Copyright © 2006-2007, OW2 Consortium | contact | webmaster.