summaryrefslogtreecommitdiffstats
path: root/branches/sca-java-1.5.2/samples/callbacks-jms/src/main/java
diff options
context:
space:
mode:
authorslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2009-10-06 14:24:43 +0000
committerslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2009-10-06 14:24:43 +0000
commit5d83de3646c6f1b07d2221f5586088deeca27d0a (patch)
tree605dce7357563e281288788013b24b9205ea3277 /branches/sca-java-1.5.2/samples/callbacks-jms/src/main/java
parentd6c22ffc58fc7728500511fc761db5bbb488faf8 (diff)
Branch for 1.5.2
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@822292 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'branches/sca-java-1.5.2/samples/callbacks-jms/src/main/java')
-rw-r--r--branches/sca-java-1.5.2/samples/callbacks-jms/src/main/java/callbacks/CallbackJMSClient.java44
-rw-r--r--branches/sca-java-1.5.2/samples/callbacks-jms/src/main/java/callbacks/OrderCallback.java30
-rw-r--r--branches/sca-java-1.5.2/samples/callbacks-jms/src/main/java/callbacks/OrderRequest.java24
-rw-r--r--branches/sca-java-1.5.2/samples/callbacks-jms/src/main/java/callbacks/OrderResponse.java24
-rw-r--r--branches/sca-java-1.5.2/samples/callbacks-jms/src/main/java/callbacks/OrderService.java33
-rw-r--r--branches/sca-java-1.5.2/samples/callbacks-jms/src/main/java/callbacks/OrderServiceClient.java59
-rw-r--r--branches/sca-java-1.5.2/samples/callbacks-jms/src/main/java/callbacks/OrderServiceImpl.java51
7 files changed, 265 insertions, 0 deletions
diff --git a/branches/sca-java-1.5.2/samples/callbacks-jms/src/main/java/callbacks/CallbackJMSClient.java b/branches/sca-java-1.5.2/samples/callbacks-jms/src/main/java/callbacks/CallbackJMSClient.java
new file mode 100644
index 0000000000..c2e62ab8bd
--- /dev/null
+++ b/branches/sca-java-1.5.2/samples/callbacks-jms/src/main/java/callbacks/CallbackJMSClient.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 callbacks;
+
+import org.apache.tuscany.sca.node.SCAClient;
+import org.apache.tuscany.sca.node.SCANode;
+import org.apache.tuscany.sca.node.SCANodeFactory;
+
+public class CallbackJMSClient {
+
+ public static void main(String[] args) throws Exception {
+
+ SCANodeFactory factory = SCANodeFactory.newInstance();
+ SCANode node = factory.createSCANodeFromClassLoader("callbacks.composite", CallbackJMSClient.class.getClassLoader());
+ node.start();
+
+ OrderServiceClient orderServiceClient = ((SCAClient)node).getService(OrderServiceClient.class, "ClientComponent");
+
+ // do something
+ orderServiceClient.doSomeOrdering();
+
+ // wait to give the service time to respond
+ Thread.sleep(500);
+
+ node.stop();
+ }
+
+}
diff --git a/branches/sca-java-1.5.2/samples/callbacks-jms/src/main/java/callbacks/OrderCallback.java b/branches/sca-java-1.5.2/samples/callbacks-jms/src/main/java/callbacks/OrderCallback.java
new file mode 100644
index 0000000000..775663cdff
--- /dev/null
+++ b/branches/sca-java-1.5.2/samples/callbacks-jms/src/main/java/callbacks/OrderCallback.java
@@ -0,0 +1,30 @@
+/*
+ * 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 callbacks;
+
+import org.osoa.sca.annotations.OneWay;
+import org.osoa.sca.annotations.Remotable;
+
+@Remotable
+public interface OrderCallback {
+
+ @OneWay
+ public void placeOrderResponse(OrderResponse orderResponse);
+}
diff --git a/branches/sca-java-1.5.2/samples/callbacks-jms/src/main/java/callbacks/OrderRequest.java b/branches/sca-java-1.5.2/samples/callbacks-jms/src/main/java/callbacks/OrderRequest.java
new file mode 100644
index 0000000000..69f5751379
--- /dev/null
+++ b/branches/sca-java-1.5.2/samples/callbacks-jms/src/main/java/callbacks/OrderRequest.java
@@ -0,0 +1,24 @@
+/*
+ * 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 callbacks;
+
+public class OrderRequest {
+
+}
diff --git a/branches/sca-java-1.5.2/samples/callbacks-jms/src/main/java/callbacks/OrderResponse.java b/branches/sca-java-1.5.2/samples/callbacks-jms/src/main/java/callbacks/OrderResponse.java
new file mode 100644
index 0000000000..882bcf8479
--- /dev/null
+++ b/branches/sca-java-1.5.2/samples/callbacks-jms/src/main/java/callbacks/OrderResponse.java
@@ -0,0 +1,24 @@
+/*
+ * 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 callbacks;
+
+public class OrderResponse {
+
+}
diff --git a/branches/sca-java-1.5.2/samples/callbacks-jms/src/main/java/callbacks/OrderService.java b/branches/sca-java-1.5.2/samples/callbacks-jms/src/main/java/callbacks/OrderService.java
new file mode 100644
index 0000000000..9f6d90577c
--- /dev/null
+++ b/branches/sca-java-1.5.2/samples/callbacks-jms/src/main/java/callbacks/OrderService.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 callbacks;
+
+import org.osoa.sca.annotations.Callback;
+import org.osoa.sca.annotations.OneWay;
+import org.osoa.sca.annotations.Remotable;
+
+@Remotable
+@Callback(OrderCallback.class)
+public interface OrderService {
+
+ @OneWay
+ public void placeOrder(OrderRequest orderRequest);
+
+}
diff --git a/branches/sca-java-1.5.2/samples/callbacks-jms/src/main/java/callbacks/OrderServiceClient.java b/branches/sca-java-1.5.2/samples/callbacks-jms/src/main/java/callbacks/OrderServiceClient.java
new file mode 100644
index 0000000000..3393ae5dca
--- /dev/null
+++ b/branches/sca-java-1.5.2/samples/callbacks-jms/src/main/java/callbacks/OrderServiceClient.java
@@ -0,0 +1,59 @@
+/*
+ * 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 callbacks;
+
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Service;
+
+@Service(OrderServiceClient.class)
+public class OrderServiceClient implements OrderCallback {
+
+ // A field to hold the reference to the order service
+
+ private OrderService orderService;
+ public static OrderResponse oResponse;
+
+ public void doSomeOrdering() {
+
+ OrderRequest oRequest = new OrderRequest();
+
+ // … fill in the details of the order …
+
+ System.out.println("client placing order: " + oRequest);
+
+ orderService.placeOrder(oRequest);
+
+ // …the client code can continue to do processing
+ }
+
+ public void placeOrderResponse(OrderResponse oResponse) {
+
+ // …handle the response as needed
+
+ System.out.println("client callback received order response: " + oResponse);
+ OrderServiceClient.oResponse = oResponse;
+ }
+
+ // A setter method for the order service reference
+ @Reference
+ public void setOrderService(OrderService theService) {
+ orderService = theService;
+ }
+}
diff --git a/branches/sca-java-1.5.2/samples/callbacks-jms/src/main/java/callbacks/OrderServiceImpl.java b/branches/sca-java-1.5.2/samples/callbacks-jms/src/main/java/callbacks/OrderServiceImpl.java
new file mode 100644
index 0000000000..dd963bc1b0
--- /dev/null
+++ b/branches/sca-java-1.5.2/samples/callbacks-jms/src/main/java/callbacks/OrderServiceImpl.java
@@ -0,0 +1,51 @@
+/*
+ * 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 callbacks;
+
+import org.osoa.sca.annotations.Callback;
+import org.osoa.sca.annotations.Service;
+
+@Service(OrderService.class)
+public class OrderServiceImpl implements OrderService {
+
+ // A field for the callback reference object
+ private OrderCallback callbackReference;
+
+ // The place order operation itself
+ public void placeOrder(OrderRequest oRequest) {
+
+ // …do the work to process the order…
+ // …which may take some time…
+
+ System.out.println("service received order: " + oRequest);
+
+ // when ready to respond…
+
+ OrderResponse theResponse = new OrderResponse();
+
+ callbackReference.placeOrderResponse(theResponse);
+ }
+
+ // A setter method for the callback reference
+ @Callback
+ public void setCallbackReference(OrderCallback theCallback) {
+ callbackReference = theCallback;
+ }
+}