summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/samples/helloworld-spring/src/main
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2010-07-28 21:01:41 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2010-07-28 21:01:41 +0000
commit9dafe3e2c4d2476cb3ea7789e3f3063418340059 (patch)
treefa543a6cc40ea6ec3ad43ee7f7bf0478685db344 /sca-java-2.x/trunk/samples/helloworld-spring/src/main
parent83d18d1113e87315181b6d9f1daba6146ad12cc9 (diff)
Allow Spring WebApplicationContext to be used by Tuscany
Bring up a sample web application which demonstrates the integration between Spring and Tuscany git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@980218 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/samples/helloworld-spring/src/main')
-rw-r--r--sca-java-2.x/trunk/samples/helloworld-spring/src/main/java/sample/HelloworldImpl.java8
-rw-r--r--sca-java-2.x/trunk/samples/helloworld-spring/src/main/resources/helloworld-context.xml4
-rw-r--r--sca-java-2.x/trunk/samples/helloworld-spring/src/main/resources/helloworld.composite7
3 files changed, 15 insertions, 4 deletions
diff --git a/sca-java-2.x/trunk/samples/helloworld-spring/src/main/java/sample/HelloworldImpl.java b/sca-java-2.x/trunk/samples/helloworld-spring/src/main/java/sample/HelloworldImpl.java
index ac03ea3ca6..a44dcacc3a 100644
--- a/sca-java-2.x/trunk/samples/helloworld-spring/src/main/java/sample/HelloworldImpl.java
+++ b/sca-java-2.x/trunk/samples/helloworld-spring/src/main/java/sample/HelloworldImpl.java
@@ -18,11 +18,17 @@
*/
package sample;
+import org.oasisopen.sca.annotation.Reference;
public class HelloworldImpl implements Helloworld {
+ @Reference(required = false)
+ private DateService dateService;
public String sayHello(String name) {
- return "Hello " + name;
+ if (dateService == null) {
+ return "Hello " + name;
+ }
+ return "[" + dateService.getDate() + "] Hello " + name;
}
}
diff --git a/sca-java-2.x/trunk/samples/helloworld-spring/src/main/resources/helloworld-context.xml b/sca-java-2.x/trunk/samples/helloworld-spring/src/main/resources/helloworld-context.xml
index 89b2cfb6f5..b5fba07d66 100644
--- a/sca-java-2.x/trunk/samples/helloworld-spring/src/main/resources/helloworld-context.xml
+++ b/sca-java-2.x/trunk/samples/helloworld-spring/src/main/resources/helloworld-context.xml
@@ -24,7 +24,9 @@
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/sca http://www.osoa.org/xmlns/sca/1.0/spring-sca.xsd">
- <bean id="testBean" class="sample.HelloworldImpl" lazy-init="true">
+ <bean id="testBean" class="sample.HelloworldImpl">
</bean>
+
+ <sca:reference name="dateService" type="sample.DateService"/>
</beans> \ No newline at end of file
diff --git a/sca-java-2.x/trunk/samples/helloworld-spring/src/main/resources/helloworld.composite b/sca-java-2.x/trunk/samples/helloworld-spring/src/main/resources/helloworld.composite
index 33895dde25..0900c63a84 100644
--- a/sca-java-2.x/trunk/samples/helloworld-spring/src/main/resources/helloworld.composite
+++ b/sca-java-2.x/trunk/samples/helloworld-spring/src/main/resources/helloworld.composite
@@ -19,11 +19,14 @@
-->
<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
targetNamespace="http://sample"
- xmlns:hns="http://tuscany.apache.org/implementation/bpel/example/helloworld"
name="helloworld">
<component name="HelloworldComponent">
<implementation.spring location="helloworld-context.xml"/>
+ <reference name="dateService" target="DateServiceComponent"/>
+ </component>
+
+ <component name="DateServiceComponent">
+ <implementation.java class="sample.DateServiceImpl"/>
</component>
-
</composite>