From 6865c59e74f19ed6057d03583944b47abd6e036e Mon Sep 17 00:00:00 2001 From: antelder Date: Tue, 26 Oct 2010 07:46:08 +0000 Subject: Create branch for next release git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1027394 13f79535-47bb-0310-9956-ffa450edef68 --- .../samples/getting-started/callback-api/pom.xml | 51 ++++++++ .../src/main/java/sample/CallBack.java | 33 +++++ .../callback-api/src/main/java/sample/Client.java | 28 ++++ .../src/main/java/sample/ClientImpl.java | 108 ++++++++++++++++ .../src/main/java/sample/Launcher.java | 60 +++++++++ .../callback-api/src/main/java/sample/Service.java | 36 ++++++ .../src/main/java/sample/ServiceImpl.java | 96 ++++++++++++++ .../src/main/resources/CallBackApi.composite | 33 +++++ .../main/resources/META-INF/sca-contribution.xml | 23 ++++ .../samples/getting-started/files/helloworld.cmds | 19 +++ .../samples/getting-started/files/helloworld.xml | 27 ++++ .../getting-started/files/new-sca-contribution.xml | 27 ++++ .../samples/getting-started/files/scdl-include.xml | 28 ++++ .../samples/getting-started/files/wsClient.html | 143 +++++++++++++++++++++ .../getting-started/helloworld-contribution/README | 7 + .../helloworld-contribution/pom.xml | 58 +++++++++ .../src/main/java/sample/Helloworld.java | 28 ++++ .../src/main/java/sample/HelloworldImpl.java | 37 ++++++ .../main/resources/META-INF/sca-contribution.xml | 25 ++++ .../src/main/resources/helloworld.composite | 29 +++++ .../src/main/resources/helloworldws.composite | 32 +++++ .../src/test/java/sample/HelloworldTestCase.java | 33 +++++ .../getting-started/helloworld-webapp/README | 7 + .../getting-started/helloworld-webapp/pom.xml | 118 +++++++++++++++++ .../src/main/webapp/WEB-INF/web.xml | 49 +++++++ .../src/test/java/itest/Helloworld.java | 27 ++++ .../test/java/itest/HelloworldTestCaseFIXME.java | 44 +++++++ .../src/test/resources/test-web.xml | 30 +++++ .../2.0-Beta1/samples/getting-started/pom.xml | 48 +++++++ .../samples/getting-started/sca-scopes/pom.xml | 51 ++++++++ .../sca-scopes/src/main/java/sample/Client.java | 25 ++++ .../src/main/java/sample/ClientImpl.java | 54 ++++++++ .../src/main/java/sample/CompositeService.java | 27 ++++ .../src/main/java/sample/CompositeServiceImpl.java | 38 ++++++ .../sca-scopes/src/main/java/sample/Launcher.java | 56 ++++++++ .../src/main/java/sample/StatelessService.java | 28 ++++ .../src/main/java/sample/StatelessServiceImpl.java | 37 ++++++ .../sca-scopes/src/main/resources/scopes.composite | 38 ++++++ .../scdl-include-contribution/README | 7 + .../scdl-include-contribution/pom.xml | 76 +++++++++++ .../main/resources/META-INF/sca-contribution.xml | 26 ++++ .../src/main/resources/scdl-include.composite | 30 +++++ 42 files changed, 1777 insertions(+) create mode 100644 sca-java-2.x/branches/2.0-Beta1/samples/getting-started/callback-api/pom.xml create mode 100644 sca-java-2.x/branches/2.0-Beta1/samples/getting-started/callback-api/src/main/java/sample/CallBack.java create mode 100644 sca-java-2.x/branches/2.0-Beta1/samples/getting-started/callback-api/src/main/java/sample/Client.java create mode 100644 sca-java-2.x/branches/2.0-Beta1/samples/getting-started/callback-api/src/main/java/sample/ClientImpl.java create mode 100644 sca-java-2.x/branches/2.0-Beta1/samples/getting-started/callback-api/src/main/java/sample/Launcher.java create mode 100644 sca-java-2.x/branches/2.0-Beta1/samples/getting-started/callback-api/src/main/java/sample/Service.java create mode 100644 sca-java-2.x/branches/2.0-Beta1/samples/getting-started/callback-api/src/main/java/sample/ServiceImpl.java create mode 100644 sca-java-2.x/branches/2.0-Beta1/samples/getting-started/callback-api/src/main/resources/CallBackApi.composite create mode 100644 sca-java-2.x/branches/2.0-Beta1/samples/getting-started/callback-api/src/main/resources/META-INF/sca-contribution.xml create mode 100644 sca-java-2.x/branches/2.0-Beta1/samples/getting-started/files/helloworld.cmds create mode 100644 sca-java-2.x/branches/2.0-Beta1/samples/getting-started/files/helloworld.xml create mode 100644 sca-java-2.x/branches/2.0-Beta1/samples/getting-started/files/new-sca-contribution.xml create mode 100644 sca-java-2.x/branches/2.0-Beta1/samples/getting-started/files/scdl-include.xml create mode 100644 sca-java-2.x/branches/2.0-Beta1/samples/getting-started/files/wsClient.html create mode 100644 sca-java-2.x/branches/2.0-Beta1/samples/getting-started/helloworld-contribution/README create mode 100644 sca-java-2.x/branches/2.0-Beta1/samples/getting-started/helloworld-contribution/pom.xml create mode 100644 sca-java-2.x/branches/2.0-Beta1/samples/getting-started/helloworld-contribution/src/main/java/sample/Helloworld.java create mode 100644 sca-java-2.x/branches/2.0-Beta1/samples/getting-started/helloworld-contribution/src/main/java/sample/HelloworldImpl.java create mode 100644 sca-java-2.x/branches/2.0-Beta1/samples/getting-started/helloworld-contribution/src/main/resources/META-INF/sca-contribution.xml create mode 100644 sca-java-2.x/branches/2.0-Beta1/samples/getting-started/helloworld-contribution/src/main/resources/helloworld.composite create mode 100644 sca-java-2.x/branches/2.0-Beta1/samples/getting-started/helloworld-contribution/src/main/resources/helloworldws.composite create mode 100644 sca-java-2.x/branches/2.0-Beta1/samples/getting-started/helloworld-contribution/src/test/java/sample/HelloworldTestCase.java create mode 100644 sca-java-2.x/branches/2.0-Beta1/samples/getting-started/helloworld-webapp/README create mode 100644 sca-java-2.x/branches/2.0-Beta1/samples/getting-started/helloworld-webapp/pom.xml create mode 100644 sca-java-2.x/branches/2.0-Beta1/samples/getting-started/helloworld-webapp/src/main/webapp/WEB-INF/web.xml create mode 100644 sca-java-2.x/branches/2.0-Beta1/samples/getting-started/helloworld-webapp/src/test/java/itest/Helloworld.java create mode 100644 sca-java-2.x/branches/2.0-Beta1/samples/getting-started/helloworld-webapp/src/test/java/itest/HelloworldTestCaseFIXME.java create mode 100644 sca-java-2.x/branches/2.0-Beta1/samples/getting-started/helloworld-webapp/src/test/resources/test-web.xml create mode 100644 sca-java-2.x/branches/2.0-Beta1/samples/getting-started/pom.xml create mode 100644 sca-java-2.x/branches/2.0-Beta1/samples/getting-started/sca-scopes/pom.xml create mode 100644 sca-java-2.x/branches/2.0-Beta1/samples/getting-started/sca-scopes/src/main/java/sample/Client.java create mode 100644 sca-java-2.x/branches/2.0-Beta1/samples/getting-started/sca-scopes/src/main/java/sample/ClientImpl.java create mode 100644 sca-java-2.x/branches/2.0-Beta1/samples/getting-started/sca-scopes/src/main/java/sample/CompositeService.java create mode 100644 sca-java-2.x/branches/2.0-Beta1/samples/getting-started/sca-scopes/src/main/java/sample/CompositeServiceImpl.java create mode 100644 sca-java-2.x/branches/2.0-Beta1/samples/getting-started/sca-scopes/src/main/java/sample/Launcher.java create mode 100644 sca-java-2.x/branches/2.0-Beta1/samples/getting-started/sca-scopes/src/main/java/sample/StatelessService.java create mode 100644 sca-java-2.x/branches/2.0-Beta1/samples/getting-started/sca-scopes/src/main/java/sample/StatelessServiceImpl.java create mode 100644 sca-java-2.x/branches/2.0-Beta1/samples/getting-started/sca-scopes/src/main/resources/scopes.composite create mode 100644 sca-java-2.x/branches/2.0-Beta1/samples/getting-started/scdl-include-contribution/README create mode 100644 sca-java-2.x/branches/2.0-Beta1/samples/getting-started/scdl-include-contribution/pom.xml create mode 100644 sca-java-2.x/branches/2.0-Beta1/samples/getting-started/scdl-include-contribution/src/main/resources/META-INF/sca-contribution.xml create mode 100644 sca-java-2.x/branches/2.0-Beta1/samples/getting-started/scdl-include-contribution/src/main/resources/scdl-include.composite (limited to 'sca-java-2.x/branches/2.0-Beta1/samples/getting-started') diff --git a/sca-java-2.x/branches/2.0-Beta1/samples/getting-started/callback-api/pom.xml b/sca-java-2.x/branches/2.0-Beta1/samples/getting-started/callback-api/pom.xml new file mode 100644 index 0000000000..b2139bf1ca --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta1/samples/getting-started/callback-api/pom.xml @@ -0,0 +1,51 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-samples + 2.0-Beta1-SNAPSHOT + ../pom.xml + + sample-callback-api-contribution + Apache Tuscany SCA Sample Callback API Contribution + + + + org.apache.tuscany.sca + tuscany-node-api + 2.0-Beta1-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-Beta1-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-Beta1-SNAPSHOT + + + + diff --git a/sca-java-2.x/branches/2.0-Beta1/samples/getting-started/callback-api/src/main/java/sample/CallBack.java b/sca-java-2.x/branches/2.0-Beta1/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/branches/2.0-Beta1/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/branches/2.0-Beta1/samples/getting-started/callback-api/src/main/java/sample/Client.java b/sca-java-2.x/branches/2.0-Beta1/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/branches/2.0-Beta1/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/branches/2.0-Beta1/samples/getting-started/callback-api/src/main/java/sample/ClientImpl.java b/sca-java-2.x/branches/2.0-Beta1/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/branches/2.0-Beta1/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/branches/2.0-Beta1/samples/getting-started/callback-api/src/main/java/sample/Launcher.java b/sca-java-2.x/branches/2.0-Beta1/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/branches/2.0-Beta1/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/branches/2.0-Beta1/samples/getting-started/callback-api/src/main/java/sample/Service.java b/sca-java-2.x/branches/2.0-Beta1/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/branches/2.0-Beta1/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/branches/2.0-Beta1/samples/getting-started/callback-api/src/main/java/sample/ServiceImpl.java b/sca-java-2.x/branches/2.0-Beta1/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/branches/2.0-Beta1/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 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/branches/2.0-Beta1/samples/getting-started/callback-api/src/main/resources/CallBackApi.composite b/sca-java-2.x/branches/2.0-Beta1/samples/getting-started/callback-api/src/main/resources/CallBackApi.composite new file mode 100644 index 0000000000..ca3a6e5f9d --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta1/samples/getting-started/callback-api/src/main/resources/CallBackApi.composite @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + diff --git a/sca-java-2.x/branches/2.0-Beta1/samples/getting-started/callback-api/src/main/resources/META-INF/sca-contribution.xml b/sca-java-2.x/branches/2.0-Beta1/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/branches/2.0-Beta1/samples/getting-started/callback-api/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,23 @@ + + + + + \ No newline at end of file diff --git a/sca-java-2.x/branches/2.0-Beta1/samples/getting-started/files/helloworld.cmds b/sca-java-2.x/branches/2.0-Beta1/samples/getting-started/files/helloworld.cmds new file mode 100644 index 0000000000..e94a0e42a6 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta1/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/branches/2.0-Beta1/samples/getting-started/files/helloworld.xml b/sca-java-2.x/branches/2.0-Beta1/samples/getting-started/files/helloworld.xml new file mode 100644 index 0000000000..e01074870c --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta1/samples/getting-started/files/helloworld.xml @@ -0,0 +1,27 @@ + + + + + + + \ No newline at end of file diff --git a/sca-java-2.x/branches/2.0-Beta1/samples/getting-started/files/new-sca-contribution.xml b/sca-java-2.x/branches/2.0-Beta1/samples/getting-started/files/new-sca-contribution.xml new file mode 100644 index 0000000000..62e8fef55d --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta1/samples/getting-started/files/new-sca-contribution.xml @@ -0,0 +1,27 @@ + + + + + + + + + diff --git a/sca-java-2.x/branches/2.0-Beta1/samples/getting-started/files/scdl-include.xml b/sca-java-2.x/branches/2.0-Beta1/samples/getting-started/files/scdl-include.xml new file mode 100644 index 0000000000..b15b20befd --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta1/samples/getting-started/files/scdl-include.xml @@ -0,0 +1,28 @@ + + + + + + + + \ No newline at end of file diff --git a/sca-java-2.x/branches/2.0-Beta1/samples/getting-started/files/wsClient.html b/sca-java-2.x/branches/2.0-Beta1/samples/getting-started/files/wsClient.html new file mode 100644 index 0000000000..402f30cdf8 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta1/samples/getting-started/files/wsClient.html @@ -0,0 +1,143 @@ + + + + + + +Tuscany Web service Sample Client + + + + + +

Tuscany Web service Sample Client

+ +

Tuscany Web service Sample Client

+ +

Sends a request to a Web Service endpoint. (This requires JavaScript)

+

Target: .

+ + + + + + + + + +
+ + + +
+ +
+ + diff --git a/sca-java-2.x/branches/2.0-Beta1/samples/getting-started/helloworld-contribution/README b/sca-java-2.x/branches/2.0-Beta1/samples/getting-started/helloworld-contribution/README new file mode 100644 index 0000000000..ed0f1d0ce4 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta1/samples/getting-started/helloworld-contribution/README @@ -0,0 +1,7 @@ +The README in the /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/branches/2.0-Beta1/samples/getting-started/helloworld-contribution/pom.xml b/sca-java-2.x/branches/2.0-Beta1/samples/getting-started/helloworld-contribution/pom.xml new file mode 100644 index 0000000000..6b2f595d3d --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta1/samples/getting-started/helloworld-contribution/pom.xml @@ -0,0 +1,58 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-samples + 2.0-Beta1-SNAPSHOT + ../pom.xml + + + jar + sample-helloworld-contribution + Apache Tuscany SCA Samples - Getting Started - helloworld-contribution + + + + org.apache.tuscany.sca + tuscany-sca-api + 2.0-Beta1-SNAPSHOT + provided + + + junit + junit + 4.8.1 + test + + + + + ${artifactId} + + + org.apache.tuscany.maven.plugins + maven-tuscany-plugin + 2.0-Beta1-SNAPSHOT + + + + diff --git a/sca-java-2.x/branches/2.0-Beta1/samples/getting-started/helloworld-contribution/src/main/java/sample/Helloworld.java b/sca-java-2.x/branches/2.0-Beta1/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/branches/2.0-Beta1/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/branches/2.0-Beta1/samples/getting-started/helloworld-contribution/src/main/java/sample/HelloworldImpl.java b/sca-java-2.x/branches/2.0-Beta1/samples/getting-started/helloworld-contribution/src/main/java/sample/HelloworldImpl.java new file mode 100644 index 0000000000..aa563cbdf3 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta1/samples/getting-started/helloworld-contribution/src/main/java/sample/HelloworldImpl.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.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) { + System.out.println("HelloworldImpl.sayHello " + name); + return "Hello " + name; + } + + @Init + public void init() { + System.out.println(sayHello("world")); + } +} diff --git a/sca-java-2.x/branches/2.0-Beta1/samples/getting-started/helloworld-contribution/src/main/resources/META-INF/sca-contribution.xml b/sca-java-2.x/branches/2.0-Beta1/samples/getting-started/helloworld-contribution/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..589b9d25c7 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta1/samples/getting-started/helloworld-contribution/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,25 @@ + + + + + + + diff --git a/sca-java-2.x/branches/2.0-Beta1/samples/getting-started/helloworld-contribution/src/main/resources/helloworld.composite b/sca-java-2.x/branches/2.0-Beta1/samples/getting-started/helloworld-contribution/src/main/resources/helloworld.composite new file mode 100644 index 0000000000..324395c246 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta1/samples/getting-started/helloworld-contribution/src/main/resources/helloworld.composite @@ -0,0 +1,29 @@ + + + + + + + + + diff --git a/sca-java-2.x/branches/2.0-Beta1/samples/getting-started/helloworld-contribution/src/main/resources/helloworldws.composite b/sca-java-2.x/branches/2.0-Beta1/samples/getting-started/helloworld-contribution/src/main/resources/helloworldws.composite new file mode 100644 index 0000000000..52436d8b0a --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta1/samples/getting-started/helloworld-contribution/src/main/resources/helloworldws.composite @@ -0,0 +1,32 @@ + + + + + + + + + + + + diff --git a/sca-java-2.x/branches/2.0-Beta1/samples/getting-started/helloworld-contribution/src/test/java/sample/HelloworldTestCase.java b/sca-java-2.x/branches/2.0-Beta1/samples/getting-started/helloworld-contribution/src/test/java/sample/HelloworldTestCase.java new file mode 100644 index 0000000000..7e679ec0e9 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta1/samples/getting-started/helloworld-contribution/src/test/java/sample/HelloworldTestCase.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 static org.junit.Assert.assertEquals; + +import org.junit.Test; + +public class HelloworldTestCase { + + @Test + public void testSayHello() { + HelloworldImpl helloworld = new HelloworldImpl(); + assertEquals("Hello Petra", helloworld.sayHello("Petra")); + } + +} diff --git a/sca-java-2.x/branches/2.0-Beta1/samples/getting-started/helloworld-webapp/README b/sca-java-2.x/branches/2.0-Beta1/samples/getting-started/helloworld-webapp/README new file mode 100644 index 0000000000..828aadb0f1 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta1/samples/getting-started/helloworld-webapp/README @@ -0,0 +1,7 @@ +The README in the /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/branches/2.0-Beta1/samples/getting-started/helloworld-webapp/pom.xml b/sca-java-2.x/branches/2.0-Beta1/samples/getting-started/helloworld-webapp/pom.xml new file mode 100644 index 0000000000..080ab1decd --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta1/samples/getting-started/helloworld-webapp/pom.xml @@ -0,0 +1,118 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-samples + 2.0-Beta1-SNAPSHOT + ../../pom.xml + + + sample-helloworld-webapp + Apache Tuscany SCA Sample Helloworld + war + + + + + org.apache.tuscany.sca + tuscany-base-runtime + 2.0-Beta1-SNAPSHOT + + + + junit + junit + 4.8.1 + test + + + + + + helloworld + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy + compile + + copy + + + + + org.apache.tuscany.sca + helloworld-contribution + ${pom.version} + + src/main/webapp/WEB-INF/sca-contributions + + + + + + + + + org.mortbay.jetty + maven-jetty-plugin + 6.1.18 + + helloworld + foo + 9999 + + + + start-jetty + process-test-classes + + run + + + src/test/resources/test-web.xml + 0 + true + + + 8085 + + + + + + stop-jetty + prepare-package + + stop + + + + + + + + diff --git a/sca-java-2.x/branches/2.0-Beta1/samples/getting-started/helloworld-webapp/src/main/webapp/WEB-INF/web.xml b/sca-java-2.x/branches/2.0-Beta1/samples/getting-started/helloworld-webapp/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..755162e305 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta1/samples/getting-started/helloworld-webapp/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,49 @@ + + + + + Apache Tuscany Helloworld Sample + + + contributions + /WEB-INF/sca-contributions + + + + + + tuscany + org.apache.tuscany.sca.host.webapp.TuscanyServletFilter + + + + tuscany + /* + + + diff --git a/sca-java-2.x/branches/2.0-Beta1/samples/getting-started/helloworld-webapp/src/test/java/itest/Helloworld.java b/sca-java-2.x/branches/2.0-Beta1/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/branches/2.0-Beta1/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/branches/2.0-Beta1/samples/getting-started/helloworld-webapp/src/test/java/itest/HelloworldTestCaseFIXME.java b/sca-java-2.x/branches/2.0-Beta1/samples/getting-started/helloworld-webapp/src/test/java/itest/HelloworldTestCaseFIXME.java new file mode 100644 index 0000000000..c1c2c6aae0 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta1/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/branches/2.0-Beta1/samples/getting-started/helloworld-webapp/src/test/resources/test-web.xml b/sca-java-2.x/branches/2.0-Beta1/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/branches/2.0-Beta1/samples/getting-started/helloworld-webapp/src/test/resources/test-web.xml @@ -0,0 +1,30 @@ + + + + + + org.apache.tuscany.sca.config + uri:default?bind=127.0.0.1:54321 + + + diff --git a/sca-java-2.x/branches/2.0-Beta1/samples/getting-started/pom.xml b/sca-java-2.x/branches/2.0-Beta1/samples/getting-started/pom.xml new file mode 100644 index 0000000000..c9b74d050e --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta1/samples/getting-started/pom.xml @@ -0,0 +1,48 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-samples + 2.0-Beta1-SNAPSHOT + ../pom.xml + + tuscany-samples-getting-started-contributions + org.apache.tuscany.sca + pom + Apache Tuscany SCA Getting Started Sample Contributions + + + + default + + true + + + helloworld-contribution + scdl-include-contribution + callback-api + sca-scopes + helloworld-webapp + + + + diff --git a/sca-java-2.x/branches/2.0-Beta1/samples/getting-started/sca-scopes/pom.xml b/sca-java-2.x/branches/2.0-Beta1/samples/getting-started/sca-scopes/pom.xml new file mode 100644 index 0000000000..f2555c2673 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta1/samples/getting-started/sca-scopes/pom.xml @@ -0,0 +1,51 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-samples + 2.0-Beta1-SNAPSHOT + ../pom.xml + + Apache Tuscany SCA Sample SCA Scopes Contribution + sample-sca-scopes-contribution + + + + org.apache.tuscany.sca + tuscany-node-api + 2.0-Beta1-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-Beta1-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-Beta1-SNAPSHOT + + + + diff --git a/sca-java-2.x/branches/2.0-Beta1/samples/getting-started/sca-scopes/src/main/java/sample/Client.java b/sca-java-2.x/branches/2.0-Beta1/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/branches/2.0-Beta1/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/branches/2.0-Beta1/samples/getting-started/sca-scopes/src/main/java/sample/ClientImpl.java b/sca-java-2.x/branches/2.0-Beta1/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/branches/2.0-Beta1/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/branches/2.0-Beta1/samples/getting-started/sca-scopes/src/main/java/sample/CompositeService.java b/sca-java-2.x/branches/2.0-Beta1/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/branches/2.0-Beta1/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/branches/2.0-Beta1/samples/getting-started/sca-scopes/src/main/java/sample/CompositeServiceImpl.java b/sca-java-2.x/branches/2.0-Beta1/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/branches/2.0-Beta1/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/branches/2.0-Beta1/samples/getting-started/sca-scopes/src/main/java/sample/Launcher.java b/sca-java-2.x/branches/2.0-Beta1/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/branches/2.0-Beta1/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/branches/2.0-Beta1/samples/getting-started/sca-scopes/src/main/java/sample/StatelessService.java b/sca-java-2.x/branches/2.0-Beta1/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/branches/2.0-Beta1/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/branches/2.0-Beta1/samples/getting-started/sca-scopes/src/main/java/sample/StatelessServiceImpl.java b/sca-java-2.x/branches/2.0-Beta1/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/branches/2.0-Beta1/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/branches/2.0-Beta1/samples/getting-started/sca-scopes/src/main/resources/scopes.composite b/sca-java-2.x/branches/2.0-Beta1/samples/getting-started/sca-scopes/src/main/resources/scopes.composite new file mode 100644 index 0000000000..14937a1f34 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta1/samples/getting-started/sca-scopes/src/main/resources/scopes.composite @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-2.x/branches/2.0-Beta1/samples/getting-started/scdl-include-contribution/README b/sca-java-2.x/branches/2.0-Beta1/samples/getting-started/scdl-include-contribution/README new file mode 100644 index 0000000000..ed0f1d0ce4 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta1/samples/getting-started/scdl-include-contribution/README @@ -0,0 +1,7 @@ +The README in the /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/branches/2.0-Beta1/samples/getting-started/scdl-include-contribution/pom.xml b/sca-java-2.x/branches/2.0-Beta1/samples/getting-started/scdl-include-contribution/pom.xml new file mode 100644 index 0000000000..4dc78b86e8 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta1/samples/getting-started/scdl-include-contribution/pom.xml @@ -0,0 +1,76 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-samples + 2.0-Beta1-SNAPSHOT + ../pom.xml + + + zip + sample-scdl-include-contribution + Apache Tuscany SCA Sample include Composite Contribution + + + + org.apache.tuscany.sca + tuscany-sca-api + 2.0-Beta1-SNAPSHOT + provided + + + junit + junit + 4.8.1 + test + + + + + ${artifactId} + + + + + + org.apache.tuscany.maven.plugins + maven-zip-plugin + alpha2 + true + + + + + org.apache.tuscany.maven.plugins + maven-tuscany-plugin + 2.0-Beta1-SNAPSHOT + + + + ..\helloworld-contribution\target\helloworld-contribution.jar + + + + + + + diff --git a/sca-java-2.x/branches/2.0-Beta1/samples/getting-started/scdl-include-contribution/src/main/resources/META-INF/sca-contribution.xml b/sca-java-2.x/branches/2.0-Beta1/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/branches/2.0-Beta1/samples/getting-started/scdl-include-contribution/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,26 @@ + + + + + + + + diff --git a/sca-java-2.x/branches/2.0-Beta1/samples/getting-started/scdl-include-contribution/src/main/resources/scdl-include.composite b/sca-java-2.x/branches/2.0-Beta1/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/branches/2.0-Beta1/samples/getting-started/scdl-include-contribution/src/main/resources/scdl-include.composite @@ -0,0 +1,30 @@ + + + + + + + + + -- cgit v1.2.3