Commit a6aac014 authored by Nicolas Dolet's avatar Nicolas Dolet

Update examples:

 - unify Maven artifacts
 - update/add READMEs
 - simplify composite sources
 - add Java APIs for components
 - use the generic launcher from factory-tools
 - typos
parent 96d0092d
============================================================================
OW2 FraSCAti Examples: Dictionary
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
============================================================================
Dictionary Web Service Client:
------------------------------
This example shows how to build an SCA client using a dictionary web service
already available over the Internet.
Compilation with Maven:
-----------------------
mvn install
Execution with Maven:
---------------------
mvn -Prun
Compilation and execution with the FraSCAti scripts:
----------------------------------------------------
frascati wsdl2java -f src/main/wsdl/DictService.wsdl -o src/main/java
frascati compile src dictionary
frascati run dictionary -libpath dictionary.jar -s Dictionary -m definition -p computer
......@@ -21,7 +21,10 @@
* Contact: frascati@ow2.org
*
* Author: Nicolas Dolet
*
* Contributor(s): Philippe Merle
-->
<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">
......@@ -32,7 +35,7 @@
<version>0.6-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Dictionary</name>
<name>OW2 FraSCAti Examples: Dictionary</name>
<parent>
<groupId>org.ow2.frascati.examples</groupId>
......@@ -42,6 +45,10 @@
<properties>
<wsdl.file>DictService.wsdl</wsdl.file>
<composite.file>dictionary</composite.file>
<service.name>Dictionary</service.name>
<method.name>definition</method.name>
<method.params>computer</method.params>
</properties>
<build>
......@@ -54,4 +61,12 @@
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.ow2.frascati.factory</groupId>
<artifactId>frascati-factory-tools</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>
/***
* OW2 FraSCAti Examples: Dictionary
* 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
*
* Contributor(s): Philippe Merle
*/
package org.ow2.frascati.examples.dictionary.api;
import org.osoa.sca.annotations.Service;
/**
* Interface for a dictionary service.
*/
@Service
public interface Dictionary {
public String definition(String word);
}
/***
* OW2 FraSCAti Assembly Factory Examples: Dictionary
* OW2 FraSCAti Examples: Dictionary
* Copyright (C) 2009 INRIA, USTL
*
* This library is free software; you can redistribute it and/or
......@@ -16,17 +16,20 @@
* 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
*
* Contributor(s): Philippe Merle
*/
package org.ow2.frascati.examples.dictionary;
package org.ow2.frascati.examples.dictionary.lib;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StringWriter;
import java.util.Iterator;
import org.osoa.sca.annotations.Reference;
import org.ow2.frascati.examples.dictionary.api.Dictionary;
import com.aonaware.services.webservices.Definition;
import com.aonaware.services.webservices.DictServiceSoap;
......@@ -34,28 +37,26 @@ import com.aonaware.services.webservices.DictServiceSoap;
/**
* SCA Java Component implementation using a dictionary web service
*/
public class Client implements Runnable {
public class Client
implements Dictionary {
@Reference
protected DictServiceSoap dict;
public void run() {
BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter a word: ");
try {
String word = input.readLine();
Iterator<Definition> it = dict.define(word).getDefinitions().getDefinition().iterator();
int count = 1;
while(it.hasNext()) {
Definition def = it.next();
System.out.println("Definition " + count + ":");
System.out.println(def.getWordDefinition());
count++;
}
} catch (IOException e) {
System.err.println("Can't read input data!");
e.printStackTrace();
// --------------------------------------------------------------------------
// Implementation of the Dictionary interface
// --------------------------------------------------------------------------
public String definition(String word) {
Iterator<Definition> it = dict.define(word).getDefinitions()
.getDefinition().iterator();
int count = 1;
StringWriter writer = new StringWriter();
while (it.hasNext()) {
Definition def = it.next();
writer.write("Definition " + count + ":");
writer.write(def.getWordDefinition());
count++;
}
return writer.toString();
}
}
<?xml version="1.0" encoding="ISO-8859-15"?>
<!-- OW2 FraSCAti Examples: Dictionary -->
<!-- Copyright (C) 2009 INRIA, USTL -->
<!-- -->
......@@ -17,25 +16,22 @@
<!-- 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 -->
<!-- -->
<!-- Contributor(s): Philippe Merle -->
<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" name="dictionary"
targetNamespace="http://frascati.ow2.org/dictionary">
<service name="r" promote="client/r">
<interface.java interface="java.lang.Runnable" />
</service>
<service name="Dictionary" promote="client/Dictionary"/>
<component name="client">
<implementation.java class="org.ow2.frascati.examples.dictionary.Client" />
<service name="r">
<interface.java interface="java.lang.Runnable" />
</service>
<implementation.java class="org.ow2.frascati.examples.dictionary.lib.Client" />
<reference name="dict">
<interface.java interface="com.aonaware.services.webservices.DictServiceSoap" />
<binding.ws wsdlElement="http://services.aonaware.com/DictService#wsdl.port(DictService/DictServiceSoap)" />
</reference>
......
......@@ -29,14 +29,17 @@ It also includes another composite: helloworld-ws that shows the usage of
the Web Service binding.
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 <composite-name> -libpath helloworld-annotations-<version>.jar -s r -m run
with <composite-name> = helloworld-wired or helloworld-ws
Compilation with Maven:
-----------------------
mvn install
Execution with Maven:
---------------------
mvn -Prun
edit the pom.xml descriptor to change the composite name
Compilation and execution with the FraSCAti scripts:
----------------------------------------------------
frascati compile src helloworld-annotations
frascati run <composite-name> -libpath helloworld-annotations.jar -s r -m run
with <composite-name> = helloworld-wired or helloworld-ws
......@@ -15,6 +15,8 @@
<!-- 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:ivy="antlib:org.apache.ivy.ant" name="helloworld-annotated" default="jar">
......
......@@ -15,6 +15,8 @@
<!-- 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 -->
<ivy-module version="2.0">
......
......@@ -21,23 +21,40 @@
* Contact: frascati@ow2.org
*
* Author: Nicolas Dolet
*
* Contributor(s): Philippe Merle
-->
<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>
<name>OW2 FraSCAti Examples: Helloworld annotated</name>
<parent>
<groupId>org.ow2.frascati.examples</groupId>
<artifactId>parent</artifactId>
<version>0.6-SNAPSHOT</version>
</parent>
<properties>
<composite.file>helloworld-wired</composite.file>
<service.name>r</service.name>
<method.name>run</method.name>
<method.params>' '</method.params>
</properties>
<dependencies>
<dependency>
<groupId>org.ow2.frascati.factory</groupId>
<artifactId>frascati-factory-tools</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>
......@@ -16,6 +16,8 @@
<!-- 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: Damien Fournier -->
<!-- -->
<!-- Contributor(s): Christophe Demarey -->
......
......@@ -16,6 +16,8 @@
<!-- 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 -->
<!-- -->
......
============================================================================
OW2 FraSCAti Examples: HelloWorld POJO
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 POJO example:
------------------------
This example shows how to build an SCA application with two POJOs: a client POJO
and a server POJO. The client is bound to the server and running the client lead
to call the PrintService SCA service offered by the server.
Compilation with Maven:
-----------------------
mvn install
Execution with Maven:
---------------------
mvn -Prun
Compilation and execution with the FraSCAti scripts:
----------------------------------------------------
frascati compile src helloworld-pojo
frascati run helloworld-pojo -libpath helloworld-pojo.jar -s r -m run
......@@ -16,7 +16,11 @@
<!-- 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: Christophe Demarey -->
<!-- -->
<!-- Contributor(s): Nicolas Dolet -->
<project name="helloworld-pojo" default="dist" basedir=".">
<description>
......
<?xml version="1.0"?>
<!--
* OW2 FraSCAti Examples: HelloWorld POJO
*
* 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
*
* Contributor(s):
-->
<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-pojo</artifactId>
<version>0.6-SNAPSHOT</version>
<packaging>jar</packaging>
<name>OW2 FraSCAti Examples: Helloworld POJO</name>
<parent>
<groupId>org.ow2.frascati.examples</groupId>
<artifactId>parent</artifactId>
<version>0.6-SNAPSHOT</version>
</parent>
<properties>
<composite.file>helloworld-pojo</composite.file>
<service.name>r</service.name>
<method.name>run</method.name>
<method.params>' '</method.params>
</properties>
<dependencies>
<dependency>
<groupId>org.ow2.frascati.factory</groupId>
<artifactId>frascati-factory-tools</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>
......@@ -16,8 +16,13 @@
<!-- 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: Damien Fournier -->
<!-- Christophe Demarey -->
<!-- -->
<!-- Contributor(s): Nicolas Dolet -->
<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" name="helloworld-pojo">
<service name="r" promote="client/r"/>
......
============================================================================
OW2 FraSCAti Examples: ISBN test
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
============================================================================
ISBN Test Web Service Client:
-----------------------------
This example shows how to build an SCA client using an ISBN verifier web service
already available over the Internet.
Compilation with Maven:
-----------------------
mvn install
Execution with Maven:
---------------------
mvn -Prun
Compilation and execution with the FraSCAti scripts:
----------------------------------------------------
frascati wsdl2java -f src/main/wsdl/isbnservice.wsdl -o src/main/java
frascati compile src isbntest
frascati run isbntest -libpath isbntest.jar -s Verifier -m verify -p ISBN-10 2-86889-006-7
......@@ -21,7 +21,10 @@
* Contact: frascati@ow2.org
*
* Author: Nicolas Dolet
*
* Contributor(s): Philippe Merle
-->
<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">
......@@ -32,7 +35,7 @@
<version>0.6-SNAPSHOT</version>
<packaging>jar</packaging>
<name>ISBN test</name>
<name>OW2 FraSCAti Examples: ISBN test</name>
<parent>
<groupId>org.ow2.frascati.examples</groupId>
......@@ -42,6 +45,10 @@
<properties>
<wsdl.file>isbnservice.wsdl</wsdl.file>
<composite.file>isbntest</composite.file>
<service.name>Verifier</service.name>
<method.name>verify</method.name>
<method.params>ISBN-10 2-86889-006-7</method.params>
</properties>
<build>
......@@ -54,4 +61,12 @@
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.ow2.frascati.factory</groupId>
<artifactId>frascati-factory-tools</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>
/***
* OW2 FraSCAti Examples: ISBN test
* 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
*
* Contributor(s):
*/
package org.ow2.frascati.examples.isbntest.api;
import org.osoa.sca.annotations.Service;
/**
* Interface for ISBN verification service.
*/
@Service
public interface Verifier {
public static String ISBN_10_TYPE = "ISBN-10";
public static String ISBN_13_TYPE = "ISBN-13";
public boolean verify(String type, String isbn);
}
/***
* OW2 FraSCAti Assembly Factory Examples: ISBN test
* OW2 FraSCAti Examples: ISBN test
* Copyright (C) 2009 INRIA, USTL
*
* This library is free software; you can redistribute it and/or
......@@ -16,49 +16,45 @@
* 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
*
* Contributor(s): Philippe Merle
*/
package org.ow2.frascati.examples.isbntest;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
package org.ow2.frascati.examples.isbntest.lib;
import org.osoa.sca.annotations.Reference;
import org.ow2.frascati.examples.isbntest.api.Verifier;
import com.daehosting.webservices.isbn.ISBNServiceSoapType;
/**
* SCA Java Component implementation using an ISBN test web service
*/
public class Client implements Runnable {
public class Client
implements Verifier {
@Reference
protected ISBNServiceSoapType isbn;
public void run() {
BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
try {
System.out.println("Do you want to check ISBN-10 [1] or ISBN-13 [2]?");
String choice = input.readLine();
if(!(choice.equals("1") || choice.equals("2"))) {
System.err.println("Invalid choice, exit...");
return;
}
System.out.print("Enter ISBN to check: ");
String isbnNumber = input.readLine();
System.out.println("Checking ISBN " + isbnNumber + "...");
boolean valid;
if(choice.equals("1")) {
valid = isbn.isValidISBN10(isbnNumber);
} else {
valid = isbn.isValidISBN13(isbnNumber);
}
System.out.println("ISBN " + isbnNumber + " is " + (valid?"":"not ") + "valid.");
} catch (IOException e) {
System.err.println("Can't read input data!");
e.printStackTrace();
// --------------------------------------------------------------------------
// Implementation of the Verifier interface
// --------------------------------------------------------------------------
public boolean verify(String type, String isbnNumber) {
System.out.println("Checking " + type + ": " + isbnNumber + "...");
boolean isValid;
if (type.equals(Verifier.ISBN_10_TYPE)) {
isValid = isbn.isValidISBN10(isbnNumber);
} else if (type.equals(Verifier.ISBN_13_TYPE)) {
isValid = isbn.isValidISBN13(isbnNumber);
} else {
System.err.println("Invalid ISBN format.");
return false;
}
System.out.println("ISBN " + isbnNumber + " is " + (isValid ? "" : "not ")
+ "valid.");
return isValid;
}
}
<?xml version="1.0" encoding="ISO-8859-15"?>
<!-- OW2 FraSCAti Examples: ISBN test -->
<!-- Copyright (C) 2009 INRIA, USTL -->
<!-- -->
......@@ -17,25 +16,22 @@
<!-- 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 -->
<!-- -->
<!-- Contributor(s): Philippe Merle -->
<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" name="isbntest"
targetNamespace="http://frascati.ow2.org/isbntest">
<service name="r" promote="client/r">
<interface.java interface="java.lang.Runnable" />
</service>
<service name="Verifier" promote="client/Verifier"/>
<component name="client">