Commit c0618797 authored by Nicolas Dolet's avatar Nicolas Dolet

New helloworld example with SCA Java annotations

parent c70db4ed
......@@ -68,6 +68,9 @@
<includes>
<include>*/src/**</include>
<include>*/build.xml</include>
<include>*/pom.xml</include>
<include>*/ivy.xml</include>
<include>*/README.txt</include>
</includes>
<outputDirectory>/examples</outputDirectory>
</fileSet>
......
============================================================================
OW2 FraSCAti - Helloworld with SCA Java Annotations
Copyright (C) 2009 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: frascati@ow2.org
Author: Nicolas Dolet
============================================================================
Helloworld with SCA Java Annotations:
-------------------------------------
This example shows how to use annotations on the helloworld-pojo example.
Compilation and packaging:
--------------------------
To compile and create the library of this example with Maven:
mvn compile jar:jar
To compile and create the library of this example with Ant Ivy:
ant jar
Run the example:
frascati run helloworld-annotated -libpath helloworld-annotations-<version>.jar -s r -m run
<!-- OW2 FraSCAti Examples : HelloWorld with SCA Java annotations -->
<!-- Copyright (C) 2009 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 -->
<!-- -->
<!-- Author: Nicolas Dolet -->
<project xmlns:ivy="antlib:org.apache.ivy.ant" name="helloworld-annotated" default="jar">
<property name="src.dir" value="src" />
<property name="build.dir" value="target" />
<property name="composite.file" value="${src.dir}/main/resources/helloworld-annotated.composite"/>
<!-- ================================= -->
<!-- target: clean -->
<!-- ================================= -->
<target name="clean" description="--> clean the example">
<delete dir="${build.dir}" />
</target>
<!-- ================================= -->
<!-- target: resolve -->
<!-- ================================= -->
<target name="resolve" description="--> retrieve dependencies with ivy">
<ivy:retrieve />
</target>
<!-- ================================= -->
<!-- target: compile -->
<!-- ================================= -->
<target name="compile" depends="clean, resolve" description="--> compile the helloworld with SCA annotations example">
<ivy:cachepath organisation="org.apache.tuscany.sca" module="tuscany-sca-api" revision="1.2.1-incubating" inline="true" pathid="classpath"/>
<mkdir dir="${build.dir}" />
<javac srcdir="${src.dir}" destdir="${build.dir}" classpathref="classpath" />
</target>
<!-- ================================= -->
<!-- target: jar -->
<!-- ================================= -->
<target name="jar" depends="compile" description="--> create the jar for the example">
<copy todir="${build.dir}" file="${composite.file}" />
<jar jarfile="${build.dir}/helloworld-annotations-0.6-SNAPSHOT.jar" >
<fileset dir="${build.dir}" />
</jar>
</target>
</project>
<!-- OW2 FraSCAti Examples : HelloWorld with SCA Java annotations -->
<!-- Copyright (C) 2009 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 -->
<!-- -->
<!-- Author: Nicolas Dolet -->
<ivy-module version="2.0">
<info organisation="org.ow2.frascati.examples.helloworld.annotated"
module="hello"/>
<dependencies>
<dependency org="org.apache.tuscany.sca" name="tuscany-sca-api" rev="1.2.1-incubating">
<artifact name="tuscany-sca-api" type="jar" url="http://people.apache.org/repo/m2-incubating-repository/org/apache/tuscany/sca/tuscany-sca-api/1.2.1-incubating/tuscany-sca-api-1.2.1-incubating.jar"/>
</dependency>
</dependencies>
</ivy-module>
<?xml version="1.0"?>
<!--
* OW2 FraSCAti Examples: HelloWorld with SCA Java annotations
*
* Copyright (c) 2009 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: frascati@ow2.org
*
* Author: Nicolas Dolet
-->
<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>
<groupId>org.ow2.frascati.examples</groupId>
<artifactId>helloworld-annotations</artifactId>
<version>0.6-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Helloworld annotated</name>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<groupId>org.ow2.frascati.factory</groupId>
<artifactId>frascati-factory-plugin</artifactId>
<version>0.6-SNAPSHOT</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>helloworld-annotated.composite</composite>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>apache-incubating</id>
<url>http://people.apache.org/repo/m2-incubating-repository</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-sca-api</artifactId>
<version>1.2.1-incubating</version>
</dependency>
</dependencies>
</project>
/***
* OW2 FraSCAti Examples: HelloWorld with SCA Java annotations
* Copyright (C) 2009 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
*
* Author: Damien Fournier
*
* Contributor(s): Christophe Demarey
* Nicolas Dolet
*/
package org.ow2.frascati.examples.helloworld.annotated;
import org.osoa.sca.annotations.Reference;
import org.osoa.sca.annotations.Service;
/** A print service client. */
@Service(Runnable.class)
public class Client
implements Runnable {
@Reference(required = true)
protected PrintService s;
/** Default constructor. */
public Client() {
System.out.println("CLIENT created.");
}
/** Run the client. */
public void run() {
s.print("Hello World!");
}
}
/***
* OW2 FraSCAti Examples: HelloWorld with SCA Java annotations
* Copyright (C) 2009 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
*
* Author: Damien Fournier
*
* Contributor(s): Christophe Demarey
* Nicolas Dolet
*/
package org.ow2.frascati.examples.helloworld.annotated;
import org.osoa.sca.annotations.Service;
/**
* A basic service used to print messages.
*/
@Service
public interface PrintService {
void print(String msg);
}
/***
* OW2 FraSCAti Examples: HelloWorld with SCA Java annotations
* Copyright (C) 2009 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
*
* Author: Damien Fournier
*
* Contributor(s): Christophe Demarey
* Nicolas Dolet
*/
package org.ow2.frascati.examples.helloworld.annotated;
import org.osoa.sca.annotations.Property;
/** The print service implementation. */
public class Server implements PrintService {
@Property
protected String header = "->";
private int count = 1;
/** Default constructor. */
public Server() {
System.out.println("SERVER created.");
}
/** PrintService implementation. */
public void print(final String msg) {
System.out.println("SERVER: begin printing...");
for (int i = 0; i < count; ++i) {
System.out.println(header + msg);
}
System.out.println("SERVER: print done.");
}
}
<?xml version="1.0" encoding="ISO-8859-15"?>
<!-- OW2 FraSCAti Examples: HelloWorld with SCA Java annotations -->
<!-- Copyright (C) 2008-2009 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 -->
<!-- -->
<!-- Author: Damien Fournier -->
<!-- -->
<!-- Contributor(s): Christophe Demarey -->
<!-- Nicolas Dolet -->
<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" name="helloworld-annotated">
<service name="r" promote="client/Runnable"/>
<component name="client">
<implementation.java class="org.ow2.frascati.examples.helloworld.annotated.Client"/>
</component>
<component name="server">
<implementation.java class="org.ow2.frascati.examples.helloworld.annotated.Server"/>
</component>
<wire source="client/s" target="server/PrintService"/>
</composite>
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