Mail Archive Home | fractal-commits List | May 2008 Index
| <-- Date Index --> | <-- Thread Index --> |
Split the juliac-runtime in two: - one for the OO mode (juliac-runtime) with a type-factory and a generic-factory interface, - one for the COMP mode (juliac-runtime-comp) with a third membrane-factory interface. The purpose is to remove the dependency to the koch-runtime module which is not needed in the OO mode. Adding a corresponding juliac_comp:run profile in juliac/pom.xml.
--- trunk/juliac/RELEASE_NOTES.txt 2008-05-27 20:07:16 UTC (rev 7799)
+++ trunk/juliac/RELEASE_NOTES.txt 2008-05-27 20:09:56 UTC (rev 7800)
@@ -1,7 +1,8 @@
Juliac 2.0
----------
* Maven groupId changed to org.objectweb.fractal.juliac
-* Fractal ADL no longer mandatory (optional module)
+* Fractal ADL no longer mandatory (optional module)
+* new juliac-runtime-comp module for applications with component-based membranes
Juliac 1.3
--- trunk/juliac/TODO.txt 2008-05-27 20:07:16 UTC (rev 7799)
+++ trunk/juliac/TODO.txt 2008-05-27 20:09:56 UTC (rev 7800)
@@ -35,7 +35,3 @@
* evaluate and inline Fractal API invocations which do not modify the
architecture (e.g. getFcName())
* rely on @Attribute to inline attribute values (suggestion by Philippe)
-
-runtime/
-* find a way to have a Juliac provider class which is independent of
- koch-runtime which is not needed if the COMP optimization mode is not used
--- trunk/juliac/examples/advanced/comp-based-membrane/README.txt 2008-05-27 20:07:16 UTC (rev 7799)
+++ trunk/juliac/examples/advanced/comp-based-membrane/README.txt 2008-05-27 20:09:56 UTC (rev 7800)
@@ -1,2 +1,2 @@
To compile and run the example:
- mvn -Pjuliac:run
+ mvn -Pjuliac_comp:run
--- trunk/juliac/examples/advanced/comp-based-membrane/pom.xml 2008-05-27 20:07:16 UTC (rev 7799)
+++ trunk/juliac/examples/advanced/comp-based-membrane/pom.xml 2008-05-27 20:09:56 UTC (rev 7800)
@@ -16,7 +16,7 @@
<!-- =============================================== -->
<!-- Juliac properties for launching the application -->
<!-- (component and interface) -->
- <!-- with the juliac:profile (mvn -Pjuliac:run) -->
+ <!-- mvn -Pjuliac_comp:run -->
<!-- =============================================== -->
<properties>
<juliac.run.component>example.hw.HelloWorld</juliac.run.component>
--- trunk/juliac/examples/advanced/mix/README.txt 2008-05-27 20:07:16 UTC (rev 7799)
+++ trunk/juliac/examples/advanced/mix/README.txt 2008-05-27 20:09:56 UTC (rev 7800)
@@ -1,2 +1,2 @@
To compile and run the example:
- mvn -Pjuliac:run
+ mvn -Pjuliac_comp:run
--- trunk/juliac/examples/advanced/mix/pom.xml 2008-05-27 20:07:16 UTC (rev 7799)
+++ trunk/juliac/examples/advanced/mix/pom.xml 2008-05-27 20:09:56 UTC (rev 7800)
@@ -16,7 +16,7 @@
<!-- =============================================== -->
<!-- Juliac properties for launching the application -->
<!-- (component and interface) -->
- <!-- with the juliac:profile (mvn -Pjuliac:run) -->
+ <!-- mvn -Pjuliac_comp:run -->
<!-- =============================================== -->
<properties>
<juliac.run.component>membrane.mix.HelloWorld</juliac.run.component>
--- trunk/juliac/pom.xml 2008-05-27 20:07:16 UTC (rev 7799)
+++ trunk/juliac/pom.xml 2008-05-27 20:09:56 UTC (rev 7800)
@@ -138,6 +138,50 @@
</dependency>
</dependencies>
</profile>
+
+ <!-- ======================================================== -->
+ <!-- Profile for lauching an application with Juliac COMP -->
+ <!-- ======================================================== -->
+ <profile>
+ <id>juliac_comp:run</id>
+ <build>
+ <defaultGoal>compile</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>java</goal>
+ </goals>
+ <phase>compile</phase>
+ </execution>
+ </executions>
+ <configuration>
+ <mainClass>org.objectweb.fractal.juliac.runtime.Launcher</mainClass>
+ <systemProperties>
+ <systemProperty>
+ <key>fractal.provider</key>
+ <value>org.objectweb.fractal.juliac.runtime.comp.Juliac</value>
+ </systemProperty>
+ </systemProperties>
+ <arguments>
+ <argument>${juliac.run.component}</argument>
+ <argument>${juliac.run.interface}</argument>
+ </arguments>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>org.objectweb.fractal.juliac</groupId>
+ <artifactId>juliac-runtime-comp</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+ </profile>
</profiles>
</project>
Name: svn:ignore
+ target
.classpath
.project
.settings
--- trunk/juliac/runtime/comp/pom.xml (rev 0)
+++ trunk/juliac/runtime/comp/pom.xml 2008-05-27 20:09:56 UTC (rev 7800)
@@ -0,0 +1,29 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.objectweb.fractal.juliac</groupId>
+ <artifactId>juliac-runtime-parent</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.objectweb.fractal.juliac</groupId>
+ <artifactId>juliac-runtime-comp</artifactId>
+ <packaging>jar</packaging>
+ <name>Juliac Runtime COMP</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.objectweb.fractal.julia</groupId>
+ <artifactId>koch-runtime</artifactId>
+ <version>2.5.2.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.objectweb.fractal.juliac</groupId>
+ <artifactId>juliac-runtime</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+</project>
--- trunk/juliac/runtime/comp/src/main/java/org/objectweb/fractal/juliac/runtime/comp/Juliac.java (rev 0)
+++ trunk/juliac/runtime/comp/src/main/java/org/objectweb/fractal/juliac/runtime/comp/Juliac.java 2008-05-27 20:09:56 UTC (rev 7800)
@@ -0,0 +1,172 @@
+/***
+ * Juliac
+ * Copyright (C) 2007-2008 INRIA, 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@xxxxxxxxxxxxxx
+ *
+ * Author: Lionel Seinturier
+ */
+
+package org.objectweb.fractal.juliac.runtime.comp;
+
+import org.objectweb.fractal.api.Component;
+import org.objectweb.fractal.api.Type;
+import org.objectweb.fractal.api.factory.Factory;
+import org.objectweb.fractal.api.factory.GenericFactory;
+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.type.BasicComponentType;
+import org.objectweb.fractal.julia.type.BasicInterfaceType;
+import org.objectweb.fractal.koch.factory.MembraneFactory;
+
+/**
+ * The Fractal provider class for Juliac in the COMP optimization level.
+ *
+ * This Fractal provider returns a bootstrap component with a type-factory,
+ * a generic-factory and a membrane-factory interface.
+ *
+ * @author Lionel Seinturier <Lionel.Seinturier@xxxxxxxxxxxxxx>
+ * @since 2.0
+ */
+public class Juliac implements Factory, GenericFactory {
+
+ public Juliac() {}
+
+ /**
+ * Return an instance of the Fractal provider class.
+ * This method is meant to allow subclassing Juliac.
+ * This method is thus more general than the default public constructor for
+ * obtaining an instance of the provider class.
+ * This method returns a singleton instance.
+ */
+ public static Juliac get() {
+
+ if( juliac != null ) {
+ return juliac;
+ }
+
+ 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();
+ juliac = (Juliac) o;
+ return juliac;
+ }
+ catch (Exception e) {
+ throw new RuntimeException(
+ "Cannot find or instantiate the '" + bootTmplClassName +
+ "' class specified in the fractal.provider system property");
+ }
+ }
+
+ /** The singleton instance of the provider class. */
+ private static Juliac juliac = null;
+
+ /** Return the Fractal type of this component. */
+ public Type getFcInstanceType() {
+ if( TYPE == null ) {
+ try {
+ TYPE =
+ new BasicComponentType(
+ new InterfaceType[] {
+ new BasicInterfaceType(
+ "type-factory",
+ TypeFactory.class.getName(),
+ false, false, false),
+ new BasicInterfaceType(
+ "generic-factory",
+ GenericFactory.class.getName(),
+ false, false, false),
+ new BasicInterfaceType(
+ "membrane-factory",
+ MembraneFactory.class.getName(),
+ false, false, false)
+ });
+ }
+ catch (InstantiationException e) {
+ throw new RuntimeException(e.getMessage());
+ }
+ }
+ return TYPE;
+ }
+
+ /** Return the Fractal controller description of this component. */
+ public Object getFcControllerDesc() {
+ return CONTROLLER_DESC;
+ }
+
+ /** Return the Fractal content description of this component. */
+ public Object getFcContentDesc() {
+ return JuliacBootstrapComponentImpl.class.getName();
+ }
+
+ /** The singleton instance of the bootstrap component. */
+ private static Component bootstrap;
+
+ /**
+ * Return the reference of the bootstrap component.
+ * This method is called by {@link
+ * org.objectweb.fractal.api.Fractal#getBootstrapComponent()}
+ * The bootstrap component provides the following interfaces:
+ * <ul>
+ * <li> {@link TypeFactory} </li>
+ * <li> {@link GenericFactory} </li>
+ * <li> {@link MembraneFactory} </li>
+ * </ul>
+ */
+ public Component newFcInstance() throws InstantiationException {
+ return newFcInstance(null,null,null);
+ }
+
+ /**
+ * Return the reference of the bootstrap component.
+ */
+ public Component newFcInstance(
+ Type type, Object controllerDesc, Object contentDesc )
+ throws InstantiationException {
+
+ if( bootstrap == null ) {
+ bootstrap = new JuliacBootstrapComponentImpl();
+ }
+
+ return bootstrap;
+ }
+
+ private static ComponentType TYPE = null;
+ final private static Object CONTROLLER_DESC = "bootstrap";
+
+
+ // ----------------------------------------------------------
+ // Implementation specific
+ // ----------------------------------------------------------
+
+ private static GenericFactory gf;
+
+ public GenericFactory getFcGenericFactory() {
+ if( gf == null ) {
+ gf = new JuliacBootstrapComponentImpl();
+ }
+ return gf;
+ }
+}
--- trunk/juliac/runtime/comp/src/main/java/org/objectweb/fractal/juliac/runtime/comp/JuliacBootstrapComponentImpl.java (rev 0)
+++ trunk/juliac/runtime/comp/src/main/java/org/objectweb/fractal/juliac/runtime/comp/JuliacBootstrapComponentImpl.java 2008-05-27 20:09:56 UTC (rev 7800)
@@ -0,0 +1,327 @@
+/***
+ * Juliac
+ * Copyright (C) 2007-2008 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@xxxxxxxxxxxxxx
+ *
+ * Author: Lionel Seinturier
+ */
+
+package org.objectweb.fractal.juliac.runtime.comp;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.objectweb.fractal.api.Component;
+import org.objectweb.fractal.api.Interface;
+import org.objectweb.fractal.api.NoSuchInterfaceException;
+import org.objectweb.fractal.api.Type;
+import org.objectweb.fractal.api.factory.GenericFactory;
+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.factory.ChainedInstantiationException;
+import org.objectweb.fractal.julia.type.BasicComponentType;
+import org.objectweb.fractal.julia.type.BasicInterfaceType;
+import org.objectweb.fractal.juliac.runtime.Factory;
+import org.objectweb.fractal.juliac.runtime.GenericFactoryFcItf;
+import org.objectweb.fractal.juliac.runtime.TypeFactoryFcItf;
+import org.objectweb.fractal.koch.factory.MembraneFactory;
+
+/**
+ * The Juliac bootstrap component for the COMP optimization level.
+ *
+ * This bootstrap component provides a type-factory, a generic-factory and a
+ * membrane-factory interface.
+ *
+ * @author Lionel Seinturier <Lionel.Seinturier@xxxxxxxxxxxxxx>
+ * @since 2.0
+ */
+public class JuliacBootstrapComponentImpl
+implements TypeFactory, GenericFactory, MembraneFactory, Component {
+
+ public JuliacBootstrapComponentImpl() {
+ interfaces = new Object[3];
+ interfaces[0] =
+ new TypeFactoryFcItf(
+ this, "type-factory",
+ new BasicInterfaceType("type-factory",TypeFactory.class.getName(),false,false,false),
+ false, this );
+ interfaces[1] =
+ new GenericFactoryFcItf(
+ this, "generic-factory",
+ new BasicInterfaceType("generic-factory",GenericFactory.class.getName(),false,false,false),
+ false, this );
+ interfaces[2] =
+ new MembraneFactoryFcItf(
+ this, "membrane-factory",
+ new BasicInterfaceType("membrane-factory",MembraneFactory.class.getName(),false,false,false),
+ false, this );
+ }
+
+ // -----------------------------------------------------------------
+ // Implementation of the TypeFactory interface
+ // -----------------------------------------------------------------
+
+ public InterfaceType createFcItfType(
+ String name, String signature,
+ boolean isClient, boolean isOptional, boolean isCollection)
+ throws InstantiationException {
+
+ return new BasicInterfaceType(
+ name,signature,isClient,isOptional,isCollection);
+ }
+
+ public ComponentType createFcType(InterfaceType[] interfaceTypes)
+ throws InstantiationException {
+
+ return new BasicComponentType(interfaceTypes);
+ }
+
+ // -----------------------------------------------------------------
+ // Implementation of the GenericFactory interface
+ // -----------------------------------------------------------------
+
+ /**
+ * Create a new component.
+ *
+ * @param type the component type
+ * @param controllerDesc
+ * the description of the control membrane associated
+ * to the component
+ * @param contentDesc
+ * the description of the content of the component
+ */
+ public Component newFcInstance(
+ Type type, Object controllerDesc, Object contentDesc )
+ throws InstantiationException {
+ ClassLoader classLoader = null;
+ /*
+ * When called from Fractal ADL, the component creation process may be
+ * accompagnied with some hints. One of the them is the class loader to
+ * be used. In this case, the controllerDesc parameter is an array where
+ * the 1st element contains the class loader.
+ */
+ if( controllerDesc.getClass().isArray() ) {
+ Object[] array = (Object[]) controllerDesc;
+ classLoader = (ClassLoader) array[0];
+ controllerDesc = array[1];
+ }
+
+ /*
+ * Adaptation for templates components.
+ * Templates are created with something like:
+ * Component cTmpl = cf.newFcInstance(
+ * cType, "flatPrimitiveTemplate",
+ * new Object[] { "flatPrimitive", "ClientImpl" });
+ */
+ if( controllerDesc instanceof String ) {
+ if( ((String)controllerDesc).endsWith("Template") ) {
+ Object[] cont = (Object[]) contentDesc;
+ contentDesc = cont[1];
+ }
+ }
+
+ if( !(type instanceof ComponentType) ) {
+ String msg = "ComponentType expected";
+ throw new InstantiationException(msg);
+ }
+
+ /*
+ * Compute the hash code used as the suffix by the initializer class.
+ * The idea is that there is a class for each different record of
+ * content class, controller descriptor and component type. The two
+ * first elements are, by nature, identify. A hash is computed to
+ * uniquely identifies component types.
+ */
+ ComponentType ct = (ComponentType) type;
+ String sct = ct.toString();
+ int hashct = sct.hashCode();
+ String hexhashct = Integer.toHexString(hashct);
+
+ /*
+ * If the specified controllerDesc is a Component, consider that this is
+ * the control membrane which is to be associated with the component.
+ */
+ if( controllerDesc instanceof Component ) {
+ // TODO Koch-like factory
+ throw new UnsupportedOperationException();
+ }
+ else {
+
+ /*
+ * If contentDesc is a string, consider that it is the fully qualified
+ * name of the class which needs to be instantiated. Else, consider that
+ * this is the instance which must be associated with the component.
+ */
+ String membraneClassname =
+ contentDesc == null ?
+ org.objectweb.fractal.juliac.runtime.Juliac.JULIAC_GENERATED+"."+controllerDesc :
+ (contentDesc instanceof String ? contentDesc : contentDesc.getClass().getName())
+ +"FC"+controllerDesc;
+ String targetClassname = membraneClassname+"FC"+hexhashct;
+ Class cl = loadClass(targetClassname, classLoader);
+ Factory f = (Factory) instanciateClass(cl);
+ Component c =
+ (contentDesc==null || contentDesc instanceof String) ?
+ f.newFcInstance() :
+ f.newFcInstance(contentDesc);
+ return c;
+ }
+ }
+
+
+ // -----------------------------------------------------------------
+ // Implementation of the MembraneFactory interface
+ // -----------------------------------------------------------------
+
+ /** The map <Object,String> of membrane adls. */
+ private Map membranes = new HashMap();
+
+ public String getFcMembraneADL(Object controllerDesc) {
+ String adl = (String) membranes.get(controllerDesc);
+ return adl;
+ }
+
+ public Component newFcMembrane(Object controllerDesc) throws InstantiationException {
+
+ Class cl = null;
+ try {
+ String adl = org.objectweb.fractal.juliac.runtime.Juliac.JULIAC_GENERATED+'.'+controllerDesc;
+ cl = loadClass(adl, null);
+ }
+ catch( InstantiationException ie ) {
+ /*
+ * The factory class hasn't been found in juliac.generated.
+ * Check whether a custom ADL has been registered for this membrane.
+ */
+ if( ! membranes.containsKey(controllerDesc) ) {
+ String msg = "Unknown controller descriptor: "+controllerDesc;
+ throw new InstantiationException(msg);
+ }
+ String adl = (String) membranes.get(controllerDesc);
+ cl = loadClass(adl, null);
+ }
+
+ org.objectweb.fractal.api.factory.Factory factory =
+ (org.objectweb.fractal.api.factory.Factory) instanciateClass(cl);
+ Component c = factory.newFcInstance();
+ return c;
+ }
+
+ public void registerFcNewMembraneDef(String controllerDesc, String adl)
+ throws InstantiationException {
+ Class cl = loadClass(adl, null);
+ if( ! Factory.class.isAssignableFrom(cl) ) {
+ String msg = adl+" should implement "+Factory.class.getName();
+ throw new InstantiationException(msg);
+ }
+ membranes.put(controllerDesc, adl);
+ }
+
+
+ // -----------------------------------------------------------------
+ // Utility methods
+ // -----------------------------------------------------------------
+
+ /**
+ * Load and instantiate the given class name.
+ * @param name the fully qualified name of the class to load
+ * @param classLoader the classloader to use; if null, the default class loader is used instead
+ */
+ private Class loadClass(String name, ClassLoader classLoader)
+ throws InstantiationException
+ {
+
+ if (classLoader !=null) {
+ try
+ {
+ Class c = classLoader.loadClass(name);
+ return c;
+ }catch (ClassNotFoundException cnfe) {
+ return loadClass(name);
+ }
+ } else {
+ return loadClass(name);
+ }
+}
+ /**
+ * Load and instantiate the given class name.
+ * @param name the fully qualified name of the class to load
+ */
+ private Class loadClass(String name) throws InstantiationException {
+ try
+ {
+ Class cl = Class.forName(name);
+ return cl;
+
+ }
+ catch (ClassNotFoundException cnfe2)
+ {
+ final String msg = "ClassNotFoundException: " + name;
+ throw new ChainedInstantiationException(cnfe2, null, msg);
+ }
+ }
+
+ /**
+ * Load and instantiate the given class name.
+ */
+ private Object instanciateClass( Class cl ) throws InstantiationException {
+
+ try {
+ Object o = cl.newInstance();
+ return o;
+ }
+ catch( java.lang.InstantiationException ie ) {
+ final String msg =
+ "java.lang.InstantiationException when instantiating class: "+
+ cl.getName();
+ throw new ChainedInstantiationException(ie,null,msg);
+ }
+ catch( IllegalAccessException iae ) {
+ final String msg =
+ "IllegalAccessException when instantiating class: "+
+ cl.getName();
+ throw new ChainedInstantiationException(iae,null,msg);
+ }
+ }
+
+ // -----------------------------------------------------------------
+ // Implementation of the Component interface
+ // -----------------------------------------------------------------
+
+ public Object getFcInterface(String arg0) throws NoSuchInterfaceException {
+ for (int i = 0; i < interfaces.length; i++) {
+ String name = ((Interface)interfaces[i]).getFcItfName();
+ if( name.equals(arg0) ) {
+ return interfaces[i];
+ }
+ }
+ throw new NoSuchInterfaceException(arg0);
+ }
+
+ public Object[] getFcInterfaces() {
+ return interfaces;
+ }
+
+ public Type getFcType() {
+ return Juliac.get().getFcInstanceType();
+ }
+
+ private Object[] interfaces;
+}
--- trunk/juliac/runtime/comp/src/main/java/org/objectweb/fractal/juliac/runtime/comp/MembraneFactoryFcItf.java (rev 0)
+++ trunk/juliac/runtime/comp/src/main/java/org/objectweb/fractal/juliac/runtime/comp/MembraneFactoryFcItf.java 2008-05-27 20:09:56 UTC (rev 7800)
@@ -0,0 +1,70 @@
+/***
+ * Juliac
+ * Copyright (C) 2007 INRIA, 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@xxxxxxxxxxxxxx
+ *
+ * Author: Lionel Seinturier
+ */
+
+package org.objectweb.fractal.juliac.runtime.comp;
+
+import org.objectweb.fractal.api.Component;
+import org.objectweb.fractal.api.Type;
+import org.objectweb.fractal.api.factory.InstantiationException;
+import org.objectweb.fractal.julia.BasicComponentInterface;
+import org.objectweb.fractal.koch.factory.MembraneFactory;
+
+/**
+ * Implementation of the Fractal interface for {@link MembraneFactory}.
+ *
+ * @author Lionel Seinturier <Lionel.Seinturier@xxxxxxxxxxxxxx>
+ */
+public class MembraneFactoryFcItf
+extends BasicComponentInterface implements MembraneFactory {
+
+ public MembraneFactoryFcItf( Component component, String s, Type type, boolean flag, Object obj ) {
+ super(component,s,type,flag,obj);
+ }
+
+ public Object getFcItfImpl() { return impl; }
+
+ public void setFcItfImpl(Object obj) {
+ impl = (MembraneFactory)obj;
+ }
+
+ private MembraneFactory impl;
+
+ public String getFcMembraneADL(Object controllerDesc) {
+ if( impl == null )
+ throw new NullPointerException("Trying to invoke a method on a client interface, or on a server interface whose complementary interface is not bound.");
+ return impl.getFcMembraneADL(controllerDesc);
+ }
+
+ public Component newFcMembrane(Object controllerDesc) throws InstantiationException {
+ if( impl == null )
+ throw new NullPointerException("Trying to invoke a method on a client interface, or on a server interface whose complementary interface is not bound.");
+ return impl.newFcMembrane(controllerDesc);
+ }
+
+ public void registerFcNewMembraneDef(String controllerDesc, String adl)
+ throws InstantiationException {
+ if( impl == null )
+ throw new NullPointerException("Trying to invoke a method on a client interface, or on a server interface whose complementary interface is not bound.");
+ impl.registerFcNewMembraneDef(controllerDesc, adl);
+ }
+}
Name: svn:ignore
+ target
.classpath
.project
.settings
--- trunk/juliac/runtime/oo/pom.xml (rev 0)
+++ trunk/juliac/runtime/oo/pom.xml 2008-05-27 20:09:56 UTC (rev 7800)
@@ -0,0 +1,16 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.objectweb.fractal.juliac</groupId>
+ <artifactId>juliac-runtime-parent</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.objectweb.fractal.juliac</groupId>
+ <artifactId>juliac-runtime</artifactId>
+ <packaging>jar</packaging>
+ <name>Juliac Runtime</name>
+
+</project>
--- trunk/juliac/runtime/oo/src/main/java/org/objectweb/fractal/juliac/runtime/Factory.java (rev 0)
+++ trunk/juliac/runtime/oo/src/main/java/org/objectweb/fractal/juliac/runtime/Factory.java 2008-05-27 20:09:56 UTC (rev 7800)
@@ -0,0 +1,47 @@
+/***
+ * Juliac
+ * Copyright (C) 2007 INRIA, 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@xxxxxxxxxxxxxx
+ *
+ * Author: Lionel Seinturier
+ */
+
+package org.objectweb.fractal.juliac.runtime;
+
+import org.objectweb.fractal.api.Component;
+import org.objectweb.fractal.api.factory.InstantiationException;
+
+/**
+ * A factory for instantiating components.
+ *
+ * This factory instantiates components of a particular type, with a particular
+ * control membrane and with a particular content implementation.
+ *
+ * @author Lionel Seinturier <Lionel.Seinturier@xxxxxxxxxxxxxx>
+ */
+public interface Factory extends org.objectweb.fractal.api.factory.Factory {
+
+ /**
+ * Return a new component instance.
+ *
+ * @param content the content instance
+ * @return a new component instance
+ */
+ public Component newFcInstance( Object content )
+ throws InstantiationException;
+}
--- trunk/juliac/runtime/oo/src/main/java/org/objectweb/fractal/juliac/runtime/GenericFactoryFcItf.java (rev 0)
+++ trunk/juliac/runtime/oo/src/main/java/org/objectweb/fractal/juliac/runtime/GenericFactoryFcItf.java 2008-05-27 20:09:56 UTC (rev 7800)
@@ -0,0 +1,58 @@
+/***
+ * Juliac
+ * Copyright (C) 2007 INRIA, 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@xxxxxxxxxxxxxx
+ *
+ * Author: Lionel Seinturier
+ */
+
+package org.objectweb.fractal.juliac.runtime;
+
+import org.objectweb.fractal.api.Component;
+import org.objectweb.fractal.api.Type;
+import org.objectweb.fractal.api.factory.GenericFactory;
+import org.objectweb.fractal.api.factory.InstantiationException;
+import org.objectweb.fractal.julia.BasicComponentInterface;
+
+/**
+ * Implementation of the Fractal interface for {@link GenericFactory}.
+ *
+ * @author Lionel Seinturier <Lionel.Seinturier@xxxxxxxxxxxxxx>
+ */
+public class GenericFactoryFcItf
+extends BasicComponentInterface implements GenericFactory {
+
+ public GenericFactoryFcItf( Component component, String s, Type type, boolean flag, Object obj ) {
+ super(component,s,type,flag,obj);
+ }
+
+ public Object getFcItfImpl() { return impl; }
+
+ public void setFcItfImpl(Object obj) {
+ impl = (GenericFactory)obj;
+ }
+
+ private GenericFactory impl;
+
+ public Component newFcInstance( Type arg0, Object arg1, Object arg2 )
+ throws InstantiationException {
+ if( impl == null )
+ throw new NullPointerException("Trying to invoke a method on a client interface, or on a server interface whose complementary interface is not bound.");
+ return impl.newFcInstance(arg0, arg1, arg2);
+ }
+}
--- trunk/juliac/runtime/oo/src/main/java/org/objectweb/fractal/juliac/runtime/Juliac.java (rev 0)
+++ trunk/juliac/runtime/oo/src/main/java/org/objectweb/fractal/juliac/runtime/Juliac.java 2008-05-27 20:09:56 UTC (rev 7800)
@@ -0,0 +1,169 @@
+/***
+ * Juliac
+ * Copyright (C) 2007-2008 INRIA, 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@xxxxxxxxxxxxxx
+ *
+ * Author: Lionel Seinturier
+ */
+
+package org.objectweb.fractal.juliac.runtime;
+
+import org.objectweb.fractal.api.Component;
+import org.objectweb.fractal.api.Type;
+import org.objectweb.fractal.api.factory.Factory;
+import org.objectweb.fractal.api.factory.GenericFactory;
+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.type.BasicComponentType;
+import org.objectweb.fractal.julia.type.BasicInterfaceType;
+
+/**
+ * The Fractal provider class for Juliac.
+ *
+ * This Fractal provider returns a bootstrap component with a type-factory and
+ * a generic-factory interface.
+ *
+ * @author Lionel Seinturier <Lionel.Seinturier@xxxxxxxxxxxxxx>
+ */
+public class Juliac implements Factory, GenericFactory {
+
+ /** The package prefix for code generated by Juliac. */
+ final public static String JULIAC_GENERATED = "juliac.generated";
+
+ public Juliac() {}
+
+ /**
+ * Return an instance of the Fractal provider class.
+ * This method is meant to allow subclassing Juliac.
+ * This method is thus more general than the default public constructor for
+ * obtaining an instance of the provider class.
+ * This method returns a singleton instance.
+ */
+ public static Juliac get() {
+
+ if( juliac != null ) {
+ return juliac;
+ }
+
+ 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();
+ juliac = (Juliac) o;
+ return juliac;
+ }
+ catch (Exception e) {
+ throw new RuntimeException(
+ "Cannot find or instantiate the '" + bootTmplClassName +
+ "' class specified in the fractal.provider system property");
+ }
+ }
+
+ /** The singleton instance of the provider class. */
+ private static Juliac juliac = null;
+
+ /** Return the Fractal type of this component. */
+ public Type getFcInstanceType() {
+ if( TYPE == null ) {
+ try {
+ TYPE =
+ new BasicComponentType(
+ new InterfaceType[] {
+ new BasicInterfaceType(
+ "type-factory",
+ TypeFactory.class.getName(),
+ false, false, false),
+ new BasicInterfaceType(
+ "generic-factory",
+ GenericFactory.class.getName(),
+ false, false, false)
+ });
+ }
+ catch (InstantiationException e) {
+ throw new RuntimeException(e.getMessage());
+ }
+ }
+ return TYPE;
+ }
+
+ /** Return the Fractal controller description of this component. */
+ public Object getFcControllerDesc() {
+ return CONTROLLER_DESC;
+ }
+
+ /** Return the Fractal content description of this component. */
+ public Object getFcContentDesc() {
+ return JuliacBootstrapComponentImpl.class.getName();
+ }
+
+ /** The singleton instance of the bootstrap component. */
+ private static Component bootstrap;
+
+ /**
+ * Return the reference of the bootstrap component.
+ * This method is called by {@link
+ * org.objectweb.fractal.api.Fractal#getBootstrapComponent()}
+ * The bootstrap component provides the following interfaces:
+ * <ul>
+ * <li> {@link TypeFactory} </li>
+ * <li> {@link GenericFactory} </li>
+ * <li> {@link MembraneFactory} </li>
+ * </ul>
+ */
+ public Component newFcInstance() throws InstantiationException {
+ return newFcInstance(null,null,null);
+ }
+
+ /**
+ * Return the reference of the bootstrap component.
+ */
+ public Component newFcInstance(
+ Type type, Object controllerDesc, Object contentDesc )
+ throws InstantiationException {
+
+ if( bootstrap == null ) {
+ bootstrap = new JuliacBootstrapComponentImpl();
+ }
+
+ return bootstrap;
+ }
+
+ private static ComponentType TYPE = null;
+ final private static Object CONTROLLER_DESC = "bootstrap";
+
+
+ // ----------------------------------------------------------
+ // Implementation specific
+ // ----------------------------------------------------------
+
+ private static GenericFactory gf;
+
+ public GenericFactory getFcGenericFactory() {
+ if( gf == null ) {
+ gf = new JuliacBootstrapComponentImpl();
+ }
+ return gf;
+ }
+}
--- trunk/juliac/runtime/oo/src/main/java/org/objectweb/fractal/juliac/runtime/JuliacBootstrapComponentImpl.java (rev 0)
+++ trunk/juliac/runtime/oo/src/main/java/org/objectweb/fractal/juliac/runtime/JuliacBootstrapComponentImpl.java 2008-05-27 20:09:56 UTC (rev 7800)
@@ -0,0 +1,265 @@
+/***
+ * Juliac
+ * Copyright (C) 2007-2008 INRIA, 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@xxxxxxxxxxxxxx
+ *
+ * Author: Lionel Seinturier
+ */
+
+package org.objectweb.fractal.juliac.runtime;
+
+import org.objectweb.fractal.api.Component;
+import org.objectweb.fractal.api.Interface;
+import org.objectweb.fractal.api.NoSuchInterfaceException;
+import org.objectweb.fractal.api.Type;
+import org.objectweb.fractal.api.factory.GenericFactory;
+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.factory.ChainedInstantiationException;
+import org.objectweb.fractal.julia.type.BasicComponentType;
+import org.objectweb.fractal.julia.type.BasicInterfaceType;
+
+/**
+ * The Juliac bootstrap component.
+ *
+ * This bootstrap component provides a type-factory and a generic-factory
+ * interface.
+ *
+ * @author Lionel Seinturier <Lionel.Seinturier@xxxxxxxxxxxxxx>
+ */
+public class JuliacBootstrapComponentImpl
+implements TypeFactory, GenericFactory, Component {
+
+ public JuliacBootstrapComponentImpl() {
+ interfaces = new Object[2];
+ interfaces[0] =
+ new TypeFactoryFcItf(
+ this, "type-factory",
+ new BasicInterfaceType("type-factory",TypeFactory.class.getName(),false,false,false),
+ false, this );
+ interfaces[1] =
+ new GenericFactoryFcItf(
+ this, "generic-factory",
+ new BasicInterfaceType("generic-factory",GenericFactory.class.getName(),false,false,false),
+ false, this );
+ }
+
+ // -----------------------------------------------------------------
+ // Implementation of the TypeFactory interface
+ // -----------------------------------------------------------------
+
+ public InterfaceType createFcItfType(
+ String name, String signature,
+ boolean isClient, boolean isOptional, boolean isCollection)
+ throws InstantiationException {
+
+ return new BasicInterfaceType(
+ name,signature,isClient,isOptional,isCollection);
+ }
+
+ public ComponentType createFcType(InterfaceType[] interfaceTypes)
+ throws InstantiationException {
+
+ return new BasicComponentType(interfaceTypes);
+ }
+
+ // -----------------------------------------------------------------
+ // Implementation of the GenericFactory interface
+ // -----------------------------------------------------------------
+
+ /**
+ * Create a new component.
+ *
+ * @param type the component type
+ * @param controllerDesc
+ * the description of the control membrane associated
+ * to the component
+ * @param contentDesc
+ * the description of the content of the component
+ */
+ public Component newFcInstance(
+ Type type, Object controllerDesc, Object contentDesc )
+ throws InstantiationException {
+ ClassLoader classLoader = null;
+ /*
+ * When called from Fractal ADL, the component creation process may be
+ * accompagnied with some hints. One of the them is the class loader to
+ * be used. In this case, the controllerDesc parameter is an array where
+ * the 1st element contains the class loader.
+ */
+ if( controllerDesc.getClass().isArray() ) {
+ Object[] array = (Object[]) controllerDesc;
+ classLoader = (ClassLoader) array[0];
+ controllerDesc = array[1];
+ }
+
+ /*
+ * Adaptation for templates components.
+ * Templates are created with something like:
+ * Component cTmpl = cf.newFcInstance(
+ * cType, "flatPrimitiveTemplate",
+ * new Object[] { "flatPrimitive", "ClientImpl" });
+ */
+ if( controllerDesc instanceof String ) {
+ if( ((String)controllerDesc).endsWith("Template") ) {
+ Object[] cont = (Object[]) contentDesc;
+ contentDesc = cont[1];
+ }
+ }
+
+ if( !(type instanceof ComponentType) ) {
+ String msg = "ComponentType expected";
+ throw new InstantiationException(msg);
+ }
+
+ /*
+ * Compute the hash code used as the suffix by the initializer class.
+ * The idea is that there is a class for each different record of
+ * content class, controller descriptor and component type. The two
+ * first elements are, by nature, identify. A hash is computed to
+ * uniquely identifies component types.
+ */
+ ComponentType ct = (ComponentType) type;
+ String sct = ct.toString();
+ int hashct = sct.hashCode();
+ String hexhashct = Integer.toHexString(hashct);
+
+ /*
+ * If the specified controllerDesc is a Component, consider that this is
+ * the control membrane which is to be associated with the component.
+ */
+ if( controllerDesc instanceof Component ) {
+ // TODO Koch-like factory
+ throw new UnsupportedOperationException();
+ }
+ else {
+
+ /*
+ * If contentDesc is a string, consider that it is the fully qualified
+ * name of the class which needs to be instantiated. Else, consider that
+ * this is the instance which must be associated with the component.
+ */
+ String membraneClassname =
+ contentDesc == null ?
+ Juliac.JULIAC_GENERATED+"."+controllerDesc :
+ (contentDesc instanceof String ? contentDesc : contentDesc.getClass().getName())
+ +"FC"+controllerDesc;
+ String targetClassname = membraneClassname+"FC"+hexhashct;
+ Class cl = loadClass(targetClassname, classLoader);
+ Factory f = (Factory) instanciateClass(cl);
+ Component c =
+ (contentDesc==null || contentDesc instanceof String) ?
+ f.newFcInstance() :
+ f.newFcInstance(contentDesc);
+ return c;
+ }
+ }
+
+
+ // -----------------------------------------------------------------
+ // Utility methods
+ // -----------------------------------------------------------------
+
+ /**
+ * Load and instantiate the given class name.
+ * @param name the fully qualified name of the class to load
+ * @param classLoader the classloader to use; if null, the default class loader is used instead
+ */
+ private Class loadClass(String name, ClassLoader classLoader)
+ throws InstantiationException
+ {
+
+ if (classLoader !=null) {
+ try
+ {
+ Class c = classLoader.loadClass(name);
+ return c;
+ }catch (ClassNotFoundException cnfe) {
+ return loadClass(name);
+ }
+ } else {
+ return loadClass(name);
+ }
+}
+ /**
+ * Load and instantiate the given class name.
+ * @param name the fully qualified name of the class to load
+ */
+ private Class loadClass(String name) throws InstantiationException {
+ try
+ {
+ Class cl = Class.forName(name);
+ return cl;
+
+ }
+ catch (ClassNotFoundException cnfe2)
+ {
+ final String msg = "ClassNotFoundException: " + name;
+ throw new ChainedInstantiationException(cnfe2, null, msg);
+ }
+ }
+
+ /**
+ * Load and instantiate the given class name.
+ */
+ private Object instanciateClass( Class cl ) throws InstantiationException {
+
+ try {
+ Object o = cl.newInstance();
+ return o;
+ }
+ catch( java.lang.InstantiationException ie ) {
+ final String msg =
+ "java.lang.InstantiationException when instantiating class: "+
+ cl.getName();
+ throw new ChainedInstantiationException(ie,null,msg);
+ }
+ catch( IllegalAccessException iae ) {
+ final String msg =
+ "IllegalAccessException when instantiating class: "+
+ cl.getName();
+ throw new ChainedInstantiationException(iae,null,msg);
+ }
+ }
+
+ // -----------------------------------------------------------------
+ // Implementation of the Component interface
+ // -----------------------------------------------------------------
+
+ public Object getFcInterface(String arg0) throws NoSuchInterfaceException {
+ for (int i = 0; i < interfaces.length; i++) {
+ String name = ((Interface)interfaces[i]).getFcItfName();
+ if( name.equals(arg0) ) {
+ return interfaces[i];
+ }
+ }
+ throw new NoSuchInterfaceException(arg0);
+ }
+
+ public Object[] getFcInterfaces() {
+ return interfaces;
+ }
+
+ public Type getFcType() {
+ return Juliac.get().getFcInstanceType();
+ }
+
+ private Object[] interfaces;
+}
--- trunk/juliac/runtime/oo/src/main/java/org/objectweb/fractal/juliac/runtime/Launcher.java (rev 0)
+++ trunk/juliac/runtime/oo/src/main/java/org/objectweb/fractal/juliac/runtime/Launcher.java 2008-05-27 20:09:56 UTC (rev 7800)
@@ -0,0 +1,119 @@
+/***
+ * Juliac
+ * Copyright (C) 2007 INRIA, 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@xxxxxxxxxxxxxx
+ *
+ * Author: Lionel Seinturier
+ */
+
+package org.objectweb.fractal.juliac.runtime;
+
+import org.objectweb.fractal.api.Component;
+import org.objectweb.fractal.api.NoSuchInterfaceException;
+import org.objectweb.fractal.api.control.IllegalLifeCycleException;
+import org.objectweb.fractal.api.factory.Factory;
+import org.objectweb.fractal.api.factory.InstantiationException;
+import org.objectweb.fractal.util.Fractal;
+
+/**
+ * <p>
+ * The class provides a {@link #main(String[])} method for launching a Fractal
+ * component compiled with Juliac.
+ * </p>
+ *
+ * <p>
+ * The first command line argument must be the fully-qualified name of the
+ * component to instantiate. If present, the second command line argument
+ * designates the name of a {@link Runnable} server interface provided by the
+ * component which is invoked by this program.
+ * </p>
+ *
+ * @author Lionel Seinturier <Lionel.Seinturier@xxxxxxxxxxxxxx>
+ */
+public class Launcher {
+
+ /**
+ * Entry point for this program.
+ */
+ public static void main(String[] args)
+ throws
+ ClassNotFoundException, InstantiationException, IllegalAccessException,
+ java.lang.InstantiationException, IllegalArgumentException,
+ NoSuchInterfaceException, IllegalLifeCycleException {
+
+ if( args.length==0 || args.length>2 ) {
+ usage();
+ return;
+ }
+
+ /*
+ * Retrieve the factory.
+ */
+ String adl = args[0];
+ Class cl = Class.forName(adl);
+ Object o = cl.newInstance();
+
+ if( o instanceof Factory ) {
+
+ /*
+ * Fractal factory.
+ */
+ Factory factory = (Factory) o;
+ Component root = factory.newFcInstance();
+ Fractal.getLifeCycleController(root).startFc();
+
+ /*
+ * If an interface name has been specified in the command line
+ * arguments, invoke it.
+ */
+ if( args.length == 2 ) {
+ String itfname = args[1];
+ Object itf = root.getFcInterface(itfname);
+ if( !(itf instanceof Runnable) ) {
+ String msg =
+ "The "+itfname+
+ " interface should implement java.lang.Runnable";
+ throw new IllegalArgumentException(msg);
+ }
+ ((Runnable)itf).run();
+ }
+ }
+ else {
+ if( o instanceof Runnable ) {
+ /*
+ * Not a Fractal factory. Assume the class implements Runnable.
+ */
+ ((Runnable)o).run();
+ }
+ else {
+ String msg = "Illegal factory class: "+adl;
+ throw new IllegalArgumentException(msg);
+ }
+ }
+ }
+
+ /**
+ * Display the usage information for this program.
+ */
+ public static void usage() {
+ System.out.println("Usage: java "+Launcher.class.getName()+" factory [itfname]");
+ System.out.println("where:");
+ System.out.println("- factory is the fully-qualified name of a Fractal Factory");
+ System.out.println("- itfname is the name of a Runnable Fractal interface");
+ }
+}
--- trunk/juliac/runtime/oo/src/main/java/org/objectweb/fractal/juliac/runtime/TypeFactoryFcItf.java (rev 0)
+++ trunk/juliac/runtime/oo/src/main/java/org/objectweb/fractal/juliac/runtime/TypeFactoryFcItf.java 2008-05-27 20:09:56 UTC (rev 7800)
@@ -0,0 +1,72 @@
+/***
+ * Juliac
+ * Copyright (C) 2007 INRIA, 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@xxxxxxxxxxxxxx
+ *
+ * Author: Lionel Seinturier
+ */
+
+package org.objectweb.fractal.juliac.runtime;
+
+import org.objectweb.fractal.api.Component;
+import org.objectweb.fractal.api.Type;
+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.BasicComponentInterface;
+
+/**
+ * Implementation of the Fractal interface for {@link TypeFactory}.
+ *
+ * @author Lionel Seinturier <Lionel.Seinturier@xxxxxxxxxxxxxx>
+ */
+public class TypeFactoryFcItf
+extends BasicComponentInterface implements TypeFactory {
+
+ public TypeFactoryFcItf( Component component, String s, Type type, boolean flag, Object obj ) {
+ super(component, s, type, flag, obj);
+ }
+
+ public Object getFcItfImpl() {
+ return impl;
+ }
+
+ public void setFcItfImpl(Object obj) {
+ impl = (TypeFactory) obj;
+ }
+
+ private TypeFactory impl;
+
+ public InterfaceType createFcItfType(
+ String arg0, String arg1, boolean arg2, boolean arg3, boolean arg4)
+ throws InstantiationException {
+ if (impl == null)
+ throw new NullPointerException(
+ "Trying to invoke a method on a client interface, or on a server interface whose complementary interface is not bound.");
+ return impl.createFcItfType(arg0, arg1, arg2, arg3, arg4);
+ }
+
+ public ComponentType createFcType( InterfaceType[] arg0 )
+ throws InstantiationException {
+ if (impl == null)
+ throw new NullPointerException(
+ "Trying to invoke a method on a client interface, or on a server interface whose complementary interface is not bound.");
+ return impl.createFcType(arg0);
+ }
+}
--- trunk/juliac/runtime/pom.xml 2008-05-27 20:07:16 UTC (rev 7799)
+++ trunk/juliac/runtime/pom.xml 2008-05-27 20:09:56 UTC (rev 7800)
@@ -2,23 +2,20 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.objectweb.fractal.juliac</groupId>
- <artifactId>juliac-parent</artifactId>
+ <parent>
+ <groupId>org.objectweb.fractal.juliac</groupId>
+ <artifactId>juliac-parent</artifactId>
<version>2.0-SNAPSHOT</version>
- </parent>
+ </parent>
- <groupId>org.objectweb.fractal.juliac</groupId>
- <artifactId>juliac-runtime</artifactId>
- <packaging>jar</packaging>
- <name>Juliac Runtime</name>
-
- <dependencies>
- <dependency>
- <groupId>org.objectweb.fractal.julia</groupId>
- <artifactId>koch-runtime</artifactId>
- <version>2.5.2.1</version>
- </dependency>
- </dependencies>
+ <groupId>org.objectweb.fractal.juliac</groupId>
+ <artifactId>juliac-runtime-parent</artifactId>
+ <packaging>pom</packaging>
+ <name>Juliac Runtime Parent</name>
+ <modules>
+ <module>oo</module>
+ <module>comp</module>
+ </modules>
+
</project>
--- trunk/juliac/tests-conf/pom.xml 2008-05-27 20:07:16 UTC (rev 7799)
+++ trunk/juliac/tests-conf/pom.xml 2008-05-27 20:09:56 UTC (rev 7800)
@@ -25,6 +25,11 @@
<version>${project.version}</version>
</dependency>
<dependency>
+ <groupId>org.objectweb.fractal.juliac</groupId>
+ <artifactId>juliac-runtime-comp</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
| <-- Date Index --> | <-- Thread Index --> |
Powered by MHonArc.
Copyright © 2006-2007, OW2 Consortium | contact | webmaster.