From 582fd9c234bb82da33b4071b627fd69e3d256e49 Mon Sep 17 00:00:00 2001 From: lresende Date: Wed, 13 Jan 2010 01:40:20 +0000 Subject: Cleaning up sandbox git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@898601 13f79535-47bb-0310-9956-ffa450edef68 --- sandbox/lresende/backup/company-das/build.xml | 116 ++++++++++++++++ sandbox/lresende/backup/company-das/company.sql | 40 ++++++ sandbox/lresende/backup/company-das/pom.xml | 149 ++++++++++++++++++++ sandbox/lresende/backup/company-das/readme.html | 110 +++++++++++++++ .../company-das/src/main/java/das/DASService.java | 61 ++++++++ .../src/main/java/das/DASServiceClient.java | 48 +++++++ .../src/main/java/das/DASServiceException.java | 37 +++++ .../src/main/java/das/DASServiceImpl.java | 153 +++++++++++++++++++++ .../company-das/src/main/resources/company.xml | 52 +++++++ .../src/main/resources/dasservice.composite | 29 ++++ .../src/main/resources/log4j.properties | 36 +++++ .../src/test/java/das/DASServiceTestCase.java | 53 +++++++ .../company-das/src/test/resources/company.xml | 52 +++++++ .../src/test/resources/log4j.properties | 36 +++++ sandbox/lresende/sca/samples/company-das/build.xml | 116 ---------------- .../lresende/sca/samples/company-das/company.sql | 40 ------ sandbox/lresende/sca/samples/company-das/pom.xml | 149 -------------------- .../lresende/sca/samples/company-das/readme.html | 110 --------------- .../company-das/src/main/java/das/DASService.java | 61 -------- .../src/main/java/das/DASServiceClient.java | 48 ------- .../src/main/java/das/DASServiceException.java | 37 ----- .../src/main/java/das/DASServiceImpl.java | 153 --------------------- .../company-das/src/main/resources/company.xml | 52 ------- .../src/main/resources/dasservice.composite | 29 ---- .../src/main/resources/log4j.properties | 36 ----- .../src/test/java/das/DASServiceTestCase.java | 53 ------- .../company-das/src/test/resources/company.xml | 52 ------- .../src/test/resources/log4j.properties | 36 ----- 28 files changed, 972 insertions(+), 972 deletions(-) create mode 100644 sandbox/lresende/backup/company-das/build.xml create mode 100644 sandbox/lresende/backup/company-das/company.sql create mode 100644 sandbox/lresende/backup/company-das/pom.xml create mode 100644 sandbox/lresende/backup/company-das/readme.html create mode 100644 sandbox/lresende/backup/company-das/src/main/java/das/DASService.java create mode 100644 sandbox/lresende/backup/company-das/src/main/java/das/DASServiceClient.java create mode 100644 sandbox/lresende/backup/company-das/src/main/java/das/DASServiceException.java create mode 100644 sandbox/lresende/backup/company-das/src/main/java/das/DASServiceImpl.java create mode 100644 sandbox/lresende/backup/company-das/src/main/resources/company.xml create mode 100644 sandbox/lresende/backup/company-das/src/main/resources/dasservice.composite create mode 100644 sandbox/lresende/backup/company-das/src/main/resources/log4j.properties create mode 100644 sandbox/lresende/backup/company-das/src/test/java/das/DASServiceTestCase.java create mode 100644 sandbox/lresende/backup/company-das/src/test/resources/company.xml create mode 100644 sandbox/lresende/backup/company-das/src/test/resources/log4j.properties delete mode 100644 sandbox/lresende/sca/samples/company-das/build.xml delete mode 100644 sandbox/lresende/sca/samples/company-das/company.sql delete mode 100644 sandbox/lresende/sca/samples/company-das/pom.xml delete mode 100644 sandbox/lresende/sca/samples/company-das/readme.html delete mode 100644 sandbox/lresende/sca/samples/company-das/src/main/java/das/DASService.java delete mode 100644 sandbox/lresende/sca/samples/company-das/src/main/java/das/DASServiceClient.java delete mode 100644 sandbox/lresende/sca/samples/company-das/src/main/java/das/DASServiceException.java delete mode 100644 sandbox/lresende/sca/samples/company-das/src/main/java/das/DASServiceImpl.java delete mode 100644 sandbox/lresende/sca/samples/company-das/src/main/resources/company.xml delete mode 100644 sandbox/lresende/sca/samples/company-das/src/main/resources/dasservice.composite delete mode 100644 sandbox/lresende/sca/samples/company-das/src/main/resources/log4j.properties delete mode 100644 sandbox/lresende/sca/samples/company-das/src/test/java/das/DASServiceTestCase.java delete mode 100644 sandbox/lresende/sca/samples/company-das/src/test/resources/company.xml delete mode 100644 sandbox/lresende/sca/samples/company-das/src/test/resources/log4j.properties (limited to 'sandbox') diff --git a/sandbox/lresende/backup/company-das/build.xml b/sandbox/lresende/backup/company-das/build.xml new file mode 100644 index 0000000000..704b698aac --- /dev/null +++ b/sandbox/lresende/backup/company-das/build.xml @@ -0,0 +1,116 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/lresende/backup/company-das/company.sql b/sandbox/lresende/backup/company-das/company.sql new file mode 100644 index 0000000000..8fb5c2d4cd --- /dev/null +++ b/sandbox/lresende/backup/company-das/company.sql @@ -0,0 +1,40 @@ +DROP TABLE EMPLOYEE; +DROP TABLE DEPARTMENT; +DROP TABLE COMPANY; + +CREATE TABLE COMPANY ( + ID INT PRIMARY KEY NOT NULL GENERATED ALWAYS AS IDENTITY, + NAME VARCHAR(30)); + +CREATE TABLE DEPARTMENT (ID INT PRIMARY KEY NOT NULL GENERATED ALWAYS AS IDENTITY, + NAME VARCHAR(30), + LOCATION VARCHAR(30), + DEPNUMBER VARCHAR(10), + COMPANYID INT); + +CREATE TABLE EMPLOYEE (ID INT PRIMARY KEY NOT NULL GENERATED ALWAYS AS IDENTITY, + NAME VARCHAR(30), + SN VARCHAR(10), + MANAGER SMALLINT, + DEPARTMENTID INT); + + +INSERT INTO COMPANY (NAME) VALUES('ACME Publishing'); +INSERT INTO COMPANY (NAME) VALUES('Do-rite plumbing'); +INSERT INTO COMPANY (NAME) VALUES('MegaCorp'); + +INSERT INTO DEPARTMENT (NAME, LOCATION, DEPNUMBER, COMPANYID) VALUES('Advanced Technologies','NY','123', 1); +INSERT INTO DEPARTMENT (NAME, LOCATION, DEPNUMBER, COMPANYID) VALUES('Default Name 2','','', 1); +INSERT INTO DEPARTMENT (NAME, LOCATION, DEPNUMBER, COMPANYID) VALUES('Default Name 3','','', 1); +INSERT INTO DEPARTMENT (NAME, LOCATION, DEPNUMBER, COMPANYID) VALUES('Default Name 4','','', 1); +INSERT INTO DEPARTMENT (NAME, LOCATION, DEPNUMBER, COMPANYID) VALUES('Default Name 5','','', 1); +INSERT INTO DEPARTMENT (NAME, LOCATION, DEPNUMBER, COMPANYID) VALUES('Default Name 6','','', 1); +INSERT INTO DEPARTMENT (NAME, LOCATION, DEPNUMBER, COMPANYID) VALUES('Default Name 7','','', 1); +INSERT INTO DEPARTMENT (NAME, LOCATION, DEPNUMBER, COMPANYID) VALUES('Default Name 8','','', 1); + +INSERT INTO EMPLOYEE (NAME, SN, MANAGER, DEPARTMENTID) VALUES('John Jones','E0001', 0, 1); +INSERT INTO EMPLOYEE (NAME, SN, MANAGER, DEPARTMENTID) VALUES('Mary Smith','E0002', 1, null); +INSERT INTO EMPLOYEE (NAME, SN, MANAGER, DEPARTMENTID) VALUES('Jane Doe','E0003', 0, 1); +INSERT INTO EMPLOYEE (NAME, SN, MANAGER, DEPARTMENTID) VALUES('Al Smith','E0004', 1, 1); + + diff --git a/sandbox/lresende/backup/company-das/pom.xml b/sandbox/lresende/backup/company-das/pom.xml new file mode 100644 index 0000000000..2c0ba4da8b --- /dev/null +++ b/sandbox/lresende/backup/company-das/pom.xml @@ -0,0 +1,149 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.1-incubating-SNAPSHOT + ../pom.xml + + + sample-company-das + Apache Tuscany SCA Company Data Access Service Sample + jar + + + + + org.apache.tuscany.sca + tuscany-sca-api + 1.2-incubating-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.2-incubating-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.2-incubating-SNAPSHOT + runtime + + + + org.apache.tuscany.sdo + tuscany-sdo-impl + 1.0-incubating-SNAPSHOT + compile + + + + org.apache.tuscany.das + tuscany-das-rdb + 1.0-incubating-SNAPSHOT + compile + + + + org.apache.derby + derby + 10.1.2.1 + test + + + + junit + junit + 4.2 + test + + + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + + das.DASServiceClient + + + + + + + org.codehaus.mojo + sql-maven-plugin + + 1.1-SNAPSHOT + + + + org.apache.derby + derby + 10.1.2.1 + + + + + + create-db + generate-resources + + execute + + + org.apache.derby.jdbc.EmbeddedDriver + jdbc:derby:${pom.basedir}/target/company_db;create=true + true + continue + skip + ; + + ${pom.basedir}/company.sql + + + + + + + shutdown-database-sothat-test-can-run + process-test-resources + + execute + + + org.apache.derby.jdbc.EmbeddedDriver + jdbc:derby:${pom.basedir}/target/company_db;shutdown=true + true + + + + + + + diff --git a/sandbox/lresende/backup/company-das/readme.html b/sandbox/lresende/backup/company-das/readme.html new file mode 100644 index 0000000000..ec6b492b72 --- /dev/null +++ b/sandbox/lresende/backup/company-das/readme.html @@ -0,0 +1,110 @@ + + + + + +Tuscany RDB DAS exposed as an SCA service + + + + + + + + + + +

Tuscany RDB DAS exposed as an SCA service

+ + +

Introduction

+ +

This is a sample SCA service that exposes DAS functionality.

+

This service would allow you to utilize DAS in a language neutral fashion, consuming existent or adHoc commands.

+ + +

Consuming the DAS service

+ + +

You should add the dependency on your client project pom file

+ + +

+

+
+<!-- DAS Service -->
+<dependency>
+   <groupId>org.apache.tuscany.das.samples</groupId>
+   <artifactId>sample-das-service</artifactId>
+   <version>${pom.version}</version>
+</dependency>
+
+
+

+ +
+

In order to consume the service, you would have to create a SCDL that references it, see sample below:

+ +

+

+
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" name="DASServiceComposite">
+  <component name="DASServiceComponent">
+     <implementation.composite name="DASServiceComposite" jarLocation="lib/sample-das-service-1.0-incubator-SNAPSHOT.jar"/>
+  </component>
+</composite>
+
+
+

+ + +

Sample Architecture

+ +

This service utilizes the following Interface as its definition:

+ + +

+

+
+
+public interface DASService {
+
+    public void configureService(InputStream configStream) throws DASServiceException;
+
+    public DataObject executeCommand(String commandName, Vector commandArguments) throws DASServiceException;
+
+    public DataObject execute(String adHocQuery, Vector commandArguments) throws DASServiceException;
+
+    public void applyChanges(DataObject graphRoot) throws DASServiceException;
+
+}
+
+
+

+ + + + diff --git a/sandbox/lresende/backup/company-das/src/main/java/das/DASService.java b/sandbox/lresende/backup/company-das/src/main/java/das/DASService.java new file mode 100644 index 0000000000..0387341b87 --- /dev/null +++ b/sandbox/lresende/backup/company-das/src/main/java/das/DASService.java @@ -0,0 +1,61 @@ +/* + * 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 das; + +import java.io.InputStream; +import java.util.Vector; + +import commonj.sdo.DataObject; + +public interface DASService { + + /** + * Set DAS configuration file to be used + * @param configStream + * @throws DASServiceException + */ + public void configureService(InputStream configStream) throws DASServiceException; + + /** + * Execute an existing command. The commands are defined in the DAS Configuration file being used by the service + * @param commandName Command name as it appears on the DAS Configuration file + * @param commandArguments Vector with arguments to be used by the command + * @throws DASServiceException + * @return + */ + public DataObject executeCommand(String commandName, Vector commandArguments) throws DASServiceException; + + /** + * Execute a new command, this can be any arbitrary valid query based on the backend implementation (e.g. SQL Query for DAS RDB) + * @param adHocQuery A new command to be executed (e.g SQL Query) + * @param commandArguments Vector with arguments to be used by the command + * @throws DASServiceException + * @return + */ + public DataObject execute(String adHocQuery, Vector commandArguments) throws DASServiceException; + + /** + * Apply all changes on the graph back to the persistent repository. + * This would save the changes on the SDO ChangeSummary back to the database + * Note: Your SDO ojects should have been created with ChangeSummary support + * @param graphRoot SDO Object with changes to be commited to persistent repository + * @throws DASServiceException + */ + public void applyChanges(DataObject graphRoot) throws DASServiceException; +} diff --git a/sandbox/lresende/backup/company-das/src/main/java/das/DASServiceClient.java b/sandbox/lresende/backup/company-das/src/main/java/das/DASServiceClient.java new file mode 100644 index 0000000000..b23731df21 --- /dev/null +++ b/sandbox/lresende/backup/company-das/src/main/java/das/DASServiceClient.java @@ -0,0 +1,48 @@ +/* + * 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 das; + +import java.util.List; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +import commonj.sdo.DataObject; + +public class DASServiceClient { + + public static void main(String[] args) throws Exception { + + SCADomain scaDomain = SCADomain.newInstance("dasservice.composite"); + DASService dasService = scaDomain.getService(DASService.class, "DASServiceComponent"); + + + dasService.configureService(DASServiceClient.class.getClassLoader().getResourceAsStream("company.xml")); + + DataObject root = dasService.executeCommand("all companies", null); + List companyList = root.getList("COMPANY"); + + for(int i=0; i 0){ + //we need to set the arguments + int pos=0; + for(Object argument : commandArguments){ + pos++; + command.setParameter(pos, argument); + } + } + + DataObject root = command.executeQuery(); + + return root; + } + + /** + * Execute a new command, this can be any arbitrary valid query based on the backend implementation (e.g. SQL Query for DAS RDB) + * @param newCommand A new command to be executed (e.g SQL Query) + * @param commandArguments Vector with arguments to be used by the command + * @throws DASServiceException + * @return + */ + public DataObject execute(String adHocQuery, Vector commandArguments) throws DASServiceException { + Command command = this.getDAS().createCommand(adHocQuery); + + if(command == null){ + throw new DASServiceException("Invalid command: " + adHocQuery); + } + + //check if arguments was passed + if(commandArguments != null && commandArguments.size() > 0){ + //we need to set the arguments + int pos=0; + for(Object argument : commandArguments){ + pos++; + command.setParameter(pos, argument); + } + } + DataObject root = command.executeQuery(); + + return root; + } + + /** + * Apply all changes on the graph back to the persistent repository. + * This would save the changes on the SDO ChangeSummary back to the database + * Note: Your SDO ojects should have been created with ChangeSummary support + * @throws DASServiceException + * @param graphRoot SDO Object with changes to be commited to persistent repository + */ + public void applyChanges(DataObject graphRoot) throws DASServiceException{ + // TODO Auto-generated method stub + + } +} diff --git a/sandbox/lresende/backup/company-das/src/main/resources/company.xml b/sandbox/lresende/backup/company-das/src/main/resources/company.xml new file mode 100644 index 0000000000..39935fe025 --- /dev/null +++ b/sandbox/lresende/backup/company-das/src/main/resources/company.xml @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + +
+ + + +
+ + + + + + +
diff --git a/sandbox/lresende/backup/company-das/src/main/resources/dasservice.composite b/sandbox/lresende/backup/company-das/src/main/resources/dasservice.composite new file mode 100644 index 0000000000..06063184c9 --- /dev/null +++ b/sandbox/lresende/backup/company-das/src/main/resources/dasservice.composite @@ -0,0 +1,29 @@ + + + + + + + + + diff --git a/sandbox/lresende/backup/company-das/src/main/resources/log4j.properties b/sandbox/lresende/backup/company-das/src/main/resources/log4j.properties new file mode 100644 index 0000000000..ab4ebbb785 --- /dev/null +++ b/sandbox/lresende/backup/company-das/src/main/resources/log4j.properties @@ -0,0 +1,36 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +# Set root logger level to DEBUG and its only appender to A1. +log4j.rootLogger=INFO, NULL + +# NULL Appender +log4j.appender.NULL=org.apache.log4j.varia.NullAppender + +log4j.appender.NULL.layout=org.apache.log4j.PatternLayout +log4j.appender.NULL.layout.ConversionPattern=[DAS RDB] - %c{1}.%M (%L) : %m %n + +# CONSOLE is set to be a ConsoleAppender. +log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender + +# A1 uses PatternLayout. +log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout +log4j.appender.CONSOLE.layout.ConversionPattern=[DAS RDB] - %c{1}.%M (%L) : %m %n + + +# Print only messages of level WARN or above in the package com.foo. +log4j.logger.org.apache.tuscany=NONE \ No newline at end of file diff --git a/sandbox/lresende/backup/company-das/src/test/java/das/DASServiceTestCase.java b/sandbox/lresende/backup/company-das/src/test/java/das/DASServiceTestCase.java new file mode 100644 index 0000000000..b866336db6 --- /dev/null +++ b/sandbox/lresende/backup/company-das/src/test/java/das/DASServiceTestCase.java @@ -0,0 +1,53 @@ +/* + * 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 das; + +import java.util.List; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +import commonj.sdo.DataObject; + +public class DASServiceTestCase extends TestCase { + + private SCADomain scaDomain; + private DASService dasService; + + @Override + protected void setUp() throws Exception { + scaDomain = SCADomain.newInstance("dasservice.composite"); + dasService = scaDomain.getService(DASService.class, "DASServiceComponent"); + } + + @Override + protected void tearDown() throws Exception { + scaDomain.close(); + } + + public void testDAS() throws Exception{ + dasService.configureService(getClass().getResourceAsStream("/company.xml")); + DataObject root = dasService.executeCommand("all companies", null); + List companyList = root.getList("COMPANY"); + + assertNotNull(companyList); + assertEquals(3,companyList.size()); + } +} diff --git a/sandbox/lresende/backup/company-das/src/test/resources/company.xml b/sandbox/lresende/backup/company-das/src/test/resources/company.xml new file mode 100644 index 0000000000..43da819521 --- /dev/null +++ b/sandbox/lresende/backup/company-das/src/test/resources/company.xml @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + +
+ + + +
+ + + + + + +
diff --git a/sandbox/lresende/backup/company-das/src/test/resources/log4j.properties b/sandbox/lresende/backup/company-das/src/test/resources/log4j.properties new file mode 100644 index 0000000000..ab4ebbb785 --- /dev/null +++ b/sandbox/lresende/backup/company-das/src/test/resources/log4j.properties @@ -0,0 +1,36 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +# Set root logger level to DEBUG and its only appender to A1. +log4j.rootLogger=INFO, NULL + +# NULL Appender +log4j.appender.NULL=org.apache.log4j.varia.NullAppender + +log4j.appender.NULL.layout=org.apache.log4j.PatternLayout +log4j.appender.NULL.layout.ConversionPattern=[DAS RDB] - %c{1}.%M (%L) : %m %n + +# CONSOLE is set to be a ConsoleAppender. +log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender + +# A1 uses PatternLayout. +log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout +log4j.appender.CONSOLE.layout.ConversionPattern=[DAS RDB] - %c{1}.%M (%L) : %m %n + + +# Print only messages of level WARN or above in the package com.foo. +log4j.logger.org.apache.tuscany=NONE \ No newline at end of file diff --git a/sandbox/lresende/sca/samples/company-das/build.xml b/sandbox/lresende/sca/samples/company-das/build.xml deleted file mode 100644 index 704b698aac..0000000000 --- a/sandbox/lresende/sca/samples/company-das/build.xml +++ /dev/null @@ -1,116 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/sandbox/lresende/sca/samples/company-das/company.sql b/sandbox/lresende/sca/samples/company-das/company.sql deleted file mode 100644 index 8fb5c2d4cd..0000000000 --- a/sandbox/lresende/sca/samples/company-das/company.sql +++ /dev/null @@ -1,40 +0,0 @@ -DROP TABLE EMPLOYEE; -DROP TABLE DEPARTMENT; -DROP TABLE COMPANY; - -CREATE TABLE COMPANY ( - ID INT PRIMARY KEY NOT NULL GENERATED ALWAYS AS IDENTITY, - NAME VARCHAR(30)); - -CREATE TABLE DEPARTMENT (ID INT PRIMARY KEY NOT NULL GENERATED ALWAYS AS IDENTITY, - NAME VARCHAR(30), - LOCATION VARCHAR(30), - DEPNUMBER VARCHAR(10), - COMPANYID INT); - -CREATE TABLE EMPLOYEE (ID INT PRIMARY KEY NOT NULL GENERATED ALWAYS AS IDENTITY, - NAME VARCHAR(30), - SN VARCHAR(10), - MANAGER SMALLINT, - DEPARTMENTID INT); - - -INSERT INTO COMPANY (NAME) VALUES('ACME Publishing'); -INSERT INTO COMPANY (NAME) VALUES('Do-rite plumbing'); -INSERT INTO COMPANY (NAME) VALUES('MegaCorp'); - -INSERT INTO DEPARTMENT (NAME, LOCATION, DEPNUMBER, COMPANYID) VALUES('Advanced Technologies','NY','123', 1); -INSERT INTO DEPARTMENT (NAME, LOCATION, DEPNUMBER, COMPANYID) VALUES('Default Name 2','','', 1); -INSERT INTO DEPARTMENT (NAME, LOCATION, DEPNUMBER, COMPANYID) VALUES('Default Name 3','','', 1); -INSERT INTO DEPARTMENT (NAME, LOCATION, DEPNUMBER, COMPANYID) VALUES('Default Name 4','','', 1); -INSERT INTO DEPARTMENT (NAME, LOCATION, DEPNUMBER, COMPANYID) VALUES('Default Name 5','','', 1); -INSERT INTO DEPARTMENT (NAME, LOCATION, DEPNUMBER, COMPANYID) VALUES('Default Name 6','','', 1); -INSERT INTO DEPARTMENT (NAME, LOCATION, DEPNUMBER, COMPANYID) VALUES('Default Name 7','','', 1); -INSERT INTO DEPARTMENT (NAME, LOCATION, DEPNUMBER, COMPANYID) VALUES('Default Name 8','','', 1); - -INSERT INTO EMPLOYEE (NAME, SN, MANAGER, DEPARTMENTID) VALUES('John Jones','E0001', 0, 1); -INSERT INTO EMPLOYEE (NAME, SN, MANAGER, DEPARTMENTID) VALUES('Mary Smith','E0002', 1, null); -INSERT INTO EMPLOYEE (NAME, SN, MANAGER, DEPARTMENTID) VALUES('Jane Doe','E0003', 0, 1); -INSERT INTO EMPLOYEE (NAME, SN, MANAGER, DEPARTMENTID) VALUES('Al Smith','E0004', 1, 1); - - diff --git a/sandbox/lresende/sca/samples/company-das/pom.xml b/sandbox/lresende/sca/samples/company-das/pom.xml deleted file mode 100644 index 2c0ba4da8b..0000000000 --- a/sandbox/lresende/sca/samples/company-das/pom.xml +++ /dev/null @@ -1,149 +0,0 @@ - - - - 4.0.0 - - org.apache.tuscany.sca - tuscany-sca - 1.1-incubating-SNAPSHOT - ../pom.xml - - - sample-company-das - Apache Tuscany SCA Company Data Access Service Sample - jar - - - - - org.apache.tuscany.sca - tuscany-sca-api - 1.2-incubating-SNAPSHOT - - - - org.apache.tuscany.sca - tuscany-host-embedded - 1.2-incubating-SNAPSHOT - - - - org.apache.tuscany.sca - tuscany-implementation-java-runtime - 1.2-incubating-SNAPSHOT - runtime - - - - org.apache.tuscany.sdo - tuscany-sdo-impl - 1.0-incubating-SNAPSHOT - compile - - - - org.apache.tuscany.das - tuscany-das-rdb - 1.0-incubating-SNAPSHOT - compile - - - - org.apache.derby - derby - 10.1.2.1 - test - - - - junit - junit - 4.2 - test - - - - - - - - org.apache.maven.plugins - maven-jar-plugin - - - - das.DASServiceClient - - - - - - - org.codehaus.mojo - sql-maven-plugin - - 1.1-SNAPSHOT - - - - org.apache.derby - derby - 10.1.2.1 - - - - - - create-db - generate-resources - - execute - - - org.apache.derby.jdbc.EmbeddedDriver - jdbc:derby:${pom.basedir}/target/company_db;create=true - true - continue - skip - ; - - ${pom.basedir}/company.sql - - - - - - - shutdown-database-sothat-test-can-run - process-test-resources - - execute - - - org.apache.derby.jdbc.EmbeddedDriver - jdbc:derby:${pom.basedir}/target/company_db;shutdown=true - true - - - - - - - diff --git a/sandbox/lresende/sca/samples/company-das/readme.html b/sandbox/lresende/sca/samples/company-das/readme.html deleted file mode 100644 index ec6b492b72..0000000000 --- a/sandbox/lresende/sca/samples/company-das/readme.html +++ /dev/null @@ -1,110 +0,0 @@ - - - - - -Tuscany RDB DAS exposed as an SCA service - - - - - - - - - - -

Tuscany RDB DAS exposed as an SCA service

- - -

Introduction

- -

This is a sample SCA service that exposes DAS functionality.

-

This service would allow you to utilize DAS in a language neutral fashion, consuming existent or adHoc commands.

- - -

Consuming the DAS service

- - -

You should add the dependency on your client project pom file

- - -

-

-
-<!-- DAS Service -->
-<dependency>
-   <groupId>org.apache.tuscany.das.samples</groupId>
-   <artifactId>sample-das-service</artifactId>
-   <version>${pom.version}</version>
-</dependency>
-
-
-

- -
-

In order to consume the service, you would have to create a SCDL that references it, see sample below:

- -

-

-
-<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" name="DASServiceComposite">
-  <component name="DASServiceComponent">
-     <implementation.composite name="DASServiceComposite" jarLocation="lib/sample-das-service-1.0-incubator-SNAPSHOT.jar"/>
-  </component>
-</composite>
-
-
-

- - -

Sample Architecture

- -

This service utilizes the following Interface as its definition:

- - -

-

-
-
-public interface DASService {
-
-    public void configureService(InputStream configStream) throws DASServiceException;
-
-    public DataObject executeCommand(String commandName, Vector commandArguments) throws DASServiceException;
-
-    public DataObject execute(String adHocQuery, Vector commandArguments) throws DASServiceException;
-
-    public void applyChanges(DataObject graphRoot) throws DASServiceException;
-
-}
-
-
-

- - - - diff --git a/sandbox/lresende/sca/samples/company-das/src/main/java/das/DASService.java b/sandbox/lresende/sca/samples/company-das/src/main/java/das/DASService.java deleted file mode 100644 index 0387341b87..0000000000 --- a/sandbox/lresende/sca/samples/company-das/src/main/java/das/DASService.java +++ /dev/null @@ -1,61 +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 das; - -import java.io.InputStream; -import java.util.Vector; - -import commonj.sdo.DataObject; - -public interface DASService { - - /** - * Set DAS configuration file to be used - * @param configStream - * @throws DASServiceException - */ - public void configureService(InputStream configStream) throws DASServiceException; - - /** - * Execute an existing command. The commands are defined in the DAS Configuration file being used by the service - * @param commandName Command name as it appears on the DAS Configuration file - * @param commandArguments Vector with arguments to be used by the command - * @throws DASServiceException - * @return - */ - public DataObject executeCommand(String commandName, Vector commandArguments) throws DASServiceException; - - /** - * Execute a new command, this can be any arbitrary valid query based on the backend implementation (e.g. SQL Query for DAS RDB) - * @param adHocQuery A new command to be executed (e.g SQL Query) - * @param commandArguments Vector with arguments to be used by the command - * @throws DASServiceException - * @return - */ - public DataObject execute(String adHocQuery, Vector commandArguments) throws DASServiceException; - - /** - * Apply all changes on the graph back to the persistent repository. - * This would save the changes on the SDO ChangeSummary back to the database - * Note: Your SDO ojects should have been created with ChangeSummary support - * @param graphRoot SDO Object with changes to be commited to persistent repository - * @throws DASServiceException - */ - public void applyChanges(DataObject graphRoot) throws DASServiceException; -} diff --git a/sandbox/lresende/sca/samples/company-das/src/main/java/das/DASServiceClient.java b/sandbox/lresende/sca/samples/company-das/src/main/java/das/DASServiceClient.java deleted file mode 100644 index b23731df21..0000000000 --- a/sandbox/lresende/sca/samples/company-das/src/main/java/das/DASServiceClient.java +++ /dev/null @@ -1,48 +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 das; - -import java.util.List; - -import org.apache.tuscany.sca.host.embedded.SCADomain; - -import commonj.sdo.DataObject; - -public class DASServiceClient { - - public static void main(String[] args) throws Exception { - - SCADomain scaDomain = SCADomain.newInstance("dasservice.composite"); - DASService dasService = scaDomain.getService(DASService.class, "DASServiceComponent"); - - - dasService.configureService(DASServiceClient.class.getClassLoader().getResourceAsStream("company.xml")); - - DataObject root = dasService.executeCommand("all companies", null); - List companyList = root.getList("COMPANY"); - - for(int i=0; i 0){ - //we need to set the arguments - int pos=0; - for(Object argument : commandArguments){ - pos++; - command.setParameter(pos, argument); - } - } - - DataObject root = command.executeQuery(); - - return root; - } - - /** - * Execute a new command, this can be any arbitrary valid query based on the backend implementation (e.g. SQL Query for DAS RDB) - * @param newCommand A new command to be executed (e.g SQL Query) - * @param commandArguments Vector with arguments to be used by the command - * @throws DASServiceException - * @return - */ - public DataObject execute(String adHocQuery, Vector commandArguments) throws DASServiceException { - Command command = this.getDAS().createCommand(adHocQuery); - - if(command == null){ - throw new DASServiceException("Invalid command: " + adHocQuery); - } - - //check if arguments was passed - if(commandArguments != null && commandArguments.size() > 0){ - //we need to set the arguments - int pos=0; - for(Object argument : commandArguments){ - pos++; - command.setParameter(pos, argument); - } - } - DataObject root = command.executeQuery(); - - return root; - } - - /** - * Apply all changes on the graph back to the persistent repository. - * This would save the changes on the SDO ChangeSummary back to the database - * Note: Your SDO ojects should have been created with ChangeSummary support - * @throws DASServiceException - * @param graphRoot SDO Object with changes to be commited to persistent repository - */ - public void applyChanges(DataObject graphRoot) throws DASServiceException{ - // TODO Auto-generated method stub - - } -} diff --git a/sandbox/lresende/sca/samples/company-das/src/main/resources/company.xml b/sandbox/lresende/sca/samples/company-das/src/main/resources/company.xml deleted file mode 100644 index 39935fe025..0000000000 --- a/sandbox/lresende/sca/samples/company-das/src/main/resources/company.xml +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - - - - - - - - - - - - - - - -
- - - -
- - - - - - -
diff --git a/sandbox/lresende/sca/samples/company-das/src/main/resources/dasservice.composite b/sandbox/lresende/sca/samples/company-das/src/main/resources/dasservice.composite deleted file mode 100644 index 06063184c9..0000000000 --- a/sandbox/lresende/sca/samples/company-das/src/main/resources/dasservice.composite +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - diff --git a/sandbox/lresende/sca/samples/company-das/src/main/resources/log4j.properties b/sandbox/lresende/sca/samples/company-das/src/main/resources/log4j.properties deleted file mode 100644 index ab4ebbb785..0000000000 --- a/sandbox/lresende/sca/samples/company-das/src/main/resources/log4j.properties +++ /dev/null @@ -1,36 +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. -# -# Set root logger level to DEBUG and its only appender to A1. -log4j.rootLogger=INFO, NULL - -# NULL Appender -log4j.appender.NULL=org.apache.log4j.varia.NullAppender - -log4j.appender.NULL.layout=org.apache.log4j.PatternLayout -log4j.appender.NULL.layout.ConversionPattern=[DAS RDB] - %c{1}.%M (%L) : %m %n - -# CONSOLE is set to be a ConsoleAppender. -log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender - -# A1 uses PatternLayout. -log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout -log4j.appender.CONSOLE.layout.ConversionPattern=[DAS RDB] - %c{1}.%M (%L) : %m %n - - -# Print only messages of level WARN or above in the package com.foo. -log4j.logger.org.apache.tuscany=NONE \ No newline at end of file diff --git a/sandbox/lresende/sca/samples/company-das/src/test/java/das/DASServiceTestCase.java b/sandbox/lresende/sca/samples/company-das/src/test/java/das/DASServiceTestCase.java deleted file mode 100644 index b866336db6..0000000000 --- a/sandbox/lresende/sca/samples/company-das/src/test/java/das/DASServiceTestCase.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 das; - -import java.util.List; - -import junit.framework.TestCase; - -import org.apache.tuscany.sca.host.embedded.SCADomain; - -import commonj.sdo.DataObject; - -public class DASServiceTestCase extends TestCase { - - private SCADomain scaDomain; - private DASService dasService; - - @Override - protected void setUp() throws Exception { - scaDomain = SCADomain.newInstance("dasservice.composite"); - dasService = scaDomain.getService(DASService.class, "DASServiceComponent"); - } - - @Override - protected void tearDown() throws Exception { - scaDomain.close(); - } - - public void testDAS() throws Exception{ - dasService.configureService(getClass().getResourceAsStream("/company.xml")); - DataObject root = dasService.executeCommand("all companies", null); - List companyList = root.getList("COMPANY"); - - assertNotNull(companyList); - assertEquals(3,companyList.size()); - } -} diff --git a/sandbox/lresende/sca/samples/company-das/src/test/resources/company.xml b/sandbox/lresende/sca/samples/company-das/src/test/resources/company.xml deleted file mode 100644 index 43da819521..0000000000 --- a/sandbox/lresende/sca/samples/company-das/src/test/resources/company.xml +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - - - - - - - - - - - - - - - -
- - - -
- - - - - - -
diff --git a/sandbox/lresende/sca/samples/company-das/src/test/resources/log4j.properties b/sandbox/lresende/sca/samples/company-das/src/test/resources/log4j.properties deleted file mode 100644 index ab4ebbb785..0000000000 --- a/sandbox/lresende/sca/samples/company-das/src/test/resources/log4j.properties +++ /dev/null @@ -1,36 +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. -# -# Set root logger level to DEBUG and its only appender to A1. -log4j.rootLogger=INFO, NULL - -# NULL Appender -log4j.appender.NULL=org.apache.log4j.varia.NullAppender - -log4j.appender.NULL.layout=org.apache.log4j.PatternLayout -log4j.appender.NULL.layout.ConversionPattern=[DAS RDB] - %c{1}.%M (%L) : %m %n - -# CONSOLE is set to be a ConsoleAppender. -log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender - -# A1 uses PatternLayout. -log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout -log4j.appender.CONSOLE.layout.ConversionPattern=[DAS RDB] - %c{1}.%M (%L) : %m %n - - -# Print only messages of level WARN or above in the package com.foo. -log4j.logger.org.apache.tuscany=NONE \ No newline at end of file -- cgit v1.2.3