From c0618797c0169da1a7f0c695525087be64789389 Mon Sep 17 00:00:00 2001 From: Nicolas Dolet Date: Tue, 31 Mar 2009 16:24:50 +0000 Subject: [PATCH] New helloworld example with SCA Java annotations --- distribution/standalone/assembly-bin.xml | 3 + examples/helloworld-annotated/README.txt | 39 ++++++++ examples/helloworld-annotated/build.xml | 59 ++++++++++++ examples/helloworld-annotated/ivy.xml | 28 ++++++ examples/helloworld-annotated/pom.xml | 90 +++++++++++++++++++ .../examples/helloworld/annotated/Client.java | 46 ++++++++++ .../helloworld/annotated/PrintService.java | 34 +++++++ .../examples/helloworld/annotated/Server.java | 50 +++++++++++ .../resources/helloworld-annotated.composite | 37 ++++++++ 9 files changed, 386 insertions(+) create mode 100644 examples/helloworld-annotated/README.txt create mode 100644 examples/helloworld-annotated/build.xml create mode 100644 examples/helloworld-annotated/ivy.xml create mode 100644 examples/helloworld-annotated/pom.xml create mode 100644 examples/helloworld-annotated/src/main/java/org/ow2/frascati/examples/helloworld/annotated/Client.java create mode 100644 examples/helloworld-annotated/src/main/java/org/ow2/frascati/examples/helloworld/annotated/PrintService.java create mode 100644 examples/helloworld-annotated/src/main/java/org/ow2/frascati/examples/helloworld/annotated/Server.java create mode 100644 examples/helloworld-annotated/src/main/resources/helloworld-annotated.composite diff --git a/distribution/standalone/assembly-bin.xml b/distribution/standalone/assembly-bin.xml index 8dd30e250..0a43090d1 100644 --- a/distribution/standalone/assembly-bin.xml +++ b/distribution/standalone/assembly-bin.xml @@ -68,6 +68,9 @@ */src/** */build.xml + */pom.xml + */ivy.xml + */README.txt /examples diff --git a/examples/helloworld-annotated/README.txt b/examples/helloworld-annotated/README.txt new file mode 100644 index 000000000..147414118 --- /dev/null +++ b/examples/helloworld-annotated/README.txt @@ -0,0 +1,39 @@ +============================================================================ +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-.jar -s r -m run diff --git a/examples/helloworld-annotated/build.xml b/examples/helloworld-annotated/build.xml new file mode 100644 index 000000000..9347e5cf4 --- /dev/null +++ b/examples/helloworld-annotated/build.xml @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/helloworld-annotated/ivy.xml b/examples/helloworld-annotated/ivy.xml new file mode 100644 index 000000000..95fa21e1e --- /dev/null +++ b/examples/helloworld-annotated/ivy.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/helloworld-annotated/pom.xml b/examples/helloworld-annotated/pom.xml new file mode 100644 index 000000000..558023f6c --- /dev/null +++ b/examples/helloworld-annotated/pom.xml @@ -0,0 +1,90 @@ + + + + 4.0.0 + + org.ow2.frascati.examples + helloworld-annotations + 0.6-SNAPSHOT + jar + + Helloworld annotated + + + + + + + maven-compiler-plugin + + 1.5 + 1.5 + + + + + org.ow2.frascati.factory + frascati-factory-plugin + 0.6-SNAPSHOT + + + generate-factory + generate-sources + + compile + + + + + GenerateFactory + + src/main/java + src/main/resources + + helloworld-annotated.composite + + + + + + + + + apache-incubating + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-sca-api + 1.2.1-incubating + + + + diff --git a/examples/helloworld-annotated/src/main/java/org/ow2/frascati/examples/helloworld/annotated/Client.java b/examples/helloworld-annotated/src/main/java/org/ow2/frascati/examples/helloworld/annotated/Client.java new file mode 100644 index 000000000..0549e8471 --- /dev/null +++ b/examples/helloworld-annotated/src/main/java/org/ow2/frascati/examples/helloworld/annotated/Client.java @@ -0,0 +1,46 @@ +/*** + * 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!"); + } +} diff --git a/examples/helloworld-annotated/src/main/java/org/ow2/frascati/examples/helloworld/annotated/PrintService.java b/examples/helloworld-annotated/src/main/java/org/ow2/frascati/examples/helloworld/annotated/PrintService.java new file mode 100644 index 000000000..235ca9eb0 --- /dev/null +++ b/examples/helloworld-annotated/src/main/java/org/ow2/frascati/examples/helloworld/annotated/PrintService.java @@ -0,0 +1,34 @@ +/*** + * 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); +} diff --git a/examples/helloworld-annotated/src/main/java/org/ow2/frascati/examples/helloworld/annotated/Server.java b/examples/helloworld-annotated/src/main/java/org/ow2/frascati/examples/helloworld/annotated/Server.java new file mode 100644 index 000000000..e3d904390 --- /dev/null +++ b/examples/helloworld-annotated/src/main/java/org/ow2/frascati/examples/helloworld/annotated/Server.java @@ -0,0 +1,50 @@ +/*** + * 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."); + } + +} diff --git a/examples/helloworld-annotated/src/main/resources/helloworld-annotated.composite b/examples/helloworld-annotated/src/main/resources/helloworld-annotated.composite new file mode 100644 index 000000000..77b3ab99d --- /dev/null +++ b/examples/helloworld-annotated/src/main/resources/helloworld-annotated.composite @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- GitLab