Commit d26468cd authored by dfournier's avatar dfournier
Browse files

* WIP : Add assembly factory runtime personality

* WIP : Add helloworld-bin example
parent 6e22a406
<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.scorware.assembly.examples</groupId>
<artifactId>helloworld-bin</artifactId>
<version>0.3-SNAPSHOT</version>
</parent>
<groupId>org.scorware.assembly.examples</groupId>
<artifactId>helloworld-bin-assembly</artifactId>
<packaging>jar</packaging>
<properties>
<example.main.class>example.hw.Client</example.main.class>
<example.main.composite>helloworld.composite</example.main.composite>
</properties>
<name>Assembly Factory Examples: HelloWorld Binary - runtime</name>
<dependencies>
<dependency>
<groupId>org.scorware.assembly</groupId>
<artifactId>runtime-factory</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.scorware.assembly.examples</groupId>
<artifactId>helloworld-bin-code</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>
/***
* Assembly Factory Examples : HelloWorld
* Copyright (C) 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: Damien.Fournier@inria.fr
*
* Author: Damien Fournier
*/
package example.hw;
import org.objectweb.fractal.api.Component;
import org.scorware.assembly.AssemblyFactoryRuntime;
import org.scorware.tinfi.TinfiDomain;
public class Client {
public static void main(String args []) {
Component scaDomain;
try {
System.out.println("\n\n\nStarting The Helloworld Example \n");
scaDomain = AssemblyFactoryRuntime.getComposite("helloworld");
java.lang.Runnable hello = TinfiDomain.getService(scaDomain,
java.lang.Runnable.class, "r");
// performs some calls
hello.run();
//closing sca domain
TinfiDomain.close(scaDomain);
System.out.println("\n\n\n");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!-- Assembly Factory Examples : HelloWorld -->
<!-- Copyright (C) 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: Damien.Fournier@inria.fr -->
<!-- -->
<!-- Author: Damien Fournier -->
<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" targetNamespace="http://helloworld"
xmlns:hw="http://helloworld" name="helloworld">
<service name="r" promote="client/r">
<interface.java interface="java.lang.Runnable" />
</service>
<component name="client">
<service name="r">
<interface.java interface="java.lang.Runnable" />
</service>
<reference name="s" target="server/s" >
<interface.java interface="example.hw.Service" />
</reference>
<implementation.java class="example.hw.ClientImpl" />
</component>
<component name="server">
<service name="s">
<interface.java interface="example.hw.Service" />
</service>
<implementation.java class="example.hw.ServerImpl" />
</component>
</composite>
<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.scorware.assembly.examples</groupId>
<artifactId>helloworld-bin</artifactId>
<version>0.3-SNAPSHOT</version>
</parent>
<groupId>org.scorware.assembly.examples</groupId>
<artifactId>helloworld-bin-code</artifactId>
<packaging>jar</packaging>
<name>Assembly Factory Examples: HelloWorld Binary - java</name>
</project>
package example.hw;
import org.osoa.sca.annotations.Init;
import org.osoa.sca.annotations.Reference;
public class ClientImpl implements Runnable {
public ClientImpl() {
Console.println("CLIENT created");
}
@Init
public void init() {
Console.println("CLIENT initialized");
}
public void run() {
s.print("hello world");
}
@Reference
public Service s;
}
\ No newline at end of file
package example.hw;
import java.io.PrintStream;
public class Console {
public static PrintStream ps = System.err;
public static void println( String msg ) {
ps.println(msg);
}
}
package example.hw;
import org.osoa.sca.annotations.Property;
public class ServerImpl implements Service {
private String header = "->";
private int count = 1;
public ServerImpl() {
Console.println("SERVER created");
}
public void print(final String msg) {
Console.println("Server: begin printing...");
for (int i = 0 ; i < (count) ; ++i) {
Console.println(((header) + msg));
}
Console.println("Server: print done.");
}
public String getHeader() {
return header;
}
@Property
public void setHeader(final String header) {
this.header = header;
}
public int getCount() {
return count;
}
@Property
public void setCount(final int count) {
this.count = count;
}
}
\ No newline at end of file
package example.hw;
public interface Service {
void print(String msg);
}
\ No newline at end of file
<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.scorware.assembly.examples</groupId>
<artifactId>parent</artifactId>
<version>0.3-SNAPSHOT</version>
</parent>
<packaging>pom</packaging>
<groupId>org.scorware.assembly.examples</groupId>
<artifactId>helloworld-bin</artifactId>
<name>Assembly Factory Examples: HelloWorld Binary</name>
<modules>
<module>code</module>
<module>assembly</module>
</modules>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<!--
* SCOrWare Assembly Factory.
*
* Copyright (c) 2007-2008 INRIA
*
* 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
-->
<project>
<parent>
<artifactId>parent</artifactId>
<groupId>org.scorware.assembly</groupId>
<version>0.3-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.scorware.assembly</groupId>
<artifactId>runtime-factory</artifactId>
<version>0.3-SNAPSHOT</version>
<url>http://www.scorware.org</url>
<inceptionYear>2007</inceptionYear>
<developers>
<developer>
<id>fournier</id>
<name>Damien Fournier</name>
<email>Damien.Fournier@inria.fr</email>
<organization>INRIA</organization>
<organizationUrl>http://www.inria.fr</organizationUrl>
<roles>
<role>Architect</role>
<role>Developer</role>
</roles>
</developer>
</developers>
<!-- ======= -->
<!-- Build -->
<!-- ======= -->
<build>
<plugins>
<!-- Process Fraclet annotations with Spoon. -->
<plugin>
<groupId>net.sf.alchim</groupId>
<artifactId>spoon-maven-plugin</artifactId>
<version>0.7</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>recompile</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.objectweb.fractal.fraclet.java</groupId>
<artifactId>fractal-spoonlet</artifactId>
<version>3.0</version>
</dependency>
<dependency>
<groupId>org.objectweb.fractal.fraclet.java</groupId>
<artifactId>fractaladl-spoonlet</artifactId>
<version>3.0</version>
</dependency>
</dependencies>
</plugin>
<!-- Compile the Fractal architecture of the SCOrWare assembly factory with JuliaC. -->
<plugin>
<groupId>org.objectweb.fractal.fractaladl.juliac</groupId>
<artifactId>maven-juliac-plugin</artifactId>
<version>${juliac.version}</version>
<executions>
<execution>
<id>juliac-compile</id>
<phase>generate-sources</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
<configuration>
<opt>OO</opt>
<srcs>target/generated-sources/spoon</srcs>
<mixins>org.objectweb.fractal.julia:julia-mixins:${julia-mixins.version}:sources</mixins>
<types>org.scorware.assembly.FrascatiRuntime</types>
<verbose>false</verbose>
</configuration>
<!-- Needed with juliac 1.3 -->
<dependencies>
<dependency>
<groupId>org.objectweb.fractal.fractaladl.juliac</groupId>
<artifactId>juliac-all</artifactId>
<version>${juliac.version}</version>
</dependency>
</dependencies>
</plugin>
<!-- Plugin for image generation representing the dependencies graph -->
<!-- This plugin requires the 'dot' library, provided by the -->
<!-- GraphViz software (http://www.graphviz.org ) -->
<!--
TODO: Commented as this plugin seems imcompatible with the production of a Maven plugin.
<plugin>
<groupId>ch.elca.el4j.maven.plugins</groupId>
<artifactId>maven-depgraph-plugin</artifactId>
<configuration>
<outDir>target/site/images</outDir>
<outFile>${pom.artifactId}.png</outFile>
</configuration>
<version>1.1</version>
</plugin>
-->
</plugins>
</build>
<!-- ============ -->
<!-- Dependencies -->
<!-- ============ -->
<dependencies>
<!-- This module is a Maven plugin. -->
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-project</artifactId>
<version>2.0</version>
</dependency>
<!-- The SCOrWare Assembly Factory Core Module. -->
<dependency>
<groupId>org.scorware.assembly</groupId>
<artifactId>frascati-af-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.scorware.assembly</groupId>
<artifactId>frascati-af-generate</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.objectweb.fractal.fractaladl.juliac</groupId>
<artifactId>juliac-all</artifactId>
<version>${juliac.version}</version>
</dependency>
<dependency>
<groupId>org.scorware.tinfi.tinfi-mixed</groupId>
<artifactId>frascati-tinfi-oo</artifactId>
<version>${tinfi.version}</version>
</dependency>
<dependency>
<groupId>org.objectweb.fractal.julia</groupId>
<artifactId>julia-mixins</artifactId>
<version>${julia-mixins.version}</version>
<classifier>sources</classifier>
</dependency>
<dependency>
<groupId>org.scorware.tinfi</groupId>
<artifactId>frascati-tinfi-mixins</artifactId>
<version>${tinfi.version}</version>
<classifier>sources</classifier>
</dependency>
</dependencies>
<!-- ============= -->
<!-- Repositories -->
<!-- ============= -->
<repositories>
<!-- The SCOrWare Private Repository. -->
<repository>
<id>private</id>
<name>Private Repository</name>
<url>file:${basedir}/../etc/private-repository</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<spoon>
<spoonlet groupId="org.objectweb.fractal.fraclet.java"
artifactId="fractaladl-spoonlet" version="3.0" />
<spoonlet groupId="org.objectweb.fractal.fraclet.java"
artifactId="fractal-spoonlet" version="3.0" />
</spoon>
\ No newline at end of file
/***
* Assembly Factory
* Copyright (C) 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: Damien.Fournier@inria.fr
*
* Author: Damien Fournier
*/
package org.scorware.assembly;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.List;
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;
import org.scorware.assembly.dispatcher.Manager;
import org.scorware.assembly.generate.runtime.RuntimeGenerate;
/**
* @author <a href="mailto:damien.fournier@inria.fr">Damien Fournier</a>
*
*/
public class AssemblyFactoryRuntime {
/**
* Logger for this class
*/
private static java.util.logging.Logger log = java.util.logging.Logger
.getLogger(AssemblyFactoryRuntime.class.getCanonicalName());
private static final String FACTORY_MAIN = "org.scorware.assembly.FrascatiRuntime";
private static final String FRACTAL_PROVIDER = "fractal.provider";
private static final String FRACTAL_PROVIDER_VALUE = "org.objectweb.fractal.util.ChainedProvider";
private static final String FRACTAL_PROVIDERS = "fractal.providers";
private static final String FRACTAL_PROVIDERS_VALUE = "org.scorware.tinfi.Tinfi,org.objectweb.fractal.julia.Julia";
private static final String CODE_GENERATOR = "org.scorware.tinfi.juliac.FCOOCtrlSourceCodeGenerator";
private static final String JULIA_CONFIG = "tinfi.cfg";
/**
* Space-separated list of source roots.
*
* @parameter
*/
private static String srcs;
/**
* The directory containing the generated source code.
*
* @parameter
*/
private static String gensrc;