Commit 469ff4a1 authored by dfournier's avatar dfournier
Browse files

* Added Forge Example using the assembly factory

* Assembly Factory start assembly through main() method instead of using a runnable component
* Updated HelloWorld Example
parent 6bfb8c2a
<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.example</groupId>
<artifactId>parent</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>org.scorware.assembly.example</groupId>
<artifactId>forge-assembly</artifactId>
<packaging>jar</packaging>
<name>Assembly Factory Examples : Forge</name>
<!-- ========================================================= -->
<!-- Dependencies for generating and compiling the application -->
<!-- ========================================================= -->
<dependencies>
<dependency><!-- Needed in all cases -->
<groupId>org.scorware.tinfi</groupId>
<artifactId>compiler</artifactId>
<version>${project.version}</version>
</dependency>
<dependency><!-- Needed in all cases -->
<groupId>org.objectweb.fractal.fractaladl.juliac</groupId>
<artifactId>runtime</artifactId>
<version>1.2</version>
</dependency>
<dependency><!-- Artifact specified in the <mixins> tag -->
<groupId>org.scorware.tinfi</groupId>
<artifactId>mixins</artifactId>
<version>${project.version}</version>
<classifier>sources</classifier>
</dependency>
<dependency><!-- Artifact specified in the <mixins> tag -->
<groupId>org.objectweb.fractal.julia</groupId>
<artifactId>julia-mixins</artifactId>
<version>2.5.2</version>
<classifier>sources</classifier>
</dependency>
<dependency><!-- Artifact specified in the <mixins> tag -->
<groupId>org.scorware.tinfi.examples</groupId>
<artifactId>forge</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>
org.objectweb.fractal.fractaladl.juliac.plugin
</groupId>
<artifactId>maven-juliac-plugin</artifactId>
<version>1.2</version>
<executions>
<execution>
<id>juliac-compile</id>
<phase>generate-sources</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
<configuration>
<!-- ================================================= -->
<!-- Choose one of the following for SCA components -->
<!-- with a control membrane: -->
<!-- - FCOOCtrlSourceCodeGenerator: object-oriented -->
<!-- - FCCompCtrlSourceCodeGenerator: component-based -->
<!-- ================================================= -->
<srcs>src/main/java src/main/resources</srcs>
<opt> org.scorware.tinfi.juliac.FCOOCtrlSourceCodeGenerator</opt>
<mixins> org.scorware.tinfi:mixins:1.0-SNAPSHOT:sources org.objectweb.fractal.julia:julia-mixins:2.5.2:sources </mixins>
<!-- opt>org.scorware.tinfi.juliac.FCCompCtrlSourceCodeGenerator</opt -->
<!-- mixins>org.scorware.tinfi:mixins:1.0-SNAPSHOT:sources org.objectweb.fractal.julia:julia-mixins:2.5.2:sources org.objectweb.fractal.julia:koch-mixins:2.5.2:sources</mixins -->
<types>TrackerEnabledSCM</types>
<sysargs>julia.config=tinfi.cfg</sysargs>
<verbose>true</verbose>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<factory.main>org.scorware.forge.assembly.Client</factory.main>
<factory.jar>
${basedir}/target/forge-assembly-1.0-SNAPSHOT.jar
</factory.jar>
<factory.composite>TrackerEnabledSCM</factory.composite>
</properties>
</project>
############################################################
# Default Logging Configuration File
#
# You can use a different file by specifying a filename
# with the java.util.logging.config.file system property.
# For example java -Djava.util.logging.config.file=myfile
############################################################
############################################################
# Global properties
############################################################
# "handlers" specifies a comma separated list of log Handler
# classes. These handlers will be installed during VM startup.
# Note that these classes must be on the system classpath.
# By default we only configure a ConsoleHandler, which will only
# show messages at the INFO and above levels.
handlers= java.util.logging.ConsoleHandler
# To also add the FileHandler, use the following line instead.
#handlers= java.util.logging.FileHandler, java.util.logging.ConsoleHandler
# Default global logging level.
# This specifies which kinds of events are logged across
# all loggers. For any given facility this global level
# can be overriden by a facility specific level
# Note that the ConsoleHandler also has a separate level
# setting to limit messages printed to the console.
.level = OFF
############################################################
# Handler specific properties.
# Describes specific configuration info for Handlers.
############################################################
# default file output is in user's home directory.
java.util.logging.FileHandler.pattern = %h/java%u.log
java.util.logging.FileHandler.limit = 50000
java.util.logging.FileHandler.count = 1
java.util.logging.FileHandler.formatter = java.util.logging.XMLFormatter
# Limit the message that are printed on the console to INFO and above.
java.util.logging.ConsoleHandler.level = INFO
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
############################################################
# Facility specific properties.
# Provides extra control for each logger.
############################################################
# For example, set the com.xyz.foo logger to only log SEVERE
# messages: com.xyz.foo.level = SEVERE
spoonlet.level = OFF
spoonlet.fractal.level = OFF
spoonlet.fractaladl.level = OFF
/***
* Assembly Factory Examples : Forge
* 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.forge.assembly;
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.InstantiationException;
import org.scorware.forge.scm.SourceCodeManager;
import org.scorware.forge.tracker.Ticket;
import org.scorware.forge.tracker.Tracker;
import org.scorware.tinfi.TinfiDomain;
public class Client {
public static void main() {
Component scaDomain;
try {
System.out.println("\n\n\nStarting The Forge Example \n");
scaDomain = TinfiDomain.getComponent("TrackerEnabledSCM");
// getting services
SourceCodeManager scm = TinfiDomain.getService(scaDomain,
SourceCodeManager.class, "TrackerSCMComposerComponent");
Tracker trac = TinfiDomain.getService(scaDomain, Tracker.class,
"TrackerComponent");
// performs some calls
Ticket t;
for (int i = 1; i < 10; i++) {
t = trac.createTicket();
System.out.println("Ticket " + t.getId() + " has been created");
t.setSummary("This is the first sample ticket");
System.out.println("Perform CheckIn");
scm.checkIn("foo" + i, "this patch close#" + i + " at last !");
Thread.currentThread().sleep(500);
System.out.println("Current version is : " + scm.getLastVersion());
t = trac.getTicket(i);
if (!t.isOpen())
System.out.println("Ticket " + t.getId() + " has been closed\n\n");
}
t = trac.createTicket();
System.out.println("Perform CheckOut\n ");
String check = scm.checkOut(scm.getLastVersion());
if (check != null) {
System.out.println(check);
System.out.println("CheckOut successful");
}
//closing sca domain
TinfiDomain.close(scaDomain);
System.out.println("\n\n\n");
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InstantiationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalLifeCycleException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (NoSuchInterfaceException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (java.lang.InstantiationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!-- Assembly Factory Examples : Forge -->
<!-- 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"
name="TrackerEnabledSCM">
<service name="TrackerSCMComposerComponent" promote="TrackerSCMComposerComponent/TrackerSCMComposerComponent">
<interface.java interface="org.scorware.forge.scm.SourceCodeManager" />
<binding.sca />
</service>
<service name="TrackerComponent" promote="TrackerComponent/TrackerComponent">
<interface.java interface="org.scorware.forge.tracker.Tracker" />
<binding.sca />
</service>
<service name="SourceCodeManagerComponent" promote="SourceCodeManagerComponent/SourceCodeManagerComponent">
<interface.java interface="org.scorware.forge.scm.SourceCodeManager" />
<binding.sca />
</service>
<component name="TrackerSCMComposerComponent">
<service name="TrackerSCMComposerComponent">
<interface.java interface="org.scorware.forge.scm.SourceCodeManager" />
<binding.sca />
</service>
<implementation.java
class="org.scorware.forge.composition.TrackerSCMComposer" />
<reference name="tracker"
target="TrackerComponent/TrackerComponent">
<interface.java
interface="org.scorware.forge.tracker.Tracker" />
<binding.sca />
</reference>
<reference name="sourceCodeManager"
target="SourceCodeManagerComponent/SourceCodeManagerComponent">
<interface.java
interface="org.scorware.forge.scm.SourceCodeManager" />
<binding.sca />
</reference>
</component>
<component name="TrackerComponent">
<service name="TrackerComponent">
<interface.java
interface="org.scorware.forge.tracker.Tracker" />
<binding.sca />
</service>
<implementation.java
class="org.scorware.forge.tracker.TrackerImpl" />
</component>
<component name="SourceCodeManagerComponent">
<service name="SourceCodeManagerComponent">
<interface.java
interface="org.scorware.forge.scm.SourceCodeManager" />
<binding.sca />
</service>
<implementation.java
class="org.scorware.forge.scm.SourceCodeManagerImpl" />
</component>
</composite>
......@@ -41,6 +41,11 @@
<version>2.5.2</version>
<classifier>sources</classifier>
</dependency>
<dependency><!-- Artifact specified in the <mixins> tag -->
<groupId>org.scorware.tinfi.examples</groupId>
<artifactId>helloworld</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
......@@ -85,6 +90,7 @@
${basedir}/target/helloworld-1.0-SNAPSHOT.jar
</factory.jar>
<factory.composite>helloworld</factory.composite>
<factory.main>example.hw.Client</factory.main>
</properties>
</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.tinfi.TinfiDomain;
public class Client {
public static void main() {
Component scaDomain;
try {
System.out.println("\n\n\nStarting The Helloworld Example \n");
scaDomain = TinfiDomain.getComponent("example.hw.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();
}
}
}
package example.hw;
import org.osoa.sca.annotations.Init;
import org.osoa.sca.annotations.Reference;
public class ClientImpl implements Runnable {
public ClientImpl() {
System.err.println("CLIENT created");
}
@Init
public void init() {
System.err.println("CLIENT initialized");
}
public void run() {
s.print("hello world");
}
@Reference
public Service s;
}
\ No newline at end of file
package example.hw;
import org.osoa.sca.annotations.Property;
public class ServerImpl implements Service {
private String header = "->";
private int count = 1;
public ServerImpl() {
System.err.println("SERVER created");
}
public void print(final String msg) {
new Exception() {
private static final long serialVersionUID = 2182742162070453637L;
public String toString() {
return "Server: print method called";
}
}.printStackTrace();
System.err.println("Server: begin printing...");
for (int i = 0 ; i < (count) ; ++i) {
System.err.println(((header) + msg));
}
System.err.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
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE definition PUBLIC "-//objectweb.org//DTD Fractal ADL 2.0//EN" "classpath://org/objectweb/fractal/adl/xml/standard.dtd">
<definition name="example.hw.HelloWorld" >
<interface name="r" signature="java.lang.Runnable" role="server" />
<component name="client">
<interface name="r" signature="java.lang.Runnable" role="server" />
<interface name="s" signature="example.hw.Service" role="client" />
<content class="example.hw.ClientImpl"/>
<controller desc="scaPrimitive" />
</component>
<component name="server">
<interface name="s" signature="example.hw.Service" role="server" cardinality="singleton" contingency="mandatory"/>
<content class="example.hw.ServerImpl"/>
<controller desc="scaPrimitive"/>
</component>
<binding client="this.r" server="client.r" />
<binding client="client.s" server="server.s" />
</definition>
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE definition PUBLIC "-//objectweb.org//DTD Fractal ADL 2.0//EN" "classpath://org/objectweb/fractal/adl/xml/standard.dtd">
<!DOCTYPE definition PUBLIC "-//objectweb.org//DTD Fractal ADL 2.0//EN" "classpath://org/objectweb/fractal/adl/xml/standard.dtd">
<!-- 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 -->
<definition name="example.hw.HelloWorldAssembly" >
......
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE definition PUBLIC "-//objectweb.org//DTD Fractal ADL 2.0//EN" "classpath://org/objectweb/fractal/adl/xml/standard.dtd">
<!-- 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 -->