OW2 Consortium
Search OW2 Mail Archive: 

Advanced Search - Powered by Google


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

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

CVS update of julia/src/org/objectweb/fractal/juliak (8 files)


    Date: Thursday, December 21, 2006 @ 11:46:58
  Author: seintur
    Path: /cvsroot/fractal/julia/src/org/objectweb/fractal/juliak

Modified: BootstrapComponentImpl.java Juliak.java
          factory/AbstractGenericFactoryImpl.java
          factory/CompBasedMembraneGenericFactoryImpl.java
          factory/TypeFactoryImpl.java membrane/MembraneDef.java
          membrane/StaticMembraneFactory.java
          membrane/backend/MembraneCompiler.java

Refactoring to let the provider class and the bootstrap class be more easily 
extended.


--------------------------------------------------+
 BootstrapComponentImpl.java                      |    6 --
 Juliak.java                                      |   55 +++++++++++++++++++--
 factory/AbstractGenericFactoryImpl.java          |   35 -------------
 factory/CompBasedMembraneGenericFactoryImpl.java |    6 +-
 factory/TypeFactoryImpl.java                     |    6 --
 membrane/MembraneDef.java                        |    7 +-
 membrane/StaticMembraneFactory.java              |   11 +++-
 membrane/backend/MembraneCompiler.java           |   15 ++---
 8 files changed, 78 insertions(+), 63 deletions(-)


Index: julia/src/org/objectweb/fractal/juliak/BootstrapComponentImpl.java
diff -u 
julia/src/org/objectweb/fractal/juliak/BootstrapComponentImpl.java:1.6 
julia/src/org/objectweb/fractal/juliak/BootstrapComponentImpl.java:1.7
--- julia/src/org/objectweb/fractal/juliak/BootstrapComponentImpl.java:1.6    
  Wed Dec 20 22:08:20 2006
+++ julia/src/org/objectweb/fractal/juliak/BootstrapComponentImpl.java  Thu 
Dec 21 11:46:57 2006
@@ -30,8 +30,6 @@
 import org.objectweb.fractal.api.type.ComponentType;
 import org.objectweb.fractal.api.type.InterfaceType;
 import org.objectweb.fractal.api.type.TypeFactory;
-import org.objectweb.fractal.juliak.factory.AbstractGenericFactoryImpl;
-import org.objectweb.fractal.juliak.factory.TypeFactoryImpl;
 
 
 /**
@@ -50,7 +48,7 @@
     // Implementation of the TypeFactory interface
     // -----------------------------------------------------------------
     
-    private TypeFactory tf = TypeFactoryImpl.get();
+    private TypeFactory tf = Juliak.get().getFcTypeFactory();
     
     public InterfaceType createFcItfType(
             String name, String signature,
@@ -71,7 +69,7 @@
     // Implementation of the GenericFactory interface
     // -----------------------------------------------------------------
     
-    private GenericFactory gf = AbstractGenericFactoryImpl.get();
+    private GenericFactory gf = Juliak.get().getFcGenericFactory();
     
     public Component newFcInstance(
             Type type, Object controllerDesc, Object contentDesc)
Index: julia/src/org/objectweb/fractal/juliak/Juliak.java
diff -u julia/src/org/objectweb/fractal/juliak/Juliak.java:1.6 
julia/src/org/objectweb/fractal/juliak/Juliak.java:1.7
--- julia/src/org/objectweb/fractal/juliak/Juliak.java:1.6      Mon Dec 18 
22:12:24 2006
+++ julia/src/org/objectweb/fractal/juliak/Juliak.java  Thu Dec 21 11:46:57 
2006
@@ -33,7 +33,8 @@
 import org.objectweb.fractal.api.type.TypeFactory;
 import org.objectweb.fractal.julia.type.BasicComponentType;
 import org.objectweb.fractal.julia.type.BasicInterfaceType;
-import org.objectweb.fractal.juliak.factory.AbstractGenericFactoryImpl;
+import 
org.objectweb.fractal.juliak.factory.CompBasedMembraneGenericFactoryImpl;
+import org.objectweb.fractal.juliak.factory.TypeFactoryImpl;
 
 
 /**
@@ -46,6 +47,30 @@
     
     public Juliak() {}
     
+    /**
+     * Return an instance of the Fractal provider class.
+     * This method is meant to allow subclassing Juliak.
+     * This method is thus more general than the default public constructor.
+     */
+    public static Juliak get() {
+
+        String bootTmplClassName = System.getProperty("fractal.provider");
+        if (bootTmplClassName == null) {
+            throw new RuntimeException(
+                "The fractal.provider system property is not defined");
+        }
+
+        try {
+            Class bootTmplClass = Class.forName(bootTmplClassName);
+            Object o = bootTmplClass.newInstance();
+            return (Juliak) o;
+        }
+        catch (Exception e) {
+            throw new RuntimeException(
+                "Cannot find or instantiate the '" + bootTmplClassName +
+                "' class specified in the fractal.provider system property");
+        }
+    }
     
     /**
      * Property name for dumping run-time generated code.
@@ -112,7 +137,8 @@
     
     /**
      * Return the reference of the bootstrap component.
-     * This method is called by Fractal.getBootstrapComponent().
+     * This method is called by {@link
+     * org.objectweb.fractal.api.Fractal#getBootstrapComponent()}
      * The bootstrap component provides the following interfaces:
      * <ul>
      * <li> {@link TypeFactory} </li>
@@ -125,7 +151,7 @@
             return bootstrap;
                 
         // Create the bootstrap component
-        GenericFactory gf = AbstractGenericFactoryImpl.get();
+        GenericFactory gf = getFcGenericFactory();
         bootstrap =
             gf.newFcInstance(
                     getFcInstanceType(),
@@ -137,4 +163,27 @@
 
     private static ComponentType TYPE = null;    
     final private static Object CONTROLLER_DESC = "bootstrap";
+
+    
+    // ----------------------------------------------------------
+    // Implementation specific
+    // ----------------------------------------------------------
+    
+    private static TypeFactory tf;
+    private static GenericFactory gf;
+    
+    public TypeFactory getFcTypeFactory() {
+        if( tf == null ) {
+            tf = new TypeFactoryImpl();
+        }
+        return tf;
+    }
+    
+    public GenericFactory getFcGenericFactory() {
+        if( gf == null ) {
+            gf = new CompBasedMembraneGenericFactoryImpl();
+        }
+        return gf;
+    }
+
 }
Index: 
julia/src/org/objectweb/fractal/juliak/factory/AbstractGenericFactoryImpl.java
diff -u 
julia/src/org/objectweb/fractal/juliak/factory/AbstractGenericFactoryImpl.java:1.2
 
julia/src/org/objectweb/fractal/juliak/factory/AbstractGenericFactoryImpl.java:1.3
--- 
julia/src/org/objectweb/fractal/juliak/factory/AbstractGenericFactoryImpl.java:1.2
  Wed Dec 20 21:29:35 2006
+++ 
julia/src/org/objectweb/fractal/juliak/factory/AbstractGenericFactoryImpl.java
      Thu Dec 21 11:46:57 2006
@@ -49,41 +49,6 @@
 public abstract class AbstractGenericFactoryImpl implements GenericFactory {
     
     /**
-     * The property name which defines the implementation class for the 
generic
-     * factory. The value must be a sub-class of GenericFactoryImpl.
-     * The default value is GenericFactoryImpl.
-     */ 
-    public static final String GEN_FACT_IMPL =
-        "org.objectweb.fractal.juliak.genericfactory";
-    
-    /** The singleton instance of itself. */
-    private static GenericFactory singleton;
-    
-    /*
-     * Initialize the singleton instance of itself.
-     */
-    static {
-        String gfClassName = System.getProperty(GEN_FACT_IMPL);
-        if( gfClassName==null || gfClassName.length()==0 ) {
-            singleton = new CompBasedMembraneGenericFactoryImpl();
-        }
-        else {
-            try {
-                Class cl = Platform.get().loadClass(gfClassName);
-                singleton = (GenericFactory) cl.newInstance();
-            }
-            catch( Exception e ) {
-                throw new RuntimeException(e.getMessage());
-            }
-        }
-    }
-    
-    /** Return the singleton instance of this class. */
-    public static GenericFactory get() {
-        return singleton;
-    }
-    
-    /**
      * The reference towards the Julia generic factory bootstrap component.
      * Lazily created whenever an heterogeneous assembly containing Julia and
      * AOKell components is instantiated.
Index: 
julia/src/org/objectweb/fractal/juliak/factory/CompBasedMembraneGenericFactoryImpl.java
diff -u 
julia/src/org/objectweb/fractal/juliak/factory/CompBasedMembraneGenericFactoryImpl.java:1.5
 
julia/src/org/objectweb/fractal/juliak/factory/CompBasedMembraneGenericFactoryImpl.java:1.6
--- 
julia/src/org/objectweb/fractal/juliak/factory/CompBasedMembraneGenericFactoryImpl.java:1.5
 Wed Dec 20 21:29:35 2006
+++ 
julia/src/org/objectweb/fractal/juliak/factory/CompBasedMembraneGenericFactoryImpl.java
     Thu Dec 21 11:46:57 2006
@@ -42,11 +42,13 @@
 import org.objectweb.fractal.api.factory.InstantiationException;
 import org.objectweb.fractal.api.type.ComponentType;
 import org.objectweb.fractal.api.type.InterfaceType;
+import org.objectweb.fractal.api.type.TypeFactory;
 import org.objectweb.fractal.julia.Controller;
 import org.objectweb.fractal.julia.InitializationContext;
 import org.objectweb.fractal.julia.type.BasicComponentType;
 import org.objectweb.fractal.julia.type.BasicInterfaceType;
 import org.objectweb.fractal.juliak.FractalHelper;
+import org.objectweb.fractal.juliak.Juliak;
 import org.objectweb.fractal.juliak.membrane.MCompositeImpl;
 import org.objectweb.fractal.juliak.membrane.MPrimitiveImpl;
 import org.objectweb.fractal.juliak.membrane.MembraneDef;
@@ -134,7 +136,9 @@
              * load the membrane.
              */
             try {
-                membrane = mdef.newFcStaticMembrane();                
+                TypeFactory tf = new Juliak().getFcTypeFactory();
+                GenericFactory gf = this;
+                membrane = mdef.newFcStaticMembrane(tf,gf);                
             }
             catch( InstantiationException ie ) {
                 adl = mdef.getAdl();
Index: julia/src/org/objectweb/fractal/juliak/factory/TypeFactoryImpl.java
diff -u 
julia/src/org/objectweb/fractal/juliak/factory/TypeFactoryImpl.java:1.4 
julia/src/org/objectweb/fractal/juliak/factory/TypeFactoryImpl.java:1.5
--- julia/src/org/objectweb/fractal/juliak/factory/TypeFactoryImpl.java:1.4   
  Wed Dec 20 21:29:35 2006
+++ julia/src/org/objectweb/fractal/juliak/factory/TypeFactoryImpl.java Thu 
Dec 21 11:46:57 2006
@@ -43,12 +43,6 @@
  */
 public class TypeFactoryImpl implements TypeFactory {
 
-    private static TypeFactory instance = new TypeFactoryImpl();
-    private TypeFactoryImpl() {}
-    public static TypeFactory get() {
-        return instance;
-    }
-    
     // -----------------------------------------------------------------
     // Implementation of the TypeFactory interface
     // -----------------------------------------------------------------
Index: julia/src/org/objectweb/fractal/juliak/membrane/MembraneDef.java
diff -u julia/src/org/objectweb/fractal/juliak/membrane/MembraneDef.java:1.4 
julia/src/org/objectweb/fractal/juliak/membrane/MembraneDef.java:1.5
--- julia/src/org/objectweb/fractal/juliak/membrane/MembraneDef.java:1.4      
  Fri Nov 10 21:06:37 2006
+++ julia/src/org/objectweb/fractal/juliak/membrane/MembraneDef.java    Thu 
Dec 21 11:46:57 2006
@@ -24,7 +24,9 @@
 package org.objectweb.fractal.juliak.membrane;
 
 import org.objectweb.fractal.api.Component;
+import org.objectweb.fractal.api.factory.GenericFactory;
 import org.objectweb.fractal.api.factory.InstantiationException;
+import org.objectweb.fractal.api.type.TypeFactory;
 import org.objectweb.fractal.juliak.platform.Platform;
 
 
@@ -62,7 +64,8 @@
      * Return a new instance of this membrane, i.e. create an instance of the
      * composite referenced by adl.
      */
-    public Component newFcStaticMembrane() throws InstantiationException {
+    public Component newFcStaticMembrane( TypeFactory tf, GenericFactory gf )
+    throws InstantiationException {
         
         try {
             if( adlsf == null ) {
@@ -76,7 +79,7 @@
                 adlsf = (StaticMembraneFactory) adlcl.newInstance();
             }
         
-            return adlsf.newFcStaticMembrane();
+            return adlsf.newFcStaticMembrane(tf,gf);
         }
         catch( Exception e ) {
             throw new InstantiationException(e.getMessage());
Index: 
julia/src/org/objectweb/fractal/juliak/membrane/StaticMembraneFactory.java
diff -u 
julia/src/org/objectweb/fractal/juliak/membrane/StaticMembraneFactory.java:1.3
 
julia/src/org/objectweb/fractal/juliak/membrane/StaticMembraneFactory.java:1.4
--- 
julia/src/org/objectweb/fractal/juliak/membrane/StaticMembraneFactory.java:1.3
      Fri Nov 10 21:06:37 2006
+++ 
julia/src/org/objectweb/fractal/juliak/membrane/StaticMembraneFactory.java  
Thu Dec 21 11:46:57 2006
@@ -24,20 +24,25 @@
 package org.objectweb.fractal.juliak.membrane;
 
 import org.objectweb.fractal.api.Component;
+import org.objectweb.fractal.api.factory.GenericFactory;
+import org.objectweb.fractal.api.type.TypeFactory;
 
 
 /**
  * Interface implemented by factories creating control membrane instances.
  * 
  * These factories, generated by
- * {@link org.objectweb.fractal.juliak.membrane.backend.MembraneCompiler}, 
are compiled
- * versions (hence the term static) of control membrane ADL descriptions.
+ * {@link org.objectweb.fractal.juliak.membrane.backend.MembraneCompiler}, 
are
+ * compiled versions (hence the term static) of control membrane ADL
+ * descriptions.
  * 
  * @author Lionel Seinturier <Lionel.Seinturier@xxxxxxx>
  * @since 2.5
  */
 public interface StaticMembraneFactory {
     
-    public Component newFcStaticMembrane() throws Exception;
+    public Component newFcStaticMembrane(
+            TypeFactory typeFactory, GenericFactory genericFactory )
+    throws Exception;
 
 }
Index: 
julia/src/org/objectweb/fractal/juliak/membrane/backend/MembraneCompiler.java
diff -u 
julia/src/org/objectweb/fractal/juliak/membrane/backend/MembraneCompiler.java:1.7
 
julia/src/org/objectweb/fractal/juliak/membrane/backend/MembraneCompiler.java:1.8
--- 
julia/src/org/objectweb/fractal/juliak/membrane/backend/MembraneCompiler.java:1.7
   Wed Dec 20 21:29:36 2006
+++ 
julia/src/org/objectweb/fractal/juliak/membrane/backend/MembraneCompiler.java 
      Thu Dec 21 11:46:57 2006
@@ -40,8 +40,6 @@
 import org.objectweb.fractal.api.type.ComponentType;
 import org.objectweb.fractal.api.type.InterfaceType;
 import org.objectweb.fractal.api.type.TypeFactory;
-import org.objectweb.fractal.juliak.factory.AbstractGenericFactoryImpl;
-import org.objectweb.fractal.juliak.factory.TypeFactoryImpl;
 import org.objectweb.fractal.juliak.membrane.JuliakMembranes;
 import org.objectweb.fractal.juliak.membrane.MembraneDef;
 import org.objectweb.fractal.juliak.membrane.StaticMembraneFactory;
@@ -165,17 +163,16 @@
         pw.println("import "+ComponentType.class.getName()+";");
         pw.println("import "+InterfaceType.class.getName()+";");
         pw.println("import "+TypeFactory.class.getName()+";");
-        pw.println("import "+AbstractGenericFactoryImpl.class.getName()+";");
-        pw.println("import "+TypeFactoryImpl.class.getName()+";");
         pw.println("import "+Fractal.class.getName()+";");        
         pw.println("import "+NoSuchInterfaceException.class.getName()+";");  
      
         pw.println();
-        
-        pw.print("public class "+classname);
+                
+        pw.print  ("public class "+classname);
         pw.println(" implements "+StaticMembraneFactory.class.getName()+" 
{");
-        pw.println("  public Component newFcStaticMembrane() throws 
Exception {");
-        pw.println("    TypeFactory typeFactory = TypeFactoryImpl.get();");
-        pw.println("    GenericFactory genericFactory = 
AbstractGenericFactoryImpl.get();");
+        pw.print  ("  public Component newFcStaticMembrane( ");
+        pw.print  (TypeFactory.class.getName()+" typeFactory, ");
+        pw.print  (GenericFactory.class.getName()+" genericFactory )");
+        pw.println("throws Exception {");
     }
 
     protected void epilogueMembrane( PrintWriter pw, Object root )



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

Reply via email to:

Powered by MHonArc.

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