summaryrefslogtreecommitdiffstats
path: root/sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src
diff options
context:
space:
mode:
Diffstat (limited to 'sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src')
-rw-r--r--sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/main/java/crud2/CRUD.java54
-rw-r--r--sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/main/java/crud2/backend/ResourceManager.java90
-rw-r--r--sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/main/java/crud2/extension/CRUDImplementation.java128
-rw-r--r--sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/main/java/crud2/extension/CRUDImplementationInvoker.java70
-rw-r--r--sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/main/java/crud2/extension/CRUDImplementationProvider.java69
-rw-r--r--sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/main/java/crud2/extension/CRUDImplementationProviderFactory.java49
-rw-r--r--sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor19
-rw-r--r--sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory19
-rw-r--r--sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/test/java/crud2/CRUDTestCase.java68
-rw-r--r--sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/test/resources/crud2.composite30
10 files changed, 596 insertions, 0 deletions
diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/main/java/crud2/CRUD.java b/sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/main/java/crud2/CRUD.java
new file mode 100644
index 0000000000..49ed376809
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/main/java/crud2/CRUD.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 crud2;
+
+/**
+ * The service interface of the single CRUD service provided by CRUD components.
+ */
+public interface CRUD {
+
+ /**
+ * Create a new resource.
+ * @param resource
+ * @return
+ */
+ String create(Object resource);
+
+ /**
+ * Retrieve a resource.
+ * @param id
+ * @return
+ */
+ Object retrieve(String id);
+
+ /**
+ * Update a resource.
+ * @param id
+ * @param resource
+ * @return
+ */
+ Object update(String id, Object resource);
+
+ /**
+ * Delete a resource.
+ * @param id
+ */
+ void delete(String id);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/main/java/crud2/backend/ResourceManager.java b/sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/main/java/crud2/backend/ResourceManager.java
new file mode 100644
index 0000000000..aa94cd55b6
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/main/java/crud2/backend/ResourceManager.java
@@ -0,0 +1,90 @@
+/*
+ * 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 crud2.backend;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * A fake resource manager implementation used as a backend by the sample
+ * CRUD component implementation.
+ */
+public class ResourceManager {
+ private static int counter;
+ private static final Map<String, Object> store = new HashMap<String, Object>();
+ private String directory;
+
+ /**
+ * Constructs a new resource manager.
+ *
+ * @param directory the directory where to persist resources
+ */
+ public ResourceManager(String directory) {
+ super();
+ this.directory = directory;
+ }
+
+ /**
+ * Creates a new resource.
+ *
+ * @param resource
+ * @return
+ */
+ public String createResource(Object resource) {
+ System.out.println("create(" + resource + ") in " + directory);
+ String key = String.valueOf(counter++);
+ store.put(key, resource);
+ return key;
+ }
+
+ /**
+ * Deletes a resource.
+ *
+ * @param id
+ */
+ public void deleteResource(String id) {
+ System.out.println("delete(" + id + ")");
+ store.remove(id);
+ }
+
+ /**
+ * Retrieves a resource.
+ *
+ * @param id
+ * @return
+ */
+ public Object retrieveResource(String id) {
+ System.out.println("retrieve(" + id + ")");
+ return store.get(id);
+ }
+
+ /**
+ * Updates a resource.
+ *
+ * @param id
+ * @param resource
+ * @return
+ */
+ public Object updateResource(String id, Object resource) {
+ System.out.println("update(" + id + ")");
+ return store.put(id, resource);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/main/java/crud2/extension/CRUDImplementation.java b/sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/main/java/crud2/extension/CRUDImplementation.java
new file mode 100644
index 0000000000..0887a98df6
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/main/java/crud2/extension/CRUDImplementation.java
@@ -0,0 +1,128 @@
+/*
+ * 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 crud2.extension;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.ConstrainingType;
+import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.assembly.Property;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
+import org.apache.tuscany.sca.interfacedef.java.DefaultJavaInterfaceFactory;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+
+import crud2.CRUD;
+
+
+/**
+ * The model representing a sample CRUD implementation in an SCA assembly model.
+ */
+public class CRUDImplementation implements Implementation {
+
+ private Service crudService;
+ private String directory;
+
+ /**
+ * Constructs a new CRUD implementation.
+ */
+ public CRUDImplementation() {
+
+ // CRUD implementation always provide a single service exposing
+ // the CRUD Java interface, create the model representing that
+ // fixed service here
+
+ // Create a default service named CRUD
+ AssemblyFactory assemblyFactory = new DefaultAssemblyFactory();
+ crudService = assemblyFactory.createService();
+ crudService.setName("CRUD");
+
+ // Create a Java interface model for the CRUD Java interface
+ JavaInterfaceFactory javaFactory = new DefaultJavaInterfaceFactory();
+ JavaInterface javaInterface;
+ try {
+ javaInterface = javaFactory.createJavaInterface(CRUD.class);
+ } catch (InvalidInterfaceException e) {
+ throw new IllegalArgumentException(e);
+ }
+
+ // Create a Java interface contract model and set it
+ // into the service
+ JavaInterfaceContract interfaceContract = javaFactory.createJavaInterfaceContract();
+ interfaceContract.setInterface(javaInterface);
+ crudService.setInterfaceContract(interfaceContract);
+ }
+
+ public String getDirectory() {
+ return directory;
+ }
+
+ public void setDirectory(String directory) {
+ this.directory = directory;
+ }
+
+ public ConstrainingType getConstrainingType() {
+ // The sample CRUD implementation does not support constrainingTypes
+ return null;
+ }
+
+ public List<Property> getProperties() {
+ // The sample CRUD implementation does not support properties
+ return Collections.emptyList();
+ }
+
+ public List<Service> getServices() {
+ // The sample CRUD implementation provides a single fixed CRUD service
+ return Collections.singletonList(crudService);
+ }
+
+ public List<Reference> getReferences() {
+ // The sample CRUD implementation does not support properties
+ return Collections.emptyList();
+ }
+
+ public String getURI() {
+ // The sample CRUD implementation does not have a URI
+ return null;
+ }
+
+ public void setConstrainingType(ConstrainingType constrainingType) {
+ // The sample CRUD implementation does not support constrainingTypes
+ }
+
+ public void setURI(String uri) {
+ // The sample CRUD implementation does not have a URI
+ }
+
+ public boolean isUnresolved() {
+ // The sample CRUD implementation is always resolved
+ return false;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ // The sample CRUD implementation is always resolved
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/main/java/crud2/extension/CRUDImplementationInvoker.java b/sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/main/java/crud2/extension/CRUDImplementationInvoker.java
new file mode 100644
index 0000000000..3040dac612
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/main/java/crud2/extension/CRUDImplementationInvoker.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 crud2.extension;
+
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+
+import crud2.backend.ResourceManager;
+
+/**
+ * Implements a target invoker for CRUD component implementations.
+ *
+ * The target invoker is responsible for dispatching invocations to the particular
+ * component implementation logic. In this example we are simply delegating the
+ * CRUD operation invocations to the corresponding methods on our fake
+ * resource manager.
+ */
+public class CRUDImplementationInvoker implements Invoker {
+ private Operation operation;
+ private ResourceManager resourceManager;
+
+ public CRUDImplementationInvoker(Operation operation, ResourceManager resourceManager) {
+ this.operation = operation;
+ this.resourceManager = resourceManager;
+ }
+
+ public Message invoke(Message msg) {
+ try {
+ Object[] args = msg.getBody();
+ Object resp = null;
+
+ if (operation.getName().equals("create")) {
+ resp = resourceManager.createResource(args[0]);
+
+ } else if (operation.getName().equals("retrieve")) {
+ resp = resourceManager.retrieveResource((String)args[0]);
+
+ } else if (operation.getName().equals("update")) {
+ resp = resourceManager.updateResource((String)args[0], args[1]);
+
+ } else if (operation.getName().equals("delete")) {
+ resourceManager.deleteResource((String)args[0]);
+ }
+
+ msg.setBody(resp);
+ } catch (Exception e) {
+ msg.setFaultBody(e.getCause());
+ }
+ return msg;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/main/java/crud2/extension/CRUDImplementationProvider.java b/sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/main/java/crud2/extension/CRUDImplementationProvider.java
new file mode 100644
index 0000000000..1135ce75cf
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/main/java/crud2/extension/CRUDImplementationProvider.java
@@ -0,0 +1,69 @@
+/*
+ * 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 crud2.extension;
+
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.provider.ImplementationProvider;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+
+import crud2.backend.ResourceManager;
+
+/**
+ * The model representing a sample CRUD implementation in an SCA assembly model.
+ * The sample CRUD implementation is not a full blown implementation, it only
+ * supports a subset of what a component implementation can support: - a single
+ * fixed service (as opposed to a list of services typed by different
+ * interfaces) - a directory attribute used to specify where a CRUD component is
+ * going to persist resources - no references or properties - no policy intents
+ * or policy sets
+ */
+public class CRUDImplementationProvider implements ImplementationProvider {
+
+ private RuntimeComponent component;
+ private CRUDImplementation implementation;
+
+ /**
+ * Constructs a new CRUD implementation.
+ */
+ public CRUDImplementationProvider(RuntimeComponent component, CRUDImplementation implementation) {
+ this.component = component;
+ this.implementation = implementation;
+ }
+
+ public void start() {
+ System.out.println("Starting " + component.getName());
+ }
+
+ public void stop() {
+ System.out.println("Stopping " + component.getName());
+ }
+
+ public Invoker createInvoker(RuntimeComponentService service, Operation operation) {
+ CRUDImplementationInvoker invoker = new CRUDImplementationInvoker(operation, new ResourceManager(implementation.getDirectory()));
+ return invoker;
+ }
+
+ public Invoker createCallbackInvoker(Operation operation) {
+ CRUDImplementationInvoker invoker = new CRUDImplementationInvoker(operation, new ResourceManager(implementation.getDirectory()));
+ return invoker;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/main/java/crud2/extension/CRUDImplementationProviderFactory.java b/sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/main/java/crud2/extension/CRUDImplementationProviderFactory.java
new file mode 100644
index 0000000000..a4d92ccedd
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/main/java/crud2/extension/CRUDImplementationProviderFactory.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 crud2.extension;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.provider.ImplementationProvider;
+import org.apache.tuscany.sca.provider.ImplementationProviderFactory;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+/**
+ * The model representing a sample CRUD implementation in an SCA assembly model.
+ * The sample CRUD implementation is not a full blown implementation, it only
+ * supports a subset of what a component implementation can support: - a single
+ * fixed service (as opposed to a list of services typed by different
+ * interfaces) - a directory attribute used to specify where a CRUD component is
+ * going to persist resources - no references or properties - no policy intents
+ * or policy sets
+ */
+public class CRUDImplementationProviderFactory implements ImplementationProviderFactory<CRUDImplementation> {
+
+ public CRUDImplementationProviderFactory(ExtensionPointRegistry registry) {
+ }
+
+ public Class<CRUDImplementation> getModelType() {
+ // Returns the type of model processed by this processor
+ return CRUDImplementation.class;
+ }
+
+ public ImplementationProvider createImplementationProvider(RuntimeComponent component, CRUDImplementation implementation) {
+ return new CRUDImplementationProvider(component, implementation);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
new file mode 100644
index 0000000000..4b922f4d28
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
@@ -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.
+
+# Implementation class for the artifact processor extension
+org.apache.tuscany.sca.assembly.xml.DefaultBeanModelProcessor;qname=http://crud2#implementation.crud,model=crud2.extension.CRUDImplementation
diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory b/sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory
new file mode 100644
index 0000000000..5ac1827889
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory
@@ -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.
+
+# Implementation class for the implementation extension
+crud2.extension.CRUDImplementationProviderFactory;model=crud2.extension.CRUDImplementation
diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/test/java/crud2/CRUDTestCase.java b/sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/test/java/crud2/CRUDTestCase.java
new file mode 100644
index 0000000000..3bc86cef80
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/test/java/crud2/CRUDTestCase.java
@@ -0,0 +1,68 @@
+/*
+ * 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 crud2;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.host.embedded.SCADomain;
+
+import crud2.CRUD;
+
+/**
+ * Tests the CRUD service
+ */
+public class CRUDTestCase extends TestCase {
+
+ private SCADomain scaDomain;
+ private CRUD crudService;
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @Override
+ protected void setUp() throws Exception {
+ scaDomain = SCADomain.newInstance("crud2.composite");
+ crudService = scaDomain.getService(CRUD.class, "CRUDServiceComponent");
+
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @Override
+ protected void tearDown() throws Exception {
+ scaDomain.close();
+ }
+
+
+ public void testCRUD() throws Exception {
+ String id = crudService.create("ABC");
+ Object result = crudService.retrieve(id);
+ assertEquals("ABC", result);
+ crudService.update(id, "EFG");
+ result = crudService.retrieve(id);
+ assertEquals("EFG", result);
+ crudService.delete(id);
+ result = crudService.retrieve(id);
+ assertNull(result);
+ }
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/test/resources/crud2.composite b/sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/test/resources/crud2.composite
new file mode 100644
index 0000000000..5aa4b3c7d6
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/test/resources/crud2.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
+ * "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.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ targetNamespace="http://sample/crud"
+ xmlns:sc="http://sample/crud"
+ xmlns:c="http://crud2"
+ name="crud2">
+
+ <component name="CRUDServiceComponent">
+ <c:implementation.crud directory="tmp" />
+ </component>
+
+</composite>