summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--java/sca/modules/api/LICENSE205
-rw-r--r--java/sca/modules/api/NOTICE6
-rw-r--r--java/sca/modules/api/pom.xml304
-rw-r--r--java/sca/modules/assembly-java-dsl/LICENSE (renamed from java/sca/contrib/modules/binding-dwr/LICENSE)0
-rw-r--r--java/sca/modules/assembly-java-dsl/NOTICE (renamed from java/sca/contrib/modules/binding-dwr/NOTICE)0
-rw-r--r--java/sca/modules/assembly-java-dsl/pom.xml56
-rw-r--r--java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/AssemblyBuilder.java37
-rw-r--r--java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/ComponentBuilder.java34
-rw-r--r--java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/ComponentPropertyBuilder.java28
-rw-r--r--java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/ComponentReferenceBuilder.java36
-rw-r--r--java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/ComponentServiceBuilder.java32
-rw-r--r--java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/CompositeBuilder.java29
-rw-r--r--java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/AssemblyBuilderImpl.java70
-rw-r--r--java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/ComponentBuilderImpl.java74
-rw-r--r--java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/ComponentPropertyBuilderImpl.java40
-rw-r--r--java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/ComponentReferenceBuilderImpl.java77
-rw-r--r--java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/ComponentServiceBuilderImpl.java62
-rw-r--r--java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/CompositeBuilderImpl.java62
-rw-r--r--java/sca/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/AccountDataService.java24
-rw-r--r--java/sca/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/AccountDataServiceImpl.java24
-rw-r--r--java/sca/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/AccountService.java24
-rw-r--r--java/sca/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/AccountServiceImpl.java24
-rw-r--r--java/sca/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/BigBankBuilder.java59
-rw-r--r--java/sca/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/BigBankBuilderTestCase.java33
-rw-r--r--java/sca/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/StockQuoteService.java24
-rw-r--r--java/sca/modules/binding-dwr/LICENSE205
-rw-r--r--java/sca/modules/binding-dwr/NOTICE6
-rw-r--r--java/sca/modules/binding-dwr/pom.xml (renamed from java/sca/contrib/modules/binding-dwr/pom.xml)0
-rw-r--r--java/sca/modules/binding-dwr/src/main/java/org/apache/tuscany/sca/binding/dwr/DWRBinding.java (renamed from java/sca/contrib/modules/binding-dwr/src/main/java/org/apache/tuscany/sca/binding/dwr/DWRBinding.java)0
-rw-r--r--java/sca/modules/binding-dwr/src/main/java/org/apache/tuscany/sca/binding/dwr/DWRBindingActivator.java (renamed from java/sca/contrib/modules/binding-dwr/src/main/java/org/apache/tuscany/sca/binding/dwr/DWRBindingActivator.java)0
-rw-r--r--java/sca/modules/binding-dwr/src/main/java/org/apache/tuscany/sca/binding/dwr/DWRInvoker.java (renamed from java/sca/contrib/modules/binding-dwr/src/main/java/org/apache/tuscany/sca/binding/dwr/DWRInvoker.java)0
-rw-r--r--java/sca/modules/binding-dwr/src/main/java/org/apache/tuscany/sca/binding/dwr/DWRInvokerFactory.java (renamed from java/sca/contrib/modules/binding-dwr/src/main/java/org/apache/tuscany/sca/binding/dwr/DWRInvokerFactory.java)0
-rw-r--r--java/sca/modules/binding-dwr/src/main/java/org/apache/tuscany/sca/binding/dwr/DWRService.java (renamed from java/sca/contrib/modules/binding-dwr/src/main/java/org/apache/tuscany/sca/binding/dwr/DWRService.java)0
-rw-r--r--java/sca/modules/binding-dwr/src/main/java/org/apache/tuscany/sca/binding/dwr/DWRServlet.java (renamed from java/sca/contrib/modules/binding-dwr/src/main/java/org/apache/tuscany/sca/binding/dwr/DWRServlet.java)0
-rw-r--r--java/sca/modules/binding-dwr/src/main/resources/META-INF/services/org.apache.tuscany.sca.extension.helper.BindingActivator (renamed from java/sca/contrib/modules/binding-dwr/src/main/resources/META-INF/services/org.apache.tuscany.sca.extension.helper.BindingActivator)0
-rw-r--r--java/sca/modules/binding-feed/LICENSE205
-rw-r--r--java/sca/modules/binding-feed/NOTICE6
-rw-r--r--java/sca/modules/binding-feed/pom.xml165
-rw-r--r--java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/AtomBinding.java30
-rw-r--r--java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/AtomBindingFactory.java35
-rw-r--r--java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/RSSBinding.java30
-rw-r--r--java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/RSSBindingFactory.java35
-rw-r--r--java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/collection/Collection.java72
-rw-r--r--java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/collection/MediaCollection.java55
-rw-r--r--java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/collection/NotFoundException.java45
-rw-r--r--java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/impl/AtomBindingFactoryImpl.java36
-rw-r--r--java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/impl/AtomBindingImpl.java96
-rw-r--r--java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/impl/RSSBindingFactoryImpl.java36
-rw-r--r--java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/impl/RSSBindingImpl.java101
-rw-r--r--java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/provider/AtomBindingInvoker.java345
-rw-r--r--java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/provider/AtomBindingProviderFactory.java74
-rw-r--r--java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/provider/AtomFeedEntryUtil.java117
-rw-r--r--java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/provider/AtomReferenceBindingProvider.java116
-rw-r--r--java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/provider/AtomServiceBindingProvider.java87
-rw-r--r--java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/provider/FeedBindingListenerServlet.java788
-rw-r--r--java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/provider/RSSBindingInvoker.java91
-rw-r--r--java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/provider/RSSBindingProviderFactory.java74
-rw-r--r--java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/provider/RSSReferenceBindingProvider.java65
-rw-r--r--java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/provider/RSSServiceBindingProvider.java85
-rw-r--r--java/sca/modules/binding-feed/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.feed.AtomBindingFactory19
-rw-r--r--java/sca/modules/binding-feed/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.feed.RSSBindingFactory19
-rw-r--r--java/sca/modules/binding-feed/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor20
-rw-r--r--java/sca/modules/binding-feed/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory20
-rw-r--r--java/sca/modules/binding-feed/src/test/java/org/apache/tuscany/sca/binding/feed/Consumer.java35
-rw-r--r--java/sca/modules/binding-feed/src/test/java/org/apache/tuscany/sca/binding/feed/CustomerClient.java25
-rw-r--r--java/sca/modules/binding-feed/src/test/java/org/apache/tuscany/sca/binding/feed/CustomerClientImpl.java97
-rw-r--r--java/sca/modules/binding-feed/src/test/java/org/apache/tuscany/sca/binding/feed/CustomerCollectionImpl.java136
-rw-r--r--java/sca/modules/binding-feed/src/test/java/org/apache/tuscany/sca/binding/feed/Provider.java41
-rw-r--r--java/sca/modules/binding-feed/src/test/resources/org/apache/tuscany/sca/binding/feed/Consumer.composite32
-rw-r--r--java/sca/modules/binding-feed/src/test/resources/org/apache/tuscany/sca/binding/feed/Provider.composite33
-rw-r--r--java/sca/modules/binding-gdata2-runtime/LICENSE205
-rw-r--r--java/sca/modules/binding-gdata2-runtime/NOTICE6
-rwxr-xr-xjava/sca/modules/binding-gdata2-runtime/deployGdataToMaven.sh7
-rw-r--r--java/sca/modules/binding-gdata2-runtime/pom.xml183
-rw-r--r--java/sca/modules/binding-gdata2-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/collection/Collection.java82
-rw-r--r--java/sca/modules/binding-gdata2-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/collection/MediaCollection.java55
-rw-r--r--java/sca/modules/binding-gdata2-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GDataBindingInvoker.java510
-rw-r--r--java/sca/modules/binding-gdata2-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GDataBindingListenerServlet.java426
-rw-r--r--java/sca/modules/binding-gdata2-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GDataBindingProviderFactory.java74
-rw-r--r--java/sca/modules/binding-gdata2-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GDataReferenceBindingProvider.java125
-rw-r--r--java/sca/modules/binding-gdata2-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GDataServiceBindingProvider.java85
-rw-r--r--java/sca/modules/binding-gdata2-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory19
-rw-r--r--java/sca/modules/binding-gdata2-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/calendarconsumer/CalendarConsumer.java121
-rw-r--r--java/sca/modules/binding-gdata2-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/calendarconsumer/CalendarConsumerImpl.java55
-rw-r--r--java/sca/modules/binding-gdata2-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/calendarconsumer/CalendarConsumerTest.java203
-rw-r--r--java/sca/modules/binding-gdata2-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/consumerprovider/Consumer.java36
-rw-r--r--java/sca/modules/binding-gdata2-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/consumerprovider/CustomerClient.java25
-rw-r--r--java/sca/modules/binding-gdata2-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/consumerprovider/CustomerClientImpl.java117
-rw-r--r--java/sca/modules/binding-gdata2-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/consumerprovider/CustomerCollectionImpl.java116
-rw-r--r--java/sca/modules/binding-gdata2-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/consumerprovider/Provider.java34
-rw-r--r--java/sca/modules/binding-gdata2-runtime/src/test/resources/org/apache/tuscany/sca/binding/gdata/CalendarConsumer.composite32
-rw-r--r--java/sca/modules/binding-gdata2-runtime/src/test/resources/org/apache/tuscany/sca/binding/gdata/Consumer.composite32
-rw-r--r--java/sca/modules/binding-gdata2-runtime/src/test/resources/org/apache/tuscany/sca/binding/gdata/Provider.composite33
-rw-r--r--java/sca/modules/binding-gdata2/LICENSE205
-rw-r--r--java/sca/modules/binding-gdata2/NOTICE6
-rw-r--r--java/sca/modules/binding-gdata2/pom.xml73
-rw-r--r--java/sca/modules/binding-gdata2/src/main/java/org/apache/tuscany/sca/binding/gdata/GDataBinding.java77
-rw-r--r--java/sca/modules/binding-gdata2/src/main/java/org/apache/tuscany/sca/binding/gdata/GDataBindingFactory.java35
-rw-r--r--java/sca/modules/binding-gdata2/src/main/java/org/apache/tuscany/sca/binding/gdata/GDataImplementationProcessor.java100
-rw-r--r--java/sca/modules/binding-gdata2/src/main/java/org/apache/tuscany/sca/binding/gdata/impl/GDataBindingFactoryImpl.java36
-rw-r--r--java/sca/modules/binding-gdata2/src/main/java/org/apache/tuscany/sca/binding/gdata/impl/GDataBindingImpl.java137
-rw-r--r--java/sca/modules/binding-gdata2/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.gdata.GDataBindingFactory19
-rw-r--r--java/sca/modules/binding-gdata2/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor21
-rw-r--r--java/sca/modules/core-spring/LICENSE205
-rw-r--r--java/sca/modules/core-spring/NOTICE6
-rw-r--r--java/sca/modules/core-spring/pom.xml126
-rw-r--r--java/sca/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/assembly/impl/BeanAssemblyFactory.java134
-rw-r--r--java/sca/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/assembly/impl/BeanComponentImpl.java233
-rw-r--r--java/sca/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/assembly/impl/BeanReferenceImpl.java70
-rw-r--r--java/sca/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/context/ModelResolverImpl.java88
-rw-r--r--java/sca/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/context/SCADomainContext.java192
-rw-r--r--java/sca/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/implementation/java/impl/BeanBaseJavaImplementationImpl.java211
-rw-r--r--java/sca/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/implementation/java/impl/BeanJavaImplementationFactory.java75
-rw-r--r--java/sca/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/implementation/java/impl/BeanJavaImplementationImpl.java175
-rw-r--r--java/sca/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/implementation/java/impl/BeanJavaInterfaceContractImpl.java34
-rw-r--r--java/sca/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/implementation/java/impl/BeanJavaInterfaceFactory.java75
-rw-r--r--java/sca/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/implementation/java/impl/BeanJavaInterfaceImpl.java149
-rw-r--r--java/sca/modules/core-spring/src/test/java/calculator/AddService.java30
-rw-r--r--java/sca/modules/core-spring/src/test/java/calculator/AddServiceImpl.java37
-rw-r--r--java/sca/modules/core-spring/src/test/java/calculator/CalculatorClient.java43
-rw-r--r--java/sca/modules/core-spring/src/test/java/calculator/CalculatorService.java36
-rw-r--r--java/sca/modules/core-spring/src/test/java/calculator/CalculatorServiceImpl.java73
-rw-r--r--java/sca/modules/core-spring/src/test/java/calculator/DivideService.java30
-rw-r--r--java/sca/modules/core-spring/src/test/java/calculator/DivideServiceImpl.java35
-rw-r--r--java/sca/modules/core-spring/src/test/java/calculator/MultiplyService.java30
-rw-r--r--java/sca/modules/core-spring/src/test/java/calculator/MultiplyServiceImpl.java35
-rw-r--r--java/sca/modules/core-spring/src/test/java/calculator/NestedCalculatorClient.java46
-rw-r--r--java/sca/modules/core-spring/src/test/java/calculator/SubtractService.java30
-rw-r--r--java/sca/modules/core-spring/src/test/java/calculator/SubtractServiceImpl.java35
-rw-r--r--java/sca/modules/core-spring/src/test/java/org/apache/tuscany/sca/core/spring/CalculatorTestCase.java56
-rw-r--r--java/sca/modules/core-spring/src/test/java/org/apache/tuscany/sca/core/spring/NestedCalculatorTestCaseFIXME.java59
-rw-r--r--java/sca/modules/core-spring/src/test/resources/org/apache/tuscany/sca/core/spring/Calculator.composite52
-rw-r--r--java/sca/modules/core-spring/src/test/resources/org/apache/tuscany/sca/core/spring/InnerCalculator.composite42
-rw-r--r--java/sca/modules/core-spring/src/test/resources/org/apache/tuscany/sca/core/spring/InnerOperations.composite57
-rw-r--r--java/sca/modules/core-spring/src/test/resources/org/apache/tuscany/sca/core/spring/OuterCalculator.composite41
-rw-r--r--java/sca/modules/data-engine-helper/LICENSE205
-rw-r--r--java/sca/modules/data-engine-helper/NOTICE6
-rw-r--r--java/sca/modules/data-engine-helper/pom.xml142
-rw-r--r--java/sca/modules/data-engine-helper/src/main/java/org/apache/tuscany/sca/data/engine/ConnectionInfoArtifactProcessor.java197
-rw-r--r--java/sca/modules/data-engine-helper/src/main/java/org/apache/tuscany/sca/data/engine/DataAccessEngine.java286
-rw-r--r--java/sca/modules/data-engine-helper/src/main/java/org/apache/tuscany/sca/data/engine/DataAccessEngineManager.java141
-rw-r--r--java/sca/modules/data-engine-helper/src/main/java/org/apache/tuscany/sca/data/engine/MissingConfigFileException.java44
-rw-r--r--java/sca/modules/data-engine-helper/src/main/java/org/apache/tuscany/sca/data/engine/config/ConnectionInfo.java47
-rw-r--r--java/sca/modules/data-engine-helper/src/main/java/org/apache/tuscany/sca/data/engine/config/ConnectionProperties.java78
-rw-r--r--java/sca/modules/data-engine-helper/src/main/resources/dataengine-helper-validation-messages.properties21
-rw-r--r--java/sca/modules/implementation-bpel-jbpm/LICENSE251
-rw-r--r--java/sca/modules/implementation-bpel-jbpm/NOTICE17
-rw-r--r--java/sca/modules/implementation-bpel-jbpm/pom.xml140
-rw-r--r--java/sca/modules/implementation-bpel-jbpm/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory22
-rw-r--r--java/sca/modules/monitor-logging/LICENSE205
-rw-r--r--java/sca/modules/monitor-logging/NOTICE6
-rw-r--r--java/sca/modules/monitor-logging/pom.xml68
-rw-r--r--java/sca/modules/monitor-logging/src/main/java/org/apache/tuscany/sca/monitor/logging/impl/DefaultLoggingMonitorImpl.java104
-rw-r--r--java/sca/modules/monitor-logging/src/main/java/org/apache/tuscany/sca/monitor/logging/impl/MonitorFactoryImpl.java41
-rw-r--r--java/sca/modules/monitor-logging/src/main/resources/META-INF/services/org.apache.tuscany.sca.monitor.MonitorFactory18
-rw-r--r--java/sca/modules/monitor-logging/src/test/java/org/apache/tuscany/sca/monitor/MonitorTestCase.java94
-rw-r--r--java/sca/modules/monitor-logging/src/test/resources/tuscany-monitor-test-messages.properties24
-rw-r--r--java/sca/modules/monitor-logging/src/test/resources/tuscany-monitor-test-messages_it.properties24
158 files changed, 12852 insertions, 0 deletions
diff --git a/java/sca/modules/api/LICENSE b/java/sca/modules/api/LICENSE
new file mode 100644
index 0000000000..6e529a25c4
--- /dev/null
+++ b/java/sca/modules/api/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/java/sca/modules/api/NOTICE b/java/sca/modules/api/NOTICE
new file mode 100644
index 0000000000..1325efd8bf
--- /dev/null
+++ b/java/sca/modules/api/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2008 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/java/sca/modules/api/pom.xml b/java/sca/modules/api/pom.xml
new file mode 100644
index 0000000000..92f6bf9189
--- /dev/null
+++ b/java/sca/modules/api/pom.xml
@@ -0,0 +1,304 @@
+<?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-api</artifactId>
+ <name>Apache Tuscany SCA API</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-embedded</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-extensibility</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-definitions</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-definitions-xml</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-sca</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-sca-xml</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution-impl</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-policy-xml</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-databinding</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xsd</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-policy-xml</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-endpoint</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ </dependencies>
+
+
+ <build>
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ </resource>
+ </resources>
+
+ <plugins>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <executions>
+
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>shade</goal>
+ </goals>
+ <configuration>
+ <shadedGroupFilter>org.apache.tuscany.sca</shadedGroupFilter>
+
+ <shadedArtifactAttached>false</shadedArtifactAttached>
+ <createSourcesJar>${createSourcesJar}</createSourcesJar>
+ <promoteTransitiveDependencies>false</promoteTransitiveDependencies>
+ <createDependencyReducedPom>true</createDependencyReducedPom>
+
+ <!-- artifactSet>
+ <includes>
+ <include>org.apache.tuscany.sca:sca-api</include>
+ </includes>
+ <excludes>
+ <exclude>org.apache.tuscany.sca:extensibility</exclude>
+ </excludes>
+ </artifactSet -->
+
+ <filters>
+ <filter>
+ <artifact>org.apache.tuscany.sca:tuscany-host-embedded</artifact>
+ <excludes>
+ <exclude>org/apache/tuscany/sca/host/embedded/impl/**</exclude>
+ </excludes>
+ </filter>
+ <filter>
+ <artifact>${project.groupId}:${project.artifactId}</artifact>
+
+ <excludes>
+ <exclude>org/**</exclude>
+ </excludes>
+ </filter>
+ </filters>
+
+ <transformers>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.assembly.AssemblyFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.assembly.SCABindingFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.binding.feed.AtomBindingFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.binding.feed.RSSBindingFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.binding.atom.AtomBindingFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.binding.rss.RSSBindingFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.binding.http.HTTPResourceBindingFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.ContributionFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.java.JavaImportExportFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.namespace.NamespaceImportExportFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.processor.ContributionPostProcessorExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.processor.PackageProcessor</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.processor.PackageProcessorExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolverExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.service.ContributionListener</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.service.ContributionListenerExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.core.ModuleActivator</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.databinding.DataBinding</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.databinding.DataBindingExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.databinding.PushTransformer</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.databinding.TransformerExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.extension.helper.BindingActivator</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.extension.helper.ImplementationActivator</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.host.http.ServletHostExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.host.rmi.RMIHostExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.implementation.java.JavaImplementationFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.implementation.resource.ResourceImplementationFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceVisitor</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.runtime.RuntimeWireProcessorExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.spi.ImplementationActivator</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.work.WorkScheduler</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.policy.util.PolicyHandler</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.definitions.SCADefinitionsProvider</resource>
+ </transformer>
+ </transformers>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/java/sca/contrib/modules/binding-dwr/LICENSE b/java/sca/modules/assembly-java-dsl/LICENSE
index 8aa906c321..8aa906c321 100644
--- a/java/sca/contrib/modules/binding-dwr/LICENSE
+++ b/java/sca/modules/assembly-java-dsl/LICENSE
diff --git a/java/sca/contrib/modules/binding-dwr/NOTICE b/java/sca/modules/assembly-java-dsl/NOTICE
index fdfa0e9faa..fdfa0e9faa 100644
--- a/java/sca/contrib/modules/binding-dwr/NOTICE
+++ b/java/sca/modules/assembly-java-dsl/NOTICE
diff --git a/java/sca/modules/assembly-java-dsl/pom.xml b/java/sca/modules/assembly-java-dsl/pom.xml
new file mode 100644
index 0000000000..8da66dbfef
--- /dev/null
+++ b/java/sca/modules/assembly-java-dsl/pom.xml
@@ -0,0 +1,56 @@
+<?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-assembly-java-dsl</artifactId>
+ <name>Apache Tuscany SCA Assembly Model Java DSL</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+
+ <configuration>
+ <instructions>
+ <Bundle-Version>${tuscany.version}</Bundle-Version>
+ <Bundle-SymbolicName>org.apache.tuscany.sca.assembly.java.dsl</Bundle-SymbolicName>
+ <Bundle-Description>${pom.name}</Bundle-Description>
+ <Export-Package>org.apache.tuscany.assembly.java.dsl*</Export-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/AssemblyBuilder.java b/java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/AssemblyBuilder.java
new file mode 100644
index 0000000000..28a5ecdc24
--- /dev/null
+++ b/java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/AssemblyBuilder.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.assembly.dsl;
+
+
+public interface AssemblyBuilder {
+
+ CompositeBuilder composite(String name);
+
+ ComponentBuilder component(String name);
+
+ ComponentReferenceBuilder reference(String name);
+
+ ComponentServiceBuilder service(String name);
+
+ ComponentPropertyBuilder property(String name);
+
+ CompositeBuilder domain(String uri);
+
+}
diff --git a/java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/ComponentBuilder.java b/java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/ComponentBuilder.java
new file mode 100644
index 0000000000..3d97041907
--- /dev/null
+++ b/java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/ComponentBuilder.java
@@ -0,0 +1,34 @@
+/*
+ * 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.assembly.dsl;
+
+public interface ComponentBuilder {
+
+ ComponentBuilder implementedBy(Class clazz);
+
+ ComponentBuilder implementedBy(CompositeBuilder composite);
+
+ ComponentBuilder uses(ComponentReferenceBuilder... componentReferences);
+
+ ComponentBuilder provides(ComponentServiceBuilder... componentServices);
+
+ ComponentBuilder declares(ComponentPropertyBuilder...componentProperties);
+
+}
diff --git a/java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/ComponentPropertyBuilder.java b/java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/ComponentPropertyBuilder.java
new file mode 100644
index 0000000000..7f3c89fd2f
--- /dev/null
+++ b/java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/ComponentPropertyBuilder.java
@@ -0,0 +1,28 @@
+/*
+ * 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.assembly.dsl;
+
+public interface ComponentPropertyBuilder {
+
+ ComponentPropertyBuilder ofType(String type);
+
+ ComponentPropertyBuilder configuredTo(Object value);
+
+}
diff --git a/java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/ComponentReferenceBuilder.java b/java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/ComponentReferenceBuilder.java
new file mode 100644
index 0000000000..8966a4be9d
--- /dev/null
+++ b/java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/ComponentReferenceBuilder.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.assembly.dsl;
+
+public interface ComponentReferenceBuilder {
+
+ ComponentReferenceBuilder wiredTo(String target);
+
+ ComponentReferenceBuilder wiredTo(ComponentServiceBuilder target);
+
+ ComponentReferenceBuilder typedBy(Class interfaceClass);
+
+ ComponentReferenceBuilder promotedAs(String promoted);
+
+ ComponentReferenceBuilder promoted();
+
+ ComponentReferenceBuilder boundTo(String uri);
+
+}
diff --git a/java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/ComponentServiceBuilder.java b/java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/ComponentServiceBuilder.java
new file mode 100644
index 0000000000..f3e36e8c38
--- /dev/null
+++ b/java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/ComponentServiceBuilder.java
@@ -0,0 +1,32 @@
+/*
+ * 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.assembly.dsl;
+
+public interface ComponentServiceBuilder {
+
+ ComponentServiceBuilder typedBy(Class interfaceClass);
+
+ ComponentServiceBuilder promotedAs(String promoted);
+
+ ComponentServiceBuilder promoted();
+
+ ComponentServiceBuilder boundTo(String uri);
+
+}
diff --git a/java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/CompositeBuilder.java b/java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/CompositeBuilder.java
new file mode 100644
index 0000000000..e2108b5ef8
--- /dev/null
+++ b/java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/CompositeBuilder.java
@@ -0,0 +1,29 @@
+/*
+ * 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.assembly.dsl;
+
+
+public interface CompositeBuilder {
+
+ CompositeBuilder contains(ComponentBuilder... components);
+
+ CompositeBuilder includes(CompositeBuilder... includes);
+
+}
diff --git a/java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/AssemblyBuilderImpl.java b/java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/AssemblyBuilderImpl.java
new file mode 100644
index 0000000000..0968310548
--- /dev/null
+++ b/java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/AssemblyBuilderImpl.java
@@ -0,0 +1,70 @@
+/*
+ * 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.assembly.dsl.impl;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory;
+import org.apache.tuscany.sca.assembly.dsl.AssemblyBuilder;
+import org.apache.tuscany.sca.assembly.dsl.ComponentBuilder;
+import org.apache.tuscany.sca.assembly.dsl.ComponentPropertyBuilder;
+import org.apache.tuscany.sca.assembly.dsl.ComponentReferenceBuilder;
+import org.apache.tuscany.sca.assembly.dsl.ComponentServiceBuilder;
+import org.apache.tuscany.sca.assembly.dsl.CompositeBuilder;
+
+public class AssemblyBuilderImpl extends DefaultAssemblyFactory implements AssemblyBuilder {
+
+ public ComponentBuilder component(String name) {
+ ComponentBuilderImpl component = new ComponentBuilderImpl();
+ component.setName(name);
+ return component;
+ }
+
+ public CompositeBuilder composite(String name) {
+ CompositeBuilderImpl composite = new CompositeBuilderImpl();
+ //TODO handle namespace
+ composite.setName(new QName("", name));
+ return composite;
+ }
+
+ public CompositeBuilder domain(String uri) {
+ CompositeBuilderImpl composite = new CompositeBuilderImpl();
+ composite.setName(new QName(uri, ""));
+ return composite;
+ }
+
+ public ComponentPropertyBuilder property(String name) {
+ ComponentPropertyBuilderImpl property = new ComponentPropertyBuilderImpl();
+ property.setName(name);
+ return property;
+ }
+
+ public ComponentReferenceBuilder reference(String name) {
+ ComponentReferenceBuilderImpl reference = new ComponentReferenceBuilderImpl(this);
+ reference.setName(name);
+ return reference;
+ }
+
+ public ComponentServiceBuilder service(String name) {
+ ComponentServiceBuilderImpl service = new ComponentServiceBuilderImpl(this);
+ service.setName(name);
+ return service;
+ }
+
+}
diff --git a/java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/ComponentBuilderImpl.java b/java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/ComponentBuilderImpl.java
new file mode 100644
index 0000000000..9022b9d9e6
--- /dev/null
+++ b/java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/ComponentBuilderImpl.java
@@ -0,0 +1,74 @@
+/*
+ * 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.assembly.dsl.impl;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.ComponentProperty;
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.dsl.ComponentBuilder;
+import org.apache.tuscany.sca.assembly.dsl.ComponentPropertyBuilder;
+import org.apache.tuscany.sca.assembly.dsl.ComponentReferenceBuilder;
+import org.apache.tuscany.sca.assembly.dsl.ComponentServiceBuilder;
+import org.apache.tuscany.sca.assembly.dsl.CompositeBuilder;
+import org.apache.tuscany.sca.assembly.impl.ComponentImpl;
+
+public class ComponentBuilderImpl extends ComponentImpl implements ComponentBuilder {
+
+ public ComponentBuilderImpl() {
+ }
+
+ public ComponentBuilder implementedBy(Class clazz) {
+ //FIXME support Java implementations
+ return this;
+ }
+
+ public ComponentBuilder implementedBy(CompositeBuilder composite) {
+ setImplementation((Composite)composite);
+ return this;
+ }
+
+ public ComponentBuilder uses(ComponentReferenceBuilder... componentReferences) {
+ List<ComponentReference> references = getReferences();
+ for (ComponentReferenceBuilder componentReference: componentReferences) {
+ references.add((ComponentReference)componentReference);
+ }
+ return this;
+ }
+
+ public ComponentBuilder provides(ComponentServiceBuilder... componentServices) {
+ List<ComponentService> services = getServices();
+ for (ComponentServiceBuilder componentService: componentServices) {
+ services.add((ComponentService)componentService);
+ }
+ return this;
+ }
+
+ public ComponentBuilder declares(ComponentPropertyBuilder...componentProperties) {
+ List<ComponentProperty> properties = getProperties();
+ for (ComponentPropertyBuilder componentProperty: componentProperties) {
+ properties.add((ComponentProperty)componentProperty);
+ }
+ return this;
+ }
+
+}
diff --git a/java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/ComponentPropertyBuilderImpl.java b/java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/ComponentPropertyBuilderImpl.java
new file mode 100644
index 0000000000..49f7cd46b2
--- /dev/null
+++ b/java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/ComponentPropertyBuilderImpl.java
@@ -0,0 +1,40 @@
+/*
+ * 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.assembly.dsl.impl;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.dsl.ComponentPropertyBuilder;
+import org.apache.tuscany.sca.assembly.impl.ComponentPropertyImpl;
+
+public class ComponentPropertyBuilderImpl extends ComponentPropertyImpl implements ComponentPropertyBuilder {
+
+ public ComponentPropertyBuilderImpl ofType(String type) {
+ //TODO handle namespace
+ this.setXSDType(new QName("", type));
+ return this;
+ }
+
+ public ComponentPropertyBuilderImpl configuredTo(Object value) {
+ this.setValue(value);
+ return this;
+ }
+
+}
diff --git a/java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/ComponentReferenceBuilderImpl.java b/java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/ComponentReferenceBuilderImpl.java
new file mode 100644
index 0000000000..d9aab9de22
--- /dev/null
+++ b/java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/ComponentReferenceBuilderImpl.java
@@ -0,0 +1,77 @@
+/*
+ * 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.assembly.dsl.impl;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.CompositeReference;
+import org.apache.tuscany.sca.assembly.dsl.ComponentReferenceBuilder;
+import org.apache.tuscany.sca.assembly.dsl.ComponentServiceBuilder;
+import org.apache.tuscany.sca.assembly.impl.ComponentReferenceImpl;
+import org.apache.tuscany.sca.assembly.impl.ComponentServiceImpl;
+
+public class ComponentReferenceBuilderImpl extends ComponentReferenceImpl implements ComponentReferenceBuilder {
+
+ private CompositeReference compositeReference;
+ private AssemblyFactory assemblyFactory;
+
+ protected ComponentReferenceBuilderImpl(AssemblyFactory assemblyFactory) {
+ this.assemblyFactory = assemblyFactory;
+ }
+
+ public ComponentReferenceBuilder wiredTo(String target) {
+ ComponentService componentService = assemblyFactory.createComponentService();
+ componentService.setUnresolved(true);
+ componentService.setName(target);
+ getTargets().add(componentService);
+ return this;
+ }
+
+ public ComponentReferenceBuilder wiredTo(ComponentServiceBuilder target) {
+ getTargets().add((ComponentServiceImpl)target);
+ return this;
+ }
+
+ public ComponentReferenceBuilderImpl typedBy(Class interfaceClass) {
+ //FIXME support for Java interfaces
+ return this;
+ }
+
+ public ComponentReferenceBuilderImpl promotedAs(String promoted) {
+ compositeReference = assemblyFactory.createCompositeReference();
+ compositeReference.setName(promoted);
+ return this;
+ }
+
+ public ComponentReferenceBuilderImpl promoted() {
+ compositeReference = assemblyFactory.createCompositeReference();
+ compositeReference.setName(getName());
+ return this;
+ }
+
+ public ComponentReferenceBuilder boundTo(String uri) {
+ //TODO support bindings
+ return this;
+ }
+
+ CompositeReference getCompositeReference() {
+ return compositeReference;
+ }
+}
diff --git a/java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/ComponentServiceBuilderImpl.java b/java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/ComponentServiceBuilderImpl.java
new file mode 100644
index 0000000000..379429d17e
--- /dev/null
+++ b/java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/ComponentServiceBuilderImpl.java
@@ -0,0 +1,62 @@
+/*
+ * 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.assembly.dsl.impl;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.CompositeService;
+import org.apache.tuscany.sca.assembly.dsl.ComponentServiceBuilder;
+import org.apache.tuscany.sca.assembly.impl.ComponentServiceImpl;
+
+public class ComponentServiceBuilderImpl extends ComponentServiceImpl implements ComponentServiceBuilder {
+
+ private CompositeService compositeService;
+ private AssemblyFactory assemblyFactory;
+
+ protected ComponentServiceBuilderImpl(AssemblyFactory assemblyFactory) {
+ this.assemblyFactory = assemblyFactory;
+ }
+
+ public ComponentServiceBuilderImpl typedBy(Class interfaceClass) {
+ //FIXME support for Java interfaces
+ return this;
+ }
+
+ public ComponentServiceBuilderImpl promotedAs(String promoted) {
+ compositeService = assemblyFactory.createCompositeService();
+ compositeService.setName(promoted);
+ return this;
+ }
+
+ public ComponentServiceBuilderImpl promoted() {
+ compositeService = assemblyFactory.createCompositeService();
+ compositeService.setName(getName());
+ return this;
+ }
+
+ public ComponentServiceBuilder boundTo(String uri) {
+ // TODO support bindings
+ return this;
+ }
+
+ CompositeService getCompositeService() {
+ return compositeService;
+ }
+
+}
diff --git a/java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/CompositeBuilderImpl.java b/java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/CompositeBuilderImpl.java
new file mode 100644
index 0000000000..709562cd72
--- /dev/null
+++ b/java/sca/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/CompositeBuilderImpl.java
@@ -0,0 +1,62 @@
+/*
+ * 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.assembly.dsl.impl;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.dsl.ComponentBuilder;
+import org.apache.tuscany.sca.assembly.dsl.CompositeBuilder;
+import org.apache.tuscany.sca.assembly.impl.CompositeImpl;
+
+public class CompositeBuilderImpl extends CompositeImpl implements CompositeBuilder {
+
+ public CompositeBuilder contains(ComponentBuilder... componentBuilders) {
+ List<Component> components = getComponents();
+ for (ComponentBuilder componentBuilder: componentBuilders) {
+ Component component = (Component)componentBuilder;
+ components.add(component);
+
+ for (ComponentService componentService: component.getServices()) {
+ ComponentServiceBuilderImpl builder = (ComponentServiceBuilderImpl)componentService;
+ if (builder.getCompositeService() != null)
+ getServices().add(builder.getCompositeService());
+ }
+ for (ComponentReference componentReference: component.getReferences()) {
+ ComponentReferenceBuilderImpl builder = (ComponentReferenceBuilderImpl)componentReference;
+ if (builder.getCompositeReference() != null)
+ getReferences().add(builder.getCompositeReference());
+ }
+ }
+ return this;
+ }
+
+ public CompositeBuilder includes(CompositeBuilder... compositeBuilders) {
+ List<Composite> list = getIncludes();
+ for (CompositeBuilder composite: compositeBuilders) {
+ list.add((Composite)composite);
+ }
+ return this;
+ }
+
+}
diff --git a/java/sca/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/AccountDataService.java b/java/sca/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/AccountDataService.java
new file mode 100644
index 0000000000..ba91fd2168
--- /dev/null
+++ b/java/sca/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/AccountDataService.java
@@ -0,0 +1,24 @@
+/*
+ * 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.assembly.dsl;
+
+public interface AccountDataService {
+
+}
diff --git a/java/sca/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/AccountDataServiceImpl.java b/java/sca/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/AccountDataServiceImpl.java
new file mode 100644
index 0000000000..4e239d03d3
--- /dev/null
+++ b/java/sca/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/AccountDataServiceImpl.java
@@ -0,0 +1,24 @@
+/*
+ * 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.assembly.dsl;
+
+public class AccountDataServiceImpl {
+
+}
diff --git a/java/sca/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/AccountService.java b/java/sca/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/AccountService.java
new file mode 100644
index 0000000000..030c820ed2
--- /dev/null
+++ b/java/sca/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/AccountService.java
@@ -0,0 +1,24 @@
+/*
+ * 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.assembly.dsl;
+
+public interface AccountService {
+
+}
diff --git a/java/sca/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/AccountServiceImpl.java b/java/sca/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/AccountServiceImpl.java
new file mode 100644
index 0000000000..92f448ec87
--- /dev/null
+++ b/java/sca/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/AccountServiceImpl.java
@@ -0,0 +1,24 @@
+/*
+ * 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.assembly.dsl;
+
+public class AccountServiceImpl {
+
+}
diff --git a/java/sca/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/BigBankBuilder.java b/java/sca/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/BigBankBuilder.java
new file mode 100644
index 0000000000..b856201551
--- /dev/null
+++ b/java/sca/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/BigBankBuilder.java
@@ -0,0 +1,59 @@
+/*
+ * 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.assembly.dsl;
+
+import org.apache.tuscany.sca.assembly.dsl.impl.AssemblyBuilderImpl;
+
+public class BigBankBuilder extends AssemblyBuilderImpl {
+
+ public CompositeBuilder build() {
+
+ CompositeBuilder bigbankAccount = composite("bigbank.account").contains(
+
+ component("AccountServiceComponent").
+ implementedBy(AccountServiceImpl.class).
+ uses(
+ reference("accountDataService").typedBy(AccountDataService.class).wiredTo("AccountDataServiceComponent/AccountDataService"),
+ reference("stockQuoteService").promotedAs("StockQuoteService")
+ ).
+ provides(
+ service("AccountDataService").typedBy(AccountService.class).promoted()
+ ).
+ declares(
+ property("currency").ofType("string").configuredTo("USD")
+ ),
+
+ component("AccountDataServiceComponent").
+ implementedBy(AccountDataServiceImpl.class).
+ provides(
+ service("AccountDataService").typedBy(AccountDataService.class)
+ )
+ );
+
+ CompositeBuilder bigbankApp = composite("bigbank.app").
+ contains(
+ component("BigBankAccount").implementedBy(bigbankAccount)
+ );
+
+ CompositeBuilder domain = domain("http://bigbank.org").includes(bigbankApp);
+
+ return domain;
+ }
+}
diff --git a/java/sca/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/BigBankBuilderTestCase.java b/java/sca/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/BigBankBuilderTestCase.java
new file mode 100644
index 0000000000..fb950b5c13
--- /dev/null
+++ b/java/sca/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/BigBankBuilderTestCase.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.assembly.dsl;
+
+import junit.framework.TestCase;
+
+public class BigBankBuilderTestCase extends TestCase {
+
+ public void testBuild() throws Exception {
+
+ BigBankBuilder builder = new BigBankBuilder();
+ CompositeBuilder domain = builder.build();
+ assertNotNull(domain);
+ }
+
+}
diff --git a/java/sca/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/StockQuoteService.java b/java/sca/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/StockQuoteService.java
new file mode 100644
index 0000000000..a0580095a0
--- /dev/null
+++ b/java/sca/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/StockQuoteService.java
@@ -0,0 +1,24 @@
+/*
+ * 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.assembly.dsl;
+
+public interface StockQuoteService {
+
+}
diff --git a/java/sca/modules/binding-dwr/LICENSE b/java/sca/modules/binding-dwr/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/java/sca/modules/binding-dwr/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/java/sca/modules/binding-dwr/NOTICE b/java/sca/modules/binding-dwr/NOTICE
new file mode 100644
index 0000000000..fdfa0e9faa
--- /dev/null
+++ b/java/sca/modules/binding-dwr/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2008 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/java/sca/contrib/modules/binding-dwr/pom.xml b/java/sca/modules/binding-dwr/pom.xml
index 19f98a4c23..19f98a4c23 100644
--- a/java/sca/contrib/modules/binding-dwr/pom.xml
+++ b/java/sca/modules/binding-dwr/pom.xml
diff --git a/java/sca/contrib/modules/binding-dwr/src/main/java/org/apache/tuscany/sca/binding/dwr/DWRBinding.java b/java/sca/modules/binding-dwr/src/main/java/org/apache/tuscany/sca/binding/dwr/DWRBinding.java
index ae5cf327ab..ae5cf327ab 100644
--- a/java/sca/contrib/modules/binding-dwr/src/main/java/org/apache/tuscany/sca/binding/dwr/DWRBinding.java
+++ b/java/sca/modules/binding-dwr/src/main/java/org/apache/tuscany/sca/binding/dwr/DWRBinding.java
diff --git a/java/sca/contrib/modules/binding-dwr/src/main/java/org/apache/tuscany/sca/binding/dwr/DWRBindingActivator.java b/java/sca/modules/binding-dwr/src/main/java/org/apache/tuscany/sca/binding/dwr/DWRBindingActivator.java
index d14751f235..d14751f235 100644
--- a/java/sca/contrib/modules/binding-dwr/src/main/java/org/apache/tuscany/sca/binding/dwr/DWRBindingActivator.java
+++ b/java/sca/modules/binding-dwr/src/main/java/org/apache/tuscany/sca/binding/dwr/DWRBindingActivator.java
diff --git a/java/sca/contrib/modules/binding-dwr/src/main/java/org/apache/tuscany/sca/binding/dwr/DWRInvoker.java b/java/sca/modules/binding-dwr/src/main/java/org/apache/tuscany/sca/binding/dwr/DWRInvoker.java
index 24e6dbbcd4..24e6dbbcd4 100644
--- a/java/sca/contrib/modules/binding-dwr/src/main/java/org/apache/tuscany/sca/binding/dwr/DWRInvoker.java
+++ b/java/sca/modules/binding-dwr/src/main/java/org/apache/tuscany/sca/binding/dwr/DWRInvoker.java
diff --git a/java/sca/contrib/modules/binding-dwr/src/main/java/org/apache/tuscany/sca/binding/dwr/DWRInvokerFactory.java b/java/sca/modules/binding-dwr/src/main/java/org/apache/tuscany/sca/binding/dwr/DWRInvokerFactory.java
index 1d073c9ecf..1d073c9ecf 100644
--- a/java/sca/contrib/modules/binding-dwr/src/main/java/org/apache/tuscany/sca/binding/dwr/DWRInvokerFactory.java
+++ b/java/sca/modules/binding-dwr/src/main/java/org/apache/tuscany/sca/binding/dwr/DWRInvokerFactory.java
diff --git a/java/sca/contrib/modules/binding-dwr/src/main/java/org/apache/tuscany/sca/binding/dwr/DWRService.java b/java/sca/modules/binding-dwr/src/main/java/org/apache/tuscany/sca/binding/dwr/DWRService.java
index 7d5a7f1677..7d5a7f1677 100644
--- a/java/sca/contrib/modules/binding-dwr/src/main/java/org/apache/tuscany/sca/binding/dwr/DWRService.java
+++ b/java/sca/modules/binding-dwr/src/main/java/org/apache/tuscany/sca/binding/dwr/DWRService.java
diff --git a/java/sca/contrib/modules/binding-dwr/src/main/java/org/apache/tuscany/sca/binding/dwr/DWRServlet.java b/java/sca/modules/binding-dwr/src/main/java/org/apache/tuscany/sca/binding/dwr/DWRServlet.java
index 3a2471d8f3..3a2471d8f3 100644
--- a/java/sca/contrib/modules/binding-dwr/src/main/java/org/apache/tuscany/sca/binding/dwr/DWRServlet.java
+++ b/java/sca/modules/binding-dwr/src/main/java/org/apache/tuscany/sca/binding/dwr/DWRServlet.java
diff --git a/java/sca/contrib/modules/binding-dwr/src/main/resources/META-INF/services/org.apache.tuscany.sca.extension.helper.BindingActivator b/java/sca/modules/binding-dwr/src/main/resources/META-INF/services/org.apache.tuscany.sca.extension.helper.BindingActivator
index 1a9f91fab2..1a9f91fab2 100644
--- a/java/sca/contrib/modules/binding-dwr/src/main/resources/META-INF/services/org.apache.tuscany.sca.extension.helper.BindingActivator
+++ b/java/sca/modules/binding-dwr/src/main/resources/META-INF/services/org.apache.tuscany.sca.extension.helper.BindingActivator
diff --git a/java/sca/modules/binding-feed/LICENSE b/java/sca/modules/binding-feed/LICENSE
new file mode 100644
index 0000000000..6e529a25c4
--- /dev/null
+++ b/java/sca/modules/binding-feed/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/java/sca/modules/binding-feed/NOTICE b/java/sca/modules/binding-feed/NOTICE
new file mode 100644
index 0000000000..1325efd8bf
--- /dev/null
+++ b/java/sca/modules/binding-feed/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2008 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/java/sca/modules/binding-feed/pom.xml b/java/sca/modules/binding-feed/pom.xml
new file mode 100644
index 0000000000..c0c895a894
--- /dev/null
+++ b/java/sca/modules/binding-feed/pom.xml
@@ -0,0 +1,165 @@
+<?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-feed</artifactId>
+ <name>Apache Tuscany SCA Atom+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-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>0.9</version>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.4</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-host-embedded</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.5</version>
+ <scope>test</scope>
+ </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>
+
+ </dependencies>
+
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+
+ <configuration>
+ <instructions>
+ <Bundle-Version>${tuscany.version}</Bundle-Version>
+ <Bundle-SymbolicName>org.apache.tuscany.sca.binding.feed</Bundle-SymbolicName>
+ <Bundle-Description>${pom.name}</Bundle-Description>
+ <Export-Package>org.apache.tuscany.sca.binding.feed*</Export-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/AtomBinding.java b/java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/AtomBinding.java
new file mode 100644
index 0000000000..00aa813af2
--- /dev/null
+++ b/java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/AtomBinding.java
@@ -0,0 +1,30 @@
+/*
+ * 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.feed;
+
+import org.apache.tuscany.sca.assembly.Binding;
+
+/**
+ * Atom binding model.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface AtomBinding extends Binding {
+}
diff --git a/java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/AtomBindingFactory.java b/java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/AtomBindingFactory.java
new file mode 100644
index 0000000000..050ba9b73c
--- /dev/null
+++ b/java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/AtomBindingFactory.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.feed;
+
+/**
+ * Factory for the Atom binding
+ *
+ * @version $Rev$ $Date$
+ */
+public interface AtomBindingFactory {
+
+ /**
+ * Creates a new Atom binding.
+ * @return the new Atom binding
+ */
+ AtomBinding createAtomBinding();
+
+}
diff --git a/java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/RSSBinding.java b/java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/RSSBinding.java
new file mode 100644
index 0000000000..81b9fd95ad
--- /dev/null
+++ b/java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/RSSBinding.java
@@ -0,0 +1,30 @@
+/*
+ * 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.feed;
+
+import org.apache.tuscany.sca.assembly.Binding;
+
+/**
+ * RSS Feed binding model.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface RSSBinding extends Binding {
+}
diff --git a/java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/RSSBindingFactory.java b/java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/RSSBindingFactory.java
new file mode 100644
index 0000000000..c95c8ac012
--- /dev/null
+++ b/java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/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.feed;
+
+/**
+ * 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/java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/collection/Collection.java b/java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/collection/Collection.java
new file mode 100644
index 0000000000..30068afa0a
--- /dev/null
+++ b/java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/collection/Collection.java
@@ -0,0 +1,72 @@
+/*
+ * 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.feed.collection;
+
+import org.osoa.sca.annotations.Remotable;
+
+import com.sun.syndication.feed.atom.Entry;
+
+/**
+ * Provides access to a collection of resources using Atom.
+ *
+ * @version $Rev$ $Date$
+ */
+@Remotable
+public interface Collection {
+
+ /**
+ * Get an RSS or Atom feed for a collection of resources.
+ *
+ * @return the RSS or Atom feed
+ */
+ com.sun.syndication.feed.atom.Feed getFeed();
+
+ /**
+ * Creates a new entry.
+ *
+ * @param entry
+ * @return
+ */
+ Entry post(Entry entry);
+
+ /**
+ * Retrieves an entry.
+ *
+ * @param id
+ * @return
+ */
+ Entry get(String id) throws NotFoundException;
+
+ /**
+ * Update an entry.
+ *
+ * @param id
+ * @param entry
+ * @return
+ */
+ void put(String id, Entry entry) throws NotFoundException;
+
+ /**
+ * Delete an entry.
+ *
+ * @param id
+ */
+ void delete(String id) throws NotFoundException;
+
+}
diff --git a/java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/collection/MediaCollection.java b/java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/collection/MediaCollection.java
new file mode 100644
index 0000000000..39a4213a65
--- /dev/null
+++ b/java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/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.feed.collection;
+
+import java.io.InputStream;
+
+import org.osoa.sca.annotations.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/java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/collection/NotFoundException.java b/java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/collection/NotFoundException.java
new file mode 100644
index 0000000000..503f30e685
--- /dev/null
+++ b/java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/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.feed.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/java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/impl/AtomBindingFactoryImpl.java b/java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/impl/AtomBindingFactoryImpl.java
new file mode 100644
index 0000000000..a9a1167544
--- /dev/null
+++ b/java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/impl/AtomBindingFactoryImpl.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.feed.impl;
+
+import org.apache.tuscany.sca.binding.feed.AtomBinding;
+import org.apache.tuscany.sca.binding.feed.AtomBindingFactory;
+
+/**
+ * Factory for the Atom binding model.
+ *
+ * @version $Rev$ $Date$
+ */
+public class AtomBindingFactoryImpl implements AtomBindingFactory {
+
+ public AtomBinding createAtomBinding() {
+ return new AtomBindingImpl();
+ }
+
+}
diff --git a/java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/impl/AtomBindingImpl.java b/java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/impl/AtomBindingImpl.java
new file mode 100644
index 0000000000..76551bc412
--- /dev/null
+++ b/java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/impl/AtomBindingImpl.java
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.feed.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.binding.feed.AtomBinding;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.IntentAttachPointType;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
+
+/**
+ * Implementation of the Atom Feed binding model.
+ *
+ * @version $Rev$ $Date$
+ */
+class AtomBindingImpl implements AtomBinding, PolicySetAttachPoint {
+
+ private String name;
+ private String uri;
+ private List<Intent> requiredIntents = new ArrayList<Intent>();
+ private List<PolicySet> policySets = new ArrayList<PolicySet>();
+ private IntentAttachPointType intentAttachPointType;
+ private List<PolicySet> applicablePolicySets = new ArrayList<PolicySet>();
+
+ public List<PolicySet> getApplicablePolicySets() {
+ return applicablePolicySets;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getURI() {
+ return uri;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void setURI(String uri) {
+ this.uri = uri;
+ }
+
+
+ public boolean isUnresolved() {
+ // The binding is always resolved
+ return false;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ // The binding is always resolved
+ }
+
+ public List<PolicySet> getPolicySets() {
+ return policySets;
+ }
+
+ public List<Intent> getRequiredIntents() {
+ return requiredIntents;
+ }
+
+ public IntentAttachPointType getType() {
+ return intentAttachPointType;
+ }
+
+ public void setType(IntentAttachPointType intentAttachPointType) {
+ this.intentAttachPointType = intentAttachPointType;
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+
+}
diff --git a/java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/impl/RSSBindingFactoryImpl.java b/java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/impl/RSSBindingFactoryImpl.java
new file mode 100644
index 0000000000..4d8fb943f0
--- /dev/null
+++ b/java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/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.feed.impl;
+
+import org.apache.tuscany.sca.binding.feed.RSSBinding;
+import org.apache.tuscany.sca.binding.feed.RSSBindingFactory;
+
+/**
+ * Factory for the RSS binding model.
+ *
+ * @version $Rev$ $Date$
+ */
+public class RSSBindingFactoryImpl implements RSSBindingFactory {
+
+ public RSSBinding createRSSBinding() {
+ return new RSSBindingImpl();
+ }
+
+}
diff --git a/java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/impl/RSSBindingImpl.java b/java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/impl/RSSBindingImpl.java
new file mode 100644
index 0000000000..9df2ec60da
--- /dev/null
+++ b/java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/impl/RSSBindingImpl.java
@@ -0,0 +1,101 @@
+/*
+ * 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.feed.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.binding.feed.RSSBinding;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.IntentAttachPointType;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
+
+/**
+ * Implementation of the RSS Feed binding model.
+ *
+ * @version $Rev$ $Date$
+ */
+class RSSBindingImpl implements RSSBinding, PolicySetAttachPoint {
+
+ private String name;
+ private String uri;
+ private List<Intent> requiredIntents = new ArrayList<Intent>();
+ private List<PolicySet> policySets = new ArrayList<PolicySet>();
+ private IntentAttachPointType intentAttachPointType;
+ private List<PolicySet> applicablePolicySets = new ArrayList<PolicySet>();
+
+ public List<PolicySet> getApplicablePolicySets() {
+ return applicablePolicySets;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getURI() {
+ return uri;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void setURI(String uri) {
+ this.uri = uri;
+ }
+
+ public boolean isUnresolved() {
+ return false;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ // The binding is always resolved
+ }
+
+ public List<PolicySet> getPolicySets() {
+ return policySets;
+ }
+
+ public List<Intent> getRequiredIntents() {
+ return requiredIntents;
+ }
+
+ public IntentAttachPointType getType() {
+ return intentAttachPointType;
+ }
+
+ public void setType(IntentAttachPointType intentAttachPointType) {
+ this.intentAttachPointType = intentAttachPointType;
+ }
+
+ public void setPolicySets(List<PolicySet> policySets) {
+ this.policySets = policySets;
+ }
+
+ public void setRequiredIntents(List<Intent> intents) {
+ this.requiredIntents = intents;
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+}
diff --git a/java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/provider/AtomBindingInvoker.java b/java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/provider/AtomBindingInvoker.java
new file mode 100644
index 0000000000..45b35d9206
--- /dev/null
+++ b/java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/provider/AtomBindingInvoker.java
@@ -0,0 +1,345 @@
+/*
+ * 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.feed.provider;
+
+import java.io.InputStreamReader;
+import java.io.StringWriter;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.methods.DeleteMethod;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.commons.httpclient.methods.PutMethod;
+import org.apache.commons.httpclient.methods.StringRequestEntity;
+import org.apache.tuscany.sca.binding.feed.collection.NotFoundException;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.invocation.DataExchangeSemantics;
+import org.osoa.sca.ServiceRuntimeException;
+
+import com.sun.syndication.feed.atom.Entry;
+import com.sun.syndication.feed.atom.Feed;
+import com.sun.syndication.io.WireFeedInput;
+import com.sun.syndication.io.XmlReader;
+
+/**
+ * Invoker for the Atom binding.
+ *
+ * @version $Rev$ $Date$
+ */
+class AtomBindingInvoker implements Invoker, DataExchangeSemantics {
+
+ Operation operation;
+ String uri;
+ HttpClient httpClient;
+ String authorizationHeader;
+
+ //FIXME Support conversion to/from data api entries
+
+ AtomBindingInvoker(Operation operation, String uri, HttpClient httpClient, String authorizationHeader) {
+ this.operation = operation;
+ this.uri = uri;
+ this.httpClient = httpClient;
+ this.authorizationHeader = authorizationHeader;
+ }
+
+ public Message invoke(Message msg) {
+ // Shouldn't get here, as the only supported methods are
+ // defined in the ResourceCollection interface, and implemented
+ // by specific invoker subclasses
+ throw new UnsupportedOperationException(operation.getName());
+ }
+
+ public boolean allowsPassByReference() {
+ return true;
+ }
+
+ /**
+ * Get operation invoker
+ */
+ public static class GetInvoker extends AtomBindingInvoker {
+
+ public GetInvoker(Operation operation, String uri, HttpClient httpClient, String authorizationHeader) {
+ super(operation, uri, httpClient, authorizationHeader);
+ }
+
+ @Override
+ public Message invoke(Message msg) {
+
+ // Get an entry
+ String id = (String)((Object[])msg.getBody())[0];
+
+ // Send an HTTP GET
+ GetMethod getMethod = new GetMethod(uri + "/" + id);
+ getMethod.setRequestHeader("Authorization", authorizationHeader);
+ try {
+ httpClient.executeMethod(getMethod);
+ int status = getMethod.getStatusCode();
+
+ // Read the Atom entry
+ if (status == 200) {
+ Entry feedEntry =
+ AtomFeedEntryUtil.readFeedEntry("atom_1.0", new InputStreamReader(getMethod.getResponseBodyAsStream()));
+ msg.setBody(feedEntry);
+
+ } else if (status == 404) {
+ msg.setFaultBody(new NotFoundException());
+ } else {
+ msg.setFaultBody(new ServiceRuntimeException("HTTP status code: " + status));
+ }
+
+ } catch (Exception e) {
+ msg.setFaultBody(new ServiceRuntimeException(e));
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ return msg;
+ }
+ }
+
+ /**
+ * Post operation invoker
+ */
+ public static class PostInvoker extends AtomBindingInvoker {
+
+ public PostInvoker(Operation operation, String uri, HttpClient httpClient, String authorizationHeader) {
+ super(operation, uri, httpClient, authorizationHeader);
+ }
+
+ @Override
+ public Message invoke(Message msg) {
+
+ // Post an entry
+ Entry feedEntry = (Entry)((Object[])msg.getBody())[0];
+
+ // Send an HTTP POST
+ PostMethod postMethod = new PostMethod(uri);
+ postMethod.setRequestHeader("Authorization", authorizationHeader);
+ try {
+
+ // Write the Atom entry
+ StringWriter writer = new StringWriter();
+ AtomFeedEntryUtil.writeFeedEntry(feedEntry, "atom_1.0", writer);
+ postMethod.setRequestHeader("Content-type", "application/atom+xml; charset=utf-8");
+ postMethod.setRequestEntity(new StringRequestEntity(writer.toString()));
+
+ httpClient.executeMethod(postMethod);
+ int status = postMethod.getStatusCode();
+
+ // Read the Atom entry
+ if (status == 200 || status == 201) {
+ Entry createdEntry =
+ AtomFeedEntryUtil
+ .readFeedEntry("atom_1.0", new InputStreamReader(postMethod.getResponseBodyAsStream()));
+ msg.setBody(createdEntry);
+
+ } else if (status == 404) {
+ msg.setFaultBody(new NotFoundException());
+ } else {
+ msg.setFaultBody(new ServiceRuntimeException("HTTP status code: " + status));
+ }
+
+ } catch (Exception e) {
+ msg.setFaultBody(new ServiceRuntimeException(e));
+ } finally {
+ postMethod.releaseConnection();
+ }
+
+ return msg;
+ }
+ }
+
+ /**
+ * Put operation invoker
+ */
+ public static class PutInvoker extends AtomBindingInvoker {
+
+ public PutInvoker(Operation operation, String uri, HttpClient httpClient, String authorizationHeader) {
+ super(operation, uri, httpClient, authorizationHeader);
+ }
+
+ @Override
+ public Message invoke(Message msg) {
+
+ // Put an entry
+ Object[] args = (Object[])msg.getBody();
+ String id = (String)args[0];
+ Entry feedEntry = (Entry)args[1];
+
+ // Send an HTTP PUT
+ PutMethod putMethod = new PutMethod(uri + "/" + id);
+ putMethod.setRequestHeader("Authorization", authorizationHeader);
+ try {
+
+ // Write the Atom entry
+ StringWriter writer = new StringWriter();
+ AtomFeedEntryUtil.writeFeedEntry(feedEntry, "atom_1.0", writer);
+ putMethod.setRequestHeader("Content-type", "application/atom+xml; charset=utf-8");
+ putMethod.setRequestEntity(new StringRequestEntity(writer.toString()));
+
+ httpClient.executeMethod(putMethod);
+ int status = putMethod.getStatusCode();
+
+ // Read the Atom entry
+ if (status == 200 || status == 201) {
+ try {
+ Entry updatedEntry =
+ AtomFeedEntryUtil.readFeedEntry("atom_1.0", new InputStreamReader(putMethod
+ .getResponseBodyAsStream()));
+ msg.setBody(updatedEntry);
+ } catch (Exception e) {
+ // Returning the updated entry is optional
+ }
+
+ } else if (status == 404) {
+ msg.setFaultBody(new NotFoundException());
+ } else {
+ msg.setFaultBody(new ServiceRuntimeException("HTTP status code: " + status));
+ }
+
+ } catch (Exception e) {
+ msg.setFaultBody(new ServiceRuntimeException(e));
+ } finally {
+ putMethod.releaseConnection();
+ }
+
+ return msg;
+ }
+ }
+
+ /**
+ * Delete operation invoker
+ */
+ public static class DeleteInvoker extends AtomBindingInvoker {
+
+ public DeleteInvoker(Operation operation, String uri, HttpClient httpClient, String authorizationHeader) {
+ super(operation, uri, httpClient, authorizationHeader);
+ }
+
+ @Override
+ public Message invoke(Message msg) {
+
+ // Delete an entry
+ String id = (String)((Object[])msg.getBody())[0];
+
+ // Send an HTTP DELETE
+ DeleteMethod deleteMethod = new DeleteMethod(uri + "/" + id);
+ deleteMethod.setRequestHeader("Authorization", authorizationHeader);
+ try {
+ httpClient.executeMethod(deleteMethod);
+ int status = deleteMethod.getStatusCode();
+
+ // Read the Atom entry
+ if (status == 200) {
+ msg.setBody(null);
+
+ } else if (status == 404) {
+ msg.setFaultBody(new NotFoundException());
+ } else {
+ msg.setFaultBody(new ServiceRuntimeException("HTTP status code: " + status));
+ }
+
+ } catch (Exception e) {
+ msg.setFaultBody(new ServiceRuntimeException(e));
+ } finally {
+ deleteMethod.releaseConnection();
+ }
+
+ return msg;
+ }
+ }
+
+ /**
+ * GetAll operation invoker
+ */
+ public static class GetAllInvoker extends AtomBindingInvoker {
+
+ public GetAllInvoker(Operation operation, String uri, HttpClient httpClient, String authorizationHeader) {
+ super(operation, uri, httpClient, authorizationHeader);
+ }
+
+ @Override
+ public Message invoke(Message msg) {
+
+ // Get a feed
+
+ // Send an HTTP GET
+ GetMethod getMethod = new GetMethod(uri);
+ getMethod.setRequestHeader("Authorization", authorizationHeader);
+ try {
+ httpClient.executeMethod(getMethod);
+ int status = getMethod.getStatusCode();
+
+ // Read the Atom feed
+ if (status == 200) {
+ WireFeedInput input = new WireFeedInput();
+ Feed feed = (Feed)input.build(new XmlReader(getMethod.getResponseBodyAsStream()));
+ msg.setBody(feed);
+
+ } else if (status == 404) {
+ msg.setFaultBody(new NotFoundException());
+ } else {
+ msg.setFaultBody(new ServiceRuntimeException("HTTP status code: " + status));
+ }
+
+ } catch (Exception e) {
+ msg.setFaultBody(new ServiceRuntimeException(e));
+ } finally {
+ getMethod.releaseConnection();
+ }
+
+ return msg;
+ }
+ }
+
+ /**
+ * PostMedia operation invoker
+ */
+ public static class PostMediaInvoker extends AtomBindingInvoker {
+
+ public PostMediaInvoker(Operation operation, String uri, HttpClient httpClient, String authorizationHeader) {
+ super(operation, uri, httpClient, authorizationHeader);
+ }
+
+ @Override
+ public Message invoke(Message msg) {
+ // TODO implement
+ return super.invoke(msg);
+ }
+ }
+
+ /**
+ * PutMedia operation invoker
+ */
+ public static class PutMediaInvoker extends AtomBindingInvoker {
+
+ public PutMediaInvoker(Operation operation, String uri, HttpClient httpClient, String authorizationHeader) {
+ super(operation, uri, httpClient, authorizationHeader);
+ }
+
+ @Override
+ public Message invoke(Message msg) {
+ // TODO implement
+ return super.invoke(msg);
+ }
+ }
+
+}
diff --git a/java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/provider/AtomBindingProviderFactory.java b/java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/provider/AtomBindingProviderFactory.java
new file mode 100644
index 0000000000..9a858f899f
--- /dev/null
+++ b/java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/provider/AtomBindingProviderFactory.java
@@ -0,0 +1,74 @@
+/*
+ * 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.feed.provider;
+
+import org.apache.tuscany.sca.binding.feed.AtomBinding;
+import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.databinding.DataBindingExtensionPoint;
+import org.apache.tuscany.sca.databinding.Mediator;
+import org.apache.tuscany.sca.databinding.TransformerExtensionPoint;
+import org.apache.tuscany.sca.databinding.impl.MediatorImpl;
+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.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+
+/**
+ * Implementation of the Atom binding model.
+ *
+ * @version $Rev$ $Date$
+ */
+public class AtomBindingProviderFactory implements BindingProviderFactory<AtomBinding> {
+
+ private MessageFactory messageFactory;
+ private Mediator mediator;
+ private ServletHost servletHost;
+
+ public AtomBindingProviderFactory(ExtensionPointRegistry extensionPoints) {
+ ServletHostExtensionPoint servletHosts = extensionPoints.getExtensionPoint(ServletHostExtensionPoint.class);
+ this.servletHost = servletHosts.getServletHosts().get(0);
+ ModelFactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(ModelFactoryExtensionPoint.class);
+ this.messageFactory = modelFactories.getFactory(MessageFactory.class);
+ this.mediator = new MediatorImpl(extensionPoints.getExtensionPoint(DataBindingExtensionPoint.class),
+ extensionPoints.getExtensionPoint(TransformerExtensionPoint.class));
+ }
+
+ public ReferenceBindingProvider createReferenceBindingProvider(RuntimeComponent component,
+ RuntimeComponentReference reference,
+ AtomBinding binding) {
+ return new AtomReferenceBindingProvider(component, reference, binding);
+ }
+
+ public ServiceBindingProvider createServiceBindingProvider(RuntimeComponent component,
+ RuntimeComponentService service,
+ AtomBinding binding) {
+ return new AtomServiceBindingProvider(component, service, binding, servletHost, messageFactory, mediator);
+ }
+
+ public Class<AtomBinding> getModelType() {
+ return AtomBinding.class;
+ }
+}
diff --git a/java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/provider/AtomFeedEntryUtil.java b/java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/provider/AtomFeedEntryUtil.java
new file mode 100644
index 0000000000..7adbfca6e8
--- /dev/null
+++ b/java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/provider/AtomFeedEntryUtil.java
@@ -0,0 +1,117 @@
+/*
+ * 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.feed.provider;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jdom.Document;
+import org.jdom.Element;
+import org.jdom.JDOMException;
+import org.jdom.input.SAXBuilder;
+import org.jdom.output.Format;
+import org.jdom.output.XMLOutputter;
+
+import com.sun.syndication.feed.atom.Content;
+import com.sun.syndication.feed.atom.Entry;
+import com.sun.syndication.feed.atom.Feed;
+import com.sun.syndication.io.FeedException;
+import com.sun.syndication.io.WireFeedInput;
+import com.sun.syndication.io.WireFeedOutput;
+
+/**
+ * Utility methods to read/write Atom entries.
+ *
+ * @version $Rev$ $Date$
+ */
+class AtomFeedEntryUtil {
+
+ /**
+ * Read an Atom entry
+ *
+ * @param request
+ * @return
+ * @throws IOException
+ * @throws JDOMException
+ * @throws FeedException
+ * @throws IllegalArgumentException
+ */
+ static Entry readFeedEntry(String feedType, Reader reader) throws JDOMException, IOException, IllegalArgumentException,
+ FeedException {
+ SAXBuilder builder = new SAXBuilder();
+ Document document = builder.build(reader);
+ Element root = document.getRootElement();
+ root.detach();
+ Feed feed = new Feed();
+ feed.setFeedType(feedType);
+ WireFeedOutput wireFeedOutput = new WireFeedOutput();
+ document = wireFeedOutput.outputJDom(feed);
+ document.getRootElement().addContent(root);
+ WireFeedInput input = new WireFeedInput();
+ feed = (Feed)input.build(document);
+ Entry feedEntry = (Entry)feed.getEntries().get(0);
+ if (feedEntry.getContents().size() != 0) {
+ Content content = (Content)feedEntry.getContents().get(0);
+ if ("text/xml".equals(content.getType())) {
+ Element element = root.getChild("content", root.getNamespace());
+ if (!element.getChildren().isEmpty()) {
+ element = (Element)element.getChildren().get(0);
+ XMLOutputter outputter = new XMLOutputter();
+ StringWriter sw = new StringWriter();
+ outputter.output(element, sw);
+ content.setValue(sw.toString());
+ }
+ }
+ }
+ return feedEntry;
+ }
+
+ /**
+ * Write an Atom entry.
+ *
+ * @param entry
+ * @param response
+ * @throws FeedException
+ * @throws IllegalArgumentException
+ * @throws IOException
+ * @throws ServletException
+ */
+ static void writeFeedEntry(Entry feedEntry, String feedType, Writer writer) throws IllegalArgumentException, FeedException,
+ IOException {
+ Feed feed = new Feed();
+ feed.setFeedType(feedType);
+ List<Entry> feedEntries = new ArrayList<Entry>();
+ feedEntries.add(feedEntry);
+ feed.setEntries(feedEntries);
+
+ WireFeedOutput wireFeedOutput = new WireFeedOutput();
+ Document document = wireFeedOutput.outputJDom(feed);
+ Element root = document.getRootElement();
+ Element element = (Element)root.getChildren().get(0);
+ XMLOutputter outputter = new XMLOutputter();
+ outputter.setFormat(Format.getPrettyFormat());
+ outputter.output(element, writer);
+ }
+
+}
diff --git a/java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/provider/AtomReferenceBindingProvider.java b/java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/provider/AtomReferenceBindingProvider.java
new file mode 100644
index 0000000000..d9bda1fb9a
--- /dev/null
+++ b/java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/provider/AtomReferenceBindingProvider.java
@@ -0,0 +1,116 @@
+/*
+ * 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.feed.provider;
+
+import java.net.URI;
+
+import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.httpclient.Credentials;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
+import org.apache.commons.httpclient.UsernamePasswordCredentials;
+import org.apache.commons.httpclient.auth.AuthScope;
+import org.apache.tuscany.sca.binding.feed.AtomBinding;
+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.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+
+/**
+ * Implementation of the Atom binding provider.
+ *
+ * @version $Rev$ $Date$
+ */
+class AtomReferenceBindingProvider implements ReferenceBindingProvider {
+
+ private RuntimeComponentReference reference;
+ private AtomBinding binding;
+ private String authorizationHeader;
+ private HttpClient httpClient;
+
+ /**
+ * Constructs a new AtomReferenceBindingProvider
+ * @param component
+ * @param reference
+ * @param binding
+ */
+ AtomReferenceBindingProvider(RuntimeComponent component,
+ RuntimeComponentReference reference,
+ AtomBinding binding) {
+ this.reference = reference;
+ this.binding = binding;
+
+ // Prepare authorization header
+ String authorization = "admin" + ":" + "admin";
+ authorizationHeader = "Basic " + new String(Base64.encodeBase64(authorization.getBytes()));
+
+ // Create an HTTP client
+ httpClient = new HttpClient(new MultiThreadedHttpConnectionManager());
+ httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(60000);
+ }
+
+ public Invoker createInvoker(Operation operation) {
+ String operationName = operation.getName();
+ if (operationName.equals("get")) {
+ return new AtomBindingInvoker.GetInvoker(operation, binding.getURI(), httpClient, authorizationHeader);
+ } else if (operationName.equals("post")) {
+ return new AtomBindingInvoker.PostInvoker(operation, binding.getURI(), httpClient, authorizationHeader);
+ } else if (operationName.equals("put")) {
+ return new AtomBindingInvoker.PutInvoker(operation, binding.getURI(), httpClient, authorizationHeader);
+ } else if (operationName.equals("delete")) {
+ return new AtomBindingInvoker.DeleteInvoker(operation, binding.getURI(), httpClient,
+ authorizationHeader);
+ } else if (operationName.equals("getFeed") || operationName.equals("getAll")) {
+ return new AtomBindingInvoker.GetAllInvoker(operation, binding.getURI(), httpClient,
+ authorizationHeader);
+ } else if (operationName.equals("postMedia")) {
+ return new AtomBindingInvoker.PostMediaInvoker(operation, binding.getURI(), httpClient,
+ authorizationHeader);
+ } else if (operationName.equals("putMedia")) {
+ return new AtomBindingInvoker.PutMediaInvoker(operation, binding.getURI(), httpClient,
+ authorizationHeader);
+ }
+
+ return new AtomBindingInvoker(operation, binding.getURI(), httpClient, authorizationHeader);
+ }
+
+ public InterfaceContract getBindingInterfaceContract() {
+ return reference.getInterfaceContract();
+ }
+
+ public void start() {
+
+ // Configure the HTTP client credentials
+ Credentials credentials = new UsernamePasswordCredentials("admin", "admin");
+ httpClient.getParams().setAuthenticationPreemptive(true);
+ URI uri = URI.create(binding.getURI());
+ httpClient.getState().setCredentials(new AuthScope(uri.getHost(), uri.getPort()), credentials);
+ }
+
+ public void stop() {
+ }
+
+ public boolean supportsOneWayInvocation() {
+ return false;
+ }
+
+}
diff --git a/java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/provider/AtomServiceBindingProvider.java b/java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/provider/AtomServiceBindingProvider.java
new file mode 100644
index 0000000000..23c36f51e3
--- /dev/null
+++ b/java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/provider/AtomServiceBindingProvider.java
@@ -0,0 +1,87 @@
+/*
+ * 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.feed.provider;
+
+import org.apache.tuscany.sca.binding.feed.AtomBinding;
+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.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+import org.apache.tuscany.sca.runtime.RuntimeWire;
+
+/**
+ * Implementation of the Atom binding provider.
+ *
+ * @version $Rev$ $Date$
+ */
+class AtomServiceBindingProvider implements ServiceBindingProvider {
+
+ private RuntimeComponentService service;
+ private AtomBinding binding;
+ private ServletHost servletHost;
+ private MessageFactory messageFactory;
+ private String servletMapping;
+ private Mediator mediator;
+
+ AtomServiceBindingProvider(RuntimeComponent component,
+ RuntimeComponentService service,
+ AtomBinding binding,
+ ServletHost servletHost,
+ MessageFactory messageFactory,
+ Mediator mediator) {
+ this.service = service;
+ this.binding = binding;
+ this.servletHost = servletHost;
+ this.messageFactory = messageFactory;
+ this.mediator = mediator;
+ }
+
+ public InterfaceContract getBindingInterfaceContract() {
+ return service.getInterfaceContract();
+ }
+
+ public boolean supportsOneWayInvocation() {
+ return false;
+ }
+
+ public void start() {
+ RuntimeComponentService componentService = (RuntimeComponentService)service;
+ RuntimeWire wire = componentService.getRuntimeWire(binding);
+
+ FeedBindingListenerServlet servlet =
+ new FeedBindingListenerServlet(wire, messageFactory, mediator, "atom_1.0");
+
+ servletMapping = binding.getURI();
+ if (!servletMapping.endsWith("/")) {
+ servletMapping += "/";
+ }
+ if (!servletMapping.endsWith("*")) {
+ servletMapping += "*";
+ }
+ servletHost.addServletMapping(servletMapping, servlet);
+ }
+
+ public void stop() {
+ servletHost.removeServletMapping(servletMapping);
+ }
+}
diff --git a/java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/provider/FeedBindingListenerServlet.java b/java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/provider/FeedBindingListenerServlet.java
new file mode 100644
index 0000000000..89366456f5
--- /dev/null
+++ b/java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/provider/FeedBindingListenerServlet.java
@@ -0,0 +1,788 @@
+/*
+ * 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.feed.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.RuntimeWire;
+import org.jdom.Document;
+import org.jdom.Element;
+import org.jdom.JDOMException;
+import org.jdom.Namespace;
+import org.jdom.output.Format;
+import org.jdom.output.XMLOutputter;
+
+import com.sun.syndication.feed.atom.Content;
+import com.sun.syndication.feed.atom.Entry;
+import com.sun.syndication.feed.atom.Feed;
+import com.sun.syndication.feed.atom.Link;
+import com.sun.syndication.feed.synd.SyndFeed;
+import com.sun.syndication.feed.synd.SyndFeedImpl;
+import com.sun.syndication.io.FeedException;
+import com.sun.syndication.io.SyndFeedOutput;
+import com.sun.syndication.io.WireFeedOutput;
+
+/**
+ * A resource collection binding listener, implemented as a Servlet and
+ * registered in a Servlet host provided by the SCA hosting runtime.
+ *
+ * @version $Rev$ $Date$
+ */
+class FeedBindingListenerServlet extends HttpServlet {
+ private static final Logger logger = Logger.getLogger(FeedBindingListenerServlet.class.getName());
+ private static final long serialVersionUID = 1L;
+
+ private static final Namespace APP_NS = Namespace.getNamespace("app", "http://purl.org/atom/app#");
+ private static final Namespace ATOM_NS = Namespace.getNamespace("atom", "http://www.w3.org/2005/Atom");
+
+ private RuntimeWire wire;
+ private Invoker getFeedInvoker;
+ private Invoker getAllInvoker;
+ private Invoker queryInvoker;
+ private Invoker getInvoker;
+ private Invoker postInvoker;
+ private Invoker postMediaInvoker;
+ private Invoker putInvoker;
+ private Invoker putMediaInvoker;
+ private Invoker deleteInvoker;
+ private MessageFactory messageFactory;
+ private String feedType;
+ private Mediator mediator;
+ private DataType<?> itemClassType;
+ private DataType<?> itemXMLType;
+ private boolean supportsFeedEntries;
+
+ /**
+ * Constructs a new binding listener.
+ *
+ * @param wire
+ * @param messageFactory
+ * @param feedType
+ */
+ FeedBindingListenerServlet(RuntimeWire wire, MessageFactory messageFactory, Mediator mediator, String feedType) {
+ this.wire = wire;
+ this.messageFactory = messageFactory;
+ this.mediator = mediator;
+ this.feedType = feedType;
+
+ // 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")) {
+ getInvoker = invocationChain.getHeadInvoker();
+ getOperation = operation;
+ } else if (operationName.equals("put")) {
+ putInvoker = invocationChain.getHeadInvoker();
+ } else if (operationName.equals("putMedia")) {
+ putMediaInvoker = invocationChain.getHeadInvoker();
+ } else if (operationName.equals("post")) {
+ postInvoker = invocationChain.getHeadInvoker();
+ } else if (operationName.equals("postMedia")) {
+ postMediaInvoker = invocationChain.getHeadInvoker();
+ } else if (operationName.equals("delete")) {
+ deleteInvoker = invocationChain.getHeadInvoker();
+ }
+ }
+
+ // Determine the collection item type
+ itemXMLType = new DataTypeImpl<Class<?>>(String.class.getName(), String.class, String.class);
+ Class<?> itemClass = getOperation.getOutputType().getPhysical();
+ if (itemClass == Entry.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");
+
+ // The feedType parameter is used to override what type of feed is going
+ // to be produced
+ String requestFeedType = request.getParameter("feedType");
+ if (requestFeedType == null)
+ requestFeedType = feedType;
+
+ logger.info(">>> FeedEndPointServlet (" + requestFeedType + ") " + request.getRequestURI());
+
+ // Handle an Atom request
+ if (requestFeedType.startsWith("atom_")) {
+
+ if (path != null && path.equals("/atomsvc")) {
+
+ // Return the Atom service document
+ response.setContentType("application/atomsvc+xml; charset=utf-8");
+ Document document = new Document();
+ Element service = new Element("service", APP_NS);
+ document.setRootElement(service);
+
+ Element workspace = new Element("workspace", APP_NS);
+ Element title = new Element("title", ATOM_NS);
+ title.setText("resource");
+ workspace.addContent(title);
+ service.addContent(workspace);
+
+ Element collection = new Element("collection", APP_NS);
+ String href = request.getRequestURL().toString();
+ href = href.substring(0, href.length() - "/atomsvc".length());
+ collection.setAttribute("href", href);
+ Element collectionTitle = new Element("title", ATOM_NS);
+ collectionTitle.setText("entries");
+ collection.addContent(collectionTitle);
+ workspace.addContent(collection);
+
+ XMLOutputter outputter = new XMLOutputter();
+ Format format = Format.getPrettyFormat();
+ format.setEncoding("UTF-8");
+ outputter.setFormat(format);
+ outputter.output(document, getWriter(response));
+
+ } else if (path == null || path.length() == 0 || path.equals("/")) {
+
+ // Return a feed containing the entries in the collection
+ Feed 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 = (Feed)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 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 Feed();
+ feed.setTitle("Feed");
+ for (org.apache.tuscany.sca.data.collection.Entry<Object, Object> entry: collection) {
+ Entry feedEntry = createFeedEntry(entry);
+ feed.getEntries().add(feedEntry);
+ }
+ }
+ }
+ if (feed != null) {
+
+ // Write the Atom feed
+ response.setContentType("application/atom+xml; charset=utf-8");
+ feed.setFeedType(requestFeedType);
+ WireFeedOutput feedOutput = new WireFeedOutput();
+ try {
+ feedOutput.output(feed, getWriter(response));
+ } catch (FeedException e) {
+ throw new ServletException(e);
+ }
+ } else {
+ response.sendError(HttpServletResponse.SC_NOT_FOUND);
+ }
+
+ } else if (path.startsWith("/")) {
+
+ // Return a specific entry in the collection
+ Entry feedEntry;
+
+ // Invoke the get operation on the service implementation
+ Message requestMessage = messageFactory.createMessage();
+ String id = path.substring(1);
+ requestMessage.setBody(new Object[] {id});
+ Message responseMessage = getInvoker.invoke(requestMessage);
+ if (responseMessage.isFault()) {
+ throw new ServletException((Throwable)responseMessage.getBody());
+ }
+ if (supportsFeedEntries) {
+
+ // The service implementation returns a feed entry
+ feedEntry = responseMessage.getBody();
+
+ } else {
+
+ // The service implementation only returns a data item, create an entry
+ // from it
+ feedEntry = createFeedEntry(new org.apache.tuscany.sca.data.collection.Entry<Object, Object>(id, responseMessage.getBody()));
+ }
+
+ // Write the Atom entry
+ if (feedEntry != null) {
+ response.setContentType("application/atom+xml; charset=utf-8");
+ try {
+ AtomFeedEntryUtil.writeFeedEntry(feedEntry, feedType, getWriter(response));
+ } catch (FeedException e) {
+ throw new ServletException(e);
+ }
+ } else {
+ response.sendError(HttpServletResponse.SC_NOT_FOUND);
+ }
+
+ } else {
+
+ // Path doesn't match any known pattern
+ response.sendError(HttpServletResponse.SC_NOT_FOUND);
+ }
+ } else {
+
+ // Handle an RSS request
+ if (path == null || path.length() == 0 || path.equals("/")) {
+
+ // Return an RSS feed containing the entries in the collection
+ Feed 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 = (Feed)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 Feed();
+ feed.setTitle("Feed");
+ for (org.apache.tuscany.sca.data.collection.Entry<Object, Object> entry: collection) {
+ Entry 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("atom_1.0");
+ SyndFeed syndFeed = new SyndFeedImpl(feed);
+ syndFeed.setFeedType(requestFeedType);
+ syndFeed.setLink(path);
+ SyndFeedOutput syndOutput = new SyndFeedOutput();
+ try {
+ syndOutput.output(syndFeed, 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 Atom entry from a data collection entry.
+ * @param entry
+ * @return
+ */
+ private Entry 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;
+
+ Entry feedEntry = new Entry();
+ feedEntry.setId(key.toString());
+ feedEntry.setTitle(item.getTitle());
+
+ String value = item.getContents();
+ if (value != null) {
+ Content content = new Content();
+ content.setType("text/xml");
+ content.setValue(value);
+ List<Content> contents = new ArrayList<Content>();
+ contents.add(content);
+ feedEntry.setContents(contents);
+ }
+
+ String href = item.getLink();
+ if (href == null) {
+ href = key.toString();
+ }
+ Link link = new Link();
+ link.setRel("edit");
+ link.setHref(href);
+ feedEntry.getOtherLinks().add(link);
+ link = new Link();
+ link.setRel("alternate");
+ link.setHref(href);
+ feedEntry.getAlternateLinks().add(link);
+
+ Date date = item.getDate();
+ if (date == null) {
+ date = new Date();
+ }
+ feedEntry.setCreated(date);
+ return feedEntry;
+
+ } else if (data != null) {
+ Entry feedEntry = new Entry();
+ feedEntry.setId(key.toString());
+ feedEntry.setTitle("item");
+
+ // Convert the item to XML
+ String value = mediator.mediate(data, itemClassType, itemXMLType, null).toString();
+
+ Content content = new Content();
+ content.setType("text/xml");
+ content.setValue(value);
+ List<Content> contents = new ArrayList<Content>();
+ contents.add(content);
+ feedEntry.setContents(contents);
+
+ Link link = new Link();
+ link.setRel("edit");
+ link.setHref(key.toString());
+ feedEntry.getOtherLinks().add(link);
+ link = new Link();
+ link.setRel("alternate");
+ link.setHref(key.toString());
+ feedEntry.getAlternateLinks().add(link);
+
+ feedEntry.setCreated(new Date());
+ return feedEntry;
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Create a data collection entry from an Atom entry.
+ * @param feedEntry
+ * @return
+ */
+ private org.apache.tuscany.sca.data.collection.Entry<Object, Object> createEntry(Entry feedEntry) {
+ if (feedEntry != null) {
+ if (itemClassType.getPhysical() == Item.class) {
+ String key = feedEntry.getId();
+
+ Item item = new Item();
+ item.setTitle(feedEntry.getTitle());
+
+ List<?> contents = feedEntry.getContents();
+ if (!contents.isEmpty()) {
+ Content content = (Content)contents.get(0);
+ String value = content.getValue();
+ item.setContents(value);
+ }
+
+ for (Object l : feedEntry.getOtherLinks()) {
+ Link link = (Link)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.getCreated());
+
+ return new org.apache.tuscany.sca.data.collection.Entry<Object, Object>(key, item);
+
+ } else {
+ String key = feedEntry.getId();
+
+ // Create the item from XML
+ List<?> contents = feedEntry.getContents();
+ if (contents.isEmpty()) {
+ return null;
+ }
+ Content content = (Content)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;
+ }
+ }
+
+ @Override
+ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException,
+ IOException {
+
+ // Authenticate the user
+ String user = processAuthorizationHeader(request);
+ if (user == null) {
+ unauthorized(response);
+ return;
+ }
+
+ // Get the request path
+ String path = URLDecoder.decode(request.getRequestURI().substring(request.getServletPath().length()), "UTF-8");
+
+ if (path == null || path.length() == 0 || path.equals("/")) {
+ Entry createdFeedEntry = null;
+
+ // Create a new Atom entry
+ String contentType = request.getContentType();
+ if (contentType != null && contentType.startsWith("application/atom+xml")) {
+
+ // Read the entry from the request
+ Entry feedEntry;
+ try {
+ feedEntry = AtomFeedEntryUtil.readFeedEntry(feedType, request.getReader());
+ } catch (JDOMException e) {
+ throw new ServletException(e);
+ } catch (FeedException e) {
+ throw new ServletException(e);
+ }
+
+ // Let the component implementation create it
+ if (supportsFeedEntries) {
+
+ // The service implementation supports feed entries, pass the entry to it
+ Message requestMessage = messageFactory.createMessage();
+ requestMessage.setBody(new Object[] {feedEntry});
+ Message responseMessage = postInvoker.invoke(requestMessage);
+ if (responseMessage.isFault()) {
+ throw new ServletException((Throwable)responseMessage.getBody());
+ }
+ createdFeedEntry = responseMessage.getBody();
+ } else {
+
+ // The service implementation does not support feed entries, pass the data item to it
+ Message requestMessage = messageFactory.createMessage();
+ org.apache.tuscany.sca.data.collection.Entry<Object, Object> entry = createEntry(feedEntry);
+ requestMessage.setBody(new Object[] {entry.getKey(), entry.getData()});
+ Message responseMessage = postInvoker.invoke(requestMessage);
+ if (responseMessage.isFault()) {
+ throw new ServletException((Throwable)responseMessage.getBody());
+ }
+ entry.setKey(responseMessage.getBody());
+ createdFeedEntry = createFeedEntry(entry);
+ }
+
+ } else if (contentType != null) {
+
+ // Create a new media entry
+
+ // Get incoming headers
+ String title = request.getHeader("Title");
+ String slug = request.getHeader("Slug");
+
+ // Let the component implementation create the media entry
+ Message requestMessage = messageFactory.createMessage();
+ requestMessage.setBody(new Object[] {title, slug, contentType, request.getInputStream()});
+ Message responseMessage = postMediaInvoker.invoke(requestMessage);
+ if (responseMessage.isFault()) {
+ throw new ServletException((Throwable)responseMessage.getBody());
+ }
+ createdFeedEntry = responseMessage.getBody();
+ } else {
+ response.sendError(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE);
+ }
+
+ // A new entry was created successfully
+ if (createdFeedEntry != null) {
+
+ // Set location of the created entry in the Location header
+ for (Object l : createdFeedEntry.getOtherLinks()) {
+ Link link = (Link)l;
+ if (link.getRel() == null || "edit".equals(link.getRel())) {
+ response.addHeader("Location", link.getHref());
+ break;
+ }
+ }
+
+ // Write the created Atom entry
+ response.setStatus(HttpServletResponse.SC_CREATED);
+ response.setContentType("application/atom+xml; charset=utf-8");
+ try {
+ AtomFeedEntryUtil.writeFeedEntry(createdFeedEntry, feedType, getWriter(response));
+ } catch (FeedException e) {
+ throw new ServletException(e);
+ }
+
+ } else {
+ response.sendError(HttpServletResponse.SC_NOT_FOUND);
+ }
+
+ } else {
+ response.sendError(HttpServletResponse.SC_NOT_FOUND);
+ }
+ }
+
+ private Writer getWriter(HttpServletResponse response) throws UnsupportedEncodingException, IOException {
+ Writer writer = new OutputStreamWriter(response.getOutputStream(), "UTF-8");
+ return writer;
+ }
+
+ @Override
+ protected void doPut(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+
+ // Authenticate the user
+ String user = processAuthorizationHeader(request);
+ if (user == null) {
+ unauthorized(response);
+ return;
+ }
+
+ // Get the request path
+ String path = URLDecoder.decode(request.getRequestURI().substring(request.getServletPath().length()), "UTF-8");
+
+ if (path != null && path.startsWith("/")) {
+ String id = path.substring(1);
+
+ // Update an Atom entry
+ String contentType = request.getContentType();
+ if (contentType != null && contentType.startsWith("application/atom+xml")) {
+
+ // Read the entry from the request
+ Entry feedEntry;
+ try {
+ feedEntry = AtomFeedEntryUtil.readFeedEntry(feedType, request.getReader());
+ } catch (JDOMException e) {
+ throw new ServletException(e);
+ } catch (FeedException e) {
+ throw new ServletException(e);
+ }
+
+ // Let the component implementation create it
+ if (supportsFeedEntries) {
+
+ // The service implementation supports feed entries, pass the entry to it
+ Message requestMessage = messageFactory.createMessage();
+ requestMessage.setBody(new Object[] {id, feedEntry});
+ Message responseMessage = putInvoker.invoke(requestMessage);
+ if (responseMessage.isFault()) {
+ Object body = responseMessage.getBody();
+ if (body.getClass().getName().endsWith(".NotFoundException")) {
+ response.sendError(HttpServletResponse.SC_NOT_FOUND);
+ } else {
+ throw new ServletException((Throwable)responseMessage.getBody());
+ }
+ }
+ } else {
+
+ // The service implementation does not support feed entries, pass the data item to it
+ Message requestMessage = messageFactory.createMessage();
+ org.apache.tuscany.sca.data.collection.Entry<Object, Object> entry = createEntry(feedEntry);
+ requestMessage.setBody(new Object[] {entry.getKey(), entry.getData()});
+ Message responseMessage = putInvoker.invoke(requestMessage);
+ if (responseMessage.isFault()) {
+ Object body = responseMessage.getBody();
+ if (body.getClass().getName().endsWith(".NotFoundException")) {
+ response.sendError(HttpServletResponse.SC_NOT_FOUND);
+ } else {
+ throw new ServletException((Throwable)responseMessage.getBody());
+ }
+ }
+ }
+
+ } else if (contentType != null) {
+
+ // Updated a media entry
+
+ // Let the component implementation create the media entry
+ Message requestMessage = messageFactory.createMessage();
+ requestMessage.setBody(new Object[] {id, contentType, request.getInputStream()});
+ Message responseMessage = putMediaInvoker.invoke(requestMessage);
+ Object body = responseMessage.getBody();
+ if (responseMessage.isFault()) {
+ if (body.getClass().getName().endsWith(".NotFoundException")) {
+ response.sendError(HttpServletResponse.SC_NOT_FOUND);
+ } else {
+ throw new ServletException((Throwable)responseMessage.getBody());
+ }
+ }
+ } else {
+ response.sendError(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE);
+ }
+ } else {
+ response.sendError(HttpServletResponse.SC_NOT_FOUND);
+ }
+ }
+
+ @Override
+ protected void doDelete(HttpServletRequest request, HttpServletResponse response) throws ServletException,
+ IOException {
+
+ // Authenticate the user
+ String user = processAuthorizationHeader(request);
+ if (user == null) {
+ unauthorized(response);
+ return;
+ }
+
+ // Get the request path
+ String path = URLDecoder.decode(request.getRequestURI().substring(request.getServletPath().length()), "UTF-8");
+
+ String id;
+ if (path != null && path.startsWith("/")) {
+ id = path.substring(1);
+ } else {
+ id = "";
+ }
+
+ // Delete a specific entry from the collection
+ Message requestMessage = messageFactory.createMessage();
+ requestMessage.setBody(new Object[] {id});
+ Message responseMessage = deleteInvoker.invoke(requestMessage);
+ if (responseMessage.isFault()) {
+ Object body = responseMessage.getBody();
+ if (body.getClass().getName().endsWith(".NotFoundException")) {
+ response.sendError(HttpServletResponse.SC_NOT_FOUND);
+ } else {
+ throw new ServletException((Throwable)responseMessage.getBody());
+ }
+ }
+ }
+
+ /**
+ * 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/java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/provider/RSSBindingInvoker.java b/java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/provider/RSSBindingInvoker.java
new file mode 100644
index 0000000000..c5bd3ec009
--- /dev/null
+++ b/java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/provider/RSSBindingInvoker.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.feed.provider;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.logging.Logger;
+
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.invocation.DataExchangeSemantics;
+
+import com.sun.syndication.feed.atom.Feed;
+import com.sun.syndication.feed.synd.SyndFeed;
+import com.sun.syndication.io.FeedException;
+import com.sun.syndication.io.SyndFeedInput;
+import com.sun.syndication.io.WireFeedInput;
+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 feedType;
+ private String uri;
+
+ RSSBindingInvoker(String uri, String feedType) {
+ this.uri = uri;
+ this.feedType = feedType;
+ }
+
+ public Message invoke(Message msg) {
+ try {
+ logger.info(">>> RSSBindingInvoker (" + feedType + ") " + uri);
+
+ // Read the configured feed URI into a Feed object
+ Feed feed;
+ if (feedType.startsWith("atom_")) {
+
+ // Read an Atom feed
+ WireFeedInput input = new WireFeedInput();
+ feed = (Feed)input.build(new XmlReader(new URL(uri)));
+ } else {
+
+ // Read an RSS feed and convert it to an Atom feed
+ SyndFeedInput input = new SyndFeedInput();
+ SyndFeed syndFeed = input.build(new XmlReader(new URL(uri)));
+ feed = (Feed)syndFeed.createWireFeed("atom_1.0");
+ }
+
+ //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/java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/provider/RSSBindingProviderFactory.java b/java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/provider/RSSBindingProviderFactory.java
new file mode 100644
index 0000000000..f4c336e12b
--- /dev/null
+++ b/java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/provider/RSSBindingProviderFactory.java
@@ -0,0 +1,74 @@
+/*
+ * 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.feed.provider;
+
+import org.apache.tuscany.sca.binding.feed.RSSBinding;
+import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.databinding.DataBindingExtensionPoint;
+import org.apache.tuscany.sca.databinding.Mediator;
+import org.apache.tuscany.sca.databinding.TransformerExtensionPoint;
+import org.apache.tuscany.sca.databinding.impl.MediatorImpl;
+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.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+
+/**
+ * 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);
+ ModelFactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(ModelFactoryExtensionPoint.class);
+ this.messageFactory = modelFactories.getFactory(MessageFactory.class);
+ this.mediator = new MediatorImpl(extensionPoints.getExtensionPoint(DataBindingExtensionPoint.class),
+ extensionPoints.getExtensionPoint(TransformerExtensionPoint.class));
+ }
+
+ public ReferenceBindingProvider createReferenceBindingProvider(RuntimeComponent component,
+ RuntimeComponentReference reference,
+ RSSBinding binding) {
+ return new RSSReferenceBindingProvider(component, reference, binding);
+ }
+
+ public ServiceBindingProvider createServiceBindingProvider(RuntimeComponent component,
+ RuntimeComponentService service,
+ RSSBinding binding) {
+ return new RSSServiceBindingProvider(component, service, binding, servletHost, messageFactory, mediator);
+ }
+
+ public Class<RSSBinding> getModelType() {
+ return RSSBinding.class;
+ }
+}
diff --git a/java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/provider/RSSReferenceBindingProvider.java b/java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/provider/RSSReferenceBindingProvider.java
new file mode 100644
index 0000000000..278ed9cb7e
--- /dev/null
+++ b/java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/provider/RSSReferenceBindingProvider.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.binding.feed.provider;
+
+import org.apache.tuscany.sca.binding.feed.RSSBinding;
+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.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+
+/**
+ * Implementation of the RSS binding provider.
+ *
+ * @version $Rev$ $Date$
+ */
+class RSSReferenceBindingProvider implements ReferenceBindingProvider {
+
+ private RuntimeComponentReference reference;
+ private RSSBinding binding;
+
+ RSSReferenceBindingProvider(RuntimeComponent component,
+ RuntimeComponentReference reference,
+ RSSBinding binding) {
+ this.reference = reference;
+ this.binding = binding;
+ }
+
+ 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/java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/provider/RSSServiceBindingProvider.java b/java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/provider/RSSServiceBindingProvider.java
new file mode 100644
index 0000000000..779b28cef6
--- /dev/null
+++ b/java/sca/modules/binding-feed/src/main/java/org/apache/tuscany/sca/binding/feed/provider/RSSServiceBindingProvider.java
@@ -0,0 +1,85 @@
+/*
+ * 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.feed.provider;
+
+import org.apache.tuscany.sca.binding.feed.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.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+import org.apache.tuscany.sca.runtime.RuntimeWire;
+
+/**
+ * Implementation of the RSS binding provider.
+ *
+ * @version $Rev$ $Date$
+ */
+class RSSServiceBindingProvider implements ServiceBindingProvider {
+
+ private RuntimeComponentService service;
+ private RSSBinding binding;
+ private ServletHost servletHost;
+ private MessageFactory messageFactory;
+ private String servletMapping;
+ private Mediator mediator;
+
+ RSSServiceBindingProvider(RuntimeComponent component,
+ RuntimeComponentService service,
+ RSSBinding binding,
+ ServletHost servletHost,
+ MessageFactory messageFactory,
+ Mediator mediator) {
+ this.service = service;
+ this.binding = binding;
+ this.servletHost = servletHost;
+ this.messageFactory = messageFactory;
+ this.mediator = mediator;
+ }
+
+ public InterfaceContract getBindingInterfaceContract() {
+ return service.getInterfaceContract();
+ }
+
+ public boolean supportsOneWayInvocation() {
+ return false;
+ }
+
+ public void start() {
+ RuntimeComponentService componentService = (RuntimeComponentService)service;
+ RuntimeWire wire = componentService.getRuntimeWire(binding);
+
+ FeedBindingListenerServlet servlet =
+ new FeedBindingListenerServlet(wire, messageFactory, mediator, "rss_2.0");
+
+ servletMapping = binding.getURI();
+ 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/java/sca/modules/binding-feed/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.feed.AtomBindingFactory b/java/sca/modules/binding-feed/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.feed.AtomBindingFactory
new file mode 100644
index 0000000000..49478e3db0
--- /dev/null
+++ b/java/sca/modules/binding-feed/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.feed.AtomBindingFactory
@@ -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.feed.impl.AtomBindingFactoryImpl \ No newline at end of file
diff --git a/java/sca/modules/binding-feed/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.feed.RSSBindingFactory b/java/sca/modules/binding-feed/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.feed.RSSBindingFactory
new file mode 100644
index 0000000000..f69b024da9
--- /dev/null
+++ b/java/sca/modules/binding-feed/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.feed.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.feed.impl.RSSBindingFactoryImpl \ No newline at end of file
diff --git a/java/sca/modules/binding-feed/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/java/sca/modules/binding-feed/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
new file mode 100644
index 0000000000..3f073b28b9
--- /dev/null
+++ b/java/sca/modules/binding-feed/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
@@ -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 class for the artifact processor extension
+org.apache.tuscany.sca.assembly.xml.DefaultBeanModelProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.0#binding.atom,model=org.apache.tuscany.sca.binding.feed.AtomBinding,factory=org.apache.tuscany.sca.binding.feed.AtomBindingFactory
+org.apache.tuscany.sca.assembly.xml.DefaultBeanModelProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.0#binding.rss,model=org.apache.tuscany.sca.binding.feed.RSSBinding,factory=org.apache.tuscany.sca.binding.feed.RSSBindingFactory
diff --git a/java/sca/modules/binding-feed/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory b/java/sca/modules/binding-feed/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory
new file mode 100644
index 0000000000..f81a0d33ae
--- /dev/null
+++ b/java/sca/modules/binding-feed/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory
@@ -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 class for the binding extension
+org.apache.tuscany.sca.binding.feed.provider.AtomBindingProviderFactory;model=org.apache.tuscany.sca.binding.feed.AtomBinding
+org.apache.tuscany.sca.binding.feed.provider.RSSBindingProviderFactory;model=org.apache.tuscany.sca.binding.feed.RSSBinding
diff --git a/java/sca/modules/binding-feed/src/test/java/org/apache/tuscany/sca/binding/feed/Consumer.java b/java/sca/modules/binding-feed/src/test/java/org/apache/tuscany/sca/binding/feed/Consumer.java
new file mode 100644
index 0000000000..4a33637121
--- /dev/null
+++ b/java/sca/modules/binding-feed/src/test/java/org/apache/tuscany/sca/binding/feed/Consumer.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.feed;
+
+import org.apache.tuscany.sca.host.embedded.SCADomain;
+
+public class Consumer {
+
+ public static void main(String[] args) throws Exception {
+
+ SCADomain scaDomain = SCADomain.newInstance("org/apache/tuscany/sca/binding/feed/Consumer.composite");
+
+ CustomerClient testService = scaDomain.getService(CustomerClient.class, "CustomerClient");
+ testService.testCustomerCollection();
+
+ scaDomain.close();
+ }
+}
diff --git a/java/sca/modules/binding-feed/src/test/java/org/apache/tuscany/sca/binding/feed/CustomerClient.java b/java/sca/modules/binding-feed/src/test/java/org/apache/tuscany/sca/binding/feed/CustomerClient.java
new file mode 100644
index 0000000000..b7416011ba
--- /dev/null
+++ b/java/sca/modules/binding-feed/src/test/java/org/apache/tuscany/sca/binding/feed/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.feed;
+
+public interface CustomerClient {
+
+ void testCustomerCollection() throws Exception;
+}
diff --git a/java/sca/modules/binding-feed/src/test/java/org/apache/tuscany/sca/binding/feed/CustomerClientImpl.java b/java/sca/modules/binding-feed/src/test/java/org/apache/tuscany/sca/binding/feed/CustomerClientImpl.java
new file mode 100644
index 0000000000..884e954036
--- /dev/null
+++ b/java/sca/modules/binding-feed/src/test/java/org/apache/tuscany/sca/binding/feed/CustomerClientImpl.java
@@ -0,0 +1,97 @@
+/*
+ * 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.feed;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.binding.feed.collection.Collection;
+import org.osoa.sca.annotations.Reference;
+
+import com.sun.syndication.feed.atom.Content;
+import com.sun.syndication.feed.atom.Entry;
+import com.sun.syndication.feed.atom.Feed;
+
+public class CustomerClientImpl implements CustomerClient {
+
+ @Reference
+ public Collection resourceCollection;
+
+ public void testCustomerCollection() throws Exception {
+
+ Entry newEntry = newEntry("Sponge Bob");
+ System.out.println(">>> post entry=" + newEntry.getTitle());
+ newEntry = resourceCollection.post(newEntry);
+ System.out.println("<<< post id=" + newEntry.getId() + " entry=" + newEntry.getTitle());
+
+ newEntry = newEntry("Jane Bond");
+ System.out.println(">>> post entry=" + newEntry.getTitle());
+ newEntry = resourceCollection.post(newEntry);
+ System.out.println("<<< post id=" + newEntry.getId() + " entry=" + newEntry.getTitle());
+
+ System.out.println(">>> get id=" + newEntry.getId());
+ Entry entry = resourceCollection.get(newEntry.getId());
+ System.out.println("<<< get id=" + entry.getId() + " entry=" + entry.getTitle());
+
+ System.out.println(">>> put id=" + newEntry.getId() + " entry=" + entry.getTitle());
+ resourceCollection.put(entry.getId(), updateEntry(entry, "James Bond"));
+ System.out.println("<<< put id=" + entry.getId() + " entry=" + entry.getTitle());
+
+ System.out.println(">>> delete id=" + entry.getId());
+ resourceCollection.delete(entry.getId());
+ System.out.println("<<< delete id=" + entry.getId());
+
+ System.out.println(">>> get collection");
+ Feed feed = resourceCollection.getFeed();
+ System.out.println("<<< get collection");
+ for (Object o : feed.getEntries()) {
+ Entry e = (Entry)o;
+ System.out.println("id = " + e.getId() + " entry = " + e.getTitle());
+ }
+ }
+
+ private Entry newEntry(String value) {
+
+ Entry entry = new Entry();
+ entry.setTitle("customer " + value);
+
+ Content content = new Content();
+ content.setValue(value);
+ content.setType(Content.TEXT);
+ List<Object> list = new ArrayList<Object>();
+ list.add(content);
+ entry.setContents(list);
+
+ return entry;
+ }
+
+ private Entry updateEntry(Entry entry, String value) {
+
+ entry.setTitle("customer " + value);
+ Content content = new Content();
+ content.setValue(value);
+ content.setType(Content.TEXT);
+ List<Object> list = new ArrayList<Object>();
+ list.add(content);
+ entry.setContents(list);
+
+ return entry;
+ }
+}
diff --git a/java/sca/modules/binding-feed/src/test/java/org/apache/tuscany/sca/binding/feed/CustomerCollectionImpl.java b/java/sca/modules/binding-feed/src/test/java/org/apache/tuscany/sca/binding/feed/CustomerCollectionImpl.java
new file mode 100644
index 0000000000..ca4a5a1946
--- /dev/null
+++ b/java/sca/modules/binding-feed/src/test/java/org/apache/tuscany/sca/binding/feed/CustomerCollectionImpl.java
@@ -0,0 +1,136 @@
+/*
+ * 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.feed;
+
+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.feed.collection.Collection;
+import org.osoa.sca.annotations.Scope;
+
+import com.sun.syndication.feed.atom.Content;
+import com.sun.syndication.feed.atom.Entry;
+import com.sun.syndication.feed.atom.Feed;
+import com.sun.syndication.feed.atom.Link;
+
+@Scope("COMPOSITE")
+public class CustomerCollectionImpl implements Collection {
+
+ private Map<String, Entry> entries = new HashMap<String, Entry>();
+
+ public CustomerCollectionImpl() {
+
+ for (int i = 0; i < 4; i++) {
+ String id = "urn:uuid:customer-" + UUID.randomUUID().toString();
+
+ Entry entry = new Entry();
+ entry.setTitle("customer " + "Jane Doe_" + String.valueOf(i));
+ entry.setId(id);
+
+ Content content = new Content();
+ content.setValue("Jane Doe_" + String.valueOf(i));
+ content.setType(Content.TEXT);
+ entry.setContents(Collections.singletonList(content));
+
+ List<Link> links = new ArrayList<Link>();
+ Link link = new Link();
+ link.setRel("edit");
+ link.setHref("" + id);
+ links.add(link);
+ entry.setOtherLinks(links);
+
+ links = new ArrayList<Link>();
+ link = new Link();
+ link.setRel("alternate");
+ link.setHref("" + id);
+ links.add(link);
+ entry.setAlternateLinks(links);
+
+ entry.setCreated(new Date());
+
+ entries.put(id, entry);
+ System.out.println(">>> id=" + id);
+ }
+ }
+
+ public Entry post(Entry entry) {
+ System.out.println(">>> ResourceCollectionImpl.post entry=" + entry.getTitle());
+
+ String id = "urn:uuid:customer-" + UUID.randomUUID().toString();
+ entry.setId(id);
+
+ List<Link> links = new ArrayList<Link>();
+ Link link = new Link();
+ link.setRel("edit");
+ link.setHref("" + id);
+ links.add(link);
+ entry.setOtherLinks(links);
+
+ links = new ArrayList<Link>();
+ link = new Link();
+ link.setRel("alternate");
+ link.setHref("" + id);
+ links.add(link);
+ entry.setAlternateLinks(links);
+
+ entry.setCreated(new Date());
+
+ entries.put(id, entry);
+ System.out.println(">>> ResourceCollectionImpl.post return id=" + id);
+
+ return entry;
+ }
+
+ public Entry get(String id) {
+ System.out.println(">>> ResourceCollectionImpl.get id=" + id);
+ return entries.get(id);
+ }
+
+ public void put(String id, Entry entry) {
+ System.out.println(">>> ResourceCollectionImpl.put id=" + id + " entry=" + entry.getTitle());
+
+ entry.setUpdated(new Date());
+ entries.put(id, entry);
+ }
+
+ public void delete(String id) {
+ System.out.println(">>> ResourceCollectionImpl.delete id=" + id);
+ entries.remove(id);
+ }
+
+ @SuppressWarnings("unchecked")
+ public Feed getFeed() {
+ System.out.println(">>> ResourceCollectionImpl.get collection");
+
+ Feed feed = new Feed();
+ feed.setTitle("customers");
+ Content subtitle = new Content();
+ subtitle.setValue("This is a sample feed");
+ feed.setSubtitle(subtitle);
+ feed.getEntries().addAll(entries.values());
+ return feed;
+ }
+
+}
diff --git a/java/sca/modules/binding-feed/src/test/java/org/apache/tuscany/sca/binding/feed/Provider.java b/java/sca/modules/binding-feed/src/test/java/org/apache/tuscany/sca/binding/feed/Provider.java
new file mode 100644
index 0000000000..a9ddc1a2c8
--- /dev/null
+++ b/java/sca/modules/binding-feed/src/test/java/org/apache/tuscany/sca/binding/feed/Provider.java
@@ -0,0 +1,41 @@
+/*
+ * 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.feed;
+
+import java.io.IOException;
+
+import org.apache.tuscany.sca.host.embedded.SCADomain;
+
+public class Provider {
+
+ public static void main(String[] args) {
+
+ SCADomain scaDomain = SCADomain.newInstance("org/apache/tuscany/sca/binding/feed/Provider.composite");
+ System.out.println("Provider.composite ready...");
+
+ try {
+ System.in.read();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ scaDomain.close();
+ }
+}
diff --git a/java/sca/modules/binding-feed/src/test/resources/org/apache/tuscany/sca/binding/feed/Consumer.composite b/java/sca/modules/binding-feed/src/test/resources/org/apache/tuscany/sca/binding/feed/Consumer.composite
new file mode 100644
index 0000000000..1987c042e6
--- /dev/null
+++ b/java/sca/modules/binding-feed/src/test/resources/org/apache/tuscany/sca/binding/feed/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://www.osoa.org/xmlns/sca/1.0"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0"
+ targetNamespace="http://customer"
+ name="Consumer">
+
+ <component name="CustomerClient">
+ <implementation.java class="org.apache.tuscany.sca.binding.feed.CustomerClientImpl"/>
+ <reference name="resourceCollection">
+ <tuscany:binding.atom uri="http://localhost:8084/customer"/>
+ </reference>
+ </component>
+
+</composite>
diff --git a/java/sca/modules/binding-feed/src/test/resources/org/apache/tuscany/sca/binding/feed/Provider.composite b/java/sca/modules/binding-feed/src/test/resources/org/apache/tuscany/sca/binding/feed/Provider.composite
new file mode 100644
index 0000000000..9268fbe211
--- /dev/null
+++ b/java/sca/modules/binding-feed/src/test/resources/org/apache/tuscany/sca/binding/feed/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://www.osoa.org/xmlns/sca/1.0"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0"
+ targetNamespace = "http://customer"
+ name="Provider">
+
+ <service name="customer" promote="CustomerCollection">
+ <tuscany:binding.atom uri = "http://localhost:8084/customer"/>
+ </service>
+
+ <component name="CustomerCollection">
+ <implementation.java class="org.apache.tuscany.sca.binding.feed.CustomerCollectionImpl"/>
+ </component>
+
+</composite>
diff --git a/java/sca/modules/binding-gdata2-runtime/LICENSE b/java/sca/modules/binding-gdata2-runtime/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/java/sca/modules/binding-gdata2-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/java/sca/modules/binding-gdata2-runtime/NOTICE b/java/sca/modules/binding-gdata2-runtime/NOTICE
new file mode 100644
index 0000000000..fdfa0e9faa
--- /dev/null
+++ b/java/sca/modules/binding-gdata2-runtime/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2008 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/java/sca/modules/binding-gdata2-runtime/deployGdataToMaven.sh b/java/sca/modules/binding-gdata2-runtime/deployGdataToMaven.sh
new file mode 100755
index 0000000000..306ad19f66
--- /dev/null
+++ b/java/sca/modules/binding-gdata2-runtime/deployGdataToMaven.sh
@@ -0,0 +1,7 @@
+mvn gpg:sign-and-deploy-file -DgroupId=com.google.gdata -DartifactId=gdata-core -Dversion=1.0 -Dpackaging=jar -Dfile=gdata-core-1.0.jar -DrepositoryId=apache.people -Durl=scp://people.apache.org/home/lresende/public_html/google-gdata/maven -Dkeyname=lresende
+
+mvn gpg:sign-and-deploy-file -DgroupId=com.google.gdata -DartifactId=gdata-client -Dversion=1.0 -Dpackaging=jar -Dfile=gdata-client-1.0.jar -DrepositoryId=apache.people -Durl=scp://people.apache.org/home/lresende/public_html/google-gdata/maven -Dkeyname=lresende
+
+mvn gpg:sign-and-deploy-file -DgroupId=com.google.gdata -DartifactId=gdata-client-meta -Dversion=1.0 -Dpackaging=jar -Dfile=gdata-client-meta-1.0.jar -DrepositoryId=apache.people -Durl=scp://people.apache.org/home/lresende/public_html/google-gdata/maven -Dkeyname=lresende
+
+mvn gpg:sign-and-deploy-file -DgroupId=com.google.gdata -DartifactId=gdata-media -Dversion=1.0 -Dpackaging=jar -Dfile=gdata-media-1.0.jar -DrepositoryId=apache.people -Durl=scp://people.apache.org/home/lresende/public_html/google-gdata/maven -Dkeyname=lresende
diff --git a/java/sca/modules/binding-gdata2-runtime/pom.xml b/java/sca/modules/binding-gdata2-runtime/pom.xml
new file mode 100644
index 0000000000..0768864c1c
--- /dev/null
+++ b/java/sca/modules/binding-gdata2-runtime/pom.xml
@@ -0,0 +1,183 @@
+<?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-gdata2-runtime</artifactId>
+ <name>Apache Tuscany SCA GData Binding Extension Runtime</name>
+
+ <repositories>
+ <repository>
+ <id>com.google.gdata</id>
+ <url>http://people.apache.org/~lresende/google-gdata/maven/</url>
+ </repository>
+ </repositories>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-gdata2</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <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-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>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.4</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-host-embedded</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.google.gdata</groupId>
+ <artifactId>gdata-core</artifactId>
+ <version>1.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>com.google.gdata</groupId>
+ <artifactId>gdata-client</artifactId>
+ <version>1.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ <version>1.3</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>commons-codec</artifactId>
+ <groupId>commons-codec</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1.1</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>servlet-api</artifactId>
+ <groupId>javax.servlet</groupId>
+ </exclusion>
+ <exclusion>
+ <artifactId>avalon-framework</artifactId>
+ <groupId>avalon-framework</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.5</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+
+ <configuration>
+ <instructions>
+ <Bundle-Version>${tuscany.version}</Bundle-Version>
+ <Bundle-SymbolicName>org.apache.tuscany.sca.binding.atom.abdera</Bundle-SymbolicName>
+ <Bundle-Description>${pom.name}</Bundle-Description>
+ <Export-Package>org.apache.tuscany.sca.binding.atom*</Export-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/java/sca/modules/binding-gdata2-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/collection/Collection.java b/java/sca/modules/binding-gdata2-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/collection/Collection.java
new file mode 100644
index 0000000000..2679071ea8
--- /dev/null
+++ b/java/sca/modules/binding-gdata2-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/collection/Collection.java
@@ -0,0 +1,82 @@
+/*
+ * 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.gdata.collection;
+
+import com.google.gdata.data.BaseEntry;
+import com.google.gdata.data.BaseFeed;
+
+import org.apache.tuscany.sca.implementation.data.collection.NotFoundException;
+import org.osoa.sca.annotations.Remotable;
+
+/**
+ * Provides access to a collection of resources using Atom.
+ *
+ * @version $Rev$ $Date$
+ */
+@Remotable
+public interface Collection {
+
+ /**
+ * Get an Atom feed for a collection of resources.
+ *
+ * @return the Atom feed
+ */
+ BaseFeed<? extends BaseFeed, ? extends BaseEntry> getFeed();
+
+ /**
+ * Get an Atom feed for a collection of resources resulting
+ * from a query.
+ *
+ * @param queryString a query string
+ * @return the Atom feed
+ */
+ BaseFeed<? extends BaseFeed, ? extends BaseEntry> query(String queryString);
+
+ /**
+ * Creates a new entry.
+ *
+ * @param entry
+ * @return
+ */
+ BaseEntry post(BaseEntry entry);
+
+ /**
+ * Retrieves an entry.
+ *
+ * @param id
+ * @return
+ */
+ BaseEntry get(String id) throws NotFoundException;
+
+ /**
+ * Update an entry.
+ *
+ * @param id
+ * @param entry
+ * @return
+ */
+ BaseEntry put(String id, BaseEntry entry) throws NotFoundException;
+
+ /**
+ * Delete an entry.
+ *
+ * @param id
+ */
+ void delete(String id) throws NotFoundException;
+}
diff --git a/java/sca/modules/binding-gdata2-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/collection/MediaCollection.java b/java/sca/modules/binding-gdata2-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/collection/MediaCollection.java
new file mode 100644
index 0000000000..b9252d097a
--- /dev/null
+++ b/java/sca/modules/binding-gdata2-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/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.gdata.collection;
+
+import com.google.gdata.data.BaseEntry;
+import java.io.InputStream;
+
+import org.osoa.sca.annotations.Remotable;
+
+import org.apache.tuscany.sca.implementation.data.collection.NotFoundException;
+
+/**
+ * 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
+ */
+ BaseEntry 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/java/sca/modules/binding-gdata2-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GDataBindingInvoker.java b/java/sca/modules/binding-gdata2-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GDataBindingInvoker.java
new file mode 100644
index 0000000000..d2c5ed4017
--- /dev/null
+++ b/java/sca/modules/binding-gdata2-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GDataBindingInvoker.java
@@ -0,0 +1,510 @@
+/*
+ * 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.gdata.provider;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.osoa.sca.ServiceRuntimeException;
+
+import com.google.gdata.client.GoogleService;
+import com.google.gdata.client.Query;
+import com.google.gdata.data.BaseEntry;
+import com.google.gdata.data.BaseFeed;
+import com.google.gdata.data.Entry;
+import com.google.gdata.data.ExtensionProfile;
+import com.google.gdata.data.Feed;
+import com.google.gdata.data.ParseSource;
+import com.google.gdata.util.AuthenticationException;
+import java.net.URL;
+import com.google.gdata.util.ResourceNotFoundException;
+import com.google.gdata.util.common.xml.XmlWriter;
+import java.io.StringWriter;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.methods.DeleteMethod;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.commons.httpclient.methods.PutMethod;
+import org.apache.commons.httpclient.methods.StringRequestEntity;
+import org.apache.tuscany.sca.binding.gdata.GDataBinding;
+import org.apache.tuscany.sca.data.collection.NotFoundException;
+import org.apache.tuscany.sca.invocation.DataExchangeSemantics;
+
+/**
+ * Invoker for the Atom binding.
+ *
+ * @version $Rev$ $Date$
+ */
+class GDataBindingInvoker implements Invoker, DataExchangeSemantics {
+
+ Operation operation;
+ GDataBinding binding;
+ HttpClient httpClient;
+ String authorizationHeader;
+ GoogleService service;
+
+ GDataBindingInvoker(Operation operation, GDataBinding binding, HttpClient httpClient, String authorizationHeader) {
+ this.operation = operation;
+ this.binding = binding;
+ this.httpClient = httpClient;
+ this.authorizationHeader = authorizationHeader;
+
+ //Create the GoogleService
+ if (!binding.getServiceType().equals("sca")) {
+ this.service = new GoogleService(binding.getServiceType(), "");
+
+ try {
+ service.setUserCredentials(binding.getUsername(), binding.getPassword());
+ } catch (AuthenticationException ex) {
+ //FIXME - promote the exception
+ Logger.getLogger(GDataReferenceBindingProvider.class.getName()).log(Level.SEVERE, null, ex);
+ }
+
+ this.service.setConnectTimeout(60000);
+ }
+ }
+
+ public Message invoke(Message msg) {
+ // Shouldn't get here, as the only supported methods are
+ // defined in the ResourceCollection interface, and implemented
+ // by specific invoker subclasses
+ throw new UnsupportedOperationException(operation.getName());
+ }
+
+ /**
+ * Get operation invoker
+ */
+ public static class GetInvoker extends GDataBindingInvoker {
+
+ public GetInvoker(Operation operation, GDataBinding binding, HttpClient httpClient, String authorizationHeader) {
+ super(operation, binding, httpClient, authorizationHeader);
+ }
+
+ @Override
+ public Message invoke(Message msg) {
+
+ BaseEntry entry;
+ GetMethod getMethod = null;
+ boolean parsing = false;
+
+ String id = (String) ((Object[]) msg.getBody())[0];
+
+ try {
+ // serviceType == "sca" - Send an HTTP GET
+ if (service == null) {
+ getMethod = new GetMethod(binding.getURI() + "/" + id);
+ getMethod.setRequestHeader("Authorization", authorizationHeader);
+
+ httpClient.executeMethod(getMethod);
+ int status = getMethod.getStatusCode();
+
+ // Read the Atom feed
+ if (status == 200) {
+
+ parsing = true;
+
+ ParseSource parser = new ParseSource(getMethod.getResponseBodyAsStream());
+ entry = BaseEntry.readEntry(parser);
+
+ msg.setBody(entry);
+
+ } else if (status == 404) {
+ msg.setFaultBody(new NotFoundException());
+ } else {
+ msg.setFaultBody(new ServiceRuntimeException("HTTP status code: " + status));
+ }
+
+ } // serviceType != "sca" - Use GoogleService
+ else {
+ entry = service.getEntry(new URL(id), Entry.class);
+ msg.setBody(entry);
+ }
+ } catch (ResourceNotFoundException ex) {
+ msg.setFaultBody(new ResourceNotFoundException("Invalid Resource at " + binding.getURI()));
+ } catch (Exception ex) {
+ msg.setFaultBody(new ServiceRuntimeException(ex));
+ } finally {
+ if (service == null && !parsing) {
+ getMethod.releaseConnection();
+ }
+ return msg;
+ }
+
+ }
+ }
+
+ /**
+ * Post operation invoker
+ */
+ public static class PostInvoker extends GDataBindingInvoker {
+
+ public PostInvoker(Operation operation, GDataBinding binding, HttpClient httpClient, String authorizationHeader) {
+ super(operation, binding, httpClient, authorizationHeader);
+ }
+
+ @Override
+ public Message invoke(Message msg) {
+
+ BaseEntry entry = (BaseEntry) ((Object[]) msg.getBody())[0];
+ BaseEntry returnedEntry;
+
+ PostMethod postMethod = null;
+ boolean parsing = false;
+
+ try {
+ // serviceType == "sca" - Send an HTTP POST
+ if (service == null) {
+ postMethod = new PostMethod(binding.getURI());
+ postMethod.setRequestHeader("Authorization", authorizationHeader);
+
+ // Write the Atom entry
+ StringWriter strWriter = new StringWriter();
+ XmlWriter writer = new XmlWriter(strWriter);
+ entry.generateAtom(writer, new ExtensionProfile());
+ writer.flush();
+ writer.close();
+
+ postMethod.setRequestHeader("Content-type", "application/atom+xml; charset=utf-8");
+ postMethod.setRequestEntity(new StringRequestEntity(strWriter.toString()));
+
+ httpClient.executeMethod(postMethod);
+ int status = postMethod.getStatusCode();
+
+ // Read the Atom feed
+ if (status == 200 || status == 201) {
+
+ parsing = true;
+
+ ParseSource parser = new ParseSource(postMethod.getResponseBodyAsStream());
+ returnedEntry = BaseEntry.readEntry(parser);
+
+ msg.setBody(returnedEntry);
+
+ } else if (status == 404) {
+ msg.setFaultBody(new NotFoundException());
+ } else {
+ msg.setFaultBody(new ServiceRuntimeException("HTTP status code: " + status));
+ }
+
+ } // serviceType != "sca" - Use GoogleService
+ else {
+ returnedEntry = service.insert(new URL(binding.getURI()), entry);
+ msg.setBody(returnedEntry);
+ }
+ } catch (ResourceNotFoundException ex) {
+ msg.setFaultBody(new ResourceNotFoundException("Invalid Resource at " + binding.getURI()));
+ } catch (Exception ex) {
+ msg.setFaultBody(new ServiceRuntimeException(ex));
+ } finally {
+ if (service == null && !parsing) {
+ postMethod.releaseConnection();
+ }
+ return msg;
+ }
+
+ }
+ }
+
+ /**
+ * Put operation invoker
+ */
+ public static class PutInvoker extends GDataBindingInvoker {
+
+ public PutInvoker(Operation operation, GDataBinding binding, HttpClient httpClient, String authorizationHeader) {
+ super(operation, binding, httpClient, authorizationHeader);
+ }
+
+ @Override
+ public Message invoke(Message msg) {
+
+ BaseEntry updatedEntry;
+ String id = (String) ((Object[]) msg.getBody())[0];
+ BaseEntry entry = (BaseEntry) ((Object[]) msg.getBody())[1];
+
+ PutMethod putMethod = null;
+ boolean parsing = false;
+
+ try {
+ // serviceType == "sca" - Send an HTTP PUT
+ if (service == null) {
+ putMethod = new PutMethod(binding.getURI() + "/" + id);
+ putMethod.setRequestHeader("Authorization", authorizationHeader);
+
+ // Write the Atom entry
+ StringWriter strWriter = new StringWriter();
+ XmlWriter writer = new XmlWriter(strWriter);
+ entry.generateAtom(writer, new ExtensionProfile());
+ writer.flush();
+ writer.close();
+
+ putMethod.setRequestHeader("Content-type", "application/atom+xml; charset=utf-8");
+ putMethod.setRequestEntity(new StringRequestEntity(strWriter.toString()));
+
+ httpClient.executeMethod(putMethod);
+ int status = putMethod.getStatusCode();
+
+ // Read the Atom feed
+ if (status == 200 || status == 201) {
+
+ parsing = true;
+
+ ParseSource parser = new ParseSource(putMethod.getResponseBodyAsStream());
+ updatedEntry = BaseEntry.readEntry(parser);
+
+ msg.setBody(updatedEntry);
+
+ } else if (status == 404) {
+ msg.setFaultBody(new NotFoundException());
+ } else {
+ msg.setFaultBody(new ServiceRuntimeException("HTTP status code: " + status));
+ }
+
+ } // serviceType != "sca" - Use GoogleService
+ else {
+ updatedEntry = service.update(new URL(id), entry);
+ msg.setBody(updatedEntry);
+ }
+ } catch (ResourceNotFoundException ex) {
+ msg.setFaultBody(new ResourceNotFoundException("Invalid Resource at " + binding.getURI()));
+ } catch (Exception ex) {
+ msg.setFaultBody(new ServiceRuntimeException(ex));
+ } finally {
+ if (service == null && !parsing) {
+ putMethod.releaseConnection();
+ }
+ return msg;
+ }
+ }
+ }
+
+ /**
+ * Delete operation invoker
+ */
+ public static class DeleteInvoker extends GDataBindingInvoker {
+
+ public DeleteInvoker(Operation operation, GDataBinding binding, HttpClient httpClient, String authorizationHeader) {
+ super(operation, binding, httpClient, authorizationHeader);
+ }
+
+ @Override
+ public Message invoke(Message msg) {
+
+ DeleteMethod deleteMethod = null;
+
+ String id = (String) ((Object[]) msg.getBody())[0];
+
+ try {
+ // serviceType == "sca" - Send an HTTP DELETE
+ if (service == null) {
+ deleteMethod = new DeleteMethod(binding.getURI() + "/" + id);
+ deleteMethod.setRequestHeader("Authorization", authorizationHeader);
+
+ httpClient.executeMethod(deleteMethod);
+ int status = deleteMethod.getStatusCode();
+
+ // Read the Atom feed
+ if (status == 200) {
+ msg.setBody(null);
+
+ } else if (status == 404) {
+ msg.setFaultBody(new NotFoundException());
+ } else {
+ msg.setFaultBody(new ServiceRuntimeException("HTTP status code: " + status));
+ }
+
+ } // serviceType != "sca" - Use GoogleService
+ else {
+ service.delete(new URL(id));
+ msg.setBody(null);
+ }
+ } catch (ResourceNotFoundException ex) {
+ msg.setFaultBody(new ResourceNotFoundException("Invalid Resource at " + binding.getURI()));
+ } catch (Exception ex) {
+ msg.setFaultBody(new ServiceRuntimeException(ex));
+ } finally {
+ if (service == null) {
+ deleteMethod.releaseConnection();
+ }
+ return msg;
+ }
+
+ }
+ }
+
+ /**
+ * GetAll operation invoker
+ */
+ public static class GetAllInvoker extends GDataBindingInvoker {
+
+ public GetAllInvoker(Operation operation, GDataBinding binding, HttpClient httpClient, String authorizationHeader) {
+ super(operation, binding, httpClient, authorizationHeader);
+ }
+
+ @Override
+ public Message invoke(Message msg) {
+
+ BaseFeed feed;
+ GetMethod getMethod = null;
+ boolean parsing = false;
+
+ try {
+ // serviceType == "sca" - Send an HTTP GET
+ if (service == null) {
+ getMethod = new GetMethod(binding.getURI());
+ getMethod.setRequestHeader("Authorization", authorizationHeader);
+
+ httpClient.executeMethod(getMethod);
+ int status = getMethod.getStatusCode();
+
+ // Read the Atom feed
+ if (status == 200) {
+
+ parsing = true;
+
+ ParseSource parser = new ParseSource(getMethod.getResponseBodyAsStream());
+ feed = BaseFeed.readFeed(parser);
+
+ msg.setBody(feed);
+
+ } else if (status == 404) {
+ msg.setFaultBody(new NotFoundException());
+ } else {
+ msg.setFaultBody(new ServiceRuntimeException("HTTP status code: " + status));
+ }
+
+ } // serviceType != "sca" - Use GoogleService
+ else {
+ feed = service.getFeed(new URL(binding.getURI()), Feed.class);
+ msg.setBody(feed);
+ }
+ } catch (ResourceNotFoundException ex) {
+ msg.setFaultBody(new ResourceNotFoundException("Invalid Resource at " + binding.getURI()));
+ } catch (Exception ex) {
+ msg.setFaultBody(new ServiceRuntimeException(ex));
+ } finally {
+ if (service == null && !parsing) {
+ getMethod.releaseConnection();
+ }
+ return msg;
+ }
+ }
+ }
+
+ /**
+ * Query operation invoker
+ */
+ public static class QueryInvoker extends GDataBindingInvoker {
+
+ public QueryInvoker(Operation operation, GDataBinding binding, HttpClient httpClient, String authorizationHeader) {
+ super(operation, binding, httpClient, authorizationHeader);
+ }
+
+ @Override
+ public Message invoke(Message msg) {
+
+ BaseFeed feed;
+ GetMethod getMethod = null;
+ boolean parsing = false;
+
+ String queryString = (String) ((Object[]) msg.getBody())[0];
+
+ try {
+ // serviceType == "sca" - Send an HTTP GET
+ if (service == null) {
+ getMethod = new GetMethod(binding.getURI());
+ getMethod.setRequestHeader("Authorization", authorizationHeader);
+ getMethod.setQueryString(queryString);
+
+ httpClient.executeMethod(getMethod);
+ int status = getMethod.getStatusCode();
+
+ // Read the Atom feed
+ if (status == 200) {
+
+ parsing = true;
+
+ ParseSource parser = new ParseSource(getMethod.getResponseBodyAsStream());
+ feed = BaseFeed.readFeed(parser);
+
+ msg.setBody(feed);
+
+ } else if (status == 404) {
+ msg.setFaultBody(new NotFoundException());
+ } else {
+ msg.setFaultBody(new ServiceRuntimeException("HTTP status code: " + status));
+ }
+
+ } // serviceType != "sca" - Use GoogleService
+ else {
+ Query query = new Query(new URL(binding.getURI()));
+ query.setFullTextQuery(queryString);
+ feed = service.query(query, Feed.class);
+ msg.setBody(feed);
+ }
+ } catch (ResourceNotFoundException ex) {
+ msg.setFaultBody(new ResourceNotFoundException("Invalid Resource at " + binding.getURI()));
+ } catch (Exception ex) {
+ msg.setFaultBody(new ServiceRuntimeException(ex));
+ } finally {
+ if (service == null && !parsing) {
+ getMethod.releaseConnection();
+ }
+ return msg;
+ }
+ }
+ }
+
+ /**
+ * PostMedia operation invoker
+ */
+ public static class PostMediaInvoker extends GDataBindingInvoker {
+
+ public PostMediaInvoker(Operation operation, GDataBinding binding, HttpClient httpClient, String authorizationHeader) {
+ super(operation, binding, httpClient, authorizationHeader);
+ }
+
+ @Override
+ public Message invoke(Message msg) {
+ // TODO implement
+ return super.invoke(msg);
+ }
+ }
+
+ /**
+ * PutMedia operation invoker
+ */
+ public static class PutMediaInvoker extends GDataBindingInvoker {
+
+ public PutMediaInvoker(Operation operation, GDataBinding binding, HttpClient httpClient, String authorizationHeader) {
+ super(operation, binding, httpClient, authorizationHeader);
+ }
+
+ @Override
+ public Message invoke(Message msg) {
+ // TODO implement
+ return super.invoke(msg);
+ }
+ }
+
+ public boolean allowsPassByReference() {
+ return true;
+ }
+}
diff --git a/java/sca/modules/binding-gdata2-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GDataBindingListenerServlet.java b/java/sca/modules/binding-gdata2-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GDataBindingListenerServlet.java
new file mode 100644
index 0000000000..1f9318070d
--- /dev/null
+++ b/java/sca/modules/binding-gdata2-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GDataBindingListenerServlet.java
@@ -0,0 +1,426 @@
+/*
+ * 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.gdata.provider;
+
+import com.google.gdata.data.BaseEntry;
+import com.google.gdata.data.BaseFeed;
+import com.google.gdata.data.ExtensionProfile;
+import com.google.gdata.data.Link;
+import com.google.gdata.data.ParseSource;
+import com.google.gdata.util.ServiceException;
+import com.google.gdata.util.common.xml.XmlWriter;
+import java.io.IOException;
+import java.net.URLDecoder;
+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 org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.runtime.RuntimeWire;
+import org.apache.tuscany.sca.invocation.MessageFactory;
+import org.apache.tuscany.sca.databinding.Mediator;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.InvocationChain;
+import org.apache.tuscany.sca.invocation.Message;
+
+class GDataBindingListenerServlet extends HttpServlet {
+
+ private static final Logger logger = Logger.getLogger(GDataBindingListenerServlet.class.getName());
+ private RuntimeWire wire;
+ private Invoker getFeedInvoker;
+ private Invoker queryInvoker;
+ private Invoker getInvoker;
+ private Invoker postInvoker;
+ private Invoker postMediaInvoker;
+ private Invoker putInvoker;
+ private Invoker putMediaInvoker;
+ private Invoker deleteInvoker;
+ private MessageFactory messageFactory;
+ private String title;
+ private Mediator mediator;
+// private DataType<?> itemClassType;
+// private DataType<?> itemXMLType;
+// private boolean supportsFeedEntries;
+
+ GDataBindingListenerServlet(RuntimeWire wire, MessageFactory messageFactory, Mediator mediator, String title) {
+ this.wire = wire;
+ this.messageFactory = messageFactory;
+ this.mediator = mediator;
+ this.title = title;
+
+ // 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("query")) {
+ queryInvoker = invocationChain.getHeadInvoker();
+ } else if (operationName.equals("get")) {
+ getInvoker = invocationChain.getHeadInvoker();
+ //getOperation = operation;
+ } else if (operationName.equals("put")) {
+ putInvoker = invocationChain.getHeadInvoker();
+ } else if (operationName.equals("putMedia")) {
+ putMediaInvoker = invocationChain.getHeadInvoker();
+ } else if (operationName.equals("post")) {
+ postInvoker = invocationChain.getHeadInvoker();
+ } else if (operationName.equals("postMedia")) {
+ postMediaInvoker = invocationChain.getHeadInvoker();
+ } else if (operationName.equals("delete")) {
+ deleteInvoker = invocationChain.getHeadInvoker();
+ }
+ }
+
+// // Determine the collection item type
+// itemXMLType = new DataTypeImpl<Class<?>>(String.class.getName(), String.class, String.class);
+// Class<?> itemClass = getOperation.getOutputType().getPhysical();
+// if (itemClass == BaseEntry.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 {
+
+ int servletPathLength = request.getContextPath().length() + request.getServletPath().length();
+
+ String path = URLDecoder.decode(request.getRequestURI().substring(servletPathLength), "UTF-8");
+
+ logger.fine("get " + request.getRequestURI());
+
+ if (path != null && path.equals("/atomsvc")) {
+ //FIX-ME - Doing nothing
+ } else if (path == null || path.length() == 0 || path.equals("/")) {
+
+ // Return a feed containing the entries in the collection
+ BaseFeed feed = null;
+
+ Message requestMessage = messageFactory.createMessage();
+ Message responseMessage;
+ if (request.getQueryString() != null) {
+ requestMessage.setBody(new Object[]{request.getQueryString()});
+ responseMessage = queryInvoker.invoke(requestMessage);
+ } else {
+ responseMessage = getFeedInvoker.invoke(requestMessage);
+ }
+ if (responseMessage.isFault()) {
+ throw new ServletException((Throwable) responseMessage.getBody());
+ }
+
+ // The service implementation supports feed entries, invoke its getFeed operation
+ feed = (BaseFeed) responseMessage.getBody();
+
+ if (feed != null) {
+
+ // Write the Atom feed
+ response.setContentType("application/atom+xml; charset=utf-8");
+ try {
+
+ XmlWriter writer = new XmlWriter(response.getWriter());
+ feed.generateAtom(writer, new ExtensionProfile());
+ writer.flush();
+ writer.close();
+
+ } catch (IOException ioe) {
+ throw new ServletException(ioe);
+ }
+ } else {
+ response.sendError(HttpServletResponse.SC_NOT_FOUND);
+ }
+
+ } else if (path.startsWith("/")) {
+ // Return a specific entry in the collection
+ BaseEntry feedEntry;
+
+ // Invoke the get operation on the service implementation
+ Message requestMessage = messageFactory.createMessage();
+ String id = path.substring(1);
+ requestMessage.setBody(new Object[]{id});
+ Message responseMessage = getInvoker.invoke(requestMessage);
+ if (responseMessage.isFault()) {
+ throw new ServletException((Throwable) responseMessage.getBody());
+ }
+
+ // The service implementation returns a feed entry
+ feedEntry = responseMessage.getBody();
+
+ // Write the Atom entry
+ if (feedEntry != null) {
+ response.setContentType("application/atom+xml; charset=utf-8");
+ try {
+ XmlWriter writer = new XmlWriter(response.getWriter());
+ feedEntry.generateAtom(writer, new ExtensionProfile());
+ writer.flush();
+ writer.close();
+ } catch (IOException ioe) {
+ throw new ServletException(ioe);
+ }
+ } else {
+ response.sendError(HttpServletResponse.SC_NOT_FOUND);
+ }
+ } else {
+ // Path doesn't match any known pattern
+ response.sendError(HttpServletResponse.SC_NOT_FOUND);
+ }
+ }
+
+ @Override
+ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+
+ // FIX-ME: Authenticate the user
+
+// String user = processAuthorizationHeader(request);
+// if (user == null) {
+// unauthorized(response);
+// return;
+// }
+
+ // Get the request path
+ String path = URLDecoder.decode(request.getRequestURI().substring(request.getServletPath().length()), "UTF-8");
+
+ if (path == null || path.length() == 0 || path.equals("/")) {
+
+ BaseEntry createdFeedEntry = null;
+
+ // Create a new Atom entry
+ String contentType = request.getContentType();
+ if (contentType != null && contentType.startsWith("application/atom+xml")) {
+
+ // Read the entry from the request
+ BaseEntry feedEntry;
+ try {
+ ParseSource parser = new ParseSource(request.getReader());
+ feedEntry = BaseEntry.readEntry(parser);
+
+ } catch (ServiceException ex) {
+ throw new ServletException(ex);
+ }
+
+ // The service implementation supports feed entries, pass the entry to it
+ Message requestMessage = messageFactory.createMessage();
+ requestMessage.setBody(new Object[]{feedEntry});
+ Message responseMessage = postInvoker.invoke(requestMessage);
+
+ if (responseMessage.isFault()) {
+ throw new ServletException((Throwable) responseMessage.getBody());
+ }
+
+ createdFeedEntry = responseMessage.getBody();
+
+ } else if (contentType != null) {
+
+ // Create a new media entry
+
+ // Get incoming headers
+ String reqTitle = request.getHeader("Title");
+ String slug = request.getHeader("Slug");
+
+ // Let the component implementation create the media entry
+ Message requestMessage = messageFactory.createMessage();
+ requestMessage.setBody(new Object[]{reqTitle, slug, contentType, request.getInputStream()});
+ Message responseMessage = postMediaInvoker.invoke(requestMessage);
+
+ if (responseMessage.isFault()) {
+ throw new ServletException((Throwable) responseMessage.getBody());
+ }
+ createdFeedEntry = responseMessage.getBody();
+ } else {
+ response.sendError(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE);
+ }
+
+ // A new entry was created successfully
+ if (createdFeedEntry != null) {
+
+ // Set location of the created entry in the Location header
+ Link link = createdFeedEntry.getSelfLink();
+ if (link != null) {
+ response.addHeader("Location", link.getHref().toString());
+ }
+
+ // Write the created Atom entry
+ response.setStatus(HttpServletResponse.SC_CREATED);
+ response.setContentType("application/atom+xml; charset=utf-8");
+ try {
+
+ XmlWriter writer = new XmlWriter(response.getWriter());
+ createdFeedEntry.generateAtom(writer, new ExtensionProfile());
+ writer.flush();
+ writer.close();
+
+ } catch (IOException ioe) {
+ throw new ServletException(ioe);
+ }
+
+ } else {
+ response.sendError(HttpServletResponse.SC_NOT_FOUND);
+ }
+
+ } else {
+ response.sendError(HttpServletResponse.SC_NOT_FOUND);
+ }
+ }
+
+ @Override
+ protected void doPut(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+
+ // FIX-ME: Authenticate the user
+
+// String user = processAuthorizationHeader(request);
+// if (user == null) {
+// unauthorized(response);
+// return;
+// }
+
+ // Get the request path
+ String path = request.getRequestURI().substring(request.getServletPath().length());
+
+ BaseEntry createdFeedEntry = null;
+
+ if (path != null && path.startsWith("/")) {
+ String id = path.substring(1);
+
+ // Update an Atom entry
+ String contentType = request.getContentType();
+ if (contentType != null && contentType.startsWith("application/atom+xml")) {
+
+ // Read the entry from the request
+ BaseEntry feedEntry;
+ try {
+ ParseSource parser = new ParseSource(request.getReader());
+ feedEntry = BaseEntry.readEntry(parser);
+
+ } catch (ServiceException ex) {
+ throw new ServletException(ex);
+ }
+
+ // Let the component implementation create it
+
+ // The service implementation supports feed entries, pass the entry to it
+ Message requestMessage = messageFactory.createMessage();
+ requestMessage.setBody(new Object[]{id, feedEntry});
+ Message responseMessage = putInvoker.invoke(requestMessage);
+
+ if (responseMessage.isFault()) {
+ Object body = responseMessage.getBody();
+ if (body.getClass().getName().endsWith(".NotFoundException")) {
+ response.sendError(HttpServletResponse.SC_NOT_FOUND);
+ } else {
+ throw new ServletException((Throwable) responseMessage.getBody());
+ }
+ }
+
+ createdFeedEntry = responseMessage.getBody();
+
+ } else if (contentType != null) {
+
+ // Updated a media entry
+
+ // Let the component implementation create the media entry
+ Message requestMessage = messageFactory.createMessage();
+ requestMessage.setBody(new Object[]{id, contentType, request.getInputStream()});
+ Message responseMessage = putMediaInvoker.invoke(requestMessage);
+ Object body = responseMessage.getBody();
+ if (responseMessage.isFault()) {
+ if (body.getClass().getName().endsWith(".NotFoundException")) {
+ response.sendError(HttpServletResponse.SC_NOT_FOUND);
+ } else {
+ throw new ServletException((Throwable) responseMessage.getBody());
+ }
+ }
+
+ createdFeedEntry = responseMessage.getBody();
+
+ } else {
+ response.sendError(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE);
+ }
+
+ // A new entry was created successfully
+ if (createdFeedEntry != null) {
+
+ // Set location of the created entry in the Location header
+ Link link = createdFeedEntry.getSelfLink();
+ if (link != null) {
+ response.addHeader("Location", link.getHref().toString());
+ }
+
+ // Write the created Atom entry
+ response.setStatus(HttpServletResponse.SC_CREATED);
+ response.setContentType("application/atom+xml; charset=utf-8");
+ try {
+
+ XmlWriter writer = new XmlWriter(response.getWriter());
+ createdFeedEntry.generateAtom(writer, new ExtensionProfile());
+ writer.flush();
+ writer.close();
+
+ } catch (IOException ioe) {
+ throw new ServletException(ioe);
+ }
+
+ } else {
+ response.sendError(HttpServletResponse.SC_NOT_FOUND);
+ }
+
+ } else {
+ response.sendError(HttpServletResponse.SC_NOT_FOUND);
+ }
+ }
+
+ @Override
+ protected void doDelete(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+
+ // FIX-ME: Authenticate the user
+// String user = processAuthorizationHeader(request);
+// if (user == null) {
+// unauthorized(response);
+// return;
+// }
+
+ // Get the request path
+ String path = URLDecoder.decode(request.getRequestURI().substring(request.getServletPath().length()), "UTF-8");
+
+ String id;
+ if (path != null && path.startsWith("/")) {
+ id = path.substring(1);
+ } else {
+ id = "";
+ }
+
+ // Delete a specific entry from the collection
+ Message requestMessage = messageFactory.createMessage();
+ requestMessage.setBody(new Object[]{id});
+ Message responseMessage = deleteInvoker.invoke(requestMessage);
+ if (responseMessage.isFault()) {
+ Object body = responseMessage.getBody();
+ if (body.getClass().getName().endsWith(".NotFoundException")) {
+ response.sendError(HttpServletResponse.SC_NOT_FOUND);
+ } else {
+ throw new ServletException((Throwable) responseMessage.getBody());
+ }
+ }
+ }
+}
diff --git a/java/sca/modules/binding-gdata2-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GDataBindingProviderFactory.java b/java/sca/modules/binding-gdata2-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GDataBindingProviderFactory.java
new file mode 100644
index 0000000000..bace6f68bb
--- /dev/null
+++ b/java/sca/modules/binding-gdata2-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GDataBindingProviderFactory.java
@@ -0,0 +1,74 @@
+/*
+ * 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.gdata.provider;
+
+import org.apache.tuscany.sca.binding.gdata.GDataBinding;
+import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.databinding.DataBindingExtensionPoint;
+import org.apache.tuscany.sca.databinding.Mediator;
+import org.apache.tuscany.sca.databinding.TransformerExtensionPoint;
+import org.apache.tuscany.sca.databinding.impl.MediatorImpl;
+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.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+
+/**
+ * Implementation of a Binding provider factory for the Atom binding.
+ *
+ * @version $Rev$ $Date$
+ */
+public class GDataBindingProviderFactory implements BindingProviderFactory<GDataBinding> {
+
+ private MessageFactory messageFactory;
+ private Mediator mediator;
+ private ServletHost servletHost;
+
+ public GDataBindingProviderFactory(ExtensionPointRegistry extensionPoints) {
+ ServletHostExtensionPoint servletHosts = extensionPoints.getExtensionPoint(ServletHostExtensionPoint.class);
+ this.servletHost = servletHosts.getServletHosts().get(0);
+ ModelFactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(ModelFactoryExtensionPoint.class);
+ this.messageFactory = modelFactories.getFactory(MessageFactory.class);
+ this.mediator = new MediatorImpl(extensionPoints.getExtensionPoint(DataBindingExtensionPoint.class),
+ extensionPoints.getExtensionPoint(TransformerExtensionPoint.class));
+ }
+
+ public ReferenceBindingProvider createReferenceBindingProvider(RuntimeComponent component,
+ RuntimeComponentReference reference,
+ GDataBinding binding) {
+ return new GDataReferenceBindingProvider(component, reference, binding);
+ }
+
+ public ServiceBindingProvider createServiceBindingProvider(RuntimeComponent component,
+ RuntimeComponentService service,
+ GDataBinding binding) {
+ return new GDataServiceBindingProvider(component, service, binding, servletHost, messageFactory, mediator);
+ }
+
+ public Class<GDataBinding> getModelType() {
+ return GDataBinding.class;
+ }
+}
diff --git a/java/sca/modules/binding-gdata2-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GDataReferenceBindingProvider.java b/java/sca/modules/binding-gdata2-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GDataReferenceBindingProvider.java
new file mode 100644
index 0000000000..198edbaa88
--- /dev/null
+++ b/java/sca/modules/binding-gdata2-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GDataReferenceBindingProvider.java
@@ -0,0 +1,125 @@
+/*
+ * 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.gdata.provider;
+
+
+import org.apache.tuscany.sca.binding.gdata.GDataBinding;
+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.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+import org.apache.commons.httpclient.HttpClient;
+import java.net.URI;
+import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.httpclient.Credentials;
+import org.apache.commons.httpclient.HttpConnectionManager;
+import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
+import org.apache.commons.httpclient.UsernamePasswordCredentials;
+import org.apache.commons.httpclient.auth.AuthScope;
+
+/**
+ * Implementation of the Atom binding provider.
+ *
+ * @version $Rev$ $Date$
+ */
+class GDataReferenceBindingProvider implements ReferenceBindingProvider {
+
+ private RuntimeComponentReference reference;
+ private GDataBinding binding;
+ private HttpClient httpClient;
+ private String authorizationHeader;
+
+ /**
+ * Constructs a new AtomReferenceBindingProvider
+ * @param component
+ * @param reference
+ * @param binding
+ * @param mediator
+ */
+ GDataReferenceBindingProvider(RuntimeComponent component,
+ RuntimeComponentReference reference,
+ GDataBinding binding) {
+ this.reference = reference;
+ this.binding = binding;
+
+ // Prepare authorization header
+ //String authorization = "admin" + ":" + "admin";
+ String authorization = "gsocstudent2008" + ":" + "gsoc2008";
+ authorizationHeader = "Basic " + new String(Base64.encodeBase64(authorization.getBytes()));
+
+ // Create an HTTP client
+ HttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager();
+ connectionManager.getParams().setDefaultMaxConnectionsPerHost(10);
+ connectionManager.getParams().setConnectionTimeout(60000);
+ httpClient = new HttpClient(connectionManager);
+ }
+
+
+
+ public Invoker createInvoker(Operation operation) {
+
+ String operationName = operation.getName();
+ if (operationName.equals("get")) {
+ return new GDataBindingInvoker.GetInvoker(operation, binding, httpClient, authorizationHeader);
+ } else if (operationName.equals("post")) {
+ return new GDataBindingInvoker.PostInvoker(operation, binding, httpClient, authorizationHeader);
+ } else if (operationName.equals("put")) {
+ return new GDataBindingInvoker.PutInvoker(operation, binding, httpClient, authorizationHeader);
+ } else if (operationName.equals("delete")) {
+ return new GDataBindingInvoker.DeleteInvoker(operation, binding, httpClient, authorizationHeader);
+ } else if (operationName.equals("getFeed") || operationName.equals("getAll")) {
+ return new GDataBindingInvoker.GetAllInvoker(operation, binding, httpClient, authorizationHeader);
+ } else if (operationName.equals("postMedia")) {
+ return new GDataBindingInvoker.PostMediaInvoker(operation, binding, httpClient, authorizationHeader);
+ } else if (operationName.equals("putMedia")) {
+ return new GDataBindingInvoker.PutMediaInvoker(operation, binding, httpClient, authorizationHeader);
+ } else if (operationName.equals("query")) {
+ return new GDataBindingInvoker.QueryInvoker(operation, binding, httpClient, authorizationHeader);
+ }
+
+ return new GDataBindingInvoker(operation, binding, httpClient, authorizationHeader);
+ }
+
+ public InterfaceContract getBindingInterfaceContract() {
+ return reference.getInterfaceContract();
+ }
+
+ public void start() {
+ // Configure the HTTP client credentials
+ //Credentials credentials = new UsernamePasswordCredentials("admin", "admin");
+ Credentials credentials = new UsernamePasswordCredentials("gsocstudent2008", "gsoc2008");
+ httpClient.getParams().setAuthenticationPreemptive(true);
+ URI uri = URI.create(binding.getURI());
+ httpClient.getState().setCredentials(new AuthScope(uri.getHost(), uri.getPort()), credentials);
+
+ // Find the get operation on the reference interface
+ if (true) {
+ return;
+ }
+ }
+
+ public void stop() {
+ }
+
+ public boolean supportsOneWayInvocation() {
+ return false;
+ }
+}
diff --git a/java/sca/modules/binding-gdata2-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GDataServiceBindingProvider.java b/java/sca/modules/binding-gdata2-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GDataServiceBindingProvider.java
new file mode 100644
index 0000000000..bb5739324c
--- /dev/null
+++ b/java/sca/modules/binding-gdata2-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GDataServiceBindingProvider.java
@@ -0,0 +1,85 @@
+/*
+ * 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.gdata.provider;
+
+import org.apache.tuscany.sca.binding.gdata.GDataBinding;
+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.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+import org.apache.tuscany.sca.runtime.RuntimeWire;
+
+class GDataServiceBindingProvider implements ServiceBindingProvider {
+
+ private RuntimeComponentService service;
+ private GDataBinding binding;
+ private ServletHost servletHost;
+ private MessageFactory messageFactory;
+ private String servletMapping;
+ private Mediator mediator;
+
+ GDataServiceBindingProvider(RuntimeComponent component,
+ RuntimeComponentService service,
+ GDataBinding binding,
+ ServletHost servletHost,
+ MessageFactory messageFactory,
+ Mediator mediator) {
+
+ this.service = service;
+ this.binding = binding;
+ this.servletHost = servletHost;
+ this.messageFactory = messageFactory;
+ this.mediator = mediator;
+ }
+
+ public void start() {
+ RuntimeComponentService componentService = (RuntimeComponentService) service;
+ RuntimeWire wire = componentService.getRuntimeWire(binding);
+
+ GDataBindingListenerServlet servlet =
+ new GDataBindingListenerServlet(wire, messageFactory, mediator, binding.getTitle());
+
+ 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);
+ }
+
+ public InterfaceContract getBindingInterfaceContract() {
+ return service.getInterfaceContract();
+ }
+
+ public boolean supportsOneWayInvocation() {
+ return false;
+ }
+}
diff --git a/java/sca/modules/binding-gdata2-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory b/java/sca/modules/binding-gdata2-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory
new file mode 100644
index 0000000000..7b655eb6b7
--- /dev/null
+++ b/java/sca/modules/binding-gdata2-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.gdata.provider.GDataBindingProviderFactory;model=org.apache.tuscany.sca.binding.gdata.GDataBinding
diff --git a/java/sca/modules/binding-gdata2-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/calendarconsumer/CalendarConsumer.java b/java/sca/modules/binding-gdata2-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/calendarconsumer/CalendarConsumer.java
new file mode 100644
index 0000000000..35a692ac67
--- /dev/null
+++ b/java/sca/modules/binding-gdata2-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/calendarconsumer/CalendarConsumer.java
@@ -0,0 +1,121 @@
+/*
+ * 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.gdata.calendarconsumer;
+
+import com.google.gdata.data.BaseEntry;
+import com.google.gdata.data.DateTime;
+import com.google.gdata.data.Entry;
+import com.google.gdata.data.Feed;
+import com.google.gdata.data.Person;
+import com.google.gdata.data.PlainTextConstruct;
+import com.google.gdata.data.extensions.EventEntry;
+import com.google.gdata.data.extensions.When;
+import org.apache.tuscany.sca.host.embedded.SCADomain;
+
+public class CalendarConsumer {
+
+ public static void main(String... args) throws Exception {
+
+ SCADomain scaDomain;
+ CalendarConsumerImpl resourceCollection;
+
+ //init
+ scaDomain = SCADomain.newInstance("org/apache/tuscany/sca/binding/gdata/CalendarConsumer.composite");
+ resourceCollection = scaDomain.getService(CalendarConsumerImpl.class, "CalendarConsumer");
+
+ //test methods
+ System.out.println(
+ "\n//--------------------------" +
+ "\n// Get the Feed" +
+ "\n//--------------------------\n");
+
+ Feed feed = (Feed) resourceCollection.getFeed();
+
+ System.out.println("Feed content - " + feed.getUpdated().toString() + ":\n");
+ for (Entry e : feed.getEntries()) {
+ System.out.println("# " + e.getTitle().getPlainText());
+ }
+
+ System.out.println(
+ "\n//--------------------------" +
+ "\n// Post a new Entry" +
+ "\n//--------------------------\n");
+
+ EventEntry entry = new EventEntry();
+
+ entry.setTitle(new PlainTextConstruct("GSoC extra activity"));
+ entry.setContent(new PlainTextConstruct("Reading the book Beautiful Code"));
+
+ Person author = new Person("GSoC Student 2008", null, "gsocstudent2008@gmail.com");
+ entry.getAuthors().add(author);
+
+ DateTime startTime = DateTime.parseDateTime("2008-07-30T15:00:00-08:00");
+ DateTime endTime = DateTime.parseDateTime("2008-07-30T17:00:00-08:00");
+ When eventTimes = new When();
+ eventTimes.setStartTime(startTime);
+ eventTimes.setEndTime(endTime);
+ entry.addTime(eventTimes);
+
+ BaseEntry returnedEntry = resourceCollection.post(entry);
+
+ System.out.println("# " + returnedEntry.getTitle().getPlainText());
+
+ System.out.println(
+ "\n//--------------------------" +
+ "\n// Get an Entry" +
+ "\n//--------------------------\n");
+
+ BaseEntry searchedEntry = resourceCollection.get(returnedEntry.getSelfLink().getHref());
+
+ System.out.println("# " + searchedEntry.getTitle().getPlainText());
+
+ System.out.println(
+ "\n//--------------------------" +
+ "\n// Update an Entry" +
+ "\n//--------------------------\n");
+
+ searchedEntry.setTitle(new PlainTextConstruct("GSoC extra activity(opcional)"));
+ BaseEntry updatedEntry = resourceCollection.put(searchedEntry.getEditLink().getHref(), searchedEntry);
+
+ System.out.println("# " + updatedEntry.getTitle().getPlainText());
+
+ System.out.println(
+ "\n//--------------------------" +
+ "\n// Delete an Entry" +
+ "\n//--------------------------\n");
+
+ resourceCollection.delete(updatedEntry.getEditLink().getHref());
+
+ System.out.println(
+ "\n//--------------------------" +
+ "\n// Execute a query" +
+ "\n//--------------------------\n");
+
+ feed = (Feed) resourceCollection.query("Students");
+
+ System.out.println("Feed content - " + feed.getUpdated().toString() + ":\n");
+ for (Entry e : feed.getEntries()) {
+ System.out.println("# " + e.getTitle().getPlainText());
+ }
+
+ //close
+ scaDomain.close();
+
+ }
+}
diff --git a/java/sca/modules/binding-gdata2-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/calendarconsumer/CalendarConsumerImpl.java b/java/sca/modules/binding-gdata2-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/calendarconsumer/CalendarConsumerImpl.java
new file mode 100644
index 0000000000..8da6977c2c
--- /dev/null
+++ b/java/sca/modules/binding-gdata2-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/calendarconsumer/CalendarConsumerImpl.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.gdata.calendarconsumer;
+
+import com.google.gdata.data.BaseEntry;
+import com.google.gdata.data.BaseFeed;
+
+import org.apache.tuscany.sca.binding.gdata.collection.Collection;
+import org.osoa.sca.annotations.Reference;
+
+public class CalendarConsumerImpl {
+
+ @Reference
+ public Collection resourceCollection;
+
+ public BaseFeed getFeed() {
+ return resourceCollection.getFeed();
+ }
+
+ public BaseEntry post(BaseEntry entry) {
+ return resourceCollection.post(entry);
+ }
+
+ public BaseEntry get(String id) throws org.apache.tuscany.sca.implementation.data.collection.NotFoundException {
+ return resourceCollection.get(id);
+ }
+
+ public BaseEntry put(String id, BaseEntry entry) throws org.apache.tuscany.sca.implementation.data.collection.NotFoundException {
+ return resourceCollection.put(id, entry);
+ }
+
+ public void delete(String id) throws org.apache.tuscany.sca.implementation.data.collection.NotFoundException {
+ resourceCollection.delete(id);
+ }
+
+ public BaseFeed query(String queryString) {
+ return resourceCollection.query(queryString);
+ }
+}
diff --git a/java/sca/modules/binding-gdata2-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/calendarconsumer/CalendarConsumerTest.java b/java/sca/modules/binding-gdata2-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/calendarconsumer/CalendarConsumerTest.java
new file mode 100644
index 0000000000..361b9b122d
--- /dev/null
+++ b/java/sca/modules/binding-gdata2-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/calendarconsumer/CalendarConsumerTest.java
@@ -0,0 +1,203 @@
+/*
+ * 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.gdata.calendarconsumer;
+
+import com.google.gdata.data.BaseEntry;
+import com.google.gdata.data.DateTime;
+import com.google.gdata.data.Feed;
+import com.google.gdata.data.Person;
+import com.google.gdata.data.PlainTextConstruct;
+import com.google.gdata.data.extensions.EventEntry;
+import com.google.gdata.data.extensions.When;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import org.apache.tuscany.sca.host.embedded.SCADomain;
+import org.apache.tuscany.sca.implementation.data.collection.NotFoundException;
+
+import org.junit.Test;
+import org.junit.BeforeClass;
+import org.junit.AfterClass;
+import static org.junit.Assert.assertNotNull;
+
+//FIX-ME: the tests are executed in an incorrect order
+public class CalendarConsumerTest {
+
+ private static SCADomain scaDomain;
+ private Feed feed;
+ private BaseEntry returnedEntry;
+ private BaseEntry searchedEntry;
+ private BaseEntry updatedEntry;
+ private static CalendarConsumerImpl consumer;
+
+ @BeforeClass
+ public static void init() {
+ scaDomain = SCADomain.newInstance("org/apache/tuscany/sca/binding/gdata/CalendarConsumer.composite");
+ consumer = scaDomain.getService(CalendarConsumerImpl.class, "CalendarConsumer");
+ }
+
+ @AfterClass
+ public static void close() {
+ scaDomain.close();
+ }
+
+ @Test
+ public void getFeed() {
+ System.out.println("getfeed");
+ feed = (Feed) consumer.getFeed();
+ assertNotNull(feed);
+ }
+
+ @Test
+ public void post() {
+ System.out.println("post");
+ EventEntry entry = new EventEntry();
+
+ entry.setTitle(new PlainTextConstruct("GSoC extra activity"));
+ entry.setContent(new PlainTextConstruct("Reading the book Beautiful Code"));
+
+ Person author = new Person("GSoC Student 2008", null, "gsocstudent2008@gmail.com");
+ entry.getAuthors().add(author);
+
+ DateTime startTime = DateTime.parseDateTime("2008-07-22T15:00:00-08:00");
+ DateTime endTime = DateTime.parseDateTime("2008-07-22T17:00:00-08:00");
+ When eventTimes = new When();
+ eventTimes.setStartTime(startTime);
+ eventTimes.setEndTime(endTime);
+ entry.addTime(eventTimes);
+
+ returnedEntry = consumer.post(entry);
+ assertNotNull(returnedEntry);
+ }
+
+ @Test
+ public void get() {
+ System.out.println("get");
+ try {
+ searchedEntry = consumer.get(returnedEntry.getSelfLink().getHref());
+ assertNotNull(searchedEntry);
+ } catch (NotFoundException ex) {
+ Logger.getLogger(CalendarConsumerTest.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+
+ @Test
+ public void put() {
+ System.out.println("put");
+ try {
+ searchedEntry.setTitle(new PlainTextConstruct("GSoC extra activity(opcional)"));
+ updatedEntry = consumer.put(searchedEntry.getEditLink().getHref(), searchedEntry);
+ assertNotNull(updatedEntry);
+ } catch (NotFoundException ex) {
+ Logger.getLogger(CalendarConsumerTest.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+
+ @Test
+ public void delete() {
+ System.out.println("delete");
+ try {
+ consumer.delete(updatedEntry.getEditLink().getHref());
+ } catch (NotFoundException ex) {
+ Logger.getLogger(CalendarConsumerTest.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+
+ @Test
+ public void query() {
+ System.out.println("query");
+ feed = (Feed) consumer.query("Students");
+ assertNotNull(feed);
+ }// public void testCustomerCollection() throws Exception {
+//
+// System.out.println(
+// "\n//--------------------------" +
+// "\n// Get the Feed" +
+// "\n//--------------------------\n");
+//
+// Feed feed = (Feed) resourceCollection.getFeed();
+//
+// System.out.println("Feed content - " + feed.getUpdated().toString() + ":\n");
+// for (Entry e : feed.getEntries()) {
+// System.out.println("# " + e.getTitle().getPlainText());
+// }
+//
+// System.out.println(
+// "\n//--------------------------" +
+// "\n// Post a new Entry" +
+// "\n//--------------------------\n");
+//
+// EventEntry entry = new EventEntry();
+//
+// entry.setTitle(new PlainTextConstruct("GSoC extra activity"));
+// entry.setContent(new PlainTextConstruct("Reading the book Beautiful Code"));
+//
+// Person author = new Person("GSoC Student 2008", null, "gsocstudent2008@gmail.com");
+// entry.getAuthors().add(author);
+//
+// DateTime startTime = DateTime.parseDateTime("2008-06-19T15:00:00-08:00");
+// DateTime endTime = DateTime.parseDateTime("2008-06-19T17:00:00-08:00");
+// When eventTimes = new When();
+// eventTimes.setStartTime(startTime);
+// eventTimes.setEndTime(endTime);
+// entry.addTime(eventTimes);
+//
+// BaseEntry returnedEntry = resourceCollection.post(entry);
+//
+// System.out.println("# " + returnedEntry.getTitle().getPlainText());
+//
+// System.out.println(
+// "\n//--------------------------" +
+// "\n// Get an Entry" +
+// "\n//--------------------------\n");
+//
+// BaseEntry searchedEntry = resourceCollection.get(returnedEntry.getSelfLink().getHref());
+//
+// System.out.println("# " + searchedEntry.getTitle().getPlainText());
+//
+// System.out.println(
+// "\n//--------------------------" +
+// "\n// Update an Entry" +
+// "\n//--------------------------\n");
+//
+// searchedEntry.setTitle(new PlainTextConstruct("GSoC extra activity(opcional)"));
+// BaseEntry updatedEntry = resourceCollection.put(searchedEntry.getEditLink().getHref(), searchedEntry);
+//
+// System.out.println("# " + updatedEntry.getTitle().getPlainText());
+//
+// System.out.println(
+// "\n//--------------------------" +
+// "\n// Delete an Entry" +
+// "\n//--------------------------\n");
+//
+// resourceCollection.delete(updatedEntry.getEditLink().getHref());
+//
+// System.out.println(
+// "\n//--------------------------" +
+// "\n// Execute a query" +
+// "\n//--------------------------\n");
+//
+// feed = (Feed) resourceCollection.query("Students");
+//
+// System.out.println("Feed content - " + feed.getUpdated().toString() + ":\n");
+// for (Entry e : feed.getEntries()) {
+// System.out.println("# " + e.getTitle().getPlainText());
+// }
+//
+// }
+}
diff --git a/java/sca/modules/binding-gdata2-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/consumerprovider/Consumer.java b/java/sca/modules/binding-gdata2-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/consumerprovider/Consumer.java
new file mode 100644
index 0000000000..00055f28b2
--- /dev/null
+++ b/java/sca/modules/binding-gdata2-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/consumerprovider/Consumer.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.gdata.consumerprovider;
+
+import org.apache.tuscany.sca.host.embedded.SCADomain;
+
+public class Consumer {
+
+ public static void main(String[] args) throws Exception {
+
+ SCADomain scaDomain = SCADomain.newInstance("org/apache/tuscany/sca/binding/gdata/Consumer.composite");
+
+ CustomerClient testService = scaDomain.getService(CustomerClient.class, "CustomerClient");
+
+ testService.testCustomerCollection();
+
+ scaDomain.close();
+ }
+}
diff --git a/java/sca/modules/binding-gdata2-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/consumerprovider/CustomerClient.java b/java/sca/modules/binding-gdata2-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/consumerprovider/CustomerClient.java
new file mode 100644
index 0000000000..1d42c9b1a4
--- /dev/null
+++ b/java/sca/modules/binding-gdata2-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/consumerprovider/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.gdata.consumerprovider;
+
+public interface CustomerClient {
+
+ void testCustomerCollection() throws Exception;
+}
diff --git a/java/sca/modules/binding-gdata2-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/consumerprovider/CustomerClientImpl.java b/java/sca/modules/binding-gdata2-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/consumerprovider/CustomerClientImpl.java
new file mode 100644
index 0000000000..d6261618bf
--- /dev/null
+++ b/java/sca/modules/binding-gdata2-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/consumerprovider/CustomerClientImpl.java
@@ -0,0 +1,117 @@
+/*
+ * 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.gdata.consumerprovider;
+
+import com.google.gdata.data.BaseEntry;
+import com.google.gdata.data.BaseFeed;
+import com.google.gdata.data.DateTime;
+import com.google.gdata.data.Entry;
+import com.google.gdata.data.Feed;
+import com.google.gdata.data.Person;
+import com.google.gdata.data.PlainTextConstruct;
+import com.google.gdata.data.Source;
+import com.google.gdata.data.extensions.EventEntry;
+import com.google.gdata.data.extensions.When;
+import org.apache.tuscany.sca.binding.gdata.collection.Collection;
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Scope;
+
+@Scope("COMPOSITE")
+public class CustomerClientImpl implements CustomerClient {
+
+ @Reference
+ public Collection resourceCollection;
+
+ public void testCustomerCollection() throws Exception {
+
+ System.out.println(
+ "\n//--------------------------" +
+ "\n// Get the Feed" +
+ "\n//--------------------------\n");
+
+ BaseFeed<? extends BaseFeed, ? extends BaseEntry> feed = resourceCollection.getFeed();
+
+ System.out.println("Feed content - " + feed.getUpdated().toString() + ":\n");
+ for (BaseEntry e : feed.getEntries()) {
+ System.out.println("# " + e.getTitle().getPlainText());
+ }
+
+ System.out.println(
+ "\n//--------------------------" +
+ "\n// Post a new Entry" +
+ "\n//--------------------------\n");
+
+ EventEntry entry = new EventEntry();
+
+ entry.setTitle(new PlainTextConstruct("Activity"));
+ entry.setContent(new PlainTextConstruct("Reading the book Beautiful Code"));
+
+ Person author = new Person("GSoC Student 2008", null, "gsocstudent2008@gmail.com");
+ entry.getAuthors().add(author);
+
+ DateTime startTime = DateTime.parseDateTime("2008-06-19T15:00:00-08:00");
+ DateTime endTime = DateTime.parseDateTime("2008-06-19T17:00:00-08:00");
+ When eventTimes = new When();
+ eventTimes.setStartTime(startTime);
+ eventTimes.setEndTime(endTime);
+ entry.addTime(eventTimes);
+
+ BaseEntry returnedEntry = resourceCollection.post(entry);
+
+ System.out.println("# " + returnedEntry.getTitle().getPlainText());
+
+ System.out.println(
+ "\n//--------------------------" +
+ "\n// Get an Entry" +
+ "\n//--------------------------\n");
+
+ BaseEntry searchedEntry = resourceCollection.get(returnedEntry.getId());
+ System.out.println("# " + searchedEntry.getTitle().getPlainText());
+
+
+ System.out.println(
+ "\n//--------------------------" +
+ "\n// Update an Entry" +
+ "\n//--------------------------\n");
+
+ searchedEntry.setTitle(new PlainTextConstruct("Activity (opcional)"));
+ BaseEntry updatedEntry = resourceCollection.put(searchedEntry.getId(), searchedEntry);
+
+ System.out.println("# " + updatedEntry.getTitle().getPlainText());
+
+ System.out.println(
+ "\n//--------------------------" +
+ "\n// Delete an Entry" +
+ "\n//--------------------------\n");
+
+ resourceCollection.delete(updatedEntry.getId());
+
+ System.out.println(
+ "\n//--------------------------" +
+ "\n// Execute a query" +
+ "\n//--------------------------\n");
+
+ feed = (Feed)(Source) resourceCollection.query("GSoC");
+
+ System.out.println("Feed content - " + feed.getUpdated().toString() + ":\n");
+ for (BaseEntry e : feed.getEntries()) {
+ System.out.println("# " + e.getTitle().getPlainText());
+ }
+ }
+}
diff --git a/java/sca/modules/binding-gdata2-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/consumerprovider/CustomerCollectionImpl.java b/java/sca/modules/binding-gdata2-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/consumerprovider/CustomerCollectionImpl.java
new file mode 100644
index 0000000000..8233d01dd9
--- /dev/null
+++ b/java/sca/modules/binding-gdata2-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/consumerprovider/CustomerCollectionImpl.java
@@ -0,0 +1,116 @@
+/*
+ * 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.gdata.consumerprovider;
+
+import com.google.gdata.data.BaseEntry;
+import com.google.gdata.data.BaseFeed;
+import com.google.gdata.data.DateTime;
+import com.google.gdata.data.Entry;
+import com.google.gdata.data.Feed;
+import com.google.gdata.data.PlainTextConstruct;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.TimeZone;
+import java.util.UUID;
+import org.apache.tuscany.sca.binding.gdata.collection.Collection;
+import org.apache.tuscany.sca.implementation.data.collection.NotFoundException;
+import org.osoa.sca.annotations.Scope;
+
+@Scope("COMPOSITE")
+public class CustomerCollectionImpl implements Collection {
+
+ private Map<String, BaseEntry> entries;
+
+ public CustomerCollectionImpl() {
+ entries = new HashMap<String, BaseEntry>();
+
+ BaseEntry entry = new Entry();
+ entry.setId("urn:uuid:customer-0");
+ entry.setTitle(new PlainTextConstruct("An exampling entry - GSoC"));
+
+ entries.put(entry.getId(), entry);
+ }
+
+ public BaseFeed<? extends BaseFeed, ? extends BaseEntry> getFeed() {
+ System.out.println(">>> CustomerCollectionImpl.getFeed");
+
+ BaseFeed feed = new Feed();
+ feed.setTitle(new PlainTextConstruct("Customers Feed"));
+ feed.setSubtitle(new PlainTextConstruct("This is a sample feed"));
+ feed.setUpdated(new DateTime());
+
+ //FIX-ME
+ //feed.addHtmlLink("", "", ""); //feed.addLink("");
+ //feed.addHtmlLink("", "self", ""); //feed.addLink("", "self");
+ feed.addHtmlLink("http://localhost:8086/customer", "", "");
+
+ feed.setEntries(new ArrayList(entries.values()));
+
+ return feed;
+ }
+
+ public BaseFeed<? extends BaseFeed, ? extends BaseEntry> query(String queryString) {
+ System.out.println(">>> CustomerCollectionImpl.query collection " + queryString);
+ return getFeed();
+ }
+
+ public BaseEntry post(BaseEntry entry) {
+ System.out.println(">>> CustomerCollectionImpl.post entry=" + entry.getTitle().getPlainText());
+
+ String id = "urn:uuid:customer-" + UUID.randomUUID().toString();
+ entry.setId(id);
+
+ //FIX-ME
+ entry.addHtmlLink("" + id, "edit", "");
+ entry.addHtmlLink("" + id, "alternate", "");
+
+ DateTime dateTime = new DateTime(new Date(), TimeZone.getTimeZone("America/Los_Angeles"));
+ entry.setUpdated(dateTime);
+
+ entries.put(id, entry);
+
+ System.out.println(">>> CustomerCollectionImpl.post return id=" + id);
+
+ return entry;
+ }
+
+ public BaseEntry get(String id) throws NotFoundException {
+ System.out.println(">>> CustomerCollectionImpl.get id=" + id);
+
+ return entries.get(id);
+ }
+
+ public BaseEntry put(String id, BaseEntry entry) throws NotFoundException {
+ System.out.println(">>> CustomerCollectionImpl.put id=" + id + " entry=" + entry.getTitle());
+
+ DateTime dateTime = new DateTime(new Date(), TimeZone.getTimeZone("America/Los_Angeles"));
+ entry.setUpdated(dateTime);
+
+ entries.put(id, entry);
+
+ return entries.get(id);
+ }
+
+ public void delete(String id) throws NotFoundException {
+ System.out.println(">>> CustomerCollectionImpl.delete id=" + id);
+ entries.remove(id);
+ }
+}
diff --git a/java/sca/modules/binding-gdata2-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/consumerprovider/Provider.java b/java/sca/modules/binding-gdata2-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/consumerprovider/Provider.java
new file mode 100644
index 0000000000..9beca538df
--- /dev/null
+++ b/java/sca/modules/binding-gdata2-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/consumerprovider/Provider.java
@@ -0,0 +1,34 @@
+/*
+ * 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.gdata.consumerprovider;
+
+import org.apache.tuscany.sca.host.embedded.SCADomain;
+
+public class Provider {
+
+ public static void main(String[] args) throws Exception {
+
+ SCADomain scaDomain = SCADomain.newInstance("org/apache/tuscany/sca/binding/gdata/Provider.composite");
+
+ System.out.println("Ready for consultings...");
+ System.in.read();
+
+ scaDomain.close();
+ }
+}
diff --git a/java/sca/modules/binding-gdata2-runtime/src/test/resources/org/apache/tuscany/sca/binding/gdata/CalendarConsumer.composite b/java/sca/modules/binding-gdata2-runtime/src/test/resources/org/apache/tuscany/sca/binding/gdata/CalendarConsumer.composite
new file mode 100644
index 0000000000..a208852f16
--- /dev/null
+++ b/java/sca/modules/binding-gdata2-runtime/src/test/resources/org/apache/tuscany/sca/binding/gdata/CalendarConsumer.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://www.osoa.org/xmlns/sca/1.0"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0"
+ targetNamespace="http://customer"
+ name="CalendarConsumerComposite">
+
+ <component name="CalendarConsumer">
+ <implementation.java class="org.apache.tuscany.sca.binding.gdata.calendarconsumer.CalendarConsumerImpl"/>
+ <reference name="resourceCollection">
+ <tuscany:binding.gdata uri="http://www.google.com/calendar/feeds/gsocstudent2008@gmail.com/private/full" serviceType="cl" username="gsocstudent2008@gmail.com" password="gsoc2008"/>
+ </reference>
+ </component>
+
+</composite> \ No newline at end of file
diff --git a/java/sca/modules/binding-gdata2-runtime/src/test/resources/org/apache/tuscany/sca/binding/gdata/Consumer.composite b/java/sca/modules/binding-gdata2-runtime/src/test/resources/org/apache/tuscany/sca/binding/gdata/Consumer.composite
new file mode 100644
index 0000000000..e381f458b6
--- /dev/null
+++ b/java/sca/modules/binding-gdata2-runtime/src/test/resources/org/apache/tuscany/sca/binding/gdata/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://www.osoa.org/xmlns/sca/1.0"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0"
+ targetNamespace="http://customer"
+ name="Consumer">
+
+ <component name="CustomerClient">
+ <implementation.java class="org.apache.tuscany.sca.binding.gdata.consumerprovider.CustomerClientImpl"/>
+ <reference name="resourceCollection">
+ <tuscany:binding.gdata uri="http://localhost:8086/customer" username="gsocstudent2008" password="gsoc2008" serviceType="sca"/>
+ </reference>
+ </component>
+
+</composite>
diff --git a/java/sca/modules/binding-gdata2-runtime/src/test/resources/org/apache/tuscany/sca/binding/gdata/Provider.composite b/java/sca/modules/binding-gdata2-runtime/src/test/resources/org/apache/tuscany/sca/binding/gdata/Provider.composite
new file mode 100644
index 0000000000..e7ddb38ff0
--- /dev/null
+++ b/java/sca/modules/binding-gdata2-runtime/src/test/resources/org/apache/tuscany/sca/binding/gdata/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://www.osoa.org/xmlns/sca/1.0"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0"
+ targetNamespace = "http://customer"
+ name="Provider">
+
+ <service name="customer" promote="CustomerCollection">
+ <tuscany:binding.gdata uri = "http://localhost:8086/customer" username="gsocstudent2008" password="gsoc2008" serviceType="cl"/>
+ </service>
+
+ <component name="CustomerCollection">
+ <implementation.java class="org.apache.tuscany.sca.binding.gdata.consumerprovider.CustomerCollectionImpl"/>
+ </component>
+
+</composite>
diff --git a/java/sca/modules/binding-gdata2/LICENSE b/java/sca/modules/binding-gdata2/LICENSE
new file mode 100644
index 0000000000..6e529a25c4
--- /dev/null
+++ b/java/sca/modules/binding-gdata2/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/java/sca/modules/binding-gdata2/NOTICE b/java/sca/modules/binding-gdata2/NOTICE
new file mode 100644
index 0000000000..1325efd8bf
--- /dev/null
+++ b/java/sca/modules/binding-gdata2/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2008 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/java/sca/modules/binding-gdata2/pom.xml b/java/sca/modules/binding-gdata2/pom.xml
new file mode 100644
index 0000000000..b0747685d3
--- /dev/null
+++ b/java/sca/modules/binding-gdata2/pom.xml
@@ -0,0 +1,73 @@
+<?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-gdata2</artifactId>
+ <name>Apache Tuscany SCA Gdata Binding Extension GSOC</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-assembly-xml</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.5</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+
+ <configuration>
+ <instructions>
+ <Bundle-Version>${tuscany.version}</Bundle-Version>
+ <Bundle-SymbolicName>org.apache.tuscany.sca.binding.atom</Bundle-SymbolicName>
+ <Bundle-Description>${pom.name}</Bundle-Description>
+ <Export-Package>org.apache.tuscany.sca.binding.atom*</Export-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/java/sca/modules/binding-gdata2/src/main/java/org/apache/tuscany/sca/binding/gdata/GDataBinding.java b/java/sca/modules/binding-gdata2/src/main/java/org/apache/tuscany/sca/binding/gdata/GDataBinding.java
new file mode 100644
index 0000000000..c1868f05dc
--- /dev/null
+++ b/java/sca/modules/binding-gdata2/src/main/java/org/apache/tuscany/sca/binding/gdata/GDataBinding.java
@@ -0,0 +1,77 @@
+/*
+ * 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.gdata;
+
+import org.apache.tuscany.sca.assembly.Binding;
+
+/**
+ * GData binding model.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface GDataBinding extends Binding {
+
+ /**
+ * Returns the title of the Atom collection.
+ * @return
+ */
+ String getTitle();
+
+ /**
+ * Sets the title of the Atom collection.
+ * @param title
+ */
+ void setTitle(String title);
+
+ /*
+ * Returns the username of a Google account
+ * @return
+ */
+ String getUsername();
+
+ /*
+ * Sets the username of a Google account
+ * @param username
+ */
+ void setUsername(String username);
+
+ /*
+ * Returns the password of a Google account
+ * @return
+ */
+ String getPassword();
+
+ /*
+ * Sets the password of a Google account
+ * @param password
+ */
+ void setPassword(String password);
+
+ /*
+ * Retruns the name of the Google service to which we are connecting. Sample names of services might include "cl" (Calendar), "mail" (GMail), or "blogger" (Blogger)
+ * @return
+ */
+ String getServiceType();
+
+ /*
+ * Sets the name of the Google service to which we are connecting. Sample names of services might include "cl" (Calendar), "mail" (GMail), or "blogger" (Blogger)
+ * @param serviceType
+ */
+ void setServiceType(String serviceType);
+}
diff --git a/java/sca/modules/binding-gdata2/src/main/java/org/apache/tuscany/sca/binding/gdata/GDataBindingFactory.java b/java/sca/modules/binding-gdata2/src/main/java/org/apache/tuscany/sca/binding/gdata/GDataBindingFactory.java
new file mode 100644
index 0000000000..ec2f179fdb
--- /dev/null
+++ b/java/sca/modules/binding-gdata2/src/main/java/org/apache/tuscany/sca/binding/gdata/GDataBindingFactory.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.gdata;
+
+/**
+ * Factory for the GData binding
+ *
+ * @version $Rev$ $Date$
+ */
+public interface GDataBindingFactory {
+
+ /**
+ * Creates a new Atom binding.
+ * @return the new Atom binding
+ */
+ GDataBinding createAtomBinding();
+
+}
diff --git a/java/sca/modules/binding-gdata2/src/main/java/org/apache/tuscany/sca/binding/gdata/GDataImplementationProcessor.java b/java/sca/modules/binding-gdata2/src/main/java/org/apache/tuscany/sca/binding/gdata/GDataImplementationProcessor.java
new file mode 100644
index 0000000000..5797629bed
--- /dev/null
+++ b/java/sca/modules/binding-gdata2/src/main/java/org/apache/tuscany/sca/binding/gdata/GDataImplementationProcessor.java
@@ -0,0 +1,100 @@
+/*
+ * 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.gdata;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.assembly.xml.Constants;
+import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.contribution.service.ContributionResolveException;
+import org.apache.tuscany.sca.monitor.Monitor;
+
+public class GDataImplementationProcessor implements StAXArtifactProcessor<GDataBinding> {
+
+ private GDataBindingFactory gdataFactory;
+ protected static final QName BINDING_GDATA = new QName(Constants.SCA10_TUSCANY_NS, "binding.gdata");
+
+ public GDataImplementationProcessor(ModelFactoryExtensionPoint modelFactories, Monitor monitor) {
+
+ this.gdataFactory = (GDataBindingFactory) modelFactories.getFactory(GDataBindingFactory.class);
+ }
+
+ public GDataBinding read(XMLStreamReader reader) {
+
+ assert BINDING_GDATA.equals(reader.getName());
+
+ GDataBinding gdataBinding = gdataFactory.createAtomBinding();
+
+ /*
+ * <tuscany:binding.gdata uri="..."
+ * login="..."
+ * password="..."/>
+ */
+
+ String uri = reader.getAttributeValue(null, "uri");
+ String serviceType = reader.getAttributeValue(null, "serviceType");
+ String login = reader.getAttributeValue(null, "username");
+ String password = reader.getAttributeValue(null, "password");
+
+ gdataBinding.setURI(uri);
+ gdataBinding.setServiceType(serviceType);
+ gdataBinding.setUsername(login);
+ gdataBinding.setPassword(password);
+
+ return gdataBinding;
+ }
+
+ public void write(GDataBinding gdataBinding, XMLStreamWriter writer) throws XMLStreamException {
+ if (gdataBinding != null) {
+ writer.writeStartElement(BINDING_GDATA.getNamespaceURI(), BINDING_GDATA.getLocalPart());
+
+ if (gdataBinding.getURI() != null) {
+ writer.writeAttribute("uri", gdataBinding.getURI());
+ }
+
+ if (gdataBinding.getServiceType() != null) {
+ writer.writeAttribute("serviceType", gdataBinding.getServiceType());
+ }
+ if (gdataBinding.getUsername() != null) {
+ writer.writeAttribute("username", gdataBinding.getUsername());
+ }
+ if (gdataBinding.getPassword() != null) {
+ writer.writeAttribute("password", gdataBinding.getPassword());
+ }
+
+ writer.writeEndElement();
+ }
+ }
+
+ public QName getArtifactType() {
+ return BINDING_GDATA;
+ }
+
+ public void resolve(GDataBinding arg0, ModelResolver arg1) throws ContributionResolveException {
+ }
+
+ public Class<GDataBinding> getModelType() {
+ return GDataBinding.class;
+ }
+}
diff --git a/java/sca/modules/binding-gdata2/src/main/java/org/apache/tuscany/sca/binding/gdata/impl/GDataBindingFactoryImpl.java b/java/sca/modules/binding-gdata2/src/main/java/org/apache/tuscany/sca/binding/gdata/impl/GDataBindingFactoryImpl.java
new file mode 100644
index 0000000000..e0c3bfbe78
--- /dev/null
+++ b/java/sca/modules/binding-gdata2/src/main/java/org/apache/tuscany/sca/binding/gdata/impl/GDataBindingFactoryImpl.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.gdata.impl;
+
+import org.apache.tuscany.sca.binding.gdata.GDataBinding;
+import org.apache.tuscany.sca.binding.gdata.GDataBindingFactory;
+
+/**
+ * Factory for the GData binding model.
+ *
+ * @version $Rev$ $Date$
+ */
+public class GDataBindingFactoryImpl implements GDataBindingFactory {
+
+ public GDataBinding createAtomBinding() {
+ return new GDataBindingImpl();
+ }
+
+}
diff --git a/java/sca/modules/binding-gdata2/src/main/java/org/apache/tuscany/sca/binding/gdata/impl/GDataBindingImpl.java b/java/sca/modules/binding-gdata2/src/main/java/org/apache/tuscany/sca/binding/gdata/impl/GDataBindingImpl.java
new file mode 100644
index 0000000000..baba882c4c
--- /dev/null
+++ b/java/sca/modules/binding-gdata2/src/main/java/org/apache/tuscany/sca/binding/gdata/impl/GDataBindingImpl.java
@@ -0,0 +1,137 @@
+/*
+ * 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.gdata.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.binding.gdata.GDataBinding;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.IntentAttachPointType;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
+
+/**
+ * Implementation of the GData binding model.
+ *
+ * @version $Rev$ $Date$
+ */
+class GDataBindingImpl implements GDataBinding, PolicySetAttachPoint {
+
+ private String password;
+ private String username;
+ private String name;
+ private String serviceType;
+ private String uri;
+ private String title;
+ private List<Intent> requiredIntents = new ArrayList<Intent>();
+ private List<PolicySet> policySets = new ArrayList<PolicySet>();
+ private IntentAttachPointType intentAttachPointType;
+ private List<PolicySet> applicablePolicySets = new ArrayList<PolicySet>();
+
+ public List<PolicySet> getApplicablePolicySets() {
+ return applicablePolicySets;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getURI() {
+ return uri;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void setURI(String uri) {
+ this.uri = uri;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public boolean isUnresolved() {
+ // The binding is always resolved
+ return false;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ // The binding is always resolved
+ }
+
+ public List<PolicySet> getPolicySets() {
+ return policySets;
+ }
+
+ public List<Intent> getRequiredIntents() {
+ return requiredIntents;
+ }
+
+ public IntentAttachPointType getType() {
+ return intentAttachPointType;
+ }
+
+ public void setType(IntentAttachPointType intentAttachPointType) {
+ this.intentAttachPointType = intentAttachPointType;
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+
+ public void setPolicySets(List<PolicySet> policySets) {
+ this.policySets = policySets;
+ }
+
+ public void setRequiredIntents(List<Intent> intents) {
+ this.requiredIntents = intents;
+ }
+
+ public String getUsername() {
+ return this.username;
+ }
+
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+ public String getPassword() {
+ return this.password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ public String getServiceType() {
+ return this.serviceType;
+ }
+
+ public void setServiceType(String serviceType) {
+ this.serviceType = serviceType;
+ }
+}
diff --git a/java/sca/modules/binding-gdata2/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.gdata.GDataBindingFactory b/java/sca/modules/binding-gdata2/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.gdata.GDataBindingFactory
new file mode 100644
index 0000000000..48be99b507
--- /dev/null
+++ b/java/sca/modules/binding-gdata2/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.gdata.GDataBindingFactory
@@ -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.gdata.impl.GDataBindingFactoryImpl \ No newline at end of file
diff --git a/java/sca/modules/binding-gdata2/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/java/sca/modules/binding-gdata2/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
new file mode 100644
index 0000000000..92aad3d44d
--- /dev/null
+++ b/java/sca/modules/binding-gdata2/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
@@ -0,0 +1,21 @@
+# 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.0#binding.gdata,model=org.apache.tuscany.sca.binding.gdata.GDataBinding,factory=org.apache.tuscany.sca.binding.gdata.GDataBindingFactory
+org.apache.tuscany.sca.binding.gdata.GDataImplementationProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.0#binding.gdata,model=org.apache.tuscany.sca.binding.gdata.GDataBinding,factory=org.apache.tuscany.sca.binding.gdata.GDataBindingFactory \ No newline at end of file
diff --git a/java/sca/modules/core-spring/LICENSE b/java/sca/modules/core-spring/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/java/sca/modules/core-spring/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/java/sca/modules/core-spring/NOTICE b/java/sca/modules/core-spring/NOTICE
new file mode 100644
index 0000000000..fdfa0e9faa
--- /dev/null
+++ b/java/sca/modules/core-spring/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2008 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/java/sca/modules/core-spring/pom.xml b/java/sca/modules/core-spring/pom.xml
new file mode 100644
index 0000000000..15156bd980
--- /dev/null
+++ b/java/sca/modules/core-spring/pom.xml
@@ -0,0 +1,126 @@
+<?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-core-spring</artifactId>
+ <name>Apache Tuscany SCA Spring-based Core Runtime</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-implementation-java</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-core</artifactId>
+ <version>2.5.5</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-beans</artifactId>
+ <version>2.5.5</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ <version>2.5.5</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-java-xml</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-xml</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-sca</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ </dependencies>
+
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+
+ <configuration>
+ <instructions>
+ <Bundle-Version>${tuscany.version}</Bundle-Version>
+ <Bundle-SymbolicName>org.apache.tuscany.sca.core.spring</Bundle-SymbolicName>
+ <Bundle-Description>${pom.name}</Bundle-Description>
+ <Export-Package>org.apache.tuscany.sca.core.spring*</Export-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/java/sca/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/assembly/impl/BeanAssemblyFactory.java b/java/sca/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/assembly/impl/BeanAssemblyFactory.java
new file mode 100644
index 0000000000..94bd5c8cf2
--- /dev/null
+++ b/java/sca/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/assembly/impl/BeanAssemblyFactory.java
@@ -0,0 +1,134 @@
+/*
+ * 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.core.spring.assembly.impl;
+
+import org.apache.tuscany.sca.assembly.AbstractProperty;
+import org.apache.tuscany.sca.assembly.AbstractReference;
+import org.apache.tuscany.sca.assembly.AbstractService;
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Callback;
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentProperty;
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.ComponentType;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.CompositeReference;
+import org.apache.tuscany.sca.assembly.CompositeService;
+import org.apache.tuscany.sca.assembly.ConfiguredOperation;
+import org.apache.tuscany.sca.assembly.ConstrainingType;
+import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory;
+import org.apache.tuscany.sca.assembly.Property;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.assembly.Wire;
+import org.springframework.beans.factory.support.BeanDefinitionRegistry;
+
+/**
+ * An alternate implementation of the SCA assembly model factory that creates SCA
+ * assembly model objects backed by Spring bean definitions.
+ *
+ * @version $Rev$ $Date$
+ */
+public class BeanAssemblyFactory implements AssemblyFactory {
+ private AssemblyFactory defaultFactory;
+ private BeanDefinitionRegistry beanRegistry;
+
+ public BeanAssemblyFactory(AssemblyFactory defaultFactory, BeanDefinitionRegistry beanRegistry) {
+ this.defaultFactory = defaultFactory;
+ this.beanRegistry = beanRegistry;
+ }
+
+ public BeanAssemblyFactory(BeanDefinitionRegistry beanRegistry) {
+ this(new DefaultAssemblyFactory(), beanRegistry);
+ }
+
+ public AbstractProperty createAbstractProperty() {
+ return defaultFactory.createAbstractProperty();
+ }
+
+ public AbstractReference createAbstractReference() {
+ return defaultFactory.createAbstractReference();
+ }
+
+ public AbstractService createAbstractService() {
+ return defaultFactory.createAbstractService();
+ }
+
+ public Callback createCallback() {
+ return defaultFactory.createCallback();
+ }
+
+ public Component createComponent() {
+ return new BeanComponentImpl(beanRegistry);
+ }
+
+ public ComponentProperty createComponentProperty() {
+ return defaultFactory.createComponentProperty();
+ }
+
+ public ComponentReference createComponentReference() {
+ return defaultFactory.createComponentReference();
+ }
+
+ public ComponentService createComponentService() {
+ return defaultFactory.createComponentService();
+ }
+
+ public ComponentType createComponentType() {
+ return defaultFactory.createComponentType();
+ }
+
+ public Composite createComposite() {
+ return defaultFactory.createComposite();
+ }
+
+ public CompositeReference createCompositeReference() {
+ return defaultFactory.createCompositeReference();
+ }
+
+ public CompositeService createCompositeService() {
+ return defaultFactory.createCompositeService();
+ }
+
+ public ConstrainingType createConstrainingType() {
+ return defaultFactory.createConstrainingType();
+ }
+
+ public Property createProperty() {
+ return defaultFactory.createProperty();
+ }
+
+ public Reference createReference() {
+ return defaultFactory.createReference();
+ }
+
+ public Service createService() {
+ return defaultFactory.createService();
+ }
+
+ public Wire createWire() {
+ return defaultFactory.createWire();
+ }
+
+ public ConfiguredOperation createConfiguredOperation() {
+ return defaultFactory.createConfiguredOperation();
+ }
+
+}
diff --git a/java/sca/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/assembly/impl/BeanComponentImpl.java b/java/sca/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/assembly/impl/BeanComponentImpl.java
new file mode 100644
index 0000000000..f2c517b092
--- /dev/null
+++ b/java/sca/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/assembly/impl/BeanComponentImpl.java
@@ -0,0 +1,233 @@
+/*
+ * 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.core.spring.assembly.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentProperty;
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.ConstrainingType;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.IntentAttachPointType;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.springframework.beans.factory.support.BeanDefinitionRegistry;
+import org.springframework.beans.factory.support.AbstractBeanDefinition;
+import org.springframework.beans.factory.support.GenericBeanDefinition;
+
+/**
+ * An implementation of the SCA assembly Component interface backed by a Spring
+ * Bean definition.
+ *
+ * @version $Rev$ $Date$
+ */
+public class BeanComponentImpl extends GenericBeanDefinition implements Component, Cloneable {
+ private List<PolicySet> applicablePolicySets = new ArrayList<PolicySet>();
+
+ public IntentAttachPointType getType() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void setType(IntentAttachPointType type) {
+ // TODO Auto-generated method stub
+
+ }
+
+ private static final long serialVersionUID = 1L;
+
+ private ConstrainingType constrainingType;
+ private Implementation implementation;
+ private String name;
+ private String uri;
+ private List<ComponentService> services = new ArrayList<ComponentService>();
+ private List<Intent> requiredIntents = new ArrayList<Intent>();
+ private List<PolicySet> policySets = new ArrayList<PolicySet>();
+ private List<Object> extensions = new ArrayList<Object>();
+ private boolean unresolved = false;
+ private BeanDefinitionRegistry beanRegistry;
+
+ protected BeanComponentImpl(BeanDefinitionRegistry beanRegistry) {
+ //super((String)"");
+ this.beanRegistry = beanRegistry;
+ }
+
+ @Override
+ public AbstractBeanDefinition cloneBeanDefinition() {
+ BeanComponentImpl clone = (BeanComponentImpl)super.cloneBeanDefinition();
+ clone.getProperties().clear();
+ try {
+ for (ComponentProperty property : getProperties()) {
+ clone.getProperties().add((ComponentProperty)property.clone());
+ }
+ clone.getReferences().clear();
+ for (ComponentReference reference : getReferences()) {
+ clone.getReferences().add((ComponentReference)reference.clone());
+ }
+ clone.getServices().clear();
+ for (ComponentService service : getServices()) {
+ clone.getServices().add((ComponentService)service.clone());
+ }
+ return clone;
+ } catch (CloneNotSupportedException e) {
+ //throw new CloneNotSupportedException(e.getMessage());
+ }
+ return clone;
+ }
+
+ @Override
+ public String getParentName() {
+ //TODO find a better name for bean definitions representing component types
+ return String.valueOf(System.identityHashCode(implementation));
+ }
+
+ public ConstrainingType getConstrainingType() {
+ return constrainingType;
+ }
+
+ public Implementation getImplementation() {
+ return implementation;
+ }
+
+ public String getURI() {
+ return uri;
+ }
+
+ public void setURI(String uri) {
+ this.uri = uri;
+
+ // Register this bean definition in the bean registry
+ this.beanRegistry.registerBeanDefinition(uri, this);
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ //TODO use a better list implementation
+ private List<ComponentProperty> properties = new ArrayList<ComponentProperty>() {
+ private static final long serialVersionUID = 1L;
+
+ // Add a property
+ @Override
+ public boolean add(ComponentProperty property) {
+
+ // Add corresponding bean property value
+ getPropertyValues().addPropertyValue(property.getName(), property.getValue());
+
+ return super.add(property);
+ }
+ };
+
+ public List<ComponentProperty> getProperties() {
+ return properties;
+ }
+
+ //TODO use a better list implementation
+ private List<ComponentReference> references = new ArrayList<ComponentReference>() {
+ private static final long serialVersionUID = 1L;
+
+ // Add a reference
+ @Override
+ public boolean add(ComponentReference reference) {
+
+ // Add corresponding bean property value
+ if (!reference.getName().startsWith("$self$.")) {
+ BeanReferenceImpl beanReference = new BeanReferenceImpl(reference);
+ getPropertyValues().addPropertyValue(reference.getName(), beanReference);
+ }
+ return super.add(reference);
+ }
+ };
+
+ public List<ComponentReference> getReferences() {
+ return references;
+ }
+
+ public List<ComponentService> getServices() {
+ return services;
+ }
+
+ public void setConstrainingType(ConstrainingType constrainingType) {
+ this.constrainingType = constrainingType;
+ }
+
+ public void setImplementation(Implementation implementation) {
+ this.implementation = implementation;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public List<Intent> getRequiredIntents() {
+ return requiredIntents;
+ }
+
+ public List<PolicySet> getPolicySets() {
+ return policySets;
+ }
+
+ public boolean isAutowire() {
+ return super.getAutowireMode() == AUTOWIRE_BY_TYPE;
+ }
+
+ public Boolean getAutowire() {
+ int autowire = super.getAutowireMode();
+ if (autowire == AUTOWIRE_BY_TYPE) {
+ return Boolean.TRUE;
+ } else if (autowire == AUTOWIRE_NO) {
+ return Boolean.FALSE;
+ } else {
+ return null;
+ }
+ }
+
+ public void setAutowire(Boolean autowire) {
+ super.setAutowireMode(autowire ? AUTOWIRE_BY_TYPE : AUTOWIRE_NO);
+ }
+
+ public List<Object> getExtensions() {
+ return extensions;
+ }
+
+ public boolean isUnresolved() {
+ return unresolved;
+ }
+
+ public void setUnresolved(boolean undefined) {
+ this.unresolved = undefined;
+ }
+
+ public void setPolicySets(List<PolicySet> policySets) {
+ this.policySets = policySets;
+ }
+
+ public void setRequiredIntents(List<Intent> intents) {
+ this.requiredIntents = intents;
+ }
+
+ public List<PolicySet> getApplicablePolicySets() {
+ return applicablePolicySets;
+ }
+
+}
diff --git a/java/sca/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/assembly/impl/BeanReferenceImpl.java b/java/sca/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/assembly/impl/BeanReferenceImpl.java
new file mode 100644
index 0000000000..7b747372b4
--- /dev/null
+++ b/java/sca/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/assembly/impl/BeanReferenceImpl.java
@@ -0,0 +1,70 @@
+/*
+ * 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.core.spring.assembly.impl;
+
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.SCABinding;
+import org.springframework.beans.factory.config.RuntimeBeanReference;
+
+/**
+ * An implementation of RuntimeBeanReference wrapping an SCA assembly
+ * Reference
+ *
+ * @version $Rev$ $Date$
+ */
+public class BeanReferenceImpl extends RuntimeBeanReference {
+ private Reference reference;
+
+ protected BeanReferenceImpl(Reference reference) {
+ super("temp");
+ this.reference = reference;
+ }
+
+ @Override
+ public String getBeanName() {
+ SCABinding binding = reference.getBinding(SCABinding.class);
+ String name = binding.getURI();
+ if (name.startsWith("/")) {
+ name = name.substring(1);
+ }
+ int s = name.lastIndexOf('/');
+ if (s != -1) {
+ name = name.substring(0, s);
+ }
+ return name;
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (this != other) {
+ if (other instanceof RuntimeBeanReference) {
+ RuntimeBeanReference br = (RuntimeBeanReference)other;
+ return (getBeanName().equals(br.getBeanName()) && this.isToParent() == br.isToParent());
+ } else
+ return false;
+ } else
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ return getBeanName().hashCode() * 29 + (this.isToParent() ? 1 : 0);
+ }
+
+}
diff --git a/java/sca/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/context/ModelResolverImpl.java b/java/sca/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/context/ModelResolverImpl.java
new file mode 100644
index 0000000000..b275bfa9a7
--- /dev/null
+++ b/java/sca/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/context/ModelResolverImpl.java
@@ -0,0 +1,88 @@
+/*
+ * 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.core.spring.context;
+
+import java.lang.ref.WeakReference;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.sca.contribution.resolver.ClassReference;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+
+
+/**
+ * A default implementation of an artifact resolver, based on a map.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ModelResolverImpl implements ModelResolver {
+ private static final long serialVersionUID = -7826976465762296634L;
+
+ private Map<Object, Object> map = new HashMap<Object, Object>();
+
+ private WeakReference<ClassLoader> classLoader;
+
+ public ModelResolverImpl(ClassLoader classLoader) {
+ this.classLoader = new WeakReference<ClassLoader>(classLoader);
+ }
+
+ public <T> T resolveModel(Class<T> modelClass, T unresolved) {
+ Object resolved = map.get(unresolved);
+ if (resolved != null) {
+
+ // Return the resolved object
+ return modelClass.cast(resolved);
+
+ } else if (unresolved instanceof ClassReference) {
+
+ // Load a class on demand
+ ClassReference classReference = (ClassReference)unresolved;
+ Class clazz;
+ try {
+ clazz = Class.forName(classReference.getClassName(), true, classLoader.get());
+ } catch (ClassNotFoundException e) {
+
+ // Return the unresolved object
+ return unresolved;
+ }
+
+ // Store a new ClassReference wrapping the loaded class
+ resolved = new ClassReference(clazz);
+ map.put(resolved, resolved);
+
+ // Return the resolved ClassReference
+ return modelClass.cast(resolved);
+
+ } else {
+
+ // Return the unresolved object
+ return unresolved;
+ }
+ }
+
+ public void addModel(Object resolved) {
+ map.put(resolved, resolved);
+ }
+
+ public Object removeModel(Object resolved) {
+ return map.remove(resolved);
+ }
+
+}
diff --git a/java/sca/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/context/SCADomainContext.java b/java/sca/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/context/SCADomainContext.java
new file mode 100644
index 0000000000..8fa5f4cd53
--- /dev/null
+++ b/java/sca/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/context/SCADomainContext.java
@@ -0,0 +1,192 @@
+/*
+ * 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.core.spring.context;
+
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.transform.TransformerFactory;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory;
+import org.apache.tuscany.sca.assembly.SCABindingFactory;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
+import org.apache.tuscany.sca.assembly.builder.impl.CompositeBuilderImpl;
+import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.service.ContributionException;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.core.spring.assembly.impl.BeanAssemblyFactory;
+import org.apache.tuscany.sca.core.spring.implementation.java.impl.BeanJavaImplementationFactory;
+import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory;
+import org.apache.tuscany.sca.implementation.java.introspect.JavaClassVisitor;
+import org.apache.tuscany.sca.implementation.java.introspect.impl.AllowsPassByReferenceProcessor;
+import org.apache.tuscany.sca.implementation.java.introspect.impl.BaseJavaClassVisitor;
+import org.apache.tuscany.sca.implementation.java.introspect.impl.ComponentNameProcessor;
+import org.apache.tuscany.sca.implementation.java.introspect.impl.ConstructorProcessor;
+import org.apache.tuscany.sca.implementation.java.introspect.impl.ContextProcessor;
+import org.apache.tuscany.sca.implementation.java.introspect.impl.ConversationProcessor;
+import org.apache.tuscany.sca.implementation.java.introspect.impl.DestroyProcessor;
+import org.apache.tuscany.sca.implementation.java.introspect.impl.EagerInitProcessor;
+import org.apache.tuscany.sca.implementation.java.introspect.impl.HeuristicPojoProcessor;
+import org.apache.tuscany.sca.implementation.java.introspect.impl.InitProcessor;
+import org.apache.tuscany.sca.implementation.java.introspect.impl.PolicyProcessor;
+import org.apache.tuscany.sca.implementation.java.introspect.impl.PropertyProcessor;
+import org.apache.tuscany.sca.implementation.java.introspect.impl.ReferenceProcessor;
+import org.apache.tuscany.sca.implementation.java.introspect.impl.ResourceProcessor;
+import org.apache.tuscany.sca.implementation.java.introspect.impl.ScopeProcessor;
+import org.apache.tuscany.sca.implementation.java.introspect.impl.ServiceProcessor;
+import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.apache.tuscany.sca.policy.DefaultIntentAttachPointTypeFactory;
+import org.apache.tuscany.sca.policy.PolicyFactory;
+import org.springframework.beans.factory.support.DefaultListableBeanFactory;
+
+/**
+ * A mini test runtime that uses the SCA assembly model variant implementation
+ * backed by Spring bean definitions.
+ *
+ * @version $Rev$ $Date$
+ */
+public class SCADomainContext {
+
+ private DefaultListableBeanFactory beanFactory;
+
+ public SCADomainContext(String... compositeFiles) {
+
+ // Create Spring bean factory
+ beanFactory = new DefaultListableBeanFactory();
+
+ // Create SCA assembly and SCA Java factories
+ DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ ModelFactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(ModelFactoryExtensionPoint.class);
+ AssemblyFactory assemblyFactory = new BeanAssemblyFactory(new DefaultAssemblyFactory(), beanFactory);
+ modelFactories.addFactory(assemblyFactory);
+ UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class);
+ InterfaceContractMapper mapper = utilities.getUtility(InterfaceContractMapper.class);
+ JavaInterfaceFactory javaFactory = modelFactories.getFactory(JavaInterfaceFactory.class);
+ PolicyFactory policyFactory = modelFactories.getFactory(PolicyFactory.class);
+ SCABindingFactory scaBindingFactory = modelFactories.getFactory(SCABindingFactory.class);
+ modelFactories.addFactory(javaFactory);
+ JavaImplementationFactory javaImplementationFactory = new BeanJavaImplementationFactory(beanFactory);
+ modelFactories.addFactory(javaImplementationFactory);
+
+ BaseJavaClassVisitor[] extensions = new BaseJavaClassVisitor[] {
+ new ConstructorProcessor(assemblyFactory),
+ new AllowsPassByReferenceProcessor(assemblyFactory),
+ new ComponentNameProcessor(assemblyFactory),
+ new ContextProcessor(assemblyFactory),
+ new ConversationProcessor(assemblyFactory),
+ new DestroyProcessor(assemblyFactory),
+ new EagerInitProcessor(assemblyFactory),
+ new InitProcessor(assemblyFactory),
+ new PropertyProcessor(assemblyFactory),
+ new ReferenceProcessor(assemblyFactory, javaFactory),
+ new ResourceProcessor(assemblyFactory),
+ new ScopeProcessor(assemblyFactory),
+ new ServiceProcessor(assemblyFactory, javaFactory),
+ new HeuristicPojoProcessor(assemblyFactory, javaFactory),
+ new PolicyProcessor(assemblyFactory, policyFactory)
+ };
+ for (JavaClassVisitor e : extensions) {
+ javaImplementationFactory.addClassVisitor(e);
+ }
+
+ // Populate ArtifactProcessor registry
+ StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ StAXArtifactProcessor<Composite> compositeProcessor = staxProcessors.getProcessor(Composite.class);
+
+ // Create a resolver
+ //FIXME The ClassLoader should be passed in
+ ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+ ModelResolverImpl resolver = new ModelResolverImpl(classLoader);
+
+ try {
+ XMLInputFactory inputFactory = XMLInputFactory.newInstance();
+
+ // Read the composite files
+ List<Composite> composites = new ArrayList<Composite>();
+ for (String compositeFile: compositeFiles) {
+ InputStream is = classLoader.getResourceAsStream(compositeFile);
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ Composite composite = compositeProcessor.read(reader);
+ resolver.addModel(composite);
+ composites.add(composite);
+ }
+
+ for (Composite composite: composites) {
+
+ // Resolve the composite
+ compositeProcessor.resolve(composite, resolver);
+ }
+
+ // Wire the top level component's composite
+ DocumentBuilderFactory documentBuilderFactory = modelFactories.getFactory(DocumentBuilderFactory.class);
+ TransformerFactory transformerFactory = modelFactories.getFactory(TransformerFactory.class);
+ buildComposite(composites.get(0), assemblyFactory, scaBindingFactory,
+ documentBuilderFactory, transformerFactory, mapper);
+
+ } catch (ContributionException e) {
+ throw new RuntimeException(e);
+ } catch (CompositeBuilderException e) {
+ throw new RuntimeException(e);
+ } catch (XMLStreamException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private void buildComposite(Composite composite, AssemblyFactory assemblyFactory,
+ SCABindingFactory scaBindingFactory,
+ DocumentBuilderFactory documentBuilderFactory,
+ TransformerFactory transformerFactory,
+ InterfaceContractMapper interfaceContractMapper) throws CompositeBuilderException {
+
+ Monitor monitor = new Monitor() {
+
+ public void problem(Problem problem) {
+ System.out.println("Composite assembly problem: " + problem.toString());
+ }
+ public List<Problem> getProblems() {
+ return null;
+ }
+ };
+
+ // Configure and wire the composite
+ CompositeBuilderImpl compositeUtil = new CompositeBuilderImpl(assemblyFactory, scaBindingFactory, new DefaultIntentAttachPointTypeFactory(),
+ documentBuilderFactory, transformerFactory, interfaceContractMapper, monitor);
+ compositeUtil.build(composite);
+
+ }
+
+ public <B> B getService(Class<B> businessInterface, String serviceName) {
+ Object bean = beanFactory.getBean(serviceName);
+ return businessInterface.cast(bean);
+ }
+
+}
diff --git a/java/sca/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/implementation/java/impl/BeanBaseJavaImplementationImpl.java b/java/sca/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/implementation/java/impl/BeanBaseJavaImplementationImpl.java
new file mode 100644
index 0000000000..49abfb4162
--- /dev/null
+++ b/java/sca/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/implementation/java/impl/BeanBaseJavaImplementationImpl.java
@@ -0,0 +1,211 @@
+/*
+ * 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.core.spring.implementation.java.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.ConfiguredOperation;
+import org.apache.tuscany.sca.assembly.ConstrainingType;
+import org.apache.tuscany.sca.assembly.Property;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.implementation.java.BaseJavaImplementation;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.IntentAttachPointType;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.springframework.beans.factory.support.BeanDefinitionRegistry;
+import org.springframework.beans.factory.support.AbstractBeanDefinition;
+import org.springframework.beans.factory.support.GenericBeanDefinition;
+
+/**
+ * An implementation of the SCA assembly JavaImplementation interface backed by a Spring
+ * Bean definition.
+ *
+ * @version $Rev$ $Date$
+ */
+public class BeanBaseJavaImplementationImpl extends GenericBeanDefinition implements BaseJavaImplementation, Cloneable {
+ private static final long serialVersionUID = 1L;
+
+ private List<Service> services = new ArrayList<Service>();
+ private ConstrainingType constrainingType;
+ private List<Object> extensions = new ArrayList<Object>();
+ private boolean unresolved;
+ private BeanDefinitionRegistry beanRegistry;
+ private String uri;
+
+ private List<PolicySet> applicablePolicySets = new ArrayList<PolicySet>();
+ private List<ConfiguredOperation> configuredOperations = new ArrayList<ConfiguredOperation>();
+ private List<PolicySet> policySets = new ArrayList<PolicySet>();
+ private List<Intent> requiredIntents = new ArrayList<Intent>();
+ private IntentAttachPointType type = null;
+
+ protected BeanBaseJavaImplementationImpl(BeanDefinitionRegistry beanRegistry) {
+ this.beanRegistry = beanRegistry;
+
+ // Register this bean definition in the bean registry
+ //TODO find a better name for bean definitions representing component types
+ String name = String.valueOf(System.identityHashCode(this));
+ this.beanRegistry.registerBeanDefinition(name, this);
+ }
+
+ @Override
+ public AbstractBeanDefinition cloneBeanDefinition() {
+ BeanBaseJavaImplementationImpl clone = (BeanBaseJavaImplementationImpl)super.cloneBeanDefinition();
+ clone.getServices().clear();
+ try {
+ for (Service service : getServices()) {
+ clone.getServices().add((Service)service.clone());
+ }
+ clone.getReferences().clear();
+ for (Reference reference : getReferences()) {
+ clone.getReferences().add((Reference)reference.clone());
+ }
+ clone.getProperties().clear();
+ for (Property property : getProperties()) {
+ clone.getProperties().add((Property)property.clone());
+ }
+ return clone;
+ } catch (CloneNotSupportedException e) {
+ //throw new CloneNotSupportedException(e.getMessage());
+ }
+ return clone;
+ }
+
+ public Class<?> getJavaClass() {
+ return super.getBeanClass();
+ }
+
+ public String getName() {
+ return super.getBeanClassName();
+ }
+
+ public void setJavaClass(Class<?> javaClass) {
+ super.setBeanClass(javaClass);
+ }
+
+ public void setName(String className) {
+ super.setBeanClassName(className);
+ }
+
+ public String getURI() {
+ return uri;
+ }
+
+ public void setURI(String uri) {
+ this.uri = uri;
+ }
+
+ public ConstrainingType getConstrainingType() {
+ return constrainingType;
+ }
+
+ //TODO use a better list implementation
+ private List<Property> properties = new ArrayList<Property>() {
+ private static final long serialVersionUID = 1L;
+
+ // Add a property
+ @Override
+ public boolean add(Property property) {
+
+ // Add corresponding bean property value
+ getPropertyValues().addPropertyValue(property.getName(), property.getValue());
+
+ return super.add(property);
+ }
+ };
+
+ public List<Property> getProperties() {
+ return properties;
+ }
+
+ //TODO use a better list implementation
+ private List<Reference> references = new ArrayList<Reference>() {
+ private static final long serialVersionUID = 1L;
+
+ // Add a reference
+ @Override
+ public boolean add(Reference reference) {
+
+ // Add corresponding bean property value
+ String target;
+ if (!reference.getTargets().isEmpty()) {
+ //TODO handle multiplicity
+ target = reference.getTargets().get(0).getName();
+ int i = target.indexOf('/');
+ if (i != -1)
+ target = target.substring(0, i);
+ } else {
+ target = null;
+ }
+ getPropertyValues().addPropertyValue(reference.getName(), target);
+
+ return super.add(reference);
+ }
+ };
+
+
+ public List<Reference> getReferences() {
+ return references;
+ }
+
+ public List<Service> getServices() {
+ return services;
+ }
+
+ public void setConstrainingType(ConstrainingType constrainingType) {
+ this.constrainingType = constrainingType;
+ }
+
+ public List<Object> getExtensions() {
+ return extensions;
+ }
+
+ public boolean isUnresolved() {
+ return unresolved;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ this.unresolved = unresolved;
+ }
+
+ public List<PolicySet> getApplicablePolicySets() {
+ return applicablePolicySets;
+ }
+
+ public List<ConfiguredOperation> getConfiguredOperations() {
+ return configuredOperations;
+ }
+
+ public List<PolicySet> getPolicySets() {
+ return policySets;
+ }
+
+ public List<Intent> getRequiredIntents() {
+ return requiredIntents;
+ }
+
+ public IntentAttachPointType getType() {
+ return type;
+ }
+
+ public void setType(IntentAttachPointType type) {
+ this.type = type;
+ }
+}
diff --git a/java/sca/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/implementation/java/impl/BeanJavaImplementationFactory.java b/java/sca/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/implementation/java/impl/BeanJavaImplementationFactory.java
new file mode 100644
index 0000000000..6b19bac413
--- /dev/null
+++ b/java/sca/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/implementation/java/impl/BeanJavaImplementationFactory.java
@@ -0,0 +1,75 @@
+/*
+ * 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.core.spring.implementation.java.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.implementation.java.IntrospectionException;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory;
+import org.apache.tuscany.sca.implementation.java.impl.JavaClassIntrospectorImpl;
+import org.apache.tuscany.sca.implementation.java.introspect.JavaClassVisitor;
+import org.springframework.beans.factory.support.BeanDefinitionRegistry;
+
+/**
+ * An alternate implementation of the SCA Java assembly model factory that
+ * creates SCA Java assembly model objects backed by Spring bean definitions.
+ *
+ * @version $Rev$ $Date$
+ */
+public class BeanJavaImplementationFactory implements JavaImplementationFactory {
+
+ private BeanDefinitionRegistry beanRegistry;
+ private List<JavaClassVisitor> visitors = new ArrayList<JavaClassVisitor>();
+ private JavaClassIntrospectorImpl introspector;
+
+ public BeanJavaImplementationFactory(BeanDefinitionRegistry beanRegistry) {
+ this.beanRegistry = beanRegistry;
+ introspector = new JavaClassIntrospectorImpl(visitors);
+ }
+
+ public JavaImplementation createJavaImplementation() {
+ return new BeanJavaImplementationImpl(beanRegistry);
+ }
+
+ public void createJavaImplementation(JavaImplementation javaImplementation, Class<?> implementationClass)
+ throws IntrospectionException {
+ introspector.introspectClass(javaImplementation, implementationClass);
+ }
+
+ public JavaImplementation createJavaImplementation(Class<?> implementationClass) throws IntrospectionException {
+ JavaImplementation javaImplementation = createJavaImplementation();
+ introspector.introspectClass(javaImplementation, implementationClass);
+ return javaImplementation;
+ }
+
+ public void addClassVisitor(JavaClassVisitor visitor) {
+ visitors.add(visitor);
+ }
+
+ public void removeClassVisitor(JavaClassVisitor visitor) {
+ visitors.remove(visitor);
+ }
+
+ public List<JavaClassVisitor> getClassVisitors() {
+ return visitors;
+ }
+
+}
diff --git a/java/sca/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/implementation/java/impl/BeanJavaImplementationImpl.java b/java/sca/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/implementation/java/impl/BeanJavaImplementationImpl.java
new file mode 100644
index 0000000000..7fc82d8711
--- /dev/null
+++ b/java/sca/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/implementation/java/impl/BeanJavaImplementationImpl.java
@@ -0,0 +1,175 @@
+/*
+ * 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.core.spring.implementation.java.impl;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.impl.JavaConstructorImpl;
+import org.apache.tuscany.sca.implementation.java.impl.JavaElementImpl;
+import org.apache.tuscany.sca.implementation.java.impl.JavaResourceImpl;
+import org.apache.tuscany.sca.implementation.java.impl.JavaScopeImpl;
+import org.apache.tuscany.sca.policy.util.PolicyHandlerTuple;
+import org.springframework.beans.factory.support.BeanDefinitionRegistry;
+
+/**
+ * An implementation of the SCA assembly JavaImplementation interface backed by a Spring
+ * Bean definition.
+ *
+ * @version $Rev$ $Date$
+ */
+public class BeanJavaImplementationImpl extends BeanBaseJavaImplementationImpl implements JavaImplementation {
+ private static final long serialVersionUID = 6792198458193774178L;
+
+ private JavaConstructorImpl<?> constructorDefinition;
+ private Map<Constructor, JavaConstructorImpl> constructors = new HashMap<Constructor, JavaConstructorImpl>();
+ private Method initMethod;
+ private Method destroyMethod;
+ private final Map<String, JavaResourceImpl> resources = new HashMap<String, JavaResourceImpl>();
+ private final Map<String, JavaElementImpl> propertyMembers = new HashMap<String, JavaElementImpl>();
+ private final Map<String, JavaElementImpl> referenceMembers = new HashMap<String, JavaElementImpl>();
+ private final Map<String, Collection<JavaElementImpl>> callbackMembers = new HashMap<String, Collection<JavaElementImpl>>();
+ private List<Member> conversationIDMember = new ArrayList<Member>();
+ private boolean eagerInit;
+ private boolean allowsPassByReference;
+ private List<Method> allowsPassByReferenceMethods = new ArrayList<Method>();
+ private long maxAge = -1;
+ private long maxIdleTime = -1;
+ private JavaScopeImpl scope = JavaScopeImpl.STATELESS;
+ private List<PolicyHandlerTuple> policyHandlerClassNames = null;
+
+ protected BeanJavaImplementationImpl(BeanDefinitionRegistry beanRegistry) {
+ super(beanRegistry);
+ }
+
+ public JavaConstructorImpl<?> getConstructor() {
+ return constructorDefinition;
+ }
+
+ public void setConstructor(JavaConstructorImpl<?> definition) {
+ this.constructorDefinition = definition;
+ }
+
+ public Method getInitMethod() {
+ return initMethod;
+ }
+
+ public void setInitMethod(Method initMethod) {
+ this.initMethod = initMethod;
+ }
+
+ public Method getDestroyMethod() {
+ return destroyMethod;
+ }
+
+ public void setDestroyMethod(Method destroyMethod) {
+ this.destroyMethod = destroyMethod;
+ }
+
+ public Map<String, JavaResourceImpl> getResources() {
+ return resources;
+ }
+
+ public List<Member> getConversationIDMembers() {
+ return this.conversationIDMember;
+ }
+
+ public void addConversationIDMember(Member conversationIDMember) {
+ this.conversationIDMember.add(conversationIDMember);
+ }
+
+ public boolean isAllowsPassByReference() {
+ return allowsPassByReference;
+ }
+
+ public void setAllowsPassByReference(boolean allowsPassByReference) {
+ this.allowsPassByReference = allowsPassByReference;
+ }
+
+ public List<Method> getAllowsPassByReferenceMethods() {
+ return allowsPassByReferenceMethods;
+ }
+
+ public boolean isAllowsPassByReference(Method method) {
+ return allowsPassByReference || allowsPassByReferenceMethods.contains(method);
+ }
+
+ public Map<Constructor, JavaConstructorImpl> getConstructors() {
+ return constructors;
+ }
+
+ public boolean isEagerInit() {
+ return eagerInit;
+ }
+
+ public void setEagerInit(boolean eagerInit) {
+ this.eagerInit = eagerInit;
+ }
+
+ public Map<String, Collection<JavaElementImpl>> getCallbackMembers() {
+ return callbackMembers;
+ }
+
+ public Map<String, JavaElementImpl> getPropertyMembers() {
+ return propertyMembers;
+ }
+
+ public Map<String, JavaElementImpl> getReferenceMembers() {
+ return referenceMembers;
+ }
+
+ public JavaScopeImpl getJavaScope() {
+ return scope;
+ }
+
+ public void setJavaScope(JavaScopeImpl scope) {
+ this.scope = scope;
+ }
+
+ public long getMaxAge() {
+ return maxAge;
+ }
+
+ public void setMaxAge(long maxAge) {
+ this.maxAge = maxAge;
+ }
+
+ public long getMaxIdleTime() {
+ return maxIdleTime;
+ }
+
+ public void setMaxIdleTime(long maxIdleTime) {
+ this.maxIdleTime = maxIdleTime;
+ }
+
+ public List<PolicyHandlerTuple> getPolicyHandlerClassNames() {
+ return policyHandlerClassNames;
+ }
+
+ public void setPolicyHandlerClassNames(List<PolicyHandlerTuple> policyHandlerClassNames) {
+ this.policyHandlerClassNames = policyHandlerClassNames;
+ }
+}
diff --git a/java/sca/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/implementation/java/impl/BeanJavaInterfaceContractImpl.java b/java/sca/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/implementation/java/impl/BeanJavaInterfaceContractImpl.java
new file mode 100644
index 0000000000..17a7e9084c
--- /dev/null
+++ b/java/sca/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/implementation/java/impl/BeanJavaInterfaceContractImpl.java
@@ -0,0 +1,34 @@
+/*
+ * 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.core.spring.implementation.java.impl;
+
+import org.apache.tuscany.sca.interfacedef.java.impl.JavaInterfaceContractImpl;
+
+/**
+ * An implementation of a Java interface contract.
+ *
+ * @version $Rev$ $Date$
+ */
+public class BeanJavaInterfaceContractImpl extends JavaInterfaceContractImpl {
+
+ protected BeanJavaInterfaceContractImpl() {
+ }
+
+}
diff --git a/java/sca/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/implementation/java/impl/BeanJavaInterfaceFactory.java b/java/sca/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/implementation/java/impl/BeanJavaInterfaceFactory.java
new file mode 100644
index 0000000000..492ab2732e
--- /dev/null
+++ b/java/sca/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/implementation/java/impl/BeanJavaInterfaceFactory.java
@@ -0,0 +1,75 @@
+/*
+ * 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.core.spring.implementation.java.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+import org.apache.tuscany.sca.interfacedef.java.impl.JavaInterfaceIntrospectorImpl;
+import org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceVisitor;
+
+/**
+ * An alternate implementation of the SCA Java assembly model factory that creates SCA
+ * Java assembly model objects backed by Spring bean definitions.
+ *
+ * @version $Rev$ $Date$
+ */
+public class BeanJavaInterfaceFactory implements JavaInterfaceFactory {
+
+ private List<JavaInterfaceVisitor> visitors = new ArrayList<JavaInterfaceVisitor>();
+ private JavaInterfaceIntrospectorImpl introspector;
+
+ public BeanJavaInterfaceFactory() {
+ introspector = new JavaInterfaceIntrospectorImpl(this);
+ }
+
+ public JavaInterface createJavaInterface() {
+ return new BeanJavaInterfaceImpl();
+ }
+
+ public JavaInterface createJavaInterface(Class<?> interfaceClass) throws InvalidInterfaceException {
+ JavaInterface javaInterface = createJavaInterface();
+ introspector.introspectInterface(javaInterface, interfaceClass);
+ return javaInterface;
+ }
+
+ public void createJavaInterface(JavaInterface javaInterface, Class<?> interfaceClass) throws InvalidInterfaceException {
+ introspector.introspectInterface(javaInterface, interfaceClass);
+ }
+
+ public JavaInterfaceContract createJavaInterfaceContract() {
+ return new BeanJavaInterfaceContractImpl();
+ }
+
+ public void addInterfaceVisitor(JavaInterfaceVisitor extension) {
+ visitors.add(extension);
+ }
+
+ public void removeInterfaceVisitor(JavaInterfaceVisitor extension) {
+ visitors.remove(extension);
+ }
+
+ public List<JavaInterfaceVisitor> getInterfaceVisitors() {
+ return visitors;
+ }
+}
diff --git a/java/sca/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/implementation/java/impl/BeanJavaInterfaceImpl.java b/java/sca/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/implementation/java/impl/BeanJavaInterfaceImpl.java
new file mode 100644
index 0000000000..6c3afdb129
--- /dev/null
+++ b/java/sca/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/implementation/java/impl/BeanJavaInterfaceImpl.java
@@ -0,0 +1,149 @@
+/*
+ * 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.core.spring.implementation.java.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.interfacedef.java.impl.JavaInterfaceImpl;
+import org.apache.tuscany.sca.policy.Intent;
+
+/**
+ * An alternate implementation of the SCA Java assembly model JavaInterface
+ * interface.
+ *
+ * @version $Rev$ $Date$
+ */
+public class BeanJavaInterfaceImpl extends JavaInterfaceImpl implements JavaInterface {
+
+ private String className;
+ private Class<?> javaClass;
+ private Class<?> callbackClass;
+ private boolean conversational;
+ private boolean remotable;
+ List<Intent> requiredIntents = new ArrayList<Intent>();
+ private List<Object> extensions = new ArrayList<Object>();
+ private List<Operation> operations = new ArrayList<Operation>();
+ private boolean unresolved = false;
+
+ protected BeanJavaInterfaceImpl() {
+ }
+
+ @Override
+ public String getName() {
+ if (isUnresolved()) {
+ return className;
+ }
+ else {
+ return javaClass.getName();
+ }
+ }
+
+ @Override
+ public void setName(String className) {
+ if (!isUnresolved())
+ throw new IllegalStateException();
+ this.className = className;
+ }
+
+ @Override
+ public Class<?> getJavaClass() {
+ return javaClass;
+ }
+
+ @Override
+ public void setJavaClass(Class<?> javaClass) {
+ this.javaClass = javaClass;
+ }
+
+ @Override
+ public Class<?> getCallbackClass() {
+ return callbackClass;
+ }
+
+ @Override
+ public void setCallbackClass(Class<?> callbackClass) {
+ this.callbackClass = callbackClass;
+ }
+
+ @Override
+ public boolean isConversational() {
+ return conversational;
+ }
+
+ @Override
+ public boolean isRemotable() {
+ return remotable;
+ }
+
+ @Override
+ public void setConversational(boolean conversational) {
+ this.conversational = conversational;
+ }
+
+ @Override
+ public void setRemotable(boolean local) {
+ this.remotable = local;
+ }
+
+ @Override
+ public List<Intent> getRequiredIntents() {
+ return requiredIntents;
+ }
+
+ public List<Object> getExtensions() {
+ return extensions;
+ }
+
+ @Override
+ public List<Operation> getOperations() {
+ return operations;
+ }
+
+ @Override
+ public boolean isUnresolved() {
+ return unresolved;
+ }
+
+ @Override
+ public void setUnresolved(boolean undefined) {
+ this.unresolved = undefined;
+ }
+
+ @Override
+ public void resetDataBinding(String dataBinding) {
+ }
+
+ @Deprecated
+ @Override
+ public void setDefaultDataBinding(String dataBinding) {
+ }
+
+ @Override
+ public boolean isDynamic() {
+ return false;
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+}
diff --git a/java/sca/modules/core-spring/src/test/java/calculator/AddService.java b/java/sca/modules/core-spring/src/test/java/calculator/AddService.java
new file mode 100644
index 0000000000..f3a24ed6b2
--- /dev/null
+++ b/java/sca/modules/core-spring/src/test/java/calculator/AddService.java
@@ -0,0 +1,30 @@
+/*
+ * 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 calculator;
+
+/**
+ * The Add Service interface.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface AddService {
+
+ double add(double n1, double n2);
+
+}
diff --git a/java/sca/modules/core-spring/src/test/java/calculator/AddServiceImpl.java b/java/sca/modules/core-spring/src/test/java/calculator/AddServiceImpl.java
new file mode 100644
index 0000000000..61654ea811
--- /dev/null
+++ b/java/sca/modules/core-spring/src/test/java/calculator/AddServiceImpl.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package calculator;
+
+import org.osoa.sca.annotations.EagerInit;
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * An implementation of the Add service
+ *
+ * @version $Rev$ $Date$
+ */
+@Scope("COMPOSITE")
+@EagerInit
+public class AddServiceImpl implements AddService {
+
+ public double add(double n1, double n2) {
+ return n1 + n2;
+ }
+
+}
diff --git a/java/sca/modules/core-spring/src/test/java/calculator/CalculatorClient.java b/java/sca/modules/core-spring/src/test/java/calculator/CalculatorClient.java
new file mode 100644
index 0000000000..73aa028084
--- /dev/null
+++ b/java/sca/modules/core-spring/src/test/java/calculator/CalculatorClient.java
@@ -0,0 +1,43 @@
+/*
+ * 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 calculator;
+
+import org.apache.tuscany.sca.core.spring.context.SCADomainContext;
+
+/**
+ * This client program shows how to create an SCA runtime, start it, locate the
+ * Calculator service and invoke it.
+ *
+ * @version $Rev$ $Date$
+ */
+public class CalculatorClient {
+ public static void main(String[] args) throws Exception {
+
+ SCADomainContext context = new SCADomainContext("org/apache/tuscany/core/spring/Calculator.composite");
+
+ CalculatorService calculatorService = context.getService(CalculatorService.class, "CalculatorServiceComponent");
+
+ // Calculate
+ System.out.println("3 + 2=" + calculatorService.add(3, 2));
+ System.out.println("3 - 2=" + calculatorService.subtract(3, 2));
+ System.out.println("3 * 2=" + calculatorService.multiply(3, 2));
+ System.out.println("3 / 2=" + calculatorService.divide(3, 2));
+
+ }
+}
diff --git a/java/sca/modules/core-spring/src/test/java/calculator/CalculatorService.java b/java/sca/modules/core-spring/src/test/java/calculator/CalculatorService.java
new file mode 100644
index 0000000000..e0cf23dc17
--- /dev/null
+++ b/java/sca/modules/core-spring/src/test/java/calculator/CalculatorService.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 calculator;
+
+/**
+ * The Calculator service interface.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface CalculatorService {
+
+ double add(double n1, double n2);
+
+ double subtract(double n1, double n2);
+
+ double multiply(double n1, double n2);
+
+ double divide(double n1, double n2);
+
+}
diff --git a/java/sca/modules/core-spring/src/test/java/calculator/CalculatorServiceImpl.java b/java/sca/modules/core-spring/src/test/java/calculator/CalculatorServiceImpl.java
new file mode 100644
index 0000000000..c1fceb575d
--- /dev/null
+++ b/java/sca/modules/core-spring/src/test/java/calculator/CalculatorServiceImpl.java
@@ -0,0 +1,73 @@
+/*
+ * 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 calculator;
+
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * An implementation of the Calculator service.
+ *
+ * @version $Rev$ $Date$
+ */
+@Scope("COMPOSITE")
+public class CalculatorServiceImpl implements CalculatorService {
+
+ private AddService addService;
+ private SubtractService subtractService;
+ private MultiplyService multiplyService;
+ private DivideService divideService;
+
+ @Reference
+ public void setAddService(AddService addService) {
+ this.addService = addService;
+ }
+
+ @Reference
+ public void setSubtractService(SubtractService subtractService) {
+ this.subtractService = subtractService;
+ }
+
+ @Reference
+ public void setDivideService(DivideService divideService) {
+ this.divideService = divideService;
+ }
+
+ @Reference
+ public void setMultiplyService(MultiplyService multiplyService) {
+ this.multiplyService = multiplyService;
+ }
+
+ public double add(double n1, double n2) {
+ return addService.add(n1, n2);
+ }
+
+ public double subtract(double n1, double n2) {
+ return subtractService.subtract(n1, n2);
+ }
+
+ public double multiply(double n1, double n2) {
+ return multiplyService.multiply(n1, n2);
+ }
+
+ public double divide(double n1, double n2) {
+ return divideService.divide(n1, n2);
+ }
+
+}
diff --git a/java/sca/modules/core-spring/src/test/java/calculator/DivideService.java b/java/sca/modules/core-spring/src/test/java/calculator/DivideService.java
new file mode 100644
index 0000000000..7c69b10b25
--- /dev/null
+++ b/java/sca/modules/core-spring/src/test/java/calculator/DivideService.java
@@ -0,0 +1,30 @@
+/*
+ * 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 calculator;
+
+/**
+ * The Divide Service interface.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface DivideService {
+
+ double divide(double n1, double n2);
+
+}
diff --git a/java/sca/modules/core-spring/src/test/java/calculator/DivideServiceImpl.java b/java/sca/modules/core-spring/src/test/java/calculator/DivideServiceImpl.java
new file mode 100644
index 0000000000..e1f35f99b5
--- /dev/null
+++ b/java/sca/modules/core-spring/src/test/java/calculator/DivideServiceImpl.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 calculator;
+
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * An implementation of the Divide service.
+ *
+ * @version $Rev$ $Date$
+ */
+@Scope("COMPOSITE")
+public class DivideServiceImpl implements DivideService {
+
+ public double divide(double n1, double n2) {
+ return n1 / n2;
+ }
+
+}
diff --git a/java/sca/modules/core-spring/src/test/java/calculator/MultiplyService.java b/java/sca/modules/core-spring/src/test/java/calculator/MultiplyService.java
new file mode 100644
index 0000000000..686542c18e
--- /dev/null
+++ b/java/sca/modules/core-spring/src/test/java/calculator/MultiplyService.java
@@ -0,0 +1,30 @@
+/*
+ * 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 calculator;
+
+/**
+ * The Multiply Service interface.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface MultiplyService {
+
+ double multiply(double n1, double n2);
+
+}
diff --git a/java/sca/modules/core-spring/src/test/java/calculator/MultiplyServiceImpl.java b/java/sca/modules/core-spring/src/test/java/calculator/MultiplyServiceImpl.java
new file mode 100644
index 0000000000..d621407908
--- /dev/null
+++ b/java/sca/modules/core-spring/src/test/java/calculator/MultiplyServiceImpl.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 calculator;
+
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * An implementation of the Multiply service.
+ *
+ * @version $Rev$ $Date$
+ */
+@Scope("COMPOSITE")
+public class MultiplyServiceImpl implements MultiplyService {
+
+ public double multiply(double n1, double n2) {
+ return n1 * n2;
+ }
+
+}
diff --git a/java/sca/modules/core-spring/src/test/java/calculator/NestedCalculatorClient.java b/java/sca/modules/core-spring/src/test/java/calculator/NestedCalculatorClient.java
new file mode 100644
index 0000000000..e8e4a6f71b
--- /dev/null
+++ b/java/sca/modules/core-spring/src/test/java/calculator/NestedCalculatorClient.java
@@ -0,0 +1,46 @@
+/*
+ * 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 calculator;
+
+import org.apache.tuscany.sca.core.spring.context.SCADomainContext;
+
+/**
+ * This client program shows how to create an SCA runtime, start it, locate the
+ * Calculator service and invoke it.
+ *
+ * @version $Rev$ $Date$
+ */
+public class NestedCalculatorClient {
+ public static void main(String[] args) throws Exception {
+
+ SCADomainContext context = new SCADomainContext(
+ "org/apache/tuscany/core/spring/OuterCalculator.composite",
+ "org/apache/tuscany/core/spring/InnerCalculator.composite",
+ "org/apache/tuscany/core/spring/InnerOperations.composite");
+
+ CalculatorService calculatorService = context.getService(CalculatorService.class, "CalculatorServiceComponent/CalculatorServiceComponent");
+
+ // Calculate
+ System.out.println("3 + 2=" + calculatorService.add(3, 2));
+ System.out.println("3 - 2=" + calculatorService.subtract(3, 2));
+ System.out.println("3 * 2=" + calculatorService.multiply(3, 2));
+ System.out.println("3 / 2=" + calculatorService.divide(3, 2));
+
+ }
+}
diff --git a/java/sca/modules/core-spring/src/test/java/calculator/SubtractService.java b/java/sca/modules/core-spring/src/test/java/calculator/SubtractService.java
new file mode 100644
index 0000000000..30632688f9
--- /dev/null
+++ b/java/sca/modules/core-spring/src/test/java/calculator/SubtractService.java
@@ -0,0 +1,30 @@
+/*
+ * 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 calculator;
+
+/**
+ * The Subtract Service interface.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface SubtractService {
+
+ double subtract(double n1, double n2);
+
+}
diff --git a/java/sca/modules/core-spring/src/test/java/calculator/SubtractServiceImpl.java b/java/sca/modules/core-spring/src/test/java/calculator/SubtractServiceImpl.java
new file mode 100644
index 0000000000..4fed0a8c6a
--- /dev/null
+++ b/java/sca/modules/core-spring/src/test/java/calculator/SubtractServiceImpl.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 calculator;
+
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * An implementation of the subtract service.
+ *
+ * @version $Rev$ $Date$
+ */
+@Scope("COMPOSITE")
+public class SubtractServiceImpl implements SubtractService {
+
+ public double subtract(double n1, double n2) {
+ return n1 - n2;
+ }
+
+}
diff --git a/java/sca/modules/core-spring/src/test/java/org/apache/tuscany/sca/core/spring/CalculatorTestCase.java b/java/sca/modules/core-spring/src/test/java/org/apache/tuscany/sca/core/spring/CalculatorTestCase.java
new file mode 100644
index 0000000000..44b447cc64
--- /dev/null
+++ b/java/sca/modules/core-spring/src/test/java/org/apache/tuscany/sca/core/spring/CalculatorTestCase.java
@@ -0,0 +1,56 @@
+/*
+ * 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.core.spring;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.core.spring.context.SCADomainContext;
+
+import calculator.CalculatorService;
+
+/**
+ * This shows how to test the Calculator service component.
+ *
+ * @version $Rev$ $Date$
+ */
+public class CalculatorTestCase extends TestCase {
+
+ private SCADomainContext context;
+ private CalculatorService calculatorService;
+
+ @Override
+ protected void setUp() throws Exception {
+ context = new SCADomainContext("org/apache/tuscany/sca/core/spring/Calculator.composite");
+
+ calculatorService = context.getService(CalculatorService.class, "CalculatorServiceComponent");
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ }
+
+ public void testCalculator() throws Exception {
+ // Calculate
+ assertEquals(calculatorService.add(3, 2), 5.0);
+ assertEquals(calculatorService.subtract(3, 2), 1.0);
+ assertEquals(calculatorService.multiply(3, 2), 6.0);
+ assertEquals(calculatorService.divide(3, 2), 1.5);
+
+ }
+}
diff --git a/java/sca/modules/core-spring/src/test/java/org/apache/tuscany/sca/core/spring/NestedCalculatorTestCaseFIXME.java b/java/sca/modules/core-spring/src/test/java/org/apache/tuscany/sca/core/spring/NestedCalculatorTestCaseFIXME.java
new file mode 100644
index 0000000000..baf73ac197
--- /dev/null
+++ b/java/sca/modules/core-spring/src/test/java/org/apache/tuscany/sca/core/spring/NestedCalculatorTestCaseFIXME.java
@@ -0,0 +1,59 @@
+/*
+ * 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.core.spring;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.core.spring.context.SCADomainContext;
+
+import calculator.CalculatorService;
+
+/**
+ * This shows how to test the Calculator service component.
+ *
+ * @version $Rev$ $Date$
+ */
+public class NestedCalculatorTestCaseFIXME extends TestCase {
+
+ private SCADomainContext context;
+ private CalculatorService calculatorService;
+
+ @Override
+ protected void setUp() throws Exception {
+ context = new SCADomainContext(
+ "org/apache/tuscany/sca/core/spring/OuterCalculator.composite",
+ "org/apache/tuscany/sca/core/spring/InnerCalculator.composite",
+ "org/apache/tuscany/sca/core/spring/InnerOperations.composite");
+
+ calculatorService = context.getService(CalculatorService.class, "CalculatorServiceComponent/InnerCalculatorServiceComponent");
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ }
+
+ public void testCalculator() throws Exception {
+ // Calculate
+ assertEquals(calculatorService.add(3, 2), 5.0);
+ assertEquals(calculatorService.subtract(3, 2), 1.0);
+ assertEquals(calculatorService.multiply(3, 2), 6.0);
+ assertEquals(calculatorService.divide(3, 2), 1.5);
+
+ }
+}
diff --git a/java/sca/modules/core-spring/src/test/resources/org/apache/tuscany/sca/core/spring/Calculator.composite b/java/sca/modules/core-spring/src/test/resources/org/apache/tuscany/sca/core/spring/Calculator.composite
new file mode 100644
index 0000000000..6d998ba035
--- /dev/null
+++ b/java/sca/modules/core-spring/src/test/resources/org/apache/tuscany/sca/core/spring/Calculator.composite
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:calc="http://sample.calculator"
+ name="calc:TestBeanCalculator">
+
+ <service name="CalculatorService" promote="CalculatorServiceComponent">
+ <interface.java interface="calculator.CalculatorService"/>
+ </service>
+
+ <component name="CalculatorServiceComponent">
+ <implementation.java class="calculator.CalculatorServiceImpl"/>
+ <reference name="addService" target="AddServiceComponent"/>
+ <reference name="subtractService" target="SubtractServiceComponent"/>
+ <reference name="multiplyService" target="MultiplyServiceComponent"/>
+ <reference name="divideService" target="DivideServiceComponent"/>
+ </component>
+
+ <component name="AddServiceComponent">
+ <implementation.java class="calculator.AddServiceImpl"/>
+ </component>
+
+ <component name="SubtractServiceComponent">
+ <implementation.java class="calculator.SubtractServiceImpl"/>
+ </component>
+
+ <component name="MultiplyServiceComponent">
+ <implementation.java class="calculator.MultiplyServiceImpl"/>
+ </component>
+
+ <component name="DivideServiceComponent">
+ <implementation.java class="calculator.DivideServiceImpl"/>
+ </component>
+
+</composite>
diff --git a/java/sca/modules/core-spring/src/test/resources/org/apache/tuscany/sca/core/spring/InnerCalculator.composite b/java/sca/modules/core-spring/src/test/resources/org/apache/tuscany/sca/core/spring/InnerCalculator.composite
new file mode 100644
index 0000000000..8b043f2b4f
--- /dev/null
+++ b/java/sca/modules/core-spring/src/test/resources/org/apache/tuscany/sca/core/spring/InnerCalculator.composite
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:calc="http://calc"
+ targetNamespace="http://calc"
+ name="InnerCalculator">
+
+ <service name="CalculatorService" promote="InnerCalculatorServiceComponent">
+ <interface.java interface="calculator.CalculatorService"/>
+ </service>
+
+ <component name="InnerCalculatorServiceComponent">
+ <implementation.java class="calculator.CalculatorServiceImpl"/>
+ <reference name="addService"/>
+ <reference name="subtractService"/>
+ <reference name="multiplyService"/>
+ <reference name="divideService"/>
+ </component>
+
+ <reference name="addService" promote="InnerCalculatorServiceComponent/addService"/>
+ <reference name="subtractService" promote="InnerCalculatorServiceComponent/subtractService"/>
+ <reference name="multiplyService" promote="InnerCalculatorServiceComponent/multiplyService"/>
+ <reference name="divideService" promote="InnerCalculatorServiceComponent/divideService"/>
+
+</composite>
diff --git a/java/sca/modules/core-spring/src/test/resources/org/apache/tuscany/sca/core/spring/InnerOperations.composite b/java/sca/modules/core-spring/src/test/resources/org/apache/tuscany/sca/core/spring/InnerOperations.composite
new file mode 100644
index 0000000000..d7d1124050
--- /dev/null
+++ b/java/sca/modules/core-spring/src/test/resources/org/apache/tuscany/sca/core/spring/InnerOperations.composite
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:calc="http://calc"
+ targetNamespace="http://calc"
+ name="InnerOperations">
+
+ <service name="AddService" promote="AddServiceComponent">
+ <interface.java interface="calculator.AddService"/>
+ </service>
+
+ <service name="SubtractService" promote="SubtractServiceComponent">
+ <interface.java interface="calculator.SubtractService"/>
+ </service>
+
+ <service name="MultiplyService" promote="MultiplyServiceComponent">
+ <interface.java interface="calculator.MultiplyService"/>
+ </service>
+
+ <service name="DivideService" promote="DivideServiceComponent">
+ <interface.java interface="calculator.DivideService"/>
+ </service>
+
+ <component name="AddServiceComponent">
+ <implementation.java class="calculator.AddServiceImpl"/>
+ </component>
+
+ <component name="SubtractServiceComponent">
+ <implementation.java class="calculator.SubtractServiceImpl"/>
+ </component>
+
+ <component name="MultiplyServiceComponent">
+ <implementation.java class="calculator.MultiplyServiceImpl"/>
+ </component>
+
+ <component name="DivideServiceComponent">
+ <implementation.java class="calculator.DivideServiceImpl"/>
+ </component>
+
+</composite>
diff --git a/java/sca/modules/core-spring/src/test/resources/org/apache/tuscany/sca/core/spring/OuterCalculator.composite b/java/sca/modules/core-spring/src/test/resources/org/apache/tuscany/sca/core/spring/OuterCalculator.composite
new file mode 100644
index 0000000000..c2b6cced36
--- /dev/null
+++ b/java/sca/modules/core-spring/src/test/resources/org/apache/tuscany/sca/core/spring/OuterCalculator.composite
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:calc="http://calc"
+ targetNamespace="http://calc"
+ name="OuterCalculator">
+
+ <service name="CalculatorService" promote="CalculatorServiceComponent">
+ <interface.java interface="calculator.CalculatorService"/>
+ </service>
+
+ <component name="CalculatorServiceComponent">
+ <implementation.composite name="calc:InnerCalculator"/>
+ <reference name="addService" target="OperationsServiceComponent/AddService"/>
+ <reference name="subtractService" target="OperationsServiceComponent/SubtractService"/>
+ <reference name="multiplyService" target="OperationsServiceComponent/MultiplyService"/>
+ <reference name="divideService" target="OperationsServiceComponent/DivideService"/>
+ </component>
+
+ <component name="OperationsServiceComponent">
+ <implementation.composite name="calc:InnerOperations"/>
+ </component>
+
+</composite>
diff --git a/java/sca/modules/data-engine-helper/LICENSE b/java/sca/modules/data-engine-helper/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/java/sca/modules/data-engine-helper/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/java/sca/modules/data-engine-helper/NOTICE b/java/sca/modules/data-engine-helper/NOTICE
new file mode 100644
index 0000000000..fdfa0e9faa
--- /dev/null
+++ b/java/sca/modules/data-engine-helper/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2008 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/java/sca/modules/data-engine-helper/pom.xml b/java/sca/modules/data-engine-helper/pom.xml
new file mode 100644
index 0000000000..ba01e8fa24
--- /dev/null
+++ b/java/sca/modules/data-engine-helper/pom.xml
@@ -0,0 +1,142 @@
+<?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-data-engine-helper</artifactId>
+ <name>Apache Tuscany SCA Data Engine Helper</name>
+
+ <repositories>
+ <repository>
+ <id>apache.incubator</id>
+ <url>http://people.apache.org/repo/m2-incubating-repository</url>
+ </repository>
+ </repositories>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.das</groupId>
+ <artifactId>tuscany-das-rdb</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <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-core</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</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-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-embedded</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymock</artifactId>
+ <version>2.2</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.derby</groupId>
+ <artifactId>derby</artifactId>
+ <version>10.3.1.4</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+
+ <configuration>
+ <instructions>
+ <Bundle-Version>${tuscany.version}</Bundle-Version>
+ <Bundle-SymbolicName>org.apache.tuscany.sca.data.engine.helper</Bundle-SymbolicName>
+ <Bundle-Description>${pom.name}</Bundle-Description>
+ <Export-Package>org.apache.tuscany.sca.data.engine*</Export-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/java/sca/modules/data-engine-helper/src/main/java/org/apache/tuscany/sca/data/engine/ConnectionInfoArtifactProcessor.java b/java/sca/modules/data-engine-helper/src/main/java/org/apache/tuscany/sca/data/engine/ConnectionInfoArtifactProcessor.java
new file mode 100644
index 0000000000..99709857b8
--- /dev/null
+++ b/java/sca/modules/data-engine-helper/src/main/java/org/apache/tuscany/sca/data/engine/ConnectionInfoArtifactProcessor.java
@@ -0,0 +1,197 @@
+/*
+ * 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.data.engine;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.assembly.builder.impl.ProblemImpl;
+import org.apache.tuscany.sca.assembly.xml.Constants;
+import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.contribution.service.ContributionReadException;
+import org.apache.tuscany.sca.contribution.service.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.service.ContributionWriteException;
+import org.apache.tuscany.sca.data.engine.config.ConnectionInfo;
+import org.apache.tuscany.sca.data.engine.config.ConnectionProperties;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.apache.tuscany.sca.monitor.Problem.Severity;
+
+/**
+ * Implements a StAX artifact processor for ConnectionInfo.
+ * This processor is shared between implementation.das and implementation.data component type implementations,
+ * and can be used for other applications that require database connectivity information.
+ *
+ * The artifact processor is responsible for processing <ConnectionInfo>
+ * elements in SCA assembly XML composite files.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ConnectionInfoArtifactProcessor implements StAXArtifactProcessor<ConnectionInfo> {
+ public static final QName CONNECTION_INFO = new QName(Constants.SCA10_TUSCANY_NS, "connectionInfo");
+ private static final QName CONNECTION_PROPERTIES = new QName(Constants.SCA10_TUSCANY_NS, "connectionProperties");
+
+ private Monitor monitor;
+ public ConnectionInfoArtifactProcessor(ModelFactoryExtensionPoint modelFactories, Monitor monitor) {
+ this.monitor = monitor;
+ }
+
+ public QName getArtifactType() {
+ // Returns the QName of the XML element processed by this processor
+ return CONNECTION_INFO;
+ }
+
+ /**
+ * Report a exception.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(String message, Object model, Exception ex) {
+ if (monitor != null) {
+ Problem problem = new ProblemImpl(this.getClass().getName(), "dataengine-helper-validation-messages", Severity.ERROR, model, message, ex);
+ monitor.problem(problem);
+ }
+ }
+
+ public Class<ConnectionInfo> getModelType() {
+ // Returns the type of model processed by this processor
+ return ConnectionInfo.class;
+ }
+
+ /*
+ * <component name="CompanyDataComponent">
+ * <implementation.data table="company">
+ *
+ * <connectionInfo>
+ * <connectionProperties
+ * driverClass="org.apache.derby.jdbc.EmbeddedDriver"
+ * databaseURL="jdbc:derby:target/test-classes/dastest; create = true"
+ * loginTimeout="600000"/>
+ * </connectionInfo>
+ *
+ * </implementation.data>
+ * </component>
+ */
+ public ConnectionInfo read(XMLStreamReader reader) throws ContributionReadException {
+ assert CONNECTION_INFO.equals(reader.getName());
+
+ // Create a ConnectionInfo from the component type model
+ ConnectionInfo connectionInfo = new ConnectionInfo();
+
+ /*
+ * <connectionInfo dataSource="jdbc:derby:target/test-classes/dastest; create = true"/>
+ */
+ String dataSource = reader.getAttributeValue(null, "datasource"); // exclusive with connection properties
+ if (dataSource != null && dataSource.length() > 0) {
+ connectionInfo.setDataSource(dataSource);
+ } else {
+ try {
+ int event = reader.next();
+ while (event == XMLStreamConstants.CHARACTERS) {
+ event = reader.next();
+ }
+ } catch (XMLStreamException e) {
+ ContributionReadException ce = new ContributionReadException(e);
+ error("ContributionReadException", reader, ce);
+ throw ce;
+ }
+
+ QName element = reader.getName();
+
+ assert CONNECTION_PROPERTIES.equals(element);
+
+ /*
+ * <connectionProperties
+ * driverClass="org.apache.derby.jdbc.EmbeddedDriver"
+ * databaseURL="jdbc:derby:target/test-classes/dastest; create = true"
+ * username=""
+ * password=""
+ * loginTimeout="600000"/>
+ */
+
+ String driverClass = reader.getAttributeValue(null, "driverClass");
+ String databaseURL = reader.getAttributeValue(null, "databaseURL");
+ String username = reader.getAttributeValue(null, "username");
+ String password = reader.getAttributeValue(null, "password");
+ String loginTimeout = reader.getAttributeValue(null, "loginTimeout");
+
+ // FIXME: validation sending info to monitor....
+ ConnectionProperties connectionProperties = new ConnectionProperties();
+ connectionProperties.setDriverClass(driverClass);
+ connectionProperties.setDatabaseURL(databaseURL);
+ connectionProperties.setUsername(username);
+ connectionProperties.setPassword(password);
+ if (loginTimeout != null) {
+ connectionProperties.setLoginTimeout(Integer.parseInt(loginTimeout));
+ }
+
+ connectionInfo.setConnectionProperties(connectionProperties);
+ }
+
+ return connectionInfo;
+ }
+
+ public void resolve(ConnectionInfo impl, ModelResolver resolver) throws ContributionResolveException {
+
+ }
+
+ public void write(ConnectionInfo connectionInfo, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException {
+
+ writer.writeStartElement(CONNECTION_INFO.getNamespaceURI(), CONNECTION_INFO.getLocalPart());
+
+ if (connectionInfo.getDataSource() != null) {
+ writer.writeAttribute("dataSource", connectionInfo.getDataSource());
+ }
+
+ ConnectionProperties connectionProperties = connectionInfo.getConnectionProperties();
+ if (connectionProperties != null) {
+ writer.writeStartElement(CONNECTION_PROPERTIES.getNamespaceURI(), CONNECTION_PROPERTIES.getLocalPart());
+
+ if (connectionProperties.getDriverClass() != null) {
+ writer.writeAttribute("driverClass", connectionProperties.getDriverClass());
+ }
+ if (connectionProperties.getDatabaseURL() != null) {
+ writer.writeAttribute("databaseURL", connectionProperties.getDatabaseURL());
+ }
+ if (connectionProperties.getUsername() != null) {
+ writer.writeAttribute("username", connectionProperties.getUsername());
+ }
+ if (connectionProperties.getPassword() != null) {
+ writer.writeAttribute("password", connectionProperties.getPassword());
+ }
+ if (connectionProperties.getLoginTimeout() != null) {
+ writer.writeAttribute("loginTimeout", String.valueOf(connectionProperties.getLoginTimeout()));
+ }
+
+ writer.writeEndElement();
+ }
+
+
+ writer.writeEndElement();
+
+ }
+}
diff --git a/java/sca/modules/data-engine-helper/src/main/java/org/apache/tuscany/sca/data/engine/DataAccessEngine.java b/java/sca/modules/data-engine-helper/src/main/java/org/apache/tuscany/sca/data/engine/DataAccessEngine.java
new file mode 100644
index 0000000000..aef9ac3261
--- /dev/null
+++ b/java/sca/modules/data-engine-helper/src/main/java/org/apache/tuscany/sca/data/engine/DataAccessEngine.java
@@ -0,0 +1,286 @@
+/*
+ * 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.data.engine;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.das.rdb.Command;
+import org.apache.tuscany.das.rdb.DAS;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.Property;
+
+/**
+ * Facade to hide DAS implementation details of handling commands
+ *
+ * @version $Rev$ $Date$
+ */
+public class DataAccessEngine {
+ private final DAS das;
+
+ public DataAccessEngine(DAS das) {
+ this.das = das;
+ }
+
+ public DataObject executeGet(ArrayList keyVals, String table, String key) {//TODO need to consider compound keys
+ try {
+ String sqlQuery = "select * from " + table.toUpperCase();
+ List<String> keys = null;
+
+ if(key == null) {
+ if(keyVals != null && keyVals.size() == 1) {
+ sqlQuery += " where ID = " + keyVals.get(0);
+ }
+ } else {//can be other than ID , can be compound keys
+ keys = getKeys(key);
+ if(keyVals.size() != keys.size()) {
+ throw new RuntimeException("One or more PK values missing");
+ }
+
+ sqlQuery += " where ";
+
+ for(int i=0; i<keys.size(); i++) {
+ sqlQuery += keys.get(i)+" = ? AND ";
+ }
+
+ sqlQuery = sqlQuery.substring(0, sqlQuery.lastIndexOf(" AND "));
+ }
+
+ Command command = this.das.createCommand(sqlQuery);
+
+ if(key != null) {
+ for(int i=1; i<=keyVals.size(); i++) {
+ command.setParameter(i, keyVals.get(i-1));
+ }
+ }
+
+ DataObject returnDO = command.executeQuery();
+ return returnDO;
+ } catch (Exception e) {
+ //e.printStackTrace();
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ *
+ * @param table table'e Type name - should be same as table name
+ * @param key column's Property name - should be same as column name
+ * @return
+ */
+ public Map<Object, DataObject> executeGetAll(String table, String key) {
+ try {
+ String sqlQuery = "select * from " + table.toUpperCase();
+ Command command = this.das.createCommand(sqlQuery);
+ DataObject result = command.executeQuery();
+ List<String> keys = getKeys(key);
+ List<DataObject> resultDataObjects = result.getList(table);
+
+ return getMappedDataObjects(resultDataObjects, keys);
+ } catch (Exception e) {
+ //e.printStackTrace();
+ throw new RuntimeException(e);
+ }
+ }
+
+ public Map<Object, DataObject> executeQuery(String queryString, String table, String key) {
+ try {
+ Command command = this.das.createCommand(queryString);
+ DataObject result = command.executeQuery();
+ List<String> keys = getKeys(key);
+ List<DataObject> resultDataObjects = result.getList(table);
+
+ return getMappedDataObjects(resultDataObjects, keys);
+ } catch (Exception e) {
+ //e.printStackTrace();
+ throw new RuntimeException(e);
+ }
+ }
+
+ //origDataObject should be with change summary. table, pk is already known to DAS, so no need to have these here
+ public void executePut(DataObject origDataObject) {
+ this.das.applyChanges(origDataObject);
+ return;
+ }
+
+ //return PK/s
+ public ArrayList executePost(DataObject origDataObject, String table, String key){
+ //TODO check that PKs are present before insert - this is not correct for auto incr PKs, so let it be upto user whether to send PK or not
+ /*List<String> keys = getKeys(key);
+ for(int i=0; i<keys.size(); i++) {
+ String currentKey = keys.get(i);
+ Object currentKeyValue = origDataObject.get(currentKey);
+ if(currentKeyValue == null) {
+ throw new RuntimeException("PK missing during INSERT");
+ }
+ }*/
+
+ String sqlString = "insert into "+table+" (";
+ List props = origDataObject.getType().getProperties();
+ if(props.size() != 0) {
+ for(int i=0; i<props.size(); i++) {
+ String currPropName = ((Property)props.get(i)).getName();
+ if(origDataObject.get(currPropName) != null) {
+ sqlString += currPropName+",";
+ }
+ }
+ sqlString = sqlString.substring(0, sqlString.length()-1);
+ sqlString += ") values (";
+ for(int i=0; i<props.size(); i++) {
+ String currPropName = ((Property)props.get(i)).getName();
+ if(origDataObject.get(currPropName) != null) {
+ sqlString += "?,";
+ }
+ }
+
+ sqlString = sqlString.substring(0, sqlString.length()-1);
+ sqlString += ")";
+
+ Command insertCommand = this.das.createCommand(sqlString);
+ int paramIdx = 1;
+ for(int i=1; i<=props.size(); i++) {
+ String currPropName = ((Property)props.get(i-1)).getName();
+ if(origDataObject.get(currPropName) != null) {
+ insertCommand.setParameter(paramIdx, origDataObject.get(currPropName));
+ paramIdx++;
+ }
+ }
+
+ insertCommand.execute();
+
+ //there can be different possibilities
+ //1- there is autogen key - insertCommand.getGeneratedKey() will return value and not exception
+ //2- there is no autogen key - insertCommand.getGeneratedKey() will return exception and value needs to be taken from origDataObject
+ //for 2 it is straight forward to know the column name same as property name
+ //for 1 it is possible for only 1 column so no question of compound PK
+
+ //now get the PK/s to be returned
+ ArrayList pks = new ArrayList();
+
+ try {
+ int newId = insertCommand.getGeneratedKey();
+ pks.add(newId);
+ return pks;
+ } catch(Exception e) {
+ List<String> keys = getKeys(key);
+ for(int i=0; i<keys.size(); i++) {
+ String currentKey = keys.get(i);
+ Object currentKeyValue = origDataObject.get(currentKey);
+ if(currentKeyValue == null) {
+ throw new RuntimeException("PK missing during INSERT");
+ }
+ pks.add(currentKeyValue);
+ }
+ return pks;
+ }
+
+ }
+ return null;
+ }
+
+ //when keyVal is null can be used as deleteAll
+ public void executeDelete(ArrayList keyVals, String table, String key) {
+ try {
+ String sqlQuery = "select * from " + table.toUpperCase();
+ List<String> keys = null;
+
+ if(key == null) {
+ if(keyVals != null && keyVals.size() == 1) {
+ sqlQuery += " where ID = " + keyVals.get(0);
+ }
+ } else {//can be other than ID , can be compound keys
+ keys = getKeys(key);
+ if(keyVals.size() != keys.size()) {
+ throw new RuntimeException("One or more PK values missing");
+ }
+
+ sqlQuery += " where ";
+
+ for(int i=0; i<keys.size(); i++) {
+ sqlQuery += keys.get(i)+" = ? AND ";
+ }
+
+ sqlQuery = sqlQuery.substring(0, sqlQuery.lastIndexOf(" AND "));
+ }
+
+ Command command = this.das.createCommand(sqlQuery);
+
+ if(key != null) {
+ for(int i=1; i<=keyVals.size(); i++) {
+ command.setParameter(i, keyVals.get(i-1));
+ }
+ }
+
+ DataObject result = command.executeQuery();
+ List<DataObject> resultDOs = result.getList(table);
+ if(resultDOs != null) {
+ for(int i=0; i<resultDOs.size(); i++) {
+ ((DataObject)resultDOs.get(i)).delete();
+ }
+ }
+ this.das.applyChanges(result);
+ } catch (Exception e) {
+ //e.printStackTrace();
+ throw new RuntimeException(e);
+ }
+ }
+
+ public Map<Object, DataObject> getMappedDataObjects(List<DataObject> resultDataObjects, List<String> keys) {
+ Map<Object, DataObject> resultMap = new HashMap<Object, DataObject>();
+ ArrayList<Object> keyCols = null;
+ for(int j=0; j<resultDataObjects.size(); j++) {
+ DataObject currentDO = resultDataObjects.get(j);
+
+ keyCols = new ArrayList<Object>();
+ for(int i=0; i<keys.size(); i++) {
+ String currentKey = keys.get(i);
+ Object currentKeyValue = currentDO.get(currentKey);
+ keyCols.add(currentKeyValue);
+ }
+
+ resultMap.put(keyCols, currentDO);
+ }
+ return resultMap;
+ }
+
+ public static List<String> getKeys(String key) {
+ String[] keys = key.split(",");
+ return Arrays.asList(keys);
+ }
+
+ public DataObject executeCommand(String commandName) {
+ try {
+ Command command = this.das.getCommand(commandName);
+ return command.executeQuery();
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ public DataObject executeCommand(String commandName, String xPath) {
+ DataObject root = executeCommand(commandName);
+ return root.getDataObject(xPath);
+ }
+}
diff --git a/java/sca/modules/data-engine-helper/src/main/java/org/apache/tuscany/sca/data/engine/DataAccessEngineManager.java b/java/sca/modules/data-engine-helper/src/main/java/org/apache/tuscany/sca/data/engine/DataAccessEngineManager.java
new file mode 100644
index 0000000000..572c190037
--- /dev/null
+++ b/java/sca/modules/data-engine-helper/src/main/java/org/apache/tuscany/sca/data/engine/DataAccessEngineManager.java
@@ -0,0 +1,141 @@
+/*
+ * 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.data.engine;
+
+import java.io.InputStream;
+import java.util.List;
+
+import org.apache.tuscany.das.rdb.ConfigHelper;
+import org.apache.tuscany.das.rdb.DAS;
+import org.apache.tuscany.das.rdb.config.wrapper.MappingWrapper;
+import org.apache.tuscany.sca.data.engine.config.ConnectionInfo;
+
+/**
+ * The DataAccessEngineManager acts like a registry and factory for DAS instances
+ * It holds DAS by it's config file name, reusing the same DAS for all components
+ * using the same config file.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DataAccessEngineManager {
+ //private final Map<String, DAS> registry = new HashMap<String, DAS>();
+
+ public DataAccessEngineManager() {
+ super();
+ }
+
+ protected DAS initializeDAS(String config, ConnectionInfo connectionInfo, String table, String pkColumns) throws MissingConfigFileException {
+ //load the config file
+ //System.out.println("Initializing DAS");
+
+ ConfigHelper configHelper;
+
+ if(config == null) {
+ //no config information
+ configHelper = new ConfigHelper();
+ } else {
+ //initialize the config helper by loading config file
+ configHelper = new ConfigHelper(this.getConfigStream(config));
+ }
+
+ //add additional connectionInfo if provided in the SCA Composite file
+ if( connectionInfo != null) {
+ String dataSource = connectionInfo.getDataSource();
+ if(dataSource != null && dataSource.length() > 0) {
+ configHelper.addConnectionInfo(dataSource);
+ } else {
+ String driverClass = connectionInfo.getConnectionProperties().getDriverClass();
+ String connectionURL = connectionInfo.getConnectionProperties().getDatabaseURL();
+ String userName = connectionInfo.getConnectionProperties().getUsername();
+ String password = connectionInfo.getConnectionProperties().getPassword();
+ int loginTimeout = connectionInfo.getConnectionProperties().getLoginTimeout();
+
+ configHelper.addConnectionInfo(driverClass, connectionURL, userName, password, loginTimeout);
+ }
+
+ }
+
+ if(table != null && pkColumns != null) {
+ MappingWrapper configWrapper = new MappingWrapper(configHelper.getConfig());
+ List<String> pkColsList = DataAccessEngine.getKeys(pkColumns);
+ for(int i=0; i<pkColsList.size(); i++) {
+ configWrapper.addPrimaryKey(table+"."+pkColsList.get(i), pkColsList.get(i));
+ }
+ }
+
+ DAS das = DAS.FACTORY.createDAS(configHelper.getConfig());
+
+ return das;
+ }
+
+/*
+ public DAS getDAS(String config) throws MissingConfigFileException {
+ //DAS das = registry.get(config);
+ //if ( das == null) {
+ // das = this.initializeDAS(config);
+ // this.registry.put(config, das);
+ //}
+ return initializeDAS(config, null);
+ }
+
+ public DAS getDAS(ConnectionInfo connectionInfo) {
+ assert connectionInfo != null;
+
+ //FIXME: cache the das, we need to define the keys to use (datasource and databaseurl + hashed(username + password))
+ DAS das = null;
+ try {
+ das = initializeDAS(null, connectionInfo);
+ }catch (MissingConfigFileException e) {
+ //this should never happen, as configFile == null
+ }
+
+ return das;
+ }
+*/
+ public DAS getDAS(String config, ConnectionInfo connectionInfo) throws MissingConfigFileException {
+ assert connectionInfo != null;
+
+ //FIXME: cache the das, we need to define the keys to use (datasource and databaseurl + hashed(username + password))
+
+ return initializeDAS(config, connectionInfo, null, null);
+ }
+
+ public DAS getDAS(String config, ConnectionInfo connectionInfo, String table, String pkColumns) throws MissingConfigFileException {
+ assert connectionInfo != null;
+
+ //FIXME: cache the das, we need to define the keys to use (datasource and databaseurl + hashed(username + password))
+
+ return initializeDAS(config, connectionInfo, table, pkColumns);
+ }
+
+ protected InputStream getConfigStream(String config) throws MissingConfigFileException{
+ InputStream configStream = null;
+
+ try {
+ configStream = this.getClass().getClassLoader().getResourceAsStream(config);
+ } catch (Exception e) {
+ throw new MissingConfigFileException(config);
+ }
+
+ return configStream;
+ }
+
+
+}
diff --git a/java/sca/modules/data-engine-helper/src/main/java/org/apache/tuscany/sca/data/engine/MissingConfigFileException.java b/java/sca/modules/data-engine-helper/src/main/java/org/apache/tuscany/sca/data/engine/MissingConfigFileException.java
new file mode 100644
index 0000000000..a010e089e9
--- /dev/null
+++ b/java/sca/modules/data-engine-helper/src/main/java/org/apache/tuscany/sca/data/engine/MissingConfigFileException.java
@@ -0,0 +1,44 @@
+/*
+ * 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.data.engine;
+
+import org.apache.tuscany.sca.contribution.service.ContributionReadException;
+
+
+/**
+ * Exception to be used when DAS configuration side file is not available
+ *
+ * @version $Rev$ $Date$
+ */
+public class MissingConfigFileException extends ContributionReadException {
+
+ private static final long serialVersionUID = -2616590185174691724L;
+
+ public MissingConfigFileException(String message) {
+ super(message);
+ }
+
+ public MissingConfigFileException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public MissingConfigFileException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/java/sca/modules/data-engine-helper/src/main/java/org/apache/tuscany/sca/data/engine/config/ConnectionInfo.java b/java/sca/modules/data-engine-helper/src/main/java/org/apache/tuscany/sca/data/engine/config/ConnectionInfo.java
new file mode 100644
index 0000000000..c72308f733
--- /dev/null
+++ b/java/sca/modules/data-engine-helper/src/main/java/org/apache/tuscany/sca/data/engine/config/ConnectionInfo.java
@@ -0,0 +1,47 @@
+/*
+ * 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.data.engine.config;
+
+/**
+ * Database connection information to be used for implementation.data
+ *
+ * @version $Rev$ $Date$
+ */
+public class ConnectionInfo {
+ private ConnectionProperties connectionProperties;
+
+ private String dataSource;
+
+ public String getDataSource() {
+ return this.dataSource;
+ }
+
+ public void setDataSource(String dataSource) {
+ this.dataSource = dataSource;
+ }
+
+ public ConnectionProperties getConnectionProperties() {
+ return this.connectionProperties;
+ }
+
+ public void setConnectionProperties(ConnectionProperties connectionProperties) {
+ this.connectionProperties = connectionProperties;
+ }
+
+}
diff --git a/java/sca/modules/data-engine-helper/src/main/java/org/apache/tuscany/sca/data/engine/config/ConnectionProperties.java b/java/sca/modules/data-engine-helper/src/main/java/org/apache/tuscany/sca/data/engine/config/ConnectionProperties.java
new file mode 100644
index 0000000000..df08a970b3
--- /dev/null
+++ b/java/sca/modules/data-engine-helper/src/main/java/org/apache/tuscany/sca/data/engine/config/ConnectionProperties.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.data.engine.config;
+
+/**
+ * Database connection properties to be used for implementation.data
+ *
+ * @version $Rev$ $Date$
+ */
+public class ConnectionProperties {
+
+ private String driverClass;
+
+ private String databaseURL;
+
+ private String userName;
+
+ private String password;
+
+ private Integer loginTimeOut;
+
+ public String getDriverClass() {
+ return this.driverClass;
+ }
+
+ public void setDriverClass(String driverClass) {
+ this.driverClass = driverClass;
+ }
+
+ public String getDatabaseURL() {
+ return this.databaseURL;
+ }
+
+ public void setDatabaseURL(String databaseURL) {
+ this.databaseURL = databaseURL;
+ }
+
+ public String getUsername() {
+ return this.userName;
+ }
+
+ public void setUsername(String userName) {
+ this.userName = userName;
+ }
+
+ public String getPassword() {
+ return this.password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ public Integer getLoginTimeout() {
+ return this.loginTimeOut;
+ }
+
+ public void setLoginTimeout(Integer loginTimeOut) {
+ this.loginTimeOut = loginTimeOut;
+ }
+
+}
diff --git a/java/sca/modules/data-engine-helper/src/main/resources/dataengine-helper-validation-messages.properties b/java/sca/modules/data-engine-helper/src/main/resources/dataengine-helper-validation-messages.properties
new file mode 100644
index 0000000000..b040d69cc5
--- /dev/null
+++ b/java/sca/modules/data-engine-helper/src/main/resources/dataengine-helper-validation-messages.properties
@@ -0,0 +1,21 @@
+#
+#
+# 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.
+#
+#
+ContributionReadException = ContributionReadException occured due to : \ No newline at end of file
diff --git a/java/sca/modules/implementation-bpel-jbpm/LICENSE b/java/sca/modules/implementation-bpel-jbpm/LICENSE
new file mode 100644
index 0000000000..4b5ab74408
--- /dev/null
+++ b/java/sca/modules/implementation-bpel-jbpm/LICENSE
@@ -0,0 +1,251 @@
+
+ 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.
+
+===============================================================================================================
+
+Apache Tuscany SCA for Java Subcomponents
+=========================================:
+
+The Tuscany SCA for Java release includes a number of subcomponents with
+separate copyright notices and license terms. Your use of the source
+code for the these subcomponents is subject to the terms and
+conditions of the following licenses.
+
+=================================================================================================================
+
+This module implementation-script temporarily includes one file under the following BSD license:
+
+ Copyright (c) 2006, Sun Microsystems, Inc.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ - Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ - Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ - Neither the name of the Sun Microsystems, Inc. nor the names of
+ contributors may be used to endorse or promote products derived from this
+ software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+ WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ DAMAGE.
+
+=================================================================================================================
diff --git a/java/sca/modules/implementation-bpel-jbpm/NOTICE b/java/sca/modules/implementation-bpel-jbpm/NOTICE
new file mode 100644
index 0000000000..a3c65715e5
--- /dev/null
+++ b/java/sca/modules/implementation-bpel-jbpm/NOTICE
@@ -0,0 +1,17 @@
+${pom.name}
+Copyright (c) 2005 - 2008 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
+Unless otherwise indicated, all distribution made available by the Apache Software Foundation
+is provided to you under the terms and conditions of the Apache License Version 2.0 ("AL").
+A copy of the AL is provided with this distribution as the LICENSE file present in the
+root directory, and is also available at http://www.apache.org/licenses/.
+
+This product also includes software under the BSD license
+(see the LICENSE file contained in this distribution), with
+the following copyright:
+
+Copyright (c) 2006, Sun Microsystems, Inc.
+All rights reserved.
diff --git a/java/sca/modules/implementation-bpel-jbpm/pom.xml b/java/sca/modules/implementation-bpel-jbpm/pom.xml
new file mode 100644
index 0000000000..713050a604
--- /dev/null
+++ b/java/sca/modules/implementation-bpel-jbpm/pom.xml
@@ -0,0 +1,140 @@
+<?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-implementation-bpel-jbpm</artifactId>
+ <name>Apache Tuscany SCA BPEL jBPM Implementation 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-implementation-bpel</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</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-databinding-sdo</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>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-embedded</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-wsdl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-wsdl-xml</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sdo</groupId>
+ <artifactId>tuscany-sdo-impl</artifactId>
+ <version>1.1.1</version>
+ <scope>compile</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>stax</groupId>
+ <artifactId>stax-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymock</artifactId>
+ <version>2.2</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+
+ <configuration>
+ <instructions>
+ <Bundle-Version>${tuscany.version}</Bundle-Version>
+ <Bundle-SymbolicName>org.apache.tuscany.sca.implementation.bpel.jbpm</Bundle-SymbolicName>
+ <Bundle-Description>${pom.name}</Bundle-Description>
+ <Export-Package>org.apache.tuscany.sca.implementation.bpel.jbpm*</Export-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/java/sca/modules/implementation-bpel-jbpm/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory b/java/sca/modules/implementation-bpel-jbpm/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory
new file mode 100644
index 0000000000..61d74d4c37
--- /dev/null
+++ b/java/sca/modules/implementation-bpel-jbpm/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory
@@ -0,0 +1,22 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Implementation class for the implementation extension
+#
+#
+# ==> Change this for JBPM
+#org.apache.tuscany.sca.implementation.bpel.ode.provider.BPELImplementationProviderFactory;model=org.apache.tuscany.sca.implementation.bpel.BPELImplementation
diff --git a/java/sca/modules/monitor-logging/LICENSE b/java/sca/modules/monitor-logging/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/java/sca/modules/monitor-logging/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/java/sca/modules/monitor-logging/NOTICE b/java/sca/modules/monitor-logging/NOTICE
new file mode 100644
index 0000000000..fdfa0e9faa
--- /dev/null
+++ b/java/sca/modules/monitor-logging/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2008 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/java/sca/modules/monitor-logging/pom.xml b/java/sca/modules/monitor-logging/pom.xml
new file mode 100644
index 0000000000..21c079ef48
--- /dev/null
+++ b/java/sca/modules/monitor-logging/pom.xml
@@ -0,0 +1,68 @@
+<?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-monitor-logging</artifactId>
+ <name>Apache Tuscany SCA Monitor Default Logging Implementation</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-monitor</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ </dependencies>
+
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+
+ <configuration>
+ <instructions>
+ <Bundle-Version>${tuscany.version}</Bundle-Version>
+ <Bundle-SymbolicName>org.apache.tuscany.sca.monitor.logging</Bundle-SymbolicName>
+ <Bundle-Description>${pom.name}</Bundle-Description>
+ <Export-Package>org.apache.tuscany.sca.monitor*</Export-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/java/sca/modules/monitor-logging/src/main/java/org/apache/tuscany/sca/monitor/logging/impl/DefaultLoggingMonitorImpl.java b/java/sca/modules/monitor-logging/src/main/java/org/apache/tuscany/sca/monitor/logging/impl/DefaultLoggingMonitorImpl.java
new file mode 100644
index 0000000000..8a9701b8fc
--- /dev/null
+++ b/java/sca/modules/monitor-logging/src/main/java/org/apache/tuscany/sca/monitor/logging/impl/DefaultLoggingMonitorImpl.java
@@ -0,0 +1,104 @@
+/*
+ * 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.monitor.logging.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.apache.tuscany.sca.monitor.Problem.Severity;
+
+
+/**
+ * A monitor for the watching for validation problems
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefaultLoggingMonitorImpl implements Monitor {
+ private static final Logger logger = Logger.getLogger(DefaultLoggingMonitorImpl.class.getName());
+
+ // Cache all the problem reported to monitor for further analysis
+ private List<Problem> problemCache = new ArrayList<Problem>();
+
+ public void problem(Problem problem) {
+
+ Logger problemLogger = Logger.getLogger(problem.getSourceClassName(), problem.getBundleName());
+
+ if (problemLogger == null){
+ logger.severe("Can't get logger " + problem.getSourceClassName()+ " with bundle " + problem.getBundleName());
+ }
+
+ if (problem.getSeverity() == Severity.INFO) {
+ problemCache.add(problem);
+ problemLogger.logp(Level.INFO, problem.getSourceClassName(), null,
+ problem.getMessageId(), problem.getMessageParams());
+ }
+ else if (problem.getSeverity() == Severity.WARNING) {
+ problemCache.add(problem);
+ problemLogger.logp(Level.WARNING, problem.getSourceClassName(), null,
+ problem.getMessageId(), problem.getMessageParams());
+ }
+ else if (problem.getSeverity() == Severity.ERROR) {
+ if (problem.getCause() != null) {
+ problemCache.add(problem);
+ problemLogger.logp(Level.SEVERE, problem.getSourceClassName(),
+ null, problem.getMessageId(), problem.getCause().toString());
+ } else {
+ problemCache.add(problem);
+ problemLogger.logp(Level.SEVERE, problem.getSourceClassName(), null,
+ problem.getMessageId(), problem.getMessageParams());
+ }
+ }
+ }
+
+ public List<Problem> getProblems(){
+ return problemCache;
+ }
+
+ public Problem getLastLoggedProblem() {
+ if (problemCache.isEmpty()) {
+ return null;
+ }
+ return problemCache.get(problemCache.size() - 1);
+ }
+
+ public boolean isMessageLogged(String messageId) {
+ for (Problem problem : problemCache){
+ if (problem.getMessageId().equals(messageId)){
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ public Problem getProblem(String messageId) {
+ for (Problem problem : problemCache){
+ if (problem.getMessageId().equals(messageId)){
+ return problem;
+ }
+ }
+
+ return null;
+ }
+}
diff --git a/java/sca/modules/monitor-logging/src/main/java/org/apache/tuscany/sca/monitor/logging/impl/MonitorFactoryImpl.java b/java/sca/modules/monitor-logging/src/main/java/org/apache/tuscany/sca/monitor/logging/impl/MonitorFactoryImpl.java
new file mode 100644
index 0000000000..a3162a3267
--- /dev/null
+++ b/java/sca/modules/monitor-logging/src/main/java/org/apache/tuscany/sca/monitor/logging/impl/MonitorFactoryImpl.java
@@ -0,0 +1,41 @@
+/*
+ * 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.monitor.logging.impl;
+
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.MonitorFactory;
+
+
+/**
+ * A factory for creating validation monitors
+ *
+ * @version $Rev$ $Date$
+ */
+public class MonitorFactoryImpl implements MonitorFactory {
+
+ private Monitor monitor = null;
+
+ public Monitor createMonitor() {
+ if (monitor == null){
+ monitor = new DefaultLoggingMonitorImpl();
+ }
+ return monitor ;
+ }
+}
diff --git a/java/sca/modules/monitor-logging/src/main/resources/META-INF/services/org.apache.tuscany.sca.monitor.MonitorFactory b/java/sca/modules/monitor-logging/src/main/resources/META-INF/services/org.apache.tuscany.sca.monitor.MonitorFactory
new file mode 100644
index 0000000000..b46d552fb5
--- /dev/null
+++ b/java/sca/modules/monitor-logging/src/main/resources/META-INF/services/org.apache.tuscany.sca.monitor.MonitorFactory
@@ -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.
+
+org.apache.tuscany.sca.monitor.logging.impl.MonitorFactoryImpl
diff --git a/java/sca/modules/monitor-logging/src/test/java/org/apache/tuscany/sca/monitor/MonitorTestCase.java b/java/sca/modules/monitor-logging/src/test/java/org/apache/tuscany/sca/monitor/MonitorTestCase.java
new file mode 100644
index 0000000000..c5fa6c4da6
--- /dev/null
+++ b/java/sca/modules/monitor-logging/src/test/java/org/apache/tuscany/sca/monitor/MonitorTestCase.java
@@ -0,0 +1,94 @@
+/*
+ * 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.monitor;
+
+import org.apache.tuscany.sca.assembly.builder.impl.ProblemImpl;
+import org.apache.tuscany.sca.monitor.Problem.Severity;
+import org.apache.tuscany.sca.monitor.logging.impl.MonitorFactoryImpl;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Loads a monitor and adds some problems to it.
+ *
+ * @version $Rev$ $Date$
+ */
+public class MonitorTestCase {
+
+ private static MonitorFactory monitorFactory;
+
+ @BeforeClass
+ public static void init() throws Exception {
+ monitorFactory = new MonitorFactoryImpl();
+ }
+
+ @AfterClass
+ public static void destroy() throws Exception {
+ monitorFactory = null;
+ }
+
+ @Test
+ public void testCreateProblem() throws Exception {
+ String dummyModelObject = "DUMMY MODEL OBJECT";
+
+ Monitor monitor = monitorFactory.createMonitor();
+
+ Problem problem = null;
+
+ problem = new ProblemImpl(this.getClass().getName(),
+ "tuscany-monitor-test-messages",
+ Severity.WARNING,
+ dummyModelObject,
+ "MESSAGE1" );
+ monitor.problem(problem);
+
+ String param = "Some Parameter";
+
+ problem = new ProblemImpl(this.getClass().getName(),
+ "tuscany-monitor-test-messages",
+ Severity.WARNING,
+ dummyModelObject,
+ "MESSAGE2",
+ param);
+ monitor.problem(problem);
+
+ problem = new ProblemImpl(this.getClass().getName(),
+ "tuscany-monitor-test-messages",
+ Severity.WARNING,
+ dummyModelObject,
+ "MESSAGE3",
+ 8,
+ 9,
+ 4);
+ monitor.problem(problem);
+
+ Exception ex = new IllegalStateException("TEST_MESSAGE");
+
+ problem = new ProblemImpl(this.getClass().getName(),
+ "tuscany-monitor-test-messages",
+ Severity.ERROR,
+ dummyModelObject,
+ "MESSAGE4",
+ ex);
+ monitor.problem(problem);
+
+ }
+}
diff --git a/java/sca/modules/monitor-logging/src/test/resources/tuscany-monitor-test-messages.properties b/java/sca/modules/monitor-logging/src/test/resources/tuscany-monitor-test-messages.properties
new file mode 100644
index 0000000000..523263da40
--- /dev/null
+++ b/java/sca/modules/monitor-logging/src/test/resources/tuscany-monitor-test-messages.properties
@@ -0,0 +1,24 @@
+#
+#
+# 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.
+#
+#
+MESSAGE1 = This is a test message with no params
+MESSAGE2 = This is a test message with a string param {0}
+MESSAGE3 = This is a test message with numbers {0}, {1}, {2}
+MESSAGE4 = This is a test message with exception
diff --git a/java/sca/modules/monitor-logging/src/test/resources/tuscany-monitor-test-messages_it.properties b/java/sca/modules/monitor-logging/src/test/resources/tuscany-monitor-test-messages_it.properties
new file mode 100644
index 0000000000..523263da40
--- /dev/null
+++ b/java/sca/modules/monitor-logging/src/test/resources/tuscany-monitor-test-messages_it.properties
@@ -0,0 +1,24 @@
+#
+#
+# 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.
+#
+#
+MESSAGE1 = This is a test message with no params
+MESSAGE2 = This is a test message with a string param {0}
+MESSAGE3 = This is a test message with numbers {0}, {1}, {2}
+MESSAGE4 = This is a test message with exception