Commit a1b14974 authored by Philippe Merle's avatar Philippe Merle

The goal of this commits is to reduce the requirement to have two FraSCAti assembly factories:

1) class AssemblyFactory without code generation and compilation (module frascati-assembly-factory),
2) class Factory with Juliac-based generation and compilation (previous module frascati-runtime-factory).

* Replaced most usage of the class Factory by the class AssemblyFactory.
* Renamed the class Factory to RuntimeFactory.
  This will help to easily identify where the second assembly factory is still required.
* Renamed module frascati-runtime-factory into frascati-assembly-factory-juliac-jdt-tinfi-oo
* Used the OW2 FraSCAti Compiler to compile SCA composites describing the architecture of OW2 FraSCAti.
  This generates code at compilation time and then reduce the requirement to generate code at runtime.
* Moved to Tinfi 1.3.1-SNAPSHOT and Juliac 2.2.5-SNAPSHOT.
parent 4ea4eaf5
......@@ -37,7 +37,8 @@ import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.apache.commons.cli.PosixParser;
import org.ow2.frascati.assembly.factory.Factory;
import org.ow2.frascati.assembly.factory.AssemblyFactory;
import org.ow2.frascati.assembly.factory.RuntimeFactory;
import org.ow2.frascati.assembly.factory.Launcher;
import org.ow2.frascati.util.FrascatiException;
......@@ -217,19 +218,20 @@ public class FactoryCommandLine {
}
Factory f = null;
AssemblyFactory f = null;
Launcher launcher = null;
try {
if ( cmd.isFscriptEnabled() )
try {
f = (Factory) Class.forName(FRASCATISCRIPT_FACTORY).newInstance();
f = (AssemblyFactory) Class.forName(FRASCATISCRIPT_FACTORY).newInstance();
} catch (Exception e) {
throw new FrascatiException(e);
}
else
f = new Factory();
f = new RuntimeFactory();
// TODO
// TODO Reactive this feature.
// f.getService(f.getFactory(), "juliac", JuliacConfiguration.class).setOutputDir(new File(cmd.getBaseDir()));
......
......@@ -28,18 +28,21 @@ package org.ow2.frascati.intent.availability.test;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.objectweb.fractal.api.Component;
import org.osoa.sca.ServiceUnavailableException;
import org.ow2.frascati.assembly.factory.Factory;
import org.ow2.frascati.assembly.factory.AssemblyFactory;
import org.ow2.frascati.tinfi.TinfiDomain;
public class AvailabilityTestCase {
Factory factory;
AssemblyFactory factory;
@Before
public void init() throws Exception {
factory = new Factory();
factory = new AssemblyFactory();
}
@Test
......
......@@ -36,7 +36,7 @@ import org.objectweb.fractal.api.NoSuchInterfaceException;
import org.osoa.sca.annotations.Scope;
import org.ow2.frascati.assembly.factory.Factory;
import org.ow2.frascati.assembly.factory.AssemblyFactory;
import org.ow2.frascati.tinfi.TinfiDomain;
import org.ow2.frascati.util.FrascatiException;
......@@ -108,7 +108,7 @@ public class ChatGUI
String compositeName = "chat-gui-client",
serviceName = "chatService";
Component c = new Factory().getComposite(compositeName);
Component c = new AssemblyFactory().getComposite(compositeName);
try {
service = TinfiDomain.getService(c, Chat.class, serviceName);
......
......@@ -32,7 +32,7 @@ import org.objectweb.fractal.api.Component;
import org.objectweb.fractal.api.NoSuchInterfaceException;
import org.objectweb.fractal.api.control.IllegalLifeCycleException;
import org.ow2.frascati.assembly.factory.Factory;
import org.ow2.frascati.assembly.factory.RuntimeFactory;
import org.ow2.frascati.tinfi.TinfiDomain;
import org.ow2.frascati.util.FrascatiException;
......@@ -58,7 +58,7 @@ public abstract class FraSCAtiTestCase {
public void loadComposite() throws FrascatiException {
String compositeName = getComposite();
System.out.println("Loading " + compositeName + " composite...");
scaComposite = new Factory().getComposite(compositeName);
scaComposite = new RuntimeFactory().getComposite(compositeName);
}
/**
......@@ -97,10 +97,11 @@ public abstract class FraSCAtiTestCase {
// ---------------------------------------------------------------------------
// Abstract methods
// ---------------------------------------------------------------------------
/**
* Return the name of the composite to test
* Return the name of the composite to test.
*
* @return name of the composite to test
* @return the name of the composite to test.
*/
public abstract String getComposite();
......
......@@ -131,6 +131,7 @@ public class FrascatiCompilerMojo extends AbstractMojo {
// Add dependencies specified in the classpath of the project (pom.xml).
File baseDir = project.getBasedir();
// Set the default directory for the generate factory
System.setProperty("org.ow2.frascati.output.directory", baseDir.getAbsolutePath() + File.separator + "target");
// Add default maven directories to srcs and libs
......@@ -210,7 +211,7 @@ public class FrascatiCompilerMojo extends AbstractMojo {
// juliac.setOutputDir(new File(baseDir.getAbsolutePath()+ File.separator + "target"));
// Add path to java source code
juliac.addJavaSource(srcs);
// juliac.addJavaSource(srcs);
// Get reference on the "runtime" interface given by the
// Assembly factory runtime component
......@@ -221,14 +222,14 @@ public class FrascatiCompilerMojo extends AbstractMojo {
srcUrl[i] = new File(srcs[i]).toURI().toURL();
}
// Load resources from srcs and into factory ClassLoader
classLoaderManager.loadLibraries(srcUrl);
// Load additional libraries
// classLoaderManager.loadLibraries(urls);
// libs = addToArray(libs, "src/main/resources");
classLoaderManager.loadLibraries(urls);
classLoaderManager.loadLibraries(new URL[]{new File(baseDir.getAbsolutePath() + File.separator + "src/main/resources").toURI().toURL()});
classLoaderManager.loadLibraries(urls);
// Load resources from srcs into factory ClassLoader
classLoaderManager.loadLibraries(srcUrl);
// Get reference on the "load" interface given by the
// Assembly factory runtime component
......
......@@ -44,7 +44,8 @@ import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.project.MavenProject;
import org.ow2.frascati.assembly.factory.Factory;
import org.ow2.frascati.assembly.factory.AssemblyFactory;
import org.ow2.frascati.assembly.factory.RuntimeFactory;
import org.ow2.frascati.assembly.factory.Launcher;
import org.ow2.frascati.fscript.FrascatiScriptFactory;
import org.ow2.frascati.util.FrascatiException;
......@@ -229,13 +230,13 @@ public class FrascatiLauncherMojo extends AbstractMojo {
currentThread.setContextClassLoader(new URLClassLoader(getClasspath(Arrays.asList(oldThreadContextClassLoader.getURLs())), oldThreadContextClassLoader));
try {
Factory factory = null;
AssemblyFactory factory = null;
Launcher launcher = null;
if (useFscript)
factory = new FrascatiScriptFactory();
else
factory = new Factory();
factory = new RuntimeFactory();
launcher = new Launcher(composite, factory);
......
......@@ -28,7 +28,7 @@ package org.ow2.frascati.test;
import org.junit.Test;
import org.ow2.frascati.assembly.factory.Factory;
import org.ow2.frascati.assembly.factory.RuntimeFactory;
/**
* JUnit test case for Factory class.
......@@ -39,7 +39,7 @@ public class FactoryTest {
@Test
public void newFactory() throws Exception {
Factory factory = new Factory();
new RuntimeFactory().getFactory();
}
}
<?xml version="1.0"?>
<!--
* OW2 FraSCAti: Assembly Factory Runtime
* OW2 FraSCAti: Assembly Factory with Juliac, JDT and Tinfi OO
*
* Copyright (c) 2007-2010 INRIA
*
......@@ -36,7 +36,10 @@
<groupId>org.ow2.frascati</groupId>
<artifactId>frascati-runtime-factory</artifactId>
<name>OW2 FraSCAti: Runtime Factory Module</name>
<!--
<artifactId>frascati-assembly-factory-juliac-jdt-tinfi-oo</artifactId>
-->
<name>OW2 FraSCAti: Assembly Factory with Juliac, JDT and Tinfi OO Module</name>
<url>http://frascati.ow2.org</url>
<inceptionYear>2007</inceptionYear>
......@@ -82,7 +85,7 @@
<artifactId>maven-juliac-plugin</artifactId>
<configuration>
<adls>
<adl>org.ow2.frascati.assembly.factory.FactoryBootstrap</adl>
<adl>org.ow2.frascati.assembly.factory.RuntimeFactoryBootstrap</adl>
</adls>
</configuration>
</plugin>
......@@ -94,7 +97,7 @@
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>org.ow2.frascati.assembly.factory.Factory</mainClass>
<mainClass>org.ow2.frascati.assembly.factory.RuntimeFactory</mainClass>
</manifest>
</archive>
</configuration>
......
......@@ -79,7 +79,7 @@ public class Launcher {
public Launcher(String compositeName)
throws FrascatiException {
try {
scaComposite = new Factory().getComposite(compositeName);
scaComposite = new RuntimeFactory().getComposite(compositeName);
this.compositeName = compositeName;
} catch (FrascatiException e) {
log.severe("Unable to launch " + compositeName + ": "
......@@ -95,7 +95,7 @@ public class Launcher {
* @param f the factory to use to create composite
* @throws FrascatiException
*/
public Launcher(String compositeName, Factory f)
public Launcher(String compositeName, AssemblyFactory f)
throws FrascatiException {
try {
scaComposite = f.getComposite(compositeName);
......@@ -116,7 +116,7 @@ public class Launcher {
* @param urls URLs of libraries required to launch the composite
* @throws FrascatiException
*/
public Launcher(String compositeName, Factory f, URL[] urls)
public Launcher(String compositeName, AssemblyFactory f, URL[] urls)
throws FrascatiException {
try {
scaComposite = f.getComposite(compositeName,urls);
......@@ -138,7 +138,7 @@ public class Launcher {
public void launch() throws FrascatiException {
if (compositeName != null) {
try {
scaComposite = new Factory().getComposite(compositeName);
scaComposite = new RuntimeFactory().getComposite(compositeName);
} catch (FrascatiException e) {
log.severe("Unable to launch " + compositeName + ": "
+ e.getMessage());
......
......@@ -31,4 +31,10 @@ import org.ow2.frascati.assembly.factory.AssemblyFactory;
/**
* @author <a href="mailto:damien.fournier@inria.fr">Damien Fournier</a>
*/
public class Factory extends AssemblyFactory {}
public class RuntimeFactory extends AssemblyFactory {
protected String getBootstrapFactoryName() {
return "org.ow2.frascati.assembly.factory.RuntimeFactoryBootstrap";
}
}
......@@ -24,13 +24,16 @@
<!-- Lionel Seinturier -->
<!-- -->
<!-- -->
<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:af="org/ow2/frascati/assembly/factory" xmlns:parser="org/ow2/frascati/parser" name="org.ow2.frascati.assembly.factory.FactoryBootstrap">
<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:af="org/ow2/frascati/assembly/factory" xmlns:parser="org/ow2/frascati/parser" name="org.ow2.frascati.assembly.factory.RuntimeFactoryBootstrap">
<service name="composite-manager" promote="assembly-factory/composite-manager">
<interface.java interface="org.ow2.frascati.assembly.factory.api.CompositeManager" />
</service>
<service name="classloader-manager" promote="assembly-factory/classloader-manager">
<interface.java interface="org.ow2.frascati.assembly.factory.api.ClassLoaderManager"/>
</service>
<service name="juliac" promote="component-factory/juliac">
<interface.java interface="org.ow2.frascati.component.factory.juliac.api.JuliacConfiguration"/>
</service>
<component name="assembly-factory">
<implementation.composite name="af:AssemblyFactory.composite"/>
<service name="composite-manager">
......@@ -81,5 +84,8 @@
<service name="type-factory">
<interface.java interface="org.ow2.frascati.component.factory.api.TypeFactory"/>
</service>
<service name="juliac">
<interface.java interface="org.ow2.frascati.component.factory.juliac.api.JuliacConfiguration"/>
</service>
</component>
</composite>
\ No newline at end of file
......@@ -34,6 +34,9 @@
<service name="membrane-generation" promote="factory/membrane-generation">
<interface.java interface="org.ow2.frascati.component.factory.api.MembraneGeneration"/>
</service>
<service name="juliac" promote="juliac/juliac">
<interface.java interface="org.ow2.frascati.component.factory.juliac.api.JuliacConfiguration"/>
</service>
<component name="factory">
<implementation.java class="org.ow2.frascati.component.factory.impl.ComponentFactoryImpl"/>
<property name="sca-primitive-membrane">scaPrimitive</property>
......
......@@ -42,7 +42,7 @@ import org.osoa.sca.annotations.Property;
import org.objectweb.fractal.api.Component;
import org.ow2.frascati.assembly.factory.Factory;
import org.ow2.frascati.assembly.factory.AssemblyFactory;
import org.ow2.frascati.assembly.factory.api.CompositeManager;
/**
......@@ -56,7 +56,7 @@ public class AllSupportedPropertyTypesTest implements Runnable {
@Test
public void loadIt() throws Exception {
Factory assemblyFactory = new Factory();
AssemblyFactory assemblyFactory = new AssemblyFactory();
CompositeManager compositeManager = assemblyFactory.getCompositeManager();
Component component = assemblyFactory.getComposite("AllSupportedPropertyTypes.composite");
Runnable runnable = (Runnable)component.getFcInterface("Runnable");
......
......@@ -28,18 +28,18 @@ package org.ow2.frascati.assembly.factory.test;
import org.junit.Test;
import org.ow2.frascati.assembly.factory.Factory;
import org.ow2.frascati.assembly.factory.AssemblyFactory;
/**
* JUnit test case for Factory class.
* JUnit test case for OW2 FraSCAti Assembly Factory class.
*
* @author Philippe Merle.
*/
public class FactoryTest {
public class AssemblyFactoryTest {
@Test
public void getFactory() throws Exception {
new Factory().getFactory();
public void newAssemblyFactory() throws Exception {
new AssemblyFactory().getFactory();
}
}
......@@ -30,7 +30,7 @@ import org.junit.Test;
import org.objectweb.fractal.api.Component;
import org.ow2.frascati.assembly.factory.Factory;
import org.ow2.frascati.assembly.factory.AssemblyFactory;
import org.ow2.frascati.assembly.factory.api.CompositeManager;
/**
......@@ -49,7 +49,7 @@ public class GenericComponentTest implements GenericInterface<String>
@Test
public void testIt() throws Exception {
Factory assemblyFactory = new Factory();
AssemblyFactory assemblyFactory = new AssemblyFactory();
CompositeManager compositeManager = assemblyFactory.getCompositeManager();
Component component = assemblyFactory.getComposite("GenericComponent.composite");
GenericInterface<String> genericInterface = (GenericInterface<String>)component.getFcInterface("GenericInterface");
......
......@@ -80,7 +80,7 @@ public class AssemblyFactory
* Get the name of the SCA composite representing the bootstrap factory to use.
*/
protected String getBootstrapFactoryName() {
return this.getClass().getCanonicalName() + "Bootstrap";
return "org.ow2.frascati.assembly.factory.AssemblyFactoryBootstrap";
}
/**
......
......@@ -78,14 +78,12 @@
<plugins>
<!-- Compile the SCA architecture of the OW2 FraSCAti Binding Factory with JuliaC. -->
<!-- Compile the OW2 FraSCAti SCA composite. -->
<plugin>
<groupId>org.objectweb.fractal.juliac</groupId>
<artifactId>maven-juliac-plugin</artifactId>
<groupId>org.ow2.frascati.mojo</groupId>
<artifactId>frascati-compiler-plugin</artifactId>
<configuration>
<adls>
<adl>org.ow2.frascati.binding.factory.BindingFactory</adl>
</adls>
<composite>org/ow2/frascati/FraSCAti</composite>
</configuration>
</plugin>
......@@ -99,7 +97,7 @@
<dependencies>
<!-- OW2 FraSCAti Runtime Factory Module. -->
<!-- OW2 FraSCAti Assembly Factory Module. -->
<dependency>
<groupId>org.ow2.frascati</groupId>
<artifactId>frascati-runtime-factory</artifactId>
......
......@@ -37,9 +37,11 @@ import org.objectweb.fractal.api.control.BindingController;
import org.objectweb.fractal.api.control.IllegalLifeCycleException;
import org.objectweb.fractal.api.control.LifeCycleController;
import org.objectweb.fractal.api.factory.InstantiationException;
import org.objectweb.fractal.bf.BindingFactory;
import org.objectweb.fractal.bf.BindingFactoryException;
import org.ow2.frascati.assembly.factory.Factory;
import org.ow2.frascati.assembly.factory.AssemblyFactory;
import org.ow2.frascati.assembly.factory.api.ClassLoaderManager;
import org.ow2.frascati.assembly.factory.api.CompositeManager;
import org.ow2.frascati.assembly.factory.api.ManagerException;
......@@ -274,9 +276,7 @@ implements CompositeManager, ClassLoaderManager, BindingFactory, BindingControll
IllegalAccessException, java.lang.InstantiationException,
org.ow2.frascati.util.FrascatiException {
// Component fd = TinfiDomain.getComponent("org.ow2.frascati.factory.FrascatiDomain");
// Fractal.getLifeCycleController(fd).startFc();
Component fd = new Factory().getFactory();
Component fd = new AssemblyFactory().getFactory();
compositeManager = (CompositeManager) fd.getFcInterface("composite-manager");
classloaderManager = (ClassLoaderManager) fd.getFcInterface("classloader-manager");
......
......@@ -24,11 +24,11 @@
*
*/
package org.ow2.frascati.binding.factory;
package org.ow2.frascati.binding.factory.test;
import org.junit.Test;
import org.ow2.frascati.assembly.factory.Factory;
import org.ow2.frascati.assembly.factory.RuntimeFactory;
/**
* JUnit test case for Factory class.
......@@ -39,7 +39,7 @@ public class FactoryTest {
@Test
public void newFactory() throws Exception {
new Factory();
new RuntimeFactory().getFactory();
}
}
......@@ -79,6 +79,7 @@
<plugins>
<!-- Compile the SCA composite of the OW2 FraSCAti HTTP Binding composite with OW2 Fractal JuliaC. -->
<!-- -->
<plugin>
<groupId>org.objectweb.fractal.juliac</groupId>
<artifactId>maven-juliac-plugin</artifactId>
......@@ -88,7 +89,17 @@
</adls>
</configuration>
</plugin>
<!-- -->
<!-- Compile OW2 FraSCAti SCA composite. -->
<!-- TODO: method not implemented into Juliac Spoon
<plugin>
<groupId>org.ow2.frascati.mojo</groupId>
<artifactId>frascati-compiler-plugin</artifactId>
<configuration>
<composite>org/ow2/frascati/FraSCAti</composite>
</configuration>
</plugin>
-->
</plugins>
</build>
......@@ -99,7 +110,7 @@
<dependencies>
<!-- OW2 FraSCAti Runtime Factory Module. -->
<!-- OW2 FraSCAti Assembly Factory Module. -->
<dependency>
<groupId>org.ow2.frascati</groupId>
<artifactId>frascati-runtime-factory</artifactId>
......
......@@ -32,7 +32,7 @@ import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.Test;
import org.ow2.frascati.assembly.factory.Factory;
import org.ow2.frascati.assembly.factory.RuntimeFactory;
import org.ow2.frascati.assembly.factory.api.CompositeManager;
import org.ow2.frascati.assembly.factory.api.ManagerException;
import org.ow2.frascati.assembly.factory.api.ProcessingContext;
......@@ -45,12 +45,12 @@ import org.ow2.frascati.assembly.factory.processor.ProcessingContextImpl;
*/
public class FactoryTest {
Factory assemblyFactory;
RuntimeFactory assemblyFactory;
CompositeManager compositeManager;
@Before
public void initFactory() throws Exception {
assemblyFactory = new Factory();
assemblyFactory = new RuntimeFactory();
compositeManager = assemblyFactory.getCompositeManager();
}
......
......@@ -77,6 +77,14 @@
<defaultGoal>install</defaultGoal>
<plugins>
<!-- Compile OW2 FraSCAti SCA composite. -->
<plugin>
<groupId>org.ow2.frascati.mojo</groupId>
<artifactId>frascati-compiler-plugin</artifactId>
<configuration>
<composite>org/ow2/frascati/FraSCAti</composite>
</configuration>
</plugin>
</plugins>
</build>
......@@ -87,25 +95,28 @@
<dependencies>
<!-- OW2 FraSCAti Runtime Factory Module. -->
<!-- OW2 FraSCAti Assembly Factory Module. -->
<dependency>
<groupId>org.ow2.frascati</groupId>
<artifactId>frascati-runtime-factory</artifactId>
<version>${frascati.version}</version>
</dependency>
<!-- OW2 FraSCAti Metamodel Module. -->
<dependency>
<groupId>org.ow2.frascati</groupId>
<artifactId>frascati-metamodel-frascati</artifactId>
<version>${frascati.version}</version>
</dependency>
<!-- OW2 FraSCAti Binding Factory Module. -->
<dependency>
<groupId>org.ow2.frascati</groupId>
<artifactId>frascati-binding-factory</artifactId>
<version>${frascati.version}</version>
</dependency>
<!-- OW2 Fractal JSON-RPC Connector Module. -->
<dependency>
<groupId>org.objectweb.fractal.bf.connectors</groupId>
<artifactId>fractal-bf-connectors-json-rpc</artifactId>
......
......@@ -28,18 +28,18 @@ package org.ow2.frascati.binding.jsonrpc;
import org.junit.Test;
import org.ow2.frascati.assembly.factory.Factory;
import org.ow2.frascati.assembly.factory.AssemblyFactory;
/**
* JUnit test case for Factory class.
* JUnit test case for OW2 FraSCAti Assembly Factory class.
*
* @author Philippe Merle.
*/
public class FactoryTest {
public class AssemblyFactoryTest {
@Test
public void newFactory() throws Exception {
new Factory();
public void newAssemblyFactory() throws Exception {
new AssemblyFactory().getFactory();
}
}
......@@ -77,6 +77,14 @@
<defaultGoal>install</defaultGoal>
<plugins>
<!-- Compile OW2 FraSCAti SCA composite. -->
<plugin>
<groupId>org.ow2.frascati.mojo</groupId>
<artifactId>frascati-compiler-plugin</artifactId>
<configuration>
<composite>org/ow2/frascati/FraSCAti</composite>
</configuration>
</plugin>
</plugins>
</build>
......@@ -87,25 +95,28 @@
<dependencies>
<!-- OW2 FraSCAti Runtime Factory Module. -->
<!-- OW2 FraSCAti Assembly Factory Module. -->
<dependency>
<groupId>org.ow2.frascati</groupId>
<artifactId>frascati-runtime-factory</artifactId>
<version>${frascati.version}</version>
</dependency>
<!-- OW2 FraSCAti Metamodel Module. -->
<dependency>
<groupId>org.ow2.frascati</groupId>
<artifactId>frascati-metamodel-frascati</artifactId>
<version>${frascati.version}</version>
</dependency>
<!-- OW2 FraSCAti Binding Factory Module. -->
<dependency>
<groupId>org.ow2.frascati</groupId>
<artifactId>frascati-binding-factory</artifactId>
<version>${frascati.version}</version>
</dependency>
<!-- OW2 Fractal REST Connector Module. -->
<dependency>
<groupId>org.objectweb.fractal.bf.connectors</groupId>
<artifactId>fractal-bf-connectors-rest-cxf</artifactId>
......
......@@ -28,18 +28,18 @@ package org.ow2.frascati.binding.rest;
import org.junit.Test;
import org.ow2.frascati.assembly.factory.Factory;
import org.ow2.frascati.assembly.factory.AssemblyFactory;
/**
* JUnit test case for Factory class.
* JUnit test case for OW2 FraSCAti Assembly Factory class.
*
* @author Philippe Merle.
*/
public class FactoryTest {
public class AssemblyFactoryTest {
@Test
public void newFactory() throws Exception {
new Factory();
public void newAssemblyFactory() throws Exception {
new AssemblyFactory().getFactory();