Commit e9659cbc authored by cdemarey's avatar cdemarey
Browse files

Merges trunk

parent c5ba3964
......@@ -312,7 +312,7 @@
<!-- STP SCA model located into the private repository. -->
<dependency>
<groupId>org.eclipse.stp</groupId>
<artifactId>sca</artifactId>
<artifactId>sca-custom</artifactId>
<version>1.0.0</version>
</dependency>
......
package org.scorware.assembly.instance.implementation;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.stp.sca.FractalImplementation;
import org.eclipse.stp.sca.Implementation;
import org.objectweb.fractal.adl.ADLException;
import org.objectweb.fractal.adl.FactoryFactory;
import org.objectweb.fractal.api.Component;
import org.objectweb.fractal.api.type.ComponentType;
/**
* Create SCA component implemented with Fractal
*
* @author <a href="mailto:damien.fournier@inria.fr">Damien Fournier</a>
* @version $Revision$
*/
@org.objectweb.fractal.fraclet.annotations.Component
public class ScaFractalImpl implements ScaImplementation {
/**
* Logger for this class
*/
java.util.logging.Logger log = java.util.logging.Logger
.getLogger(ScaFractalImpl.class.getCanonicalName());
/* (non-Javadoc)
* @see org.scorware.assembly.instance.implementation.ScaImplementation#create(org.eclipse.stp.sca.Implementation, org.objectweb.fractal.api.type.ComponentType)
*/
@SuppressWarnings("unchecked")
public Component create(Implementation implementation,
ComponentType componentType) {
Map context = new HashMap();
Component c = null;
FractalImplementation impl = (FractalImplementation) implementation;
org.objectweb.fractal.adl.Factory f;
try {
// init Fractal ADL factory
f = FactoryFactory.getFactory(FactoryFactory.FRACTAL_BACKEND);
// try instanciation for the given Fractal ADL definition
c = (Component) f.newComponent(impl.getDefinition(), context);
} catch (ADLException e) {
// Error with Fractal ADL
log.severe("Error in the Fractal implementation : "
+ impl.getDefinition());
e.printStackTrace();
}
return c;
}
/* (non-Javadoc)
* @see org.scorware.assembly.instance.implementation.ScaImplementation#getImplementationID()
*/
public int getImplementationID() {
return org.eclipse.stp.sca.ScaPackage.FRACTAL_IMPLEMENTATION;
}
}
......@@ -39,10 +39,14 @@
<component name="composite"
definition="org.scorware.assembly.instance.implementation.ScaCompositeImpl" />
<component name="fractal"
definition="org.scorware.assembly.instance.implementation.ScaFractalImpl" />
<binding client="this.implementation" server="switcher.implementation" />
<binding client="switcher.implementations-java" server="java.implementation" />
<binding client="switcher.implementations-composite" server="composite.implementation" />
<binding client="switcher.implementations-fractal" server="fractal.implementation" />
<binding client="java.runtime" server="this.runtime" />
<binding client="composite.loader" server="this.loader" />
......
<?xml version="1.0" encoding="UTF-8"?><project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.eclipse.stp</groupId>
<artifactId>sca-custom</artifactId>
<version>1.0.0</version>
</project>
<?xml version="1.0"?>
<!--
* 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 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.4-SNAPSHOT</version>
</parent>
<groupId>org.scorware.assembly.examples</groupId>
<artifactId>helloworld-fractal</artifactId>
<packaging>jar</packaging>
<name>SCOrWare FraSCAti Assembly Factory Examples: HelloWorld with Fractal Implementation</name>
<properties>
<example.main.composite>helloworld-fractal.composite</example.main.composite>
</properties>
<dependencies>
<dependency>
<groupId>org.scorware.assembly.examples</groupId>
<artifactId>helloworld-bin-code</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.scorware.assembly</groupId>
<artifactId>frascati-af-runtime</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.objectweb.fractal.fractaladl.examples</groupId>
<artifactId>helloworld</artifactId>
<version>2.3</version>
</dependency>
</dependencies>
</project>
<?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="Service" role="client" />
<content class="ClientImpl"/>
</component>
<component name="server">
<interface name="s" signature="Service" role="server" cardinality="singleton" contingency="mandatory"/>
<content class="ServerImpl"/>
</component>
<binding client="this.r" server="client.r" />
<binding client="client.s" server="server.s" />
</definition>
<?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>
<implementation.fractal definition="example.hw.HelloWorld" />
</component>
</composite>
package example.hw;
import static org.junit.Assert.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.scorware.assembly.Factory;
import org.scorware.tinfi.TinfiDomain;
import org.objectweb.fractal.api.Component;
import example.hw.Service;
public class HelloWorldFractalTestCase {
private Component scaClient;
private Component scaServer;
private java.lang.Runnable service;
@Before
public void setUp() throws Exception {
// Start SCA server composite
//scaServer = Factory.getComposite("helloworldServer.composite");
// Start SCA client composite
scaClient = Factory.getComposite("helloworld-fractal.composite");
// Get reference on client interface
service = TinfiDomain.getService(scaClient, java.lang.Runnable.class, "r");
}
@Test
public void testInit() {
assertNotNull(scaClient);
assertNotNull(service);
}
@Test
public void testCall() {
service.run();
}
@After
public void tearDown() throws Exception {
TinfiDomain.close(scaClient);
}
}
......@@ -364,6 +364,7 @@
<module>helloworld-standalone-client</module>
<module>helloworld-standalone-server</module>
<module>helloworld-ws</module>
<module>helloworld-fractal-impl</module>
<module>meteo</module>
<module>chat</module>
</modules>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment