summaryrefslogtreecommitdiffstats
path: root/sandbox/sebastien/java/vhost/unreleased/modules
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/LICENSE205
-rw-r--r--sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/META-INF/MANIFEST.MF21
-rw-r--r--sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/NOTICE6
-rw-r--r--sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/pom.xml170
-rw-r--r--sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/collection/Collection.java58
-rw-r--r--sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/collection/MediaCollection.java55
-rw-r--r--sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/collection/NotFoundException.java45
-rw-r--r--sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSBindingInvoker.java76
-rw-r--r--sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSBindingListenerServlet.java397
-rw-r--r--sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSBindingProviderFactory.java66
-rw-r--r--sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSReferenceBindingProvider.java68
-rw-r--r--sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSServiceBindingProvider.java93
-rw-r--r--sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory19
-rw-r--r--sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/src/test/java/org/apache/tuscany/sca/binding/rss/Consumer.java42
-rw-r--r--sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/src/test/java/org/apache/tuscany/sca/binding/rss/CustomerClient.java25
-rw-r--r--sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/src/test/java/org/apache/tuscany/sca/binding/rss/CustomerClientImpl.java45
-rw-r--r--sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/src/test/java/org/apache/tuscany/sca/binding/rss/CustomerCollectionImpl.java114
-rw-r--r--sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/src/test/java/org/apache/tuscany/sca/binding/rss/Provider.java49
-rw-r--r--sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/src/test/java/org/apache/tuscany/sca/binding/rss/RSSGetTestCase.java78
-rw-r--r--sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/src/test/resources/org/apache/tuscany/sca/binding/rss/Consumer.composite32
-rw-r--r--sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/src/test/resources/org/apache/tuscany/sca/binding/rss/Provider.composite33
-rw-r--r--sandbox/sebastien/java/vhost/unreleased/modules/binding-rss/LICENSE205
-rw-r--r--sandbox/sebastien/java/vhost/unreleased/modules/binding-rss/META-INF/MANIFEST.MF20
-rw-r--r--sandbox/sebastien/java/vhost/unreleased/modules/binding-rss/NOTICE6
-rw-r--r--sandbox/sebastien/java/vhost/unreleased/modules/binding-rss/pom.xml78
-rw-r--r--sandbox/sebastien/java/vhost/unreleased/modules/binding-rss/src/main/java/org/apache/tuscany/sca/binding/rss/RSSBinding.java33
-rw-r--r--sandbox/sebastien/java/vhost/unreleased/modules/binding-rss/src/main/java/org/apache/tuscany/sca/binding/rss/RSSBindingFactory.java35
-rw-r--r--sandbox/sebastien/java/vhost/unreleased/modules/binding-rss/src/main/java/org/apache/tuscany/sca/binding/rss/impl/RSSBindingFactoryImpl.java36
-rw-r--r--sandbox/sebastien/java/vhost/unreleased/modules/binding-rss/src/main/java/org/apache/tuscany/sca/binding/rss/impl/RSSBindingImpl.java91
-rw-r--r--sandbox/sebastien/java/vhost/unreleased/modules/binding-rss/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.rss.RSSBindingFactory19
-rw-r--r--sandbox/sebastien/java/vhost/unreleased/modules/binding-rss/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor19
-rw-r--r--sandbox/sebastien/java/vhost/unreleased/modules/databinding-protobuf/META-INF/MANIFEST.MF21
-rw-r--r--sandbox/sebastien/java/vhost/unreleased/modules/databinding-protobuf/pom.xml64
-rw-r--r--sandbox/sebastien/java/vhost/unreleased/modules/databinding-protobuf/src/main/java/org/apache/tuscany/sca/databinding/protobuf/InputStream2Protobuf.java65
-rw-r--r--sandbox/sebastien/java/vhost/unreleased/modules/databinding-protobuf/src/main/java/org/apache/tuscany/sca/databinding/protobuf/Protobuf2OutputStream.java60
-rw-r--r--sandbox/sebastien/java/vhost/unreleased/modules/databinding-protobuf/src/main/java/org/apache/tuscany/sca/databinding/protobuf/ProtobufDatabinding.java107
-rw-r--r--sandbox/sebastien/java/vhost/unreleased/modules/databinding-protobuf/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.DataBinding20
-rw-r--r--sandbox/sebastien/java/vhost/unreleased/modules/databinding-protobuf/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer20
-rw-r--r--sandbox/sebastien/java/vhost/unreleased/modules/databinding-protobuf/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PushTransformer17
-rw-r--r--sandbox/sebastien/java/vhost/unreleased/modules/databinding-protobuf/src/test/java/com/example/tutorial/AddressBookProtos.java1375
-rw-r--r--sandbox/sebastien/java/vhost/unreleased/modules/databinding-protobuf/src/test/java/org/apache/tuscany/sca/databinding/protobuf/ProtobufTransformationTestCase.java63
-rw-r--r--sandbox/sebastien/java/vhost/unreleased/modules/databinding-protobuf/src/test/resources/addressbook.proto48
-rw-r--r--sandbox/sebastien/java/vhost/unreleased/modules/host-tomcat/LICENSE205
-rw-r--r--sandbox/sebastien/java/vhost/unreleased/modules/host-tomcat/META-INF/MANIFEST.MF33
-rw-r--r--sandbox/sebastien/java/vhost/unreleased/modules/host-tomcat/NOTICE6
-rw-r--r--sandbox/sebastien/java/vhost/unreleased/modules/host-tomcat/pom.xml69
-rw-r--r--sandbox/sebastien/java/vhost/unreleased/modules/host-tomcat/src/main/java/org/apache/tuscany/sca/http/tomcat/ServletWrapper.java58
-rw-r--r--sandbox/sebastien/java/vhost/unreleased/modules/host-tomcat/src/main/java/org/apache/tuscany/sca/http/tomcat/TomcatDefaultServlet.java114
-rw-r--r--sandbox/sebastien/java/vhost/unreleased/modules/host-tomcat/src/main/java/org/apache/tuscany/sca/http/tomcat/TomcatServer.java701
-rw-r--r--sandbox/sebastien/java/vhost/unreleased/modules/host-tomcat/src/main/resources/META-INF/services/org.apache.tuscany.sca.host.http.ServletHost18
-rw-r--r--sandbox/sebastien/java/vhost/unreleased/modules/host-tomcat/src/test/java/org/apache/tuscany/sca/http/tomcat/TomcatServerTestCase.java375
-rw-r--r--sandbox/sebastien/java/vhost/unreleased/modules/host-tomcat/src/test/resources/content/test.html21
-rw-r--r--sandbox/sebastien/java/vhost/unreleased/modules/host-tomcat/src/test/resources/tuscany.keyStorebin0 -> 1265 bytes
-rw-r--r--sandbox/sebastien/java/vhost/unreleased/modules/pom.xml93
54 files changed, 5792 insertions, 0 deletions
diff --git a/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/LICENSE b/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/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/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/META-INF/MANIFEST.MF b/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..c78875e887
--- /dev/null
+++ b/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/META-INF/MANIFEST.MF
@@ -0,0 +1,21 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.binding.rss.collection
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA RSS Feed Binding Extension
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA RSS Feed Binding Extension
+Import-Package: javax.xml.namespace,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.assembly.xml;version="2.0.0",
+ org.apache.tuscany.sca.binding.rss;version="2.0.0",
+ org.apache.tuscany.sca.core,
+ org.apache.tuscany.sca.interfacedef,
+ org.apache.tuscany.sca.interfacedef.impl,
+ org.apache.tuscany.sca.interfacedef.util,
+ org.apache.tuscany.sca.monitor
+Bundle-SymbolicName: org.apache.tuscany.sca.binding.rss.runtime
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/NOTICE b/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/NOTICE
new file mode 100644
index 0000000000..d69e595698
--- /dev/null
+++ b/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2011 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/pom.xml b/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/pom.xml
new file mode 100644
index 0000000000..a6bb39de01
--- /dev/null
+++ b/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/pom.xml
@@ -0,0 +1,170 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-modules</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-binding-rss-runtime</artifactId>
+ <name>Apache Tuscany SCA RSS Feed Binding Extension</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-rss</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-java</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-data-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-spi</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-http</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-httpclient</groupId>
+ <artifactId>commons-httpclient</artifactId>
+ <version>3.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>rome</groupId>
+ <artifactId>rome</artifactId>
+ <version>1.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ <version>1.3</version>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1.1</version>
+ <exclusions>
+ <exclusion>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>avalon-framework</groupId>
+ <artifactId>avalon-framework</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-jetty</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>2.0.1</version>
+ <configuration>
+ <instructions>
+ <Bundle-Version>${tuscany.version}</Bundle-Version>
+ <Bundle-SymbolicName>org.apache.tuscany.sca.binding.rss.rome</Bundle-SymbolicName>
+ <Bundle-Description>${pom.name}</Bundle-Description>
+ <Export-Package>org.apache.tuscany.sca.binding.rss*</Export-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/collection/Collection.java b/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/collection/Collection.java
new file mode 100644
index 0000000000..581ae59ae6
--- /dev/null
+++ b/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/collection/Collection.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.rss.collection;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+import com.sun.syndication.feed.synd.SyndEntry;
+import com.sun.syndication.feed.synd.SyndFeed;
+
+
+/**
+ * Provides access to a collection of resources using RSS.
+ *
+ * @version $Rev$ $Date$
+ */
+@Remotable
+public interface Collection {
+
+ /**
+ * Get an RSS feed for a collection of resources.
+ *
+ * @return the RSS feed
+ */
+ SyndFeed getFeed();
+
+ /**
+ * Get an RSS feed for a collection of resources resulting from a query.
+ *
+ * @param queryString the query string
+ * @return the RSS feed
+ */
+ SyndFeed query(String queryString);
+
+ /**
+ * Retrieves an RSS entry.
+ *
+ * @param id The entry ID
+ * @return The requested entry
+ * @throws NotFoundException No entry found with the given ID
+ */
+ SyndEntry get(String id) throws NotFoundException;
+}
diff --git a/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/collection/MediaCollection.java b/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/collection/MediaCollection.java
new file mode 100644
index 0000000000..a2b83465da
--- /dev/null
+++ b/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/collection/MediaCollection.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.rss.collection;
+
+import java.io.InputStream;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+import com.sun.syndication.feed.atom.Entry;
+
+/**
+ * Provides access to a collection of resources using Atom.
+ *
+ * @version $Rev$ $Date$
+ */
+@Remotable
+public interface MediaCollection extends Collection {
+
+ /**
+ * Creates a new media entry
+ *
+ * @param title
+ * @param slug
+ * @param contentType
+ * @param media
+ */
+ Entry postMedia(String title, String slug, String contentType, InputStream media);
+
+ /**
+ * Update a media entry.
+ *
+ * @param id
+ * @param contentType
+ * @param media
+ * @return
+ */
+ void putMedia(String id, String contentType, InputStream media) throws NotFoundException;
+
+}
diff --git a/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/collection/NotFoundException.java b/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/collection/NotFoundException.java
new file mode 100644
index 0000000000..0912878938
--- /dev/null
+++ b/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/collection/NotFoundException.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 org.apache.tuscany.sca.binding.rss.collection;
+
+/**
+ * Indicates that a resource could not be found.
+ *
+ * @version $Rev$ $Date$
+ */
+public class NotFoundException extends Exception {
+ private static final long serialVersionUID = -5046027674128627383L;
+
+ public NotFoundException() {
+ }
+
+ public NotFoundException(String message) {
+ super(message);
+ }
+
+ public NotFoundException(Throwable cause) {
+ super(cause);
+ }
+
+ public NotFoundException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+}
diff --git a/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSBindingInvoker.java b/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSBindingInvoker.java
new file mode 100644
index 0000000000..e3a177198c
--- /dev/null
+++ b/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSBindingInvoker.java
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.rss.provider;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.logging.Logger;
+
+import org.apache.tuscany.sca.invocation.DataExchangeSemantics;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+
+import com.sun.syndication.feed.synd.SyndFeed;
+import com.sun.syndication.io.FeedException;
+import com.sun.syndication.io.SyndFeedInput;
+import com.sun.syndication.io.XmlReader;
+
+/**
+ * Invoker for the RSS binding.
+ *
+ * @version $Rev$ $Date$
+ */
+class RSSBindingInvoker implements Invoker , DataExchangeSemantics {
+ private static final Logger logger = Logger.getLogger(RSSBindingInvoker.class.getName());
+
+ private String uri;
+
+ RSSBindingInvoker(String uri, String feedType) {
+ this.uri = uri;
+ }
+
+ public Message invoke(Message msg) {
+ try {
+ logger.fine("invoke " + uri);
+
+ // Read an RSS feed into a Synd feed
+ SyndFeedInput input = new SyndFeedInput();
+ SyndFeed feed = input.build(new XmlReader(new URL(uri)));
+
+ //FIXME Support conversion to data-api entries
+
+ msg.setBody(feed);
+
+ } catch (MalformedURLException e) {
+ msg.setFaultBody(e);
+ } catch (IllegalArgumentException e) {
+ msg.setFaultBody(e);
+ } catch (FeedException e) {
+ msg.setFaultBody(e);
+ } catch (IOException e) {
+ msg.setFaultBody(e);
+ }
+ return msg;
+ }
+
+ public boolean allowsPassByReference() {
+ return true;
+ }
+}
diff --git a/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSBindingListenerServlet.java b/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSBindingListenerServlet.java
new file mode 100644
index 0000000000..44c84ce5bb
--- /dev/null
+++ b/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSBindingListenerServlet.java
@@ -0,0 +1,397 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.rss.provider;
+
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.io.UnsupportedEncodingException;
+import java.io.Writer;
+import java.net.URLDecoder;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.StringTokenizer;
+import java.util.logging.Logger;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.xml.namespace.QName;
+
+import org.apache.commons.codec.binary.Base64;
+import org.apache.tuscany.sca.data.collection.Item;
+import org.apache.tuscany.sca.databinding.Mediator;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+import org.apache.tuscany.sca.invocation.InvocationChain;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.invocation.MessageFactory;
+import org.apache.tuscany.sca.runtime.Invocable;
+
+import com.sun.syndication.feed.synd.SyndContent;
+import com.sun.syndication.feed.synd.SyndContentImpl;
+import com.sun.syndication.feed.synd.SyndEntry;
+import com.sun.syndication.feed.synd.SyndEntryImpl;
+import com.sun.syndication.feed.synd.SyndFeed;
+import com.sun.syndication.feed.synd.SyndFeedImpl;
+import com.sun.syndication.feed.synd.SyndLink;
+import com.sun.syndication.feed.synd.SyndLinkImpl;
+import com.sun.syndication.io.FeedException;
+import com.sun.syndication.io.SyndFeedOutput;
+
+/**
+ * An RSS binding listener, implemented as a Servlet and
+ * registered in a Servlet host provided by the SCA hosting runtime.
+ *
+ * @version $Rev$ $Date$
+ */
+class RSSBindingListenerServlet extends HttpServlet {
+ private static final Logger logger = Logger.getLogger(RSSBindingListenerServlet.class.getName());
+ private static final long serialVersionUID = 1L;
+
+ private Invocable wire;
+ private Invoker getFeedInvoker;
+ private Invoker getAllInvoker;
+ private Invoker queryInvoker;
+ private MessageFactory messageFactory;
+ private Mediator mediator;
+ private DataType<?> itemClassType;
+ private DataType<?> itemXMLType;
+ private boolean supportsFeedEntries;
+
+ /**
+ * Constructs a new binding listener.
+ *
+ * @param wire
+ * @param messageFactory
+ */
+ RSSBindingListenerServlet(Invocable wire, MessageFactory messageFactory, Mediator mediator) {
+ this.wire = wire;
+ this.messageFactory = messageFactory;
+ this.mediator = mediator;
+
+ // Get the invokers for the supported operations
+ Operation getOperation = null;
+ for (InvocationChain invocationChain : this.wire.getInvocationChains()) {
+ invocationChain.setAllowsPassByReference(true);
+ Operation operation = invocationChain.getTargetOperation();
+ String operationName = operation.getName();
+ if (operationName.equals("getFeed")) {
+ getFeedInvoker = invocationChain.getHeadInvoker();
+ } else if (operationName.equals("getAll")) {
+ getAllInvoker = invocationChain.getHeadInvoker();
+ } else if (operationName.equals("query")) {
+ queryInvoker = invocationChain.getHeadInvoker();
+ } else if (operationName.equals("get")) {
+ getOperation = operation;
+ }
+ }
+
+ // Determine the collection item type
+ if (getOperation != null) {
+ itemXMLType = new DataTypeImpl<Class<?>>(String.class.getName(), String.class, String.class);
+ Class<?> itemClass = getOperation.getOutputType().getPhysical();
+ if (itemClass == SyndEntry.class) {
+ supportsFeedEntries = true;
+ }
+ DataType<XMLType> outputType = getOperation.getOutputType();
+ QName qname = outputType.getLogical().getElementName();
+ qname = new QName(qname.getNamespaceURI(), itemClass.getSimpleName());
+ itemClassType = new DataTypeImpl<XMLType>("java:complexType", itemClass, new XMLType(qname, null));
+ }
+ }
+
+ @Override
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+
+ // No authentication required for a get request
+
+ // Get the request path
+ String path = URLDecoder.decode(request.getRequestURI().substring(request.getServletPath().length()), "UTF-8");
+
+ logger.fine("get " + request.getRequestURI());
+
+ // Handle an RSS request
+ if (path == null || path.length() == 0 || path.equals("/")) {
+
+ // Return an RSS feed containing the entries in the collection
+ SyndFeed feed = null;
+ if (supportsFeedEntries) {
+
+ // The service implementation supports feed entries, invoke its getFeed operation
+ Message requestMessage = messageFactory.createMessage();
+ Message responseMessage = getFeedInvoker.invoke(requestMessage);
+ if (responseMessage.isFault()) {
+ throw new ServletException((Throwable)responseMessage.getBody());
+ }
+ feed = (SyndFeed)responseMessage.getBody();
+
+ } else {
+
+ // The service implementation does not support feed entries, invoke its
+ // getAll operation to get the data item collection. then create feed entries
+ // from the data items
+ Message requestMessage = messageFactory.createMessage();
+ Message responseMessage;
+ if (request.getQueryString() != null) {
+ requestMessage.setBody(new Object[] {request.getQueryString()});
+ responseMessage = queryInvoker.invoke(requestMessage);
+ } else {
+ responseMessage = getAllInvoker.invoke(requestMessage);
+ }
+ if (responseMessage.isFault()) {
+ throw new ServletException((Throwable)responseMessage.getBody());
+ }
+ org.apache.tuscany.sca.data.collection.Entry<Object, Object>[] collection =
+ (org.apache.tuscany.sca.data.collection.Entry<Object, Object>[])responseMessage.getBody();
+ if (collection != null) {
+ // Create the feed
+ feed = new SyndFeedImpl();
+ feed.setTitle("Feed");
+ feed.setDescription("Feed description");
+
+ for (org.apache.tuscany.sca.data.collection.Entry<Object, Object> entry: collection) {
+ SyndEntry feedEntry = createFeedEntry(entry);
+ feed.getEntries().add(feedEntry);
+ }
+ }
+ }
+
+ // Convert to an RSS feed
+ if (feed != null) {
+ response.setContentType("application/rss+xml; charset=utf-8");
+ feed.setFeedType("rss_2.0");
+ feed.setLink(path);
+ SyndFeedOutput syndOutput = new SyndFeedOutput();
+ try {
+ syndOutput.output(feed, getWriter(response));
+ } catch (FeedException e) {
+ throw new ServletException(e);
+ }
+ } else {
+ response.sendError(HttpServletResponse.SC_NOT_FOUND);
+ }
+ } else {
+ response.sendError(HttpServletResponse.SC_NOT_FOUND);
+ }
+
+ }
+
+ /**
+ * Create an RSS entry from a data collection entry.
+ * @param entry
+ * @return
+ */
+ private SyndEntry createFeedEntry(org.apache.tuscany.sca.data.collection.Entry<Object, Object> entry) {
+ Object key = entry.getKey();
+ Object data = entry.getData();
+ if (data instanceof Item) {
+ Item item = (Item)data;
+
+ SyndEntry feedEntry = new SyndEntryImpl();
+ feedEntry.setUri(key.toString());
+ feedEntry.setTitle(item.getTitle());
+
+ String value = item.getContents();
+ if (value != null) {
+ SyndContent content = new SyndContentImpl();
+ content.setType("text/xml");
+ content.setValue(value);
+ List<SyndContent> contents = new ArrayList<SyndContent>();
+ contents.add(content);
+ feedEntry.setContents(contents);
+ }
+
+ String href = item.getLink();
+ if (href == null) {
+ href = key.toString();
+ }
+ SyndLink link = new SyndLinkImpl();
+ link.setRel("edit");
+ link.setHref(href);
+ feedEntry.getLinks().add(link);
+ link = new SyndLinkImpl();
+ link.setRel("alternate");
+ link.setHref(href);
+ feedEntry.getLinks().add(link);
+ feedEntry.setLink(href);
+
+ Date date = item.getDate();
+ if (date == null) {
+ date = new Date();
+ }
+ feedEntry.setPublishedDate(date);
+ return feedEntry;
+
+ } else if (data != null) {
+ SyndEntry feedEntry = new SyndEntryImpl();
+ feedEntry.setUri(key.toString());
+ feedEntry.setTitle("item");
+
+ // Convert the item to XML
+ String value = mediator.mediate(data, itemClassType, itemXMLType, null).toString();
+
+ SyndContent content = new SyndContentImpl();
+ content.setType("text/xml");
+ content.setValue(value);
+ List<SyndContent> contents = new ArrayList<SyndContent>();
+ contents.add(content);
+ feedEntry.setContents(contents);
+
+ SyndLink link = new SyndLinkImpl();
+ link.setRel("edit");
+ link.setHref(key.toString());
+ feedEntry.getLinks().add(link);
+ link = new SyndLinkImpl();
+ link.setRel("alternate");
+ link.setHref(key.toString());
+ feedEntry.getLinks().add(link);
+
+ feedEntry.setPublishedDate(new Date());
+ return feedEntry;
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Create a data collection entry from an RSS entry.
+ * @param feedEntry
+ * @return
+ */
+ private org.apache.tuscany.sca.data.collection.Entry<Object, Object> createEntry(SyndEntry feedEntry) {
+ if (feedEntry != null) {
+ if (itemClassType.getPhysical() == Item.class) {
+ String key = feedEntry.getUri();
+
+ Item item = new Item();
+ item.setTitle(feedEntry.getTitle());
+
+ List<?> contents = feedEntry.getContents();
+ if (!contents.isEmpty()) {
+ SyndContent content = (SyndContent)contents.get(0);
+ String value = content.getValue();
+ item.setContents(value);
+ }
+
+ for (Object l : feedEntry.getLinks()) {
+ SyndLink link = (SyndLink)l;
+ if (link.getRel() == null || "edit".equals(link.getRel())) {
+ String href = link.getHref();
+ if (href.startsWith("null/")) {
+ href = href.substring(5);
+ }
+ item.setLink(href);
+ break;
+ }
+ }
+
+ item.setDate(feedEntry.getPublishedDate());
+
+ return new org.apache.tuscany.sca.data.collection.Entry<Object, Object>(key, item);
+
+ } else {
+ String key = feedEntry.getUri();
+
+ // Create the item from XML
+ List<?> contents = feedEntry.getContents();
+ if (contents.isEmpty()) {
+ return null;
+ }
+ SyndContent content = (SyndContent)contents.get(0);
+ String value = content.getValue();
+ Object data = mediator.mediate(value, itemXMLType, itemClassType, null);
+
+ return new org.apache.tuscany.sca.data.collection.Entry<Object, Object>(key, data);
+ }
+ } else {
+ return null;
+ }
+ }
+
+
+ private Writer getWriter(HttpServletResponse response) throws UnsupportedEncodingException, IOException {
+ Writer writer = new OutputStreamWriter(response.getOutputStream(), "UTF-8");
+ return writer;
+ }
+
+ /**
+ * Process the authorization header
+ *
+ * @param request
+ * @return
+ * @throws ServletException
+ */
+ private String processAuthorizationHeader(HttpServletRequest request) throws ServletException {
+ try {
+ String authorization = request.getHeader("Authorization");
+ if (authorization != null) {
+ StringTokenizer tokens = new StringTokenizer(authorization);
+ if (tokens.hasMoreTokens()) {
+ String basic = tokens.nextToken();
+ if (basic.equalsIgnoreCase("Basic")) {
+ String credentials = tokens.nextToken();
+ String userAndPassword = new String(Base64.decodeBase64(credentials.getBytes()));
+ int colon = userAndPassword.indexOf(":");
+ if (colon != -1) {
+ String user = userAndPassword.substring(0, colon);
+ String password = userAndPassword.substring(colon + 1);
+
+ // Authenticate the User.
+ if (authenticate(user, password)) {
+ return user;
+ }
+ }
+ }
+ }
+ }
+ } catch (Exception e) {
+ throw new ServletException(e);
+ }
+ return null;
+ }
+
+ /**
+ * Authenticate a user.
+ *
+ * @param user
+ * @param password
+ * @return
+ */
+ private boolean authenticate(String user, String password) {
+
+ // TODO Handle this using SCA security policies
+ //FIXME Why are we using endsWith instead of equals here??
+ return ("admin".endsWith(user) && "admin".equals(password));
+ }
+
+ /**
+ * Reject an unauthorized request.
+ *
+ * @param response
+ */
+ private void unauthorized(HttpServletResponse response) throws IOException {
+ response.setHeader("WWW-Authenticate", "BASIC realm=\"Tuscany\"");
+ response.sendError(HttpServletResponse.SC_UNAUTHORIZED);
+ }
+}
diff --git a/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSBindingProviderFactory.java b/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSBindingProviderFactory.java
new file mode 100644
index 0000000000..e1bafdd3cd
--- /dev/null
+++ b/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSBindingProviderFactory.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.rss.provider;
+
+import org.apache.tuscany.sca.binding.rss.RSSBinding;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.databinding.Mediator;
+import org.apache.tuscany.sca.host.http.ServletHost;
+import org.apache.tuscany.sca.host.http.ServletHostExtensionPoint;
+import org.apache.tuscany.sca.invocation.MessageFactory;
+import org.apache.tuscany.sca.provider.BindingProviderFactory;
+import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
+import org.apache.tuscany.sca.provider.ServiceBindingProvider;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+
+/**
+ * Implementation of the RSS binding provider factory.
+ *
+ * @version $Rev$ $Date$
+ */
+public class RSSBindingProviderFactory implements BindingProviderFactory<RSSBinding> {
+
+ private MessageFactory messageFactory;
+ private Mediator mediator;
+ private ServletHost servletHost;
+
+ public RSSBindingProviderFactory(ExtensionPointRegistry extensionPoints) {
+ ServletHostExtensionPoint servletHosts = extensionPoints.getExtensionPoint(ServletHostExtensionPoint.class);
+ this.servletHost = servletHosts.getServletHosts().get(0);
+ FactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ this.messageFactory = modelFactories.getFactory(MessageFactory.class);
+ this.mediator = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class).getUtility(Mediator.class);
+ }
+
+ public ReferenceBindingProvider createReferenceBindingProvider(RuntimeEndpointReference endpointReference) {
+ return new RSSReferenceBindingProvider(endpointReference, mediator);
+ }
+
+ public ServiceBindingProvider createServiceBindingProvider(RuntimeEndpoint endpoint) {
+ return new RSSServiceBindingProvider(endpoint, messageFactory, mediator, servletHost);
+ }
+
+ public Class<RSSBinding> getModelType() {
+ return RSSBinding.class;
+ }
+}
diff --git a/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSReferenceBindingProvider.java b/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSReferenceBindingProvider.java
new file mode 100644
index 0000000000..d234a0c92c
--- /dev/null
+++ b/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSReferenceBindingProvider.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.rss.provider;
+
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.binding.rss.RSSBinding;
+import org.apache.tuscany.sca.databinding.Mediator;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+
+/**
+ * Implementation of the RSS binding provider.
+ *
+ * @version $Rev$ $Date$
+ */
+class RSSReferenceBindingProvider implements ReferenceBindingProvider {
+
+ private EndpointReference endpointReference;
+
+ private RuntimeComponentReference reference;
+ private RSSBinding binding;
+
+ RSSReferenceBindingProvider(EndpointReference endpointReference,
+ Mediator mediator) {
+ this.endpointReference = endpointReference;
+ this.reference = (RuntimeComponentReference) endpointReference.getReference();
+ this.binding = (RSSBinding) endpointReference.getBinding();
+ }
+
+ public Invoker createInvoker(Operation operation) {
+ return new RSSBindingInvoker(binding.getURI(), "rss_2.0");
+ }
+
+ public boolean supportsOneWayInvocation() {
+ return false;
+ }
+
+ public InterfaceContract getBindingInterfaceContract() {
+ return reference.getInterfaceContract();
+ }
+
+ public void start() {
+ }
+
+ public void stop() {
+ }
+
+}
diff --git a/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSServiceBindingProvider.java b/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSServiceBindingProvider.java
new file mode 100644
index 0000000000..25ab939341
--- /dev/null
+++ b/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSServiceBindingProvider.java
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.rss.provider;
+
+import org.apache.tuscany.sca.binding.rss.RSSBinding;
+import org.apache.tuscany.sca.databinding.Mediator;
+import org.apache.tuscany.sca.host.http.ServletHost;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.invocation.MessageFactory;
+import org.apache.tuscany.sca.provider.ServiceBindingProvider;
+import org.apache.tuscany.sca.runtime.Invocable;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+
+/**
+ * Implementation of the RSS binding provider.
+ *
+ * @version $Rev$ $Date$
+ */
+class RSSServiceBindingProvider implements ServiceBindingProvider {
+
+ private RuntimeEndpoint endpoint;
+
+ //private RuntimeComponentService service;
+ private RSSBinding binding;
+
+ private MessageFactory messageFactory;
+ private Mediator mediator;
+ private ServletHost servletHost;
+
+ private String servletMapping;
+
+ RSSServiceBindingProvider(RuntimeEndpoint endpoint,
+ MessageFactory messageFactory,
+ Mediator mediator,
+ ServletHost servletHost) {
+ this.endpoint = endpoint;
+
+ //this.service = (RuntimeComponentService)endpoint.getService();
+ this.binding = (RSSBinding) endpoint.getBinding();
+ this.servletHost = servletHost;
+ this.messageFactory = messageFactory;
+ this.mediator = mediator;
+ }
+
+ public InterfaceContract getBindingInterfaceContract() {
+ return endpoint.getComponentTypeServiceInterfaceContract();
+ }
+
+ public boolean supportsOneWayInvocation() {
+ return false;
+ }
+
+ public void start() {
+ Invocable wire = (RuntimeEndpoint) endpoint;
+
+ RSSBindingListenerServlet servlet =
+ new RSSBindingListenerServlet(wire, messageFactory, mediator);
+
+ servletMapping = binding.getURI();
+ if (!servletMapping.endsWith("/")) {
+ servletMapping += "/";
+ }
+ if (!servletMapping.endsWith("*")) {
+ servletMapping += "*";
+ }
+ servletHost.addServletMapping(servletMapping, servlet);
+
+ // Save the actual binding URI in the binding
+ //binding.setURI(servletHost.getURLMapping(binding.getURI()).toString());
+ }
+
+ public void stop() {
+ servletHost.removeServletMapping(servletMapping);
+ }
+
+}
diff --git a/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory b/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory
new file mode 100644
index 0000000000..e60dc2855a
--- /dev/null
+++ b/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory
@@ -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 binding extension
+org.apache.tuscany.sca.binding.rss.provider.RSSBindingProviderFactory;model=org.apache.tuscany.sca.binding.rss.RSSBinding
diff --git a/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/src/test/java/org/apache/tuscany/sca/binding/rss/Consumer.java b/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/src/test/java/org/apache/tuscany/sca/binding/rss/Consumer.java
new file mode 100644
index 0000000000..1ae4515e70
--- /dev/null
+++ b/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/src/test/java/org/apache/tuscany/sca/binding/rss/Consumer.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.rss;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+
+
+public class Consumer {
+
+ public static void main(String[] args) throws Exception {
+
+ String contribution = ContributionLocationHelper.getContributionLocation(Consumer.class);
+ Node node = NodeFactory.newInstance().createNode("org/apache/tuscany/sca/binding/feed/Consumer.composite", new Contribution("consumer", contribution));
+
+ node.start();
+
+ CustomerClient testService = node.getService(CustomerClient.class, "CustomerClient");
+ testService.testCustomerCollection();
+
+ node.stop();
+ }
+}
diff --git a/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/src/test/java/org/apache/tuscany/sca/binding/rss/CustomerClient.java b/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/src/test/java/org/apache/tuscany/sca/binding/rss/CustomerClient.java
new file mode 100644
index 0000000000..af87155f45
--- /dev/null
+++ b/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/src/test/java/org/apache/tuscany/sca/binding/rss/CustomerClient.java
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.rss;
+
+public interface CustomerClient {
+
+ void testCustomerCollection() throws Exception;
+}
diff --git a/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/src/test/java/org/apache/tuscany/sca/binding/rss/CustomerClientImpl.java b/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/src/test/java/org/apache/tuscany/sca/binding/rss/CustomerClientImpl.java
new file mode 100644
index 0000000000..a80f721136
--- /dev/null
+++ b/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/src/test/java/org/apache/tuscany/sca/binding/rss/CustomerClientImpl.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 org.apache.tuscany.sca.binding.rss;
+
+import org.apache.tuscany.sca.binding.rss.collection.Collection;
+import org.oasisopen.sca.annotation.Reference;
+
+import com.sun.syndication.feed.synd.SyndEntry;
+import com.sun.syndication.feed.synd.SyndFeed;
+
+
+public class CustomerClientImpl implements CustomerClient {
+
+ @Reference
+ public Collection resourceCollection;
+
+ public void testCustomerCollection() throws Exception {
+
+ System.out.println(">>> get collection");
+ SyndFeed feed = resourceCollection.getFeed();
+ System.out.println("<<< get collection");
+ for (Object o : feed.getEntries()) {
+ SyndEntry e = (SyndEntry)o;
+ System.out.println("id = " + e.getUri() + " entry = " + e.getTitle());
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/src/test/java/org/apache/tuscany/sca/binding/rss/CustomerCollectionImpl.java b/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/src/test/java/org/apache/tuscany/sca/binding/rss/CustomerCollectionImpl.java
new file mode 100644
index 0000000000..4b5bf373e7
--- /dev/null
+++ b/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/src/test/java/org/apache/tuscany/sca/binding/rss/CustomerCollectionImpl.java
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.rss;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import org.apache.tuscany.sca.binding.rss.collection.Collection;
+import org.apache.tuscany.sca.binding.rss.collection.NotFoundException;
+import org.oasisopen.sca.annotation.Scope;
+
+import com.sun.syndication.feed.synd.SyndContent;
+import com.sun.syndication.feed.synd.SyndContentImpl;
+import com.sun.syndication.feed.synd.SyndEntry;
+import com.sun.syndication.feed.synd.SyndEntryImpl;
+import com.sun.syndication.feed.synd.SyndFeed;
+import com.sun.syndication.feed.synd.SyndFeedImpl;
+import com.sun.syndication.feed.synd.SyndLink;
+import com.sun.syndication.feed.synd.SyndLinkImpl;
+
+@Scope("COMPOSITE")
+public class CustomerCollectionImpl implements Collection {
+
+ private Map<String, SyndEntry> entries = new HashMap<String, SyndEntry>();
+
+ public CustomerCollectionImpl() {
+
+ for (int i = 0; i < 4; i++) {
+ String id = "urn:uuid:customer-" + UUID.randomUUID().toString();
+
+ SyndEntry entry = new SyndEntryImpl();
+ entry.setTitle("customer " + "Jane Doe_" + String.valueOf(i));
+ entry.setUri(id);
+
+ SyndContent content = new SyndContentImpl();
+ content.setValue("Jane Doe_" + String.valueOf(i));
+ content.setType("text");
+ entry.setContents(Collections.singletonList(content));
+
+ List<SyndLink> links = new ArrayList<SyndLink>();
+ SyndLink link = new SyndLinkImpl();
+ link.setRel("edit");
+ link.setHref("" + id);
+ links.add(link);
+ entry.setLinks(links);
+
+ links = new ArrayList<SyndLink>();
+ link = new SyndLinkImpl();
+ link.setRel("alternate");
+ link.setHref("" + id);
+ links.add(link);
+ entry.setLinks(links);
+
+ entry.setPublishedDate(new Date());
+
+ entries.put(id, entry);
+ System.out.println(">>> id=" + id);
+ }
+ }
+
+ public SyndFeed getFeed() {
+ System.out.println(">>> CustomerCollectionImpl.getFeed");
+
+ SyndFeed feed = new SyndFeedImpl();
+ feed.setTitle("customers");
+ feed.setDescription("This is a sample feed");
+ feed.getEntries().addAll(entries.values());
+ return feed;
+ }
+
+ public SyndFeed query(String queryString) {
+ System.out.println(">>> CustomerCollectionImpl.query");
+
+ SyndFeed feed = new SyndFeedImpl();
+ feed.setTitle("customers");
+ feed.setDescription("This is a sample feed");
+ feed.getEntries().addAll(entries.values());
+ return feed;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public SyndEntry get(String id) throws NotFoundException {
+ final SyndEntry entry = entries.get(id);
+ if (id == null) {
+ throw new NotFoundException("No entry found with ID " + id);
+ }
+
+ return entry;
+ }
+}
diff --git a/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/src/test/java/org/apache/tuscany/sca/binding/rss/Provider.java b/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/src/test/java/org/apache/tuscany/sca/binding/rss/Provider.java
new file mode 100644
index 0000000000..6dc23ac503
--- /dev/null
+++ b/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/src/test/java/org/apache/tuscany/sca/binding/rss/Provider.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.rss;
+
+import java.io.IOException;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+
+public class Provider {
+
+ public static void main(String[] args) {
+
+
+ String contribution = ContributionLocationHelper.getContributionLocation(Provider.class);
+ Node node = NodeFactory.newInstance().createNode("org/apache/tuscany/sca/binding/feed/Provider.composite", new Contribution("provider", contribution));
+
+ node.start();
+
+ System.out.println("Provider.composite ready...");
+
+ try {
+ System.in.read();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ node.stop();
+ }
+}
diff --git a/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/src/test/java/org/apache/tuscany/sca/binding/rss/RSSGetTestCase.java b/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/src/test/java/org/apache/tuscany/sca/binding/rss/RSSGetTestCase.java
new file mode 100644
index 0000000000..5a786f3bd0
--- /dev/null
+++ b/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/src/test/java/org/apache/tuscany/sca/binding/rss/RSSGetTestCase.java
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.rss;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * Basic test case that will get the feed entries from an RSS feed.
+ */
+public class RSSGetTestCase {
+ protected static Node scaConsumerNode;
+ protected static Node scaProviderNode;
+ protected static CustomerClient testService;
+
+ @BeforeClass
+ public static void init() throws Exception {
+ System.out.println(">>>RSSGetTestCase.init entry");
+ String contribution = ContributionLocationHelper.getContributionLocation(RSSGetTestCase.class);
+
+ scaProviderNode = NodeFactory.newInstance().createNode("org/apache/tuscany/sca/binding/rss/Provider.composite", new Contribution("provider", contribution));
+ scaProviderNode.start();
+
+ scaConsumerNode = NodeFactory.newInstance().createNode("org/apache/tuscany/sca/binding/rss/Consumer.composite", new Contribution("consumer", contribution));
+ scaConsumerNode.start();
+
+ testService = scaConsumerNode.getService(CustomerClient.class, "CustomerClient");
+ }
+
+ @AfterClass
+ public static void destroy() throws Exception {
+ // System.out.println(">>>RSSGetTestCase.destroy entry");
+ if (scaConsumerNode != null) {
+ scaConsumerNode.stop();
+ }
+ if (scaProviderNode != null) {
+ scaProviderNode.stop();
+ }
+ }
+
+ @Test
+ public void testPrelim() throws Exception {
+ Assert.assertNotNull(scaProviderNode);
+ Assert.assertNotNull(scaConsumerNode);
+ Assert.assertNotNull(testService);
+ }
+
+ @Test
+ @Ignore("TUSCANY-3537")
+ public void testRSSGet() throws Exception {
+ testService.testCustomerCollection();
+ }
+}
diff --git a/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/src/test/resources/org/apache/tuscany/sca/binding/rss/Consumer.composite b/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/src/test/resources/org/apache/tuscany/sca/binding/rss/Consumer.composite
new file mode 100644
index 0000000000..22141805cd
--- /dev/null
+++ b/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/src/test/resources/org/apache/tuscany/sca/binding/rss/Consumer.composite
@@ -0,0 +1,32 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://customer"
+ name="Consumer">
+
+ <component name="CustomerClient">
+ <implementation.java class="org.apache.tuscany.sca.binding.rss.CustomerClientImpl"/>
+ <reference name="resourceCollection">
+ <tuscany:binding.rss uri="http://localhost:8084/customer"/>
+ </reference>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/src/test/resources/org/apache/tuscany/sca/binding/rss/Provider.composite b/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/src/test/resources/org/apache/tuscany/sca/binding/rss/Provider.composite
new file mode 100644
index 0000000000..181267fa1d
--- /dev/null
+++ b/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss-runtime/src/test/resources/org/apache/tuscany/sca/binding/rss/Provider.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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace = "http://customer"
+ name="Provider">
+
+ <service name="customer" promote="CustomerCollection">
+ <tuscany:binding.rss uri = "http://localhost:8084/customer"/>
+ </service>
+
+ <component name="CustomerCollection">
+ <implementation.java class="org.apache.tuscany.sca.binding.rss.CustomerCollectionImpl"/>
+ </component>
+
+</composite>
diff --git a/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss/LICENSE b/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss/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/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss/META-INF/MANIFEST.MF b/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..a0886018d3
--- /dev/null
+++ b/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss/META-INF/MANIFEST.MF
@@ -0,0 +1,20 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.binding.rss;
+ uses:="org.apache.tuscany.sca.assembly";version="2.0.0"
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA RSS Feed Binding Extension
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA RSS Feed Binding Extension
+Import-Package: javax.xml.namespace,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.assembly.xml;version="2.0.0",
+ org.apache.tuscany.sca.binding.rss;version="2.0.0",
+ org.apache.tuscany.sca.core,
+ org.apache.tuscany.sca.monitor
+Bundle-SymbolicName: org.apache.tuscany.sca.binding.rss
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
+
diff --git a/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss/NOTICE b/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss/NOTICE
new file mode 100644
index 0000000000..d69e595698
--- /dev/null
+++ b/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2011 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss/pom.xml b/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss/pom.xml
new file mode 100644
index 0000000000..a52b183471
--- /dev/null
+++ b/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss/pom.xml
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-modules</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-binding-rss</artifactId>
+ <name>Apache Tuscany SCA RSS Feed Binding Extension</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-java</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-data-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-spi</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss/src/main/java/org/apache/tuscany/sca/binding/rss/RSSBinding.java b/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss/src/main/java/org/apache/tuscany/sca/binding/rss/RSSBinding.java
new file mode 100644
index 0000000000..bda3210e73
--- /dev/null
+++ b/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss/src/main/java/org/apache/tuscany/sca/binding/rss/RSSBinding.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.rss;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Binding;
+
+/**
+ * RSS Feed binding model.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface RSSBinding extends Binding {
+ QName TYPE = new QName(SCA11_TUSCANY_NS, "binding.rss");
+}
diff --git a/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss/src/main/java/org/apache/tuscany/sca/binding/rss/RSSBindingFactory.java b/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss/src/main/java/org/apache/tuscany/sca/binding/rss/RSSBindingFactory.java
new file mode 100644
index 0000000000..3e691e636e
--- /dev/null
+++ b/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss/src/main/java/org/apache/tuscany/sca/binding/rss/RSSBindingFactory.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 org.apache.tuscany.sca.binding.rss;
+
+/**
+ * Factory for the RSS binding
+ *
+ * @version $Rev$ $Date$
+ */
+public interface RSSBindingFactory {
+
+ /**
+ * Creates a new RSS binding.
+ * @return the new RSS binding
+ */
+ RSSBinding createRSSBinding();
+
+}
diff --git a/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss/src/main/java/org/apache/tuscany/sca/binding/rss/impl/RSSBindingFactoryImpl.java b/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss/src/main/java/org/apache/tuscany/sca/binding/rss/impl/RSSBindingFactoryImpl.java
new file mode 100644
index 0000000000..a4e6a8283d
--- /dev/null
+++ b/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss/src/main/java/org/apache/tuscany/sca/binding/rss/impl/RSSBindingFactoryImpl.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 org.apache.tuscany.sca.binding.rss.impl;
+
+import org.apache.tuscany.sca.binding.rss.RSSBinding;
+import org.apache.tuscany.sca.binding.rss.RSSBindingFactory;
+
+/**
+ * Factory for the RSS binding model.
+ *
+ * @version $Rev$ $Date$
+ */
+public class RSSBindingFactoryImpl implements RSSBindingFactory {
+
+ public RSSBinding createRSSBinding() {
+ return new RSSBindingImpl();
+ }
+
+}
diff --git a/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss/src/main/java/org/apache/tuscany/sca/binding/rss/impl/RSSBindingImpl.java b/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss/src/main/java/org/apache/tuscany/sca/binding/rss/impl/RSSBindingImpl.java
new file mode 100644
index 0000000000..00abffafb5
--- /dev/null
+++ b/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss/src/main/java/org/apache/tuscany/sca/binding/rss/impl/RSSBindingImpl.java
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.rss.impl;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.OperationSelector;
+import org.apache.tuscany.sca.assembly.WireFormat;
+import org.apache.tuscany.sca.binding.rss.RSSBinding;
+
+/**
+ * Implementation of the RSS Feed binding model.
+ *
+ * @version $Rev$ $Date$
+ */
+class RSSBindingImpl implements RSSBinding {
+
+ private String name;
+ private String uri;
+
+ public QName getType() {
+ return RSSBinding.TYPE;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getURI() {
+ return uri;
+ }
+
+ public void setURI(String uri) {
+ this.uri = uri;
+ }
+
+ public boolean isUnresolved() {
+ return false;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ // The binding is always resolved
+ }
+
+ public WireFormat getRequestWireFormat() {
+ return null;
+ }
+
+ public void setRequestWireFormat(WireFormat wireFormat) {
+ }
+
+ public WireFormat getResponseWireFormat() {
+ return null;
+ }
+
+ public void setResponseWireFormat(WireFormat wireFormat) {
+ }
+
+ public OperationSelector getOperationSelector() {
+ return null;
+ }
+
+ public void setOperationSelector(OperationSelector operationSelector) {
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+}
diff --git a/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.rss.RSSBindingFactory b/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.rss.RSSBindingFactory
new file mode 100644
index 0000000000..73c47a3f41
--- /dev/null
+++ b/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.rss.RSSBindingFactory
@@ -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 model factory
+org.apache.tuscany.sca.binding.rss.impl.RSSBindingFactoryImpl \ No newline at end of file
diff --git a/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
new file mode 100644
index 0000000000..d298c16673
--- /dev/null
+++ b/sandbox/sebastien/java/vhost/unreleased/modules/binding-rss/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
+org.apache.tuscany.sca.assembly.xml.DefaultBeanModelProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#binding.rss,model=org.apache.tuscany.sca.binding.rss.RSSBinding,factory=org.apache.tuscany.sca.binding.rss.RSSBindingFactory
diff --git a/sandbox/sebastien/java/vhost/unreleased/modules/databinding-protobuf/META-INF/MANIFEST.MF b/sandbox/sebastien/java/vhost/unreleased/modules/databinding-protobuf/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..d6aa1a741f
--- /dev/null
+++ b/sandbox/sebastien/java/vhost/unreleased/modules/databinding-protobuf/META-INF/MANIFEST.MF
@@ -0,0 +1,21 @@
+Manifest-Version: 1.0
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA Data Binding for Google ProtocolBuffers
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Data Binding for JSON
+Import-Package: javax.xml.namespace,
+ javax.xml.stream,
+ org.apache.tuscany.sca.common.xml.stax;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.databinding;version="2.0.0",
+ org.apache.tuscany.sca.databinding.impl;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.impl;version="2.0.0";resolution:=optional,
+ org.apache.tuscany.sca.interfacedef.util;version="2.0.0",
+ org.oasisopen.sca.annotation;version="2.0.0"
+Bundle-SymbolicName: org.apache.tuscany.sca.databinding.protobuf
+Bundle-DocURL: http://www.apache.org/
+
diff --git a/sandbox/sebastien/java/vhost/unreleased/modules/databinding-protobuf/pom.xml b/sandbox/sebastien/java/vhost/unreleased/modules/databinding-protobuf/pom.xml
new file mode 100644
index 0000000000..90b5ba1c68
--- /dev/null
+++ b/sandbox/sebastien/java/vhost/unreleased/modules/databinding-protobuf/pom.xml
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-modules</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-databinding-protobuf</artifactId>
+ <name>Apache Tuscany SCA Data Binding for Google ProtocolBuffers</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-spi</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-common-xml</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>com.google.protobuf</groupId>
+ <artifactId>protobuf-java</artifactId>
+ <version>2.3.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+</project>
diff --git a/sandbox/sebastien/java/vhost/unreleased/modules/databinding-protobuf/src/main/java/org/apache/tuscany/sca/databinding/protobuf/InputStream2Protobuf.java b/sandbox/sebastien/java/vhost/unreleased/modules/databinding-protobuf/src/main/java/org/apache/tuscany/sca/databinding/protobuf/InputStream2Protobuf.java
new file mode 100644
index 0000000000..7953e4e5b3
--- /dev/null
+++ b/sandbox/sebastien/java/vhost/unreleased/modules/databinding-protobuf/src/main/java/org/apache/tuscany/sca/databinding/protobuf/InputStream2Protobuf.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 org.apache.tuscany.sca.databinding.protobuf;
+
+import java.io.InputStream;
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+
+import com.google.protobuf.Message;
+
+/**
+ *
+ */
+public class InputStream2Protobuf implements PullTransformer<InputStream, Message> {
+
+ @Override
+ public String getSourceDataBinding() {
+ return "application/x-protobuf" + "#" + InputStream.class.getName();
+ }
+
+ @Override
+ public String getTargetDataBinding() {
+ // TODO Auto-generated method stub
+ return ProtobufDatabinding.NAME;
+ }
+
+ @Override
+ public int getWeight() {
+ // TODO Auto-generated method stub
+ return 10;
+ }
+
+ @Override
+ public Message transform(InputStream source, TransformationContext context) {
+ try {
+ Class<?> type = context.getTargetDataType().getPhysical();
+ Method method = type.getMethod("parseFrom", InputStream.class);
+ Object result = method.invoke(null, source);
+ return (Message)result;
+ } catch (Throwable e) {
+ throw new TransformationException(e);
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/vhost/unreleased/modules/databinding-protobuf/src/main/java/org/apache/tuscany/sca/databinding/protobuf/Protobuf2OutputStream.java b/sandbox/sebastien/java/vhost/unreleased/modules/databinding-protobuf/src/main/java/org/apache/tuscany/sca/databinding/protobuf/Protobuf2OutputStream.java
new file mode 100644
index 0000000000..6892287f67
--- /dev/null
+++ b/sandbox/sebastien/java/vhost/unreleased/modules/databinding-protobuf/src/main/java/org/apache/tuscany/sca/databinding/protobuf/Protobuf2OutputStream.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.databinding.protobuf;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import org.apache.tuscany.sca.databinding.PushTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+
+import com.google.protobuf.Message;
+
+/**
+ *
+ */
+public class Protobuf2OutputStream implements PushTransformer<Message, OutputStream> {
+ @Override
+ public String getSourceDataBinding() {
+ return ProtobufDatabinding.NAME;
+ }
+
+ @Override
+ public String getTargetDataBinding() {
+ return "application/x-protobuf" + "#" + OutputStream.class.getName();
+ }
+
+ @Override
+ public int getWeight() {
+ return 10;
+ }
+
+ @Override
+ public void transform(Message source, OutputStream sink, TransformationContext context) {
+ try {
+ if (source != null) {
+ source.writeTo(sink);
+ }
+ } catch (IOException e) {
+ throw new TransformationException(e);
+ }
+ }
+}
diff --git a/sandbox/sebastien/java/vhost/unreleased/modules/databinding-protobuf/src/main/java/org/apache/tuscany/sca/databinding/protobuf/ProtobufDatabinding.java b/sandbox/sebastien/java/vhost/unreleased/modules/databinding-protobuf/src/main/java/org/apache/tuscany/sca/databinding/protobuf/ProtobufDatabinding.java
new file mode 100644
index 0000000000..ad148c7499
--- /dev/null
+++ b/sandbox/sebastien/java/vhost/unreleased/modules/databinding-protobuf/src/main/java/org/apache/tuscany/sca/databinding/protobuf/ProtobufDatabinding.java
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.databinding.protobuf;
+
+import org.apache.tuscany.sca.databinding.DataBinding;
+import org.apache.tuscany.sca.databinding.WrapperHandler;
+import org.apache.tuscany.sca.databinding.XMLTypeHelper;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
+
+import com.google.protobuf.Message;
+
+/**
+ * Google ProtocolBuffers databinding
+ */
+public class ProtobufDatabinding implements DataBinding {
+
+ public static final String NAME = "ProtocolBuffers";
+
+ /**
+ *
+ */
+ public ProtobufDatabinding() {
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.tuscany.sca.databinding.DataBinding#getName()
+ */
+ @Override
+ public String getName() {
+ return NAME;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.tuscany.sca.databinding.DataBinding#introspect(org.apache.tuscany.sca.interfacedef.DataType, org.apache.tuscany.sca.interfacedef.Operation)
+ */
+ @Override
+ public boolean introspect(DataType dataType, Operation operation) {
+ if (Message.class.isAssignableFrom(dataType.getPhysical())) {
+ dataType.setDataBinding(NAME);
+ return true;
+ }
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.tuscany.sca.databinding.DataBinding#introspect(java.lang.Object, org.apache.tuscany.sca.interfacedef.Operation)
+ */
+ @Override
+ public DataType introspect(Object value, Operation operation) {
+ if (value instanceof Message) {
+ DataType dt = new DataTypeImpl(value.getClass(), null);
+ dt.setDataBinding(NAME);
+ return dt;
+ } else {
+ return null;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.tuscany.sca.databinding.DataBinding#getWrapperHandler()
+ */
+ @Override
+ public WrapperHandler getWrapperHandler() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.tuscany.sca.databinding.DataBinding#copy(java.lang.Object, org.apache.tuscany.sca.interfacedef.DataType, org.apache.tuscany.sca.interfacedef.DataType, org.apache.tuscany.sca.interfacedef.Operation, org.apache.tuscany.sca.interfacedef.Operation)
+ */
+ @Override
+ public Object copy(Object object,
+ DataType sourceDataType,
+ DataType targetDataType,
+ Operation sourceOperation,
+ Operation targetOperation) {
+ Message msg = (Message)object;
+ return ((Message.Builder)msg.toBuilder().clone()).build();
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.tuscany.sca.databinding.DataBinding#getXMLTypeHelper()
+ */
+ @Override
+ public XMLTypeHelper getXMLTypeHelper() {
+ return null;
+ }
+
+}
diff --git a/sandbox/sebastien/java/vhost/unreleased/modules/databinding-protobuf/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.DataBinding b/sandbox/sebastien/java/vhost/unreleased/modules/databinding-protobuf/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.DataBinding
new file mode 100644
index 0000000000..35f7932ff9
--- /dev/null
+++ b/sandbox/sebastien/java/vhost/unreleased/modules/databinding-protobuf/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.DataBinding
@@ -0,0 +1,20 @@
+# 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 classes for the databindings
+org.apache.tuscany.sca.databinding.protobuf.ProtobufDatabinding;name=ProtocolBuffers
+
diff --git a/sandbox/sebastien/java/vhost/unreleased/modules/databinding-protobuf/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer b/sandbox/sebastien/java/vhost/unreleased/modules/databinding-protobuf/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer
new file mode 100644
index 0000000000..0f60373c30
--- /dev/null
+++ b/sandbox/sebastien/java/vhost/unreleased/modules/databinding-protobuf/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer
@@ -0,0 +1,20 @@
+# 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 classes for the transformers
+org.apache.tuscany.sca.databinding.protobuf.InputStream2Protobuf;source=application/x-protobuf#java.io.InputStream;target=ProtocolBuffers,weight=10,public=true
+
diff --git a/sandbox/sebastien/java/vhost/unreleased/modules/databinding-protobuf/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PushTransformer b/sandbox/sebastien/java/vhost/unreleased/modules/databinding-protobuf/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PushTransformer
new file mode 100644
index 0000000000..cc1989eb7b
--- /dev/null
+++ b/sandbox/sebastien/java/vhost/unreleased/modules/databinding-protobuf/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PushTransformer
@@ -0,0 +1,17 @@
+# 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.
+org.apache.tuscany.sca.databinding.protobuf.Protobuf2OutputStream;source=ProtocolBuffers;target=application/x-protobuf#java.io.OutputStream,weight=10,public=true
diff --git a/sandbox/sebastien/java/vhost/unreleased/modules/databinding-protobuf/src/test/java/com/example/tutorial/AddressBookProtos.java b/sandbox/sebastien/java/vhost/unreleased/modules/databinding-protobuf/src/test/java/com/example/tutorial/AddressBookProtos.java
new file mode 100644
index 0000000000..8219fe1099
--- /dev/null
+++ b/sandbox/sebastien/java/vhost/unreleased/modules/databinding-protobuf/src/test/java/com/example/tutorial/AddressBookProtos.java
@@ -0,0 +1,1375 @@
+/*
+ * 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.
+ */
+// Generated by the protocol buffer compiler. DO NOT EDIT!
+// source: addressbook.proto
+
+package com.example.tutorial;
+
+public final class AddressBookProtos {
+ private AddressBookProtos() {
+ }
+
+ public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry registry) {
+ }
+
+ public static final class Person extends com.google.protobuf.GeneratedMessage {
+ // Use Person.newBuilder() to construct.
+ private Person() {
+ initFields();
+ }
+
+ private Person(boolean noInit) {
+ }
+
+ private static final Person defaultInstance;
+
+ public static Person getDefaultInstance() {
+ return defaultInstance;
+ }
+
+ public Person getDefaultInstanceForType() {
+ return defaultInstance;
+ }
+
+ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
+ return com.example.tutorial.AddressBookProtos.internal_static_tutorial_Person_descriptor;
+ }
+
+ protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable() {
+ return com.example.tutorial.AddressBookProtos.internal_static_tutorial_Person_fieldAccessorTable;
+ }
+
+ public enum PhoneType implements com.google.protobuf.ProtocolMessageEnum {
+ MOBILE(0, 0), HOME(1, 1), WORK(2, 2), ;
+
+ public final int getNumber() {
+ return value;
+ }
+
+ public static PhoneType valueOf(int value) {
+ switch (value) {
+ case 0:
+ return MOBILE;
+ case 1:
+ return HOME;
+ case 2:
+ return WORK;
+ default:
+ return null;
+ }
+ }
+
+ public static com.google.protobuf.Internal.EnumLiteMap<PhoneType> internalGetValueMap() {
+ return internalValueMap;
+ }
+
+ private static com.google.protobuf.Internal.EnumLiteMap<PhoneType> internalValueMap =
+ new com.google.protobuf.Internal.EnumLiteMap<PhoneType>() {
+ public PhoneType findValueByNumber(int number) {
+ return PhoneType.valueOf(number);
+ }
+ };
+
+ public final com.google.protobuf.Descriptors.EnumValueDescriptor getValueDescriptor() {
+ return getDescriptor().getValues().get(index);
+ }
+
+ public final com.google.protobuf.Descriptors.EnumDescriptor getDescriptorForType() {
+ return getDescriptor();
+ }
+
+ public static final com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() {
+ return com.example.tutorial.AddressBookProtos.Person.getDescriptor().getEnumTypes().get(0);
+ }
+
+ private static final PhoneType[] VALUES = {MOBILE, HOME, WORK,};
+
+ public static PhoneType valueOf(com.google.protobuf.Descriptors.EnumValueDescriptor desc) {
+ if (desc.getType() != getDescriptor()) {
+ throw new java.lang.IllegalArgumentException("EnumValueDescriptor is not for this type.");
+ }
+ return VALUES[desc.getIndex()];
+ }
+
+ private final int index;
+ private final int value;
+
+ private PhoneType(int index, int value) {
+ this.index = index;
+ this.value = value;
+ }
+
+ static {
+ com.example.tutorial.AddressBookProtos.getDescriptor();
+ }
+
+ // @@protoc_insertion_point(enum_scope:tutorial.Person.PhoneType)
+ }
+
+ public static final class PhoneNumber extends com.google.protobuf.GeneratedMessage {
+ // Use PhoneNumber.newBuilder() to construct.
+ private PhoneNumber() {
+ initFields();
+ }
+
+ private PhoneNumber(boolean noInit) {
+ }
+
+ private static final PhoneNumber defaultInstance;
+
+ public static PhoneNumber getDefaultInstance() {
+ return defaultInstance;
+ }
+
+ public PhoneNumber getDefaultInstanceForType() {
+ return defaultInstance;
+ }
+
+ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
+ return com.example.tutorial.AddressBookProtos.internal_static_tutorial_Person_PhoneNumber_descriptor;
+ }
+
+ protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable() {
+ return com.example.tutorial.AddressBookProtos.internal_static_tutorial_Person_PhoneNumber_fieldAccessorTable;
+ }
+
+ // required string number = 1;
+ public static final int NUMBER_FIELD_NUMBER = 1;
+ private boolean hasNumber;
+ private java.lang.String number_ = "";
+
+ public boolean hasNumber() {
+ return hasNumber;
+ }
+
+ public java.lang.String getNumber() {
+ return number_;
+ }
+
+ // optional .tutorial.Person.PhoneType type = 2 [default = HOME];
+ public static final int TYPE_FIELD_NUMBER = 2;
+ private boolean hasType;
+ private com.example.tutorial.AddressBookProtos.Person.PhoneType type_;
+
+ public boolean hasType() {
+ return hasType;
+ }
+
+ public com.example.tutorial.AddressBookProtos.Person.PhoneType getType() {
+ return type_;
+ }
+
+ private void initFields() {
+ type_ = com.example.tutorial.AddressBookProtos.Person.PhoneType.HOME;
+ }
+
+ public final boolean isInitialized() {
+ if (!hasNumber)
+ return false;
+ return true;
+ }
+
+ public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException {
+ getSerializedSize();
+ if (hasNumber()) {
+ output.writeString(1, getNumber());
+ }
+ if (hasType()) {
+ output.writeEnum(2, getType().getNumber());
+ }
+ getUnknownFields().writeTo(output);
+ }
+
+ private int memoizedSerializedSize = -1;
+
+ public int getSerializedSize() {
+ int size = memoizedSerializedSize;
+ if (size != -1)
+ return size;
+
+ size = 0;
+ if (hasNumber()) {
+ size += com.google.protobuf.CodedOutputStream.computeStringSize(1, getNumber());
+ }
+ if (hasType()) {
+ size += com.google.protobuf.CodedOutputStream.computeEnumSize(2, getType().getNumber());
+ }
+ size += getUnknownFields().getSerializedSize();
+ memoizedSerializedSize = size;
+ return size;
+ }
+
+ public static com.example.tutorial.AddressBookProtos.Person.PhoneNumber parseFrom(com.google.protobuf.ByteString data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return newBuilder().mergeFrom(data).buildParsed();
+ }
+
+ public static com.example.tutorial.AddressBookProtos.Person.PhoneNumber parseFrom(com.google.protobuf.ByteString data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return newBuilder().mergeFrom(data, extensionRegistry).buildParsed();
+ }
+
+ public static com.example.tutorial.AddressBookProtos.Person.PhoneNumber parseFrom(byte[] data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return newBuilder().mergeFrom(data).buildParsed();
+ }
+
+ public static com.example.tutorial.AddressBookProtos.Person.PhoneNumber parseFrom(byte[] data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return newBuilder().mergeFrom(data, extensionRegistry).buildParsed();
+ }
+
+ public static com.example.tutorial.AddressBookProtos.Person.PhoneNumber parseFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ return newBuilder().mergeFrom(input).buildParsed();
+ }
+
+ public static com.example.tutorial.AddressBookProtos.Person.PhoneNumber parseFrom(java.io.InputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return newBuilder().mergeFrom(input, extensionRegistry).buildParsed();
+ }
+
+ public static com.example.tutorial.AddressBookProtos.Person.PhoneNumber parseDelimitedFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ Builder builder = newBuilder();
+ if (builder.mergeDelimitedFrom(input)) {
+ return builder.buildParsed();
+ } else {
+ return null;
+ }
+ }
+
+ public static com.example.tutorial.AddressBookProtos.Person.PhoneNumber parseDelimitedFrom(java.io.InputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ Builder builder = newBuilder();
+ if (builder.mergeDelimitedFrom(input, extensionRegistry)) {
+ return builder.buildParsed();
+ } else {
+ return null;
+ }
+ }
+
+ public static com.example.tutorial.AddressBookProtos.Person.PhoneNumber parseFrom(com.google.protobuf.CodedInputStream input)
+ throws java.io.IOException {
+ return newBuilder().mergeFrom(input).buildParsed();
+ }
+
+ public static com.example.tutorial.AddressBookProtos.Person.PhoneNumber parseFrom(com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return newBuilder().mergeFrom(input, extensionRegistry).buildParsed();
+ }
+
+ public static Builder newBuilder() {
+ return Builder.create();
+ }
+
+ public Builder newBuilderForType() {
+ return newBuilder();
+ }
+
+ public static Builder newBuilder(com.example.tutorial.AddressBookProtos.Person.PhoneNumber prototype) {
+ return newBuilder().mergeFrom(prototype);
+ }
+
+ public Builder toBuilder() {
+ return newBuilder(this);
+ }
+
+ public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder<Builder> {
+ private com.example.tutorial.AddressBookProtos.Person.PhoneNumber result;
+
+ // Construct using com.example.tutorial.AddressBookProtos.Person.PhoneNumber.newBuilder()
+ private Builder() {
+ }
+
+ private static Builder create() {
+ Builder builder = new Builder();
+ builder.result = new com.example.tutorial.AddressBookProtos.Person.PhoneNumber();
+ return builder;
+ }
+
+ protected com.example.tutorial.AddressBookProtos.Person.PhoneNumber internalGetResult() {
+ return result;
+ }
+
+ public Builder clear() {
+ if (result == null) {
+ throw new IllegalStateException("Cannot call clear() after build().");
+ }
+ result = new com.example.tutorial.AddressBookProtos.Person.PhoneNumber();
+ return this;
+ }
+
+ public Builder clone() {
+ return create().mergeFrom(result);
+ }
+
+ public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() {
+ return com.example.tutorial.AddressBookProtos.Person.PhoneNumber.getDescriptor();
+ }
+
+ public com.example.tutorial.AddressBookProtos.Person.PhoneNumber getDefaultInstanceForType() {
+ return com.example.tutorial.AddressBookProtos.Person.PhoneNumber.getDefaultInstance();
+ }
+
+ public boolean isInitialized() {
+ return result.isInitialized();
+ }
+
+ public com.example.tutorial.AddressBookProtos.Person.PhoneNumber build() {
+ if (result != null && !isInitialized()) {
+ throw newUninitializedMessageException(result);
+ }
+ return buildPartial();
+ }
+
+ private com.example.tutorial.AddressBookProtos.Person.PhoneNumber buildParsed()
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ if (!isInitialized()) {
+ throw newUninitializedMessageException(result).asInvalidProtocolBufferException();
+ }
+ return buildPartial();
+ }
+
+ public com.example.tutorial.AddressBookProtos.Person.PhoneNumber buildPartial() {
+ if (result == null) {
+ throw new IllegalStateException("build() has already been called on this Builder.");
+ }
+ com.example.tutorial.AddressBookProtos.Person.PhoneNumber returnMe = result;
+ result = null;
+ return returnMe;
+ }
+
+ public Builder mergeFrom(com.google.protobuf.Message other) {
+ if (other instanceof com.example.tutorial.AddressBookProtos.Person.PhoneNumber) {
+ return mergeFrom((com.example.tutorial.AddressBookProtos.Person.PhoneNumber)other);
+ } else {
+ super.mergeFrom(other);
+ return this;
+ }
+ }
+
+ public Builder mergeFrom(com.example.tutorial.AddressBookProtos.Person.PhoneNumber other) {
+ if (other == com.example.tutorial.AddressBookProtos.Person.PhoneNumber.getDefaultInstance())
+ return this;
+ if (other.hasNumber()) {
+ setNumber(other.getNumber());
+ }
+ if (other.hasType()) {
+ setType(other.getType());
+ }
+ this.mergeUnknownFields(other.getUnknownFields());
+ return this;
+ }
+
+ public Builder mergeFrom(com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ com.google.protobuf.UnknownFieldSet.Builder unknownFields =
+ com.google.protobuf.UnknownFieldSet.newBuilder(this.getUnknownFields());
+ while (true) {
+ int tag = input.readTag();
+ switch (tag) {
+ case 0:
+ this.setUnknownFields(unknownFields.build());
+ return this;
+ default: {
+ if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) {
+ this.setUnknownFields(unknownFields.build());
+ return this;
+ }
+ break;
+ }
+ case 10: {
+ setNumber(input.readString());
+ break;
+ }
+ case 16: {
+ int rawValue = input.readEnum();
+ com.example.tutorial.AddressBookProtos.Person.PhoneType value =
+ com.example.tutorial.AddressBookProtos.Person.PhoneType.valueOf(rawValue);
+ if (value == null) {
+ unknownFields.mergeVarintField(2, rawValue);
+ } else {
+ setType(value);
+ }
+ break;
+ }
+ }
+ }
+ }
+
+ // required string number = 1;
+ public boolean hasNumber() {
+ return result.hasNumber();
+ }
+
+ public java.lang.String getNumber() {
+ return result.getNumber();
+ }
+
+ public Builder setNumber(java.lang.String value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ result.hasNumber = true;
+ result.number_ = value;
+ return this;
+ }
+
+ public Builder clearNumber() {
+ result.hasNumber = false;
+ result.number_ = getDefaultInstance().getNumber();
+ return this;
+ }
+
+ // optional .tutorial.Person.PhoneType type = 2 [default = HOME];
+ public boolean hasType() {
+ return result.hasType();
+ }
+
+ public com.example.tutorial.AddressBookProtos.Person.PhoneType getType() {
+ return result.getType();
+ }
+
+ public Builder setType(com.example.tutorial.AddressBookProtos.Person.PhoneType value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ result.hasType = true;
+ result.type_ = value;
+ return this;
+ }
+
+ public Builder clearType() {
+ result.hasType = false;
+ result.type_ = com.example.tutorial.AddressBookProtos.Person.PhoneType.HOME;
+ return this;
+ }
+
+ // @@protoc_insertion_point(builder_scope:tutorial.Person.PhoneNumber)
+ }
+
+ static {
+ defaultInstance = new PhoneNumber(true);
+ com.example.tutorial.AddressBookProtos.internalForceInit();
+ defaultInstance.initFields();
+ }
+
+ // @@protoc_insertion_point(class_scope:tutorial.Person.PhoneNumber)
+ }
+
+ // required string name = 1;
+ public static final int NAME_FIELD_NUMBER = 1;
+ private boolean hasName;
+ private java.lang.String name_ = "";
+
+ public boolean hasName() {
+ return hasName;
+ }
+
+ public java.lang.String getName() {
+ return name_;
+ }
+
+ // required int32 id = 2;
+ public static final int ID_FIELD_NUMBER = 2;
+ private boolean hasId;
+ private int id_ = 0;
+
+ public boolean hasId() {
+ return hasId;
+ }
+
+ public int getId() {
+ return id_;
+ }
+
+ // optional string email = 3;
+ public static final int EMAIL_FIELD_NUMBER = 3;
+ private boolean hasEmail;
+ private java.lang.String email_ = "";
+
+ public boolean hasEmail() {
+ return hasEmail;
+ }
+
+ public java.lang.String getEmail() {
+ return email_;
+ }
+
+ // repeated .tutorial.Person.PhoneNumber phone = 4;
+ public static final int PHONE_FIELD_NUMBER = 4;
+ private java.util.List<com.example.tutorial.AddressBookProtos.Person.PhoneNumber> phone_ =
+ java.util.Collections.emptyList();
+
+ public java.util.List<com.example.tutorial.AddressBookProtos.Person.PhoneNumber> getPhoneList() {
+ return phone_;
+ }
+
+ public int getPhoneCount() {
+ return phone_.size();
+ }
+
+ public com.example.tutorial.AddressBookProtos.Person.PhoneNumber getPhone(int index) {
+ return phone_.get(index);
+ }
+
+ private void initFields() {
+ }
+
+ public final boolean isInitialized() {
+ if (!hasName)
+ return false;
+ if (!hasId)
+ return false;
+ for (com.example.tutorial.AddressBookProtos.Person.PhoneNumber element : getPhoneList()) {
+ if (!element.isInitialized())
+ return false;
+ }
+ return true;
+ }
+
+ public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException {
+ getSerializedSize();
+ if (hasName()) {
+ output.writeString(1, getName());
+ }
+ if (hasId()) {
+ output.writeInt32(2, getId());
+ }
+ if (hasEmail()) {
+ output.writeString(3, getEmail());
+ }
+ for (com.example.tutorial.AddressBookProtos.Person.PhoneNumber element : getPhoneList()) {
+ output.writeMessage(4, element);
+ }
+ getUnknownFields().writeTo(output);
+ }
+
+ private int memoizedSerializedSize = -1;
+
+ public int getSerializedSize() {
+ int size = memoizedSerializedSize;
+ if (size != -1)
+ return size;
+
+ size = 0;
+ if (hasName()) {
+ size += com.google.protobuf.CodedOutputStream.computeStringSize(1, getName());
+ }
+ if (hasId()) {
+ size += com.google.protobuf.CodedOutputStream.computeInt32Size(2, getId());
+ }
+ if (hasEmail()) {
+ size += com.google.protobuf.CodedOutputStream.computeStringSize(3, getEmail());
+ }
+ for (com.example.tutorial.AddressBookProtos.Person.PhoneNumber element : getPhoneList()) {
+ size += com.google.protobuf.CodedOutputStream.computeMessageSize(4, element);
+ }
+ size += getUnknownFields().getSerializedSize();
+ memoizedSerializedSize = size;
+ return size;
+ }
+
+ public static com.example.tutorial.AddressBookProtos.Person parseFrom(com.google.protobuf.ByteString data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return newBuilder().mergeFrom(data).buildParsed();
+ }
+
+ public static com.example.tutorial.AddressBookProtos.Person parseFrom(com.google.protobuf.ByteString data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return newBuilder().mergeFrom(data, extensionRegistry).buildParsed();
+ }
+
+ public static com.example.tutorial.AddressBookProtos.Person parseFrom(byte[] data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return newBuilder().mergeFrom(data).buildParsed();
+ }
+
+ public static com.example.tutorial.AddressBookProtos.Person parseFrom(byte[] data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return newBuilder().mergeFrom(data, extensionRegistry).buildParsed();
+ }
+
+ public static com.example.tutorial.AddressBookProtos.Person parseFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ return newBuilder().mergeFrom(input).buildParsed();
+ }
+
+ public static com.example.tutorial.AddressBookProtos.Person parseFrom(java.io.InputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return newBuilder().mergeFrom(input, extensionRegistry).buildParsed();
+ }
+
+ public static com.example.tutorial.AddressBookProtos.Person parseDelimitedFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ Builder builder = newBuilder();
+ if (builder.mergeDelimitedFrom(input)) {
+ return builder.buildParsed();
+ } else {
+ return null;
+ }
+ }
+
+ public static com.example.tutorial.AddressBookProtos.Person parseDelimitedFrom(java.io.InputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ Builder builder = newBuilder();
+ if (builder.mergeDelimitedFrom(input, extensionRegistry)) {
+ return builder.buildParsed();
+ } else {
+ return null;
+ }
+ }
+
+ public static com.example.tutorial.AddressBookProtos.Person parseFrom(com.google.protobuf.CodedInputStream input)
+ throws java.io.IOException {
+ return newBuilder().mergeFrom(input).buildParsed();
+ }
+
+ public static com.example.tutorial.AddressBookProtos.Person parseFrom(com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return newBuilder().mergeFrom(input, extensionRegistry).buildParsed();
+ }
+
+ public static Builder newBuilder() {
+ return Builder.create();
+ }
+
+ public Builder newBuilderForType() {
+ return newBuilder();
+ }
+
+ public static Builder newBuilder(com.example.tutorial.AddressBookProtos.Person prototype) {
+ return newBuilder().mergeFrom(prototype);
+ }
+
+ public Builder toBuilder() {
+ return newBuilder(this);
+ }
+
+ public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder<Builder> {
+ private com.example.tutorial.AddressBookProtos.Person result;
+
+ // Construct using com.example.tutorial.AddressBookProtos.Person.newBuilder()
+ private Builder() {
+ }
+
+ private static Builder create() {
+ Builder builder = new Builder();
+ builder.result = new com.example.tutorial.AddressBookProtos.Person();
+ return builder;
+ }
+
+ protected com.example.tutorial.AddressBookProtos.Person internalGetResult() {
+ return result;
+ }
+
+ public Builder clear() {
+ if (result == null) {
+ throw new IllegalStateException("Cannot call clear() after build().");
+ }
+ result = new com.example.tutorial.AddressBookProtos.Person();
+ return this;
+ }
+
+ public Builder clone() {
+ return create().mergeFrom(result);
+ }
+
+ public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() {
+ return com.example.tutorial.AddressBookProtos.Person.getDescriptor();
+ }
+
+ public com.example.tutorial.AddressBookProtos.Person getDefaultInstanceForType() {
+ return com.example.tutorial.AddressBookProtos.Person.getDefaultInstance();
+ }
+
+ public boolean isInitialized() {
+ return result.isInitialized();
+ }
+
+ public com.example.tutorial.AddressBookProtos.Person build() {
+ if (result != null && !isInitialized()) {
+ throw newUninitializedMessageException(result);
+ }
+ return buildPartial();
+ }
+
+ private com.example.tutorial.AddressBookProtos.Person buildParsed()
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ if (!isInitialized()) {
+ throw newUninitializedMessageException(result).asInvalidProtocolBufferException();
+ }
+ return buildPartial();
+ }
+
+ public com.example.tutorial.AddressBookProtos.Person buildPartial() {
+ if (result == null) {
+ throw new IllegalStateException("build() has already been called on this Builder.");
+ }
+ if (result.phone_ != java.util.Collections.EMPTY_LIST) {
+ result.phone_ = java.util.Collections.unmodifiableList(result.phone_);
+ }
+ com.example.tutorial.AddressBookProtos.Person returnMe = result;
+ result = null;
+ return returnMe;
+ }
+
+ public Builder mergeFrom(com.google.protobuf.Message other) {
+ if (other instanceof com.example.tutorial.AddressBookProtos.Person) {
+ return mergeFrom((com.example.tutorial.AddressBookProtos.Person)other);
+ } else {
+ super.mergeFrom(other);
+ return this;
+ }
+ }
+
+ public Builder mergeFrom(com.example.tutorial.AddressBookProtos.Person other) {
+ if (other == com.example.tutorial.AddressBookProtos.Person.getDefaultInstance())
+ return this;
+ if (other.hasName()) {
+ setName(other.getName());
+ }
+ if (other.hasId()) {
+ setId(other.getId());
+ }
+ if (other.hasEmail()) {
+ setEmail(other.getEmail());
+ }
+ if (!other.phone_.isEmpty()) {
+ if (result.phone_.isEmpty()) {
+ result.phone_ =
+ new java.util.ArrayList<com.example.tutorial.AddressBookProtos.Person.PhoneNumber>();
+ }
+ result.phone_.addAll(other.phone_);
+ }
+ this.mergeUnknownFields(other.getUnknownFields());
+ return this;
+ }
+
+ public Builder mergeFrom(com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ com.google.protobuf.UnknownFieldSet.Builder unknownFields =
+ com.google.protobuf.UnknownFieldSet.newBuilder(this.getUnknownFields());
+ while (true) {
+ int tag = input.readTag();
+ switch (tag) {
+ case 0:
+ this.setUnknownFields(unknownFields.build());
+ return this;
+ default: {
+ if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) {
+ this.setUnknownFields(unknownFields.build());
+ return this;
+ }
+ break;
+ }
+ case 10: {
+ setName(input.readString());
+ break;
+ }
+ case 16: {
+ setId(input.readInt32());
+ break;
+ }
+ case 26: {
+ setEmail(input.readString());
+ break;
+ }
+ case 34: {
+ com.example.tutorial.AddressBookProtos.Person.PhoneNumber.Builder subBuilder =
+ com.example.tutorial.AddressBookProtos.Person.PhoneNumber.newBuilder();
+ input.readMessage(subBuilder, extensionRegistry);
+ addPhone(subBuilder.buildPartial());
+ break;
+ }
+ }
+ }
+ }
+
+ // required string name = 1;
+ public boolean hasName() {
+ return result.hasName();
+ }
+
+ public java.lang.String getName() {
+ return result.getName();
+ }
+
+ public Builder setName(java.lang.String value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ result.hasName = true;
+ result.name_ = value;
+ return this;
+ }
+
+ public Builder clearName() {
+ result.hasName = false;
+ result.name_ = getDefaultInstance().getName();
+ return this;
+ }
+
+ // required int32 id = 2;
+ public boolean hasId() {
+ return result.hasId();
+ }
+
+ public int getId() {
+ return result.getId();
+ }
+
+ public Builder setId(int value) {
+ result.hasId = true;
+ result.id_ = value;
+ return this;
+ }
+
+ public Builder clearId() {
+ result.hasId = false;
+ result.id_ = 0;
+ return this;
+ }
+
+ // optional string email = 3;
+ public boolean hasEmail() {
+ return result.hasEmail();
+ }
+
+ public java.lang.String getEmail() {
+ return result.getEmail();
+ }
+
+ public Builder setEmail(java.lang.String value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ result.hasEmail = true;
+ result.email_ = value;
+ return this;
+ }
+
+ public Builder clearEmail() {
+ result.hasEmail = false;
+ result.email_ = getDefaultInstance().getEmail();
+ return this;
+ }
+
+ // repeated .tutorial.Person.PhoneNumber phone = 4;
+ public java.util.List<com.example.tutorial.AddressBookProtos.Person.PhoneNumber> getPhoneList() {
+ return java.util.Collections.unmodifiableList(result.phone_);
+ }
+
+ public int getPhoneCount() {
+ return result.getPhoneCount();
+ }
+
+ public com.example.tutorial.AddressBookProtos.Person.PhoneNumber getPhone(int index) {
+ return result.getPhone(index);
+ }
+
+ public Builder setPhone(int index, com.example.tutorial.AddressBookProtos.Person.PhoneNumber value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ result.phone_.set(index, value);
+ return this;
+ }
+
+ public Builder setPhone(int index,
+ com.example.tutorial.AddressBookProtos.Person.PhoneNumber.Builder builderForValue) {
+ result.phone_.set(index, builderForValue.build());
+ return this;
+ }
+
+ public Builder addPhone(com.example.tutorial.AddressBookProtos.Person.PhoneNumber value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ if (result.phone_.isEmpty()) {
+ result.phone_ =
+ new java.util.ArrayList<com.example.tutorial.AddressBookProtos.Person.PhoneNumber>();
+ }
+ result.phone_.add(value);
+ return this;
+ }
+
+ public Builder addPhone(com.example.tutorial.AddressBookProtos.Person.PhoneNumber.Builder builderForValue) {
+ if (result.phone_.isEmpty()) {
+ result.phone_ =
+ new java.util.ArrayList<com.example.tutorial.AddressBookProtos.Person.PhoneNumber>();
+ }
+ result.phone_.add(builderForValue.build());
+ return this;
+ }
+
+ public Builder addAllPhone(java.lang.Iterable<? extends com.example.tutorial.AddressBookProtos.Person.PhoneNumber> values) {
+ if (result.phone_.isEmpty()) {
+ result.phone_ =
+ new java.util.ArrayList<com.example.tutorial.AddressBookProtos.Person.PhoneNumber>();
+ }
+ super.addAll(values, result.phone_);
+ return this;
+ }
+
+ public Builder clearPhone() {
+ result.phone_ = java.util.Collections.emptyList();
+ return this;
+ }
+
+ // @@protoc_insertion_point(builder_scope:tutorial.Person)
+ }
+
+ static {
+ defaultInstance = new Person(true);
+ com.example.tutorial.AddressBookProtos.internalForceInit();
+ defaultInstance.initFields();
+ }
+
+ // @@protoc_insertion_point(class_scope:tutorial.Person)
+ }
+
+ public static final class AddressBook extends com.google.protobuf.GeneratedMessage {
+ // Use AddressBook.newBuilder() to construct.
+ private AddressBook() {
+ initFields();
+ }
+
+ private AddressBook(boolean noInit) {
+ }
+
+ private static final AddressBook defaultInstance;
+
+ public static AddressBook getDefaultInstance() {
+ return defaultInstance;
+ }
+
+ public AddressBook getDefaultInstanceForType() {
+ return defaultInstance;
+ }
+
+ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
+ return com.example.tutorial.AddressBookProtos.internal_static_tutorial_AddressBook_descriptor;
+ }
+
+ protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable() {
+ return com.example.tutorial.AddressBookProtos.internal_static_tutorial_AddressBook_fieldAccessorTable;
+ }
+
+ // repeated .tutorial.Person person = 1;
+ public static final int PERSON_FIELD_NUMBER = 1;
+ private java.util.List<com.example.tutorial.AddressBookProtos.Person> person_ = java.util.Collections
+ .emptyList();
+
+ public java.util.List<com.example.tutorial.AddressBookProtos.Person> getPersonList() {
+ return person_;
+ }
+
+ public int getPersonCount() {
+ return person_.size();
+ }
+
+ public com.example.tutorial.AddressBookProtos.Person getPerson(int index) {
+ return person_.get(index);
+ }
+
+ private void initFields() {
+ }
+
+ public final boolean isInitialized() {
+ for (com.example.tutorial.AddressBookProtos.Person element : getPersonList()) {
+ if (!element.isInitialized())
+ return false;
+ }
+ return true;
+ }
+
+ public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException {
+ getSerializedSize();
+ for (com.example.tutorial.AddressBookProtos.Person element : getPersonList()) {
+ output.writeMessage(1, element);
+ }
+ getUnknownFields().writeTo(output);
+ }
+
+ private int memoizedSerializedSize = -1;
+
+ public int getSerializedSize() {
+ int size = memoizedSerializedSize;
+ if (size != -1)
+ return size;
+
+ size = 0;
+ for (com.example.tutorial.AddressBookProtos.Person element : getPersonList()) {
+ size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, element);
+ }
+ size += getUnknownFields().getSerializedSize();
+ memoizedSerializedSize = size;
+ return size;
+ }
+
+ public static com.example.tutorial.AddressBookProtos.AddressBook parseFrom(com.google.protobuf.ByteString data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return newBuilder().mergeFrom(data).buildParsed();
+ }
+
+ public static com.example.tutorial.AddressBookProtos.AddressBook parseFrom(com.google.protobuf.ByteString data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return newBuilder().mergeFrom(data, extensionRegistry).buildParsed();
+ }
+
+ public static com.example.tutorial.AddressBookProtos.AddressBook parseFrom(byte[] data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return newBuilder().mergeFrom(data).buildParsed();
+ }
+
+ public static com.example.tutorial.AddressBookProtos.AddressBook parseFrom(byte[] data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return newBuilder().mergeFrom(data, extensionRegistry).buildParsed();
+ }
+
+ public static com.example.tutorial.AddressBookProtos.AddressBook parseFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ return newBuilder().mergeFrom(input).buildParsed();
+ }
+
+ public static com.example.tutorial.AddressBookProtos.AddressBook parseFrom(java.io.InputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return newBuilder().mergeFrom(input, extensionRegistry).buildParsed();
+ }
+
+ public static com.example.tutorial.AddressBookProtos.AddressBook parseDelimitedFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ Builder builder = newBuilder();
+ if (builder.mergeDelimitedFrom(input)) {
+ return builder.buildParsed();
+ } else {
+ return null;
+ }
+ }
+
+ public static com.example.tutorial.AddressBookProtos.AddressBook parseDelimitedFrom(java.io.InputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ Builder builder = newBuilder();
+ if (builder.mergeDelimitedFrom(input, extensionRegistry)) {
+ return builder.buildParsed();
+ } else {
+ return null;
+ }
+ }
+
+ public static com.example.tutorial.AddressBookProtos.AddressBook parseFrom(com.google.protobuf.CodedInputStream input)
+ throws java.io.IOException {
+ return newBuilder().mergeFrom(input).buildParsed();
+ }
+
+ public static com.example.tutorial.AddressBookProtos.AddressBook parseFrom(com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return newBuilder().mergeFrom(input, extensionRegistry).buildParsed();
+ }
+
+ public static Builder newBuilder() {
+ return Builder.create();
+ }
+
+ public Builder newBuilderForType() {
+ return newBuilder();
+ }
+
+ public static Builder newBuilder(com.example.tutorial.AddressBookProtos.AddressBook prototype) {
+ return newBuilder().mergeFrom(prototype);
+ }
+
+ public Builder toBuilder() {
+ return newBuilder(this);
+ }
+
+ public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder<Builder> {
+ private com.example.tutorial.AddressBookProtos.AddressBook result;
+
+ // Construct using com.example.tutorial.AddressBookProtos.AddressBook.newBuilder()
+ private Builder() {
+ }
+
+ private static Builder create() {
+ Builder builder = new Builder();
+ builder.result = new com.example.tutorial.AddressBookProtos.AddressBook();
+ return builder;
+ }
+
+ protected com.example.tutorial.AddressBookProtos.AddressBook internalGetResult() {
+ return result;
+ }
+
+ public Builder clear() {
+ if (result == null) {
+ throw new IllegalStateException("Cannot call clear() after build().");
+ }
+ result = new com.example.tutorial.AddressBookProtos.AddressBook();
+ return this;
+ }
+
+ public Builder clone() {
+ return create().mergeFrom(result);
+ }
+
+ public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() {
+ return com.example.tutorial.AddressBookProtos.AddressBook.getDescriptor();
+ }
+
+ public com.example.tutorial.AddressBookProtos.AddressBook getDefaultInstanceForType() {
+ return com.example.tutorial.AddressBookProtos.AddressBook.getDefaultInstance();
+ }
+
+ public boolean isInitialized() {
+ return result.isInitialized();
+ }
+
+ public com.example.tutorial.AddressBookProtos.AddressBook build() {
+ if (result != null && !isInitialized()) {
+ throw newUninitializedMessageException(result);
+ }
+ return buildPartial();
+ }
+
+ private com.example.tutorial.AddressBookProtos.AddressBook buildParsed()
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ if (!isInitialized()) {
+ throw newUninitializedMessageException(result).asInvalidProtocolBufferException();
+ }
+ return buildPartial();
+ }
+
+ public com.example.tutorial.AddressBookProtos.AddressBook buildPartial() {
+ if (result == null) {
+ throw new IllegalStateException("build() has already been called on this Builder.");
+ }
+ if (result.person_ != java.util.Collections.EMPTY_LIST) {
+ result.person_ = java.util.Collections.unmodifiableList(result.person_);
+ }
+ com.example.tutorial.AddressBookProtos.AddressBook returnMe = result;
+ result = null;
+ return returnMe;
+ }
+
+ public Builder mergeFrom(com.google.protobuf.Message other) {
+ if (other instanceof com.example.tutorial.AddressBookProtos.AddressBook) {
+ return mergeFrom((com.example.tutorial.AddressBookProtos.AddressBook)other);
+ } else {
+ super.mergeFrom(other);
+ return this;
+ }
+ }
+
+ public Builder mergeFrom(com.example.tutorial.AddressBookProtos.AddressBook other) {
+ if (other == com.example.tutorial.AddressBookProtos.AddressBook.getDefaultInstance())
+ return this;
+ if (!other.person_.isEmpty()) {
+ if (result.person_.isEmpty()) {
+ result.person_ = new java.util.ArrayList<com.example.tutorial.AddressBookProtos.Person>();
+ }
+ result.person_.addAll(other.person_);
+ }
+ this.mergeUnknownFields(other.getUnknownFields());
+ return this;
+ }
+
+ public Builder mergeFrom(com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ com.google.protobuf.UnknownFieldSet.Builder unknownFields =
+ com.google.protobuf.UnknownFieldSet.newBuilder(this.getUnknownFields());
+ while (true) {
+ int tag = input.readTag();
+ switch (tag) {
+ case 0:
+ this.setUnknownFields(unknownFields.build());
+ return this;
+ default: {
+ if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) {
+ this.setUnknownFields(unknownFields.build());
+ return this;
+ }
+ break;
+ }
+ case 10: {
+ com.example.tutorial.AddressBookProtos.Person.Builder subBuilder =
+ com.example.tutorial.AddressBookProtos.Person.newBuilder();
+ input.readMessage(subBuilder, extensionRegistry);
+ addPerson(subBuilder.buildPartial());
+ break;
+ }
+ }
+ }
+ }
+
+ // repeated .tutorial.Person person = 1;
+ public java.util.List<com.example.tutorial.AddressBookProtos.Person> getPersonList() {
+ return java.util.Collections.unmodifiableList(result.person_);
+ }
+
+ public int getPersonCount() {
+ return result.getPersonCount();
+ }
+
+ public com.example.tutorial.AddressBookProtos.Person getPerson(int index) {
+ return result.getPerson(index);
+ }
+
+ public Builder setPerson(int index, com.example.tutorial.AddressBookProtos.Person value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ result.person_.set(index, value);
+ return this;
+ }
+
+ public Builder setPerson(int index, com.example.tutorial.AddressBookProtos.Person.Builder builderForValue) {
+ result.person_.set(index, builderForValue.build());
+ return this;
+ }
+
+ public Builder addPerson(com.example.tutorial.AddressBookProtos.Person value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ if (result.person_.isEmpty()) {
+ result.person_ = new java.util.ArrayList<com.example.tutorial.AddressBookProtos.Person>();
+ }
+ result.person_.add(value);
+ return this;
+ }
+
+ public Builder addPerson(com.example.tutorial.AddressBookProtos.Person.Builder builderForValue) {
+ if (result.person_.isEmpty()) {
+ result.person_ = new java.util.ArrayList<com.example.tutorial.AddressBookProtos.Person>();
+ }
+ result.person_.add(builderForValue.build());
+ return this;
+ }
+
+ public Builder addAllPerson(java.lang.Iterable<? extends com.example.tutorial.AddressBookProtos.Person> values) {
+ if (result.person_.isEmpty()) {
+ result.person_ = new java.util.ArrayList<com.example.tutorial.AddressBookProtos.Person>();
+ }
+ super.addAll(values, result.person_);
+ return this;
+ }
+
+ public Builder clearPerson() {
+ result.person_ = java.util.Collections.emptyList();
+ return this;
+ }
+
+ // @@protoc_insertion_point(builder_scope:tutorial.AddressBook)
+ }
+
+ static {
+ defaultInstance = new AddressBook(true);
+ com.example.tutorial.AddressBookProtos.internalForceInit();
+ defaultInstance.initFields();
+ }
+
+ // @@protoc_insertion_point(class_scope:tutorial.AddressBook)
+ }
+
+ private static com.google.protobuf.Descriptors.Descriptor internal_static_tutorial_Person_descriptor;
+ private static com.google.protobuf.GeneratedMessage.FieldAccessorTable internal_static_tutorial_Person_fieldAccessorTable;
+ private static com.google.protobuf.Descriptors.Descriptor internal_static_tutorial_Person_PhoneNumber_descriptor;
+ private static com.google.protobuf.GeneratedMessage.FieldAccessorTable internal_static_tutorial_Person_PhoneNumber_fieldAccessorTable;
+ private static com.google.protobuf.Descriptors.Descriptor internal_static_tutorial_AddressBook_descriptor;
+ private static com.google.protobuf.GeneratedMessage.FieldAccessorTable internal_static_tutorial_AddressBook_fieldAccessorTable;
+
+ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() {
+ return descriptor;
+ }
+
+ private static com.google.protobuf.Descriptors.FileDescriptor descriptor;
+ static {
+ java.lang.String[] descriptorData =
+ {"\n\021addressbook.proto\022\010tutorial\"\332\001\n\006Person" + "\022\014\n\004name\030\001 \002(\t\022\n\n\002id\030\002 \002(\005\022\r\n\005email\030\003 \001("
+ + "\t\022+\n\005phone\030\004 \003(\0132\034.tutorial.Person.Phone"
+ + "Number\032M\n\013PhoneNumber\022\016\n\006number\030\001 \002(\t\022.\n"
+ + "\004type\030\002 \001(\0162\032.tutorial.Person.PhoneType:"
+ + "\004HOME\"+\n\tPhoneType\022\n\n\006MOBILE\020\000\022\010\n\004HOME\020\001"
+ + "\022\010\n\004WORK\020\002\"/\n\013AddressBook\022 \n\006person\030\001 \003("
+ + "\0132\020.tutorial.PersonB)\n\024com.example.tutor"
+ + "ialB\021AddressBookProtos"};
+ com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
+ new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() {
+ public com.google.protobuf.ExtensionRegistry assignDescriptors(com.google.protobuf.Descriptors.FileDescriptor root) {
+ descriptor = root;
+ internal_static_tutorial_Person_descriptor = getDescriptor().getMessageTypes().get(0);
+ internal_static_tutorial_Person_fieldAccessorTable =
+ new com.google.protobuf.GeneratedMessage.FieldAccessorTable(
+ internal_static_tutorial_Person_descriptor,
+ new java.lang.String[] {"Name",
+ "Id",
+ "Email",
+ "Phone",},
+ com.example.tutorial.AddressBookProtos.Person.class,
+ com.example.tutorial.AddressBookProtos.Person.Builder.class);
+ internal_static_tutorial_Person_PhoneNumber_descriptor =
+ internal_static_tutorial_Person_descriptor.getNestedTypes().get(0);
+ internal_static_tutorial_Person_PhoneNumber_fieldAccessorTable =
+ new com.google.protobuf.GeneratedMessage.FieldAccessorTable(
+ internal_static_tutorial_Person_PhoneNumber_descriptor,
+ new java.lang.String[] {"Number",
+ "Type",},
+ com.example.tutorial.AddressBookProtos.Person.PhoneNumber.class,
+ com.example.tutorial.AddressBookProtos.Person.PhoneNumber.Builder.class);
+ internal_static_tutorial_AddressBook_descriptor = getDescriptor().getMessageTypes().get(1);
+ internal_static_tutorial_AddressBook_fieldAccessorTable =
+ new com.google.protobuf.GeneratedMessage.FieldAccessorTable(
+ internal_static_tutorial_AddressBook_descriptor,
+ new java.lang.String[] {"Person",},
+ com.example.tutorial.AddressBookProtos.AddressBook.class,
+ com.example.tutorial.AddressBookProtos.AddressBook.Builder.class);
+ return null;
+ }
+ };
+ com.google.protobuf.Descriptors.FileDescriptor
+ .internalBuildGeneratedFileFrom(descriptorData,
+ new com.google.protobuf.Descriptors.FileDescriptor[] {},
+ assigner);
+ }
+
+ public static void internalForceInit() {
+ }
+
+ // @@protoc_insertion_point(outer_class_scope)
+}
diff --git a/sandbox/sebastien/java/vhost/unreleased/modules/databinding-protobuf/src/test/java/org/apache/tuscany/sca/databinding/protobuf/ProtobufTransformationTestCase.java b/sandbox/sebastien/java/vhost/unreleased/modules/databinding-protobuf/src/test/java/org/apache/tuscany/sca/databinding/protobuf/ProtobufTransformationTestCase.java
new file mode 100644
index 0000000000..9fc6f30794
--- /dev/null
+++ b/sandbox/sebastien/java/vhost/unreleased/modules/databinding-protobuf/src/test/java/org/apache/tuscany/sca/databinding/protobuf/ProtobufTransformationTestCase.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.databinding.protobuf;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.impl.TransformationContextImpl;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
+import org.junit.Test;
+
+import com.example.tutorial.AddressBookProtos.AddressBook;
+import com.example.tutorial.AddressBookProtos.Person;
+
+/**
+ *
+ */
+public class ProtobufTransformationTestCase {
+ @Test
+ public void testTransform() throws Exception {
+ Protobuf2OutputStream t1 = new Protobuf2OutputStream();
+ TransformationContext context = new TransformationContextImpl();
+ DataType dt1 = new DataTypeImpl(AddressBook.class, null);
+ context.setSourceDataType(dt1);
+
+ AddressBook addressBook =
+ AddressBook.newBuilder()
+ .addPerson(Person.newBuilder().setId(1).setEmail("abc@example.com").setName("John Smith").build())
+ .build();
+
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ t1.transform(addressBook, bos, context);
+
+ InputStream2Protobuf t2 = new InputStream2Protobuf();
+ context.setSourceDataType(null);
+ context.setTargetDataType(dt1);
+
+ ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
+ AddressBook addressBook2 = (AddressBook)t2.transform(bis, context);
+ Assert.assertEquals(addressBook, addressBook2);
+ }
+}
diff --git a/sandbox/sebastien/java/vhost/unreleased/modules/databinding-protobuf/src/test/resources/addressbook.proto b/sandbox/sebastien/java/vhost/unreleased/modules/databinding-protobuf/src/test/resources/addressbook.proto
new file mode 100644
index 0000000000..395320fb22
--- /dev/null
+++ b/sandbox/sebastien/java/vhost/unreleased/modules/databinding-protobuf/src/test/resources/addressbook.proto
@@ -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.
+//
+// See README.txt for information and build instructions.
+
+package tutorial;
+
+option java_package = "com.example.tutorial";
+option java_outer_classname = "AddressBookProtos";
+
+message Person {
+ required string name = 1;
+ required int32 id = 2; // Unique ID number for this person.
+ optional string email = 3;
+
+ enum PhoneType {
+ MOBILE = 0;
+ HOME = 1;
+ WORK = 2;
+ }
+
+ message PhoneNumber {
+ required string number = 1;
+ optional PhoneType type = 2 [default = HOME];
+ }
+
+ repeated PhoneNumber phone = 4;
+}
+
+// Our address book file is just one of these.
+message AddressBook {
+ repeated Person person = 1;
+}
diff --git a/sandbox/sebastien/java/vhost/unreleased/modules/host-tomcat/LICENSE b/sandbox/sebastien/java/vhost/unreleased/modules/host-tomcat/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/sandbox/sebastien/java/vhost/unreleased/modules/host-tomcat/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/sandbox/sebastien/java/vhost/unreleased/modules/host-tomcat/META-INF/MANIFEST.MF b/sandbox/sebastien/java/vhost/unreleased/modules/host-tomcat/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..cab6b5057e
--- /dev/null
+++ b/sandbox/sebastien/java/vhost/unreleased/modules/host-tomcat/META-INF/MANIFEST.MF
@@ -0,0 +1,33 @@
+Manifest-Version: 1.0
+Private-Package: org.apache.tuscany.sca.http.tomcat;version="2.0.0",org.
+ apache.tuscany.sca.http.tomcat.module;version="2.0.0"
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA Tomcat Servlet Host Extension
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1222833663765
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Tomcat Servlet Host Extension
+Import-Package: javax.naming,
+ javax.naming.directory,
+ javax.servlet,
+ javax.servlet.http,
+ org.apache.catalina,
+ org.apache.catalina.connector,
+ org.apache.catalina.core,
+ org.apache.catalina.servlets,
+ org.apache.catalina.startup,
+ org.apache.coyote,
+ org.apache.coyote.http11,
+ org.apache.naming.resources,
+ org.apache.tomcat.util.buf,
+ org.apache.tomcat.util.http.mapper,
+ org.apache.tomcat.util.net,
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.host.http;version="2.0.0",
+ org.apache.tuscany.sca.work;version="2.0.0"
+Bundle-SymbolicName: org.apache.tuscany.sca.host.tomcat
+Bundle-DocURL: http://www.apache.org/
+
diff --git a/sandbox/sebastien/java/vhost/unreleased/modules/host-tomcat/NOTICE b/sandbox/sebastien/java/vhost/unreleased/modules/host-tomcat/NOTICE
new file mode 100644
index 0000000000..25bb89c9b2
--- /dev/null
+++ b/sandbox/sebastien/java/vhost/unreleased/modules/host-tomcat/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2009 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/sebastien/java/vhost/unreleased/modules/host-tomcat/pom.xml b/sandbox/sebastien/java/vhost/unreleased/modules/host-tomcat/pom.xml
new file mode 100644
index 0000000000..6f49551591
--- /dev/null
+++ b/sandbox/sebastien/java/vhost/unreleased/modules/host-tomcat/pom.xml
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-modules</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-host-tomcat</artifactId>
+ <name>Apache Tuscany SCA Tomcat Servlet Host Extension</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-http</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tomcat</groupId>
+ <artifactId>catalina</artifactId>
+ <version>6.0.26</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.tomcat</groupId>
+ <artifactId>servlet-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tomcat</groupId>
+ <artifactId>coyote</artifactId>
+ <version>6.0.26</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.tomcat</groupId>
+ <artifactId>servlet-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/sandbox/sebastien/java/vhost/unreleased/modules/host-tomcat/src/main/java/org/apache/tuscany/sca/http/tomcat/ServletWrapper.java b/sandbox/sebastien/java/vhost/unreleased/modules/host-tomcat/src/main/java/org/apache/tuscany/sca/http/tomcat/ServletWrapper.java
new file mode 100644
index 0000000000..a0b384d554
--- /dev/null
+++ b/sandbox/sebastien/java/vhost/unreleased/modules/host-tomcat/src/main/java/org/apache/tuscany/sca/http/tomcat/ServletWrapper.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.http.tomcat;
+
+import javax.servlet.Servlet;
+import javax.servlet.ServletException;
+
+import org.apache.catalina.core.StandardWrapper;
+
+/**
+ * A Servlet wrapper.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ServletWrapper extends StandardWrapper {
+ private static final long serialVersionUID = 1L;
+
+ private final Servlet servlet;
+
+ public ServletWrapper(Servlet servlet) {
+ this.servlet = servlet;
+ }
+
+ @Override
+ public synchronized Servlet loadServlet() {
+ return servlet;
+ }
+
+ @Override
+ public Servlet getServlet() {
+ return servlet;
+ }
+
+ public void initServlet() throws ServletException {
+ servlet.init(facade);
+ }
+
+ public void destroyServlet() {
+ servlet.destroy();
+ }
+
+}
diff --git a/sandbox/sebastien/java/vhost/unreleased/modules/host-tomcat/src/main/java/org/apache/tuscany/sca/http/tomcat/TomcatDefaultServlet.java b/sandbox/sebastien/java/vhost/unreleased/modules/host-tomcat/src/main/java/org/apache/tuscany/sca/http/tomcat/TomcatDefaultServlet.java
new file mode 100644
index 0000000000..5d9b65503a
--- /dev/null
+++ b/sandbox/sebastien/java/vhost/unreleased/modules/host-tomcat/src/main/java/org/apache/tuscany/sca/http/tomcat/TomcatDefaultServlet.java
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.http.tomcat;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.Hashtable;
+
+import javax.naming.NamingException;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.BasicAttributes;
+import javax.naming.directory.DirContext;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.catalina.servlets.DefaultServlet;
+import org.apache.naming.resources.FileDirContext;
+import org.apache.naming.resources.ProxyDirContext;
+import org.apache.naming.resources.Resource;
+
+/**
+ * DefaultServlet implementation for Tomcat.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TomcatDefaultServlet extends DefaultServlet {
+ private static final long serialVersionUID = -7503581551326796573L;
+
+ private String documentRoot;
+ private ProxyDirContext proxyDirContext;
+
+ public TomcatDefaultServlet(String servletPath, String documentRoot) {
+ this.documentRoot = documentRoot;
+
+ DirContext dirContext;
+ URI uri = URI.create(documentRoot);
+ if (!"file".equals(uri.getScheme())) {
+
+ dirContext = new FileDirContext() {
+ @Override
+ public Attributes getAttributes(String name) throws NamingException {
+ return new BasicAttributes();
+ }
+
+ @Override
+ public Object lookup(String name) throws NamingException {
+
+ try {
+ final URL url = new URL(TomcatDefaultServlet.this.documentRoot + name);
+ return new Resource() {
+ @Override
+ public InputStream streamContent() throws IOException {
+ URLConnection connection = url.openConnection();
+ connection.setUseCaches(false);
+ return connection.getInputStream();
+ }
+ };
+ } catch (MalformedURLException e) {
+ throw new NamingException(e.toString());
+ }
+ }
+ };
+
+ } else {
+ dirContext = new FileDirContext();
+ ((FileDirContext)dirContext).setDocBase(uri.getPath());
+ }
+ proxyDirContext = new ProxyDirContext(new Hashtable(), dirContext);
+ resources = proxyDirContext;
+ }
+
+ @Override
+ public void init() throws ServletException {
+ super.init();
+ resources = proxyDirContext;
+ }
+
+ @Override
+ public void init(ServletConfig servletConfig) throws ServletException {
+ super.init(servletConfig);
+ resources = proxyDirContext;
+ }
+
+ @Override
+ protected String getRelativePath(HttpServletRequest request) {
+ String path = request.getPathInfo();
+ if (path == null || path.length() == 0) {
+ path = "/";
+ }
+ return path;
+ }
+}
diff --git a/sandbox/sebastien/java/vhost/unreleased/modules/host-tomcat/src/main/java/org/apache/tuscany/sca/http/tomcat/TomcatServer.java b/sandbox/sebastien/java/vhost/unreleased/modules/host-tomcat/src/main/java/org/apache/tuscany/sca/http/tomcat/TomcatServer.java
new file mode 100644
index 0000000000..d1a2e5d283
--- /dev/null
+++ b/sandbox/sebastien/java/vhost/unreleased/modules/host-tomcat/src/main/java/org/apache/tuscany/sca/http/tomcat/TomcatServer.java
@@ -0,0 +1,701 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.http.tomcat;
+
+import java.beans.PropertyChangeListener;
+import java.net.InetAddress;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URL;
+import java.net.UnknownHostException;
+import java.security.AccessController;
+import java.security.KeyStore;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Logger;
+
+import javax.servlet.RequestDispatcher;
+import javax.servlet.Servlet;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+
+import org.apache.catalina.Container;
+import org.apache.catalina.Context;
+import org.apache.catalina.Engine;
+import org.apache.catalina.Host;
+import org.apache.catalina.Lifecycle;
+import org.apache.catalina.LifecycleException;
+import org.apache.catalina.Loader;
+import org.apache.catalina.connector.Connector;
+import org.apache.catalina.core.StandardEngine;
+import org.apache.catalina.startup.ContextConfig;
+import org.apache.catalina.startup.Embedded;
+import org.apache.coyote.http11.Http11Protocol;
+import org.apache.tomcat.util.buf.MessageBytes;
+import org.apache.tomcat.util.http.mapper.MappingData;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.LifeCycleListener;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.host.http.DefaultResourceServlet;
+import org.apache.tuscany.sca.host.http.SecurityContext;
+import org.apache.tuscany.sca.host.http.ServletHost;
+import org.apache.tuscany.sca.host.http.ServletMappingException;
+import org.apache.tuscany.sca.work.WorkScheduler;
+
+/**
+ * A Tomcat based implementation of ServletHost.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TomcatServer implements ServletHost, LifeCycleListener {
+ private static final Logger logger = Logger.getLogger(TomcatServer.class.getName());
+
+ private WorkScheduler workScheduler;
+ private Embedded embedded;
+ private Map<Integer, Port> ports = new HashMap<Integer, Port>();
+ private String contextPath = "/";
+ private int defaultPort = 8080;
+ private int defaultSSLPort = 8443;
+
+ private final class TuscanyLoader implements Loader {
+ private final ClassLoader tccl;
+ private boolean delegate;
+ private boolean reloadable;
+ private Container container;
+ private List<String> repos = new ArrayList<String>();
+ private List<PropertyChangeListener> listeners = new ArrayList<PropertyChangeListener>();
+
+ private TuscanyLoader(ClassLoader tccl) {
+ this.tccl = tccl;
+ }
+
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ listeners.add(listener);
+ }
+
+ public void addRepository(String repository) {
+ repos.add(repository);
+ }
+
+ public void backgroundProcess() {
+ }
+
+ public String[] findRepositories() {
+ return repos.toArray(new String[repos.size()]);
+ }
+
+ public Container getContainer() {
+ return container;
+ }
+
+ public boolean getDelegate() {
+ return delegate;
+ }
+
+ public String getInfo() {
+ return "Tuscany Loader for Embedded Tomcat";
+ }
+
+ public boolean getReloadable() {
+ return reloadable;
+ }
+
+ public boolean modified() {
+ return false;
+ }
+
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ listeners.remove(listener);
+ }
+
+ public void setContainer(Container container) {
+ this.container = container;
+ }
+
+ public void setDelegate(boolean delegate) {
+ this.delegate = delegate;
+ }
+
+ public void setReloadable(boolean reloadable) {
+ this.reloadable = reloadable;
+ }
+
+ public ClassLoader getClassLoader() {
+ return tccl;
+ }
+ }
+
+ /**
+ * Represents a port and the server that serves it.
+ */
+ private class Port {
+ private Engine engine;
+ private Host host;
+ private Connector connector;
+
+ private Port(Engine engine, Host host, Connector connector) {
+ this.engine = engine;
+ this.host = host;
+ this.connector = connector;
+ }
+
+ public Engine getEngine() {
+ return engine;
+ }
+
+ public Host getHost() {
+ return host;
+ }
+
+ public Connector getConnector() {
+ return connector;
+ }
+ }
+
+ /**
+ * Constructs a new embedded Tomcat server.
+ *
+ */
+ public TomcatServer(ExtensionPointRegistry registry, Map<String, String> attributes) {
+ UtilityExtensionPoint utilities = registry.getExtensionPoint(UtilityExtensionPoint.class);
+ this.workScheduler = utilities.getUtility(WorkScheduler.class);
+ String port = attributes.get("defaultPort");
+ if (port != null) {
+ defaultPort = Integer.parseInt(port);
+ }
+ String sslPort = attributes.get("defaultSSLPort");
+ if (sslPort != null) {
+ defaultPort = Integer.parseInt(sslPort);
+ }
+ if (attributes.containsKey("contextPath")) {
+ contextPath = attributes.get("contextPath");
+ }
+ }
+
+ protected TomcatServer(WorkScheduler workScheduler) {
+ this.workScheduler = workScheduler;
+ }
+
+ public void setDefaultPort(int port) {
+ defaultPort = port;
+ }
+
+ public int getDefaultPort() {
+ return defaultPort;
+ }
+
+ /**
+ * Stop all the started servers.
+ */
+ public void stop() {
+ if (embedded != null) {
+ try {
+ // embedded.stop();
+ embedded.destroy();
+ for (Port port : ports.values()) {
+ port.connector.stop();
+ }
+ } catch (LifecycleException e) {
+ throw new IllegalStateException(e);
+ }
+ }
+ }
+
+ public synchronized String addServletMapping(String suri, Servlet servlet) {
+ init();
+ URI uri = URI.create(suri);
+
+ // Get the URI scheme and port
+ String scheme = uri.getScheme();
+ if (scheme == null) {
+ scheme = "http";
+ }
+ final int portNumber = (uri.getPort() == -1 ? defaultPort : uri.getPort());
+
+ // Get the port object associated with the given port number
+ Port port = ports.get(portNumber);
+ if (port == null) {
+
+ port = createInstance(scheme, portNumber);
+ ports.put(portNumber, port);
+ }
+
+ // Register the Servlet mapping
+ String path = uri.getPath();
+
+ if (!path.startsWith("/")) {
+ path = '/' + path;
+ }
+
+ if (!path.startsWith(contextPath)) {
+ path = contextPath + path;
+ }
+
+ ServletWrapper wrapper;
+ if (servlet instanceof DefaultResourceServlet) {
+ String defaultServletPath = path;
+
+ // Optimize the handling of resource requests, use the Tomcat default Servlet
+ // instead of our default resource Servlet
+ if (defaultServletPath.endsWith("*")) {
+ defaultServletPath = defaultServletPath.substring(0, defaultServletPath.length() - 1);
+ }
+ if (defaultServletPath.endsWith("/")) {
+ defaultServletPath = defaultServletPath.substring(0, defaultServletPath.length() - 1);
+ }
+ DefaultResourceServlet resourceServlet = (DefaultResourceServlet)servlet;
+ TomcatDefaultServlet defaultServlet =
+ new TomcatDefaultServlet(defaultServletPath, resourceServlet.getDocumentRoot());
+ wrapper = new ServletWrapper(defaultServlet);
+
+ } else {
+ wrapper = new ServletWrapper(servlet);
+ }
+ Context context = port.getHost().map(path);
+ wrapper.setName(path);
+ wrapper.addMapping(path);
+ context.addChild(wrapper);
+ context.addServletMapping(path, path);
+ port.getConnector().getMapper().addWrapper("localhost", "", path, wrapper);
+
+ // Initialize the Servlet
+ try {
+ wrapper.initServlet();
+ } catch (ServletException e) {
+ throw new ServletMappingException(e);
+ }
+
+ // Compute the complete URL
+ String host;
+ try {
+ host = InetAddress.getLocalHost().getHostName();
+ } catch (UnknownHostException e) {
+ host = "localhost";
+ }
+ URL addedURL;
+ try {
+ addedURL = new URL(scheme, host, portNumber, path);
+ } catch (MalformedURLException e) {
+ throw new ServletMappingException(e);
+ }
+ logger.info("Added Servlet mapping: " + addedURL);
+ return addedURL.toString();
+ }
+
+ private Port createInstance(String scheme, final int portNumber) {
+ Port port;
+ // Create an engine
+ // Allow privileged access to read properties. Requires PropertiesPermission read in
+ // security policy.
+ final Engine engine = AccessController.doPrivileged(new PrivilegedAction<Engine>() {
+ public Engine run() {
+ return embedded.createEngine();
+ }
+ });
+
+ ((StandardEngine)engine).setBaseDir("");
+ engine.setDefaultHost("localhost");
+ engine.setName("engine/" + portNumber);
+
+ // Create a host
+ // Allow privileged access to read properties. Requires PropertiesPermission read in
+ // security policy.
+ final Host host = AccessController.doPrivileged(new PrivilegedAction<Host>() {
+ public Host run() {
+ Host host = embedded.createHost("localhost", "");
+ engine.addChild(host);
+ return host;
+ }
+ });
+
+ // Create the root context
+ Context context = embedded.createContext("", "");
+ final ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+ context.setLoader(new TuscanyLoader(tccl));
+ // context.setParentClassLoader(tccl.getParent());
+ ContextConfig config = new ContextConfig();
+ ((Lifecycle)context).addLifecycleListener(config);
+ host.addChild(context);
+
+ embedded.addEngine(engine);
+
+ // Install an HTTP connector
+
+ Connector connector;
+ // Allow privileged access to read properties. Requires PropertiesPermission read in
+ // security policy.
+ try {
+ final String protocol = scheme;
+ connector = AccessController.doPrivileged(new PrivilegedExceptionAction<Connector>() {
+ public Connector run() throws Exception {
+ Connector customConnector = new Connector();
+ customConnector.setPort(portNumber);
+
+ if ("https".equalsIgnoreCase(protocol)) {
+ configureSSL(customConnector);
+ ((Http11Protocol)customConnector.getProtocolHandler()).setSSLEnabled(true);
+ }
+ return customConnector;
+ }
+
+ private void configureSSL(Connector customConnector) {
+ String trustStore = System.getProperty("javax.net.ssl.trustStore");
+ String trustStorePass = System.getProperty("javax.net.ssl.trustStorePassword");
+ String keyStore = System.getProperty("javax.net.ssl.keyStore");
+ String keyStorePass = System.getProperty("javax.net.ssl.keyStorePassword");
+
+ customConnector.setProperty("protocol", "TLS");
+
+ customConnector.setProperty("keystore", keyStore);
+ customConnector.setProperty("keypass", keyStorePass);
+ String keyStoreType = System.getProperty("javax.net.ssl.keyStoreType", KeyStore.getDefaultType());
+ String trustStoreType =
+ System.getProperty("javax.net.ssl.trustStoreType", KeyStore.getDefaultType());
+ customConnector.setProperty("keytype", keyStoreType);
+ customConnector.setProperty("trusttype", trustStoreType);
+ customConnector.setProperty("truststore", trustStore);
+ customConnector.setProperty("trustpass", trustStorePass);
+
+ customConnector.setProperty("clientauth", "false");
+ customConnector.setProtocol("HTTP/1.1");
+ customConnector.setScheme(protocol);
+ customConnector.setProperty("backlog", "10");
+ customConnector.setSecure(true);
+ }
+ });
+ } catch (Exception e) {
+ throw new ServletMappingException(e);
+ }
+
+ embedded.addConnector(connector);
+ try {
+ connector.start();
+ } catch (LifecycleException e) {
+ throw new ServletMappingException(e);
+ }
+
+ // Keep track of the running server
+ port = new Port(engine, host, connector);
+ return port;
+ }
+
+ private synchronized void init() {
+ if (embedded != null) {
+ return;
+ }
+ embedded = new Embedded();
+ embedded.setAwait(true);
+ // Allow privileged access to read properties. Requires PropertiesPermission read in
+ // security policy.
+ try {
+ AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
+ public Object run() throws LifecycleException {
+ embedded.start();
+ return null;
+ }
+ });
+ } catch (PrivilegedActionException e) {
+ // throw (LifecycleException)e.getException();
+ throw new ServletMappingException(e);
+ }
+ }
+
+ public URL getURLMapping(String suri) throws ServletMappingException {
+ URI uri = URI.create(suri);
+
+ // Get the URI scheme and port
+ String scheme = uri.getScheme();
+ if (scheme == null) {
+ scheme = "http";
+ }
+ int portNumber = uri.getPort();
+ if (portNumber == -1) {
+ portNumber = defaultPort;
+ }
+
+ // Get the host
+ String host;
+ try {
+ host = InetAddress.getLocalHost().getHostName();
+ } catch (UnknownHostException e) {
+ host = "localhost";
+ }
+
+ // Construct the URL
+ String path = uri.getPath();
+
+ if (!path.startsWith("/")) {
+ path = '/' + path;
+ }
+
+ if (!path.startsWith(contextPath)) {
+ path = contextPath + path;
+ }
+ URL url;
+ try {
+ url = new URL(scheme, host, portNumber, path);
+ } catch (MalformedURLException e) {
+ throw new ServletMappingException(e);
+ }
+ return url;
+ }
+
+ public Servlet getServletMapping(String suri) throws ServletMappingException {
+
+ if (suri == null) {
+ return null;
+ }
+
+ URI uri = URI.create(suri);
+
+ // Get the URI port
+ int portNumber = uri.getPort();
+ if (portNumber == -1) {
+ portNumber = defaultPort;
+ }
+
+ // Get the port object associated with the given port number
+ Port port = ports.get(portNumber);
+ if (port == null) {
+ return null;
+ }
+
+ String mapping = uri.getPath();
+
+ if (!mapping.startsWith("/")) {
+ mapping = '/' + mapping;
+ }
+
+ if (!mapping.startsWith(contextPath)) {
+ mapping = contextPath + mapping;
+ }
+
+ final Context context = port.getHost().map(mapping);
+ final MappingData md = new MappingData();
+ final MessageBytes mb = MessageBytes.newInstance();
+ mb.setString(mapping);
+ try {
+ // Allow privileged access to read properties. Requires PropertiesPermission read in
+ // security policy.
+ AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
+ public Object run() throws Exception {
+ context.getMapper().map(mb, md);
+ return null;
+ }
+ });
+ } catch (Exception e) {
+ return null;
+ }
+ if (md.wrapper instanceof ServletWrapper) {
+ ServletWrapper servletWrapper = (ServletWrapper)md.wrapper;
+ return servletWrapper.getServlet();
+ } else {
+ return null;
+ }
+ }
+
+ public synchronized Servlet removeServletMapping(String suri) {
+ URI uri = URI.create(suri);
+
+ // Get the URI port
+ int portNumber = uri.getPort();
+ if (portNumber == -1) {
+ portNumber = defaultPort;
+ }
+
+ // Get the port object associated with the given port number
+ Port port = ports.get(portNumber);
+ if (port == null) {
+ throw new IllegalStateException("No servlet registered at this URI: " + suri);
+ }
+
+ String mapping = uri.getPath();
+
+ if (!mapping.startsWith("/")) {
+ mapping = '/' + mapping;
+ }
+
+ if (!mapping.startsWith(contextPath)) {
+ mapping = contextPath + mapping;
+ }
+
+ final Context context = port.getHost().map(mapping);
+ final MappingData md = new MappingData();
+ final MessageBytes mb = MessageBytes.newInstance();
+ mb.setString(mapping);
+ try {
+ // Allow privileged access to read properties. Requires PropertiesPermission read in
+ // security policy.
+ AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
+ public Object run() throws Exception {
+ context.getMapper().map(mb, md);
+ return null;
+ }
+ });
+ } catch (Exception e) {
+ return null;
+ }
+ if (md.wrapper instanceof ServletWrapper) {
+ ServletWrapper servletWrapper = (ServletWrapper)md.wrapper;
+
+ port.getConnector().getMapper().removeWrapper("localhost", "", mapping);
+
+ try {
+ context.removeServletMapping(mapping);
+ } catch (NegativeArraySizeException e) {
+ // JIRA TUSCANY-1599
+ // FIXME Looks like a bug in Tomcat when removing the last
+ // Servlet in the list, catch the exception for now as it doesn't
+ // seem harmful, will find a better solution for the next release
+ }
+ context.removeChild(servletWrapper);
+ try {
+ servletWrapper.destroyServlet();
+ } catch (Exception ex) {
+ // Hack to handle destruction of Servlets without Servlet context
+ }
+
+ logger.info("Removed Servlet mapping: " + suri);
+
+ // Stop the port if there's no servlets on it anymore
+ String[] contextNames = port.getConnector().getMapper().getContextNames();
+ if (contextNames == null || contextNames.length == 0) {
+ try {
+ port.getConnector().stop();
+ ((StandardEngine)port.getEngine()).stop();
+ embedded.removeEngine(port.getEngine());
+ embedded.removeConnector(port.getConnector());
+ ports.remove(portNumber);
+ } catch (LifecycleException e) {
+ throw new IllegalStateException(e);
+ }
+ }
+
+ return servletWrapper.getServlet();
+ } else {
+ logger.warning("Trying to Remove servlet mapping: " + mapping + " where mapping is not registered");
+ return null;
+ }
+ }
+
+ public RequestDispatcher getRequestDispatcher(String suri) throws ServletMappingException {
+ //FIXME implement this later
+ return null;
+ }
+
+ public String getContextPath() {
+ return contextPath;
+ }
+
+ public void setContextPath(String path) {
+ this.contextPath = path;
+ }
+
+ public void start() {
+
+ }
+
+ public String addServletMapping(String uri, Servlet servlet, SecurityContext securityContext)
+ throws ServletMappingException {
+ return addServletMapping(uri, servlet);
+ }
+
+ public String getName() {
+ return "tomcat";
+ }
+
+ public URL getURLMapping(String arg0, SecurityContext arg1) {
+ return null;
+ }
+
+ public void setAttribute(String arg0, Object arg1) {
+ }
+
+ private URL map(String suri, SecurityContext securityContext, boolean resolve) throws ServletMappingException {
+ URI uri = URI.create(suri);
+
+ // Get the URI scheme and port
+ String scheme = null;
+ if (securityContext != null && securityContext.isSSLEnabled()) {
+ scheme = "https";
+ } else {
+ scheme = uri.getScheme();
+ if (scheme == null) {
+ scheme = "http";
+ }
+ }
+
+ int portNumber = uri.getPort();
+ if (portNumber == -1) {
+ if ("http".equals(scheme)) {
+ portNumber = defaultPort;
+ } else {
+ portNumber = defaultSSLPort;
+ }
+ }
+
+ // Get the host
+ String host = uri.getHost();
+ if (host == null) {
+ host = "0.0.0.0";
+ if (resolve) {
+ try {
+ host = InetAddress.getLocalHost().getHostAddress();
+ } catch (UnknownHostException e) {
+ host = "localhost";
+ }
+ }
+ }
+
+ // Construct the URL
+ String path = uri.getPath();
+
+ if (!path.startsWith("/")) {
+ path = '/' + path;
+ }
+
+ if (!path.startsWith(contextPath)) {
+ path = contextPath + path;
+ }
+
+ URL url;
+ try {
+ url = new URL(scheme, host, portNumber, path);
+ } catch (MalformedURLException e) {
+ throw new ServletMappingException(e);
+ }
+ return url;
+ }
+
+ @Override
+ public ServletContext getServletContext() {
+ if (ports.isEmpty()) {
+ return null;
+ } else {
+ Port port = ports.values().iterator().next();
+ return port.getHost().map(getContextPath()).getServletContext();
+ }
+ }
+
+}
diff --git a/sandbox/sebastien/java/vhost/unreleased/modules/host-tomcat/src/main/resources/META-INF/services/org.apache.tuscany.sca.host.http.ServletHost b/sandbox/sebastien/java/vhost/unreleased/modules/host-tomcat/src/main/resources/META-INF/services/org.apache.tuscany.sca.host.http.ServletHost
new file mode 100644
index 0000000000..00350bbf6b
--- /dev/null
+++ b/sandbox/sebastien/java/vhost/unreleased/modules/host-tomcat/src/main/resources/META-INF/services/org.apache.tuscany.sca.host.http.ServletHost
@@ -0,0 +1,18 @@
+# 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 ServletHost
+org.apache.tuscany.sca.http.tomcat.TomcatServer;name=tomcat,ranking=50,defaultPort=8085
diff --git a/sandbox/sebastien/java/vhost/unreleased/modules/host-tomcat/src/test/java/org/apache/tuscany/sca/http/tomcat/TomcatServerTestCase.java b/sandbox/sebastien/java/vhost/unreleased/modules/host-tomcat/src/test/java/org/apache/tuscany/sca/http/tomcat/TomcatServerTestCase.java
new file mode 100644
index 0000000000..7e2f4e1614
--- /dev/null
+++ b/sandbox/sebastien/java/vhost/unreleased/modules/host-tomcat/src/test/java/org/apache/tuscany/sca/http/tomcat/TomcatServerTestCase.java
@@ -0,0 +1,375 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.http.tomcat;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.net.Socket;
+import java.net.URL;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+import javax.net.ssl.HostnameVerifier;
+import javax.net.ssl.HttpsURLConnection;
+import javax.net.ssl.SSLSession;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.host.http.DefaultResourceServlet;
+import org.apache.tuscany.sca.host.http.ExtensibleServletHost;
+import org.apache.tuscany.sca.host.http.ServletHost;
+import org.apache.tuscany.sca.work.NotificationListener;
+import org.apache.tuscany.sca.work.WorkScheduler;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class TomcatServerTestCase extends TestCase {
+
+ private static final String REQUEST1_HEADER =
+ "GET /foo HTTP/1.0\n" + "Host: localhost\n"
+ + "Content-Type: text/xml\n"
+ + "Connection: close\n"
+ + "Content-Length: ";
+ private static final String REQUEST1_CONTENT = "";
+ private static final String REQUEST1 =
+ REQUEST1_HEADER + REQUEST1_CONTENT.getBytes().length + "\n\n" + REQUEST1_CONTENT;
+
+ private static final String REQUEST2_HEADER =
+ "GET /webcontent/test.html HTTP/1.0\n" + "Host: localhost\n"
+ + "Content-Type: text/xml\n"
+ + "Connection: close\n"
+ + "Content-Length: ";
+ private static final String REQUEST2_CONTENT = "";
+ private static final String REQUEST2 =
+ REQUEST2_HEADER + REQUEST2_CONTENT.getBytes().length + "\n\n" + REQUEST2_CONTENT;
+
+ private static final int HTTP_PORT = 8085;
+
+ private WorkScheduler workScheduler = new WorkScheduler() {
+ private ExecutorService executorService = Executors.newCachedThreadPool();
+
+ public <T extends Runnable> void scheduleWork(T work) {
+ executorService.submit(work);
+ }
+
+ public <T extends Runnable> void scheduleWork(T work, NotificationListener<T> listener) {
+ scheduleWork(work);
+ }
+
+ public ExecutorService getExecutorService() {
+ return executorService;
+ }
+ };
+
+ /**
+ * Verifies requests are properly routed according to the Servlet mapping
+ */
+ public void testRegisterServletMapping() throws Exception {
+ TomcatServer service = new TomcatServer(workScheduler);
+ TestServlet servlet = new TestServlet();
+ service.addServletMapping("http://127.0.0.1:" + HTTP_PORT + "/foo", servlet);
+ ServletContext servletContext = service.getServletContext();
+ Assert.assertNotNull(servletContext);
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ os.write(REQUEST1.getBytes());
+ os.flush();
+ read(client);
+ service.stop();
+ assertTrue(servlet.invoked);
+ }
+
+ /**
+ * Verifies requests are properly routed according to the Servlet mapping
+ */
+ public void testRegisterServletMappingSSL() throws Exception {
+ System.setProperty("javax.net.ssl.keyStore", "target/test-classes/tuscany.keyStore");
+ System.setProperty("javax.net.ssl.keyStorePassword", "apache");
+ TomcatServer service = new TomcatServer(workScheduler);
+ TestServlet servlet = new TestServlet();
+ try {
+ service.addServletMapping("https://127.0.0.1:" + HTTP_PORT + "/foo", servlet);
+ } finally {
+ System.clearProperty("javax.net.ssl.keyStore");
+ System.clearProperty("javax.net.ssl.keyStorePassword");
+ }
+ System.setProperty("javax.net.ssl.trustStore", "target/test-classes/tuscany.keyStore");
+ System.setProperty("javax.net.ssl.trustStorePassword", "apache");
+ URL url = new URL("https://127.0.0.1:8085/foo");
+ HttpsURLConnection conn = (HttpsURLConnection) url.openConnection();
+ conn.setHostnameVerifier(new HostnameVerifier() {
+ public boolean verify(String hostname, SSLSession session) {
+ return true;
+ }}
+ );
+
+ conn.connect();
+ read(conn.getInputStream());
+
+ service.stop();
+ assertTrue(servlet.invoked);
+
+ }
+ /**
+ * Verifies that Servlets can be registered with multiple ports
+ */
+ public void testRegisterMultiplePorts() throws Exception {
+ TomcatServer service = new TomcatServer(workScheduler);
+ TestServlet servlet = new TestServlet();
+ service.addServletMapping("http://127.0.0.1:" + HTTP_PORT + "/", servlet);
+ TestServlet servlet2 = new TestServlet();
+ service.addServletMapping("http://127.0.0.1:" + (HTTP_PORT + 1) + "/", servlet2);
+ {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ os.write(REQUEST1.getBytes());
+ os.flush();
+ read(client);
+ }
+ {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT + 1);
+ OutputStream os = client.getOutputStream();
+ os.write(REQUEST1.getBytes());
+ os.flush();
+ read(client);
+ }
+
+ service.stop();
+ assertTrue(servlet.invoked);
+ assertTrue(servlet2.invoked);
+ }
+
+ public void testUnregisterMapping() throws Exception {
+ TomcatServer service = new TomcatServer(workScheduler);
+ TestServlet servlet = new TestServlet();
+ service.addServletMapping("http://127.0.0.1:" + HTTP_PORT + "/foo", servlet);
+ service.removeServletMapping("http://127.0.0.1:" + HTTP_PORT + "/foo");
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ os.write(REQUEST1.getBytes());
+ os.flush();
+ read(client);
+ service.stop();
+ assertFalse(servlet.invoked);
+
+ }
+
+ public void testRegisterUnregisterMapping() throws Exception {
+ TomcatServer service = new TomcatServer(workScheduler);
+ TestServlet servlet = new TestServlet();
+ service.addServletMapping("http://127.0.0.1:" + HTTP_PORT + "/foo", servlet);
+ {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ os.write(REQUEST1.getBytes());
+ os.flush();
+ read(client);
+ }
+ assertTrue(servlet.invoked);
+ service.removeServletMapping("http://127.0.0.1:" + HTTP_PORT + "/foo");
+ {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ os.write(REQUEST1.getBytes());
+ os.flush();
+ read(client);
+ }
+ servlet = new TestServlet();
+ service.addServletMapping("http://127.0.0.1:" + HTTP_PORT + "/foo", servlet);
+ {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ os.write(REQUEST1.getBytes());
+ os.flush();
+ read(client);
+ }
+ assertTrue(servlet.invoked);
+ service.stop();
+ }
+
+ public void testRequestSession() throws Exception {
+ TomcatServer service = new TomcatServer(workScheduler);
+ TestServlet servlet = new TestServlet();
+ service.addServletMapping("http://127.0.0.1:" + HTTP_PORT + "/foo", servlet);
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ os.write(REQUEST1.getBytes());
+ os.flush();
+ read(client);
+ service.stop();
+ assertTrue(servlet.invoked);
+ assertNotNull(servlet.sessionId);
+ }
+
+ public void testRestart() throws Exception {
+ TomcatServer service = new TomcatServer(workScheduler);
+ service.stop();
+ service.stop();
+ }
+
+ public void testNoMappings() throws Exception {
+ TomcatServer service = new TomcatServer(workScheduler);
+ Exception ex = null;
+ try {
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ os.write(REQUEST1.getBytes());
+ os.flush();
+ } catch (Exception e) {
+ ex = e;
+ }
+ assertNotNull(ex);
+ service.stop();
+ }
+
+ public void testResourceServlet() throws Exception {
+ TomcatServer service = new TomcatServer(workScheduler);
+
+ String documentRoot = getClass().getClassLoader().getResource("content/test.html").toString();
+ documentRoot = documentRoot.substring(0, documentRoot.lastIndexOf('/'));
+ DefaultResourceServlet resourceServlet = new DefaultResourceServlet(documentRoot);
+ TestResourceServlet servlet = new TestResourceServlet(resourceServlet);
+ service.addServletMapping("http://127.0.0.1:" + HTTP_PORT + "/webcontent/*", servlet);
+
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ os.write(REQUEST2.getBytes());
+ os.flush();
+
+ String document = read(client);
+ assertTrue(document.indexOf("<body><p>hello</body>") != -1);
+
+ service.stop();
+ }
+
+ public void testDefaultServlet() throws Exception {
+ TomcatServer service = new TomcatServer(workScheduler);
+
+ String documentRoot = getClass().getClassLoader().getResource("content/test.html").toString();
+ documentRoot = documentRoot.substring(0, documentRoot.lastIndexOf('/'));
+ DefaultResourceServlet resourceServlet = new DefaultResourceServlet(documentRoot);
+ service.addServletMapping("http://127.0.0.1:" + HTTP_PORT + "/webcontent/*", resourceServlet);
+
+ Socket client = new Socket("127.0.0.1", HTTP_PORT);
+ OutputStream os = client.getOutputStream();
+ os.write(REQUEST2.getBytes());
+ os.flush();
+
+ String document = read(client);
+ assertTrue(document.indexOf("<body><p>hello</body>") != -1);
+
+ service.stop();
+ }
+
+ private static String read(Socket socket) throws IOException {
+ InputStream is = socket.getInputStream();
+ return read(is);
+ }
+
+ private static String read(InputStream is) throws IOException {
+ BufferedReader reader = null;
+ try {
+ reader = new BufferedReader(new InputStreamReader(is));
+ StringBuffer sb = new StringBuffer();
+ String str;
+ while ((str = reader.readLine()) != null) {
+ sb.append(str);
+ }
+ return sb.toString();
+ } finally {
+ if (reader != null) {
+ reader.close();
+ }
+ }
+ }
+ private class TestServlet extends HttpServlet {
+ private static final long serialVersionUID = 1L;
+ boolean invoked;
+ String sessionId;
+
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ invoked = true;
+ sessionId = req.getSession().getId();
+ OutputStream writer = resp.getOutputStream();
+ try {
+ writer.write("result".getBytes());
+ } finally {
+ writer.close();
+ }
+ }
+
+ }
+
+ private class TestResourceServlet extends HttpServlet {
+ private static final long serialVersionUID = 1L;
+ private HttpServlet delegate;
+
+ public TestResourceServlet(HttpServlet delegate) {
+ this.delegate = delegate;
+ }
+
+ @Override
+ public void init() throws ServletException {
+ super.init();
+ delegate.init();
+ }
+
+ @Override
+ public void init(ServletConfig config) throws ServletException {
+ super.init();
+ delegate.init(config);
+ }
+
+ @Override
+ protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ delegate.service(req, resp);
+ }
+
+ @Override
+ public void destroy() {
+ super.destroy();
+ delegate.destroy();
+ }
+ }
+
+ @Test
+ public void testDiscovery() {
+ ExtensionPointRegistry registry = new DefaultExtensionPointRegistry();
+ ExtensibleServletHost host = ExtensibleServletHost.getInstance(registry);
+ ServletHost me = host.getDefaultServletHost();
+ Assert.assertEquals("tomcat", me.getName());
+ Assert.assertEquals(8085, me.getDefaultPort());
+ registry.stop();
+ }
+}
diff --git a/sandbox/sebastien/java/vhost/unreleased/modules/host-tomcat/src/test/resources/content/test.html b/sandbox/sebastien/java/vhost/unreleased/modules/host-tomcat/src/test/resources/content/test.html
new file mode 100644
index 0000000000..f4b79d7f01
--- /dev/null
+++ b/sandbox/sebastien/java/vhost/unreleased/modules/host-tomcat/src/test/resources/content/test.html
@@ -0,0 +1,21 @@
+<html>
+<!--
+ * 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.
+-->
+<body><p>hello</body>
+</html> \ No newline at end of file
diff --git a/sandbox/sebastien/java/vhost/unreleased/modules/host-tomcat/src/test/resources/tuscany.keyStore b/sandbox/sebastien/java/vhost/unreleased/modules/host-tomcat/src/test/resources/tuscany.keyStore
new file mode 100644
index 0000000000..7ea23f7ff4
--- /dev/null
+++ b/sandbox/sebastien/java/vhost/unreleased/modules/host-tomcat/src/test/resources/tuscany.keyStore
Binary files differ
diff --git a/sandbox/sebastien/java/vhost/unreleased/modules/pom.xml b/sandbox/sebastien/java/vhost/unreleased/modules/pom.xml
new file mode 100644
index 0000000000..af4cedc8dc
--- /dev/null
+++ b/sandbox/sebastien/java/vhost/unreleased/modules/pom.xml
@@ -0,0 +1,93 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-contrib-modules</artifactId>
+ <packaging>pom</packaging>
+ <name>Apache Tuscany SCA Contributed Modules</name>
+
+ <modules>
+ <module>binding-comet</module>
+ <module>binding-comet-runtime</module>
+ <module>databinding-protobuf</module>
+ <module>host-tomcat</module>
+ </modules>
+
+ <profiles>
+ <profile>
+ <id>eclipse</id>
+ <build>
+ <defaultGoal>org.apache.tuscany.maven.plugins:maven-bundle-plugin:eclipse</defaultGoal>
+ <!--
+ <plugins>
+ <plugin>
+ <groupId>org.apache.tuscany.maven.plugins</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>1.0.6</version>
+ <extensions>true</extensions>
+ <executions>
+ <execution>
+ <id>generate-pde</id>
+ <phase>generate-resources</phase>
+ <goals>
+ <goal>eclipse</goal>
+ </goals>
+ <configuration>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ -->
+ </build>
+ </profile>
+ </profiles>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifestFile>${basedir}/META-INF/MANIFEST.MF</manifestFile>
+ </archive>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+
+</project>