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/control (2 files)


    Date: Friday, December 22, 2006 @ 19:27:01
  Author: seintur
    Path: /cvsroot/fractal/julia/src/org/objectweb/fractal/juliak/control

   Added: attribute/BasicAttributeControllerMixin.java
          membrane/BasicMembraneControllerMixin.java

Mixin layers for the attribute and membrane controllers.


----------------------------------------------+
 attribute/BasicAttributeControllerMixin.java |  105 +++++++++++++++++++++++++
 membrane/BasicMembraneControllerMixin.java   |   59 ++++++++++++++
 2 files changed, 164 insertions(+)


Index: 
julia/src/org/objectweb/fractal/juliak/control/attribute/BasicAttributeControllerMixin.java
diff -u /dev/null 
julia/src/org/objectweb/fractal/juliak/control/attribute/BasicAttributeControllerMixin.java:1.1
--- /dev/null   Fri Dec 22 19:27:02 2006
+++ 
julia/src/org/objectweb/fractal/juliak/control/attribute/BasicAttributeControllerMixin.java
 Fri Dec 22 19:27:01 2006
@@ -0,0 +1,105 @@
+/***
+ * Julia
+ * Copyright (C) 2005-2006 INRIA, France Telecom, USTL
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Contact: Lionel.Seinturier@xxxxxxx
+ *
+ * Author: Lionel Seinturier
+ */
+
+package org.objectweb.fractal.juliak.control.attribute;
+
+import org.objectweb.fractal.api.Component;
+import org.objectweb.fractal.api.control.AttributeController;
+import org.objectweb.fractal.api.factory.InstantiationException;
+import org.objectweb.fractal.api.type.InterfaceType;
+import org.objectweb.fractal.julia.BasicComponentInterface;
+import org.objectweb.fractal.julia.InitializationContext;
+import 
org.objectweb.fractal.julia.control.attribute.CloneableAttributeController;
+import org.objectweb.fractal.juliak.FractalHelper;
+import org.objectweb.fractal.juliak.asm.ClassGenerator;
+import 
org.objectweb.fractal.juliak.asm.CloneableAttributeControllerClassGenerator;
+import org.objectweb.fractal.juliak.factory.InstanceGenerator;
+
+
+/**
+ * Provides as a mixin layer, a basic implementation of the {@link
+ * CloneableAttributeController} interface.
+ * 
+ * @author Lionel Seinturier <Lionel.Seinturier@xxxxxxx>
+ * @since 2.5
+ */
+public abstract class BasicAttributeControllerMixin
+    implements CloneableAttributeController {
+    
+    private BasicAttributeControllerMixin() {}
+
+    
+    public void cloneFcAttributes(AttributeController dst) {
+        delegate.cloneFcAttributes(dst);
+    }
+    private CloneableAttributeController delegate;
+
+    
+    public void initFcController(InitializationContext ic)
+    throws InstantiationException {        
+        
+        Component comp = (Component) ic.interfaces.get("component");
+        
+        /*
+         * Retrieve the attribute-controller interface.
+         */
+        Object itf = FractalHelper.getAttributeController(comp);
+        if( ! (itf instanceof BasicComponentInterface) ) {
+            final String msg =
+                "The interface for attribute-controller should implement 
o.o.f.j.BasicComponentInterface";
+            throw new InstantiationException(msg);
+        }
+        BasicComponentInterface citf = (BasicComponentInterface) itf;
+        InterfaceType it = (InterfaceType) citf.getFcItfType();
+        
+        /*
+         * Generate a cloneable (in the sense CloneableAttributeController)
+         * version of the attribute-controller.
+         */
+        if( ig == null ) {
+            ClassGenerator caccg =
+                new CloneableAttributeControllerClassGenerator();
+            ig = new InstanceGenerator(caccg);
+        }
+        Object o = ig.generate(it, null);
+        if( !(o instanceof CloneableAttributeController) ) {
+            final String msg =
+                "The generated instance should implement 
o.o.f.j.control.attribute.CloneableAttributeController";
+            throw new InstantiationException(msg);
+        }
+        delegate = (CloneableAttributeController) o;
+        
+        /*
+         * Replace the original implementation of the attribute-controller by
+         * the generated version.
+         */
+        citf.setFcItfImpl(o);
+
+        _super_initFcController(ic);
+    }
+    
+    private InstanceGenerator ig;
+
+    abstract void _super_initFcController(InitializationContext ic)
+    throws InstantiationException;
+}
Index: 
julia/src/org/objectweb/fractal/juliak/control/membrane/BasicMembraneControllerMixin.java
diff -u /dev/null 
julia/src/org/objectweb/fractal/juliak/control/membrane/BasicMembraneControllerMixin.java:1.1
--- /dev/null   Fri Dec 22 19:27:02 2006
+++ 
julia/src/org/objectweb/fractal/juliak/control/membrane/BasicMembraneControllerMixin.java
   Fri Dec 22 19:27:01 2006
@@ -0,0 +1,59 @@
+/***
+ * Julia
+ * Copyright (C) 2005-2006 INRIA, France Telecom, USTL
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Contact: Lionel.Seinturier@xxxxxxx
+ *
+ * Author: Lionel Seinturier
+ */
+
+package org.objectweb.fractal.juliak.control.membrane;
+
+import org.objectweb.fractal.api.Component;
+import org.objectweb.fractal.api.factory.InstantiationException;
+import org.objectweb.fractal.julia.InitializationContext;
+import org.objectweb.fractal.juliak.FractalHelper;
+
+
+/**
+ * Provides as a mixin layer, a basic implementation of the {@link
+ * MembraneController} interface.
+ * 
+ * Membrane controllers provide an access to the current control membrane.
+ * This access allows introspecting the control membrane.
+ * 
+ * @author Lionel Seinturier <Lionel.Seinturier@xxxxxxx>
+ * @since 2.5
+ */
+public abstract class BasicMembraneControllerMixin implements 
MembraneController {
+
+    private BasicMembraneControllerMixin() {}
+    
+    public Component getFcMembrane() {
+        return FractalHelper.getTopMostComponent(compctrl);
+    }
+
+    private Component compctrl;
+
+    public void initFcController(InitializationContext ic) throws 
InstantiationException {
+        compctrl = (Component) ic.getInterface("//component");
+        _super_initFcController(ic);
+    }
+    
+    abstract void _super_initFcController(InitializationContext ic)
+    throws InstantiationException;
+}



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

Reply via email to:

Powered by MHonArc.

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