summaryrefslogtreecommitdiffstats
path: root/sandbox/amita/sca/modules/implementation-data-sdo/main
diff options
context:
space:
mode:
authordims <dims@13f79535-47bb-0310-9956-ffa450edef68>2008-06-17 00:23:01 +0000
committerdims <dims@13f79535-47bb-0310-9956-ffa450edef68>2008-06-17 00:23:01 +0000
commitbdd0a41aed7edf21ec2a65cfa17a86af2ef8c48a (patch)
tree38a92061c0793434c4be189f1d70c3458b6bc41d /sandbox/amita/sca/modules/implementation-data-sdo/main
Move Tuscany from Incubator to top level.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@668359 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sandbox/amita/sca/modules/implementation-data-sdo/main')
-rw-r--r--sandbox/amita/sca/modules/implementation-data-sdo/main/java/org/apache/tuscany/sca/implementation/sdo/SDOImplementation.java47
-rw-r--r--sandbox/amita/sca/modules/implementation-data-sdo/main/java/org/apache/tuscany/sca/implementation/sdo/SDOImplementationFactory.java24
-rw-r--r--sandbox/amita/sca/modules/implementation-data-sdo/main/java/org/apache/tuscany/sca/implementation/sdo/SDOImplementationProcessor.java147
-rw-r--r--sandbox/amita/sca/modules/implementation-data-sdo/main/java/org/apache/tuscany/sca/implementation/sdo/impl/SDOImplementationFactoryImpl.java39
-rw-r--r--sandbox/amita/sca/modules/implementation-data-sdo/main/java/org/apache/tuscany/sca/implementation/sdo/impl/SDOImplementationImpl.java132
-rw-r--r--sandbox/amita/sca/modules/implementation-data-sdo/main/java/org/apache/tuscany/sca/implementation/sdo/provider/SDOImplementationProvider.java79
-rw-r--r--sandbox/amita/sca/modules/implementation-data-sdo/main/java/org/apache/tuscany/sca/implementation/sdo/provider/SDOImplementationProviderFactory.java45
-rw-r--r--sandbox/amita/sca/modules/implementation-data-sdo/main/java/org/apache/tuscany/sca/implementation/sdo/provider/SDOInvoker.java87
-rw-r--r--sandbox/amita/sca/modules/implementation-data-sdo/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor19
-rw-r--r--sandbox/amita/sca/modules/implementation-data-sdo/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.sdo.SDOImplementationFactory19
-rw-r--r--sandbox/amita/sca/modules/implementation-data-sdo/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory19
11 files changed, 657 insertions, 0 deletions
diff --git a/sandbox/amita/sca/modules/implementation-data-sdo/main/java/org/apache/tuscany/sca/implementation/sdo/SDOImplementation.java b/sandbox/amita/sca/modules/implementation-data-sdo/main/java/org/apache/tuscany/sca/implementation/sdo/SDOImplementation.java
new file mode 100644
index 0000000000..3216734b9e
--- /dev/null
+++ b/sandbox/amita/sca/modules/implementation-data-sdo/main/java/org/apache/tuscany/sca/implementation/sdo/SDOImplementation.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 org.apache.tuscany.sca.implementation.sdo;
+
+import java.util.Properties;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.data.engine.config.ConnectionInfo;
+import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+
+public interface SDOImplementation extends Implementation {
+
+ public ConnectionInfo getConnectionInfo();
+
+ public void setConnectionInfo(ConnectionInfo connectionInfo);
+
+ public String getTable();
+
+ public void setTable(String config);
+
+ public String getKey();
+
+ public void setKey(String key);//can be comma separated string
+}
diff --git a/sandbox/amita/sca/modules/implementation-data-sdo/main/java/org/apache/tuscany/sca/implementation/sdo/SDOImplementationFactory.java b/sandbox/amita/sca/modules/implementation-data-sdo/main/java/org/apache/tuscany/sca/implementation/sdo/SDOImplementationFactory.java
new file mode 100644
index 0000000000..afe04a3eb9
--- /dev/null
+++ b/sandbox/amita/sca/modules/implementation-data-sdo/main/java/org/apache/tuscany/sca/implementation/sdo/SDOImplementationFactory.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.implementation.sdo;
+
+public interface SDOImplementationFactory {
+ SDOImplementation createSDOImplementation();
+}
diff --git a/sandbox/amita/sca/modules/implementation-data-sdo/main/java/org/apache/tuscany/sca/implementation/sdo/SDOImplementationProcessor.java b/sandbox/amita/sca/modules/implementation-data-sdo/main/java/org/apache/tuscany/sca/implementation/sdo/SDOImplementationProcessor.java
new file mode 100644
index 0000000000..a0638179ef
--- /dev/null
+++ b/sandbox/amita/sca/modules/implementation-data-sdo/main/java/org/apache/tuscany/sca/implementation/sdo/SDOImplementationProcessor.java
@@ -0,0 +1,147 @@
+/*
+ * 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.implementation.sdo;
+
+import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.xml.Constants;
+import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.contribution.service.ContributionReadException;
+import org.apache.tuscany.sca.contribution.service.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.service.ContributionWriteException;
+import org.apache.tuscany.sca.data.engine.ConnectionInfoArtifactProcessor;
+import org.apache.tuscany.sca.data.engine.config.ConnectionInfo;
+import org.apache.tuscany.sca.implementation.sdo.impl.SDOImplementationFactoryImpl;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+
+
+/**
+ * Implements a STAX artifact processor for DATA implementations.
+ *
+ * The artifact processor is responsible for processing <implementation.data>
+ * elements in SCA assembly XML composite files and populating the DATA
+ * implementation model, resolving its references to other artifacts in the SCA
+ * contribution, and optionally write the model back to SCA assembly XML.
+ *
+ * @version $Rev$ $Date$
+ */
+public class SDOImplementationProcessor implements StAXArtifactProcessor<SDOImplementation> {
+ protected static final QName IMPLEMENTATION_SDO = new QName(Constants.SCA10_TUSCANY_NS, "implementation.sdo");
+
+ private SDOImplementationFactory sdoFactory;
+
+ private StAXArtifactProcessor<ConnectionInfo> connectionInfoProcessor;
+
+ public SDOImplementationProcessor(ModelFactoryExtensionPoint modelFactories) {
+ AssemblyFactory assemblyFactory = modelFactories.getFactory(AssemblyFactory.class);
+ JavaInterfaceFactory javaFactory = modelFactories.getFactory(JavaInterfaceFactory.class);
+
+ this.sdoFactory = new SDOImplementationFactoryImpl(assemblyFactory, javaFactory);
+
+ this.connectionInfoProcessor = new ConnectionInfoArtifactProcessor(modelFactories);
+ }
+
+ public QName getArtifactType() {
+ // Returns the qname of the XML element processed by this processor
+ return IMPLEMENTATION_SDO;
+ }
+
+ public Class<SDOImplementation> getModelType() {
+ // Returns the type of model processed by this processor
+ return SDOImplementation.class;
+ }
+
+ /*
+ * <component name="CompanyDataComponent">
+ * <implementation.sdo table="company">
+ * <connectionInfo>
+ * <connectionProperties
+ * driverClass="org.apache.derby.jdbc.EmbeddedDriver"
+ * databaseURL="jdbc:derby:target/test-classes/dastest; create = true"
+ * loginTimeout="600000"/>
+ * </connectionInfo>
+ * </implementation.data>
+ * </component>
+ */
+ public SDOImplementation read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
+ assert IMPLEMENTATION_SDO.equals(reader.getName());
+
+ // Read an <implementation.data> element
+
+ // Create an initialize the DAS implementation model
+ SDOImplementation implementation = sdoFactory.createSDOImplementation();
+
+ //FIXME: validation sending info to monitor....
+ String table = reader.getAttributeValue(null, "table");
+ implementation.setTable(table); //required
+ String key = reader.getAttributeValue(null, "key");
+ if(key == null) {
+ implementation.setKey("ID");
+ } else {
+ implementation.setKey(key);
+ }
+
+ while (true) {
+ int event = reader.next();
+ switch (event) {
+
+ case START_ELEMENT:
+ if (ConnectionInfoArtifactProcessor.CONNECTION_INFO.equals(reader.getName())) {
+
+ // Read connection info
+ ConnectionInfo connectionInfo = (ConnectionInfo) connectionInfoProcessor.read(reader);;
+ implementation.setConnectionInfo(connectionInfo);
+ }
+ break;
+ case XMLStreamConstants.END_ELEMENT:
+ if (IMPLEMENTATION_SDO.equals(reader.getName())) {
+ return implementation;
+ }
+ break;
+ }
+ }
+
+ }
+
+ public void resolve(SDOImplementation impl, ModelResolver resolver) throws ContributionResolveException {
+ }
+
+ public void write(SDOImplementation implementation, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException {
+ writer.writeStartElement(IMPLEMENTATION_SDO.getNamespaceURI(), IMPLEMENTATION_SDO.getLocalPart());
+
+ if (implementation.getTable() != null) {
+ writer.writeAttribute("table", implementation.getTable());
+ }
+
+ if (implementation.getConnectionInfo() != null) {
+ connectionInfoProcessor.write(implementation.getConnectionInfo(), writer);
+ }
+
+ writer.writeEndElement();
+ }
+}
diff --git a/sandbox/amita/sca/modules/implementation-data-sdo/main/java/org/apache/tuscany/sca/implementation/sdo/impl/SDOImplementationFactoryImpl.java b/sandbox/amita/sca/modules/implementation-data-sdo/main/java/org/apache/tuscany/sca/implementation/sdo/impl/SDOImplementationFactoryImpl.java
new file mode 100644
index 0000000000..39b2d7fc7c
--- /dev/null
+++ b/sandbox/amita/sca/modules/implementation-data-sdo/main/java/org/apache/tuscany/sca/implementation/sdo/impl/SDOImplementationFactoryImpl.java
@@ -0,0 +1,39 @@
+/*
+ * 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.implementation.sdo.impl;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.implementation.sdo.*;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+
+public class SDOImplementationFactoryImpl implements SDOImplementationFactory {
+ private AssemblyFactory assemblyFactory;
+ private JavaInterfaceFactory javaFactory;
+
+ public SDOImplementationFactoryImpl(AssemblyFactory aF, JavaInterfaceFactory javaIF) {
+ this.assemblyFactory = aF;
+ this.javaFactory = javaIF;
+ }
+
+ public SDOImplementation createSDOImplementation() {
+ return new SDOImplementationImpl(assemblyFactory, javaFactory);
+ }
+
+}
diff --git a/sandbox/amita/sca/modules/implementation-data-sdo/main/java/org/apache/tuscany/sca/implementation/sdo/impl/SDOImplementationImpl.java b/sandbox/amita/sca/modules/implementation-data-sdo/main/java/org/apache/tuscany/sca/implementation/sdo/impl/SDOImplementationImpl.java
new file mode 100644
index 0000000000..59a0134277
--- /dev/null
+++ b/sandbox/amita/sca/modules/implementation-data-sdo/main/java/org/apache/tuscany/sca/implementation/sdo/impl/SDOImplementationImpl.java
@@ -0,0 +1,132 @@
+/*
+ * 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.implementation.sdo.impl;
+
+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.Property;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.data.engine.config.ConnectionInfo;
+import org.apache.tuscany.sca.implementation.sdo.SDOImplementation;
+import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+
+public class SDOImplementationImpl implements SDOImplementation {
+
+ private Service dataService;
+ private ConnectionInfo connectionInfo;
+ private String table;
+ private String key;
+
+ /**
+ * Constructs a new DAS implementation.
+ */
+ public SDOImplementationImpl(AssemblyFactory assemblyFactory,
+ JavaInterfaceFactory javaFactory) {
+
+ // DATA implementation always provide a single service exposing
+ // the DATA interface, and have no references and properties
+ dataService = assemblyFactory.createService();
+ dataService.setName("DATA");
+ JavaInterface javaInterface;
+ try {
+ javaInterface = javaFactory.createJavaInterface(org.apache.tuscany.sca.implementation.data.collection.Collection.class);
+ } catch (InvalidInterfaceException e) {
+ throw new IllegalArgumentException(e);
+ }
+ JavaInterfaceContract interfaceContract = javaFactory.createJavaInterfaceContract();
+ interfaceContract.setInterface(javaInterface);
+ dataService.setInterfaceContract(interfaceContract);
+ }
+
+ public ConnectionInfo getConnectionInfo() {
+ return this.connectionInfo;
+ }
+
+ public void setConnectionInfo(ConnectionInfo connectionInfo) {
+ this.connectionInfo = connectionInfo;
+ }
+
+ public String getTable() {
+ return this.table;
+ }
+
+ public void setTable(String config) {
+ this.table = config;
+ }
+
+ public String getKey() {
+ return this.key;
+ }
+
+ public void setKey(String key) {
+ this.key = key;
+ }
+
+ public ConstrainingType getConstrainingType() {
+ // The sample DATA implementation does not support constrainingTypes
+ return null;
+ }
+
+ public List<Property> getProperties() {
+ // The sample DATA implementation does not support properties
+ return Collections.emptyList();
+ }
+
+ public List<Service> getServices() {
+ // The sample DATA implementation provides a single fixed CRUD service
+ return Collections.singletonList(dataService);
+ }
+
+ public List<Reference> getReferences() {
+ // The sample DATA implementation does not support properties
+ return Collections.emptyList();
+ }
+
+ public String getURI() {
+ // The sample DATA implementation does not have a URI
+ return null;
+ }
+
+ public void setConstrainingType(ConstrainingType constrainingType) {
+ // The sample DATA implementation does not support constrainingTypes
+ }
+
+ public void setURI(String uri) {
+ // The sample DATA implementation does not have a URI
+ }
+
+
+ public boolean isUnresolved() {
+ // The sample DATA implementation is always resolved
+ return false;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ // The sample DATA implementation is always resolved
+ }
+
+}
diff --git a/sandbox/amita/sca/modules/implementation-data-sdo/main/java/org/apache/tuscany/sca/implementation/sdo/provider/SDOImplementationProvider.java b/sandbox/amita/sca/modules/implementation-data-sdo/main/java/org/apache/tuscany/sca/implementation/sdo/provider/SDOImplementationProvider.java
new file mode 100644
index 0000000000..5d79da32df
--- /dev/null
+++ b/sandbox/amita/sca/modules/implementation-data-sdo/main/java/org/apache/tuscany/sca/implementation/sdo/provider/SDOImplementationProvider.java
@@ -0,0 +1,79 @@
+/*
+ * 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.implementation.sdo.provider;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.tuscany.das.rdb.DAS;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.data.engine.DataAccessEngine;
+import org.apache.tuscany.sca.data.engine.DataAccessEngineManager;
+import org.apache.tuscany.sca.implementation.sdo.SDOImplementation;
+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;
+
+public class SDOImplementationProvider implements ImplementationProvider {
+ private RuntimeComponent component;
+ private SDOImplementation implementation;
+ private final DataAccessEngineManager dataAccessEngineManager;
+
+ public SDOImplementationProvider(RuntimeComponent component,
+ SDOImplementation implementation,
+ ExtensionPointRegistry extensionPoints) {
+ this.component = component;
+ this.implementation = implementation;
+ this.dataAccessEngineManager = new DataAccessEngineManager();
+ }
+
+ private Log log = LogFactory.getLog(this.getClass());
+
+ public Invoker createInvoker(RuntimeComponentService service, Operation operation) {
+ DAS das = null;
+ try {
+ das = dataAccessEngineManager.getDAS(null, implementation.getConnectionInfo(), implementation.getTable(), implementation.getKey());
+ } catch(Exception e) {
+ e.printStackTrace();
+ //what now ?
+ }
+ SDOInvoker invoker = new SDOInvoker(operation, implementation.getTable(), implementation.getKey(), new DataAccessEngine(das) );
+ return invoker; }
+
+ public void start() {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void stop() {
+ // TODO Auto-generated method stub
+
+ }
+
+ public boolean supportsOneWayInvocation() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+}
diff --git a/sandbox/amita/sca/modules/implementation-data-sdo/main/java/org/apache/tuscany/sca/implementation/sdo/provider/SDOImplementationProviderFactory.java b/sandbox/amita/sca/modules/implementation-data-sdo/main/java/org/apache/tuscany/sca/implementation/sdo/provider/SDOImplementationProviderFactory.java
new file mode 100644
index 0000000000..b02b47e6bb
--- /dev/null
+++ b/sandbox/amita/sca/modules/implementation-data-sdo/main/java/org/apache/tuscany/sca/implementation/sdo/provider/SDOImplementationProviderFactory.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 org.apache.tuscany.sca.implementation.sdo.provider;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.implementation.sdo.SDOImplementation;
+import org.apache.tuscany.sca.provider.ImplementationProvider;
+import org.apache.tuscany.sca.provider.ImplementationProviderFactory;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+public class SDOImplementationProviderFactory implements ImplementationProviderFactory<SDOImplementation> {
+ private ExtensionPointRegistry eP;
+
+ public SDOImplementationProviderFactory(ExtensionPointRegistry extensionPoints) {
+ eP = extensionPoints;
+ }
+
+ public ImplementationProvider createImplementationProvider(RuntimeComponent component,
+ SDOImplementation implementation) {
+ return new SDOImplementationProvider(component, implementation, eP);
+ }
+
+ public Class<SDOImplementation> getModelType() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
diff --git a/sandbox/amita/sca/modules/implementation-data-sdo/main/java/org/apache/tuscany/sca/implementation/sdo/provider/SDOInvoker.java b/sandbox/amita/sca/modules/implementation-data-sdo/main/java/org/apache/tuscany/sca/implementation/sdo/provider/SDOInvoker.java
new file mode 100644
index 0000000000..776541869c
--- /dev/null
+++ b/sandbox/amita/sca/modules/implementation-data-sdo/main/java/org/apache/tuscany/sca/implementation/sdo/provider/SDOInvoker.java
@@ -0,0 +1,87 @@
+/*
+ * 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.implementation.sdo.provider;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.tuscany.sca.data.engine.DataAccessEngine;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.java.impl.JavaInterfaceUtil;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+
+import commonj.sdo.DataObject;
+
+public class SDOInvoker implements Invoker {
+ private final Operation operation;
+ private final String table;
+ private final String key;
+ private final DataAccessEngine dataAccessEngine;
+
+ public SDOInvoker(Operation operation, String table, String key, DataAccessEngine dataAccessEngine) {
+ this.operation = operation;
+ this.table = table;
+ this.key = key;
+ this.dataAccessEngine = dataAccessEngine;
+ }
+
+ public Message invoke(Message msg) {
+ try {
+ Object[] args = msg.getBody();
+ Object resp = doTheWork(args);
+ msg.setBody(resp);
+ } catch (InvocationTargetException e) {
+ msg.setFaultBody(e.getCause());
+ }
+ return msg;
+ }
+
+ public Object doTheWork(Object[] args) throws InvocationTargetException {
+ if (operation.getName().equals("get")) {
+ ArrayList id = (ArrayList) args[0];
+
+ //simple execute command by name
+ return this.dataAccessEngine.executeGet(id, table, key);
+ } else if (operation.getName().equals("getAll")) {
+ return this.dataAccessEngine.executeGetAll(table, key);
+ } else if (operation.getName().equals("query")) {
+ String queryString = (String) args[0];
+ return this.dataAccessEngine.executeQuery(queryString, table, key);
+ } else if (operation.getName().equals("put")) {
+ ArrayList keys = (ArrayList) args[0];//TODO this will be ignored
+ DataObject origDataObject = (DataObject)args[1];
+ this.dataAccessEngine.executePut(origDataObject);
+ return null;
+ } else if (operation.getName().equals("post")) {
+ DataObject origDataObject = (DataObject)args[0];
+ return this.dataAccessEngine.executePost(origDataObject, table, key);
+ } else if (operation.getName().equals("delete")) {
+ ArrayList keyVals = (ArrayList)args[0];
+ this.dataAccessEngine.executeDelete(keyVals, table, key);
+ return null;
+ } else {
+ return null;
+ }
+ }
+}
diff --git a/sandbox/amita/sca/modules/implementation-data-sdo/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/sandbox/amita/sca/modules/implementation-data-sdo/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
new file mode 100644
index 0000000000..5572f23ea7
--- /dev/null
+++ b/sandbox/amita/sca/modules/implementation-data-sdo/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.implementation.sdo.SDOImplementationProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.0#implementation.sdo,model=org.apache.tuscany.sca.implementation.sdo.SDOImplementation \ No newline at end of file
diff --git a/sandbox/amita/sca/modules/implementation-data-sdo/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.sdo.SDOImplementationFactory b/sandbox/amita/sca/modules/implementation-data-sdo/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.sdo.SDOImplementationFactory
new file mode 100644
index 0000000000..9e908ce4f5
--- /dev/null
+++ b/sandbox/amita/sca/modules/implementation-data-sdo/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.sdo.SDOImplementationFactory
@@ -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
+org.apache.tuscany.sca.implementation.sdo.provider.SDOImplementationProviderFactory;model=org.apache.tuscany.sca.implementation.sdo.SDOImplementation \ No newline at end of file
diff --git a/sandbox/amita/sca/modules/implementation-data-sdo/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory b/sandbox/amita/sca/modules/implementation-data-sdo/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory
new file mode 100644
index 0000000000..909cd57f8f
--- /dev/null
+++ b/sandbox/amita/sca/modules/implementation-data-sdo/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
+org.apache.tuscany.sca.implementation.sdo.provider.SDOImplementationProviderFactory;model=org.apache.tuscany.sca.implementation.sdo.SDOImplementation