summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/tags/2.0.1-RC1/modules/binding-rest-runtime/src/test/java/services
diff options
context:
space:
mode:
Diffstat (limited to 'sca-java-2.x/tags/2.0.1-RC1/modules/binding-rest-runtime/src/test/java/services')
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/binding-rest-runtime/src/test/java/services/binary/BinaryService.java45
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/binding-rest-runtime/src/test/java/services/binary/BinaryServiceImpl.java57
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/binding-rest-runtime/src/test/java/services/customer/Customer.java70
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/binding-rest-runtime/src/test/java/services/customer/CustomerService.java49
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/binding-rest-runtime/src/test/java/services/customer/CustomerServiceImpl.java65
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/binding-rest-runtime/src/test/java/services/echo/Echo.java41
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/binding-rest-runtime/src/test/java/services/echo/EchoImpl.java45
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/binding-rest-runtime/src/test/java/services/echo/jaxrs/Echo.java47
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/binding-rest-runtime/src/test/java/services/echo/jaxrs/EchoClientImpl.java43
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/binding-rest-runtime/src/test/java/services/echo/jaxrs/EchoImpl.java45
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/binding-rest-runtime/src/test/java/services/store/Catalog.java54
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/binding-rest-runtime/src/test/java/services/store/CurrencyConverter.java29
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/binding-rest-runtime/src/test/java/services/store/CurrencyConverterImpl.java38
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/binding-rest-runtime/src/test/java/services/store/FruitsCatalogImpl.java76
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/binding-rest-runtime/src/test/java/services/store/Item.java50
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/binding-rest-runtime/src/test/java/services/store/Items.java37
16 files changed, 791 insertions, 0 deletions
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/binding-rest-runtime/src/test/java/services/binary/BinaryService.java b/sca-java-2.x/tags/2.0.1-RC1/modules/binding-rest-runtime/src/test/java/services/binary/BinaryService.java
new file mode 100644
index 0000000000..4749383a0c
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/binding-rest-runtime/src/test/java/services/binary/BinaryService.java
@@ -0,0 +1,45 @@
+/*
+ * 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 services.binary;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.activation.DataSource;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ *
+ */
+@Remotable
+public interface BinaryService {
+ @GET
+ InputStream get();
+
+ @PUT
+ void update(InputStream is) throws IOException;
+
+ @POST
+ void create(DataSource dataSource) throws IOException;
+}
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/binding-rest-runtime/src/test/java/services/binary/BinaryServiceImpl.java b/sca-java-2.x/tags/2.0.1-RC1/modules/binding-rest-runtime/src/test/java/services/binary/BinaryServiceImpl.java
new file mode 100644
index 0000000000..aefbf64504
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/binding-rest-runtime/src/test/java/services/binary/BinaryServiceImpl.java
@@ -0,0 +1,57 @@
+/*
+ * 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 services.binary;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.activation.DataSource;
+
+import org.oasisopen.sca.annotation.Scope;
+
+/**
+ *
+ */
+@Scope("COMPOSITE")
+public class BinaryServiceImpl implements BinaryService {
+ private byte[] content;
+ private int length;
+
+ public void create(DataSource dataSource) throws IOException {
+ content = new byte[10240];
+ InputStream is = dataSource.getInputStream();
+ length = is.read(content);
+ System.out.println("Content received: " + length);
+ }
+
+ public InputStream get() {
+ byte[] bytes = new byte[length];
+ System.arraycopy(content, 0, bytes, 0, length);
+ System.out.println("Content sent: " + length);
+ return new ByteArrayInputStream(bytes);
+ }
+
+ public void update(InputStream is) throws IOException {
+ length = is.read(content);
+ System.out.println("Content updated: " + length);
+ }
+
+}
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/binding-rest-runtime/src/test/java/services/customer/Customer.java b/sca-java-2.x/tags/2.0.1-RC1/modules/binding-rest-runtime/src/test/java/services/customer/Customer.java
new file mode 100644
index 0000000000..08506ebd48
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/binding-rest-runtime/src/test/java/services/customer/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 services.customer;
+
+
+/**
+ * Customer data
+ */
+public class Customer {
+ private String id;
+ private String email;
+ private String name;
+
+ public Customer() {
+ super();
+ }
+
+ public Customer(String id, String name, String email) {
+ super();
+ this.id = id;
+ this.email = email;
+ this.name = name;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getEmail() {
+ return email;
+ }
+
+ public void setEmail(String email) {
+ this.email = email;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String toString() {
+ return "id: " + id + " name: " + name + " e-mail: " + email;
+ }
+
+}
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/binding-rest-runtime/src/test/java/services/customer/CustomerService.java b/sca-java-2.x/tags/2.0.1-RC1/modules/binding-rest-runtime/src/test/java/services/customer/CustomerService.java
new file mode 100644
index 0000000000..403804e95e
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/binding-rest-runtime/src/test/java/services/customer/CustomerService.java
@@ -0,0 +1,49 @@
+/*
+ * 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 services.customer;
+
+import javax.jws.WebResult;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.core.Response;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface CustomerService {
+
+ @GET
+ @WebResult(name = "Customer", targetNamespace = "")
+ @Path("{name}")
+ Customer get(@PathParam("name") String name);
+
+ @GET
+ @WebResult(name = "Customer", targetNamespace = "")
+ Response getResponse();
+
+ @POST
+ Response addCustomer(Customer customer);
+
+ @PUT
+ void updateCustomer(Customer customer);
+}
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/binding-rest-runtime/src/test/java/services/customer/CustomerServiceImpl.java b/sca-java-2.x/tags/2.0.1-RC1/modules/binding-rest-runtime/src/test/java/services/customer/CustomerServiceImpl.java
new file mode 100644
index 0000000000..d0f2809cd6
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/binding-rest-runtime/src/test/java/services/customer/CustomerServiceImpl.java
@@ -0,0 +1,65 @@
+/*
+ * 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 services.customer;
+
+import java.net.URI;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
+
+import org.oasisopen.sca.annotation.Init;
+import org.oasisopen.sca.annotation.Scope;
+
+@Scope("COMPOSITE")
+public class CustomerServiceImpl implements CustomerService {
+ private Map<String, Customer> customers = new HashMap<String, Customer>();
+
+ @Init
+ public void init() {
+ customers.put("John", new Customer("John", "John", "john@domain.com"));
+ }
+
+ public Customer get(String name) {
+ Customer c = customers.get(name);
+ if (c == null) {
+ // Not found
+ throw new WebApplicationException(Status.NOT_FOUND);
+ }
+ return c;
+ }
+
+ public Response getResponse() {
+ return Response.ok(get("John")).build();
+ }
+
+ public Response addCustomer(Customer customer) {
+ customers.put(customer.getName(), customer);
+ return Response.created(URI.create("/001")).build();
+ }
+
+ public void updateCustomer(Customer customer) {
+ if (customers.get(customer.getName()) != null) {
+ customers.put(customer.getName(), customer);
+ }
+ }
+}
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/binding-rest-runtime/src/test/java/services/echo/Echo.java b/sca-java-2.x/tags/2.0.1-RC1/modules/binding-rest-runtime/src/test/java/services/echo/Echo.java
new file mode 100644
index 0000000000..b93ff0838b
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/binding-rest-runtime/src/test/java/services/echo/Echo.java
@@ -0,0 +1,41 @@
+/*
+ * 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 services.echo;
+
+import javax.ws.rs.QueryParam;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * Interface of our sample JSONRPC service.
+ *
+ * @version $Rev$ $Date$
+ */
+@Remotable
+public interface Echo {
+
+ String echo(@QueryParam("msg") String msg);
+
+ int echoInt(@QueryParam("param") int param);
+
+ String [] echoArrayString(@QueryParam("msgArray") String[] stringArray);
+
+ int [] echoArrayInt(@QueryParam("intArray") int[] intArray);
+
+}
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/binding-rest-runtime/src/test/java/services/echo/EchoImpl.java b/sca-java-2.x/tags/2.0.1-RC1/modules/binding-rest-runtime/src/test/java/services/echo/EchoImpl.java
new file mode 100644
index 0000000000..6bc22bd41a
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/binding-rest-runtime/src/test/java/services/echo/EchoImpl.java
@@ -0,0 +1,45 @@
+/*
+ * 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 services.echo;
+
+
+/**
+ * A simple client component that uses a reference with an JSONRPC binding.
+ *
+ * @version $Rev$ $Date$
+ */
+public class EchoImpl implements Echo {
+
+ public String echo(String msg) {
+ return msg;
+ }
+
+ public int echoInt(int param) {
+ int value = param;
+ return value;
+ }
+
+ public String[] echoArrayString(String[] stringArray) {
+ return stringArray;
+ }
+
+ public int[] echoArrayInt(int[] intArray) {
+ return intArray;
+ }
+}
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/binding-rest-runtime/src/test/java/services/echo/jaxrs/Echo.java b/sca-java-2.x/tags/2.0.1-RC1/modules/binding-rest-runtime/src/test/java/services/echo/jaxrs/Echo.java
new file mode 100644
index 0000000000..5554a3d572
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/binding-rest-runtime/src/test/java/services/echo/jaxrs/Echo.java
@@ -0,0 +1,47 @@
+/*
+ * 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 services.echo.jaxrs;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.QueryParam;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * Interface of our sample JSONRPC service.
+ *
+ * @version $Rev$ $Date$
+ */
+@Remotable
+@Path("")
+public interface Echo {
+ @GET
+ String echo(@QueryParam("msg") String msg);
+
+ @GET
+ int echoInt(@QueryParam("param") int param);
+
+ @GET
+ String [] echoArrayString(@QueryParam("msgArray") String[] stringArray);
+
+ @GET
+ int [] echoArrayInt(@QueryParam("intArray") int[] intArray);
+
+}
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/binding-rest-runtime/src/test/java/services/echo/jaxrs/EchoClientImpl.java b/sca-java-2.x/tags/2.0.1-RC1/modules/binding-rest-runtime/src/test/java/services/echo/jaxrs/EchoClientImpl.java
new file mode 100644
index 0000000000..f0b62523d7
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/binding-rest-runtime/src/test/java/services/echo/jaxrs/EchoClientImpl.java
@@ -0,0 +1,43 @@
+/*
+ * 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 services.echo.jaxrs;
+
+import org.oasisopen.sca.annotation.Reference;
+
+public class EchoClientImpl implements Echo {
+ @Reference
+ private Echo echoService;
+
+ public String echo(String msg) {
+ return "echo: "+ echoService.echo(msg);
+ }
+
+ public int echoInt(int param) {
+ return echoService.echoInt(param);
+ }
+
+ public String[] echoArrayString(String[] stringArray) {
+ return echoService.echoArrayString(stringArray);
+ }
+
+ public int[] echoArrayInt(int[] intArray) {
+ return echoService.echoArrayInt(intArray);
+ }
+}
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/binding-rest-runtime/src/test/java/services/echo/jaxrs/EchoImpl.java b/sca-java-2.x/tags/2.0.1-RC1/modules/binding-rest-runtime/src/test/java/services/echo/jaxrs/EchoImpl.java
new file mode 100644
index 0000000000..54bc9004c7
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/binding-rest-runtime/src/test/java/services/echo/jaxrs/EchoImpl.java
@@ -0,0 +1,45 @@
+/*
+ * 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 services.echo.jaxrs;
+
+
+/**
+ * A simple client component that uses a reference with an REST binding.
+ *
+ * @version $Rev$ $Date$
+ */
+public class EchoImpl implements Echo {
+
+ public String echo(String msg) {
+ return msg;
+ }
+
+ public int echoInt(int param) {
+ int value = param;
+ return value;
+ }
+
+ public String[] echoArrayString(String[] stringArray) {
+ return stringArray;
+ }
+
+ public int[] echoArrayInt(int[] intArray) {
+ return intArray;
+ }
+}
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/binding-rest-runtime/src/test/java/services/store/Catalog.java b/sca-java-2.x/tags/2.0.1-RC1/modules/binding-rest-runtime/src/test/java/services/store/Catalog.java
new file mode 100644
index 0000000000..5fb29782f2
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/binding-rest-runtime/src/test/java/services/store/Catalog.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 services.store;
+
+import java.util.Date;
+
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.HeaderParam;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+
+@Remotable
+public interface Catalog {
+
+ @GET
+ Items getItem();
+
+ @GET
+ @Path("{id}")
+ Item getItemById(@PathParam("id") String itemId, @HeaderParam("If-Modified-Since") Date date);
+
+ @POST
+ void addItem(Item item);
+
+ @PUT
+ void updateItem(Item item);
+
+ @DELETE
+ @Path("{id}")
+ void deleteItem(@PathParam("id") String itemId);
+}
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/binding-rest-runtime/src/test/java/services/store/CurrencyConverter.java b/sca-java-2.x/tags/2.0.1-RC1/modules/binding-rest-runtime/src/test/java/services/store/CurrencyConverter.java
new file mode 100644
index 0000000000..45f8949633
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/binding-rest-runtime/src/test/java/services/store/CurrencyConverter.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 services.store;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface CurrencyConverter {
+ public double getConversion(String fromCurrenycCode, String toCurrencyCode, double amount);
+
+ public String getCurrencySymbol(String currencyCode);
+}
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/binding-rest-runtime/src/test/java/services/store/CurrencyConverterImpl.java b/sca-java-2.x/tags/2.0.1-RC1/modules/binding-rest-runtime/src/test/java/services/store/CurrencyConverterImpl.java
new file mode 100644
index 0000000000..9956e207e1
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/binding-rest-runtime/src/test/java/services/store/CurrencyConverterImpl.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 services.store;
+
+public class CurrencyConverterImpl implements CurrencyConverter {
+ public double getConversion(String fromCurrencyCode, String toCurrencyCode, double amount) {
+ if (toCurrencyCode.equals("USD"))
+ return amount;
+ else if (toCurrencyCode.equals("EUR"))
+ return ((double)Math.round(amount * 0.7256 * 100)) /100;
+ return 0;
+ }
+
+ public String getCurrencySymbol(String currencyCode) {
+ if (currencyCode.equals("USD"))
+ return "$";
+ else if (currencyCode.equals("EUR"))
+ return "E"; //"€";
+ return "?";
+ }
+}
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/binding-rest-runtime/src/test/java/services/store/FruitsCatalogImpl.java b/sca-java-2.x/tags/2.0.1-RC1/modules/binding-rest-runtime/src/test/java/services/store/FruitsCatalogImpl.java
new file mode 100644
index 0000000000..447e983aa7
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/binding-rest-runtime/src/test/java/services/store/FruitsCatalogImpl.java
@@ -0,0 +1,76 @@
+/*
+ * 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 services.store;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.oasisopen.sca.annotation.Init;
+import org.oasisopen.sca.annotation.Property;
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Scope;
+
+@Scope("COMPOSITE")
+public class FruitsCatalogImpl implements Catalog {
+
+ @Property
+ public String currencyCode = "USD";
+
+ @Reference
+ public CurrencyConverter currencyConverter;
+
+ private Map<String, Item> catalog = new HashMap<String, Item>();
+
+ @Init
+ public void init() {
+ String currencySymbol = currencyConverter.getCurrencySymbol(currencyCode);
+ catalog.put("Apple", new Item("Apple", currencySymbol + currencyConverter.getConversion("USD", currencyCode, 2.99)));
+ catalog.put("Orange", new Item("Orange", currencySymbol + currencyConverter.getConversion("USD", currencyCode, 3.55)));
+ catalog.put("Pear", new Item("Pear", currencySymbol + currencyConverter.getConversion("USD", currencyCode, 1.55)));
+ }
+
+ public Items getItem() {
+ Items items = new Items();
+ items.setItems(new ArrayList<Item>(catalog.values()));
+ return items;
+ }
+
+ public Item getItemById(String itemId, Date date) {
+ return catalog.get(itemId);
+ }
+
+ public void addItem(Item item) {
+ catalog.put(item.getName(),item);
+ }
+
+ public void updateItem(Item item) {
+ if(catalog.get(item.getName()) != null) {
+ catalog.put(item.getName(), item);
+ }
+ }
+
+ public void deleteItem(String itemId) {
+ if(catalog.get(itemId) != null) {
+ catalog.remove(itemId);
+ }
+ }
+}
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/binding-rest-runtime/src/test/java/services/store/Item.java b/sca-java-2.x/tags/2.0.1-RC1/modules/binding-rest-runtime/src/test/java/services/store/Item.java
new file mode 100644
index 0000000000..d5a298eee5
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/binding-rest-runtime/src/test/java/services/store/Item.java
@@ -0,0 +1,50 @@
+/*
+ * 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 services.store;
+
+public class Item {
+ private String name;
+ private String price;
+
+ public Item() {
+ }
+
+ public Item(String name, String price) {
+ this.name = name;
+ this.price = price;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getPrice() {
+ return price;
+ }
+
+ public void setPrice(String price) {
+ this.price = price;
+ }
+
+}
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/binding-rest-runtime/src/test/java/services/store/Items.java b/sca-java-2.x/tags/2.0.1-RC1/modules/binding-rest-runtime/src/test/java/services/store/Items.java
new file mode 100644
index 0000000000..82a995943d
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/binding-rest-runtime/src/test/java/services/store/Items.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 services.store;
+
+import java.util.List;
+
+/**
+ *
+ */
+public class Items {
+ private List<Item> items;
+
+ public List<Item> getItems() {
+ return items;
+ }
+
+ public void setItems(List<Item> items) {
+ this.items = items;
+ }
+}