summaryrefslogtreecommitdiffstats
path: root/branches/sca-java-1.4/modules/implementation-data-xml
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--branches/sca-java-1.4/modules/implementation-data-xml/LICENSE205
-rw-r--r--branches/sca-java-1.4/modules/implementation-data-xml/NOTICE6
-rw-r--r--branches/sca-java-1.4/modules/implementation-data-xml/company.sql28
-rw-r--r--branches/sca-java-1.4/modules/implementation-data-xml/pom.xml220
-rw-r--r--branches/sca-java-1.4/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/DATA.java64
-rw-r--r--branches/sca-java-1.4/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/DATACollection.java28
-rw-r--r--branches/sca-java-1.4/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/DATAImplementation.java161
-rw-r--r--branches/sca-java-1.4/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/DATAImplementationFactory.java44
-rw-r--r--branches/sca-java-1.4/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/DATAImplementationProcessor.java132
-rw-r--r--branches/sca-java-1.4/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/jdbc/JDBCHelper.java215
-rw-r--r--branches/sca-java-1.4/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/jdbc/JDBCResultSetStreamReader.java53
-rw-r--r--branches/sca-java-1.4/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/jdbc/ResultSetXmlNodeImpl.java251
-rw-r--r--branches/sca-java-1.4/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/provider/DATAImplementationProvider.java98
-rw-r--r--branches/sca-java-1.4/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/provider/DATAImplementationProviderFactory.java47
-rw-r--r--branches/sca-java-1.4/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/provider/DATAInvoker.java583
-rw-r--r--branches/sca-java-1.4/modules/implementation-data-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor19
-rw-r--r--branches/sca-java-1.4/modules/implementation-data-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory19
-rw-r--r--branches/sca-java-1.4/modules/implementation-data-xml/src/test/java/org/apache/tuscany/sca/implementation/data/DATACollectionTestCaseFIXME.java118
-rw-r--r--branches/sca-java-1.4/modules/implementation-data-xml/src/test/java/org/apache/tuscany/sca/implementation/data/DATAImplementationProcessorTestCase.java133
-rw-r--r--branches/sca-java-1.4/modules/implementation-data-xml/src/test/java/org/apache/tuscany/sca/implementation/data/DATATestCase.java133
-rw-r--r--branches/sca-java-1.4/modules/implementation-data-xml/src/test/java/org/apache/tuscany/sca/implementation/data/companyFeed/CompanyFeed.java62
-rw-r--r--branches/sca-java-1.4/modules/implementation-data-xml/src/test/java/org/apache/tuscany/sca/implementation/data/companyFeed/CompanyFeedTestCaseFIXME.java51
-rw-r--r--branches/sca-java-1.4/modules/implementation-data-xml/src/test/resources/data-feed.composite50
-rw-r--r--branches/sca-java-1.4/modules/implementation-data-xml/src/test/resources/data.composite36
-rw-r--r--branches/sca-java-1.4/modules/implementation-data-xml/src/test/resources/insert.xml9
-rw-r--r--branches/sca-java-1.4/modules/implementation-data-xml/src/test/resources/update.xml7
26 files changed, 0 insertions, 2772 deletions
diff --git a/branches/sca-java-1.4/modules/implementation-data-xml/LICENSE b/branches/sca-java-1.4/modules/implementation-data-xml/LICENSE
deleted file mode 100644
index 8aa906c321..0000000000
--- a/branches/sca-java-1.4/modules/implementation-data-xml/LICENSE
+++ /dev/null
@@ -1,205 +0,0 @@
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- Licensed 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.
-
-
-
diff --git a/branches/sca-java-1.4/modules/implementation-data-xml/NOTICE b/branches/sca-java-1.4/modules/implementation-data-xml/NOTICE
deleted file mode 100644
index fdfa0e9faa..0000000000
--- a/branches/sca-java-1.4/modules/implementation-data-xml/NOTICE
+++ /dev/null
@@ -1,6 +0,0 @@
-${pom.name}
-Copyright (c) 2005 - 2008 The Apache Software Foundation
-
-This product includes software developed by
-The Apache Software Foundation (http://www.apache.org/).
-
diff --git a/branches/sca-java-1.4/modules/implementation-data-xml/company.sql b/branches/sca-java-1.4/modules/implementation-data-xml/company.sql
deleted file mode 100644
index e9f8b06901..0000000000
--- a/branches/sca-java-1.4/modules/implementation-data-xml/company.sql
+++ /dev/null
@@ -1,28 +0,0 @@
---
--- 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.
---
-
-DROP TABLE COMPANY;
-
-CREATE TABLE COMPANY (
- ID INT PRIMARY KEY NOT NULL GENERATED ALWAYS AS IDENTITY,
- NAME VARCHAR(30));
-
-INSERT INTO COMPANY (NAME) VALUES('ACME Publishing');
-INSERT INTO COMPANY (NAME) VALUES('Do-rite plumbing');
-INSERT INTO COMPANY (NAME) VALUES('MegaCorp'); \ No newline at end of file
diff --git a/branches/sca-java-1.4/modules/implementation-data-xml/pom.xml b/branches/sca-java-1.4/modules/implementation-data-xml/pom.xml
deleted file mode 100644
index d65382fccb..0000000000
--- a/branches/sca-java-1.4/modules/implementation-data-xml/pom.xml
+++ /dev/null
@@ -1,220 +0,0 @@
-<?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.
---><project>
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-modules</artifactId>
- <version>1.4</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
- <artifactId>tuscany-implementation-data-xml</artifactId>
- <name>Apache Tuscany SCA Data Implementation Extension</name>
-
- <repositories>
- <repository>
- <id>apache.incubator</id>
- <url>http://people.apache.org/repo/m2-incubating-repository</url>
- </repository>
- </repositories>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.tuscany.das</groupId>
- <artifactId>tuscany-das-rdb</artifactId>
- <version>1.0-SNAPSHOT</version>
- <scope>compile</scope>
- <exclusions>
- <exclusion>
- <groupId>backport-util-concurrent</groupId>
- <artifactId>backport-util-concurrent</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>backport-util-concurrent</groupId>
- <artifactId>backport-util-concurrent</artifactId>
- <version>3.1</version>
- </dependency>
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-assembly</artifactId>
- <version>1.4</version>
- </dependency>
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-core</artifactId>
- <version>1.4</version>
- </dependency>
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-interface</artifactId>
- <version>1.4</version>
- </dependency>
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-assembly-xml</artifactId>
- <version>1.4</version>
- </dependency>
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-contribution-impl</artifactId>
- <version>1.4</version>
- </dependency>
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-sca-api</artifactId>
- <version>1.4</version>
- </dependency>
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-databinding</artifactId>
- <version>1.4</version>
- </dependency>
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-implementation-java-runtime</artifactId>
- <version>1.4</version>
- </dependency>
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-host-embedded</artifactId>
- <version>1.4</version>
- </dependency>
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-data-engine-helper</artifactId>
- <version>1.4</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-binding-atom-abdera</artifactId>
- <version>1.4</version>
- <scope>runtime</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.derby</groupId>
- <artifactId>derby</artifactId>
- <version>10.3.1.4</version>
- <scope>runtime</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-host-jetty</artifactId>
- <version>1.4</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- <version>2.5</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.5</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>org.easymock</groupId>
- <artifactId>easymock</artifactId>
- <version>2.2</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-data-api</artifactId>
- <version>1.4</version>
- <scope>compile</scope>
- </dependency>
- </dependencies>
-
- <build>
- <finalName>${artifactId}</finalName>
-
- <plugins>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>sql-maven-plugin</artifactId>
- <!-- 1.1 due to MOJO-619 -->
- <version>1.1-SNAPSHOT</version>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.derby</groupId>
- <artifactId>derby</artifactId>
- <version>10.1.2.1</version>
- </dependency>
- </dependencies>
-
- <executions>
- <execution>
- <id>create-db</id>
- <phase>generate-resources</phase>
- <goals>
- <goal>execute</goal>
- </goals>
- <configuration>
- <driver>org.apache.derby.jdbc.EmbeddedDriver</driver>
- <url>jdbc:derby:${pom.basedir}/target/test-classes/company;create=true</url>
- <autocommit>true</autocommit>
- <onError>continue</onError>
- <onConnectionError>skip</onConnectionError>
- <delimiter>;</delimiter>
- <srcFiles>
- <srcFile>${pom.basedir}/company.sql</srcFile>
- </srcFiles>
- </configuration>
- </execution>
-
- <!-- Shutdown DB in order to be able to run unit tests -->
- <execution>
- <id>shutdown-database-sothat-test-can-run</id>
- <phase>process-test-resources</phase>
- <goals>
- <goal>execute</goal>
- </goals>
- <configuration>
- <driver>org.apache.derby.jdbc.EmbeddedDriver</driver>
- <url>jdbc:derby:${pom.basedir}/target/test-classes/company;shutdown=true</url>
- <skipOnConnectionError>true</skipOnConnectionError>
- </configuration>
- </execution>
- </executions>
- </plugin>
-
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
-
- <configuration>
- <instructions>
- <Bundle-Version>${tuscany.version}</Bundle-Version>
- <Bundle-SymbolicName>org.apache.tuscany.sca.implementation.data.xml</Bundle-SymbolicName>
- <Bundle-Description>${pom.name}</Bundle-Description>
- <Export-Package>org.apache.tuscany.sca.implementation.data*</Export-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
-</project>
diff --git a/branches/sca-java-1.4/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/DATA.java b/branches/sca-java-1.4/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/DATA.java
deleted file mode 100644
index 3ce96e58da..0000000000
--- a/branches/sca-java-1.4/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/DATA.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * 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.data;
-
-import javax.xml.stream.XMLStreamReader;
-
-/**
- * The service interface of a DAS service provided by DAS components.
- *
- * @version $Rev$ $Date$
- */
-public interface DATA {
-
- /**
- * Retrieve the Database table contents If a id is given, the results will
- * be filtered to a matching row
- *
- * @param id The PK that identifies the row on the table
- * @return The row content in XML format
- */
- XMLStreamReader get(String id);
-
- /**
- * Insert new content in the Database
- *
- * @param insertStream The insertion in XML format
- * @return The number of rows affected
- */
- int insert(XMLStreamReader insertStream);
-
- /**
- * Update the Database table contents
- *
- * @param updateStream The updates in XML format
- * @return The number of rows affected
- */
- int update(XMLStreamReader updateStream);
-
- /**
- * Delete the Database table contents If a id is given, only a specific row
- * will be deleted
- *
- * @param id The PK that identifies the row on the table
- * @return The number of rows affected
- */
- int delete(String id);
-
-}
diff --git a/branches/sca-java-1.4/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/DATACollection.java b/branches/sca-java-1.4/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/DATACollection.java
deleted file mode 100644
index 1dc5673fe5..0000000000
--- a/branches/sca-java-1.4/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/DATACollection.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * 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.data;
-
-import javax.xml.stream.XMLStreamReader;
-
-import org.apache.tuscany.sca.data.collection.Collection;
-
-public interface DATACollection extends Collection<String, XMLStreamReader> {
-
-}
diff --git a/branches/sca-java-1.4/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/DATAImplementation.java b/branches/sca-java-1.4/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/DATAImplementation.java
deleted file mode 100644
index a50ad89b64..0000000000
--- a/branches/sca-java-1.4/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/DATAImplementation.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * 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.data;
-
-import java.sql.Connection;
-import java.sql.DatabaseMetaData;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.ArrayList;
-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.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.data.engine.config.ConnectionInfo;
-import org.apache.tuscany.sca.implementation.data.jdbc.JDBCHelper;
-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;
-
-
-/**
- * The model representing a sample DATA implementation in an SCA assembly model.
- *
- * @version $Rev$ $Date$
- */
-public class DATAImplementation implements Implementation {
- private AssemblyFactory assemblyFactory;
- private JavaInterfaceFactory javaFactory;
-
- private ConnectionInfo connectionInfo;
- private List<Service> services = new ArrayList<Service>();
-
- /**
- * Constructs a new DAS implementation.
- */
- public DATAImplementation(AssemblyFactory assemblyFactory,
- JavaInterfaceFactory javaFactory) {
-
- // DATA implementation provides one service per database table
- // exposing the DATA interface, and have no references and properties
- this.assemblyFactory = assemblyFactory;
- this.javaFactory = javaFactory;
- }
-
- private void introspectServices( AssemblyFactory assemblyFactory, JavaInterfaceFactory javaFactory) {
- Connection connection = null;
- try {
- connection = JDBCHelper.getConnection(connectionInfo);
- DatabaseMetaData databaseMetaData = connection.getMetaData();
- ResultSet tables = databaseMetaData.getTables(null, null, "%", null);
- while(tables.next()) {
- //create the SCA service for the table
- Service dataService = assemblyFactory.createService();
- Service dataCollectionService = assemblyFactory.createService();
-
- dataService.setName(tables.getString(3)+"_DATA");
- dataCollectionService.setName(tables.getString(3));
-
- JavaInterface dataInterface;
- JavaInterface dataCollectionInterface;
-
- try {
- dataInterface = javaFactory.createJavaInterface(DATA.class);
- dataCollectionInterface = javaFactory.createJavaInterface(DATACollection.class);
- } catch (InvalidInterfaceException e) {
- throw new IllegalArgumentException(e);
- }
- JavaInterfaceContract dataInterfaceContract = javaFactory.createJavaInterfaceContract();
- JavaInterfaceContract dataCollectionInterfaceContract = javaFactory.createJavaInterfaceContract();
-
- dataInterfaceContract.setInterface(dataInterface);
- dataCollectionInterfaceContract.setInterface(dataCollectionInterface);
-
- dataService.setInterfaceContract(dataInterfaceContract);
- dataCollectionService.setInterfaceContract(dataCollectionInterfaceContract);
-
- services.add(dataService);
- services.add(dataCollectionService);
-
- }
- } catch(SQLException e) {
-
- } finally {
- JDBCHelper.cleanupResources(connection, null, null);
- }
- }
-
- public ConnectionInfo getConnectionInfo() {
- return this.connectionInfo;
- }
-
- public void setConnectionInfo(ConnectionInfo connectionInfo) {
- this.connectionInfo = connectionInfo;
- }
-
- 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() {
- if(services == null || services.size() == 0) {
- introspectServices(assemblyFactory, javaFactory);
- }
- return services;
- }
-
- public List<Reference> getReferences() {
- // The sample DATA implementation does not support references
- 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/branches/sca-java-1.4/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/DATAImplementationFactory.java b/branches/sca-java-1.4/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/DATAImplementationFactory.java
deleted file mode 100644
index d4cf816dbf..0000000000
--- a/branches/sca-java-1.4/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/DATAImplementationFactory.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * 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.data;
-
-import org.apache.tuscany.sca.assembly.AssemblyFactory;
-import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
-
-/**
- * A default factory for the DATA implementation model.
- *
- * @version $Rev$ $Date$
- */
-public class DATAImplementationFactory {
-
- private AssemblyFactory assemblyFactory;
- private JavaInterfaceFactory javaFactory;
-
- public DATAImplementationFactory(AssemblyFactory assemblyFactory, JavaInterfaceFactory javaFactory) {
- this.assemblyFactory = assemblyFactory;
- this.javaFactory = javaFactory;
- }
-
- public DATAImplementation createDASImplementation() {
- return new DATAImplementation(assemblyFactory, javaFactory);
- }
-
-}
diff --git a/branches/sca-java-1.4/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/DATAImplementationProcessor.java b/branches/sca-java-1.4/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/DATAImplementationProcessor.java
deleted file mode 100644
index 16c5a370ec..0000000000
--- a/branches/sca-java-1.4/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/DATAImplementationProcessor.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * 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.data;
-
-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.interfacedef.java.JavaInterfaceFactory;
-import org.apache.tuscany.sca.monitor.Monitor;
-
-
-/**
- * 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 DATAImplementationProcessor implements StAXArtifactProcessor<DATAImplementation> {
- protected static final QName IMPLEMENTATION_DATA_XML = new QName(Constants.SCA10_TUSCANY_NS, "implementation.data.xml");
-
- private DATAImplementationFactory dataFactory;
- private Monitor monitor;
- private StAXArtifactProcessor<ConnectionInfo> connectionInfoProcessor;
-
- public DATAImplementationProcessor(ModelFactoryExtensionPoint modelFactories, Monitor monitor) {
- AssemblyFactory assemblyFactory = modelFactories.getFactory(AssemblyFactory.class);
- JavaInterfaceFactory javaFactory = modelFactories.getFactory(JavaInterfaceFactory.class);
- this.monitor = monitor;
- this.dataFactory = new DATAImplementationFactory(assemblyFactory, javaFactory);
- this.connectionInfoProcessor = new ConnectionInfoArtifactProcessor(modelFactories, this.monitor);
- }
-
- public QName getArtifactType() {
- // Returns the qname of the XML element processed by this processor
- return IMPLEMENTATION_DATA_XML;
- }
-
- public Class<DATAImplementation> getModelType() {
- // Returns the type of model processed by this processor
- return DATAImplementation.class;
- }
-
- /*
- * <component name="CompanyDataComponent">
- * <implementation.data.xml>
- * <connectionInfo>
- * <connectionProperties
- * driverClass="org.apache.derby.jdbc.EmbeddedDriver"
- * databaseURL="jdbc:derby:target/test-classes/dastest; create = true"
- * loginTimeout="600000"/>
- * </connectionInfo>
- * </implementation.data>
- * </component>
- */
- public DATAImplementation read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
- assert IMPLEMENTATION_DATA_XML.equals(reader.getName());
-
- // Read an <implementation.data.xml> element
-
- // Create an initialize the DAS implementation model
- DATAImplementation implementation = dataFactory.createDASImplementation();
-
- 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_DATA_XML.equals(reader.getName())) {
- return implementation;
- }
- break;
- }
- }
-
- }
-
- public void resolve(DATAImplementation impl, ModelResolver resolver) throws ContributionResolveException {
- }
-
- public void write(DATAImplementation implementation, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException {
- writer.writeStartElement(IMPLEMENTATION_DATA_XML.getNamespaceURI(), IMPLEMENTATION_DATA_XML.getLocalPart());
-
- if (implementation.getConnectionInfo() != null) {
- connectionInfoProcessor.write(implementation.getConnectionInfo(), writer);
- }
-
- writer.writeEndElement();
- }
-}
diff --git a/branches/sca-java-1.4/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/jdbc/JDBCHelper.java b/branches/sca-java-1.4/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/jdbc/JDBCHelper.java
deleted file mode 100644
index 265f250717..0000000000
--- a/branches/sca-java-1.4/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/jdbc/JDBCHelper.java
+++ /dev/null
@@ -1,215 +0,0 @@
-/*
- * 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.data.jdbc;
-
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.Properties;
-
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import javax.sql.DataSource;
-
-import org.apache.tuscany.das.rdb.exception.DataSourceInitializationException;
-import org.apache.tuscany.sca.data.engine.config.ConnectionInfo;
-
-/**
- * JDBC Helper
- * - JDBC Connection utility methods
- * - JDBC Resource cleanup methods
- *
- * @version $Rev$ $Date$
- */
-public class JDBCHelper {
-
- /**
- * protected constructor
- */
- protected JDBCHelper() {
-
- }
-
- /**
- *
- * @param connectionInfo
- * @return
- */
- public static Connection getConnection(ConnectionInfo connectionInfo) {
- if (connectionInfo.getDataSource() == null && connectionInfo.getConnectionProperties() == null) {
- throw new IllegalArgumentException("Not enough information to create Database Connection.");
- }
-
- if(connectionInfo.getDataSource() != null && connectionInfo.getConnectionProperties() != null) {
- throw new IllegalArgumentException("Use either dataSource or ConnectionProperties. Can't use both !");
- }
-
- if(connectionInfo.getDataSource() != null) {
- return getDataSourceConnection(connectionInfo);
- } else {
- return getDriverManagerConnection(connectionInfo);
- }
- }
-
- /**
- * Initializes a DB connection on a managed environment (e.g inside Tomcat)
- *
- * @param connectionInfo
- * @return
- */
- private static Connection getDataSourceConnection(ConnectionInfo connectionInfo) {
- Connection connection = null;
-
- InitialContext ctx;
- try {
- ctx = new InitialContext();
- } catch (NamingException e) {
- throw new RuntimeException(e);
- }
- try {
- DataSource ds = (DataSource) ctx.lookup(connectionInfo.getDataSource());
- try {
- connection = ds.getConnection();
- if (connection == null) {
- throw new RuntimeException("Could not obtain a Connection from DataSource");
- }
- connection.setAutoCommit(false);
- } catch (SQLException e) {
- throw new RuntimeException(e);
- }
- } catch (NamingException e) {
- throw new RuntimeException(e);
- }
-
- return connection;
- }
-
- /**
- * Initialize a DB connection on a J2SE environment
- * For more info, see http://java.sun.com/j2se/1.3/docs/guide/jdbc/getstart/drivermanager.html
- *
- * @param connectionInfo
- * @return
- */
- private static Connection getDriverManagerConnection(ConnectionInfo connectionInfo) {
- Connection connection = null;
-
- if (connectionInfo.getConnectionProperties() == null) {
- throw new RuntimeException("No existing context and no connection properties");
- }
-
- if (connectionInfo.getConnectionProperties().getDriverClass() == null) {
- throw new RuntimeException("No jdbc driver class specified!");
- }
-
- try {
- Properties p = System.getProperties();
- p.put("derby.system.home", "target");
-
- //initialize driver and register it with DriverManager
- Class.forName(connectionInfo.getConnectionProperties().getDriverClass());
-
- //prepare to initialize connection
- String databaseUrl = connectionInfo.getConnectionProperties().getDatabaseURL();
- String userName = connectionInfo.getConnectionProperties().getUsername();
- String userPassword = connectionInfo.getConnectionProperties().getPassword();
- int loginTimeout = connectionInfo.getConnectionProperties().getLoginTimeout();
-
- DriverManager.setLoginTimeout(loginTimeout);
- if( (userName == null || userName.length() ==0) && (userPassword == null || userPassword.length()==0) ){
- //no username or password supplied
- connection = DriverManager.getConnection(databaseUrl);
- }else{
- connection = DriverManager.getConnection(databaseUrl, userName, userPassword);
- }
-
- if(connection == null){
- throw new DataSourceInitializationException("Error initializing connection : null");
- }
-
- //FIXME we should make this flexible, we can't autocommit when participating in transactions
- connection.setAutoCommit(true);
-
- }catch(ClassNotFoundException cnf){
- throw new DataSourceInitializationException("JDBC Driver '" + connectionInfo.getConnectionProperties().getDriverClass() + "' not found", cnf);
- }catch(SQLException sqle){
- throw new DataSourceInitializationException(sqle.getMessage(), sqle);
- }
-
- return connection;
- }
-
- /**
- * Cleanup and close all JDBC resources in the proper order and ignoring erros
- * @param connection The connection to be closed
- * @param queryStatement The statement to be closed
- * @param resultSet The ResultSet to be closed
- */
- public static void cleanupResources(Connection connection, PreparedStatement queryStatement, ResultSet resultSet) {
- cleanupResultSet(resultSet);
- cleanupPreparedStatement(queryStatement);
- cleanupConnection(connection);
- }
-
- /**
- * Proper cleanup the ResultSet
- * @param resultSet
- */
- private static void cleanupResultSet(ResultSet resultSet) {
- if (resultSet != null) {
- try {
- resultSet.close();
- } catch (SQLException e) {
- // We should log the error. Since we're trying to close, we don't re-throw.
- }
- }
- }
-
- /**
- * Proper cleanup the prepared statement
- * @param queryStatement
- */
- private static void cleanupPreparedStatement(PreparedStatement queryStatement) {
- if (queryStatement != null) {
- try {
- queryStatement.close();
- } catch (SQLException e) {
- // We should log the error. Since we're trying to close, we don't re-throw.
- }
- }
- }
-
- /**
- * proper cleanup the connection
- * @param connection
- */
- private static void cleanupConnection(Connection connection) {
- if (connection != null) {
- try {
- connection.close();
- } catch (SQLException e) {
- // We should log the error. Since we're trying to close, we don't re-throw.
- }
- }
- }
-
-}
diff --git a/branches/sca-java-1.4/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/jdbc/JDBCResultSetStreamReader.java b/branches/sca-java-1.4/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/jdbc/JDBCResultSetStreamReader.java
deleted file mode 100644
index 316330243b..0000000000
--- a/branches/sca-java-1.4/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/jdbc/JDBCResultSetStreamReader.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * 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.data.jdbc;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-import javax.xml.stream.XMLStreamException;
-
-import org.apache.tuscany.sca.databinding.xml.XmlTreeStreamReaderImpl;
-
-/**
- * JDBCResultSetStreamReader perform streaming of database tables as XML
- *
- * @version $Rev$ $Date$
- */
-public class JDBCResultSetStreamReader extends XmlTreeStreamReaderImpl {
- private ResultSet resultSet;
-
- /**
- * @param root
- */
- public JDBCResultSetStreamReader(ResultSet resultSet) {
- super(new ResultSetXmlNodeImpl(resultSet));
- this.resultSet = resultSet;
- }
-
- @Override
- public void close() throws XMLStreamException {
- try {
- resultSet.close();
- } catch (SQLException e) {
- }
- }
-}
-
diff --git a/branches/sca-java-1.4/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/jdbc/ResultSetXmlNodeImpl.java b/branches/sca-java-1.4/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/jdbc/ResultSetXmlNodeImpl.java
deleted file mode 100644
index 576fe5605d..0000000000
--- a/branches/sca-java-1.4/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/jdbc/ResultSetXmlNodeImpl.java
+++ /dev/null
@@ -1,251 +0,0 @@
-/*
- * 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.data.jdbc;
-
-import java.sql.ResultSet;
-import java.sql.ResultSetMetaData;
-import java.sql.SQLException;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import javax.xml.namespace.QName;
-
-import org.apache.tuscany.sca.databinding.xml.SimpleXmlNodeImpl;
-import org.apache.tuscany.sca.databinding.xml.XmlNode;
-
-/**
- * @version $Rev$ $Date$
- */
-public class ResultSetXmlNodeImpl implements XmlNode {
- private static final String NS = "";
- private static final QName RESULT_SET = new QName(NS, "resultSet");
- private static final QName RECORD = new QName(NS, "record");
- private static final QName COLUMN = new QName(NS, "column");
- private static final QName NAME = new QName(NS, "name");
-
- private ResultSet resultSet;
- private String[] columnNames;
-
- /**
- * @param resultSet
- */
- public ResultSetXmlNodeImpl(ResultSet resultSet) {
- super();
- this.resultSet = resultSet;
- try {
- ResultSetMetaData metaData = resultSet.getMetaData();
- columnNames = new String[metaData.getColumnCount()];
- for (int i = 0; i < columnNames.length; i++) {
- columnNames[i] = metaData.getColumnName(i + 1);
- }
- } catch (SQLException e) {
- throw new IllegalStateException(e);
- }
- }
-
- /**
- * @see org.apache.tuscany.sca.databinding.xml.XmlNode#attributes()
- */
- public List<XmlNode> attributes() {
- return Collections.emptyList();
- }
-
- public Type getType() {
- return Type.ELEMENT;
- }
-
-
- /**
- * @see org.apache.tuscany.sca.databinding.xml.XmlNode#children()
- */
- public Iterator<XmlNode> children() {
- return new ResultSetIteraror();
- }
-
- private class ResultSetIteraror implements Iterator<XmlNode> {
- private Boolean hasNext;
-
- public ResultSetIteraror() {
- }
-
- public boolean hasNext() {
- try {
- if (hasNext == null) {
- hasNext = resultSet.next();
- }
- return hasNext;
- } catch (SQLException e) {
- throw new IllegalStateException(e);
- }
- }
-
- public XmlNode next() {
- hasNext();
- hasNext = null;
- return new RecordXmlNodeImpl();
- }
-
- public void remove() {
- }
- }
-
- /**
- * @see org.apache.tuscany.sca.databinding.xml.XmlNode#getName()
- */
- public QName getName() {
- return RESULT_SET;
- }
-
- /**
- * @see org.apache.tuscany.sca.databinding.xml.XmlNode#getValue()
- */
- public String getValue() {
- return null;
- }
-
- /**
- * @see org.apache.tuscany.sca.databinding.xml.XmlNode#namespaces()
- */
- public Map<String, String> namespaces() {
- return Collections.emptyMap();
- }
-
- private class RecordXmlNodeImpl extends XmlNodeImpl {
- int index = 0;
-
- @Override
- public Iterator<XmlNode> children() {
- return new Iterator<XmlNode>() {
-
- public boolean hasNext() {
- return index < columnNames.length;
- }
-
- public XmlNode next() {
- return new ColumnXmlNodeImpl(index++);
- }
-
- public void remove() {
- }
-
- };
- }
-
- @Override
- public QName getName() {
- return RECORD;
- }
-
- }
-
- private class ColumnXmlNodeImpl extends XmlNodeImpl {
- private int index;
-
- /**
- * @param index
- */
- public ColumnXmlNodeImpl(int index) {
- super();
- this.index = index;
- }
-
- @Override
- public List<XmlNode> attributes() {
- XmlNode attr = new SimpleXmlNodeImpl(NAME, columnNames[index], XmlNode.Type.ATTRIBUTE);
- return Arrays.asList(attr);
- }
-
- @Override
- public Iterator<XmlNode> children() {
- XmlNode[] nodes = {new ValueXmlNodeImpl(index)};
- return Arrays.asList(nodes).iterator();
- }
-
- @Override
- public QName getName() {
- return COLUMN;
- }
-
- }
-
- private class ValueXmlNodeImpl extends XmlNodeImpl {
- private int index;
-
- /**
- * @param index
- */
- public ValueXmlNodeImpl(int index) {
- super();
- this.index = index;
- }
-
- @Override
- public String getValue() {
- try {
- return String.valueOf(resultSet.getObject(index + 1));
- } catch (SQLException e) {
- throw new IllegalStateException(e);
- }
- }
-
- @Override
- public Type getType() {
- return Type.CHARACTERS;
- }
-
- }
-
- private static abstract class XmlNodeImpl implements XmlNode {
-
- public List<XmlNode> attributes() {
- return Collections.emptyList();
- }
-
- public Iterator<XmlNode> children() {
- return null;
- }
-
- public QName getName() {
- return null;
- }
-
- public String getValue() {
- return null;
- }
-
- public boolean isLeaf() {
- return false;
- }
-
- public Map<String, String> namespaces() {
- return Collections.emptyMap();
- }
-
- public Type getType() {
- return Type.ELEMENT;
- }
-
- }
-
-
-}
diff --git a/branches/sca-java-1.4/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/provider/DATAImplementationProvider.java b/branches/sca-java-1.4/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/provider/DATAImplementationProvider.java
deleted file mode 100644
index bbd963922c..0000000000
--- a/branches/sca-java-1.4/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/provider/DATAImplementationProvider.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * 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.data.provider;
-
-import org.apache.tuscany.sca.implementation.data.DATAImplementation;
-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;
-
-/**
- * DATA Implementation provider
- *
- * @version $Rev$ $Date$
- */
-public class DATAImplementationProvider implements ImplementationProvider {
- //private RuntimeComponent component;
- private DATAImplementation implementation;
-
- /**
- * Constructs a new DATA implementation.
- */
- public DATAImplementationProvider(RuntimeComponent component, DATAImplementation implementation) {
- //this.component = component;
- this.implementation = implementation;
- }
-
- public Invoker createInvoker(RuntimeComponentService service, Operation operation) {
- String operationName = operation.getName();
- String tableName = service.getName();
-
- String interfaceFullName = operation.getInterface().toString();
- int index = interfaceFullName.lastIndexOf(".") + 1;
- String interfaceName = interfaceFullName.substring(index, interfaceFullName.length());
-
- if (interfaceName.equals("DATACollection")) {
-
- if (operationName.equals("getAll")) {
- return new DATAInvoker.GetAllInvoker(operation, implementation.getConnectionInfo(), tableName);
- } else if (operationName.equals("query")) {
- return new DATAInvoker.QueryInvoker(operation, implementation.getConnectionInfo(), tableName);
- } else if (operationName.equals("post")) {
- return new DATAInvoker.PostInvoker(operation, implementation.getConnectionInfo(), tableName);
- } else if (operationName.equals("get")) {
- return new DATAInvoker.GetInvoker(operation, implementation.getConnectionInfo(), tableName);
- } else if (operationName.equals("put")) {
- return new DATAInvoker.PutInvoker(operation, implementation.getConnectionInfo(), tableName);
- } else if (operationName.equals("delete")) {
- return new DATAInvoker.DeleteInvoker(operation, implementation.getConnectionInfo(), tableName);
- }
-
- } else if (interfaceName.equals("DATA")) {
-
- tableName = tableName.split("_")[0];
-
- if (operationName.equals("get")) {
- return new DATAInvoker.GetDATAInvoker(operation, implementation.getConnectionInfo(), tableName);
- } else if (operationName.equals("insert")) {
- return new DATAInvoker.InsertDATAInvoker(operation, implementation.getConnectionInfo(), tableName);
- } else if (operationName.equals("update")) {
- return new DATAInvoker.UpdateDATAInvoker(operation, implementation.getConnectionInfo(), tableName);
- } else if (operationName.equals("delete")) {
- return new DATAInvoker.DeleteDATAInvoker(operation, implementation.getConnectionInfo(), tableName);
- }
- }
-
- return new DATAInvoker(operation, implementation.getConnectionInfo(), tableName);
- }
-
- public boolean supportsOneWayInvocation() {
- return false;
- }
-
- public void start() {
- // System.out.println("Starting " + component.getName());
- }
-
- public void stop() {
- // System.out.println("Stopping " + component.getName());
- }
-}
diff --git a/branches/sca-java-1.4/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/provider/DATAImplementationProviderFactory.java b/branches/sca-java-1.4/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/provider/DATAImplementationProviderFactory.java
deleted file mode 100644
index e1af9ecd92..0000000000
--- a/branches/sca-java-1.4/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/provider/DATAImplementationProviderFactory.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * 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.data.provider;
-
-import org.apache.tuscany.sca.core.ExtensionPointRegistry;
-import org.apache.tuscany.sca.implementation.data.DATAImplementation;
-import org.apache.tuscany.sca.provider.ImplementationProvider;
-import org.apache.tuscany.sca.provider.ImplementationProviderFactory;
-import org.apache.tuscany.sca.runtime.RuntimeComponent;
-
-/**
- * Factory for DATA Implementation Provider
- *
- * @version $Rev$ $Date$
- */
-public class DATAImplementationProviderFactory implements ImplementationProviderFactory<DATAImplementation> {
-
- /**
- * Constructs a new DATA implementation.
- */
- public DATAImplementationProviderFactory(ExtensionPointRegistry extensionPoints) {
- }
-
- public ImplementationProvider createImplementationProvider(RuntimeComponent component, DATAImplementation implementation) {
- return new DATAImplementationProvider(component, implementation);
- }
-
- public Class<DATAImplementation> getModelType() {
- return DATAImplementation.class;
- }
-}
diff --git a/branches/sca-java-1.4/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/provider/DATAInvoker.java b/branches/sca-java-1.4/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/provider/DATAInvoker.java
deleted file mode 100644
index e74bf4d134..0000000000
--- a/branches/sca-java-1.4/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/provider/DATAInvoker.java
+++ /dev/null
@@ -1,583 +0,0 @@
-/*
- * 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.data.provider;
-
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-
-import org.apache.tuscany.sca.data.engine.config.ConnectionInfo;
-import org.apache.tuscany.sca.implementation.data.jdbc.JDBCHelper;
-import org.apache.tuscany.sca.implementation.data.jdbc.JDBCResultSetStreamReader;
-import org.apache.tuscany.sca.interfacedef.Operation;
-import org.apache.tuscany.sca.invocation.Invoker;
-import org.apache.tuscany.sca.invocation.Message;
-import org.osoa.sca.ServiceRuntimeException;
-
-/**
- * Implements a target invoker for DAS component implementations.
- *
- * The target invoker is responsible for dispatching invocations to the particular
- * component implementation logic. The current component implementation will
- * dispatch calls to the DAS APIs to retrieve the requested data from the back-end store
- *
- * @version $Rev$ $Date$
- */
-public class DATAInvoker implements Invoker {
-
- protected final Operation operation;
- protected final ConnectionInfo connectionInfo;
- protected final String table;
-
- public DATAInvoker(Operation operation, ConnectionInfo connectionInfo, String table) {
- this.operation = operation;
- this.connectionInfo = connectionInfo;
- this.table = table;
- }
-
- public Message invoke(Message msg) {
- // Shouldn't get here, as the only supported operations
- // are the ones defined DATA interface and implemented
- // by specific invoker subclasses
-
- throw new UnsupportedOperationException(operation.getName());
- }
-
- /****************************************************************
- *
- * Internal invoker implementations for each supported operation
- *
- *****************************************************************/
- /**
- * GetAll operation invoker
- */
- public static class GetAllInvoker extends DATAInvoker {
-
- public GetAllInvoker(Operation operation, ConnectionInfo connectionInfo, String table) {
- super(operation, connectionInfo, table);
- }
-
- @Override
- public Message invoke(Message msg) {
- return msg;
- }
- }
-
- /**
- * Query operation invoker
- */
- public static class QueryInvoker extends DATAInvoker {
-
- public QueryInvoker(Operation operation, ConnectionInfo connectionInfo, String table) {
- super(operation, connectionInfo, table);
- }
-
- @Override
- public Message invoke(Message msg) {
- return msg;
- }
- }
-
- /**
- * Post operation invoker
- */
- public static class PostInvoker extends DATAInvoker {
-
- public PostInvoker(Operation operation, ConnectionInfo connectionInfo, String table) {
- super(operation, connectionInfo, table);
- }
-
- @Override
- public Message invoke(Message msg) {
-
- StringBuilder sqlInsert = new StringBuilder();
- XMLStreamReader insertStream = (XMLStreamReader) ((Object[]) msg.getBody())[1];
-
- if (insertStream == null) {
- throw new IllegalArgumentException("The XMLStreamReader \"insertStream\" must not be null");
- }
-
-
- Connection connection = null;
- PreparedStatement inStmt = null;
-
- List<String> colNames = new ArrayList<String>();
- List<String> values = new ArrayList<String>();
-
- int result = 0;
- try {
-
- connection = JDBCHelper.getConnection(connectionInfo);
-
- while (insertStream.hasNext()) {
-
- insertStream.next();
- if (insertStream.isStartElement()) {
- if (insertStream.getLocalName().equals("record")) {
- sqlInsert.append("INSERT INTO " + this.table + " (");
- } else if (insertStream.getLocalName().equals("column")) {
- colNames.add(insertStream.getAttributeValue(0));
- insertStream.next();
- if (insertStream.isCharacters()) {
- values.add(insertStream.getText());
- }
- }
- } else if (insertStream.isEndElement() && insertStream.getLocalName().equals("record")) {
- for (String c : colNames) {
- sqlInsert.append(" " + c + ",");
- }
-
- sqlInsert.deleteCharAt(sqlInsert.length() - 1);
- sqlInsert.append(" ) VALUES (");
-
- for (String v : values) {
- sqlInsert.append(" '" + v + "',");
- }
-
- sqlInsert.deleteCharAt(sqlInsert.length() - 1);
- sqlInsert.append(" )");
-
- inStmt = connection.prepareStatement(sqlInsert.toString());
-
- result += inStmt.executeUpdate();
-
- // Clean up resources
- inStmt.close();
- sqlInsert.delete(0, sqlInsert.length());
- values.clear();
- colNames.clear();
- }
- }
- } catch (XMLStreamException e) {
- msg.setFaultBody(new ServiceRuntimeException(e));
- } catch (SQLException sqle) {
- sqle.printStackTrace();
- msg.setFaultBody(new ServiceRuntimeException(sqle.getCause()));
- } catch (Exception e) {
- msg.setFaultBody(new ServiceRuntimeException(e));
- } finally {
- JDBCHelper.cleanupResources(connection, inStmt, null);
- }
-
- msg.setBody(Integer.toString(result));
- return msg;
- }
- }
-
- /**
- * Get operation invoker
- */
- public static class GetInvoker extends DATAInvoker {
-
- public GetInvoker(Operation operation, ConnectionInfo connectionInfo, String table) {
- super(operation, connectionInfo, table);
- }
-
- @Override
- public Message invoke(Message msg) {
-
- // Get an entry
- String sqlQuery = null;
- String id = (String) ((Object[]) msg.getBody())[0];
-
- if (id == null) {
- sqlQuery = "SELECT * FROM " + this.table;
- } else {
- sqlQuery = "SELECT * FROM " + this.table + " WHERE ID = " + id;
- }
-
- Connection connection = null;
- PreparedStatement queryStatement = null;
- ResultSet resultSet = null;
- try {
- connection = JDBCHelper.getConnection(connectionInfo);
- queryStatement = connection.prepareStatement(sqlQuery);
- resultSet = queryStatement.executeQuery();
-
-
- } catch (SQLException sqle) {
- msg.setFaultBody(new ServiceRuntimeException(sqle.getCause()));
- JDBCHelper.cleanupResources(connection, queryStatement, resultSet);
- } catch (Exception e) {
- msg.setFaultBody(new ServiceRuntimeException(e));
- JDBCHelper.cleanupResources(connection, queryStatement, resultSet);
- } finally {
- //default we leave the connection open to pass to the JDBCStreamReader
- }
-
- msg.setBody(new JDBCResultSetStreamReader(resultSet));
- return msg;
- }
- }
-
- /**
- * Put operation invoker
- */
- public static class PutInvoker extends DATAInvoker {
-
- public PutInvoker(Operation operation, ConnectionInfo connectionInfo, String table) {
- super(operation, connectionInfo, table);
- }
-
- @Override
- public Message invoke(Message msg) {
-
- XMLStreamReader updateStream = (XMLStreamReader) ((Object[]) msg.getBody())[1];
-
- if (updateStream == null) {
- throw new IllegalArgumentException("The XMLStreamReader \"updateStream\" must not be null");
- }
-
- Connection connection = null;
- PreparedStatement upStmt = null;
-
- String id = null;
- String columnName = null;
- String newValue = null;
- int result = 0;
-
- try {
- connection = JDBCHelper.getConnection(connectionInfo);
- while (updateStream.hasNext()) {
- updateStream.next();
-
- if (updateStream.isStartElement() && updateStream.getLocalName().equals("column")) {
- columnName = updateStream.getAttributeValue(0);
- updateStream.next();
- if (updateStream.isCharacters()) {
- if (columnName.equals("ID")) {
- id = updateStream.getText();
- } else {
- newValue = updateStream.getText();
-
- upStmt = connection.prepareStatement("UPDATE " + this.table + " SET " + columnName + " = '" + newValue + "' WHERE ID = " + id);
-
- result += upStmt.executeUpdate();
- upStmt.close();
- }
- }
- }
- }
- } catch (XMLStreamException e) {
- msg.setFaultBody(new ServiceRuntimeException(e));
- } catch (SQLException sqle) {
- sqle.printStackTrace();
- msg.setFaultBody(new ServiceRuntimeException(sqle.getCause()));
- } catch (Exception e) {
- msg.setFaultBody(new ServiceRuntimeException(e));
- } finally {
- JDBCHelper.cleanupResources(connection, upStmt, null);
- }
-
- msg.setBody(result);
- return msg;
- }
- }
-
- /**
- * Delete operation invoker
- */
- public static class DeleteInvoker extends DATAInvoker {
-
- public DeleteInvoker(Operation operation, ConnectionInfo connectionInfo, String table) {
- super(operation, connectionInfo, table);
- }
-
- @Override
- public Message invoke(Message msg) {
-
- // Get an entry
- String sqlDelete = null;
- String id = (String) ((Object[]) msg.getBody())[0];
-
- if (id == null) {
- sqlDelete = "DELETE FROM " + this.table;
- } else {
- sqlDelete = "DELETE FROM " + this.table + " WHERE ID = " + id;
- }
-
- Connection connection = null;
- PreparedStatement deleteStatement = null;
- int result = -1;
-
- try {
- connection = JDBCHelper.getConnection(connectionInfo);
- deleteStatement = connection.prepareStatement(sqlDelete);
- result = deleteStatement.executeUpdate();
-
- } catch (SQLException sqle) {
- msg.setFaultBody(new ServiceRuntimeException(sqle.getCause()));
- } catch (Exception e) {
- msg.setFaultBody(new ServiceRuntimeException(e));
- } finally {
- JDBCHelper.cleanupResources(connection, deleteStatement, null);
- }
-
- msg.setBody(result);
- return msg;
- }
- }
- /**
- * Get operation invoker
- *
- * @version $Rev$ $Date$
- */
- public static class GetDATAInvoker extends DATAInvoker {
-
- public GetDATAInvoker(Operation operation, ConnectionInfo connectionInfo, String table) {
- super(operation, connectionInfo, table);
- }
-
- @Override
- public Message invoke(Message msg) {
-
- // Get an entry
- String sqlQuery = null;
- String id = (String) ((Object[]) msg.getBody())[0];
-
- if (id == null) {
- sqlQuery = "SELECT * FROM " + this.table;
- } else {
- sqlQuery = "SELECT * FROM " + this.table + " WHERE ID = " + id;
- }
-
- Connection connection = null;
- PreparedStatement queryStatement = null;
- ResultSet resultSet = null;
- try {
- connection = JDBCHelper.getConnection(connectionInfo);
- queryStatement = connection.prepareStatement(sqlQuery);
- resultSet = queryStatement.executeQuery();
-
-
- } catch (SQLException sqle) {
- msg.setFaultBody(new ServiceRuntimeException(sqle.getCause()));
- JDBCHelper.cleanupResources(connection, queryStatement, resultSet);
- } catch (Exception e) {
- msg.setFaultBody(new ServiceRuntimeException(e));
- JDBCHelper.cleanupResources(connection, queryStatement, resultSet);
- } finally {
- //default we leave the connection open to pass to the JDBCStreamReader
- }
-
- msg.setBody(new JDBCResultSetStreamReader(resultSet));
- return msg;
- }
- }
-
- /**
- * Insert operation invoker
- */
- public static class InsertDATAInvoker extends DATAInvoker {
-
- public InsertDATAInvoker(Operation operation,
- ConnectionInfo connectionInfo, String table) {
- super(operation, connectionInfo, table);
- }
-
- @Override
- public Message invoke(Message msg) throws IllegalArgumentException {
- StringBuilder sqlInsert = new StringBuilder();
- XMLStreamReader insertStream = (XMLStreamReader) ((Object[]) msg.getBody())[0];
-
- if (insertStream == null) {
- throw new IllegalArgumentException("The XMLStreamReader \"insertStream\" must not be null");
- }
-
-
- Connection connection = null;
- PreparedStatement inStmt = null;
-
- List<String> colNames = new ArrayList<String>();
- List<String> values = new ArrayList<String>();
-
- int result = 0;
- try {
-
- connection = JDBCHelper.getConnection(connectionInfo);
-
- while (insertStream.hasNext()) {
-
- insertStream.next();
- if (insertStream.isStartElement()) {
- if (insertStream.getLocalName().equals("record")) {
- sqlInsert.append("INSERT INTO " + this.table + " (");
- } else if (insertStream.getLocalName().equals("column")) {
- colNames.add(insertStream.getAttributeValue(0));
- insertStream.next();
- if (insertStream.isCharacters()) {
- values.add(insertStream.getText());
- }
- }
- } else if (insertStream.isEndElement() && insertStream.getLocalName().equals("record")) {
- for (String c : colNames) {
- sqlInsert.append(" " + c + ",");
- }
-
- sqlInsert.deleteCharAt(sqlInsert.length() - 1);
- sqlInsert.append(" ) VALUES (");
-
- for (String v : values) {
- sqlInsert.append(" '" + v + "',");
- }
-
- sqlInsert.deleteCharAt(sqlInsert.length() - 1);
- sqlInsert.append(" )");
-
- inStmt = connection.prepareStatement(sqlInsert.toString());
- result += inStmt.executeUpdate();
-
- // Clean up resources
- inStmt.close();
- sqlInsert.delete(0, sqlInsert.length());
- values.clear();
- colNames.clear();
- }
- }
- } catch (XMLStreamException e) {
- msg.setFaultBody(new ServiceRuntimeException(e));
- } catch (SQLException sqle) {
- sqle.printStackTrace();
- msg.setFaultBody(new ServiceRuntimeException(sqle.getCause()));
- } catch (Exception e) {
- msg.setFaultBody(new ServiceRuntimeException(e));
- } finally {
- JDBCHelper.cleanupResources(connection, inStmt, null);
- }
-
- msg.setBody(result);
- return msg;
- }
- }
-
- /**
- * Update operation invoker
- */
- public static class UpdateDATAInvoker extends DATAInvoker {
-
- public UpdateDATAInvoker(Operation operation,
- ConnectionInfo connectionInfo, String table) {
- super(operation, connectionInfo, table);
- }
-
- @Override
- public Message invoke(Message msg) throws IllegalArgumentException {
-
- XMLStreamReader updateStream = (XMLStreamReader) ((Object[]) msg.getBody())[0];
-
- if (updateStream == null) {
- throw new IllegalArgumentException("The XMLStreamReader \"updateStream\" must not be null");
- }
-
- Connection connection = null;
- PreparedStatement upStmt = null;
-
- String id = null;
- String columnName = null;
- String newValue = null;
- int result = 0;
-
- try {
- connection = JDBCHelper.getConnection(connectionInfo);
- while (updateStream.hasNext()) {
- updateStream.next();
-
- if (updateStream.isStartElement() && updateStream.getLocalName().equals("column")) {
- columnName = updateStream.getAttributeValue(0);
- updateStream.next();
- if (updateStream.isCharacters()) {
- if (columnName.equals("ID")) {
- id = updateStream.getText();
- } else {
- newValue = updateStream.getText();
-
- upStmt = connection.prepareStatement("UPDATE " + this.table + " SET " + columnName + " = '" + newValue + "' WHERE ID = " + id);
-
- result += upStmt.executeUpdate();
- upStmt.close();
- }
- }
- }
- }
- } catch (XMLStreamException e) {
- msg.setFaultBody(new ServiceRuntimeException(e));
- } catch (SQLException sqle) {
- sqle.printStackTrace();
- msg.setFaultBody(new ServiceRuntimeException(sqle.getCause()));
- } catch (Exception e) {
- msg.setFaultBody(new ServiceRuntimeException(e));
- } finally {
- JDBCHelper.cleanupResources(connection, upStmt, null);
- }
-
- msg.setBody(result);
- return msg;
- }
- }
-
- /**
- * Delete operation invoker
- */
- public static class DeleteDATAInvoker extends DATAInvoker {
-
- public DeleteDATAInvoker(Operation operation, ConnectionInfo connectionInfo, String table) {
- super(operation, connectionInfo, table);
- }
-
- @Override
- public Message invoke(Message msg) {
-
- // Get an entry
- String sqlDelete = null;
- String id = (String) ((Object[]) msg.getBody())[0];
-
- if (id == null) {
- sqlDelete = "DELETE FROM " + this.table;
- } else {
- sqlDelete = "DELETE FROM " + this.table + " WHERE ID = " + id;
- }
-
- Connection connection = null;
- PreparedStatement deleteStatement = null;
- int result = -1;
-
- try {
- connection = JDBCHelper.getConnection(connectionInfo);
- deleteStatement = connection.prepareStatement(sqlDelete);
- result = deleteStatement.executeUpdate();
-
- } catch (SQLException sqle) {
- msg.setFaultBody(new ServiceRuntimeException(sqle.getCause()));
- } catch (Exception e) {
- msg.setFaultBody(new ServiceRuntimeException(e));
- } finally {
- JDBCHelper.cleanupResources(connection, deleteStatement, null);
- }
-
- msg.setBody(result);
- return msg;
- }
- }
-}
diff --git a/branches/sca-java-1.4/modules/implementation-data-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/branches/sca-java-1.4/modules/implementation-data-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
deleted file mode 100644
index 5cd3334e3f..0000000000
--- a/branches/sca-java-1.4/modules/implementation-data-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
+++ /dev/null
@@ -1,19 +0,0 @@
-# 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.data.DATAImplementationProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.0#implementation.data.xml,model=org.apache.tuscany.sca.implementation.data.DATAImplementation
diff --git a/branches/sca-java-1.4/modules/implementation-data-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory b/branches/sca-java-1.4/modules/implementation-data-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory
deleted file mode 100644
index e20f1a6379..0000000000
--- a/branches/sca-java-1.4/modules/implementation-data-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory
+++ /dev/null
@@ -1,19 +0,0 @@
-# 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.data.provider.DATAImplementationProviderFactory;model=org.apache.tuscany.sca.implementation.data.DATAImplementation
diff --git a/branches/sca-java-1.4/modules/implementation-data-xml/src/test/java/org/apache/tuscany/sca/implementation/data/DATACollectionTestCaseFIXME.java b/branches/sca-java-1.4/modules/implementation-data-xml/src/test/java/org/apache/tuscany/sca/implementation/data/DATACollectionTestCaseFIXME.java
deleted file mode 100644
index 458025dd66..0000000000
--- a/branches/sca-java-1.4/modules/implementation-data-xml/src/test/java/org/apache/tuscany/sca/implementation/data/DATACollectionTestCaseFIXME.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * 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.data;
-
-import java.io.FileInputStream;
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamReader;
-import junit.framework.TestCase;
-import org.apache.tuscany.sca.databinding.xml.XMLStreamReader2String;
-import org.apache.tuscany.sca.host.embedded.SCADomain;
-import org.apache.tuscany.sca.implementation.data.DATACollection;
-
-public class DATACollectionTestCaseFIXME extends TestCase {
-
- private SCADomain scaDomain;
- private DATACollection dataService;
-
- /**
- * @throws java.lang.Exception
- */
- @Override
- protected void setUp() throws Exception {
- scaDomain = SCADomain.newInstance("data.composite");
- dataService = scaDomain.getService(DATACollection.class, "DataComponent/COMPANY");
- }
-
- /**
- * @throws java.lang.Exception
- */
- @Override
- protected void tearDown() throws Exception {
- scaDomain.close();
- }
-
- public void testInsert() throws Exception {
- System.out.println(">testInsert");
-
- //Read and process the XML file
- FileInputStream fileInputStream = new FileInputStream("src/test/resources/insert.xml");
- XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(fileInputStream);
-
- String result = dataService.post(null, reader);
- assertEquals(result, "2");
-
- System.out.println("Number of rows inserted: " + result);
-
- reader.close();
- }
-
- public void testGet() throws Exception {
-
- System.out.println(">testGet");
-
- XMLStreamReader reader = dataService.get(null);
- assertNotNull(reader);
- String xml = new XMLStreamReader2String().transform(reader, null);
- System.out.println(xml);
- reader.close();
- }
-
- public void testUpdate() throws Exception {
-
- System.out.println(">testUpdate");
-
- //Read and process the XML file
- FileInputStream fileInputStream = new FileInputStream("src/test/resources/update.xml");
- XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(fileInputStream);
-
- dataService.put(null,reader);
-
- reader.close();
- }
-
- public void testGetByID() throws Exception {
- System.out.println(">testGetByID");
-
- Integer companyID = new Integer(4);
-
- XMLStreamReader reader = dataService.get(companyID.toString());
- assertNotNull(reader);
- String xml = new XMLStreamReader2String().transform(reader, null);
- System.out.println(xml);
- reader.close();
- }
-
- public void testDeleteByID() throws Exception {
- System.out.println(">testDeleteByID");
-
- Integer companyID = new Integer(4);
- dataService.delete(companyID.toString());
- }
-
- public void testDelete() throws Exception {
- System.out.println(">testDelete");
-
- dataService.delete(null);
-
- System.out.println("recreating database...");
- //Helper.createDB();
- System.out.println("done!");
- }
-}
diff --git a/branches/sca-java-1.4/modules/implementation-data-xml/src/test/java/org/apache/tuscany/sca/implementation/data/DATAImplementationProcessorTestCase.java b/branches/sca-java-1.4/modules/implementation-data-xml/src/test/java/org/apache/tuscany/sca/implementation/data/DATAImplementationProcessorTestCase.java
deleted file mode 100644
index dcf87d8c68..0000000000
--- a/branches/sca-java-1.4/modules/implementation-data-xml/src/test/java/org/apache/tuscany/sca/implementation/data/DATAImplementationProcessorTestCase.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * 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.data;
-
-import java.io.StringReader;
-
-import javax.xml.namespace.QName;
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamReader;
-
-import junit.framework.TestCase;
-
-import org.apache.tuscany.sca.assembly.AssemblyFactory;
-import org.apache.tuscany.sca.assembly.Composite;
-import org.apache.tuscany.sca.assembly.SCABindingFactory;
-import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
-import org.apache.tuscany.sca.assembly.builder.impl.CompositeBuilderImpl;
-import org.apache.tuscany.sca.assembly.xml.Constants;
-import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
-import org.apache.tuscany.sca.contribution.processor.DefaultStAXArtifactProcessorExtensionPoint;
-import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
-import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
-import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
-import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
-import org.apache.tuscany.sca.core.UtilityExtensionPoint;
-import org.apache.tuscany.sca.data.engine.config.ConnectionInfo;
-import org.apache.tuscany.sca.data.engine.config.ConnectionProperties;
-import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
-import org.apache.tuscany.sca.interfacedef.impl.InterfaceContractMapperImpl;
-import org.apache.tuscany.sca.policy.IntentAttachPointTypeFactory;
-
-/**
- * @version $Rev: 538445 $ $Date: 2007-05-15 23:20:37 -0700 (Tue, 15 May 2007) $
- */
-public class DATAImplementationProcessorTestCase extends TestCase {
-
- protected static final QName IMPLEMENTATION_DATA = new QName(Constants.SCA10_TUSCANY_NS, "implementation.data.xml");
-
- private static final String COMPOSITE_USING_DATASOURCE =
- "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
- + "<composite xmlns=\"http://www.osoa.org/xmlns/sca/1.0\" xmlns:tuscany=\"http://tuscany.apache.org/xmlns/sca/1.0\" targetNamespace=\"http://data\" name=\"data\">"
- + " <component name=\"DataComponent\">"
- + " <tuscany:implementation.data.xml>"
- + " <tuscany:connectionInfo datasource=\"dataSource\"/>"
- + " </tuscany:implementation.data.xml>"
- + " </component>"
- + "</composite>";
-
- private static final String COMPOSITE_USING_CONNECTION_PROPERTIES =
- "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
- + "<composite xmlns=\"http://www.osoa.org/xmlns/sca/1.0\" xmlns:tuscany=\"http://tuscany.apache.org/xmlns/sca/1.0\" targetNamespace=\"http://data\" name=\"data\">"
- + " <component name=\"DataComponent\">"
- + " <tuscany:implementation.data.xml>"
- + " <tuscany:connectionInfo>"
- + " <tuscany:connectionProperties"
- + " driverClass=\"driverClass\""
- + " databaseURL=\"databaseURL\""
- + " loginTimeout=\"1\"/>"
- + " </tuscany:connectionInfo>"
- + " </tuscany:implementation.data.xml>"
- + " </component>"
- + "</composite>";
-
- private XMLInputFactory inputFactory;
- private StAXArtifactProcessor<Object> staxProcessor;
- private CompositeBuilder compositeBuilder;
-
- @Override
- protected void setUp() throws Exception {
- DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
- inputFactory = XMLInputFactory.newInstance();
- StAXArtifactProcessorExtensionPoint staxProcessors = new DefaultStAXArtifactProcessorExtensionPoint(extensionPoints);
- staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, null, null);
-
- ModelFactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(ModelFactoryExtensionPoint.class);
- AssemblyFactory assemblyFactory = modelFactories.getFactory(AssemblyFactory.class);
- SCABindingFactory scaBindingFactory = modelFactories.getFactory(SCABindingFactory.class);
- UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class);
- InterfaceContractMapper mapper = utilities.getUtility(InterfaceContractMapper.class);
- IntentAttachPointTypeFactory attachPointTypeFactory = modelFactories.getFactory(IntentAttachPointTypeFactory.class);
- compositeBuilder = new CompositeBuilderImpl(assemblyFactory, scaBindingFactory, attachPointTypeFactory, mapper, null);
- }
-
- public void testLoadCompositeUsingDatasource() throws Exception {
- XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(COMPOSITE_USING_DATASOURCE));
-
- Composite composite = (Composite)staxProcessor.read(reader);
- DATAImplementation implementation = (DATAImplementation)composite.getComponents().get(0).getImplementation();
- assertNotNull(implementation);
-
- ConnectionInfo connInfo = implementation.getConnectionInfo();
- assertNotNull(connInfo);
- assertEquals("dataSource", connInfo.getDataSource());
-
- ConnectionProperties connProperties = connInfo.getConnectionProperties();
- assertNull(connProperties);
- }
-
- public void testLoadCompositeUsingConnectionProperties() throws Exception {
- XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(COMPOSITE_USING_CONNECTION_PROPERTIES));
-
- Composite composite = (Composite)staxProcessor.read(reader);
- DATAImplementation implementation = (DATAImplementation)composite.getComponents().get(0).getImplementation();
- assertNotNull(implementation);
-
- ConnectionInfo connInfo = implementation.getConnectionInfo();
- assertNotNull(connInfo);
- assertNull("dataSource", connInfo.getDataSource());
-
- ConnectionProperties connProperties = connInfo.getConnectionProperties();
- assertNotNull(connProperties);
- assertEquals("driverClass",connProperties.getDriverClass());
- assertEquals("databaseURL",connProperties.getDatabaseURL());
- assertEquals(1,connProperties.getLoginTimeout().intValue());
- }
-}
diff --git a/branches/sca-java-1.4/modules/implementation-data-xml/src/test/java/org/apache/tuscany/sca/implementation/data/DATATestCase.java b/branches/sca-java-1.4/modules/implementation-data-xml/src/test/java/org/apache/tuscany/sca/implementation/data/DATATestCase.java
deleted file mode 100644
index 4010cb63d3..0000000000
--- a/branches/sca-java-1.4/modules/implementation-data-xml/src/test/java/org/apache/tuscany/sca/implementation/data/DATATestCase.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * 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.data;
-
-import java.io.FileInputStream;
-
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamReader;
-
-import junit.framework.TestCase;
-
-import org.apache.tuscany.sca.databinding.xml.XMLStreamReader2String;
-import org.apache.tuscany.sca.host.embedded.SCADomain;
-import org.apache.tuscany.sca.implementation.data.DATA;
-
-/**
- * Tests the DAS service
- *
- * @version $Rev$ $Date$
- */
-public class DATATestCase extends TestCase {
- private SCADomain scaDomain;
- private DATA dataService;
-
- /**
- * @throws java.lang.Exception
- */
- @Override
- protected void setUp() throws Exception {
- scaDomain = SCADomain.newInstance("data.composite");
- dataService = scaDomain.getService(DATA.class, "DataComponent/COMPANY_DATA");
- }
-
- /**
- * @throws java.lang.Exception
- */
- @Override
- protected void tearDown() throws Exception {
- scaDomain.close();
- }
-
- public void testInsert() throws Exception {
- System.out.println(">testInsert");
-
- //Read and process the XML file
- FileInputStream fileInputStream = new FileInputStream("src/test/resources/insert.xml");
- XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(fileInputStream);
-
- int result = dataService.insert(reader);
- assertEquals(result,2);
-
- System.out.println("Number of rows inserted: "+result);
-
- reader.close();
- }
-
- public void testGet() throws Exception {
-
- System.out.println(">testGet");
-
- XMLStreamReader reader = dataService.get(null);
- assertNotNull(reader);
- String xml = new XMLStreamReader2String().transform(reader, null);
- System.out.println(xml);
- reader.close();
- }
-
- public void testUpdate() throws Exception {
-
- System.out.println(">testUpdate");
-
- //Read and process the XML file
- FileInputStream fileInputStream = new FileInputStream("src/test/resources/update.xml");
- XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(fileInputStream);
-
- int result = dataService.update(reader);
- assertEquals(result,1);
- System.out.println("Number of rows affected: "+result);
-
- reader.close();
- }
-
- public void testGetByID() throws Exception {
- System.out.println(">testGetByID");
-
- Integer companyID = new Integer(4);
-
- XMLStreamReader reader = dataService.get(companyID.toString());
- assertNotNull(reader);
- String xml = new XMLStreamReader2String().transform(reader, null);
- System.out.println(xml);
- reader.close();
- }
-
- public void testDeleteByID() throws Exception {
- System.out.println(">testDeleteByID");
-
- Integer companyID = new Integer(4);
- int result = dataService.delete(companyID.toString());
- assertEquals(result,1);
- System.out.println("Number of rows deleted: "+result);
- }
-
- public void testDelete() throws Exception {
- System.out.println(">testDelete");
-
- int result = dataService.delete(null);
- assertEquals(result,4);
- System.out.println("Number of rows deleted: "+result);
-
- System.out.println("recreating database...");
- //Helper.createDB();
- System.out.println("done!");
- }
-
-}
diff --git a/branches/sca-java-1.4/modules/implementation-data-xml/src/test/java/org/apache/tuscany/sca/implementation/data/companyFeed/CompanyFeed.java b/branches/sca-java-1.4/modules/implementation-data-xml/src/test/java/org/apache/tuscany/sca/implementation/data/companyFeed/CompanyFeed.java
deleted file mode 100644
index 7f0707c0bc..0000000000
--- a/branches/sca-java-1.4/modules/implementation-data-xml/src/test/java/org/apache/tuscany/sca/implementation/data/companyFeed/CompanyFeed.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * 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.data.companyFeed;
-
-import org.apache.tuscany.sca.data.collection.Collection;
-import org.apache.tuscany.sca.data.collection.Entry;
-import org.apache.tuscany.sca.data.collection.NotFoundException;
-import org.apache.tuscany.sca.implementation.data.DATA;
-import org.osoa.sca.annotations.Reference;
-
-import commonj.sdo.DataObject;
-
-public class CompanyFeed implements Collection<String, DataObject> {
-
- @Reference
- protected DATA dataService;
-
- public Entry<String, DataObject>[] getAll() {
- return null;
- }
-
- public DataObject get(String id) throws NotFoundException{
-
- DataObject data = null;//dataService.get(id);
- if(data == null) {
- throw new NotFoundException();
- } else {
- return data;
- }
- }
-
- public void delete(String id) throws NotFoundException {
- }
-
- public String post(String key, DataObject item) {
- return null;
- }
-
- public void put(String key, DataObject item) throws NotFoundException {
- }
-
- public Entry<String, DataObject>[] query(String queryString) {
- return null;
- }
-}
diff --git a/branches/sca-java-1.4/modules/implementation-data-xml/src/test/java/org/apache/tuscany/sca/implementation/data/companyFeed/CompanyFeedTestCaseFIXME.java b/branches/sca-java-1.4/modules/implementation-data-xml/src/test/java/org/apache/tuscany/sca/implementation/data/companyFeed/CompanyFeedTestCaseFIXME.java
deleted file mode 100644
index b72ff89e3b..0000000000
--- a/branches/sca-java-1.4/modules/implementation-data-xml/src/test/java/org/apache/tuscany/sca/implementation/data/companyFeed/CompanyFeedTestCaseFIXME.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * 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.data.companyFeed;
-
-import java.io.IOException;
-import java.net.Socket;
-
-import junit.framework.TestCase;
-
-import org.apache.tuscany.sca.host.embedded.SCADomain;
-
-/**
- * @version $Rev: 543175 $ $Date: 2007-05-31 09:09:12 -0700 (Thu, 31 May 2007) $
- */
-public class CompanyFeedTestCaseFIXME extends TestCase {
- private SCADomain scaDomain;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- scaDomain = SCADomain.newInstance("data-feed.composite");
- //System.in.read();
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- scaDomain.close();
- }
-
- public void testPing() throws IOException {
- new Socket("127.0.0.1", 8085);
- }
-
-}
diff --git a/branches/sca-java-1.4/modules/implementation-data-xml/src/test/resources/data-feed.composite b/branches/sca-java-1.4/modules/implementation-data-xml/src/test/resources/data-feed.composite
deleted file mode 100644
index 40c755b134..0000000000
--- a/branches/sca-java-1.4/modules/implementation-data-xml/src/test/resources/data-feed.composite
+++ /dev/null
@@ -1,50 +0,0 @@
-<?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"
- xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0"
- targetNamespace="http://data"
- name="data-feed">
-
-
- <service name="CompanyFeed" promote="CompanyFeedComponent">
- <tuscany:binding.atom uri="http://localhost:8085/comnpanyfeed/*"/>
- </service>
-
- <component name="CompanyFeedComponent">
- <implementation.java class="org.apache.tuscany.sca.implementation.data.companyFeed.CompanyFeed"/>
- <reference name="dataService" target="CompanyDataComponent"/>
- </component>
-
- <!-- service name="CompanyDataServiceComponent" promote="CompanyDataComponent">
- <binding.atom uri="http://localhost:8085/comnpanyfeed/"/>
- </service -->
-
- <component name="CompanyDataComponent">
- <tuscany:implementation.data.xml table="company">
- <tuscany:connectionInfo>
- <tuscany:connectionProperties
- driverClass="org.apache.derby.jdbc.EmbeddedDriver"
- databaseURL="jdbc:derby:target/test-classes/company; create = true"
- loginTimeout="600000"/>
- </tuscany:connectionInfo>
- </tuscany:implementation.data.xml>
- </component>
-
-</composite>
diff --git a/branches/sca-java-1.4/modules/implementation-data-xml/src/test/resources/data.composite b/branches/sca-java-1.4/modules/implementation-data-xml/src/test/resources/data.composite
deleted file mode 100644
index f30b15e34c..0000000000
--- a/branches/sca-java-1.4/modules/implementation-data-xml/src/test/resources/data.composite
+++ /dev/null
@@ -1,36 +0,0 @@
-<?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"
- xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0"
- targetNamespace="http://data"
- name="data">
-
- <component name="DataComponent">
- <tuscany:implementation.data.xml>
- <tuscany:connectionInfo>
- <tuscany:connectionProperties
- driverClass="org.apache.derby.jdbc.EmbeddedDriver"
- databaseURL="jdbc:derby:target/test-classes/company; create = true"
- loginTimeout="600000"/>
- </tuscany:connectionInfo>
- </tuscany:implementation.data.xml>
- </component>
-
-</composite>
diff --git a/branches/sca-java-1.4/modules/implementation-data-xml/src/test/resources/insert.xml b/branches/sca-java-1.4/modules/implementation-data-xml/src/test/resources/insert.xml
deleted file mode 100644
index c0a5ada4bf..0000000000
--- a/branches/sca-java-1.4/modules/implementation-data-xml/src/test/resources/insert.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<resultSet>
- <record>
- <column name="NAME">New Coorporation I</column>
- </record>
- <record>
- <column name="NAME">New Coorporation II</column>
- </record>
-</resultSet>
diff --git a/branches/sca-java-1.4/modules/implementation-data-xml/src/test/resources/update.xml b/branches/sca-java-1.4/modules/implementation-data-xml/src/test/resources/update.xml
deleted file mode 100644
index c6cef75274..0000000000
--- a/branches/sca-java-1.4/modules/implementation-data-xml/src/test/resources/update.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<result_set>
- <record>
- <column name="ID">4</column>
- <column name="NAME">Update Coorporation</column>
- </record>
-</result_set>