diff options
author | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2011-02-10 08:40:56 +0000 |
---|---|---|
committer | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2011-02-10 08:40:56 +0000 |
commit | 8ae95d6e100b095d57502be4247803451a16d97e (patch) | |
tree | 0f6d670fd8de9fcc55088a4bc95121951de72e68 /sca-java-2.x/contrib/samples/getting-started | |
parent | d64d4281ec5636ffc7511cc94fcc3171f34bb805 (diff) |
Copy all trunk samples to contrib
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1069274 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/contrib/samples/getting-started')
45 files changed, 1942 insertions, 0 deletions
diff --git a/sca-java-2.x/contrib/samples/getting-started/callback-api/pom.xml b/sca-java-2.x/contrib/samples/getting-started/callback-api/pom.xml new file mode 100644 index 0000000000..a87560b9f2 --- /dev/null +++ b/sca-java-2.x/contrib/samples/getting-started/callback-api/pom.xml @@ -0,0 +1,51 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-samples</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+ <artifactId>sample-callback-api-contribution</artifactId>
+ <name>Apache Tuscany SCA Sample Callback API Contribution</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/sca-java-2.x/contrib/samples/getting-started/callback-api/src/main/java/sample/CallBack.java b/sca-java-2.x/contrib/samples/getting-started/callback-api/src/main/java/sample/CallBack.java new file mode 100644 index 0000000000..16e4297e9d --- /dev/null +++ b/sca-java-2.x/contrib/samples/getting-started/callback-api/src/main/java/sample/CallBack.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package sample; + +import org.oasisopen.sca.annotation.Remotable; + +/** + * The callback interface. + */ +@Remotable +public interface CallBack { + + void callBackMessage(String aString); + + void callBackIncrement(); + +} diff --git a/sca-java-2.x/contrib/samples/getting-started/callback-api/src/main/java/sample/Client.java b/sca-java-2.x/contrib/samples/getting-started/callback-api/src/main/java/sample/Client.java new file mode 100644 index 0000000000..7e0709e660 --- /dev/null +++ b/sca-java-2.x/contrib/samples/getting-started/callback-api/src/main/java/sample/Client.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package sample; + +import org.oasisopen.sca.annotation.Remotable; + +@Remotable +public interface Client { + + void run(); + +} diff --git a/sca-java-2.x/contrib/samples/getting-started/callback-api/src/main/java/sample/ClientImpl.java b/sca-java-2.x/contrib/samples/getting-started/callback-api/src/main/java/sample/ClientImpl.java new file mode 100644 index 0000000000..01219aa608 --- /dev/null +++ b/sca-java-2.x/contrib/samples/getting-started/callback-api/src/main/java/sample/ClientImpl.java @@ -0,0 +1,108 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package sample; + +import org.oasisopen.sca.annotation.Reference; +import org.oasisopen.sca.annotation.Service; + +@Service(Client.class) +public class ClientImpl implements Client, CallBack { + + public static final String DELIMITER = "\n----------------------------"; + + @Reference + protected sample.Service service; + + private static int callBackCount = 0; + + /** + * This function prints the message received from the service + * implementation. + * + * @param String the message received from the service + */ + public void callBackMessage(String aString) { + System.out.println("ClientImpl - Received callback message: " + aString); + } + + /** + * This function increments the callBackCount variable when called from the + * service implementation. + */ + public void callBackIncrement() { + System.out.println("ClientImpl - Received increment callback"); + callBackCount++; + System.out.println("ClientImpl - Callback counter incremented to : " + getCallBackCount()); + } + + /** + * This method runs different kinds of service calls implying callbacks. + */ + public void run() { + simpleCallBack(); + simpleCallBackByRef(); + noCallBack(); + multipleCallBack(); + } + + /** + * The basic callback where the target calls back prior to returning to the + * client. + */ + private void simpleCallBack() { + System.out.println(DELIMITER + "\nSimple callback" + DELIMITER); + service.knockKnock("Knock Knock"); + } + + /** + * The basic callback where the target calls back prior to returning to the + * client. + */ + private void simpleCallBackByRef() { + System.out.println(DELIMITER + "\nSimple callback by reference" + DELIMITER); + service.knockKnockByRef("Knock Knock by reference"); + } + + /** + * The basic callback where the target does not call back to the client. + */ + private void noCallBack() { + System.out.println(DELIMITER + "\nNo callback" + DELIMITER); + service.noCallBack("No Reply Desired"); + } + + /** + * The basic callback where the target calls back multiple times to the + * client. + */ + private void multipleCallBack() { + System.out.println(DELIMITER + "\nMultiple callbacks" + DELIMITER); + service.multiCallBack("Call me back 3 times"); + } + + /** + * This function returns the callBackCount variable. + * + * @return Integer the callBackCount variable + */ + public int getCallBackCount() { + return callBackCount; + } + +} diff --git a/sca-java-2.x/contrib/samples/getting-started/callback-api/src/main/java/sample/Launcher.java b/sca-java-2.x/contrib/samples/getting-started/callback-api/src/main/java/sample/Launcher.java new file mode 100644 index 0000000000..fa1a59d726 --- /dev/null +++ b/sca-java-2.x/contrib/samples/getting-started/callback-api/src/main/java/sample/Launcher.java @@ -0,0 +1,60 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package sample; + +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.ContributionLocationHelper; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; + +/** + * This class starts the Tuscany Runtime and runs the client calls to the + * service. + */ +public class Launcher { + + public static void main(String[] args) { + Node node = startRuntime(); + Client client = node.getService(Client.class, "Client"); + client.run(); + stopRuntime(node); + } + + /** + * Starts a Tuscany node with the predefined contribution. + * + * @return the running node + */ + private static Node startRuntime() { + String location = ContributionLocationHelper.getContributionLocation("CallBackApi.composite"); + Node node = NodeFactory.newInstance().createNode("CallBackApi.composite", new Contribution("c1", location)); + node.start(); + return node; + } + + /** + * Stops a Tuscany node. + * + * @param node the node to stop + */ + private static void stopRuntime(Node node) { + node.stop(); + } +} diff --git a/sca-java-2.x/contrib/samples/getting-started/callback-api/src/main/java/sample/Service.java b/sca-java-2.x/contrib/samples/getting-started/callback-api/src/main/java/sample/Service.java new file mode 100644 index 0000000000..6723af2adf --- /dev/null +++ b/sca-java-2.x/contrib/samples/getting-started/callback-api/src/main/java/sample/Service.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package sample; + +import org.oasisopen.sca.annotation.Callback; +import org.oasisopen.sca.annotation.Remotable; + +@Remotable +@Callback(CallBack.class) +public interface Service { + + void knockKnock(String aString); + + void knockKnockByRef(String aString); + + void noCallBack(String aString); + + void multiCallBack(String aString); + +} diff --git a/sca-java-2.x/contrib/samples/getting-started/callback-api/src/main/java/sample/ServiceImpl.java b/sca-java-2.x/contrib/samples/getting-started/callback-api/src/main/java/sample/ServiceImpl.java new file mode 100644 index 0000000000..4850f434ff --- /dev/null +++ b/sca-java-2.x/contrib/samples/getting-started/callback-api/src/main/java/sample/ServiceImpl.java @@ -0,0 +1,96 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package sample; + +import org.oasisopen.sca.ComponentContext; +import org.oasisopen.sca.ServiceReference; +import org.oasisopen.sca.annotation.Callback; +import org.oasisopen.sca.annotation.Context; +import org.oasisopen.sca.annotation.Service; + +@Service(sample.Service.class) +public class ServiceImpl implements sample.Service { + + public static final String MESSAGE_RECEIVED = "ServiceImpl - Received message: "; + + @Context + protected ComponentContext componentContext; + + @Callback + protected ServiceReference<CallBack> callbackRef; + + /** + * This function gets an object of ServiceImpl by calling + * getCallBackInterface function and calls the callBackMessage function. + * + * @param aString String passed by a function call + */ + public void knockKnock(String aString) { + System.out.println(MESSAGE_RECEIVED + aString); + CallBack callback = this.getCallBackFromComponentContext(); + callback.callBackMessage("Who's There"); + } + + /** + * This function calls the callBackMessage function. The reference to this + * function is received from the callback reference to the Service class. + * + * @param aString String passed by a function call + */ + public void knockKnockByRef(String aString) { + System.out.println(MESSAGE_RECEIVED + aString); + callbackRef.getService().callBackMessage("Who's There"); + } + + /** + * This function gets an object of ServiceImpl by calling + * getCallBackInterface function. This function then places multiple + * callbacks using the callbackIncrement function defined in the callback + * implementation. + * + * @param aString String passed by a function call + */ + public void multiCallBack(String aString) { + CallBack callback = this.getCallBackFromComponentContext(); + System.out.println(MESSAGE_RECEIVED + aString); + callback.callBackIncrement(); + callback.callBackIncrement(); + callback.callBackIncrement(); + } + + /** + * This function does not callBack any function. + * + * @param aString String passed by a function call + */ + public void noCallBack(String aString) { + System.out.println(MESSAGE_RECEIVED + aString); + } + + /** + * This function gets an object of ServiceImpl from the present + * componentContext. + * + * @return the callback + */ + private CallBack getCallBackFromComponentContext() { + return componentContext.getRequestContext().getCallback(); + } + +} diff --git a/sca-java-2.x/contrib/samples/getting-started/callback-api/src/main/resources/CallBackApi.composite b/sca-java-2.x/contrib/samples/getting-started/callback-api/src/main/resources/CallBackApi.composite new file mode 100644 index 0000000000..ca3a6e5f9d --- /dev/null +++ b/sca-java-2.x/contrib/samples/getting-started/callback-api/src/main/resources/CallBackApi.composite @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +--> +<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" + targetNamespace="http://callback" + name="CallBackApi"> + + <component name="Client"> + <implementation.java class="sample.ClientImpl"/> + <reference name="service" target="Service"/> + </component> + + <component name="Service"> + <implementation.java class="sample.ServiceImpl"/> + </component> + +</composite> diff --git a/sca-java-2.x/contrib/samples/getting-started/callback-api/src/main/resources/META-INF/sca-contribution.xml b/sca-java-2.x/contrib/samples/getting-started/callback-api/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..f17791205a --- /dev/null +++ b/sca-java-2.x/contrib/samples/getting-started/callback-api/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +--> +<contribution xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" + xmlns:t="http://callback"> + <deployable composite="t:CallBackApi" /> +</contribution>
\ No newline at end of file diff --git a/sca-java-2.x/contrib/samples/getting-started/files/helloworld.cmds b/sca-java-2.x/contrib/samples/getting-started/files/helloworld.cmds new file mode 100644 index 0000000000..e94a0e42a6 --- /dev/null +++ b/sca-java-2.x/contrib/samples/getting-started/files/helloworld.cmds @@ -0,0 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# install the helloworld contribution and start its deployables
+install helloworld-contribution/target/helloworld-contribution.jar -start
diff --git a/sca-java-2.x/contrib/samples/getting-started/files/helloworld.xml b/sca-java-2.x/contrib/samples/getting-started/files/helloworld.xml new file mode 100644 index 0000000000..e01074870c --- /dev/null +++ b/sca-java-2.x/contrib/samples/getting-started/files/helloworld.xml @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +--> +<node xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912" + xmlns="http://tuscany.apache.org/xmlns/sca/1.1" + xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1" + domain="helloworld"> + + <contribution location="helloworld-contribution/target/helloworld-contribution.jar" startDeployables="true"/> + +</node>
\ No newline at end of file diff --git a/sca-java-2.x/contrib/samples/getting-started/files/helloworldws.composite b/sca-java-2.x/contrib/samples/getting-started/files/helloworldws.composite new file mode 100644 index 0000000000..abefee7360 --- /dev/null +++ b/sca-java-2.x/contrib/samples/getting-started/files/helloworldws.composite @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://sample"
+ name="helloworldws">
+
+ <component name="HelloworldWSComponent">
+ <implementation.java class="sample.HelloworldImpl"/>
+ <service name="Helloworld">
+ <binding.ws />
+ </service>
+ </component>
+
+</composite>
diff --git a/sca-java-2.x/contrib/samples/getting-started/files/new-sca-contribution.xml b/sca-java-2.x/contrib/samples/getting-started/files/new-sca-contribution.xml new file mode 100644 index 0000000000..62e8fef55d --- /dev/null +++ b/sca-java-2.x/contrib/samples/getting-started/files/new-sca-contribution.xml @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +--> +<contribution xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" + xmlns:sample="http://sample"> + + <!-- Add exports from the helloworld contribution resources so other contributions can reuse them --> + <export namespace="http://sample"/> + <export.java package="sample"/> + +</contribution> diff --git a/sca-java-2.x/contrib/samples/getting-started/files/scdl-include.xml b/sca-java-2.x/contrib/samples/getting-started/files/scdl-include.xml new file mode 100644 index 0000000000..b15b20befd --- /dev/null +++ b/sca-java-2.x/contrib/samples/getting-started/files/scdl-include.xml @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +--> +<node xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912" + xmlns="http://tuscany.apache.org/xmlns/sca/1.1" + xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1" + domain="helloworld"> + + <contribution location="helloworld-contribution/target/helloworld-contribution.jar" metaDataURL="new-sca-contribution.xml"/> + <contribution location="scdl-include-contribution/target/scdl-include-contribution.zip" startDeployables="true" /> + +</node>
\ No newline at end of file diff --git a/sca-java-2.x/contrib/samples/getting-started/files/wsClient.html b/sca-java-2.x/contrib/samples/getting-started/files/wsClient.html new file mode 100644 index 0000000000..402f30cdf8 --- /dev/null +++ b/sca-java-2.x/contrib/samples/getting-started/files/wsClient.html @@ -0,0 +1,143 @@ +<!-- + + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +--> + +<!-- +Simple html page that presents a form to post xml to a web service endpoint and display the response xml. +Copied from ServiceMix wsdl first example. +--> + +<html> +<head> +<title>Tuscany Web service Sample Client</title> +<script type="text/javascript"> + +var urlToOpen = "http://localhost:8085/HelloworldComponent/Helloworld"; //default URL to open + +function getHTTPObject() { + var xmlhttp = false; + + /* Compilation conditionnelle d'IE */ + /*@cc_on + @if (@_jscript_version >= 5) + try { + xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); + } catch (e) { + try { + xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); + } catch (E) { + xmlhttp = false; + } + } + @else + xmlhttp = false; + @end @*/ + + /* on essaie de créer l'objet si ce n'est pas déjà fait */ + if (!xmlhttp && typeof XMLHttpRequest != 'undefined') { + try { + xmlhttp = new XMLHttpRequest(); + } catch (e) { + xmlhttp = false; + } + } + + if (xmlhttp) { + /* on définit ce qui doit se passer quand la page répondra */ + xmlhttp.onreadystatechange=function() { + if (xmlhttp.readyState == 4) { /* 4 : état "complete" */ + var response = document.getElementById("response"); + var responseStatus = ""; + try { + responseStatus = xmlhttp.status + ""; + } catch (e) { + responseStatus = "ERROR WHILE RETRIEVING STATUS; MAYBE UNABLE TO CONNECT."; + } + response.value = xmlhttp.responseText; + } + } + } + return xmlhttp; +} + +function send() { + if ((document.getElementById("urlToOpen").value != urlToOpen) && (document.getElementById("urlToOpen").value != "")) { + //use user entry only if it at least can be okay + urlToOpen = document.getElementById("urlToOpen").value; + } + var xmlhttp = getHTTPObject(); + if (!xmlhttp) { + alert('cound not create XMLHttpRequest object'); + return; + } + var request = document.getElementById("request"); + var response = document.getElementById("response"); + try { + netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead UniversalBrowserWrite"); + } catch (e) { + } + + + try { + xmlhttp.open("POST", urlToOpen, true); + } catch (e) { + alert('error opening'); + } + xmlhttp.setRequestHeader("Content-Type", "text/xml;charset=UTF-8"); + xmlhttp.send(request.value); +} + +</script> +</head> + +<body> + +<h1>Tuscany Web service Sample Client</h1> + +<p>Tuscany Web service Sample Client</p> + +<p>Sends a request to a Web Service endpoint. (This requires JavaScript)</p> +<p>Target: <input type="text" size="50" id="urlToOpen" value=""><script type="text/javascript">document.getElementById("urlToOpen").value = urlToOpen;</script>.</p> + +<table> + <tr> + <td> + <textarea id="request" style="width:600px;height:400px" ><?xml version='1.0' encoding='UTF-8'?> +<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> +<soapenv:Body> +<ns:sayHello xmlns:ns="http://helloworld"> +<ns:name>petra</ns:name> +</ns:sayHello> +</soapenv:Body> +</soapenv:Envelope> + + </textarea> + </td> + <td> + <textarea id="response" style="width:600px;height:400px"> + </textarea> + </td> + </tr> + <tr> + <td colspan=2> + <input type="button" value="Send" onClick="send();"/> + </td> + </tr> +</table> +</body> +</html> diff --git a/sca-java-2.x/contrib/samples/getting-started/helloworld-contribution/README b/sca-java-2.x/contrib/samples/getting-started/helloworld-contribution/README new file mode 100644 index 0000000000..bab77d3885 --- /dev/null +++ b/sca-java-2.x/contrib/samples/getting-started/helloworld-contribution/README @@ -0,0 +1,42 @@ +Tuscany - Getting Started - Helloworld Sample
+---------------------------------------------
+
+This sample demonstrates a simple helloworld style SCA application and how to run that with Tuscany.
+
+See the README in the top-level samples folder for general information on the Tuscany samples.
+
+This project creates a jar format SCA contribution with a deployable composite, helloworld.comosite.
+The composite defines an SCA component, HelloworldComponent, which provides a Helloworld service,
+the component is implemented by a Java class.
+
+You can use the contribution by installing it and starting the composite in the Tuscany Shell. To do
+that run the following command in the helloworld-contribution folder:
+
+ mvn tuscany:run
+
+Alternatively, the Tuscany Shell can be started with the scripts in the Tuscany binary distribution
+bin folder. To do that run the following command at the root of a Tuscany binary distribution:
+
+ bin\tuscany.bat samples\getting-started\helloworld-contribution
+
+Once the Shell has been started with one of those methods you can use Shell commands to explore
+the SCA domain, for example, use the "installed" command to get the status of installed contributions,
+"services" to see the available component services. You may test calling the helloworld service by
+using the "invoke" command:
+
+ invoke HelloworldComponent sayHello yourName
+
+---
+
+This sample was created by the Tuscany contribution-jar Maven archetype. You can use that archetype to
+create your own SCA contribution projects by running the following Maven command:
+
+ mvn archetype:generate -DarchetypeCatalog=http://tuscany.apache.org
+
+then at the prompt select 1 to choose the contribution-jar archetype and then answer the questions.
+This project used the following answers:
+
+ Define value for property 'groupId': : org.apache.tuscany.sca.samples
+ Define value for property 'artifactId': : helloworld-contribution
+ Define value for property 'version': 1.0-SNAPSHOT: 2.0-SNAPSHOT
+ Define value for property 'package': org.apache.tuscany.sca.samples: sample
diff --git a/sca-java-2.x/contrib/samples/getting-started/helloworld-contribution/pom.xml b/sca-java-2.x/contrib/samples/getting-started/helloworld-contribution/pom.xml new file mode 100644 index 0000000000..5ecc7a8831 --- /dev/null +++ b/sca-java-2.x/contrib/samples/getting-started/helloworld-contribution/pom.xml @@ -0,0 +1,86 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<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.apache.tuscany.sca.samples</groupId>
+ <artifactId>helloworld-contribution</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <packaging>jar</packaging>
+
+ <name>helloworld-contribution</name>
+
+ <properties>
+ <tuscany.version>2.0-SNAPSHOT</tuscany.version>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>${tuscany.version}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-base-runtime</artifactId>
+ <version>${tuscany.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <finalName>helloworld-contribution</finalName>
+
+ <plugins>
+ <plugin>
+ <groupId>org.apache.tuscany.maven.plugins</groupId>
+ <artifactId>maven-tuscany-plugin</artifactId>
+ <version>${tuscany.version}</version>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ <optimise>true</optimise>
+ <debug>true</debug>
+ </configuration>
+ </plugin>
+ </plugins>
+
+ </build>
+
+</project>
diff --git a/sca-java-2.x/contrib/samples/getting-started/helloworld-contribution/src/main/java/sample/Helloworld.java b/sca-java-2.x/contrib/samples/getting-started/helloworld-contribution/src/main/java/sample/Helloworld.java new file mode 100644 index 0000000000..f4e8c50448 --- /dev/null +++ b/sca-java-2.x/contrib/samples/getting-started/helloworld-contribution/src/main/java/sample/Helloworld.java @@ -0,0 +1,28 @@ +/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package sample;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface Helloworld {
+
+ String sayHello(String name);
+
+}
diff --git a/sca-java-2.x/contrib/samples/getting-started/helloworld-contribution/src/main/java/sample/HelloworldImpl.java b/sca-java-2.x/contrib/samples/getting-started/helloworld-contribution/src/main/java/sample/HelloworldImpl.java new file mode 100644 index 0000000000..3b86c10df0 --- /dev/null +++ b/sca-java-2.x/contrib/samples/getting-started/helloworld-contribution/src/main/java/sample/HelloworldImpl.java @@ -0,0 +1,36 @@ +/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package sample;
+
+import org.oasisopen.sca.annotation.Init;
+import org.oasisopen.sca.annotation.Scope;
+import org.oasisopen.sca.annotation.EagerInit;
+
+@Scope("COMPOSITE") @EagerInit
+public class HelloworldImpl implements Helloworld {
+
+ public String sayHello(String name) {
+ return "Hello " + name;
+ }
+
+ @Init
+ public void init() {
+ System.out.println(sayHello("world"));
+ }
+}
diff --git a/sca-java-2.x/contrib/samples/getting-started/helloworld-contribution/src/main/resources/META-INF/sca-contribution.xml b/sca-java-2.x/contrib/samples/getting-started/helloworld-contribution/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..95c32fb5bf --- /dev/null +++ b/sca-java-2.x/contrib/samples/getting-started/helloworld-contribution/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<contribution xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sample="http://sample">
+
+ <deployable composite="sample:helloworld-contribution" />
+
+</contribution>
diff --git a/sca-java-2.x/contrib/samples/getting-started/helloworld-contribution/src/main/resources/helloworld.composite b/sca-java-2.x/contrib/samples/getting-started/helloworld-contribution/src/main/resources/helloworld.composite new file mode 100644 index 0000000000..e0206cd6e8 --- /dev/null +++ b/sca-java-2.x/contrib/samples/getting-started/helloworld-contribution/src/main/resources/helloworld.composite @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://sample"
+ name="helloworld-contribution">
+
+ <component name="HelloworldComponent">
+ <implementation.java class="sample.HelloworldImpl"/>
+ </component>
+
+</composite>
diff --git a/sca-java-2.x/contrib/samples/getting-started/helloworld-contribution/src/test/java/sample/HelloworldTestCase.java b/sca-java-2.x/contrib/samples/getting-started/helloworld-contribution/src/test/java/sample/HelloworldTestCase.java new file mode 100644 index 0000000000..be27aa68ef --- /dev/null +++ b/sca-java-2.x/contrib/samples/getting-started/helloworld-contribution/src/test/java/sample/HelloworldTestCase.java @@ -0,0 +1,48 @@ +/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package sample;
+
+import org.junit.Assert;
+
+import org.apache.tuscany.sca.Node;
+import org.apache.tuscany.sca.TuscanyRuntime;
+import org.junit.Test;
+import org.oasisopen.sca.NoSuchServiceException;
+
+public class HelloworldTestCase {
+
+ @Test
+ public void testSayHello() throws NoSuchServiceException {
+
+ // Run the SCA composite in a Tuscany runtime
+ Node node = TuscanyRuntime.runComposite("helloworld.composite", "target/classes");
+ try {
+
+ // Get the Helloworld service proxy
+ Helloworld helloworld = node.getService(Helloworld.class, "HelloworldComponent");
+
+ // test that it works as expected
+ Assert.assertEquals("Hello Amelia", helloworld.sayHello("Amelia"));
+
+ } finally {
+ // Stop the Tuscany runtime Node
+ node.stop();
+ }
+ }
+}
diff --git a/sca-java-2.x/contrib/samples/getting-started/helloworld-webapp/README b/sca-java-2.x/contrib/samples/getting-started/helloworld-webapp/README new file mode 100644 index 0000000000..828aadb0f1 --- /dev/null +++ b/sca-java-2.x/contrib/samples/getting-started/helloworld-webapp/README @@ -0,0 +1,7 @@ +The README in the <distribution-unpack-dir>/samples directory provides
+general instructions about building and running samples. (where
+distribution-unpack-dir is the directory in which you unpacked the tuscany
+binary distribution archive). Take a look there first (noting at you read it that this sample
+is not a new style sample).
+
+TODO - finish
\ No newline at end of file diff --git a/sca-java-2.x/contrib/samples/getting-started/helloworld-webapp/pom.xml b/sca-java-2.x/contrib/samples/getting-started/helloworld-webapp/pom.xml new file mode 100644 index 0000000000..4a8c757ecf --- /dev/null +++ b/sca-java-2.x/contrib/samples/getting-started/helloworld-webapp/pom.xml @@ -0,0 +1,120 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +--> +<project> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-samples</artifactId> + <version>2.0-SNAPSHOT</version> + <relativePath>../../pom.xml</relativePath> + </parent> + + <artifactId>sample-helloworld-webapp</artifactId> + <name>Apache Tuscany SCA Sample Helloworld</name> + <packaging>war</packaging> + + <dependencies> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-base-runtime</artifactId> + <version>2.0-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.8.1</version> + <scope>test</scope> + </dependency> + + </dependencies> + + <build> + <finalName>helloworld</finalName> + <plugins> + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-dependency-plugin</artifactId> + <executions> + <execution> + <id>copy</id> + <phase>compile</phase> + <goals> + <goal>copy</goal> + </goals> + <configuration> + <artifactItems> + <artifactItem> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>sample-helloworld-contribution</artifactId> + <version>${project.version}</version> + <!-- should really go in the target folder but i can't get jetty:run to work using that --> + <outputDirectory>src/main/webapp/WEB-INF/sca-contributions</outputDirectory> + </artifactItem> + </artifactItems> + </configuration> + </execution> + </executions> + </plugin> + + <plugin> + <groupId>org.mortbay.jetty</groupId> + <artifactId>maven-jetty-plugin</artifactId> + <version>6.1.18</version> + <configuration> + <contextPath>helloworld</contextPath> + <stopKey>foo</stopKey> + <stopPort>9999</stopPort> + </configuration> +<!-- + <executions> + <execution> + <id>start-jetty</id> + <phase>process-test-classes</phase> + <goals> + <goal>run</goal> + </goals> + <configuration> + <overrideWebXml>src/test/resources/test-web.xml</overrideWebXml> + <scanIntervalSeconds>0</scanIntervalSeconds> + <daemon>true</daemon> + <connectors> + <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector"> + <port>8085</port> + </connector> + </connectors> + </configuration> + </execution> + <execution> + <id>stop-jetty</id> + <phase>prepare-package</phase> + <goals> + <goal>stop</goal> + </goals> + </execution> + </executions> +--> + </plugin> + </plugins> + </build> + +</project> diff --git a/sca-java-2.x/contrib/samples/getting-started/helloworld-webapp/src/main/java/sample/Helloworld.java b/sca-java-2.x/contrib/samples/getting-started/helloworld-webapp/src/main/java/sample/Helloworld.java new file mode 100644 index 0000000000..1eeb8be9fd --- /dev/null +++ b/sca-java-2.x/contrib/samples/getting-started/helloworld-webapp/src/main/java/sample/Helloworld.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package sample; + +import org.oasisopen.sca.annotation.Remotable; + +@Remotable +public interface Helloworld { + + String sayHello(String name); + +} diff --git a/sca-java-2.x/contrib/samples/getting-started/helloworld-webapp/src/main/webapp/WEB-INF/web.composite b/sca-java-2.x/contrib/samples/getting-started/helloworld-webapp/src/main/webapp/WEB-INF/web.composite new file mode 100644 index 0000000000..0c03826f99 --- /dev/null +++ b/sca-java-2.x/contrib/samples/getting-started/helloworld-webapp/src/main/webapp/WEB-INF/web.composite @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://samples"
+ name="Helloworld">
+
+ <component name="foo">
+ <implementation.web web-uri=""/>
+ <reference name="service" target="HelloworldComponent"/>
+ </component>
+
+</composite>
diff --git a/sca-java-2.x/contrib/samples/getting-started/helloworld-webapp/src/main/webapp/WEB-INF/web.xml b/sca-java-2.x/contrib/samples/getting-started/helloworld-webapp/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..b83a9c3417 --- /dev/null +++ b/sca-java-2.x/contrib/samples/getting-started/helloworld-webapp/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,41 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +--> +<web-app version="2.4" + xmlns="http://java.sun.com/xml/ns/j2ee" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" > + + <display-name>Apache Tuscany Helloworld Sample</display-name> + + <filter> + <filter-name>tuscany</filter-name> + <filter-class>org.apache.tuscany.sca.host.webapp.TuscanyServletFilter</filter-class> + </filter> + + <filter-mapping> + <filter-name>tuscany</filter-name> + <url-pattern>/*</url-pattern> + </filter-mapping> + + <welcome-file-list id="WelcomeFileList"> + <welcome-file>hello.jsp</welcome-file> + </welcome-file-list> + +</web-app> diff --git a/sca-java-2.x/contrib/samples/getting-started/helloworld-webapp/src/main/webapp/hello.jsp b/sca-java-2.x/contrib/samples/getting-started/helloworld-webapp/src/main/webapp/hello.jsp new file mode 100644 index 0000000000..57abb08ca2 --- /dev/null +++ b/sca-java-2.x/contrib/samples/getting-started/helloworld-webapp/src/main/webapp/hello.jsp @@ -0,0 +1,37 @@ +<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+<%@ taglib uri="http://www.osoa.org/sca/sca_jsp.tld" prefix="sca" %>
+
+<sca:reference name="service" type="sample.Helloworld" />
+
+<html>
+ <body >
+
+ <h2>Apache Tuscany Helloworld JSP Sample</h2>
+
+ Calling HelloworldService sayHello("world") returns:
+
+ <p>
+
+ <%= service.sayHello("world") %>
+
+ </body>
+</html>
diff --git a/sca-java-2.x/contrib/samples/getting-started/helloworld-webapp/src/test/java/itest/Helloworld.java b/sca-java-2.x/contrib/samples/getting-started/helloworld-webapp/src/test/java/itest/Helloworld.java new file mode 100644 index 0000000000..f1ccf0b1ba --- /dev/null +++ b/sca-java-2.x/contrib/samples/getting-started/helloworld-webapp/src/test/java/itest/Helloworld.java @@ -0,0 +1,27 @@ +/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package itest;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface Helloworld {
+ String sayHello(String name);
+}
diff --git a/sca-java-2.x/contrib/samples/getting-started/helloworld-webapp/src/test/java/itest/HelloworldTestCaseFIXME.java b/sca-java-2.x/contrib/samples/getting-started/helloworld-webapp/src/test/java/itest/HelloworldTestCaseFIXME.java new file mode 100644 index 0000000000..76d6661576 --- /dev/null +++ b/sca-java-2.x/contrib/samples/getting-started/helloworld-webapp/src/test/java/itest/HelloworldTestCaseFIXME.java @@ -0,0 +1,44 @@ +/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package itest;
+
+import static org.junit.Assert.assertEquals;
+
+import java.net.URI;
+
+import org.junit.Test;
+import org.oasisopen.sca.NoSuchDomainException;
+import org.oasisopen.sca.NoSuchServiceException;
+import org.oasisopen.sca.client.SCAClientFactory;
+
+/**
+ */
+public class HelloworldTestCaseFIXME {
+
+ @Test
+ public void testHelloworld() throws NoSuchDomainException, NoSuchServiceException {
+// TODO: need to fix the config URI so it works properly
+// SCAClientFactory factory = SCAClientFactory.newInstance(URI.create("uri:default?remote=127.0.0.1:54321"));
+// SCAClientFactory factory = SCAClientFactory.newInstance(URI.create("tuscany:default?remotes=192.168.1.64"));
+// Helloworld helloworld = factory.getService(Helloworld.class, "HelloworldComponent");
+// assertEquals("Hello World", helloworld.sayHello("World"));
+ }
+
+}
diff --git a/sca-java-2.x/contrib/samples/getting-started/helloworld-webapp/src/test/resources/test-web.xml b/sca-java-2.x/contrib/samples/getting-started/helloworld-webapp/src/test/resources/test-web.xml new file mode 100644 index 0000000000..a68aa28698 --- /dev/null +++ b/sca-java-2.x/contrib/samples/getting-started/helloworld-webapp/src/test/resources/test-web.xml @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<web-app version="2.4"
+ xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" >
+
+ <context-param>
+ <param-name>org.apache.tuscany.sca.config</param-name>
+ <param-value>uri:default?bind=127.0.0.1:54321</param-value>
+ </context-param>
+
+</web-app>
diff --git a/sca-java-2.x/contrib/samples/getting-started/pom.xml b/sca-java-2.x/contrib/samples/getting-started/pom.xml new file mode 100644 index 0000000000..56195a1997 --- /dev/null +++ b/sca-java-2.x/contrib/samples/getting-started/pom.xml @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +--> +<project> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-samples</artifactId> + <version>2.0-SNAPSHOT</version> + </parent> + <artifactId>tuscany-samples-getting-started-contributions</artifactId> + <groupId>org.apache.tuscany.sca</groupId> + <packaging>pom</packaging> + <name>Apache Tuscany SCA Getting Started Sample Contributions</name> + + <profiles> + <profile> + <id>default</id> + <activation> + <activeByDefault>true</activeByDefault> + </activation> + <modules> + <module>helloworld-contribution</module> + <module>scdl-include-contribution</module> + <module>callback-api</module> + <module>sca-scopes</module> + <module>helloworld-webapp</module> + </modules> + </profile> + </profiles> +</project> diff --git a/sca-java-2.x/contrib/samples/getting-started/sca-scopes/pom.xml b/sca-java-2.x/contrib/samples/getting-started/sca-scopes/pom.xml new file mode 100644 index 0000000000..878da43573 --- /dev/null +++ b/sca-java-2.x/contrib/samples/getting-started/sca-scopes/pom.xml @@ -0,0 +1,51 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-samples</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+ <name>Apache Tuscany SCA Sample SCA Scopes Contribution</name>
+ <artifactId>sample-sca-scopes-contribution</artifactId>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/sca-java-2.x/contrib/samples/getting-started/sca-scopes/src/main/java/sample/Client.java b/sca-java-2.x/contrib/samples/getting-started/sca-scopes/src/main/java/sample/Client.java new file mode 100644 index 0000000000..13f6e003f8 --- /dev/null +++ b/sca-java-2.x/contrib/samples/getting-started/sca-scopes/src/main/java/sample/Client.java @@ -0,0 +1,25 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package sample; + +public interface Client { + + void run(); + +} diff --git a/sca-java-2.x/contrib/samples/getting-started/sca-scopes/src/main/java/sample/ClientImpl.java b/sca-java-2.x/contrib/samples/getting-started/sca-scopes/src/main/java/sample/ClientImpl.java new file mode 100644 index 0000000000..3dbeeb0649 --- /dev/null +++ b/sca-java-2.x/contrib/samples/getting-started/sca-scopes/src/main/java/sample/ClientImpl.java @@ -0,0 +1,54 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package sample; + +import org.oasisopen.sca.annotation.Reference; + +public class ClientImpl implements Client { + + private static final int TIMES = 5; + + @Reference + private CompositeService compositeService; + + @Reference + private StatelessService statelessService; + + public void setCompositeService(CompositeService compositeService) { + this.compositeService = compositeService; + } + + public void setStatelessService(StatelessService statelessService) { + this.statelessService = statelessService; + } + + @Override + public void run() { + System.out.println("Calling CompositeService " + TIMES + " times..."); + for (int i = 0 ; i < TIMES; i++) { + compositeService.hello(); + } + System.out.println("Calling StatelessService " + TIMES + " times..."); + for (int i = 0 ; i < TIMES; i++) { + statelessService.hello(); + } + } + + +} diff --git a/sca-java-2.x/contrib/samples/getting-started/sca-scopes/src/main/java/sample/CompositeService.java b/sca-java-2.x/contrib/samples/getting-started/sca-scopes/src/main/java/sample/CompositeService.java new file mode 100644 index 0000000000..60384cb73c --- /dev/null +++ b/sca-java-2.x/contrib/samples/getting-started/sca-scopes/src/main/java/sample/CompositeService.java @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */package sample; + +import org.oasisopen.sca.annotation.Remotable; + +@Remotable +public interface CompositeService { + + void hello(); + +} diff --git a/sca-java-2.x/contrib/samples/getting-started/sca-scopes/src/main/java/sample/CompositeServiceImpl.java b/sca-java-2.x/contrib/samples/getting-started/sca-scopes/src/main/java/sample/CompositeServiceImpl.java new file mode 100644 index 0000000000..f4587671c0 --- /dev/null +++ b/sca-java-2.x/contrib/samples/getting-started/sca-scopes/src/main/java/sample/CompositeServiceImpl.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package sample; + +import org.oasisopen.sca.annotation.Scope; +import org.oasisopen.sca.annotation.Service; + +@Scope("COMPOSITE") +@Service(CompositeService.class) +public class CompositeServiceImpl implements CompositeService { + + public CompositeServiceImpl() { + super(); + System.out.println("Constructing CompositeServiceImpl instance."); + } + + @Override + public void hello() { + System.out.println("Saying hello to CompositeServiceImpl instance."); + } + +} diff --git a/sca-java-2.x/contrib/samples/getting-started/sca-scopes/src/main/java/sample/Launcher.java b/sca-java-2.x/contrib/samples/getting-started/sca-scopes/src/main/java/sample/Launcher.java new file mode 100644 index 0000000000..8d00b6ef64 --- /dev/null +++ b/sca-java-2.x/contrib/samples/getting-started/sca-scopes/src/main/java/sample/Launcher.java @@ -0,0 +1,56 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package sample; + +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.ContributionLocationHelper; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; + +public class Launcher { + + public static void main(String[] args) { + Node node = startRuntime(); + Client client = node.getService(Client.class, "Client"); + client.run(); + stopRuntime(node); + } + + /** + * Starts a Tuscany node with the predefined contribution. + * + * @return the running node + */ + private static Node startRuntime() { + String location = ContributionLocationHelper.getContributionLocation("scopes.composite"); + Node node = NodeFactory.newInstance().createNode("scopes.composite", new Contribution("c1", location)); + node.start(); + return node; + } + + /** + * Stops a Tuscany node. + * + * @param node the node to stop + */ + private static void stopRuntime(Node node) { + node.stop(); + } + +} diff --git a/sca-java-2.x/contrib/samples/getting-started/sca-scopes/src/main/java/sample/StatelessService.java b/sca-java-2.x/contrib/samples/getting-started/sca-scopes/src/main/java/sample/StatelessService.java new file mode 100644 index 0000000000..8474bc6ff3 --- /dev/null +++ b/sca-java-2.x/contrib/samples/getting-started/sca-scopes/src/main/java/sample/StatelessService.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package sample; + +import org.oasisopen.sca.annotation.Remotable; + +@Remotable +public interface StatelessService { + + void hello(); + +} diff --git a/sca-java-2.x/contrib/samples/getting-started/sca-scopes/src/main/java/sample/StatelessServiceImpl.java b/sca-java-2.x/contrib/samples/getting-started/sca-scopes/src/main/java/sample/StatelessServiceImpl.java new file mode 100644 index 0000000000..94d6339c3d --- /dev/null +++ b/sca-java-2.x/contrib/samples/getting-started/sca-scopes/src/main/java/sample/StatelessServiceImpl.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package sample; + +import org.oasisopen.sca.annotation.Scope; +import org.oasisopen.sca.annotation.Service; + +@Scope("STATELESS") +@Service(StatelessService.class) +public class StatelessServiceImpl implements StatelessService { + + public StatelessServiceImpl() { + super(); + System.out.println("Constructing StatelessServiceImpl instance."); + } + + @Override + public void hello() { + System.out.println("Saying hello to StatelessServiceImpl."); + } +} diff --git a/sca-java-2.x/contrib/samples/getting-started/sca-scopes/src/main/resources/scopes.composite b/sca-java-2.x/contrib/samples/getting-started/sca-scopes/src/main/resources/scopes.composite new file mode 100644 index 0000000000..14937a1f34 --- /dev/null +++ b/sca-java-2.x/contrib/samples/getting-started/sca-scopes/src/main/resources/scopes.composite @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +--> +<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" + targetNamespace="http://Scopes" + name="Scopes"> + + <component name="Stateless"> + <implementation.java class="sample.StatelessServiceImpl"/> + </component> + + <component name="Composite"> + <implementation.java class="sample.CompositeServiceImpl"/> + </component> + + <component name="Client"> + <implementation.java class="sample.ClientImpl"/> + <reference name="statelessService" target="Stateless"/> + <reference name="compositeService" target="Composite"/> + </component> + +</composite> diff --git a/sca-java-2.x/contrib/samples/getting-started/scdl-include-contribution/README b/sca-java-2.x/contrib/samples/getting-started/scdl-include-contribution/README new file mode 100644 index 0000000000..ed0f1d0ce4 --- /dev/null +++ b/sca-java-2.x/contrib/samples/getting-started/scdl-include-contribution/README @@ -0,0 +1,7 @@ +The README in the <distribution-unpack-dir>/samples directory provides
+general instructions about building and running samples. (where
+distribution-unpack-dir is the directory in which you unpacked the tuscany
+binary distribution archive). Take a look there first (noting at you read it that this sample
+is not a new style sample).
+
+TODO - finish this
\ No newline at end of file diff --git a/sca-java-2.x/contrib/samples/getting-started/scdl-include-contribution/pom.xml b/sca-java-2.x/contrib/samples/getting-started/scdl-include-contribution/pom.xml new file mode 100644 index 0000000000..3dfd4da55d --- /dev/null +++ b/sca-java-2.x/contrib/samples/getting-started/scdl-include-contribution/pom.xml @@ -0,0 +1,76 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-samples</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <packaging>zip</packaging>
+ <artifactId>sample-scdl-include-contribution</artifactId>
+ <name>Apache Tuscany SCA Sample include Composite Contribution</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <finalName>${project.artifactId}</finalName>
+
+ <plugins>
+
+ <!-- plugin to support zip packaging for SCA contributions -->
+ <plugin>
+ <groupId>org.apache.tuscany.maven.plugins</groupId>
+ <artifactId>maven-zip-plugin</artifactId>
+ <version>alpha2</version>
+ <extensions>true</extensions>
+ </plugin>
+
+ <!-- plugin to support using mvn tuscany:run to run this contribution -->
+ <plugin>
+ <groupId>org.apache.tuscany.maven.plugins</groupId>
+ <artifactId>maven-tuscany-plugin</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <configuration>
+ <contributions>
+ <!-- add the dependee contribution that this contribution uses -->
+ <param>../helloworld-contribution/target/helloworld-contribution.jar</param>
+ </contributions>
+ </configuration>
+ </plugin>
+
+ </plugins>
+ </build>
+</project>
diff --git a/sca-java-2.x/contrib/samples/getting-started/scdl-include-contribution/src/main/resources/META-INF/sca-contribution.xml b/sca-java-2.x/contrib/samples/getting-started/scdl-include-contribution/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..b7677f1740 --- /dev/null +++ b/sca-java-2.x/contrib/samples/getting-started/scdl-include-contribution/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<contribution xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sample="http://sample">
+ <deployable composite="sample:scdl-include"/>
+ <import namespace="http://sample"/>
+ <export namespace="http://sample"/>
+</contribution>
+
diff --git a/sca-java-2.x/contrib/samples/getting-started/scdl-include-contribution/src/main/resources/scdl-include.composite b/sca-java-2.x/contrib/samples/getting-started/scdl-include-contribution/src/main/resources/scdl-include.composite new file mode 100644 index 0000000000..7f75c65a68 --- /dev/null +++ b/sca-java-2.x/contrib/samples/getting-started/scdl-include-contribution/src/main/resources/scdl-include.composite @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="scdl-include">
+
+ <include name="sample:helloworld" />
+
+ <service name="MyHelloworld" promote="HelloworldComponent/Helloworld" />
+
+</composite>
|