diff options
author | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2008-08-11 03:32:25 +0000 |
---|---|---|
committer | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2008-08-11 03:32:25 +0000 |
commit | 9fe9a0d09adb6c32391580e66f36c528ae10abe0 (patch) | |
tree | 9b0e758d977a427847a2d50f91296d27bf0a7afd /sandbox/lresende | |
parent | 2a25d97953be52451c073f8abc22034283c6d8c9 (diff) |
Adding spring layer to organization sample application
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@684626 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sandbox/lresende')
8 files changed, 155 insertions, 18 deletions
diff --git a/sandbox/lresende/sca/samples/organization-das/pom.xml b/sandbox/lresende/sca/samples/organization-das/pom.xml index 3799abbbbd..f100e8d647 100644 --- a/sandbox/lresende/sca/samples/organization-das/pom.xml +++ b/sandbox/lresende/sca/samples/organization-das/pom.xml @@ -51,6 +51,34 @@ <scope>runtime</scope> </dependency> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-binding-ws-axis2</artifactId> + <version>1.4-SNAPSHOT</version> + <scope>runtime</scope> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-host-tomcat</artifactId> + <version>1.4-SNAPSHOT</version> + <scope>runtime</scope> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-implementation-spring</artifactId> + <version>1.4-SNAPSHOT</version> + <scope>runtime</scope> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-databinding-sdo</artifactId> + <version>1.4-SNAPSHOT</version> + <scope>compile</scope> + </dependency> + <dependency> <groupId>org.apache.tuscany.sdo</groupId> <artifactId>tuscany-sdo-impl</artifactId> diff --git a/sandbox/lresende/sca/samples/organization-das/src/main/java/org/osoa/services/OrganizationDataService.java b/sandbox/lresende/sca/samples/organization-das/src/main/java/organization/das/OrganizationDataService.java index 1dcf8bf814..e035720769 100644 --- a/sandbox/lresende/sca/samples/organization-das/src/main/java/org/osoa/services/OrganizationDataService.java +++ b/sandbox/lresende/sca/samples/organization-das/src/main/java/organization/das/OrganizationDataService.java @@ -17,10 +17,12 @@ * under the License. */ -package org.osoa.services; +package organization.das; +import org.osoa.sca.annotations.Remotable; import org.soa.types.SchemaInfoType; +@Remotable public interface OrganizationDataService { public commonj.sdo.DataObject findOrganizationBugTwo(java.lang.String id, SchemaInfoType schemaInfo); diff --git a/sandbox/lresende/sca/samples/organization-das/src/main/java/org/osoa/services/OrganizationDataServiceImpl.java b/sandbox/lresende/sca/samples/organization-das/src/main/java/organization/das/OrganizationDataServiceImpl.java index 6f74774dcd..96e9233f66 100644 --- a/sandbox/lresende/sca/samples/organization-das/src/main/java/org/osoa/services/OrganizationDataServiceImpl.java +++ b/sandbox/lresende/sca/samples/organization-das/src/main/java/organization/das/OrganizationDataServiceImpl.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.osoa.services; +package organization.das; import java.io.InputStream; import java.sql.Connection; diff --git a/sandbox/lresende/sca/samples/organization-das/src/main/java/organization/services/OrganizationService.java b/sandbox/lresende/sca/samples/organization-das/src/main/java/organization/services/OrganizationService.java new file mode 100644 index 0000000000..f29d94e30b --- /dev/null +++ b/sandbox/lresende/sca/samples/organization-das/src/main/java/organization/services/OrganizationService.java @@ -0,0 +1,35 @@ +/* + * 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 organization.services; + +import org.osoa.sca.annotations.Remotable; +import org.soa.types.SchemaInfoType; + +import commonj.sdo.DataObject; + +@Remotable +public interface OrganizationService { + + public DataObject findOrganizationBugTwo(String id, SchemaInfoType schemaInfo); + + public DataObject findOrganizationBugOne(String id, SchemaInfoType schemaInfo); + + public void updateOrganization(DataObject organization, SchemaInfoType schemaInfo); +} diff --git a/sandbox/lresende/sca/samples/organization-das/src/main/java/organization/services/OrganizationServiceImpl.java b/sandbox/lresende/sca/samples/organization-das/src/main/java/organization/services/OrganizationServiceImpl.java new file mode 100644 index 0000000000..fe977aff55 --- /dev/null +++ b/sandbox/lresende/sca/samples/organization-das/src/main/java/organization/services/OrganizationServiceImpl.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 organization.services; + +import org.osoa.sca.annotations.Service; +import org.soa.types.SchemaInfoType; + +import organization.das.OrganizationDataService; + +import commonj.sdo.DataObject; + +@Service(OrganizationService.class) +public class OrganizationServiceImpl implements OrganizationService { + + private OrganizationDataService organizationDataService; + + public OrganizationDataService getOrganizationDataService() { + return organizationDataService; + } + + public void setOrganizationDataService(OrganizationDataService organizationDataService) { + this.organizationDataService = organizationDataService; + } + + public DataObject findOrganizationBugTwo(String id, SchemaInfoType schemaInfo) { + return organizationDataService.findOrganizationBugTwo(id, schemaInfo); + } + + public DataObject findOrganizationBugOne(String id, SchemaInfoType schemaInfo) { + return organizationDataService.findOrganizationBugOne(id, schemaInfo); + } + + public void updateOrganization(DataObject organization, SchemaInfoType schemaInfo) { + organizationDataService.updateOrganization(organization, schemaInfo); + } +} diff --git a/sandbox/lresende/sca/samples/organization-das/src/main/resources/organization-spring-context.xml b/sandbox/lresende/sca/samples/organization-das/src/main/resources/organization-spring-context.xml new file mode 100644 index 0000000000..c814afe28b --- /dev/null +++ b/sandbox/lresende/sca/samples/organization-das/src/main/resources/organization-spring-context.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<beans xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:sca="http://www.springframework.org/schema/sca" + xsi:schemaLocation=" + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd + http://www.springframework.org/schema/sca http://www.springframework.org/schema/sca/spring-sca.xsd"> + + <sca:service name="OrganizationService" + type="organization.services.OrganizationService" target="OrganizationServiceBean"/> + + <bean id="OrganizationServiceBean" class="organization.services.OrganizationServiceImpl"> + <property name="organizationDataService" ref="OrganizationDataServiceBean"/> + </bean> + + <bean id="OrganizationDataServiceBean" class="organization.das.OrganizationDataServiceImpl"> + + </bean> +</beans> diff --git a/sandbox/lresende/sca/samples/organization-das/src/main/resources/organization.composite b/sandbox/lresende/sca/samples/organization-das/src/main/resources/organization.composite index e19441aa5d..0113ccf8a0 100644 --- a/sandbox/lresende/sca/samples/organization-das/src/main/resources/organization.composite +++ b/sandbox/lresende/sca/samples/organization-das/src/main/resources/organization.composite @@ -5,17 +5,17 @@ xmlns:soa="http://org.soa.services" name="Organization-Service-Composite"> - <component name="OrganizationServiceComponent"> - <implementation.spring location="Organization-spring-context.xml"/> - <service name="OrganizationService"/> - </component> - <service name="OrganizationService" promote="OrganizationServiceComponent/OrganizationService"> <binding.ws/> </service> + + <component name="OrganizationServiceComponent"> + <implementation.spring location="organization-spring-context.xml"/> + <service name="OrganizationService"/> + </component> <component name="OrganizationDataServiceComponent"> - <implementation.spring location="Organization-spring-context.xml"/> + <implementation.spring location="organization-spring-context.xml"/> </component> diff --git a/sandbox/lresende/sca/samples/organization-das/src/test/java/organization/OrganizationTestCase.java b/sandbox/lresende/sca/samples/organization-das/src/test/java/organization/OrganizationTestCase.java index d6d22787db..f4d8ea1564 100644 --- a/sandbox/lresende/sca/samples/organization-das/src/test/java/organization/OrganizationTestCase.java +++ b/sandbox/lresende/sca/samples/organization-das/src/test/java/organization/OrganizationTestCase.java @@ -21,8 +21,6 @@ package organization; import java.io.InputStream; import java.util.Random; -import junit.framework.Assert; - import org.apache.tuscany.das.rdb.Command; import org.apache.tuscany.das.rdb.DAS; import org.apache.tuscany.sca.host.embedded.SCADomain; @@ -30,6 +28,7 @@ import org.junit.Test; import org.soa.types.SchemaInfoType; import org.soa.types.TypesFactory; +import organization.services.OrganizationService; import util.ConnectionHelper; import commonj.sdo.DataObject; @@ -46,7 +45,7 @@ public class OrganizationTestCase { DataObject root = null; InputStream in = getClass().getClassLoader().getResourceAsStream("organizationConfiguration.xml"); - // Need to put in valid values for your DB + // Need to put in valid values for your DB SchemaInfoType schemaInfo = TypesFactory.INSTANCE.createSchemaInfoType(); schemaInfo.setPASSWORD(""); schemaInfo.setSCHEMA(""); @@ -84,23 +83,25 @@ public class OrganizationTestCase { @Test public void testRetrieveOrganizationSCA() { - /* System.out.println("\n1. Organization-Service-Composite OrganizationClientRunner "); - SCADomain scaDomain = - SCADomain.newInstance("Organization-Service-Composite.composite"); + SCADomain scaDomain = SCADomain.newInstance("organization.composite"); OrganizationService organizationService = scaDomain.getService(OrganizationService.class, "OrganizationServiceComponent"); // Need to put in valid values for your DB - SchemaInfoType schemaInfo = org.soa.types.TypeFactory.INSTANCE.createSchemaInfoType(); + SchemaInfoType schemaInfo = TypesFactory.INSTANCE.createSchemaInfoType(); schemaInfo.setPASSWORD(""); schemaInfo.setSCHEMA(""); schemaInfo.setUSERNAME(""); // This doesn't work. Just retreive account, make a change, then apply changes - //commonj.sdo.DataObject root = organizationService.findOrganizationBugOne("16", schemaInfo); + DataObject root = organizationService.findOrganizationBugOne(id, schemaInfo); + DataObject account = root.getDataObject("ACCOUNT[1]"); + + org.junit.Assert.assertEquals("TestNode2", account.get("ACCOUNT_NAME")); + // This doesn't work either. The root datagraph is null // If you call das.applyChanges for a dataObject that has null as the dataGraph, @@ -110,7 +111,5 @@ public class OrganizationTestCase { //organizationService.updateOrganization(rootOne, schemaInfo); scaDomain.close(); - - */ } } |