Commit 3b26b84d authored by Philippe Merle's avatar Philippe Merle
Browse files

Added an example illustrating SCA implementation with Spring.

parent 60fb7815
<?xml version="1.0" encoding="UTF-8"?>
<!--
* ====================================================================
*
* SCOrWare 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: Philippe.Merle@inria.fr
*
* Author: Philippe Merle
-->
<assembly>
<id>bin</id>
<formats>
<format>zip</format>
<format>dir</format>
</formats>
<fileSets>
<fileSet>
<directory>target</directory>
<includes>
<include>*.jar</include>
</includes>
<outputDirectory>/lib</outputDirectory>
</fileSet>
</fileSets>
<dependencySets>
<dependencySet>
<outputDirectory>/lib</outputDirectory>
<includes>
<include>*:jar</include>
</includes>
</dependencySet>
</dependencySets>
</assembly>
<?xml version="1.0"?>
<!--
* SCOrWare FraSCAti 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-spring</artifactId>
<packaging>jar</packaging>
<name>SCOrWare FraSCAti Assembly Factory Examples: HelloWorld Spring</name>
<!-- Compile the ${example.main.composite} SCA composite with the SCOrWare Generate Factory.-->
<build>
<plugins>
<plugin>
<groupId>org.scorware.assembly</groupId>
<artifactId>frascati-factory-tools</artifactId>
<version>${project.version}</version>
<executions>
<execution>
<id>generate-factory</id>
<phase>generate-sources</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
<configuration>
<factory>GenerateFactory</factory>
<srcs>
<src>src/main/java</src>
<src>src/main/resources</src>
</srcs>
<composite>${example.main.composite}</composite>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<example.main.composite>helloworld-spring</example.main.composite>
<example.main.class>example.hw.Client</example.main.class>
</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 = ALL
############################################################
# 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 = ALL
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
/***
* SCOrWare FraSCAti Assembly Factory Examples : HelloWorld Spring
* 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: Philippe.Merle@inria.fr
*
* Author: Philippe Merle
*/
package example.hw;
import org.objectweb.fractal.api.Component;
import org.scorware.assembly.AssemblyFactory;
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 = new AssemblyFactory().getComposite("helloworld-spring");
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();
}
}
}
/***
* SCOrWare FraSCAti Assembly Factory Examples : HelloWorld Spring
* 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: Philippe.Merle@inria.fr
*
* Author: Philippe Merle
*/
package example.hw;
public class ClientImpl implements Runnable {
public ClientImpl() {
System.err.println("CLIENT created");
}
public void init() {
System.err.println("CLIENT initialized");
}
public void run() {
s.print("hello world");
}
public Service s;
public void setService(Service s) { this.s = s; }
}
/***
* SCOrWare FraSCAti Assembly Factory Examples : HelloWorld Spring
* 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: Philippe.Merle@inria.fr
*
* Author: Philippe Merle
*/
package example.hw;
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;
}
public void setHeader(final String header) {
this.header = header;
}
public int getCount() {
return count;
}
public void setCount(final int count) {
this.count = count;
}
}
/***
* SCOrWare FraSCAti Assembly Factory Examples : HelloWorld Spring
* 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: Philippe.Merle@inria.fr
*
* Author: Philippe Merle
*/
package example.hw;
public interface Service {
void print(String msg);
}
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<bean id="client" class="example.hw.ClientImpl">
<property name="service" ref="s"/>
</bean>
</beans>
<?xml version="1.0" encoding="UTF-8"?>
<!-- Assembly Factory Examples : HelloWorld Spring -->
<!-- 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 -->
<!-- -->
<!-- Contributor: Philippe Merle -->
<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
targetNamespace="http://helloworld-spring"
xmlns:hw="http://helloworld-spring"
name="helloworld-spring">
<service name="r" promote="SpringClientComponent/client">
<interface.java interface="java.lang.Runnable" />
</service>
<component name="SpringClientComponent">
<service name="client">
<interface.java interface="java.lang.Runnable" />
</service>
<reference name="s" target="SpringServerComponent/server" >
<interface.java interface="example.hw.Service" />
</reference>
<implementation.spring location="client-spring.xml" />
</component>
<component name="SpringServerComponent">
<service name="server">
<interface.java interface="example.hw.Service" />
</service>
<implementation.spring location="server-spring.xml" />
</component>
</composite>
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<bean id="server" class="example.hw.ServerImpl">
<property name="header" value="SpringServer> "/>
<property name="count" value="1"/>
</bean>
</beans>
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