summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/itest/nodes/binding-sca-hazelcast/src/main
diff options
context:
space:
mode:
authorantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2010-03-09 22:11:06 +0000
committerantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2010-03-09 22:11:06 +0000
commitac7c6f292a8db012b4b43ab92a17a0f18abd52aa (patch)
tree13257ac0faa6214e051867c11750a585fe827b84 /sca-java-2.x/trunk/itest/nodes/binding-sca-hazelcast/src/main
parentac60cac78259127fdeae8ebafd37878281f76b54 (diff)
Add a copy of the binding-sca test using Hazelcast
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@921161 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/itest/nodes/binding-sca-hazelcast/src/main')
-rw-r--r--sca-java-2.x/trunk/itest/nodes/binding-sca-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/Client.java29
-rw-r--r--sca-java-2.x/trunk/itest/nodes/binding-sca-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/ClientImpl.java48
-rw-r--r--sca-java-2.x/trunk/itest/nodes/binding-sca-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/Customer.java70
-rw-r--r--sca-java-2.x/trunk/itest/nodes/binding-sca-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/Local.java27
-rw-r--r--sca-java-2.x/trunk/itest/nodes/binding-sca-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/LocalServiceImpl.java38
-rw-r--r--sca-java-2.x/trunk/itest/nodes/binding-sca-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/Remote.java36
-rw-r--r--sca-java-2.x/trunk/itest/nodes/binding-sca-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/RemoteServiceImpl.java61
-rw-r--r--sca-java-2.x/trunk/itest/nodes/binding-sca-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/SCAClientImpl.java52
-rw-r--r--sca-java-2.x/trunk/itest/nodes/binding-sca-hazelcast/src/main/resources/org/apache/tuscany/sca/itest/bindingsca/Client.composite30
-rw-r--r--sca-java-2.x/trunk/itest/nodes/binding-sca-hazelcast/src/main/resources/org/apache/tuscany/sca/itest/bindingsca/Service.composite31
10 files changed, 422 insertions, 0 deletions
diff --git a/sca-java-2.x/trunk/itest/nodes/binding-sca-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/Client.java b/sca-java-2.x/trunk/itest/nodes/binding-sca-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/Client.java
new file mode 100644
index 0000000000..ef2565b750
--- /dev/null
+++ b/sca-java-2.x/trunk/itest/nodes/binding-sca-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/Client.java
@@ -0,0 +1,29 @@
+/*
+ * 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 org.apache.tuscany.sca.itest.bindingsca;
+
+/**
+ *
+ */
+public interface Client {
+ String getName(String id);
+
+ String create(String name);
+}
diff --git a/sca-java-2.x/trunk/itest/nodes/binding-sca-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/ClientImpl.java b/sca-java-2.x/trunk/itest/nodes/binding-sca-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/ClientImpl.java
new file mode 100644
index 0000000000..30ae3cc0fb
--- /dev/null
+++ b/sca-java-2.x/trunk/itest/nodes/binding-sca-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/ClientImpl.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 org.apache.tuscany.sca.itest.bindingsca;
+
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ *
+ */
+@Service(Client.class)
+public class ClientImpl implements Client {
+ @Reference
+ protected Local local;
+
+ @Reference
+ protected Remote remote;
+
+ public String getName(String id) {
+ Customer customer = remote.getCustomer(id);
+ customer.dump("Client.getName()");
+ return local.getName(customer);
+ }
+
+ public String create(String name) {
+ String id = remote.generateId();
+ Customer customer = remote.createCustomer(id, name);
+ customer.dump("Client.create()");
+ return remote.getId(customer);
+ }
+}
diff --git a/sca-java-2.x/trunk/itest/nodes/binding-sca-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/Customer.java b/sca-java-2.x/trunk/itest/nodes/binding-sca-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/Customer.java
new file mode 100644
index 0000000000..f2b7b1e41d
--- /dev/null
+++ b/sca-java-2.x/trunk/itest/nodes/binding-sca-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/Customer.java
@@ -0,0 +1,70 @@
+/*
+ * 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 org.apache.tuscany.sca.itest.bindingsca;
+
+/**
+ *
+ */
+public class Customer {
+ private String id;
+ private String name;
+
+ public Customer() {
+ }
+
+ /**
+ * @param id
+ * @param name
+ */
+ public Customer(String id, String name) {
+ super();
+ this.id = id;
+ this.name = name;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String toString() {
+ return "Customer [id=" + id + ", name=" + name + "]";
+ }
+
+ public void dump(String prefix) {
+ System.out.print(prefix);
+ System.out.print(": ");
+ System.out.print(toString());
+ System.out.println(" @" + System.identityHashCode(this));
+ System.out.println(getClass().getClassLoader());
+ }
+}
diff --git a/sca-java-2.x/trunk/itest/nodes/binding-sca-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/Local.java b/sca-java-2.x/trunk/itest/nodes/binding-sca-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/Local.java
new file mode 100644
index 0000000000..0fe30c9d53
--- /dev/null
+++ b/sca-java-2.x/trunk/itest/nodes/binding-sca-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/Local.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 org.apache.tuscany.sca.itest.bindingsca;
+
+/**
+ *
+ */
+public interface Local {
+ String getName(Customer customer);
+}
diff --git a/sca-java-2.x/trunk/itest/nodes/binding-sca-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/LocalServiceImpl.java b/sca-java-2.x/trunk/itest/nodes/binding-sca-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/LocalServiceImpl.java
new file mode 100644
index 0000000000..8783808334
--- /dev/null
+++ b/sca-java-2.x/trunk/itest/nodes/binding-sca-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/LocalServiceImpl.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 org.apache.tuscany.sca.itest.bindingsca;
+
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ *
+ */
+@Service(Local.class)
+public class LocalServiceImpl implements Local {
+
+ public String getName(Customer customer) {
+ if (customer == null) {
+ return null;
+ }
+ customer.dump("Local.getName()");
+ return customer.getName();
+ }
+
+}
diff --git a/sca-java-2.x/trunk/itest/nodes/binding-sca-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/Remote.java b/sca-java-2.x/trunk/itest/nodes/binding-sca-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/Remote.java
new file mode 100644
index 0000000000..eaa2298c49
--- /dev/null
+++ b/sca-java-2.x/trunk/itest/nodes/binding-sca-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/Remote.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 org.apache.tuscany.sca.itest.bindingsca;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ *
+ */
+@Remotable
+public interface Remote {
+ String generateId();
+
+ String getId(Customer customer);
+
+ Customer getCustomer(String id);
+
+ Customer createCustomer(String id, String name);
+}
diff --git a/sca-java-2.x/trunk/itest/nodes/binding-sca-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/RemoteServiceImpl.java b/sca-java-2.x/trunk/itest/nodes/binding-sca-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/RemoteServiceImpl.java
new file mode 100644
index 0000000000..baf32ad959
--- /dev/null
+++ b/sca-java-2.x/trunk/itest/nodes/binding-sca-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/RemoteServiceImpl.java
@@ -0,0 +1,61 @@
+/*
+ * 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 org.apache.tuscany.sca.itest.bindingsca;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+import org.oasisopen.sca.annotation.AllowsPassByReference;
+import org.oasisopen.sca.annotation.Scope;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ *
+ */
+@Service(Remote.class)
+@Scope("COMPOSITE")
+public class RemoteServiceImpl implements Remote {
+ private Map<String, Customer> customers = new HashMap<String, Customer>();
+
+ public String generateId() {
+ return UUID.randomUUID().toString();
+ }
+
+ @AllowsPassByReference
+ public String getId(Customer customer) {
+ customer.dump("Remote.getId()");
+ return customer.getId();
+ }
+
+ public Customer getCustomer(String id) {
+ Customer customer = customers.get(id);
+ customer.dump("Remote.getCustomer()");
+ return customer;
+ }
+
+ public Customer createCustomer(String id, String name) {
+ Customer customer = new Customer(id, name);
+ customer.dump("Remote.createCustomer()");
+ customers.put(id, customer);
+ return customer;
+ }
+
+}
diff --git a/sca-java-2.x/trunk/itest/nodes/binding-sca-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/SCAClientImpl.java b/sca-java-2.x/trunk/itest/nodes/binding-sca-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/SCAClientImpl.java
new file mode 100644
index 0000000000..eb7fbf06e0
--- /dev/null
+++ b/sca-java-2.x/trunk/itest/nodes/binding-sca-hazelcast/src/main/java/org/apache/tuscany/sca/itest/bindingsca/SCAClientImpl.java
@@ -0,0 +1,52 @@
+/*
+ * 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 org.apache.tuscany.sca.itest.bindingsca;
+
+import java.net.URI;
+
+import org.oasisopen.sca.client.SCAClientFactory;
+
+/**
+ *
+ */
+public class SCAClientImpl implements Client {
+ private Local local;
+ private Remote remote;
+
+ public SCAClientImpl(String domainURI) throws Exception {
+ SCAClientFactory factory = SCAClientFactory.newInstance(URI.create(domainURI));
+ local = factory.getService(Local.class, "LocalComponent/Local");
+ remote = factory.getService(Remote.class, "RemoteComponent/Remote");
+ }
+
+ public String getName(String id) {
+ Customer customer = remote.getCustomer(id);
+ customer.dump("Client.getName()");
+ return local.getName(customer);
+ }
+
+ public String create(String name) {
+ String id = remote.generateId();
+ Customer customer = remote.createCustomer(id, name);
+ customer.dump("Client.create()");
+ return remote.getId(customer);
+ }
+
+}
diff --git a/sca-java-2.x/trunk/itest/nodes/binding-sca-hazelcast/src/main/resources/org/apache/tuscany/sca/itest/bindingsca/Client.composite b/sca-java-2.x/trunk/itest/nodes/binding-sca-hazelcast/src/main/resources/org/apache/tuscany/sca/itest/bindingsca/Client.composite
new file mode 100644
index 0000000000..b04cc33023
--- /dev/null
+++ b/sca-java-2.x/trunk/itest/nodes/binding-sca-hazelcast/src/main/resources/org/apache/tuscany/sca/itest/bindingsca/Client.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
+ * 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://client"
+ name="Client">
+
+ <component name="ClientComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.bindingsca.ClientImpl" />
+ <reference name="local" target="LocalComponent" />
+ <reference name="remote" target="RemoteComponent" />
+ </component>
+
+
+</composite> \ No newline at end of file
diff --git a/sca-java-2.x/trunk/itest/nodes/binding-sca-hazelcast/src/main/resources/org/apache/tuscany/sca/itest/bindingsca/Service.composite b/sca-java-2.x/trunk/itest/nodes/binding-sca-hazelcast/src/main/resources/org/apache/tuscany/sca/itest/bindingsca/Service.composite
new file mode 100644
index 0000000000..fe282d291c
--- /dev/null
+++ b/sca-java-2.x/trunk/itest/nodes/binding-sca-hazelcast/src/main/resources/org/apache/tuscany/sca/itest/bindingsca/Service.composite
@@ -0,0 +1,31 @@
+<?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
+ * 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://service"
+ name="Service">
+
+ <component name="LocalComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.bindingsca.LocalServiceImpl" />
+ </component>
+
+ <component name="RemoteComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.bindingsca.RemoteServiceImpl" />
+ </component>
+
+</composite> \ No newline at end of file