summaryrefslogtreecommitdiffstats
path: root/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension
diff options
context:
space:
mode:
authorlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2009-11-11 23:07:19 +0000
committerlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2009-11-11 23:07:19 +0000
commit6fadbc9cd1fcf03d0b3630f772d91df149b70428 (patch)
tree32752e491abb97fc8ef4f246455e3b5fd2814862 /sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension
parent5559ef5edbf8d3616f7a4b497b2a459b0ee4082b (diff)
Moving 1.x branches
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@835123 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension')
-rw-r--r--sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/DISCLAIMER8
-rw-r--r--sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/LICENSE205
-rw-r--r--sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/NOTICE6
-rw-r--r--sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/README70
-rw-r--r--sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/build.xml51
-rw-r--r--sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/pom.xml77
-rw-r--r--sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/main/java/pojo/POJOImplementation.java65
-rw-r--r--sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/main/java/pojo/POJOImplementationFactory.java36
-rw-r--r--sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/main/java/pojo/impl/POJOImplementationFactoryImpl.java36
-rw-r--r--sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/main/java/pojo/impl/POJOImplementationImpl.java156
-rw-r--r--sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/main/java/pojo/impl/POJOImplementationProcessor.java173
-rw-r--r--sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/main/java/pojo/provider/POJOImplementationInvoker.java51
-rw-r--r--sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/main/java/pojo/provider/POJOImplementationProvider.java96
-rw-r--r--sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/main/java/pojo/provider/POJOImplementationProviderFactory.java45
-rw-r--r--sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor19
-rw-r--r--sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema19
-rw-r--r--sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory19
-rw-r--r--sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/main/resources/META-INF/services/pojo.POJOImplementationFactory19
-rw-r--r--sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/main/resources/sample-implementation-pojo.xsd38
-rw-r--r--sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/test/java/helloworld/HelloWorld.java26
-rw-r--r--sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/test/java/helloworld/HelloWorldImpl.java37
-rw-r--r--sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/test/java/helloworld/HelloWorldImpl2.java37
-rw-r--r--sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/test/java/helloworld/HelloWorldTestCase.java50
-rw-r--r--sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/test/resources/helloworld/HelloWorldImpl2.componentType26
-rw-r--r--sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/test/resources/helloworld/helloworld.composite33
25 files changed, 1398 insertions, 0 deletions
diff --git a/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/DISCLAIMER b/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/DISCLAIMER
new file mode 100644
index 0000000000..d68a410903
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/DISCLAIMER
@@ -0,0 +1,8 @@
+Apache Tuscany is an effort undergoing incubation at The Apache Software
+Foundation (ASF), sponsored by the Apache Web Services PMC. Incubation is
+required of all newly accepted projects until a further review indicates that
+the infrastructure, communications, and decision making process have stabilized
+in a manner consistent with other successful ASF projects. While incubation
+status is not necessarily a reflection of the completeness or stability of the
+code, it does indicate that the project has yet to be fully endorsed by the ASF.
+
diff --git a/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/LICENSE b/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/LICENSE
@@ -0,0 +1,205 @@
+
+ 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/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/NOTICE b/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/NOTICE
new file mode 100644
index 0000000000..94481d6cfa
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2007 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/README b/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/README
new file mode 100644
index 0000000000..3b201779e1
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/README
@@ -0,0 +1,70 @@
+Implementation POJO Sample
+==========================
+This sample demonstrates how new implementation types are constructed for
+Apache Tuscany SCA.
+
+The README in the samples directory (the directory above this) provides
+general instructions about building and running samples. Take a look there
+first.
+
+Sample Overview
+---------------
+This sample contains a POJO implementation type as an example of how to create
+new implementation types.
+
+implementation-pojo-extension/
+ src/
+ main/
+ java/
+ pojo/ - implementation model interfaces
+ impl/ - implementations of the model interfaces
+ provider/ - runtime implementation
+ resources/
+ META-INF/
+ services/ - declares the extension
+ test/
+ java/
+ helloworld/
+ HelloWorldTestCase.java - JUnit test case
+ resources/
+ helloworld.composite - the SCA assembly used during unit testing
+
+ build.xml - the Ant build file
+ pom.xml - the Maven build file
+
+Building The Sample Extension Using Ant
+-----------------------------------------
+With the binary distribution the sample extension can be built using Ant as
+follows
+
+cd implementation-pojo-extension
+ant compile
+
+Building The Sample Using Maven
+-------------------------------------------
+With either the binary or source distributions the sample can be built
+using Maven as follows.
+
+cd implementation-pojo-extension
+mvn
+
+Maven will also test that the sample extension built properly. You should see
+the following output from the test phase.
+
+-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running helloworld.HelloWorldTestCase
+Initializing POJO
+Initializing POJO
+Executing POJO sayHello
+Initializing POJO
+Initializing POJO
+Executing POJO sayHello
+Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.616 sec
+
+Results :
+
+Tests run: 2, Failures: 0, Errors: 0, Skipped: 0
+
+This shows that the Junit test cases have run successfully.
diff --git a/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/build.xml b/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/build.xml
new file mode 100644
index 0000000000..78bae79859
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/build.xml
@@ -0,0 +1,51 @@
+<!--
+ * 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 name="implementation-pojo-extension" default="compile">
+ <property name="test.jar" value="sample-implementation-pojo-extension.jar" />
+
+ <target name="init">
+ <mkdir dir="target/classes"/>
+ </target>
+
+ <target name="compile" depends="init">
+ <javac srcdir="src/main/java"
+ destdir="target/classes"
+ debug="on"
+ source="1.5"
+ target="1.5">
+ <classpath>
+ <pathelement location="../../lib/tuscany-sca-manifest.jar"/>
+ </classpath>
+ </javac>
+ <copy todir="target/classes">
+ <fileset dir="src/main/resources"/>
+ </copy>
+ <jar destfile="target/${test.jar}" basedir="target/classes">
+ <manifest>
+ <attribute name="Main-Class" value="${test.class}" />
+ </manifest>
+ </jar>
+ </target>
+
+ <target name="clean">
+ <delete quiet="true" includeemptydirs="true">
+ <fileset dir="target"/>
+ </delete>
+ </target>
+</project>
diff --git a/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/pom.xml b/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/pom.xml
new file mode 100644
index 0000000000..61c9040520
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/pom.xml
@@ -0,0 +1,77 @@
+<?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-sca</artifactId>
+ <version>1.0.1-incubating-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+ <artifactId>sample-implementation-pojo-extension</artifactId>
+ <name>Apache Tuscany SCA POJO Implementation Extension Sample</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.sca</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ <version>1.0.1-incubating-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-java-xml</artifactId>
+ <version>1.0.1-incubating-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-spi</artifactId>
+ <version>1.0.1-incubating-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-embedded</artifactId>
+ <version>1.0.1-incubating-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.2</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ </build>
+
+</project>
diff --git a/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/main/java/pojo/POJOImplementation.java b/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/main/java/pojo/POJOImplementation.java
new file mode 100644
index 0000000000..7c2f5d236f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/main/java/pojo/POJOImplementation.java
@@ -0,0 +1,65 @@
+/*
+ * 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 pojo;
+
+import java.lang.reflect.Method;
+import java.util.Map;
+
+import org.apache.tuscany.sca.assembly.Implementation;
+
+
+/**
+ * Represents a POJO implementation in an SCA assembly.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface POJOImplementation extends Implementation {
+
+ /**
+ * Returns the POJO class name
+ * @return
+ */
+ public String getPOJOName();
+
+ /**
+ * Sets the POJO class name
+ * @param pojoName
+ */
+ public void setPOJOName(String pojoName);
+
+ /**
+ * Returns the POJO class.
+ * @return
+ */
+ public Class<?> getPOJOClass();
+
+ /**
+ * Sets the POJO class.
+ * @param pojoClass
+ */
+ public void setPOJOClass(Class<?> pojoClass);
+
+ /**
+ * Returns the POJO's methods.
+ * @return
+ */
+ public Map<String, Method> getMethods();
+
+}
diff --git a/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/main/java/pojo/POJOImplementationFactory.java b/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/main/java/pojo/POJOImplementationFactory.java
new file mode 100644
index 0000000000..bbcfb3d0dc
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/main/java/pojo/POJOImplementationFactory.java
@@ -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.
+ */
+
+package pojo;
+
+
+/**
+ * Factory for the POJO implementation model.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface POJOImplementationFactory {
+
+ /**
+ * Creates a new POJO implementation model object.
+ * @return a new POJO implementation model object
+ */
+ POJOImplementation createPOJOImplementation();
+
+}
diff --git a/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/main/java/pojo/impl/POJOImplementationFactoryImpl.java b/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/main/java/pojo/impl/POJOImplementationFactoryImpl.java
new file mode 100644
index 0000000000..0dad270a6c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/main/java/pojo/impl/POJOImplementationFactoryImpl.java
@@ -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.
+ */
+
+package pojo.impl;
+
+import pojo.POJOImplementation;
+import pojo.POJOImplementationFactory;
+
+/**
+ * A factory for the POJO implementation model.
+ *
+ * @version $Rev$ $Date$
+ */
+public class POJOImplementationFactoryImpl implements POJOImplementationFactory {
+
+ public POJOImplementation createPOJOImplementation() {
+ return new POJOImplementationImpl();
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/main/java/pojo/impl/POJOImplementationImpl.java b/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/main/java/pojo/impl/POJOImplementationImpl.java
new file mode 100644
index 0000000000..b5682673f6
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/main/java/pojo/impl/POJOImplementationImpl.java
@@ -0,0 +1,156 @@
+/*
+ * 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 pojo.impl;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.sca.assembly.ConstrainingType;
+import org.apache.tuscany.sca.assembly.Property;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.Service;
+
+import pojo.POJOImplementation;
+
+
+/**
+ * Represents a POJO implementation in an SCA assembly.
+ *
+ * @version $Rev$ $Date$
+ */
+class POJOImplementationImpl implements POJOImplementation {
+
+ private String pojoName;
+ private Class<?> pojoClass;
+ private String uri;
+ private Map<String, Method> methods;
+ private List<Service> services = new ArrayList<Service>();
+ private List<Reference> references = new ArrayList<Reference>();
+ private List<Property> properties = new ArrayList<Property>();
+ private boolean unresolved;
+
+ POJOImplementationImpl() {
+ }
+
+ /**
+ * Returns the POJO class name
+ * @return
+ */
+ public String getPOJOName() {
+ return pojoName;
+ }
+
+ /**
+ * Sets the POJO class name
+ * @param pojoName
+ */
+ public void setPOJOName(String pojoName) {
+ this.pojoName = pojoName;
+ setURI(pojoName.replace('.', '/'));
+ }
+
+ /**
+ * Returns the POJO class.
+ * @return
+ */
+ public Class<?> getPOJOClass() {
+ return pojoClass;
+ }
+
+ /**
+ * Sets the POJO class.
+ * @param pojoClass
+ */
+ public void setPOJOClass(Class<?> pojoClass) {
+ this.pojoClass = pojoClass;
+ setPOJOName(pojoClass.getName());
+
+ // Index the POJO's methods
+ methods = new HashMap<String, Method>();
+ Method[] m = pojoClass.getMethods();
+ for (int i = 0; i < m.length; i++) {
+ methods.put(m[i].getName(), m[i]);
+ }
+ }
+
+ /**
+ * Returns the POJO's methods.
+ * @return
+ */
+ public Map<String, Method> getMethods() {
+ return methods;
+ }
+
+ public ConstrainingType getConstrainingType() {
+ // The sample POJO implementation does not support constrainingTypes
+ return null;
+ }
+
+ public List<Property> getProperties() {
+ return properties;
+ }
+
+ public List<Service> getServices() {
+ return services;
+ }
+
+ public List<Reference> getReferences() {
+ return references;
+ }
+
+ public String getURI() {
+ return uri;
+ }
+
+ public void setConstrainingType(ConstrainingType constrainingType) {
+ // The sample POJO implementation does not support constrainingTypes
+ }
+
+ public void setURI(String uri) {
+ this.uri = uri;
+ }
+
+ public boolean isUnresolved() {
+ return unresolved;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ this.unresolved = unresolved;
+ }
+
+ @Override
+ public int hashCode() {
+ return uri.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof POJOImplementationImpl) {
+ return ((POJOImplementationImpl)obj).getURI().equals(uri);
+ } else {
+ return false;
+ }
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/main/java/pojo/impl/POJOImplementationProcessor.java b/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/main/java/pojo/impl/POJOImplementationProcessor.java
new file mode 100644
index 0000000000..d388fae6d3
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/main/java/pojo/impl/POJOImplementationProcessor.java
@@ -0,0 +1,173 @@
+/*
+ * 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 pojo.impl;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+
+import javax.xml.namespace.QName;
+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.ComponentType;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.assembly.xml.PolicyAttachPointProcessor;
+import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ClassReference;
+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.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;
+import org.apache.tuscany.sca.policy.PolicyFactory;
+
+import pojo.POJOImplementation;
+import pojo.POJOImplementationFactory;
+
+/**
+ * Implements a STAX based artifact processor for POJO implementations.
+ *
+ * The artifact processor is responsible for processing <implementation.pojo>
+ * elements in SCA assembly XML composite files and populating the POJO
+ * implementation model, resolving its references to other artifacts in the SCA
+ * contribution, and optionally write the model back to SCA assembly XML.
+ */
+public class POJOImplementationProcessor implements StAXArtifactProcessor<POJOImplementation> {
+ private static final QName IMPLEMENTATION_POJO = new QName("http://pojo", "implementation.pojo");
+
+ private AssemblyFactory assemblyFactory;
+ private JavaInterfaceFactory javaFactory;
+ private POJOImplementationFactory pojoImplementationFactory;
+ private PolicyFactory policyFactory;
+ private PolicyAttachPointProcessor policyProcessor;
+
+ public POJOImplementationProcessor(ModelFactoryExtensionPoint modelFactories) {
+
+ // Get the assembly and Java interface factories as we'll need them to
+ // create model objects
+ assemblyFactory = modelFactories.getFactory(AssemblyFactory.class);
+ javaFactory = modelFactories.getFactory(JavaInterfaceFactory.class);
+ policyFactory = modelFactories.getFactory(PolicyFactory.class);
+ pojoImplementationFactory = modelFactories.getFactory(POJOImplementationFactory.class);
+ policyProcessor = new PolicyAttachPointProcessor(policyFactory);
+ }
+
+ public QName getArtifactType() {
+ // Returns the qname of the XML element processed by this processor
+ return IMPLEMENTATION_POJO;
+ }
+
+ public Class<POJOImplementation> getModelType() {
+ // Returns the type of model processed by this processor
+ return POJOImplementation.class;
+ }
+
+ public POJOImplementation read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
+
+ // Read an <implementation.pojo> element
+ POJOImplementation implementation = pojoImplementationFactory.createPOJOImplementation();
+
+ // Read policies
+ policyProcessor.readPolicies(implementation, reader);
+
+ // Read the POJO class attribute.
+ String className = reader.getAttributeValue(null, "class");
+ implementation.setPOJOName(className);
+
+ // Mark the POJO model unresolved to track the fact that it's not
+ // completely initialized, its class is not loaded yet and services
+ // and references not initialized either
+ implementation.setUnresolved(true);
+
+ // Skip to end element
+ while (reader.hasNext()) {
+ if (reader.next() == END_ELEMENT && IMPLEMENTATION_POJO.equals(reader.getName())) {
+ break;
+ }
+ }
+
+ return implementation;
+ }
+
+ public void resolve(POJOImplementation implementation, ModelResolver resolver) throws ContributionResolveException {
+
+ // Resolve the POJO implementation
+
+ // First resolve its class
+ ClassReference classReference = new ClassReference(implementation.getPOJOName());
+ classReference = resolver.resolveModel(ClassReference.class, classReference);
+ Class pojoClass = classReference.getJavaClass();
+ if (pojoClass == null) {
+ throw new ContributionResolveException("Class could not be resolved: " + implementation.getPOJOName());
+ }
+ implementation.setPOJOClass(pojoClass);
+
+ // Check to see if we have a .componentType file describing the POJO class
+ ComponentType componentType = assemblyFactory.createComponentType();
+ componentType.setUnresolved(true);
+ componentType.setURI(implementation.getURI() + ".componentType");
+ componentType = resolver.resolveModel(ComponentType.class, componentType);
+ if (!componentType.isUnresolved()) {
+
+ // We have a component type description, merge it into the POJO model
+ implementation.getServices().addAll(componentType.getServices());
+ implementation.getReferences().addAll(componentType.getReferences());
+ implementation.getProperties().addAll(componentType.getProperties());
+
+ } else {
+
+ // We have no component type description, simply introspect the POJO and
+ // create a single Service for it
+ Service service = assemblyFactory.createService();
+ service.setName(pojoClass.getSimpleName());
+ JavaInterface javaInterface;
+ try {
+ javaInterface = javaFactory.createJavaInterface(pojoClass);
+ } catch (InvalidInterfaceException e) {
+ throw new ContributionResolveException(e);
+ }
+ JavaInterfaceContract interfaceContract = javaFactory.createJavaInterfaceContract();
+ interfaceContract.setInterface(javaInterface);
+ service.setInterfaceContract(interfaceContract);
+ implementation.getServices().add(service);
+ }
+
+ // Mark the implementation resolved now
+ implementation.setUnresolved(false);
+ }
+
+ public void write(POJOImplementation implementation, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException {
+
+ // Write <implementation.pojo> element
+ policyProcessor.writePolicyPrefixes(implementation, writer);
+ writer.writeStartElement(IMPLEMENTATION_POJO.getNamespaceURI(), IMPLEMENTATION_POJO.getLocalPart());
+ policyProcessor.writePolicyAttributes(implementation, writer);
+
+ if (implementation.getPOJOName() != null) {
+ writer.writeAttribute("class", implementation.getPOJOName());
+ }
+
+ writer.writeEndElement();
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/main/java/pojo/provider/POJOImplementationInvoker.java b/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/main/java/pojo/provider/POJOImplementationInvoker.java
new file mode 100644
index 0000000000..dbe956b8c6
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/main/java/pojo/provider/POJOImplementationInvoker.java
@@ -0,0 +1,51 @@
+/*
+ * 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 pojo.provider;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+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;
+
+class POJOImplementationInvoker implements Invoker {
+
+ private Object pojoInstance;
+ private Method method;
+
+ POJOImplementationInvoker(Object pojoInstance, Operation operation, Method method) {
+ this.pojoInstance = pojoInstance;
+ this.method = method;
+ }
+
+ public Message invoke(Message msg) {
+ try {
+ msg.setBody(method.invoke(pojoInstance, (Object[])msg.getBody()));
+ } catch (InvocationTargetException e) {
+ msg.setFaultBody(e);
+ } catch (Exception e) {
+ throw new ServiceRuntimeException(e);
+ }
+ return msg;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/main/java/pojo/provider/POJOImplementationProvider.java b/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/main/java/pojo/provider/POJOImplementationProvider.java
new file mode 100644
index 0000000000..dd96a18cbb
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/main/java/pojo/provider/POJOImplementationProvider.java
@@ -0,0 +1,96 @@
+/*
+ * 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 pojo.provider;
+
+import java.lang.reflect.Method;
+
+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;
+import org.osoa.sca.ServiceRuntimeException;
+
+import pojo.POJOImplementation;
+
+/**
+ * The model representing a sample CRUD implementation in an SCA assembly model.
+ * The sample CRUD implementation is not a full blown implementation, it only
+ * supports a subset of what a component implementation can support: - a single
+ * fixed service (as opposed to a list of services typed by different
+ * interfaces) - a directory attribute used to specify where a CRUD component is
+ * going to persist resources - no references or properties - no policy intents
+ * or policy sets
+ */
+class POJOImplementationProvider implements ImplementationProvider {
+
+ private POJOImplementation implementation;
+ private Object pojoInstance;
+
+ /**
+ * Constructs a new CRUD implementation.
+ */
+ POJOImplementationProvider(RuntimeComponent component, POJOImplementation implementation) {
+ this.implementation = implementation;
+
+ // Create a new instance of the POJO
+ try {
+ pojoInstance = implementation.getPOJOClass().newInstance();
+ } catch (Exception e) {
+ throw new ServiceRuntimeException(e);
+ }
+ }
+
+ public void start() {
+ try {
+ // Invoke the POJO's init method
+ Method initMethod = implementation.getMethods().get("init");
+ if (initMethod != null) {
+ initMethod.invoke(pojoInstance);
+ }
+ } catch (Exception e) {
+ throw new ServiceRuntimeException(e);
+ }
+ }
+
+ public void stop() {
+ try {
+ // Invoke the POJO's destroy method
+ Method destroyMethod = implementation.getMethods().get("destroy");
+ if (destroyMethod != null) {
+ destroyMethod.invoke(pojoInstance);
+ }
+ } catch (Exception e) {
+ throw new ServiceRuntimeException(e);
+ } finally {
+ pojoInstance = null;
+ }
+ }
+
+ public Invoker createInvoker(RuntimeComponentService service, Operation operation) {
+ Method method = implementation.getMethods().get(operation.getName());
+ POJOImplementationInvoker invoker = new POJOImplementationInvoker(pojoInstance, operation, method);
+ return invoker;
+ }
+
+ public boolean supportsOneWayInvocation() {
+ return false;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/main/java/pojo/provider/POJOImplementationProviderFactory.java b/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/main/java/pojo/provider/POJOImplementationProviderFactory.java
new file mode 100644
index 0000000000..ce135b64cf
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/main/java/pojo/provider/POJOImplementationProviderFactory.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package pojo.provider;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.provider.ImplementationProvider;
+import org.apache.tuscany.sca.provider.ImplementationProviderFactory;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+import pojo.POJOImplementation;
+
+/**
+ * The model representing a sample POJO implementation in an SCA assembly model.
+ */
+public class POJOImplementationProviderFactory implements ImplementationProviderFactory<POJOImplementation> {
+
+ public POJOImplementationProviderFactory(ExtensionPointRegistry registry) {
+ }
+
+ public Class<POJOImplementation> getModelType() {
+ // Returns the type of model processed by this processor
+ return POJOImplementation.class;
+ }
+
+ public ImplementationProvider createImplementationProvider(RuntimeComponent component, POJOImplementation implementation) {
+ return new POJOImplementationProvider(component, implementation);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
new file mode 100644
index 0000000000..8337e81c5f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
@@ -0,0 +1,19 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Implementation class for the artifact processor extension
+pojo.impl.POJOImplementationProcessor;qname=http://pojo#implementation.pojo,model=pojo.POJOImplementation,factory=pojo.POJOImplementationFactory
diff --git a/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema b/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema
new file mode 100644
index 0000000000..64dd230a15
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema
@@ -0,0 +1,19 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# URI of the XML schema to be used for validation
+sample-implementation-pojo.xsd
diff --git a/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory b/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory
new file mode 100644
index 0000000000..b30ea3b9cf
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory
@@ -0,0 +1,19 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Implementation class for the implementation extension
+pojo.provider.POJOImplementationProviderFactory;model=pojo.POJOImplementation
diff --git a/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/main/resources/META-INF/services/pojo.POJOImplementationFactory b/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/main/resources/META-INF/services/pojo.POJOImplementationFactory
new file mode 100644
index 0000000000..075af98240
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/main/resources/META-INF/services/pojo.POJOImplementationFactory
@@ -0,0 +1,19 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Implementation class for implementation model factory
+pojo.impl.POJOImplementationFactoryImpl
diff --git a/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/main/resources/sample-implementation-pojo.xsd b/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/main/resources/sample-implementation-pojo.xsd
new file mode 100644
index 0000000000..c9d170770b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/main/resources/sample-implementation-pojo.xsd
@@ -0,0 +1,38 @@
+<?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.
+-->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://pojo"
+ xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:p="http://pojo"
+ elementFormDefault="qualified">
+
+ <import namespace="http://www.osoa.org/xmlns/sca/1.0"/>
+
+ <element name="implementation.pojo" type="p:POJOImplementation"/>
+
+ <complexType name="POJOImplementation">
+ <complexContent>
+ <extension base="sca:Implementation">
+ <attribute name="class" type="NCName" use="required"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+</schema>
diff --git a/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/test/java/helloworld/HelloWorld.java b/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/test/java/helloworld/HelloWorld.java
new file mode 100644
index 0000000000..cc32929f09
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/test/java/helloworld/HelloWorld.java
@@ -0,0 +1,26 @@
+/*
+ * 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 helloworld;
+
+public interface HelloWorld {
+
+ String sayHello(String name);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/test/java/helloworld/HelloWorldImpl.java b/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/test/java/helloworld/HelloWorldImpl.java
new file mode 100644
index 0000000000..0580e30aba
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/test/java/helloworld/HelloWorldImpl.java
@@ -0,0 +1,37 @@
+/*
+ * 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 helloworld;
+
+public class HelloWorldImpl {
+
+ public void init() {
+ System.out.println("Initializing POJO");
+ }
+
+ public void destroy() {
+ System.out.println("Destroying POJO");
+ }
+
+ public String sayHello(String name) {
+ System.out.println("Executing POJO sayHello");
+ return "Hello " + name;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/test/java/helloworld/HelloWorldImpl2.java b/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/test/java/helloworld/HelloWorldImpl2.java
new file mode 100644
index 0000000000..69ab1f567e
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/test/java/helloworld/HelloWorldImpl2.java
@@ -0,0 +1,37 @@
+/*
+ * 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 helloworld;
+
+public class HelloWorldImpl2 {
+
+ public void init() {
+ System.out.println("Initializing POJO");
+ }
+
+ public void destroy() {
+ System.out.println("Destroying POJO");
+ }
+
+ public String sayHello(String name) {
+ System.out.println("Executing POJO sayHello");
+ return "Hello " + name;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/test/java/helloworld/HelloWorldTestCase.java b/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/test/java/helloworld/HelloWorldTestCase.java
new file mode 100644
index 0000000000..b2a676be49
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/test/java/helloworld/HelloWorldTestCase.java
@@ -0,0 +1,50 @@
+/*
+ * 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 helloworld;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.host.embedded.SCADomain;
+
+/**
+ */
+public class HelloWorldTestCase extends TestCase {
+
+ private SCADomain scaDomain;
+
+ @Override
+ protected void setUp() throws Exception {
+ scaDomain = SCADomain.newInstance("helloworld/helloworld.composite");
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ scaDomain.close();
+ }
+
+ public void testHello() throws Exception {
+ HelloWorld helloworld = scaDomain.getService(HelloWorld.class, "HelloWorldComponent");
+ assertEquals("Hello petra", helloworld.sayHello("petra"));
+ }
+
+ public void testHello2() throws Exception {
+ HelloWorld helloworld = scaDomain.getService(HelloWorld.class, "HelloWorldComponent2/HelloWorld2");
+ assertEquals("Hello petra", helloworld.sayHello("petra"));
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/test/resources/helloworld/HelloWorldImpl2.componentType b/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/test/resources/helloworld/HelloWorldImpl2.componentType
new file mode 100644
index 0000000000..a92c5ab8db
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/test/resources/helloworld/HelloWorldImpl2.componentType
@@ -0,0 +1,26 @@
+<?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.
+-->
+<componentType xmlns="http://www.osoa.org/xmlns/sca/1.0">
+
+ <service name="HelloWorld2">
+ <interface.java interface="helloworld.HelloWorld"/>
+ </service>
+
+</componentType> \ No newline at end of file
diff --git a/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/test/resources/helloworld/helloworld.composite b/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/test/resources/helloworld/helloworld.composite
new file mode 100644
index 0000000000..c38094dfc9
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-1.0.1/samples/implementation-pojo-extension/src/test/resources/helloworld/helloworld.composite
@@ -0,0 +1,33 @@
+<?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"
+ targetNamespace="http://test/helloworld"
+ xmlns:p="http://pojo"
+ name="helloworld">
+
+ <component name="HelloWorldComponent">
+ <p:implementation.pojo class="helloworld.HelloWorldImpl" />
+ </component>
+
+ <component name="HelloWorldComponent2">
+ <p:implementation.pojo class="helloworld.HelloWorldImpl2" />
+ </component>
+
+</composite>