diff options
Diffstat (limited to '')
6 files changed, 0 insertions, 361 deletions
diff --git a/sca-java-2.x/branches/2.0-Beta2/samples/getting-started/callback-api/src/main/java/sample/CallBack.java b/sca-java-2.x/branches/2.0-Beta2/samples/getting-started/callback-api/src/main/java/sample/CallBack.java deleted file mode 100644 index 16e4297e9d..0000000000 --- a/sca-java-2.x/branches/2.0-Beta2/samples/getting-started/callback-api/src/main/java/sample/CallBack.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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-Beta2/samples/getting-started/callback-api/src/main/java/sample/Client.java b/sca-java-2.x/branches/2.0-Beta2/samples/getting-started/callback-api/src/main/java/sample/Client.java deleted file mode 100644 index 7e0709e660..0000000000 --- a/sca-java-2.x/branches/2.0-Beta2/samples/getting-started/callback-api/src/main/java/sample/Client.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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-Beta2/samples/getting-started/callback-api/src/main/java/sample/ClientImpl.java b/sca-java-2.x/branches/2.0-Beta2/samples/getting-started/callback-api/src/main/java/sample/ClientImpl.java deleted file mode 100644 index 01219aa608..0000000000 --- a/sca-java-2.x/branches/2.0-Beta2/samples/getting-started/callback-api/src/main/java/sample/ClientImpl.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * 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-Beta2/samples/getting-started/callback-api/src/main/java/sample/Launcher.java b/sca-java-2.x/branches/2.0-Beta2/samples/getting-started/callback-api/src/main/java/sample/Launcher.java deleted file mode 100644 index fa1a59d726..0000000000 --- a/sca-java-2.x/branches/2.0-Beta2/samples/getting-started/callback-api/src/main/java/sample/Launcher.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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-Beta2/samples/getting-started/callback-api/src/main/java/sample/Service.java b/sca-java-2.x/branches/2.0-Beta2/samples/getting-started/callback-api/src/main/java/sample/Service.java deleted file mode 100644 index 6723af2adf..0000000000 --- a/sca-java-2.x/branches/2.0-Beta2/samples/getting-started/callback-api/src/main/java/sample/Service.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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-Beta2/samples/getting-started/callback-api/src/main/java/sample/ServiceImpl.java b/sca-java-2.x/branches/2.0-Beta2/samples/getting-started/callback-api/src/main/java/sample/ServiceImpl.java deleted file mode 100644 index 4850f434ff..0000000000 --- a/sca-java-2.x/branches/2.0-Beta2/samples/getting-started/callback-api/src/main/java/sample/ServiceImpl.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * 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(); - } - -} |