You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by js...@apache.org on 2007/04/16 19:15:54 UTC
svn commit: r529329 - in
/incubator/tuscany/java/sca/samples/implementation-crud/src:
main/java/crud/ main/java/org/ main/resources/META-INF/services/
test/java/crud/ test/java/org/
Author: jsdelfino
Date: Mon Apr 16 10:15:52 2007
New Revision: 529329
URL: http://svn.apache.org/viewvc?view=rev&rev=529329
Log:
Moved to a simpler sample package name.
Added:
incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/
incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUD.java (with props)
incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDAtomicComponent.java (with props)
incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDComponentBuilder.java (with props)
incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDImpl.java (with props)
incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDImplementation.java (with props)
incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDImplementationLoader.java (with props)
incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDModuleActivator.java (with props)
incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDTargetInvoker.java (with props)
incubator/tuscany/java/sca/samples/implementation-crud/src/test/java/crud/
incubator/tuscany/java/sca/samples/implementation-crud/src/test/java/crud/CRUDTestCase.java (with props)
Removed:
incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/org/
incubator/tuscany/java/sca/samples/implementation-crud/src/test/java/org/
Modified:
incubator/tuscany/java/sca/samples/implementation-crud/src/main/resources/META-INF/services/org.apache.tuscany.core.ModuleActivator
Added: incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUD.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUD.java?view=auto&rev=529329
==============================================================================
--- incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUD.java (added)
+++ incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUD.java Mon Apr 16 10:15:52 2007
@@ -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 crud;
+
+/**
+ * The service interface implemented by CRUD components.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface CRUD {
+
+ String create(Object resource);
+
+ Object retrieve(String id);
+
+ Object update(String id, Object resource);
+
+ void delete(String id);
+
+}
Propchange: incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUD.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUD.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDAtomicComponent.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDAtomicComponent.java?view=auto&rev=529329
==============================================================================
--- incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDAtomicComponent.java (added)
+++ incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDAtomicComponent.java Mon Apr 16 10:15:52 2007
@@ -0,0 +1,110 @@
+/*
+ * 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 crud;
+
+import java.net.URI;
+import java.util.List;
+
+import org.apache.tuscany.core.component.ComponentContextImpl;
+import org.apache.tuscany.core.component.ComponentContextProvider;
+import org.apache.tuscany.core.component.ServiceReferenceImpl;
+import org.apache.tuscany.core.component.scope.InstanceWrapperBase;
+import org.apache.tuscany.core.injection.SingletonObjectFactory;
+import org.apache.tuscany.interfacedef.Operation;
+import org.apache.tuscany.spi.ObjectCreationException;
+import org.apache.tuscany.spi.component.InstanceWrapper;
+import org.apache.tuscany.spi.component.TargetInvokerCreationException;
+import org.apache.tuscany.spi.component.TargetResolutionException;
+import org.apache.tuscany.spi.extension.AtomicComponentExtension;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+import org.apache.tuscany.spi.wire.Wire;
+import org.osoa.sca.CallableReference;
+import org.osoa.sca.ComponentContext;
+import org.osoa.sca.ServiceReference;
+
+/**
+ * The runtime instantiation of Java component implementations
+ *
+ * @version $Rev$ $Date$
+ */
+public class CRUDAtomicComponent extends AtomicComponentExtension implements ComponentContextProvider {
+ private CRUDImplementation impl;
+ private ComponentContext componentContext;
+
+ public CRUDAtomicComponent(URI uri, URI groupId, CRUDImplementation impl) {
+ super(uri, null, null, groupId, 50);
+ this.impl = impl;
+ componentContext = new ComponentContextImpl(this);
+
+ }
+
+ public Object createInstance() throws ObjectCreationException {
+ return new CRUDImpl(impl.getDirectory());
+ }
+
+ public InstanceWrapper createInstanceWrapper() throws ObjectCreationException {
+ return new InstanceWrapperBase(createInstance());
+ }
+
+ public Object getTargetInstance() throws TargetResolutionException {
+ return new CRUDImpl(impl.getDirectory());
+ }
+
+ public void attachCallbackWire(Wire arg0) {
+ }
+
+ public void attachWire(Wire arg0) {
+ }
+
+ public void attachWires(List<Wire> arg0) {
+ }
+
+ public List<Wire> getWires(String arg0) {
+ return null;
+ }
+
+ public TargetInvoker createTargetInvoker(String targetName, final Operation operation, boolean callback)
+ throws TargetInvokerCreationException {
+ return new CRUDTargetInvoker(operation, impl.getDirectory());
+
+ }
+
+ @Override
+ public ComponentContext getComponentContext() {
+ return componentContext;
+ }
+
+ public <B, R extends CallableReference<B>> R cast(B target) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public <B> B getProperty(Class<B> type, String propertyName) {
+ return null;
+ }
+
+ public <B> B getService(Class<B> businessInterface, String referenceName) {
+ return null;
+ }
+
+ public <B> ServiceReference<B> getServiceReference(Class<B> businessInterface, String referenceName) {
+ return new ServiceReferenceImpl<B>(businessInterface, new SingletonObjectFactory<B>((B)createInstance()));
+ }
+
+}
Propchange: incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDAtomicComponent.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDAtomicComponent.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDComponentBuilder.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDComponentBuilder.java?view=auto&rev=529329
==============================================================================
--- incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDComponentBuilder.java (added)
+++ incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDComponentBuilder.java Mon Apr 16 10:15:52 2007
@@ -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 crud;
+
+import java.net.URI;
+
+import org.apache.tuscany.assembly.Component;
+import org.apache.tuscany.spi.builder.BuilderConfigException;
+import org.apache.tuscany.spi.component.AtomicComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.ComponentBuilderExtension;
+
+/**
+ * Builds a Java-based atomic context from a component definition
+ *
+ * @version $$Rev$$ $$Date: 2007-03-28 09:03:01 -0700 (Wed, 28 Mar
+ * 2007) $$
+ */
+public class CRUDComponentBuilder extends ComponentBuilderExtension<CRUDImplementation> {
+
+ @SuppressWarnings("unchecked")
+ public AtomicComponent build(Component definition, DeploymentContext context) throws BuilderConfigException {
+ URI id = URI.create(context.getComponentId() + definition.getName());
+ CRUDAtomicComponent component = new CRUDAtomicComponent(id, context.getGroupId(),
+ (CRUDImplementation)definition.getImplementation());
+ return component;
+ }
+
+ protected Class<CRUDImplementation> getImplementationType() {
+ return CRUDImplementation.class;
+ }
+
+}
Propchange: incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDComponentBuilder.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDComponentBuilder.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDImpl.java?view=auto&rev=529329
==============================================================================
--- incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDImpl.java (added)
+++ incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDImpl.java Mon Apr 16 10:15:52 2007
@@ -0,0 +1,64 @@
+/*
+ * 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 crud;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class CRUDImpl implements CRUD {
+ private static int counter;
+ private static final Map<String, Object> STORE = new HashMap<String, Object>();
+
+ private String directory;
+
+ /**
+ * @param directory
+ */
+ public CRUDImpl(String directory) {
+ super();
+ this.directory = directory;
+ }
+
+ public String create(Object resource) {
+ System.out.println("create(" + resource + ")");
+ String key = String.valueOf(counter++);
+ STORE.put(key, resource);
+ return key;
+ }
+
+ public void delete(String id) {
+ System.out.println("delete(" + id + ")");
+ STORE.remove(id);
+ }
+
+ public Object retrieve(String id) {
+ System.out.println("retrieve(" + id + ")");
+ return STORE.get(id);
+ }
+
+ public Object update(String id, Object resource) {
+ System.out.println("update(" + id + ")");
+ return STORE.put(id, resource);
+ }
+
+}
Propchange: incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDImpl.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDImplementation.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDImplementation.java?view=auto&rev=529329
==============================================================================
--- incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDImplementation.java (added)
+++ incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDImplementation.java Mon Apr 16 10:15:52 2007
@@ -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 crud;
+
+import org.apache.tuscany.assembly.ComponentService;
+import org.apache.tuscany.assembly.Implementation;
+import org.apache.tuscany.assembly.impl.ComponentServiceImpl;
+import org.apache.tuscany.assembly.impl.ComponentTypeImpl;
+import org.apache.tuscany.interfacedef.java.JavaInterface;
+import org.apache.tuscany.interfacedef.java.JavaInterfaceContract;
+import org.apache.tuscany.interfacedef.java.impl.JavaInterfaceContractImpl;
+import org.apache.tuscany.interfacedef.java.impl.JavaInterfaceImpl;
+
+/**
+ * @version $$Rev$$ $$Date: 2007-04-03 11:08:56 -0700 (Tue, 03 Apr
+ * 2007) $$
+ */
+public class CRUDImplementation extends ComponentTypeImpl implements Implementation {
+ private String directory;
+
+ public CRUDImplementation(String directory) {
+ this.directory = directory;
+ ComponentService service = createService(CRUD.class);
+ getServices().add(service);
+ }
+
+ private ComponentService createService(Class<?> type) {
+ org.apache.tuscany.assembly.ComponentService service = new ComponentServiceImpl();
+ service.setName(type.getSimpleName());
+ JavaInterface interfaze = new JavaInterfaceImpl();
+ interfaze.setJavaClass(type);
+ JavaInterfaceContract interfaceContract = new JavaInterfaceContractImpl();
+ interfaceContract.setInterface(interfaze);
+ service.setInterfaceContract(interfaceContract);
+ return service;
+ }
+
+ /**
+ * @return the directory
+ */
+ public String getDirectory() {
+ return directory;
+ }
+
+ /**
+ * @param directory the directory to set
+ */
+ public void setDirectory(String directory) {
+ this.directory = directory;
+ }
+
+}
Propchange: incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDImplementation.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDImplementation.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDImplementationLoader.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDImplementationLoader.java?view=auto&rev=529329
==============================================================================
--- incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDImplementationLoader.java (added)
+++ incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDImplementationLoader.java Mon Apr 16 10:15:52 2007
@@ -0,0 +1,77 @@
+/*
+ * 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 crud;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import static org.osoa.sca.Constants.SCA_NS;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.contribution.processor.StAXArtifactProcessorExtension;
+import org.apache.tuscany.contribution.resolver.ArtifactResolver;
+import org.apache.tuscany.contribution.service.ContributionException;
+import org.apache.tuscany.contribution.service.ContributionReadException;
+import org.apache.tuscany.contribution.service.ContributionResolveException;
+import org.apache.tuscany.contribution.service.ContributionWireException;
+import org.apache.tuscany.contribution.service.ContributionWriteException;
+
+public class CRUDImplementationLoader implements StAXArtifactProcessorExtension<CRUDImplementation> {
+ public static final QName IMPLEMENTATION_CRUD = new QName(SCA_NS, "implementation.crud");
+
+ public QName getArtifactType() {
+ return IMPLEMENTATION_CRUD;
+ }
+
+ public Class<CRUDImplementation> getModelType() {
+ return CRUDImplementation.class;
+ }
+
+ public void optimize(CRUDImplementation impl) throws ContributionException {
+ }
+
+ public CRUDImplementation read(XMLStreamReader reader) throws ContributionReadException {
+ assert IMPLEMENTATION_CRUD.equals(reader.getName());
+ try {
+ String dir = reader.getAttributeValue(null, "directory");
+
+ CRUDImplementation implementation = new CRUDImplementation(dir);
+ // Skip to end element
+ while (reader.hasNext()) {
+ if (reader.next() == END_ELEMENT && IMPLEMENTATION_CRUD.equals(reader.getName())) {
+ break;
+ }
+ }
+ return implementation;
+ } catch (XMLStreamException e) {
+ throw new ContributionReadException(e);
+ }
+ }
+
+ public void resolve(CRUDImplementation impl, ArtifactResolver resolver) throws ContributionResolveException {
+ }
+
+ public void wire(CRUDImplementation model) throws ContributionWireException {
+ }
+
+ public void write(CRUDImplementation model, XMLStreamWriter outputSource) throws ContributionWriteException {
+ }
+}
Propchange: incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDImplementationLoader.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDImplementationLoader.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDModuleActivator.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDModuleActivator.java?view=auto&rev=529329
==============================================================================
--- incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDModuleActivator.java (added)
+++ incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDModuleActivator.java Mon Apr 16 10:15:52 2007
@@ -0,0 +1,55 @@
+/*
+ * 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 crud;
+
+import java.util.Map;
+
+import org.apache.tuscany.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.core.ExtensionPointRegistry;
+import org.apache.tuscany.core.ModuleActivator;
+import org.apache.tuscany.spi.builder.BuilderRegistry;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class CRUDModuleActivator implements ModuleActivator {
+
+ private CRUDImplementationLoader implementationLoader;
+ private CRUDComponentBuilder builder;
+
+ public void start(ExtensionPointRegistry registry) {
+ StAXArtifactProcessorExtensionPoint processors = registry.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ BuilderRegistry builderRegistry = registry.getExtensionPoint(BuilderRegistry.class);
+
+ implementationLoader = new CRUDImplementationLoader();
+ processors.addExtension(implementationLoader);
+
+ builder = new CRUDComponentBuilder();
+ builder.setBuilderRegistry(builderRegistry);
+ builder.init();
+ }
+
+ public Map<Class, Object> getExtensionPoints() {
+ return null;
+ }
+
+ public void stop(ExtensionPointRegistry registry) {
+ }
+}
Propchange: incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDModuleActivator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDModuleActivator.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDTargetInvoker.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDTargetInvoker.java?view=auto&rev=529329
==============================================================================
--- incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDTargetInvoker.java (added)
+++ incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDTargetInvoker.java Mon Apr 16 10:15:52 2007
@@ -0,0 +1,60 @@
+/*
+ * 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 crud;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.interfacedef.Operation;
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.extension.TargetInvokerExtension;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class CRUDTargetInvoker extends TargetInvokerExtension {
+ private static final Map<String, Method> METHODS = new HashMap<String, Method>();
+ static {
+ for (Method m : CRUD.class.getMethods()) {
+ METHODS.put(m.getName(), m);
+ }
+ }
+ private Method operation;
+ private CRUD instance;
+
+ public CRUDTargetInvoker(Operation operation, String directory) {
+ this.operation = METHODS.get(operation.getName());
+ this.instance = new CRUDImpl(directory);
+
+ }
+
+ public Object invokeTarget(Object body, short sequence, WorkContext context) throws InvocationTargetException {
+ try {
+ return operation.invoke(instance, (Object[])body);
+ } catch (IllegalArgumentException e) {
+ throw new AssertionError(e);
+ } catch (IllegalAccessException e) {
+ throw new AssertionError(e);
+ }
+ }
+
+}
Propchange: incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDTargetInvoker.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDTargetInvoker.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/tuscany/java/sca/samples/implementation-crud/src/main/resources/META-INF/services/org.apache.tuscany.core.ModuleActivator
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/implementation-crud/src/main/resources/META-INF/services/org.apache.tuscany.core.ModuleActivator?view=diff&rev=529329&r1=529328&r2=529329
==============================================================================
--- incubator/tuscany/java/sca/samples/implementation-crud/src/main/resources/META-INF/services/org.apache.tuscany.core.ModuleActivator (original)
+++ incubator/tuscany/java/sca/samples/implementation-crud/src/main/resources/META-INF/services/org.apache.tuscany.core.ModuleActivator Mon Apr 16 10:15:52 2007
@@ -1,2 +1,2 @@
# Implementation class for the ExtensionActivator
-org.apache.tuscany.container.crud.CRUDModuleActivator
+crud.CRUDModuleActivator
Added: incubator/tuscany/java/sca/samples/implementation-crud/src/test/java/crud/CRUDTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/implementation-crud/src/test/java/crud/CRUDTestCase.java?view=auto&rev=529329
==============================================================================
--- incubator/tuscany/java/sca/samples/implementation-crud/src/test/java/crud/CRUDTestCase.java (added)
+++ incubator/tuscany/java/sca/samples/implementation-crud/src/test/java/crud/CRUDTestCase.java Mon Apr 16 10:15:52 2007
@@ -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 crud;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.host.embedded.SCARuntime;
+import org.osoa.sca.ComponentContext;
+import org.osoa.sca.ServiceReference;
+
+import crud.CRUD;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class CRUDTestCase extends TestCase {
+ private CRUD crudService;
+
+ /**
+ * @throws java.lang.Exception
+ */
+ protected void setUp() throws Exception {
+ SCARuntime.start("crud.composite");
+ ComponentContext context = SCARuntime.getComponentContext("CRUDServiceComponent");
+ assertNotNull(context);
+ ServiceReference<CRUD> self = context.createSelfReference(CRUD.class);
+ crudService = self.getService();
+
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ protected void tearDown() throws Exception {
+ SCARuntime.stop();
+ }
+
+
+ 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);
+ }
+
+
+}
Propchange: incubator/tuscany/java/sca/samples/implementation-crud/src/test/java/crud/CRUDTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/samples/implementation-crud/src/test/java/crud/CRUDTestCase.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org