summaryrefslogtreecommitdiffstats
path: root/branches/sca-java-M2/sca/services/bindings
diff options
context:
space:
mode:
authordims <dims@13f79535-47bb-0310-9956-ffa450edef68>2008-06-17 00:23:01 +0000
committerdims <dims@13f79535-47bb-0310-9956-ffa450edef68>2008-06-17 00:23:01 +0000
commitbdd0a41aed7edf21ec2a65cfa17a86af2ef8c48a (patch)
tree38a92061c0793434c4be189f1d70c3458b6bc41d /branches/sca-java-M2/sca/services/bindings
Move Tuscany from Incubator to top level.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@668359 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'branches/sca-java-M2/sca/services/bindings')
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.axis2/.ruleset190
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.axis2/LICENSE.txt202
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.axis2/NOTICE.txt14
-rwxr-xr-xbranches/sca-java-M2/sca/services/bindings/binding.axis2/pom.xml163
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/assembly/axis2.xml38
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2AsyncTargetInvoker.java84
-rwxr-xr-xbranches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2BindingBuilder.java208
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2BindingBuilderRuntimeException.java65
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2BindingRunTimeException.java48
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2CallbackInvocationHandler.java74
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2OneWayTargetInvoker.java71
-rwxr-xr-xbranches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2Reference.java187
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ReferenceCallback.java55
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ReferenceCallbackTargetInvoker.java100
-rwxr-xr-xbranches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2Service.java290
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceCallbackTargetInvoker.java114
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceInMessageReceiver.java67
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceInOutAsyncMessageReceiver.java95
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceInOutSyncMessageReceiver.java73
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceServlet.java207
-rwxr-xr-xbranches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2TargetInvoker.java136
-rwxr-xr-xbranches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/WebServiceBinding.java78
-rwxr-xr-xbranches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/WebServiceBindingLoader.java143
-rwxr-xr-xbranches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/util/TuscanyAxisConfigurator.java44
-rwxr-xr-xbranches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/util/WebServiceOperationMetaData.java491
-rwxr-xr-xbranches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/util/WebServicePortMetaData.java377
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/resources/META-INF/sca/binding.axis2.scdl48
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/resources/META-INF/sca/default.scdl49
-rwxr-xr-xbranches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/resources/org/apache/tuscany/binding/axis2/engine/config/axis2.xml302
-rwxr-xr-xbranches/sca-java-M2/sca/services/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/Axis2ReferenceTestCase.java105
-rwxr-xr-xbranches/sca-java-M2/sca/services/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/Axis2ServiceTestCase.java150
-rwxr-xr-xbranches/sca-java-M2/sca/services/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/Greeter.java31
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/GreetingCallback.java24
-rwxr-xr-xbranches/sca-java-M2/sca/services/bindings/binding.axis2/src/test/resources/wsdl/hello_world_doc_lit.wsdl169
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.celtix/.checkstyle24
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.celtix/.pmd23
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.celtix/.ruleset190
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.celtix/LICENSE.txt202
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.celtix/NOTICE.txt14
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.celtix/README.txt35
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.celtix/pom.xml96
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/BusService.java35
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/BusServiceImpl.java77
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/CeltixBindingBuilder.java104
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/CeltixInvoker.java245
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/CeltixReference.java66
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/CeltixService.java270
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/CeltixServiceInitException.java43
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/InvokerCreationException.java43
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/TuscanyWSDLManager.java89
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/WebServiceBinding.java90
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/WebServiceBindingLoader.java195
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/io/NodeDataReader.java205
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/io/NodeDataWriter.java322
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/io/RawByteArrayOutputStream.java30
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/io/SCADataBindingCallback.java83
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/io/SCAServerDataBindingCallback.java69
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/resources/META-INF/sca/default.scdl31
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.celtix/src/test/java/org/apache/tuscany/binding/celtix/BootstrapTestCase.java35
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.celtix/src/test/java/org/apache/tuscany/binding/celtix/CeltixInvokerTestCase.java134
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.celtix/src/test/java/org/apache/tuscany/binding/celtix/CeltixServiceTestCase.java129
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.celtix/src/test/java/org/apache/tuscany/binding/celtix/Greeter.java32
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.celtix/src/test/java/org/apache/tuscany/binding/celtix/GreeterImpl.java33
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.celtix/src/test/resources/wsdl/hello_world.wsdl181
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.celtix/src/test/resources/wsdl/hello_world_doc_lit.wsdl154
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.celtix/src/test/resources/wsdl/hello_world_doc_lit_inout.wsdl181
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.celtix/tuscany-checkstyle.xml288
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/.ruleset190
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/LICENSE.txt202
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/NOTICE.txt14
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/pom.xml59
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/java/org/apache/tuscany/binding/jsonrpc/JSONRPCBinding.java38
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/java/org/apache/tuscany/binding/jsonrpc/JSONRPCBindingBuilder.java56
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/java/org/apache/tuscany/binding/jsonrpc/JSONRPCBindingLoader.java57
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/java/org/apache/tuscany/binding/jsonrpc/JSONRPCEntryPointServlet.java71
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/java/org/apache/tuscany/binding/jsonrpc/JSONRPCService.java56
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/java/org/apache/tuscany/binding/jsonrpc/ScriptGetterServlet.java52
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/resources/META-INF/sca/binding.jsonrpc.scdl42
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/resources/META-INF/sca/default.scdl43
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/resources/META-INF/sca/jsonrpc_extension.scdl42
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/resources/org/apache/tuscany/binding/jsonrpc/jsonrpc.js484
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.rmi/.ruleset190
-rwxr-xr-xbranches/sca-java-M2/sca/services/bindings/binding.rmi/LICENSE.txt202
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.rmi/NOTICE.txt14
-rwxr-xr-xbranches/sca-java-M2/sca/services/bindings/binding.rmi/pom.xml63
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/NoRemoteMethodException.java37
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/NoRemoteServiceException.java37
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBinding.java57
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBindingBuilder.java78
-rwxr-xr-xbranches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBindingLoader.java64
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIInvoker.java66
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIReference.java87
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIRuntimeException.java39
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIService.java160
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RemoteMethodHandler.java47
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/host/RMIHostImpl.java136
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/resources/META-INF/sca/default.scdl55
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/resources/META-INF/sca/rmi_extension.scdl42
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/helloworld/HelloWorldImpl.java32
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/helloworld/HelloWorldRmiImpl.java45
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/helloworld/HelloWorldRmiService.java28
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/helloworld/HelloWorldService.java28
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/BindingTestCase.java54
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/NoRemoteMethodExceptionTestCase.java47
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/NoRemoteServiceExceptionTestCase.java47
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/RMIBindingBuilderTestCase.java48
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/RMIBindingLoaderTestCase.java74
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/RMIBindingTestCase.java40
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/RMIInvokerTestCase.java84
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/RMIReferenceTestCase.java48
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/RMIServiceTestCase.java53
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/RemoteMethodHandlerTestCase.java42
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/host/RMIHostImplTestCase.java76
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/resources/HelloWorldImpl.componentType27
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/resources/HelloWorldRmiImpl.componentType29
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/resources/META-INF/LICENSE.txt1277
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/resources/META-INF/NOTICE18
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/resources/META-INF/sca/default.scdl44
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.servicemix/pom.xml60
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/ScaBootstrap.java169
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/ScaComponent.java43
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/ScaDeployer.java60
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/ScaEndpoint.java157
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/ScaLifeCycle.java30
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/ScaServiceUnit.java113
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/assembly/JbiAssemblyFactory.java33
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/assembly/JbiBinding.java85
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/assembly/impl/JbiAssemblyFactoryImpl.java44
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/assembly/impl/JbiBindingImpl.java166
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/builder/ExternalJbiServiceBuilder.java151
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/builder/ExternalJbiServiceWireBuilder.java70
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/builder/JbiServiceEntryPointBuilder.java169
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/config/ExternalJbiServiceContextFactory.java30
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/config/JbiServiceEntryPointContextFactory.java30
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/handler/ExternalJbiServiceClient.java94
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/handler/ExternalJbiServiceTargetInvoker.java110
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/loader/JbiBindingLoader.java75
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/tuscany/BootstrapHelper.java125
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/tuscany/CommonsLoggingMonitorFactory.java90
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/tuscany/TuscanyRuntime.java174
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/tuscany/servicemix/JBIBinding.java47
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/tuscany/servicemix/JBIBindingLoader.java63
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/tuscany/servicemix/ServiceMixBuilder.java57
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/tuscany/servicemix/ServiceMixInvoker.java77
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/tuscany/servicemix/ServiceMixReference.java54
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/tuscany/servicemix/ServiceMixService.java42
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/jbi/META-INF/DISCLAIMER6
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/jbi/META-INF/LICENSE203
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/jbi/META-INF/NOTICE11
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/AssemblyLoaderTest.java74
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/ScaComponentTest.java110
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountReportRequest.java43
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountReportResponse.java45
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountService.java27
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountServiceImpl.java93
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountSummary.java68
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/accountdata/AccountDataService.java28
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/accountdata/AccountDataServiceImpl.java50
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/accountdata/CheckingAccount.java41
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/accountdata/SavingsAccount.java41
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/accountdata/StockAccount.java50
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/stockquote/StockQuoteRequest.java43
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/stockquote/StockQuoteResponse.java43
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/stockquote/StockQuoteService.java29
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/resources/log4j-tests.properties38
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/resources/log4j.properties39
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/resources/org/apache/servicemix/sca/bigbank/account/AccountService.wsdl80
-rw-r--r--branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/resources/org/apache/servicemix/sca/bigbank/sca.module56
-rw-r--r--branches/sca-java-M2/sca/services/bindings/pom.xml63
-rw-r--r--branches/sca-java-M2/sca/services/bindings/sunjars/build.xml56
-rw-r--r--branches/sca-java-M2/sca/services/bindings/sunjars/pom.xml102
171 files changed, 17018 insertions, 0 deletions
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.axis2/.ruleset b/branches/sca-java-M2/sca/services/bindings/binding.axis2/.ruleset
new file mode 100644
index 0000000000..70a035bc01
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.axis2/.ruleset
@@ -0,0 +1,190 @@
+<?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.
+-->
+<ruleset name="pmd-eclipse">
+ <description>PMD Plugin preferences rule set</description>
+
+
+ <rule ref="rulesets/basic.xml/BooleanInstantiation"/>
+ <rule ref="rulesets/basic.xml/CollapsibleIfStatements"/>
+ <rule ref="rulesets/basic.xml/DoubleCheckedLocking"/>
+<!--<rule ref="rulesets/basic.xml/EmptyCatchBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyFinallyBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyIfStmt"/>-->
+ <rule ref="rulesets/basic.xml/EmptyStatementNotInLoop"/>
+<!--<rule ref="rulesets/basic.xml/EmptyStaticInitializer"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptySwitchStatements"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptySynchronizedBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyTryBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyWhileStmt"/>-->
+ <rule ref="rulesets/basic.xml/ForLoopShouldBeWhileLoop"/>
+ <rule ref="rulesets/basic.xml/JumbledIncrementer"/>
+<!--<rule ref="rulesets/basic.xml/OverrideBothEqualsAndHashcode"/>-->
+ <rule ref="rulesets/basic.xml/ReturnFromFinallyBlock"/>
+ <rule ref="rulesets/basic.xml/UnconditionalIfStatement"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryConversionTemporary"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryFinalModifier"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryReturn"/>
+<!--<rule ref="rulesets/basic.xml/UselessOverridingMethod"/>-->
+
+<!--<rule ref="rulesets/braces.xml/ForLoopsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/IfElseStmtsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/IfStmtsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/WhileLoopsMustUseBraces"/>-->
+
+<!--<rule ref="rulesets/clone.xml/CloneMethodMustImplementCloneable"/>-->
+<!--<rule ref="rulesets/clone.xml/CloneThrowsCloneNotSupportedException"/>-->
+<!--<rule ref="rulesets/clone.xml/ProperCloneImplementation"/>-->
+
+<!--<rule ref="rulesets/codesize.xml/CyclomaticComplexity"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveClassLength"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveMethodLength"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveParameterList"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessivePublicCount"/>-->
+<!--<rule ref="rulesets/codesize.xml/TooManyFields"/>-->
+
+<rule ref="rulesets/controversial.xml/AssignmentInOperand"/>
+<!--<rule ref="rulesets/controversial.xml/AtLeastOneConstructor"/>-->
+<!--<rule ref="rulesets/controversial.xml/CallSuperInConstructor"/>-->
+<!--<rule ref="rulesets/controversial.xml/DontImportSun"/>-->
+<!--<rule ref="rulesets/controversial.xml/NullAssignment"/>-->
+<!--<rule ref="rulesets/controversial.xml/OnlyOneReturn"/>-->
+<!--<rule ref="rulesets/controversial.xml/SingularField"/>-->
+<!--<rule ref="rulesets/controversial.xml/SuspiciousOctalEscape"/>-->
+<!--<rule ref="rulesets/controversial.xml/UnnecessaryConstructor"/>-->
+<rule ref="rulesets/controversial.xml/UnnecessaryParentheses"/>
+<!--<rule ref="rulesets/controversial.xml/UnusedModifier"/>-->
+
+<!--<rule ref="rulesets/coupling.xml/CouplingBetweenObjects"/>-->
+<!--<rule ref="rulesets/coupling.xml/ExcessiveImports"/>-->
+<!--<rule ref="rulesets/coupling.xml/LooseCoupling"/>-->
+
+<!--<rule ref="rulesets/design.xml/AbstractClassWithoutAbstractMethod"/>-->
+<!--<rule ref="rulesets/design.xml/AccessorClassGeneration"/>-->
+<!--<rule ref="rulesets/design.xml/AssignmentToNonFinalStatic"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidDeeplyNestedIfStmts"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidInstanceofChecksInCatchClause"/>-->
+<rule ref="rulesets/design.xml/AvoidProtectedFieldInFinalClass"/>
+<!--<rule ref="rulesets/design.xml/AvoidReassigningParameters"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidSynchronizedAtMethodLevel"/>-->
+<!--<rule ref="rulesets/design.xml/BadComparison"/>-->
+<!--<rule ref="rulesets/design.xml/CloseConnection"/>-->
+<!--<rule ref="rulesets/design.xml/CompareObjectsWithEquals"/>-->
+<!--<rule ref="rulesets/design.xml/ConfusingTernary"/>-->
+<rule ref="rulesets/design.xml/ConstructorCallsOverridableMethod"/>
+<!--<rule ref="rulesets/design.xml/DefaultLabelNotLastInSwitchStmt"/>-->
+<!--<rule ref="rulesets/design.xml/FinalFieldCouldBeStatic"/>-->
+<rule ref="rulesets/design.xml/IdempotentOperations"/>
+<!--<rule ref="rulesets/design.xml/ImmutableField"/>-->
+<!--<rule ref="rulesets/design.xml/InstantiationToGetClass"/>-->
+<!--<rule ref="rulesets/design.xml/MissingBreakInSwitch"/>-->
+<!--<rule ref="rulesets/design.xml/MissingStaticMethodInNonInstantiatableClass"/>-->
+<!--<rule ref="rulesets/design.xml/NonCaseLabelInSwitchStatement"/>-->
+<!--<rule ref="rulesets/design.xml/NonStaticInitializer"/>-->
+<rule ref="rulesets/design.xml/OptimizableToArrayCall"/>
+<rule ref="rulesets/design.xml/PositionLiteralsFirstInComparisons"/>
+<rule ref="rulesets/design.xml/SimplifyBooleanExpressions"/>
+<rule ref="rulesets/design.xml/SimplifyBooleanReturns"/>
+<rule ref="rulesets/design.xml/SimplifyConditional"/>
+<!--<rule ref="rulesets/design.xml/SwitchDensity"/>-->
+<!--<rule ref="rulesets/design.xml/SwitchStmtsShouldHaveDefault"/>-->
+<rule ref="rulesets/design.xml/UnnecessaryLocalBeforeReturn"/>
+<!--<rule ref="rulesets/design.xml/UseLocaleWithCaseConversions"/>-->
+<!--<rule ref="rulesets/design.xml/UseNotifyAllInsteadOfNotify"/>-->
+<!--<rule ref="rulesets/design.xml/UseSingleton"/>-->
+
+<!--<rule ref="rulesets/finalizers.xml/EmptyFinalizer"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeOnlyCallsSuperFinalize"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeOverloaded"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeDoesNotCallSuperFinalize"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeShouldBeProtected"/>-->
+<!--<rule ref="rulesets/finalizers.xml/AvoidCallingFinalize"/>-->
+
+<!--<rule ref="rulesets/imports.xml/DuplicateImports"/>-->
+<!--<rule ref="rulesets/imports.xml/DontImportJavaLang"/>-->
+<!--<rule ref="rulesets/imports.xml/UnusedImports"/>-->
+<!--<rule ref="rulesets/imports.xml/ImportFromSamePackage"/>-->
+
+<!--<rule ref="rulesets/javabeans.xml/BeanMembersShouldSerialize"/>-->
+<!--<rule ref="rulesets/javabeans.xml/MissingSerialVersionUID"/>-->
+
+<!--<rule ref="rulesets/junit.xml/JUnitStaticSuite"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitSpelling"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitAssertionsShouldIncludeMessage"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitTestsShouldIncludeAssert"/>-->
+<!--<rule ref="rulesets/junit.xml/TestClassWithoutTestCases"/>-->
+<!--<rule ref="rulesets/junit.xml/UnnecessaryBooleanAssertion"/>-->
+<!--<rule ref="rulesets/junit.xml/UseAssertEqualsInsteadOfAssertTrue"/>-->
+<!--<rule ref="rulesets/junit.xml/UseAssertSameInsteadOfAssertTrue"/>-->
+
+ <!--<rule ref="rulesets/logging-java.xml/AvoidPrintStackTrace"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LoggerIsNotStaticFinal"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/MoreThanOneLogger"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LoggerIsNotStaticFinal"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LogBlockWithoutIf"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/SystemPrintln"/>-->
+ <!--<rule ref="rulesets/logging-jakarta-commons.xml/UseCorrectExceptionLogging"/>-->
+ <!--<rule ref="rulesets/logging-jakarta-commons.xml/ProperLogger"/>-->
+
+ <!--<rule ref="rulesets/naming.xml/ShortVariable"/>-->
+ <!--<rule ref="rulesets/naming.xml/LongVariable"/>-->
+ <!--<rule ref="rulesets/naming.xml/ShortMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/VariableNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/MethodNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/ClassNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/AbstractNaming"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidDollarSigns"/>-->
+ <!--<rule ref="rulesets/naming.xml/MethodWithSameNameAsEnclosingClass"/>-->
+ <!--<rule ref="rulesets/naming.xml/SuspiciousHashcodeMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/SuspiciousConstantFieldName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidFieldNameMatchingTypeName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidFieldNameMatchingMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidNonConstructorMethodsWithClassName"/>-->
+ <!--<rule ref="rulesets/naming.xml/NoPackage"/>-->
+ <!--<rule ref="rulesets/naming.xml/PackageCase"/>-->
+
+ <!--<rule ref="rulesets/optimizations.xml/LocalVariableCouldBeFinal"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/MethodArgumentCouldBeFinal"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/AvoidInstantiatingObjectsInLoops"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/UseArrayListInsteadOfVector"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/SimplifyStartsWith"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/UseStringBufferForStringAppends"/>-->
+
+ <!--<rule ref="rulesets/strictexception.xml/AvoidCatchingThrowable"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/SignatureDeclareThrowsException"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/ExceptionAsFlowControl"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidCatchingNPE"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidThrowingRawExceptionTypes"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidThrowingNullPointerException"/>-->
+
+ <!--<rule ref="rulesets/strings.xml/AvoidDuplicateLiterals"/>-->
+ <!--<rule ref="rulesets/strings.xml/StringInstantiation"/>-->
+ <!--<rule ref="rulesets/strings.xml/StringToString"/>-->
+ <!--<rule ref="rulesets/strings.xml/AvoidConcatenatingNonLiteralsInStringBuffer"/>-->
+ <!--<rule ref="rulesets/strings.xml/UnnecessaryCaseChange"/>-->
+
+ <!--<rule ref="rulesets/sunsecure.xml/MethodReturnsInternalArray"/>-->
+ <!--<rule ref="rulesets/sunsecure.xml/ArrayIsStoredDirectly"/>-->
+
+ <rule ref="rulesets/unusedcode.xml/UnusedLocalVariable"/>
+ <rule ref="rulesets/unusedcode.xml/UnusedPrivateField"/>
+ <rule ref="rulesets/unusedcode.xml/UnusedPrivateMethod"/>
+ <!--<rule ref="rulesets/unusedcode.xml/UnusedFormalParameter"/>-->
+
+</ruleset>
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.axis2/LICENSE.txt b/branches/sca-java-M2/sca/services/bindings/binding.axis2/LICENSE.txt
new file mode 100644
index 0000000000..0084319535
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.axis2/LICENSE.txt
@@ -0,0 +1,202 @@
+
+ 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, serviceDefinition 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/branches/sca-java-M2/sca/services/bindings/binding.axis2/NOTICE.txt b/branches/sca-java-M2/sca/services/bindings/binding.axis2/NOTICE.txt
new file mode 100644
index 0000000000..d83ebbe236
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.axis2/NOTICE.txt
@@ -0,0 +1,14 @@
+${pom.name}
+Copyright (c) 2005 - 2006 The Apache Software Foundation
+
+Apache Tuscany is an effort undergoing incubation at The Apache Software
+Foundation (ASF), sponsored by the Apache Web Services PMC. Incubation is
+required of all newly accepted projects until a further review indicates that
+the infrastructure, communications, and decision making process have stabilized
+in a manner consistent with other successful ASF projects. While incubation
+status is not necessarily a reflection of the completeness or stability of the
+code, it does indicate that the project has yet to be fully endorsed by the ASF.
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.axis2/pom.xml b/branches/sca-java-M2/sca/services/bindings/binding.axis2/pom.xml
new file mode 100755
index 0000000000..e9d32c7f9c
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.axis2/pom.xml
@@ -0,0 +1,163 @@
+<?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>
+ <parent>
+ <groupId>org.apache.tuscany.sca.services.bindings</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>axis2</artifactId>
+ <name>Apache Tuscany Binding for Axis2</name>
+ <description>Implementation of the SCA Web Services binding using Axis2.</description>
+
+ <repositories>
+ <!-- ws zones repos is for woden -->
+ <repository>
+ <id>apache.ws.zones</id>
+ <name>Apache WS zones Repository</name>
+ <url>http://ws.zones.apache.org/repository/</url>
+ <layout>legacy</layout>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.services.idl</groupId>
+ <artifactId>wsdl</artifactId>
+ <version>${sca.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <!-- A hack to bring in databinding-axiom transitively -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca.services.databinding</groupId>
+ <artifactId>databinding-axiom</artifactId>
+ <version>${sca.version}</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </dependency>
+
+ <!-- Axis2 1.1 release -->
+
+ <dependency>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>axis2-kernel</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ws.commons.axiom</groupId>
+ <artifactId>axiom-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ws.commons.axiom</groupId>
+ <artifactId>axiom-impl</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>incubator-woden</groupId>
+ <artifactId>woden</artifactId>
+ <version>1.0.0M6</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>woodstox</groupId>
+ <artifactId>wstx-asl</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ws.commons.neethi</groupId>
+ <artifactId>neethi</artifactId>
+ <version>2.0</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ws.commons.schema</groupId>
+ <artifactId>XmlSchema</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-httpclient</groupId>
+ <artifactId>commons-httpclient</artifactId>
+ <version>3.0.1</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.mail</groupId>
+ <artifactId>mail</artifactId>
+ <version>1.4</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>backport-util-concurrent</groupId>
+ <artifactId>backport-util-concurrent</artifactId>
+ <version>2.2</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ <version>1.3</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>httpcomponents-httpcore</groupId>
+ <artifactId>jakarta-httpcore</artifactId>
+ <version>4.0-alpha2</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <!-- end Axis2 1.1 release -->
+
+ <!-- test dependencies -->
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymock</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>test</artifactId>
+ <version>${sca.version}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/assembly/axis2.xml b/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/assembly/axis2.xml
new file mode 100644
index 0000000000..7c835caa5c
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/assembly/axis2.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<assembly>
+ <id>bin</id>
+ <includeBaseDirectory>false</includeBaseDirectory>
+ <formats>
+ <format>zip</format>
+ <format>tar.gz</format>
+ </formats>
+
+ <dependencySets>
+ <dependencySet>
+ <outputDirectory>extension</outputDirectory>
+ <includes>
+ <include>org.apache.tuscany.bindings:axis2</include>
+ </includes>
+ <fileMode>644</fileMode>
+ </dependencySet>
+ </dependencySets>
+</assembly>
+
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2AsyncTargetInvoker.java b/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2AsyncTargetInvoker.java
new file mode 100644
index 0000000000..0cf3976f37
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2AsyncTargetInvoker.java
@@ -0,0 +1,84 @@
+/*
+ * 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.binding.axis2;
+
+import java.lang.reflect.InvocationTargetException;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.client.OperationClient;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.InvocationRuntimeException;
+import org.apache.tuscany.spi.wire.Message;
+
+public class Axis2AsyncTargetInvoker extends Axis2TargetInvoker {
+
+ protected static final OMElement RESPONSE = null;
+
+ private InboundWire wire;
+ private Object messageId;
+ private Axis2ReferenceCallbackTargetInvoker callbackInvoker;
+
+ public Axis2AsyncTargetInvoker(ServiceClient serviceClient,
+ QName wsdlOperationName,
+ Options options,
+ SOAPFactory soapFactory,
+ InboundWire wire) {
+ super(serviceClient, wsdlOperationName, options, soapFactory);
+ this.wire = wire;
+ }
+
+ public Object invokeTarget(final Object payload) throws InvocationTargetException {
+ try {
+ Object[] args = (Object[])payload;
+ OperationClient operationClient = createOperationClient(args);
+ callbackInvoker.setCorrelationId(messageId);
+ Axis2ReferenceCallback callback = new Axis2ReferenceCallback(callbackInvoker);
+ operationClient.setCallback(callback);
+
+ operationClient.execute(false);
+
+ // REVIEW it seems ok to return null
+ return RESPONSE;
+ } catch (AxisFault e) {
+ throw new InvocationTargetException(e);
+ }
+ }
+
+ public Message invoke(Message msg) throws InvocationRuntimeException {
+ try {
+ wire.addMapping(msg.getMessageId(), msg.getFromAddress());
+ messageId = msg.getMessageId();
+ Object resp = invokeTarget(msg.getBody());
+ msg.setBody(resp);
+ } catch (Throwable e) {
+ msg.setBodyWithFault(e);
+ }
+ return msg;
+ }
+
+ public void setCallbackTargetInvoker(Axis2ReferenceCallbackTargetInvoker callbackInvoker) {
+ this.callbackInvoker = callbackInvoker;
+ }
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2BindingBuilder.java b/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2BindingBuilder.java
new file mode 100755
index 0000000000..1090be874d
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2BindingBuilder.java
@@ -0,0 +1,208 @@
+/*
+ * 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.binding.axis2;
+
+import javax.wsdl.Port;
+import javax.wsdl.PortType;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.tuscany.binding.axis2.util.TuscanyAxisConfigurator;
+import org.apache.tuscany.idl.wsdl.InterfaceWSDLIntrospector;
+import org.apache.tuscany.idl.wsdl.WSDLServiceContract;
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.builder.BuilderConfigException;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.Reference;
+import org.apache.tuscany.spi.component.Service;
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.BindingBuilderExtension;
+import org.apache.tuscany.spi.host.ServletHost;
+import org.apache.tuscany.spi.idl.InvalidServiceContractException;
+import org.apache.tuscany.spi.model.BoundReferenceDefinition;
+import org.apache.tuscany.spi.model.BoundServiceDefinition;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.wire.IncompatibleServiceContractException;
+
+/**
+ * Builds a {@link org.osoa.sca.annotations.Service} or {@link org.apache.tuscany.spi.component.Reference} configured
+ * with the Axis2 binding
+ *
+ * @version $Rev$ $Date$
+ */
+public class Axis2BindingBuilder extends BindingBuilderExtension<WebServiceBinding> {
+ private static final String OM_DATA_BINDING = OMElement.class.getName();
+
+ private ServletHost servletHost;
+
+ private ConfigurationContext configContext;
+
+ private WorkContext workContext;
+
+ private InterfaceWSDLIntrospector introspector;
+
+ public Axis2BindingBuilder() {
+ initAxis();
+ }
+
+ @Autowire(required = false)
+ public void setServletHost(ServletHost servletHost) {
+ this.servletHost = servletHost;
+ }
+
+ /**
+ * @param introspector the introspector to set
+ */
+ @Autowire
+ public void setIntrospector(InterfaceWSDLIntrospector introspector) {
+ this.introspector = introspector;
+ }
+
+ @Autowire
+ public void setWorkContext(WorkContext workContext) {
+ this.workContext = workContext;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Service build(
+ CompositeComponent parent,
+ BoundServiceDefinition<WebServiceBinding> serviceDefinition,
+ DeploymentContext deploymentContext) {
+
+ try {
+ // Set the default databinding
+ ServiceContract<?> outboundContract = serviceDefinition.getServiceContract();
+ if (WSDLServiceContract.class.isInstance(outboundContract)) {
+ outboundContract.setDataBinding(OM_DATA_BINDING);
+ }
+
+ // FIXME: We need to define how the WSDL PortType is honored in the case that
+ // both the binding.ws and interface.wsdl are in place.
+ // The WSDL portType from the WSDL Port decides the incoming SOAP message format
+ // There are also cases that interface.java is used.
+
+ ServiceContract<?> inboundContract = null;
+ WebServiceBinding wsBinding = serviceDefinition.getBinding();
+ Port port = wsBinding.getWSDLPort();
+ if (port == null) {
+ // FIXME: [rfeng] No WSDL is referenced by binding.ws, we need to create one from
+ // the outbound service contract if it's JavaServiceContract
+ inboundContract = outboundContract;
+ }
+
+ PortType portType = wsBinding.getWSDLPort().getBinding().getPortType();
+ inboundContract = introspector.introspect(portType);
+
+ // FIXME:
+ inboundContract.setInterfaceClass(serviceDefinition.getServiceContract().getInterfaceClass());
+ inboundContract.setDataBinding(OM_DATA_BINDING);
+ inboundContract.setCallbackName(serviceDefinition.getServiceContract().getCallbackName());
+
+ try {
+ wireService.checkCompatibility(inboundContract, outboundContract, true);
+ } catch (IncompatibleServiceContractException e) {
+ throw new Axis2BindingBuilderRuntimeException(e);
+ }
+
+ Service service = new Axis2Service(serviceDefinition.getName(), outboundContract, parent, wireService, wsBinding,
+ servletHost, configContext, workContext);
+ service.setBindingServiceContract(inboundContract);
+
+ return service;
+
+ } catch (InvalidServiceContractException e) {
+ throw new Axis2BindingBuilderRuntimeException(e);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public Reference build(
+ CompositeComponent parent,
+ BoundReferenceDefinition<WebServiceBinding> boundReferenceDefinition,
+ DeploymentContext deploymentContext) {
+
+ try {
+ // Set the default binding
+ ServiceContract<?> inboundContract = boundReferenceDefinition.getServiceContract();
+ if (WSDLServiceContract.class.isInstance(inboundContract)) {
+ inboundContract.setDataBinding(OM_DATA_BINDING);
+ }
+
+ // FIXME: We need to define how the WSDL PortType is honored in the case that
+ // both the binding.ws and interface.wsdl are in place
+ // The WSDL portType from the WSDL Port decides the incoming SOAP message format
+
+ ServiceContract<?> outboundContract = inboundContract;
+ WebServiceBinding wsBinding = boundReferenceDefinition.getBinding();
+ Port port = wsBinding.getWSDLPort();
+ if (port == null) {
+ // FIXME: [rfeng] No WSDL is referenced by binding.ws, we need to create one from
+ // the inbound service contract if it's JavaServiceContract
+ outboundContract = inboundContract;
+ }
+ PortType portType = port.getBinding().getPortType();
+ outboundContract = introspector.introspect(portType);
+
+ // Set the default databinding
+ outboundContract.setDataBinding(OM_DATA_BINDING);
+
+ try {
+ wireService.checkCompatibility(inboundContract, outboundContract, true);
+ } catch (IncompatibleServiceContractException e) {
+ throw new Axis2BindingBuilderRuntimeException(e);
+ }
+
+ Reference reference = new Axis2Reference(boundReferenceDefinition.getName(), parent, wireService, wsBinding,
+ inboundContract, workContext);
+ reference.setBindingServiceContract(outboundContract);
+
+ return reference;
+
+ } catch (InvalidServiceContractException e) {
+ throw new Axis2BindingBuilderRuntimeException(e);
+ }
+ }
+
+ protected Class<WebServiceBinding> getBindingType() {
+ return WebServiceBinding.class;
+ }
+
+ protected void initAxis() {
+ // TODO: Fix classloader switching. See TUSCANY-647
+ // TODO: also consider having a system component wrapping the Axis2 ConfigContext
+ ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+ ClassLoader scl = getClass().getClassLoader();
+ try {
+ if (tccl != scl) {
+ Thread.currentThread().setContextClassLoader(scl);
+ }
+ try {
+ this.configContext = new TuscanyAxisConfigurator().getConfigurationContext();
+ } catch (AxisFault e) {
+ throw new BuilderConfigException(e);
+ }
+ } finally {
+ if (tccl != scl) {
+ Thread.currentThread().setContextClassLoader(tccl);
+ }
+ }
+ }
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2BindingBuilderRuntimeException.java b/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2BindingBuilderRuntimeException.java
new file mode 100644
index 0000000000..a5743668a4
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2BindingBuilderRuntimeException.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.binding.axis2;
+
+
+/**
+ * Base class for Exceptions raised during the loading process. Loader implementations should throw a subclass of this
+ * to indicate the actual problem.
+ *
+ * @version $Rev$ $Date$
+ */
+public class Axis2BindingBuilderRuntimeException extends Axis2BindingRunTimeException {
+ private static final long serialVersionUID = -7459051598906813461L;
+ private String resourceURI;
+
+ public Axis2BindingBuilderRuntimeException() {
+ }
+
+ public Axis2BindingBuilderRuntimeException(String message) {
+ super(message);
+ }
+
+ public Axis2BindingBuilderRuntimeException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public Axis2BindingBuilderRuntimeException(Throwable cause) {
+ super(cause);
+ }
+
+ /**
+ * Returns the location of the resource that was being loaded.
+ *
+ * @return the location of the resource that was being loaded
+ */
+ public String getResourceURI() {
+ return resourceURI;
+ }
+
+ /**
+ * Sets the location of the resource that was being loaded.
+ *
+ * @param resourceURI the location of the resource that was being loaded
+ */
+ public void setResourceURI(String resourceURI) {
+ this.resourceURI = resourceURI;
+ }
+
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2BindingRunTimeException.java b/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2BindingRunTimeException.java
new file mode 100644
index 0000000000..cd957c2ec6
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2BindingRunTimeException.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.binding.axis2;
+
+import org.apache.tuscany.api.TuscanyRuntimeException;
+
+/**
+ * Denotes an error creating a new object instance
+ *
+ * @version $Rev$ $Date$
+ */
+public class Axis2BindingRunTimeException extends TuscanyRuntimeException {
+ private static final long serialVersionUID = -6423113430265944499L;
+
+ public Axis2BindingRunTimeException() {
+ super();
+ }
+
+ public Axis2BindingRunTimeException(String message) {
+ super(message);
+ }
+
+ public Axis2BindingRunTimeException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public Axis2BindingRunTimeException(Throwable cause) {
+ super(cause);
+ }
+
+}
+
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2CallbackInvocationHandler.java b/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2CallbackInvocationHandler.java
new file mode 100644
index 0000000000..4a9e054237
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2CallbackInvocationHandler.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.binding.axis2;
+
+import java.util.Map;
+
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.wire.AbstractOutboundInvocationHandler;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.OutboundInvocationChain;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+
+public class Axis2CallbackInvocationHandler extends AbstractOutboundInvocationHandler {
+
+ private InboundWire inboundWire;
+ private Object messageId;
+ private Object correlationId;
+
+ public Axis2CallbackInvocationHandler(InboundWire inboundWire) {
+ this.inboundWire = inboundWire;
+ }
+
+ public Object invoke(Operation operation, Object[] args) throws Throwable {
+ Object targetAddress = inboundWire.retrieveMapping(correlationId);
+ if (targetAddress == null) {
+ throw new AssertionError("No from address associated with message id [" + correlationId + "]");
+ }
+ //TODO optimize as this is slow in local invocations
+ Map<Operation<?>, OutboundInvocationChain> sourceCallbackInvocationChains =
+ inboundWire.getSourceCallbackInvocationChains(targetAddress);
+ OutboundInvocationChain chain = sourceCallbackInvocationChains.get(operation);
+ TargetInvoker invoker = chain.getTargetInvoker();
+ return invoke(chain, invoker, args);
+ }
+
+ // This must be called before invoke
+ public void setMessageId(Object messageId) {
+ this.messageId = messageId;
+ }
+
+ // This must be called before invoke
+ public void setCorrelationId(Object correlationId) {
+ this.correlationId = correlationId;
+ }
+
+ protected Object getFromAddress() {
+ return (inboundWire.getContainer() == null) ? null : inboundWire.getContainer().getName();
+ }
+
+ protected Object getMessageId() {
+ return messageId;
+ }
+
+ protected Object getCorrelationId() {
+ return correlationId;
+ }
+
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2OneWayTargetInvoker.java b/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2OneWayTargetInvoker.java
new file mode 100644
index 0000000000..a85c57313f
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2OneWayTargetInvoker.java
@@ -0,0 +1,71 @@
+/*
+ * 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.binding.axis2;
+
+import java.lang.reflect.InvocationTargetException;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.client.OperationClient;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
+import org.apache.tuscany.spi.wire.InvocationRuntimeException;
+import org.apache.tuscany.spi.wire.Message;
+
+public class Axis2OneWayTargetInvoker extends Axis2TargetInvoker {
+
+ protected static final OMElement RESPONSE = null;
+
+ public Axis2OneWayTargetInvoker(ServiceClient serviceClient,
+ QName wsdlOperationName,
+ Options options,
+ SOAPFactory soapFactory) {
+
+ super(serviceClient, wsdlOperationName, options, soapFactory);
+ }
+
+ public Object invokeTarget(final Object payload) throws InvocationTargetException {
+ try {
+ Object[] args = (Object[])payload;
+ OperationClient operationClient = createOperationClient(args);
+
+ operationClient.execute(false);
+
+ // REVIEW it seems ok to return null
+ return RESPONSE;
+ } catch (AxisFault e) {
+ throw new InvocationTargetException(e);
+ } catch (Throwable t) {
+ throw new Axis2BindingRunTimeException(t);
+ }
+ }
+
+ public Message invoke(Message msg) throws InvocationRuntimeException {
+ try {
+ Object resp = invokeTarget(msg.getBody());
+ msg.setBody(resp);
+ } catch (Throwable e) {
+ msg.setBodyWithFault(e);
+ }
+ return msg;
+ }
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2Reference.java b/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2Reference.java
new file mode 100755
index 0000000000..53ae1ae51e
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2Reference.java
@@ -0,0 +1,187 @@
+/*
+ * 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.binding.axis2;
+
+import java.util.Collection;
+
+import javax.wsdl.Definition;
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.transport.http.HTTPConstants;
+import org.apache.tuscany.binding.axis2.util.TuscanyAxisConfigurator;
+import org.apache.tuscany.binding.axis2.util.WebServiceOperationMetaData;
+import org.apache.tuscany.binding.axis2.util.WebServicePortMetaData;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.extension.ReferenceExtension;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.wire.OutboundWire;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+import org.apache.tuscany.spi.wire.WireService;
+
+/**
+ * Axis2Reference uses Axis2 to invoke a remote web service
+ */
+public class Axis2Reference<T> extends ReferenceExtension {
+
+ private WebServicePortMetaData wsPortMetaData;
+ private ServiceClient serviceClient;
+
+ // private WorkContext workContext;
+
+ @SuppressWarnings("unchecked")
+ public Axis2Reference(String theName,
+ CompositeComponent parent,
+ WireService wireService,
+ WebServiceBinding wsBinding,
+ ServiceContract contract,
+ WorkContext workContext) {
+ super(theName, (Class<T>)contract.getInterfaceClass(), parent, wireService);
+ try {
+ Definition wsdlDefinition = wsBinding.getWSDLDefinition();
+ wsPortMetaData =
+ new WebServicePortMetaData(wsdlDefinition, wsBinding.getWSDLPort(), wsBinding.getURI(), false);
+ serviceClient = createServiceClient(wsdlDefinition, wsPortMetaData);
+ // this.workContext = workContext;
+ } catch (AxisFault e) {
+ throw new Axis2BindingRunTimeException(e);
+ }
+ }
+
+ public TargetInvoker createTargetInvoker(ServiceContract contract, Operation operation) {
+ Axis2TargetInvoker invoker;
+ try {
+ boolean isOneWay = operation.isNonBlocking();
+ invoker = createOperationInvoker(serviceClient, operation, wsPortMetaData, false, isOneWay);
+ } catch (AxisFault e) {
+ throw new Axis2BindingRunTimeException(e);
+ }
+ return invoker;
+ }
+
+ public TargetInvoker createAsyncTargetInvoker(OutboundWire wire, Operation operation) {
+ Axis2AsyncTargetInvoker invoker;
+ try {
+ // FIXME: SDODataBinding needs to pass in TypeHelper and classLoader
+ // as parameters.
+ invoker =
+ (Axis2AsyncTargetInvoker)createOperationInvoker(serviceClient,
+ operation,
+ wsPortMetaData,
+ true,
+ false);
+ // FIXME: This makes the (BIG) assumption that there is only one
+ // callback method
+ // Relaxing this assumption, however, does not seem to be trivial,
+ // it may depend on knowledge
+ // of what actual callback method was invoked by the service at the
+ // other end
+ Operation callbackOperation = findCallbackOperation();
+ Axis2CallbackInvocationHandler invocationHandler =
+ new Axis2CallbackInvocationHandler(inboundWire);
+ Axis2ReferenceCallbackTargetInvoker callbackInvoker =
+ new Axis2ReferenceCallbackTargetInvoker(callbackOperation, inboundWire, invocationHandler);
+ invoker.setCallbackTargetInvoker(callbackInvoker);
+ } catch (AxisFault e) {
+ throw new Axis2BindingRunTimeException(e);
+ }
+ return invoker;
+ }
+
+ private Operation findCallbackOperation() {
+ ServiceContract contract = inboundWire.getServiceContract();
+ Operation callbackOperation = null;
+ Collection callbackOperations = contract.getCallbackOperations().values();
+ if (callbackOperations.size() != 1) {
+ throw new Axis2BindingRunTimeException("Can only handle one callback operation");
+ } else {
+ callbackOperation = (Operation)callbackOperations.iterator().next();
+ }
+ return callbackOperation;
+ }
+
+ /**
+ * Create an Axis2 ServiceClient
+ */
+ private ServiceClient createServiceClient(Definition wsdlDefinition, WebServicePortMetaData wsPortMetaData)
+ throws AxisFault {
+
+ TuscanyAxisConfigurator tuscanyAxisConfigurator = new TuscanyAxisConfigurator();
+ ConfigurationContext configurationContext = tuscanyAxisConfigurator.getConfigurationContext();
+ QName serviceQName = wsPortMetaData.getServiceName();
+ String portName = wsPortMetaData.getPortName().getLocalPart();
+ AxisService axisService =
+ AxisService.createClientSideAxisService(wsdlDefinition, serviceQName, portName, new Options());
+ return new ServiceClient(configurationContext, axisService);
+ }
+
+ /**
+ * Create and configure an Axis2TargetInvoker for each operations
+ */
+ private Axis2TargetInvoker createOperationInvoker(ServiceClient serviceClient,
+ Operation m,
+ WebServicePortMetaData wsPortMetaData,
+ boolean hasCallback,
+ boolean isOneWay) throws AxisFault {
+ SOAPFactory soapFactory = OMAbstractFactory.getSOAP11Factory();
+ String portTypeNS = wsPortMetaData.getPortTypeName().getNamespaceURI();
+
+ String methodName = m.getName();
+
+ WebServiceOperationMetaData operationMetaData = wsPortMetaData.getOperationMetaData(methodName);
+
+ Options options = new Options();
+ options.setTo(new EndpointReference(wsPortMetaData.getEndpoint()));
+ options.setProperty(HTTPConstants.CHUNKED, Boolean.FALSE);
+
+ String wsdlOperationName = operationMetaData.getBindingOperation().getOperation().getName();
+
+ String soapAction = wsPortMetaData.getOperationMetaData(wsdlOperationName).getSOAPAction();
+ if (soapAction != null && soapAction.length() > 1) {
+ options.setAction(soapAction);
+ }
+
+ options.setTimeOutInMilliSeconds(5 * 60 * 1000);
+
+ QName wsdlOperationQName = new QName(portTypeNS, wsdlOperationName);
+
+ Axis2TargetInvoker invoker;
+ if (hasCallback) {
+ invoker =
+ new Axis2AsyncTargetInvoker(serviceClient, wsdlOperationQName, options, soapFactory,
+ inboundWire);
+ } else if (isOneWay) {
+ invoker = new Axis2OneWayTargetInvoker(serviceClient, wsdlOperationQName, options, soapFactory);
+ } else {
+ invoker = new Axis2TargetInvoker(serviceClient, wsdlOperationQName, options, soapFactory);
+ }
+
+ return invoker;
+ }
+
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ReferenceCallback.java b/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ReferenceCallback.java
new file mode 100644
index 0000000000..d6bb1a0290
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ReferenceCallback.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.binding.axis2;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axis2.client.async.AsyncResult;
+import org.apache.axis2.client.async.Callback;
+import org.apache.axis2.context.MessageContext;
+import org.apache.tuscany.spi.wire.InvocationRuntimeException;
+
+public class Axis2ReferenceCallback extends Callback {
+
+ private Axis2ReferenceCallbackTargetInvoker targetInvoker;
+
+ public Axis2ReferenceCallback(Axis2ReferenceCallbackTargetInvoker targetInvoker) {
+ this.targetInvoker = targetInvoker;
+ }
+
+ public void onComplete(AsyncResult result) {
+ MessageContext responseMC = result.getResponseMessageContext();
+ OMElement responseOM = responseMC.getEnvelope().getBody().getFirstElement();
+ try {
+ targetInvoker.invokeTarget(new Object[] {responseOM});
+ } catch (InvocationTargetException e) {
+ // FIXME what is the appropriate exception here?
+ throw new InvocationRuntimeException(e);
+ }
+ }
+
+ public void setComplete(boolean complete) {
+ super.setComplete(complete);
+ }
+
+ public void onError(Exception e) {
+ throw new InvocationRuntimeException(e);
+ }
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ReferenceCallbackTargetInvoker.java b/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ReferenceCallbackTargetInvoker.java
new file mode 100644
index 0000000000..87f9b5654b
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ReferenceCallbackTargetInvoker.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.binding.axis2;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.InvocationRuntimeException;
+import org.apache.tuscany.spi.wire.Message;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+
+public class Axis2ReferenceCallbackTargetInvoker implements TargetInvoker {
+
+ private Operation operation;
+ private InboundWire inboundWire;
+ private Object correlationId;
+ private boolean cacheable;
+ Axis2CallbackInvocationHandler invocationHandler;
+
+ public Axis2ReferenceCallbackTargetInvoker(Operation operation,
+ InboundWire inboundWire,
+ Axis2CallbackInvocationHandler invocationHandler) {
+
+ this.operation = operation;
+ this.inboundWire = inboundWire;
+ this.invocationHandler = invocationHandler;
+ }
+
+ public Object invokeTarget(final Object payload) throws InvocationTargetException {
+ invocationHandler.setMessageId(null);
+ invocationHandler.setCorrelationId(correlationId);
+ Object[] args;
+ if (payload != null && !payload.getClass().isArray()) {
+ args = new Object[]{payload};
+ } else {
+ args = (Object[]) payload;
+ }
+ try {
+ return invocationHandler.invoke(operation, args);
+ } catch(Throwable t) {
+ t.printStackTrace();
+ throw new InvocationTargetException(t);
+ }
+ }
+
+ public Message invoke(Message msg) throws InvocationRuntimeException {
+ try {
+ Object resp = invokeTarget(msg.getBody());
+ msg.setBody(resp);
+ } catch (InvocationTargetException e) {
+ msg.setBodyWithFault(e.getCause());
+ } catch (Throwable e) {
+ msg.setBodyWithFault(e);
+ }
+ return msg;
+ }
+
+ public boolean isCacheable() {
+ return cacheable;
+ }
+
+ public void setCacheable(boolean cacheable) {
+ this.cacheable = cacheable;
+ }
+
+ public boolean isOptimizable() {
+ return isCacheable(); // we only need to check if the scopes are correct
+ }
+
+ public Axis2ReferenceCallbackTargetInvoker clone() throws CloneNotSupportedException {
+ Axis2ReferenceCallbackTargetInvoker invoker = (Axis2ReferenceCallbackTargetInvoker) super.clone();
+ invoker.operation = this.operation;
+ invoker.inboundWire = this.inboundWire;
+ invoker.correlationId = this.correlationId;
+ invoker.cacheable = this.cacheable;
+ invoker.invocationHandler = this.invocationHandler;
+ return invoker;
+ }
+
+ public void setCorrelationId(Object correlationId) {
+ this.correlationId = correlationId;
+ }
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2Service.java b/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2Service.java
new file mode 100755
index 0000000000..47c9d8308a
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2Service.java
@@ -0,0 +1,290 @@
+/*
+ * 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.binding.axis2;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.CountDownLatch;
+
+import javax.wsdl.Definition;
+import javax.wsdl.Operation;
+import javax.wsdl.PortType;
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.description.AxisOperation;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.Parameter;
+import org.apache.axis2.description.WSDL11ToAxisServiceBuilder;
+import org.apache.axis2.description.WSDLToAxisServiceBuilder;
+import org.apache.axis2.engine.MessageReceiver;
+import org.apache.axis2.wsdl.WSDLConstants;
+import org.apache.axis2.wsdl.WSDLConstants.WSDL20_2004Constants;
+import org.apache.tuscany.binding.axis2.util.WebServicePortMetaData;
+import org.apache.tuscany.spi.builder.BuilderConfigException;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.extension.ServiceExtension;
+import org.apache.tuscany.spi.host.ServletHost;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.wire.Interceptor;
+import org.apache.tuscany.spi.wire.InvocationChain;
+import org.apache.tuscany.spi.wire.Message;
+import org.apache.tuscany.spi.wire.MessageId;
+import org.apache.tuscany.spi.wire.MessageImpl;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+import org.apache.tuscany.spi.wire.WireService;
+import org.osoa.sca.annotations.Destroy;
+
+/**
+ * An implementation of a {@link ServiceExtension} configured with the Axis2
+ * binding
+ *
+ * @version $Rev$ $Date$
+ */
+public class Axis2Service extends ServiceExtension {
+ private ServiceContract<?> serviceContract;
+
+ private ServletHost servletHost;
+
+ private ConfigurationContext configContext;
+
+ private WebServiceBinding binding;
+
+ private WorkContext workContext;
+
+ private Map<MessageId, InvocationContext> invCtxMap = new HashMap<MessageId, InvocationContext>();
+
+ private String serviceName;
+
+ public Axis2Service(String theName,
+ ServiceContract<?> serviceContract,
+ CompositeComponent parent,
+ WireService wireService,
+ WebServiceBinding binding,
+ ServletHost servletHost,
+ ConfigurationContext configContext,
+ WorkContext workContext) {
+
+ super(theName, serviceContract.getInterfaceClass(), parent, wireService);
+
+ this.serviceContract = serviceContract;
+ this.binding = binding;
+ this.servletHost = servletHost;
+ this.configContext = configContext;
+ this.workContext = workContext;
+ this.serviceName = theName;
+ }
+
+ public void start() {
+ super.start();
+
+ try {
+ configContext.getAxisConfiguration().addService(createAxisService(binding));
+ } catch (AxisFault e) {
+ throw new Axis2BindingRunTimeException(e);
+ }
+
+ Axis2ServiceServlet servlet = new Axis2ServiceServlet();
+ servlet.init(configContext);
+ configContext.setContextRoot(getName());
+ servletHost.registerMapping("/" + getName(), servlet);
+ }
+
+ @Destroy
+ public void stop() {
+ servletHost.unregisterMapping("/" + getName());
+ try {
+ configContext.getAxisConfiguration().removeService(getName());
+ } catch (AxisFault e) {
+ throw new Axis2BindingRunTimeException(e);
+ }
+ super.stop();
+ }
+
+ private AxisService createAxisService(WebServiceBinding wsBinding) throws AxisFault {
+ Definition definition = wsBinding.getWSDLDefinition();
+ WebServicePortMetaData wsdlPortInfo =
+ new WebServicePortMetaData(definition, wsBinding.getWSDLPort(), null, false);
+
+ // TODO investigate if this is 20 wsdl what todo?
+ WSDLToAxisServiceBuilder builder =
+ new WSDL11ToAxisServiceBuilder(definition, wsdlPortInfo.getServiceName(), wsdlPortInfo.getPort()
+ .getName());
+ builder.setServerSide(true);
+ AxisService axisService = builder.populateService();
+
+ axisService.setName(this.getName());
+ axisService.setServiceDescription("Tuscany configured AxisService for service: '" + this.getName()
+ + "'");
+
+ // Use the existing WSDL
+ Parameter wsdlParam = new Parameter(WSDLConstants.WSDL_4_J_DEFINITION, null);
+ wsdlParam.setValue(definition);
+ axisService.addParameter(wsdlParam);
+ Parameter userWSDL = new Parameter("useOriginalwsdl", "true");
+ axisService.addParameter(userWSDL);
+
+ PortType wsdlPortType = wsdlPortInfo.getPortType();
+ for (Object o : wsdlPortType.getOperations()) {
+ Operation wsdlOperation = (Operation)o;
+ String operationName = wsdlOperation.getName();
+ QName operationQN = new QName(definition.getTargetNamespace(), operationName);
+
+ org.apache.tuscany.spi.model.Operation<?> op = serviceContract.getOperations().get(operationName);
+
+ MessageReceiver msgrec = null;
+ boolean opIsNonBlocking = op.isNonBlocking();
+ if (serviceContract.getCallbackName() != null) {
+ msgrec = new Axis2ServiceInOutAsyncMessageReceiver(this, op, workContext);
+ } else if (opIsNonBlocking) {
+ msgrec = new Axis2ServiceInMessageReceiver(this, op);
+ } else {
+ msgrec = new Axis2ServiceInOutSyncMessageReceiver(this, op);
+ }
+
+ AxisOperation axisOp = axisService.getOperation(operationQN);
+ if (opIsNonBlocking) {
+ axisOp.setMessageExchangePattern(WSDL20_2004Constants.MEP_URI_IN_ONLY);
+ } else {
+ axisOp.setMessageExchangePattern(WSDL20_2004Constants.MEP_URI_IN_OUT);
+ }
+ axisOp.setMessageReceiver(msgrec);
+ }
+
+ return axisService;
+ }
+
+ public Object invokeTarget(org.apache.tuscany.spi.model.Operation<?> op, Object[] args)
+ throws InvocationTargetException {
+ InvocationChain chain = inboundWire.getInvocationChains().get(op);
+ Interceptor headInterceptor = chain.getHeadInterceptor();
+ if (headInterceptor == null) {
+ try {
+ // short-circuit the dispatch and invoke the target directly
+ if (chain.getTargetInvoker() == null) {
+ throw new AssertionError("No target invoker [" + chain.getOperation().getName() + "]");
+ }
+ return chain.getTargetInvoker().invokeTarget(args);
+ } catch (InvocationTargetException e) {
+ // the cause was thrown by the target so throw it
+ throw e;
+ }
+ } else {
+ Object messageId = workContext.getCurrentMessageId();
+ workContext.setCurrentMessageId(null);
+ Object correlationId = workContext.getCurrentCorrelationId();
+ workContext.setCurrentCorrelationId(null);
+
+ Message msg = new MessageImpl();
+ msg.setTargetInvoker(chain.getTargetInvoker());
+ msg.setFromAddress(getFromAddress());
+ if (messageId == null) {
+ messageId = new MessageId();
+ }
+ msg.setMessageId(messageId);
+ msg.setCorrelationId(correlationId);
+ msg.setBody(args);
+ Message resp;
+ // dispatch the wire down the chain and get the response
+ // TODO http://issues.apache.org/jira/browse/TUSCANY-777
+ ClassLoader oldtccl = Thread.currentThread().getContextClassLoader();
+ try {
+ Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
+ resp = headInterceptor.invoke(msg);
+ } finally {
+ Thread.currentThread().setContextClassLoader(oldtccl);
+ }
+ Object body = resp.getBody();
+ if (resp.isFault()) {
+ throw new InvocationTargetException((Throwable)body);
+ }
+ return body;
+ }
+ }
+
+ protected Object getFromAddress() {
+ return this.serviceName;
+ }
+
+ /**
+ * Get the Method from an interface matching the WSDL operation name
+ */
+ protected Method getMethod(Class<?> serviceInterface, String operationName) {
+ // Note: this doesn't support overloaded operations
+ Method[] methods = serviceInterface.getMethods();
+ for (Method m : methods) {
+ if (m.getName().equals(operationName)) {
+ return m;
+ }
+ // tolerate WSDL with capatalized operation name
+ StringBuilder sb = new StringBuilder(operationName);
+ sb.setCharAt(0, Character.toLowerCase(sb.charAt(0)));
+ if (m.getName().equals(sb.toString())) {
+ return m;
+ }
+ }
+ throw new BuilderConfigException("no operation named " + operationName
+ + " found on service interface: "
+ + serviceInterface.getName());
+ }
+
+ public TargetInvoker createCallbackTargetInvoker(ServiceContract contract,
+ org.apache.tuscany.spi.model.Operation operation) {
+
+ return new Axis2ServiceCallbackTargetInvoker(workContext, this);
+ }
+
+ public void addMapping(MessageId msgId, InvocationContext invCtx) {
+ this.invCtxMap.put(msgId, invCtx);
+ }
+
+ public InvocationContext retrieveMapping(MessageId msgId) {
+ return this.invCtxMap.get(msgId);
+ }
+
+ public void removeMapping(MessageId msgId) {
+ this.invCtxMap.remove(msgId);
+ }
+
+ protected class InvocationContext {
+ public MessageContext inMessageContext;
+
+ public org.apache.tuscany.spi.model.Operation<?> operation;
+
+ public SOAPFactory soapFactory;
+
+ public CountDownLatch doneSignal;
+
+ public InvocationContext(MessageContext messageCtx,
+ org.apache.tuscany.spi.model.Operation<?> operation,
+ SOAPFactory soapFactory,
+ CountDownLatch doneSignal) {
+ this.inMessageContext = messageCtx;
+ this.operation = operation;
+ this.soapFactory = soapFactory;
+ this.doneSignal = doneSignal;
+ }
+ }
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceCallbackTargetInvoker.java b/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceCallbackTargetInvoker.java
new file mode 100644
index 0000000000..ca7812e01b
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceCallbackTargetInvoker.java
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.binding.axis2;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.engine.AxisEngine;
+import org.apache.axis2.util.Utils;
+import org.apache.tuscany.binding.axis2.Axis2Service.InvocationContext;
+import org.apache.tuscany.binding.axis2.Axis2AsyncTargetInvoker;
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.wire.InvocationRuntimeException;
+import org.apache.tuscany.spi.wire.Message;
+import org.apache.tuscany.spi.wire.MessageId;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+
+public class Axis2ServiceCallbackTargetInvoker implements TargetInvoker {
+
+ private Axis2Service service;
+
+ private MessageId currentCorrelationId;
+
+ public Axis2ServiceCallbackTargetInvoker(WorkContext workContext, Axis2Service service) {
+ this.service = service;
+ }
+
+ public Object invokeTarget(final Object payload) throws InvocationTargetException {
+ try {
+ // Use current correlation id as index to retrieve inv context
+ InvocationContext invCtx = service.retrieveMapping(this.currentCorrelationId);
+
+ MessageContext outMC = Utils.createOutMessageContext(invCtx.inMessageContext);
+ outMC.getOperationContext().addMessageContext(outMC);
+
+ OMElement responseOM = null;
+ if (payload != null && !payload.getClass().isArray()) {
+ responseOM = (OMElement)payload;
+ } else {
+ responseOM = (OMElement)((Object[])payload)[0];
+ }
+ SOAPEnvelope soapEnvelope = invCtx.soapFactory.getDefaultEnvelope();
+ soapEnvelope.getBody().addChild(responseOM);
+ outMC.setEnvelope(soapEnvelope);
+ outMC.getOperationContext().setProperty(Constants.RESPONSE_WRITTEN, Constants.VALUE_TRUE);
+
+ AxisEngine engine =
+ new AxisEngine(invCtx.inMessageContext.getOperationContext().getServiceContext().getConfigurationContext());
+ engine.send(outMC);
+
+ invCtx.doneSignal.countDown();
+
+ service.removeMapping(this.currentCorrelationId);
+ } catch (AxisFault e) {
+ throw new InvocationTargetException(e);
+ } catch(Throwable t) {
+ throw new Axis2BindingRunTimeException(t);
+ }
+
+ return Axis2AsyncTargetInvoker.RESPONSE;
+ }
+
+ public Message invoke(Message msg) throws InvocationRuntimeException {
+ try {
+ this.currentCorrelationId = (MessageId)msg.getCorrelationId();
+ Object resp = invokeTarget(msg.getBody());
+ msg.setBody(resp);
+ } catch (Throwable e) {
+ msg.setBodyWithFault(e);
+ }
+ return msg;
+ }
+
+ public Axis2ServiceCallbackTargetInvoker clone() throws CloneNotSupportedException {
+ try {
+ return (Axis2ServiceCallbackTargetInvoker)super.clone();
+ } catch (CloneNotSupportedException e) {
+ // will not happen
+ return null;
+ }
+ }
+
+ public boolean isCacheable() {
+ return true;
+ }
+
+ public void setCacheable(boolean cacheable) {
+
+ }
+
+ public boolean isOptimizable() {
+ return false;
+ }
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceInMessageReceiver.java b/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceInMessageReceiver.java
new file mode 100644
index 0000000000..3b1b0d25e4
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceInMessageReceiver.java
@@ -0,0 +1,67 @@
+/*
+ * 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.binding.axis2;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.receivers.AbstractInMessageReceiver;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.wire.InvocationRuntimeException;
+
+public class Axis2ServiceInMessageReceiver extends AbstractInMessageReceiver {
+
+ protected Operation<?> operation;
+
+ private Axis2Service axis2Service;
+
+ public Axis2ServiceInMessageReceiver(Axis2Service service, Operation<?> operation) {
+ this.axis2Service = service;
+ this.operation = operation;
+ }
+
+ public Axis2ServiceInMessageReceiver() {
+
+ }
+
+ @Override
+ public void invokeBusinessLogic(MessageContext inMC) throws AxisFault {
+ try {
+ OMElement requestOM = inMC.getEnvelope().getBody().getFirstElement();
+ Object[] args = new Object[] {requestOM};
+
+ axis2Service.invokeTarget(operation, args);
+
+ } catch (InvocationTargetException e) {
+ Throwable t = e.getCause();
+ if (t instanceof Exception) {
+ throw AxisFault.makeFault((Exception)t);
+ }
+ throw new InvocationRuntimeException(e);
+ } catch (Throwable t) {
+ if (t instanceof Exception) {
+ throw AxisFault.makeFault((Exception)t);
+ }
+ throw new Axis2BindingRunTimeException(t);
+ }
+
+ }
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceInOutAsyncMessageReceiver.java b/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceInOutAsyncMessageReceiver.java
new file mode 100644
index 0000000000..f83862399c
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceInOutAsyncMessageReceiver.java
@@ -0,0 +1,95 @@
+/*
+ * 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.binding.axis2;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.concurrent.CountDownLatch;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.receivers.AbstractMessageReceiver;
+import org.apache.tuscany.binding.axis2.Axis2Service.InvocationContext;
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.wire.InvocationRuntimeException;
+import org.apache.tuscany.spi.wire.MessageId;
+
+public class Axis2ServiceInOutAsyncMessageReceiver extends AbstractMessageReceiver {
+
+ private Operation<?> operation;
+
+ private WorkContext workContext;
+
+ private Axis2Service service;
+
+ public Axis2ServiceInOutAsyncMessageReceiver(Axis2Service service,
+ Operation operation,
+ WorkContext workContext) {
+ this.operation = operation;
+ this.workContext = workContext;
+ this.service = service;
+ }
+
+ public Axis2ServiceInOutAsyncMessageReceiver() {
+ }
+
+ public final void receive(final MessageContext messageCtx) {
+ try {
+ // Create a new message id and hand it to
+ // JDKInboundInvocationHandler
+ // via work context
+ MessageId messageId = new MessageId();
+ workContext.setCurrentMessageId(messageId);
+ // Now use message id as index to context to be used by callback
+ // target invoker
+ CountDownLatch doneSignal = new CountDownLatch(1);
+ InvocationContext invCtx =
+ service.new InvocationContext(messageCtx, operation, getSOAPFactory(messageCtx), doneSignal);
+ service.addMapping(messageId, invCtx);
+
+ invokeBusinessLogic(messageCtx);
+
+ try {
+ doneSignal.await();
+ } catch(InterruptedException e) {
+ e.printStackTrace();
+ }
+ } catch (AxisFault e) {
+ // log.error(e);
+ }
+ }
+
+ public void invokeBusinessLogic(MessageContext inMC) throws AxisFault {
+ try {
+ OMElement requestOM = inMC.getEnvelope().getBody().getFirstElement();
+ Object[] args = new Object[] {requestOM};
+ service.invokeTarget(operation, args);
+ } catch (InvocationTargetException e) {
+ Throwable t = e.getCause();
+ if (t instanceof Exception) {
+ throw AxisFault.makeFault((Exception)t);
+ }
+ throw new InvocationRuntimeException(e);
+ } catch (Exception e) {
+ throw AxisFault.makeFault(e);
+ }
+
+ }
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceInOutSyncMessageReceiver.java b/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceInOutSyncMessageReceiver.java
new file mode 100644
index 0000000000..4522632d9f
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceInOutSyncMessageReceiver.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 org.apache.tuscany.binding.axis2;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.wire.InvocationRuntimeException;
+
+public class Axis2ServiceInOutSyncMessageReceiver extends AbstractInOutSyncMessageReceiver {
+
+ protected Operation<?> operation;
+
+ private Axis2Service axis2Service;
+
+ public Axis2ServiceInOutSyncMessageReceiver(Axis2Service service, Operation<?> operation) {
+ this.axis2Service = service;
+ this.operation = operation;
+ }
+
+ public Axis2ServiceInOutSyncMessageReceiver() {
+
+ }
+
+ @Override
+ public void invokeBusinessLogic(MessageContext inMC, MessageContext outMC) throws AxisFault {
+ try {
+ OMElement requestOM = inMC.getEnvelope().getBody().getFirstElement();
+ Object[] args = new Object[] {requestOM};
+
+ OMElement responseOM = (OMElement)axis2Service.invokeTarget(operation, args);
+
+ SOAPEnvelope soapEnvelope = getSOAPFactory(inMC).getDefaultEnvelope();
+ soapEnvelope.getBody().addChild(responseOM);
+ outMC.setEnvelope(soapEnvelope);
+ outMC.getOperationContext().setProperty(Constants.RESPONSE_WRITTEN, Constants.VALUE_TRUE);
+
+ } catch (InvocationTargetException e) {
+ e.printStackTrace();
+ Throwable t = e.getCause();
+ if (t instanceof Exception) {
+ throw AxisFault.makeFault((Exception)t);
+ }
+ throw new InvocationRuntimeException(e);
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw AxisFault.makeFault(e);
+ }
+
+ }
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceServlet.java b/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceServlet.java
new file mode 100644
index 0000000000..cab5b28ee7
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceServlet.java
@@ -0,0 +1,207 @@
+/*
+ * 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.binding.axis2;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.Set;
+import java.util.Vector;
+
+import javax.servlet.RequestDispatcher;
+import javax.servlet.Servlet;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.transport.http.AxisServlet;
+
+/**
+ * This overrides the servlet init of the AxisServlet so Tuscany can use
+ * a single Axis2 ConfigurationContext instance shared between AxisServlet
+ * instances for each SCA service with a ws binding.
+ * TODO: need to review if thats really what we want to be doing
+ */
+public class Axis2ServiceServlet extends AxisServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ private static final ServletConfig DUMMY_CONFIG = createDummyServletConfig();
+
+ private boolean inited;
+
+ public void init(ConfigurationContext configContext) {
+ this.configContext = configContext;
+ try {
+ super.init(DUMMY_CONFIG);
+ } catch (ServletException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * We've setup the Servlet by passing in a ConfigurationContext on our init method
+ * override this method to just return that
+ */
+ @Override
+ protected ConfigurationContext initConfigContext(ServletConfig config) throws ServletException {
+ return this.configContext;
+ }
+
+ /**
+ * The AxisServlet gets NPE during init without a ServletConfig so this is a mocked up one to prevent that.
+ */
+ private static ServletConfig createDummyServletConfig() {
+ ServletConfig sc = new ServletConfig() {
+
+ public String getServletName() {
+ return "TuscanyAxis2DummyServlet";
+ }
+
+ public ServletContext getServletContext() {
+ return new ServletContext() {
+
+ public ServletContext getContext(String uripath) {
+ return null;
+ }
+
+ public int getMajorVersion() {
+ return 0;
+ }
+
+ public int getMinorVersion() {
+ return 0;
+ }
+
+ public String getMimeType(String file) {
+ return null;
+ }
+
+ public Set getResourcePaths(String path) {
+ return Collections.emptySet();
+ }
+
+ public URL getResource(String path) throws MalformedURLException {
+ if("/".equals(path)) {
+ // HACK: To avoid NPE
+ return new URL("/axis2");
+ }
+ return null;
+ }
+
+ public InputStream getResourceAsStream(String path) {
+ return null;
+ }
+
+ public RequestDispatcher getRequestDispatcher(String path) {
+ return null;
+ }
+
+ public RequestDispatcher getNamedDispatcher(String arg0) {
+ return null;
+ }
+
+ public Servlet getServlet(String arg0) throws ServletException {
+ return null;
+ }
+
+ public Enumeration getServlets() {
+ return null;
+ }
+
+ public Enumeration getServletNames() {
+ return null;
+ }
+
+ public void log(String arg0) {
+ }
+
+ public void log(Exception arg0, String arg1) {
+ }
+
+ public void log(String arg0, Throwable arg1) {
+ }
+
+ public String getRealPath(String arg0) {
+ return null;
+ }
+
+ public String getServerInfo() {
+ return null;
+ }
+
+ public String getInitParameter(String arg0) {
+ return null;
+ }
+
+ public Enumeration getInitParameterNames() {
+ return null;
+ }
+
+ public Object getAttribute(String arg0) {
+ return null;
+ }
+
+ public Enumeration getAttributeNames() {
+ return null;
+ }
+
+ public void setAttribute(String arg0, Object arg1) {
+ }
+
+ public void removeAttribute(String arg0) {
+ }
+
+ public String getServletContextName() {
+ return null;
+ }
+ };
+ }
+
+ public String getInitParameter(String arg0) {
+ return null;
+ }
+
+ public Enumeration getInitParameterNames() {
+ return new Vector().elements();
+ }
+ };
+ return sc;
+ }
+
+ @Override
+ protected void service(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ // HACK: Get the correct context root which is not available during init() call
+ if (!inited) {
+ synchronized (configContext) {
+ configContext.setContextRoot(request.getContextPath());
+ inited = true;
+ }
+ }
+ super.service(request, response);
+ }
+
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2TargetInvoker.java b/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2TargetInvoker.java
new file mode 100755
index 0000000000..175f995c76
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2TargetInvoker.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.binding.axis2;
+
+import java.lang.reflect.InvocationTargetException;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.soap.SOAPBody;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.client.OperationClient;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.wsdl.WSDLConstants;
+import org.apache.tuscany.spi.wire.InvocationRuntimeException;
+import org.apache.tuscany.spi.wire.Message;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+
+/**
+ * Axis2TargetInvoker uses an Axis2 OperationClient to invoke a remote web service
+ */
+public class Axis2TargetInvoker implements TargetInvoker {
+
+ private QName wsdlOperationName;
+
+ private Options options;
+
+ private SOAPFactory soapFactory;
+
+ private ServiceClient serviceClient;
+
+ public Axis2TargetInvoker(ServiceClient serviceClient, QName wsdlOperationName, Options options,
+ SOAPFactory soapFactory) {
+ this.wsdlOperationName = wsdlOperationName;
+ this.options = options;
+ this.soapFactory = soapFactory;
+ this.serviceClient = serviceClient;
+ }
+
+ /**
+ * Invoke a WS operation
+ *
+ * @param payload
+ * @return
+ * @throws InvocationTargetException
+ */
+ public Object invokeTarget(final Object payload) throws InvocationTargetException {
+ try {
+ Object[] args = (Object[]) payload;
+ OperationClient operationClient = createOperationClient(args);
+
+ operationClient.execute(true);
+
+ MessageContext responseMC = operationClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
+ return responseMC.getEnvelope().getBody().getFirstElement();
+
+ } catch (AxisFault e) {
+ throw new InvocationTargetException(e);
+ }
+
+ }
+
+ protected OperationClient createOperationClient(Object[] args) throws AxisFault {
+ SOAPEnvelope env = soapFactory.getDefaultEnvelope();
+ if (args != null && args.length > 0) {
+ SOAPBody body = env.getBody();
+ for (Object bc : args) {
+ if (bc instanceof OMElement) {
+ body.addChild((OMElement) bc);
+ } else {
+ throw new IllegalArgumentException(
+ "Can't handle mixed payloads betweem OMElements and other types.");
+ }
+ }
+ }
+ MessageContext requestMC = new MessageContext();
+ requestMC.setEnvelope(env);
+ // Axis2 operationClients can not be shared so create a new one for each request
+ OperationClient operationClient = serviceClient.createClient(wsdlOperationName);
+ operationClient.setOptions(options);
+ operationClient.addMessageContext(requestMC);
+ return operationClient;
+ }
+
+ public Message invoke(Message msg) throws InvocationRuntimeException {
+ try {
+ Object resp = invokeTarget(msg.getBody());
+ msg.setBody(resp);
+ } catch (Throwable e) {
+ msg.setBodyWithFault(e);
+ }
+ return msg;
+ }
+
+ public Axis2TargetInvoker clone() throws CloneNotSupportedException {
+ try {
+ return (Axis2TargetInvoker) super.clone();
+ } catch (CloneNotSupportedException e) {
+ // will not happen
+ return null;
+ }
+ }
+
+ public boolean isCacheable() {
+ return true;
+ }
+
+ public void setCacheable(boolean cacheable) {
+
+ }
+
+ public boolean isOptimizable() {
+ return false;
+ }
+
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/WebServiceBinding.java b/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/WebServiceBinding.java
new file mode 100755
index 0000000000..6d4ec6eaf9
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/WebServiceBinding.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.binding.axis2;
+
+
+import javax.wsdl.Definition;
+import javax.wsdl.Port;
+import javax.wsdl.Service;
+import org.apache.tuscany.spi.model.Binding;
+
+/**
+ * Represents a Celtix binding configuration in an assembly
+ *
+ * @version $Rev$ $Date$
+ */
+public class WebServiceBinding extends Binding {
+
+ private Definition definition;
+ private Port port;
+ private Service service;
+ //private String portURI;
+ private String uri;
+ public WebServiceBinding(Definition definition, Port port, String uri, String portURI, Service service) {
+ this.definition = definition;
+ this.port = port;
+ this.uri = uri;
+ //this.portURI = portURI;
+ this.service = service;
+ }
+
+ public Port getWSDLPort() {
+ return port;
+ }
+
+ public Service getWSDLService() {
+ return service;
+ }
+
+ public void setWSDLPort(Port value) {
+ port = value;
+ }
+
+ public Definition getWSDLDefinition() {
+ return definition;
+ }
+
+ public void setWSDLDefinition(Definition def) {
+ definition = def;
+ }
+
+ // public void setPortURI(String uri) {
+ // portURI = uri;
+ // }
+
+ public String getURI() {
+ return uri;
+ }
+
+ public void setURI(String theUri) {
+ this.uri = theUri;
+ }
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/WebServiceBindingLoader.java b/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/WebServiceBindingLoader.java
new file mode 100755
index 0000000000..5535dbb5c2
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/WebServiceBindingLoader.java
@@ -0,0 +1,143 @@
+/*
+ * 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.binding.axis2;
+
+import static org.osoa.sca.Version.XML_NAMESPACE_1_0;
+
+import java.io.IOException;
+import java.util.Collection;
+
+import javax.wsdl.Definition;
+import javax.wsdl.Port;
+import javax.wsdl.Service;
+import javax.wsdl.WSDLException;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.idl.wsdl.WSDLDefinitionRegistry;
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.LoaderExtension;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.loader.LoaderRegistry;
+import org.apache.tuscany.spi.loader.LoaderUtil;
+import org.osoa.sca.annotations.Constructor;
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * Parses a <code>WebServiceBinding</code> entry in an assembly XML file
+ *
+ * @version $Rev$ $Date$
+ */
+@Scope("MODULE")
+@SuppressWarnings("deprecation")
+public class WebServiceBindingLoader extends LoaderExtension<WebServiceBinding> {
+ public static final QName BINDING_WS = new QName(XML_NAMESPACE_1_0, "binding.ws");
+
+ private WSDLDefinitionRegistry wsdlDefinitionRegistry;
+
+ @Constructor( { "loaderRegistry", "wsdlDefinitionRegistry" })
+ public WebServiceBindingLoader(@Autowire LoaderRegistry loaderRegistry,
+ @Autowire WSDLDefinitionRegistry wsdlDefinitionRegistry) {
+ super(loaderRegistry);
+ this.wsdlDefinitionRegistry = wsdlDefinitionRegistry;
+ }
+
+ public QName getXMLType() {
+ return BINDING_WS;
+ }
+
+ public WebServiceBinding load(CompositeComponent parent, XMLStreamReader reader, DeploymentContext deploymentContext)
+ throws XMLStreamException, LoaderException {
+ // not sure what uri was here ? String uri = reader.getAttributeValue(null, "uri");
+ String uri = null;
+ String endpoint = reader.getAttributeValue(null, "endpoint");
+ String wsdlLocation = reader.getAttributeValue(null, "location");
+ LoaderUtil.skipToEndElement(reader);
+ try {
+ return createBinding(uri, endpoint, wsdlLocation, deploymentContext);
+ } catch (Exception e) {
+ throw new LoaderException(e);
+ }
+
+ }
+
+ @SuppressWarnings("unchecked")
+ private WebServiceBinding createBinding(String uri, String endpoint, String wsdlLocation, DeploymentContext deploymentContext)
+ throws WSDLException, IOException, LoaderException {
+ // Get the WSDL port namespace and name
+ if (uri == null && endpoint != null) {
+ int h = endpoint.indexOf('#');
+ String serviceName;
+ String portName;
+
+ String namespace = endpoint.substring(0, h);
+ String fragment = endpoint.substring(h + 1);
+ if (fragment.startsWith("wsdl.endpoint(") && fragment.endsWith(")")) {
+ fragment = fragment.substring(14, fragment.length() - 1);
+ int slash = fragment.indexOf('/');
+ if (slash != -1) {
+ serviceName = fragment.substring(0, slash);
+ portName = fragment.substring(slash + 1);
+ } else {
+ serviceName = null;
+ portName = fragment;
+ }
+ } else {
+ serviceName = null;
+ portName = fragment;
+ }
+ // FIXME need to find out how to get wsdl and what context to use --- terrible hack attack!
+ if (null == wsdlLocation) {
+ throw new Axis2BindingRunTimeException(
+ "Failed to determine wsdl location on binding. Try specifying 'location' attribute on binding.");
+ }
+ Definition definition =
+ wsdlDefinitionRegistry.loadDefinition(namespace+" "+wsdlLocation, deploymentContext.getClassLoader());
+
+ Port thePort = null;
+ Service service = null;
+ // Find the port with the given name
+ for (Service serv : (Collection<Service>) definition.getServices().values()) {
+ QName sqn = serv.getQName();
+ if (serviceName != null && !serviceName.equals(sqn.getLocalPart())) {
+ continue;
+ }
+
+ Port p = serv.getPort(portName);
+ if (p != null) {
+ service = serv;
+ thePort = p;
+ break;
+ }
+ }
+ if (thePort == null) {
+ throw new IllegalArgumentException("Cannot find WSDL port " + endpoint);
+
+ }
+ return new WebServiceBinding(definition, thePort, uri, endpoint, service);
+ }
+ // FIXME: Find the first port?
+ throw new LoaderException("Web Service endpoint cannot be resolved: " + endpoint);
+
+ }
+
+} \ No newline at end of file
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/util/TuscanyAxisConfigurator.java b/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/util/TuscanyAxisConfigurator.java
new file mode 100755
index 0000000000..c0ef46fee3
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/util/TuscanyAxisConfigurator.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.binding.axis2.util;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ConfigurationContextFactory;
+import org.apache.axis2.deployment.URLBasedAxisConfigurator;
+import org.apache.axis2.engine.AxisConfigurator;
+
+/**
+ * Helps configure Axis2 from a resource in binding.axis2 instead of Axis2.xml
+ * <p/> TODO: Review: should there be a single global Axis
+ * ConfigurationContext
+ */
+public class TuscanyAxisConfigurator extends URLBasedAxisConfigurator implements AxisConfigurator {
+
+ public TuscanyAxisConfigurator() throws AxisFault {
+ super(TuscanyAxisConfigurator.class.getResource("/org/apache/tuscany/binding/axis2/engine/config/axis2.xml"), null);
+ }
+
+ public ConfigurationContext getConfigurationContext() throws AxisFault {
+ if (configContext == null)
+ configContext = ConfigurationContextFactory.createConfigurationContext(this);
+ return configContext;
+ }
+
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/util/WebServiceOperationMetaData.java b/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/util/WebServiceOperationMetaData.java
new file mode 100755
index 0000000000..2a453bdf15
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/util/WebServiceOperationMetaData.java
@@ -0,0 +1,491 @@
+/*
+ * 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.binding.axis2.util;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import javax.wsdl.Binding;
+import javax.wsdl.BindingInput;
+import javax.wsdl.BindingOperation;
+import javax.wsdl.BindingOutput;
+import javax.wsdl.Input;
+import javax.wsdl.Message;
+import javax.wsdl.Operation;
+import javax.wsdl.Output;
+import javax.wsdl.Part;
+import javax.wsdl.extensions.soap.SOAPBinding;
+import javax.wsdl.extensions.soap.SOAPHeader;
+import javax.wsdl.extensions.soap.SOAPOperation;
+import javax.xml.namespace.QName;
+
+/**
+ * Metadata for a WSDL operation
+ */
+@SuppressWarnings({"all"})
+public class WebServiceOperationMetaData implements Serializable {
+ private static final long serialVersionUID = 2425306250256227724L;
+
+ // WSDL Binding and BindingOperation
+ private Binding binding;
+ private BindingOperation bindingOperation;
+ // Fields to cache derived metadata
+ private transient Set<Part> inputHeaderParts;
+ private transient Set<Part> outputHeaderParts;
+ private transient String style;
+ private transient String use;
+ private transient String soapAction;
+ private transient List<Object> signature;
+ private String encoding;
+ private transient QName rpcOperationName;
+
+ public WebServiceOperationMetaData(Binding binding, BindingOperation bindingOperation) {
+ this.binding = binding;
+ this.bindingOperation = bindingOperation;
+ }
+
+ public WebServiceOperationMetaData(Binding binding, BindingOperation bindingOperation, String style, String use,
+ String encoding,
+ String soapAction) {
+ this.binding = binding;
+ this.bindingOperation = bindingOperation;
+ this.style = style;
+ this.use = use;
+ this.encoding = encoding;
+ this.soapAction = soapAction;
+ }
+
+ public Set<Part> getInputHeaderParts() {
+ if (inputHeaderParts == null) {
+ // Build a set of header parts that we need to exclude
+ inputHeaderParts = new HashSet<Part>();
+ BindingInput bindingInput = bindingOperation.getBindingInput();
+
+ if (bindingInput != null) {
+ Operation operation = bindingOperation.getOperation();
+ javax.wsdl.Message message = operation.getInput().getMessage();
+ List elements = bindingInput.getExtensibilityElements();
+ for (Iterator i = elements.iterator(); i.hasNext();) {
+ Object extensibilityElement = i.next();
+ Part part = getPartFromSOAPHeader(message, extensibilityElement);
+ if (part != null) {
+ inputHeaderParts.add(part);
+ }
+ }
+ }
+ }
+ return inputHeaderParts;
+ }
+
+ public Set<Part> getOutputHeaderParts() {
+ if (outputHeaderParts == null) {
+ // Build a set of header parts that we need to exclude
+ outputHeaderParts = new HashSet<Part>();
+ BindingOutput bindingOutput = bindingOperation.getBindingOutput();
+
+ if (bindingOutput != null) {
+ Operation operation = bindingOperation.getOperation();
+ javax.wsdl.Message message = operation.getOutput().getMessage();
+ List elements = bindingOutput.getExtensibilityElements();
+ for (Iterator i = elements.iterator(); i.hasNext();) {
+ Object extensibilityElement = i.next();
+ Part part = getPartFromSOAPHeader(message, extensibilityElement);
+ if (part != null) {
+ outputHeaderParts.add(part);
+ }
+ }
+ }
+ }
+ return outputHeaderParts;
+ }
+
+ private Part getPartFromSOAPHeader(Message message, Object extensibilityElement) {
+ Part part = null;
+ if (extensibilityElement instanceof SOAPHeader) {
+ SOAPHeader soapHeader = (SOAPHeader) extensibilityElement;
+ QName msgName = soapHeader.getMessage();
+ if (message.getQName().equals(msgName)) {
+ part = message.getPart(soapHeader.getPart());
+ }
+ } else if (extensibilityElement instanceof SOAPHeader) {
+ SOAPHeader soapHeader = (SOAPHeader) extensibilityElement;
+ QName msgName = soapHeader.getMessage();
+ if (message.getQName().equals(msgName)) {
+ part = message.getPart(soapHeader.getPart());
+ }
+ }
+ return part;
+ }
+
+ public String getStyle() {
+ if (style == null) {
+ SOAPOperation soapOperation = (SOAPOperation) WebServicePortMetaData
+ .getExtensibilityElement(bindingOperation.getExtensibilityElements(),
+ SOAPOperation.class);
+ if (soapOperation != null) {
+ style = soapOperation.getStyle();
+ }
+ if (style == null) {
+ SOAPBinding soapBinding = WebServicePortMetaData
+ .getExtensibilityElement(binding.getExtensibilityElements(), SOAPBinding.class);
+ if (soapBinding != null) {
+ style = soapBinding.getStyle();
+ }
+ }
+ if (style == null) {
+ style = "document";
+ }
+ }
+ return style;
+ }
+
+ /**
+ * Returns the SOAP action for the given operation.
+ */
+ public String getSOAPAction() {
+ if (soapAction == null) {
+ final List wsdlBindingOperationExtensions = bindingOperation.getExtensibilityElements();
+ final SOAPOperation soapOp =
+ WebServicePortMetaData.getExtensibilityElement(wsdlBindingOperationExtensions, SOAPOperation.class);
+ if (soapOp != null) {
+ soapAction = soapOp.getSoapActionURI();
+ }
+ }
+ return soapAction;
+ }
+
+ public QName getRPCOperationName() {
+ if (rpcOperationName == null) {
+ javax.wsdl.extensions.soap.SOAPBody soapBody = getSOAPBody(true);
+ String ns =
+ (soapBody != null) ? soapBody.getNamespaceURI() : binding.getPortType().getQName().getNamespaceURI();
+ String name = bindingOperation.getOperation().getName();
+ rpcOperationName = new QName(ns, name);
+ }
+ return rpcOperationName;
+ }
+
+ private List<String> getSOAPBodyParts(boolean input) {
+ javax.wsdl.extensions.soap.SOAPBody soapBody = getSOAPBody(input);
+ if (soapBody != null) {
+ List parts = soapBody.getParts();
+ if (parts != null) {
+ List<String> names = new ArrayList<String>();
+ for (Iterator i = parts.iterator(); i.hasNext();) {
+ Object part = i.next();
+ if (part instanceof String) {
+ names.add((String) part);
+ } else if (part instanceof Part) {
+ names.add(((Part) part).getName());
+ }
+ }
+ return names;
+ } else {
+ return null;
+ }
+ } else {
+ return null;
+ }
+ }
+
+ private javax.wsdl.extensions.soap.SOAPBody getSOAPBody(boolean input) {
+ List elements = null;
+ if (input) {
+ BindingInput bindingInput = bindingOperation.getBindingInput();
+ if (bindingInput == null) {
+ return null;
+ }
+ elements = bindingInput.getExtensibilityElements();
+ } else {
+ BindingOutput bindingOutput = bindingOperation.getBindingOutput();
+ if (bindingOutput == null) {
+ return null;
+ }
+ elements = bindingOutput.getExtensibilityElements();
+ }
+ javax.wsdl.extensions.soap.SOAPBody soapBody = WebServicePortMetaData.getExtensibilityElement(elements,
+ javax.wsdl.extensions.soap.SOAPBody.class);
+ return soapBody;
+ }
+
+ /**
+ * Returns the use attribute
+ */
+ public String getUse() {
+ if (use == null) {
+ javax.wsdl.extensions.soap.SOAPBody soapBody = getSOAPBody(true);
+ if (soapBody != null) {
+ use = soapBody.getUse();
+ }
+ if (use == null) {
+ use = "literal";
+ }
+ }
+ return use;
+ }
+
+ @SuppressWarnings("unchecked")
+ public String getEncoding() {
+ if (encoding == null) {
+ javax.wsdl.extensions.soap.SOAPBody soapBody = getSOAPBody(true);
+ if (soapBody != null) {
+ List<String> styles = (List<String>) soapBody.getEncodingStyles();
+ if (styles != null && !styles.isEmpty()) {
+ encoding = styles.get(0);
+ }
+ }
+ if (encoding == null) {
+ encoding = "";
+ }
+ }
+ return encoding;
+ }
+
+ public boolean isDocLitWrapped() {
+ boolean flag = getStyle().equals("document") && getUse().equals("literal");
+ if (!flag) {
+ return false;
+ }
+ Message msg = getMessage(true);
+ if (msg == null) {
+ return false;
+ }
+ List parts = msg.getOrderedParts(null);
+ if (parts.size() != 1) {
+ return false;
+ }
+ Part part = (Part) parts.get(0);
+ QName element = part.getElementName();
+ if (element == null) {
+ return false;
+ }
+ return element.getLocalPart().equals(bindingOperation.getOperation().getName());
+ }
+
+ /*
+ * public SOAPMediator createMediator(boolean serverMode) throws SOAPException {
+ * // create a new mediator for each invoke for thread-safety
+ * boolean rpcStyle = getStyle().equals("rpc"); boolean rpcEncoded = isEncoded();
+ *
+ * SOAPMediator mediator = null;
+ *
+ * if (!rpcStyle) { // Document mediator = new SOAPDocumentLiteralMediatorImpl(this, serverMode);
+ * } else { if (!rpcEncoded) mediator = new
+ * SOAPRPCLiteralMediatorImpl(this, serverMode); // RPC-literal else mediator =
+ * new SOAPRPCEncodedMediatorImpl(this, serverMode); // RPC-encoded }
+ * return mediator; }
+ */
+
+ /**
+ * Get the operation signature from the WSDL operation
+ */
+ public List<?> getOperationSignature() {
+ if (signature == null) {
+ signature = new ArrayList<Object>();
+
+ Operation operation = bindingOperation.getOperation();
+ if (operation == null) {
+ return signature;
+ }
+
+ final Input input = operation.getInput();
+ if (input == null) {
+ return signature;
+ }
+
+ String sstyle = getStyle();
+
+ if ("rpc".equals(sstyle)) {
+ Collection partNames = input.getMessage().getParts().values();
+ for (Iterator i = partNames.iterator(); i.hasNext();) {
+ Part part = (Part) i.next();
+ signature.add(part.getName());
+ }
+ } else {
+ /*
+ * WS-I Basic Profile 1.1 4.7.6 Operation Signatures Definition: operation signature
+ *
+ * The profile defines the "operation signature" to be the fully qualified name of the child element of
+ * SOAP body of the SOAP input
+ * message described by an operation in a WSDL binding.
+ *
+ * In the case of rpc-literal binding, the operation name is used as a wrapper for the part accessors.
+ * In the document-literal case, designed so that they meet this requirement.
+ *
+ * An endpoint that supports multiple operations must unambiguously identify the operation being
+ * invoked based on the input message
+ * that it receives. This is only possible if all the operations specified in the wsdl:binding
+ * associated with an endpoint have a
+ * unique operation signature.
+ *
+ * R2710 The operations in a wsdl:binding in a DESCRIPTION MUST result in operation signatures that are
+ * different from one another.
+ */
+ List<String> bodyParts = getSOAPBodyParts(true);
+
+ Collection<?> parts = input.getMessage().getParts().values();
+ // Exclude the parts to be transmitted in SOAP header
+ if (bodyParts == null) {
+ parts.removeAll(getInputHeaderParts());
+ }
+ for (Iterator i = parts.iterator(); i.hasNext();) {
+ Part part = (Part) i.next();
+ if (bodyParts == null) {
+ // All parts
+ QName elementName = part.getElementName();
+ if (elementName == null) {
+ elementName = new QName("", part.getName());
+ // TODO: [rfeng] throw new
+ // ServiceRuntimeException("Message part for
+ // document style must refer to an XSD element
+ // using a QName: " + part);
+ }
+ signature.add(elementName);
+ } else {
+ // "parts" in soap:body
+ if (bodyParts.contains(part.getName())) {
+ QName elementName = part.getElementName();
+ if (elementName == null) {
+ elementName = new QName("", part.getName());
+ // TODO: [rfeng] throw new
+ // ServiceRuntimeException("Message part for
+ // document style must refer to an XSD
+ // element using a QName: " + part);
+ }
+ signature.add(elementName);
+ }
+
+ }
+ }
+ }
+ }
+ return signature;
+ }
+
+ public Message getMessage(boolean isInput) {
+ Operation operation = bindingOperation.getOperation();
+ if (operation == null) {
+ return null;
+ }
+
+ if (isInput) {
+ final Input input = operation.getInput();
+ return input == null ? null : input.getMessage();
+ } else {
+ final Output output = operation.getOutput();
+ return output == null ? null : output.getMessage();
+ }
+ }
+
+ public Part getInputPart(int index) {
+ Part part = null;
+ Message message = getMessage(true);
+ if (message == null) {
+ return part;
+ }
+
+ List parts = message.getOrderedParts(null);
+ return (Part) parts.get(index);
+
+ }
+
+ public Part getOutputPart(int index) {
+ Part part = null;
+ Message message = getMessage(false);
+ if (message == null) {
+ return part;
+ }
+
+ List parts = message.getOrderedParts(null);
+ return (Part) parts.get(index);
+
+ }
+
+ /**
+ * Get a list of indexes for each part in the SOAP body
+ *
+ * @param isInput
+ */
+ public List<Integer> getBodyPartIndexes(boolean isInput) {
+ List<Integer> indexes = new ArrayList<Integer>();
+
+ Message message = getMessage(isInput);
+ if (message == null) {
+ return indexes;
+ }
+
+ List<String> bodyParts = getSOAPBodyParts(isInput);
+ List parts = message.getOrderedParts(null);
+ Set headerParts = isInput ? getInputHeaderParts() : getOutputHeaderParts();
+
+ int index = 0;
+ for (Iterator i = parts.iterator(); i.hasNext(); index++) {
+ Part part = (Part) i.next();
+ if (headerParts.contains(part)) {
+ continue;
+ }
+ if (bodyParts == null) {
+ // All parts
+ indexes.add(index);
+ } else {
+ // "parts" in soap:body
+ if (bodyParts.contains(part.getName())) {
+ indexes.add(index);
+ }
+ }
+ }
+ return indexes;
+ }
+
+ /**
+ * Get the corresponding index for a part in the SOAP header by element name
+ *
+ * @param elementName
+ * @param isInput
+ */
+ public int getHeaderPartIndex(QName elementName, boolean isInput) {
+
+ Message message = getMessage(isInput);
+ if (message == null) {
+ return -1;
+ }
+
+ List parts = message.getOrderedParts(null);
+ Set headerParts = isInput ? getInputHeaderParts() : getOutputHeaderParts();
+
+ int index = 0;
+ for (Iterator i = parts.iterator(); i.hasNext(); index++) {
+ Part part = (Part) i.next();
+ // Test if the part is in header section
+ if (headerParts.contains(part) && elementName.equals(part.getElementName())) {
+ return index;
+ }
+ }
+ return -1;
+ }
+
+ public BindingOperation getBindingOperation() {
+ return bindingOperation;
+ }
+
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/util/WebServicePortMetaData.java b/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/util/WebServicePortMetaData.java
new file mode 100755
index 0000000000..a8d4f0f581
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/util/WebServicePortMetaData.java
@@ -0,0 +1,377 @@
+/*
+ * 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.binding.axis2.util;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.wsdl.Binding;
+import javax.wsdl.BindingOperation;
+import javax.wsdl.Definition;
+import javax.wsdl.Operation;
+import javax.wsdl.Port;
+import javax.wsdl.PortType;
+import javax.wsdl.Service;
+import javax.wsdl.extensions.soap.SOAPAddress;
+import javax.wsdl.extensions.soap.SOAPBinding;
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.idl.wsdl.WSDLServiceContract;
+
+/**
+ * Metadata for a WSDL port
+ *
+ */
+public class WebServicePortMetaData {
+
+ private Service wsdlService;
+ private QName wsdlServiceName;
+ private Port wsdlPort;
+ private Binding wsdlBinding;
+ private QName wsdlPortName;
+ private PortType wsdlPortType;
+ private QName wsdlPortTypeName;
+ private String endpoint;
+ private boolean managed;
+ private List<WebServiceOperationMetaData> allOperationMetaData;
+ private WSDLServiceContract interfaceType;
+
+ /**
+ * Constructor
+ *
+ * @param wsdlDefinition
+ */
+ public WebServicePortMetaData(Definition wsdlDefinition, Port wsdlPort, String endpoint, boolean managed) {
+
+ // Lookup the named port
+ this.wsdlPort = wsdlPort;
+ wsdlPortName = new QName(wsdlDefinition.getTargetNamespace(), wsdlPort.getName());
+ Collection services = wsdlDefinition.getServices().values();
+ for (Object serviceObj : services) {
+ Service service = (Service) serviceObj;
+ if (service.getPorts().containsValue(wsdlPort)) {
+ wsdlService = service;
+ wsdlServiceName = service.getQName();
+ break;
+ }
+ }
+
+ // Save the binding
+ wsdlBinding = wsdlPort.getBinding();
+ if (wsdlBinding == null) {
+ throw new IllegalArgumentException("WSDL binding cannot be found for " + wsdlPortName);
+ }
+
+ // Save the portType
+ wsdlPortType = wsdlBinding.getPortType();
+ if (wsdlPortType == null) {
+ throw new IllegalArgumentException("WSDL portType cannot be found for " + wsdlPortName);
+ }
+ wsdlPortTypeName = wsdlPortType.getQName();
+
+ // Save the endpoint
+ this.endpoint = endpoint;
+
+ // Track if this endpoint is managed or not
+ this.managed = managed;
+ }
+
+ /**
+ * Constructor
+ *
+ * @param serviceName
+ * @param portName
+ * @param portTypeName
+ * @param endpoint
+ */
+ public WebServicePortMetaData(QName serviceName, String portName, QName portTypeName, String endpoint) {
+ wsdlServiceName = serviceName;
+ wsdlPortName = new QName(serviceName.getNamespaceURI(), portName);
+ wsdlPortTypeName = portTypeName;
+ this.endpoint = endpoint;
+ }
+
+ /**
+ * @return Returns the wsdlPort.
+ */
+ public javax.wsdl.Port getPort() {
+ return wsdlPort;
+ }
+
+ /**
+ * @return Returns the wsdlService.
+ */
+ public QName getServiceName() {
+ return wsdlServiceName;
+ }
+
+ /**
+ * @return Returns the wsdlService.
+ */
+ public javax.wsdl.Service getService() {
+ return wsdlService;
+ }
+
+ /**
+ * @return Returns the wsdlPortType.
+ */
+ public PortType getPortType() {
+ return wsdlPortType;
+ }
+
+ /**
+ * @return Returns the wsdlPortType.
+ */
+ public QName getPortTypeName() {
+ return wsdlPortTypeName;
+ }
+
+ /**
+ * @return Returns the wsdlBinding.
+ */
+ public Binding getBinding() {
+ return wsdlBinding;
+ }
+
+ /**
+ * @return Returns the wsdlPortName.
+ */
+ public QName getPortName() {
+ return wsdlPortName;
+ }
+
+ /**
+ * Returns the endpoint of a given port.
+ */
+ public String getEndpoint() {
+
+ // Return the specified endpoint
+ if (endpoint != null) {
+ return endpoint;
+ }
+
+ // Find the target endpoint on the port
+ if (wsdlPort != null) {
+ final List wsdlPortExtensions = wsdlPort.getExtensibilityElements();
+ for (final Object extension : wsdlPortExtensions) {
+ if (extension instanceof SOAPAddress) {
+ return ((SOAPAddress) extension).getLocationURI();
+ }
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Returns the SOAP binding style.
+ */
+ public String getStyle() {
+
+ // Find the binding style
+ String style = null;
+ if (wsdlBinding != null) {
+ final List wsdlBindingExtensions = wsdlBinding.getExtensibilityElements();
+ SOAPBinding soapBinding = getExtensibilityElement(wsdlBindingExtensions, SOAPBinding.class);
+ if (soapBinding != null) {
+ style = soapBinding.getStyle();
+ }
+ }
+
+ // Default to document
+ return (style == null) ? "document" : style;
+ }
+
+ /**
+ * Returns the use attribute
+ */
+ public String getUse() {
+ List<WebServiceOperationMetaData> list = getAllOperationMetaData();
+ return list.get(0).getUse();
+ }
+
+ /**
+ * Returns the encoding attribute
+ */
+ public String getEncoding() {
+ List<WebServiceOperationMetaData> list = getAllOperationMetaData();
+ return list.get(0).getEncoding();
+ }
+
+ /**
+ * @return Returns true if this is a managed web service.
+ */
+ public boolean isManaged() {
+ return managed;
+ }
+
+ /**
+ * Returns the first extensibility element of the given type.
+ *
+ * @param elements
+ * @param type
+ */
+ public static <T> T getExtensibilityElement(List elements, Class<T> type) {
+ for (Object element : elements) {
+ if (type.isInstance(element)) {
+ return type.cast(element);
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Returns the extensibility elements of the given type.
+ *
+ * @param elements
+ * @param type
+ * @return List
+ */
+ public static <T> List<T> getExtensibilityElements(List elements, Class<T> type) {
+ List<T> result = new ArrayList<T>();
+ for (Object element : elements) {
+ if (type.isInstance(element)) {
+ result.add(type.cast(element));
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Get the operation signature from the SOAP Body
+ *
+ * @return A list of QNames
+ */
+ // public static List getOperationSignature(javax.xml.soap.SOAPBody body) {
+ // List signature = new ArrayList();
+ // for (Iterator i = body.getChildElements(); i.hasNext();) {
+ // Object child = i.next();
+ // if (child instanceof SOAPBodyElement) {
+ // Name name = ((SOAPBodyElement) child).getElementName();
+ // QName qname = new QName(name.getURI(), name.getLocalName(), name.getPrefix());
+ // signature.add(qname);
+ // }
+ // }
+ // return signature;
+ // }
+ // public static List getRPCOperationSignature(javax.xml.soap.SOAPBody body) {
+ // List signature = new ArrayList();
+ // for (Iterator i = body.getChildElements(); i.hasNext();) {
+ // Object child = i.next();
+ // if (child instanceof SOAPBodyElement) {
+ // SOAPBodyElement op = ((SOAPBodyElement) child);
+ // for (Iterator j = op.getChildElements(); j.hasNext();) {
+ // Object part = i.next();
+ // if (part instanceof SOAPElement) {
+ // SOAPElement p = (SOAPElement) part;
+ // signature.add(p.getLocalName());
+ // }
+ // }
+ // }
+ // }
+ // return signature;
+ // }
+ // public WebServiceOperationMetaData getOperationMetaData(javax.xml.soap.SOAPBody body) {
+ // List s1 = getOperationSignature(body);
+ // // List rpcParts = getRPCOperationSignature(body);
+ // for (Iterator it = getAllOperationMetaData().iterator(); it.hasNext();) {
+ // WebServiceOperationMetaData descriptor = (WebServiceOperationMetaData) it.next();
+ //
+ // String style = descriptor.getStyle();
+ //
+ // if (style.equals("document")) {
+ // List s2 = descriptor.getOperationSignature();
+ // if (s1.equals(s2))
+ // return descriptor;
+ // } else {
+ // QName op1 = (QName) s1.get(0);
+ // QName op2 = descriptor.getRPCOperationName();
+ // if (op1.equals(op2)) {
+ // /*
+ // * // FIXME: [rfeng] We don't support method overloading
+ // * List partNames = getOperationSignature(binding,
+ // * bindingOperation); if (rpcParts.equals(partNames))
+ // */
+ // return descriptor;
+ // }
+ // }
+ // }
+ // return null;
+ // }
+ public List<WebServiceOperationMetaData> getAllOperationMetaData() {
+ if (allOperationMetaData == null) {
+ allOperationMetaData = new ArrayList<WebServiceOperationMetaData>();
+ for (Iterator it = wsdlBinding.getBindingOperations().iterator(); it.hasNext();) {
+ final BindingOperation bindingOperation = (BindingOperation) it.next();
+ if (bindingOperation.getOperation() != null) {
+ allOperationMetaData.add(new WebServiceOperationMetaData(wsdlBinding, bindingOperation));
+ }
+ }
+ }
+ return allOperationMetaData;
+ }
+
+ public WebServiceOperationMetaData getOperationMetaData(String operationName) {
+ StringBuilder sb = new StringBuilder(operationName);
+ sb.setCharAt(0, Character.toUpperCase(sb.charAt(0)));
+ String capatalizedOpName = sb.toString();
+
+ for (WebServiceOperationMetaData webServiceOperationMetaData : getAllOperationMetaData()) {
+ WebServiceOperationMetaData descriptor = (WebServiceOperationMetaData) webServiceOperationMetaData;
+ String opName = descriptor.getBindingOperation().getOperation().getName();
+
+ if (opName.equals(operationName) || opName.equals(capatalizedOpName)) {
+ return descriptor;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Returns the WSDL service contract
+ *
+ * @return WSDLServiceContract
+ */
+ public WSDLServiceContract getInterfaceType() {
+ return interfaceType;
+ }
+
+ /**
+ * Get the WSDL operation name for a Java method name
+ */
+ public String getWSDLOperationName(String methodName) {
+ StringBuilder sb = new StringBuilder(methodName);
+ sb.setCharAt(0, Character.toUpperCase(sb.charAt(0)));
+ String capatalizedOpName = sb.toString();
+ for (Object o : wsdlPortType.getOperations()) {
+ Operation operation = (Operation) o;
+ String wsdlOpName = operation.getName();
+ if (wsdlOpName.equals(methodName)) {
+ return wsdlOpName;
+ }
+ if (wsdlOpName.equals(capatalizedOpName)) {
+ return wsdlOpName;
+ }
+ }
+ return null;
+ }
+
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/resources/META-INF/sca/binding.axis2.scdl b/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/resources/META-INF/sca/binding.axis2.scdl
new file mode 100644
index 0000000000..0eb56942f8
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/resources/META-INF/sca/binding.axis2.scdl
@@ -0,0 +1,48 @@
+<?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.
+-->
+<!-- Axis2 based WebService binding extension -->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:system="http://incubator.apache.org/tuscany/xmlns/system/1.0-incubator-M2"
+ name="org.apache.tuscany.binding.axis2.include">
+
+ <dependency xmlns="http://incubator.apache.org/tuscany/xmlns/1.0-incubator-M2">
+ <group>org.apache.tuscany.sca.services.bindings</group>
+ <name>axis2</name>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </dependency>
+
+ <dependency xmlns="http://incubator.apache.org/tuscany/xmlns/1.0-incubator-M2">
+ <group>org.apache.tuscany.sca.services.databinding</group>
+ <name>databinding-axiom</name>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </dependency>
+
+ <component name="webservice.bindingLoader">
+ <system:implementation.system class="org.apache.tuscany.binding.axis2.WebServiceBindingLoader" />
+ </component>
+
+ <component name="webservice.axis2.bindingBuilder">
+ <system:implementation.system class="org.apache.tuscany.binding.axis2.Axis2BindingBuilder" />
+ </component>
+
+ <!-- A workaround to handle inter-extension dependencies -->
+ <include name="idl.wsdl" scdlResource="META-INF/sca/idl.wsdl.scdl" />
+ <include name="databinding.axiom" scdlResource="META-INF/sca/databinding.axiom.scdl" />
+
+</composite>
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/resources/META-INF/sca/default.scdl b/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/resources/META-INF/sca/default.scdl
new file mode 100644
index 0000000000..d14e850caf
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/resources/META-INF/sca/default.scdl
@@ -0,0 +1,49 @@
+<?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.
+-->
+<!-- Axis2 based WebService binding extension -->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:system="http://incubator.apache.org/tuscany/xmlns/system/1.0-incubator-M2"
+ name="org.apache.tuscany.binding.axis2.WebServiceBinding">
+
+ <dependency xmlns="http://incubator.apache.org/tuscany/xmlns/1.0-incubator-M2">
+ <group>org.apache.tuscany.sca.services.bindings</group>
+ <name>axis2</name>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </dependency>
+
+ <dependency xmlns="http://incubator.apache.org/tuscany/xmlns/1.0-incubator-M2">
+ <group>org.apache.tuscany.sca.services.databinding</group>
+ <name>databinding-axiom</name>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </dependency>
+
+ <component name="webservice.bindingLoader">
+ <system:implementation.system class="org.apache.tuscany.binding.axis2.WebServiceBindingLoader"/>
+ </component>
+
+ <component name="webservice.axis2.bindingBuilder">
+ <system:implementation.system class="org.apache.tuscany.binding.axis2.Axis2BindingBuilder"/>
+ </component>
+
+ <!-- A workaround to handle inter-extension dependencies -->
+ <include name="idl.wsdl" scdlResource="META-INF/sca/idl.wsdl.scdl"/>
+ <include name="databinding.axiom" scdlResource="META-INF/sca/databinding.axiom.scdl"/>
+
+</composite>
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/resources/org/apache/tuscany/binding/axis2/engine/config/axis2.xml b/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/resources/org/apache/tuscany/binding/axis2/engine/config/axis2.xml
new file mode 100755
index 0000000000..84c86d6dfb
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/main/resources/org/apache/tuscany/binding/axis2/engine/config/axis2.xml
@@ -0,0 +1,302 @@
+<?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.
+-->
+<axisconfig name="AxisJava2.0">
+ <!-- ================================================= -->
+ <!-- Parameters -->
+ <!-- ================================================= -->
+ <parameter name="hotdeployment" locked="false">false</parameter>
+ <parameter name="hotupdate" locked="false">false</parameter>
+ <parameter name="enableMTOM" locked="false">false</parameter>
+ <parameter name="enableSwA" locked="false">false</parameter>
+
+ <!--Uncomment if you want to enable file caching for attachments -->
+ <!--parameter name="cacheAttachments" locked="false">true</parameter>
+ <parameter name="attachmentDIR" locked="false"></parameter>
+ <parameter name="sizeThreshold" locked="false">4000</parameter-->
+
+ <!--This will give out the timout of the configuration contexts, in seconds-->
+ <parameter name="ConfigContextTimeoutInterval" locked="false">30</parameter>
+
+ <!--During a fault, stacktrace can be sent with the fault message. The following flag will control -->
+ <!--that behaviour.-->
+ <parameter name="sendStacktraceDetailsWithFaults" locked="false">true</parameter>
+
+ <!--If there aren't any information available to find out the fault reason, we set the message of the expcetion-->
+ <!--as the faultreason/Reason. But when a fault is thrown from a service or some where, it will be -->
+ <!--wrapped by different levels. Due to this the initial exception message can be lost. If this flag-->
+ <!--is set then, Axis2 tries to get the first exception and set its message as the faultreason/Reason.-->
+ <parameter name="DrillDownToRootCauseForFaultReason" locked="false">false</parameter>
+
+ <parameter name="userName" locked="false">admin</parameter>
+ <parameter name="password" locked="false">axis2</parameter>
+
+ <!--Following params will set the proper context paths for invocations. All the endpoints will have a commons context-->
+ <!--root which can configured using the following contextRoot parameter-->
+ <!--<parameter name="contextRoot" locked="false">axis2</parameter>-->
+
+ <!--Our HTTP endpoints can handle both REST and SOAP. Following parameters can be used to distingiush those endpoints-->
+ <!--In case of a servlet, if you change this you have to manually change the settings of your servlet container to map this -->
+ <!--context path to proper Axis2 servlets-->
+ <!--<parameter name="servicePath" locked="false">services</parameter>-->
+ <!--<parameter name="restPath" locked="false">rest</parameter>-->
+
+
+ <!--Set the flag to true if you want to enable transport level session mangment-->
+ <parameter name="manageTransportSession" locked="false">false</parameter>
+
+ <!--Following two parameters will be used to handle REST in Axis2. The default settings will make Axis2 to have two-->
+ <!--different endpoints, one for REST (AxisRESTServlet) one for SOAP message handling (AxisServlet). But following-->
+ <!--parameters help to tweak the message handling of two main servlets. -->
+
+ <!-- If the enableRESTInAxis2MainServlet is true, then Axis2MainServlet will handle both SOAP and REST messages -->
+ <parameter name="enableRESTInAxis2MainServlet" locked="true">false</parameter>
+
+ <!-- Following parameter will completely disable REST handling in both the servlets-->
+ <parameter name="disableREST" locked="true">false</parameter>
+
+ <!-- This will disable the separate servlet we have for REST handling. -->
+ <parameter name="disableSeparateEndpointForREST" locked="true">false</parameter>
+
+ <!-- If you have a frontend host which exposes this webservice using a different public URL -->
+ <!-- use this parameter to override autodetected url -->
+ <!--<parameter name="httpFrontendHostUrl" locked="false">https://someotherhost/context</parameter>-->
+
+
+ <!-- The way of adding listener to the system-->
+ <!-- <listener class="org.apache.axis2.ObserverIMPL">-->
+ <!-- <parameter name="RSS_URL" locked="false">http://127.0.0.1/rss</parameter>-->
+ <!-- </listener>-->
+
+ <!-- ================================================= -->
+ <!-- Message Receivers -->
+ <!-- ================================================= -->
+ <!--This is the Deafult Message Receiver for the system , if you want to have MessageReceivers for -->
+ <!--all the other MEP implement it and add the correct entry to here , so that you can refer from-->
+ <!--any operation -->
+ <!--Note : You can ovride this for particular service by adding the same element with your requirement-->
+ <messageReceivers>
+ <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only"
+ class="org.apache.tuscany.binding.axis2.Axis2ServiceInMessageReceiver"/>
+ <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only"
+ class="org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver"/>
+ <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out"
+ class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
+ <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out"
+ class="org.apache.tuscany.binding.axis2.Axis2ServiceInOutAsyncMessageReceiver"/>
+ <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out"
+ class="org.apache.tuscany.binding.axis2.Axis2ServiceInOutSyncMessageReceiver"/>
+ </messageReceivers>
+ <!-- ================================================= -->
+ <!-- Transport Ins -->
+ <!-- ================================================= -->
+ <transportReceiver name="http"
+ class="org.apache.axis2.transport.http.SimpleHTTPServer">
+ <parameter name="port" locked="false">6060</parameter>
+ <!-- Here is the complete list of supported parameters (see example settings further below):
+ port: the port to listen on (default 6060)
+ hostname: if non-null, url prefix used in reply-to endpoint references (default null)
+ originServer: value of http Server header in outgoing messages (default "Simple-Server/1.1")
+ requestTimeout: value in millis of time that requests can wait for data (default 20000)
+ requestTcpNoDelay: true to maximize performance and minimize latency (default true)
+ false to minimize bandwidth consumption by combining segments
+ requestCoreThreadPoolSize: number of threads available for request processing (unless queue fills up) (default 25)
+ requestMaxThreadPoolSize: number of threads available for request processing if queue fills us (default 150)
+ note that default queue never fills up: see HttpFactory
+ threadKeepAliveTime: time to keep threads in excess of core size alive while inactive (default 180)
+ note that no such threads can exist with default unbounded request queue
+ threadKeepAliveTimeUnit: TimeUnit of value in threadKeepAliveTime (default SECONDS) (default SECONDS)
+ -->
+ <!-- <parameter name="hostname" locked="false">http://www.myApp.com/ws</parameter> -->
+ <!-- <parameter name="originServer" locked="false">My-Server/1.1</parameter> -->
+ <!-- <parameter name="requestTimeout" locked="false">10000</parameter> -->
+ <!-- <parameter name="requestTcpNoDelay" locked="false">false</parameter> -->
+ <!-- <parameter name="requestCoreThreadPoolSize" locked="false">50</parameter> -->
+ <!-- <parameter name="RequestMaxThreadPoolSize" locked="false">100</parameter> -->
+ <!-- <parameter name="threadKeepAliveTime" locked="false">240000</parameter> -->
+ <!-- <parameter name="threadKeepAliveTimeUnit" locked="false">MILLISECONDS</parameter> -->
+ </transportReceiver>
+
+ <!--Uncomment this and configure as appropriate for JMS transport support, after setting up your JMS environment (e.g. ActiveMQ)
+ <transportReceiver name="jms" class="org.apache.axis2.transport.jms.JMSListener">
+ <parameter name="myTopicConnectionFactory" locked="false">
+ <parameter name="java.naming.factory.initial" locked="false">org.apache.activemq.jndi.ActiveMQInitialContextFactory</parameter>
+ <parameter name="java.naming.provider.url" locked="false">tcp://localhost:61616</parameter>
+ <parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false">TopicConnectionFactory</parameter>
+ </parameter>
+
+ <parameter name="myQueueConnectionFactory" locked="false">
+ <parameter name="java.naming.factory.initial" locked="false">org.apache.activemq.jndi.ActiveMQInitialContextFactory</parameter>
+ <parameter name="java.naming.provider.url" locked="false">tcp://localhost:61616</parameter>
+ <parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false">QueueConnectionFactory</parameter>
+ </parameter>
+
+ <parameter name="default" locked="false">
+ <parameter name="java.naming.factory.initial" locked="false">org.apache.activemq.jndi.ActiveMQInitialContextFactory</parameter>
+ <parameter name="java.naming.provider.url" locked="false">tcp://localhost:61616</parameter>
+ <parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false">QueueConnectionFactory</parameter>
+ </parameter>
+ </transportReceiver>-->
+
+ <!--Uncomment if you want to have SMTP transport support-->
+ <!--<transportReceiver name="mail" class="org.apache.axis2.transport.mail.SimpleMailListener">-->
+ <!--<parameter name="transport.mail.pop3.host" locked="false">127.0.0.1</parameter>-->
+ <!--<parameter name="transport.mail.pop3.user" locked="false">axis2</parameter>-->
+ <!--<parameter name="transport.mail.pop3.password" locked="false">axis2</parameter>-->
+ <!--<parameter name="transport.mail.pop3.port" locked="false">110</parameter>-->
+ <!--<parameter name="transport.mail.replyToAddress" locked="false">axis2@127.0.0.1</parameter>-->
+ <!--</transportReceiver>-->
+
+ <transportReceiver name="tcp"
+ class="org.apache.axis2.transport.tcp.TCPServer">
+ <parameter name="port" locked="false">6060</parameter>
+ <!--If you want to give your own host address for EPR generation-->
+ <!--uncommet following paramter , and set as you required.-->
+ <!--<parameter name="hostname" locked="false">tcp://myApp.com/ws</parameter>-->
+ </transportReceiver>
+
+ <!-- ================================================= -->
+ <!-- Transport Outs -->
+ <!-- ================================================= -->
+
+ <transportSender name="tcp"
+ class="org.apache.axis2.transport.tcp.TCPTransportSender"/>
+ <transportSender name="local"
+ class="org.apache.axis2.transport.local.LocalTransportSender"/>
+ <transportSender name="http"
+ class="org.apache.axis2.transport.http.CommonsHTTPTransportSender">
+ <parameter name="PROTOCOL" locked="false">HTTP/1.1</parameter>
+ <parameter name="Transfer-Encoding" locked="false">chunked</parameter>
+ </transportSender>
+ <transportSender name="https"
+ class="org.apache.axis2.transport.http.CommonsHTTPTransportSender">
+ <parameter name="PROTOCOL" locked="false">HTTP/1.1</parameter>
+ <parameter name="Transfer-Encoding" locked="false">chunked</parameter>
+ </transportSender>
+
+ <!-- Commented out by Tuscany
+ <transportSender name="jms"
+ class="org.apache.axis2.transport.jms.JMSSender"/>
+ -->
+
+ <!-- Uncomment this one with the appropriate papameters to enable the SMTP transport Receiver
+ <transportSender name="mailto" class="org.apache.axis2.transport.mail.MailTransportSender">
+ <parameter name="transport.mail.smtp.host" locked="false">127.0.0.1</parameter>
+ <parameter name="transport.mail.smtp.user" locked="false">axis2</parameter>
+ <parameter name="transport.mail.smtp.password" locked="false">axis2</parameter>
+ <parameter name="transport.mail.smtp.port" locked="false">25</parameter>
+ </transportSender>
+ -->
+
+ <!-- ================================================= -->
+ <!-- Global Modules -->
+ <!-- ================================================= -->
+ <!-- Comment this to disable Addressing -->
+ <!-- Commented out by Tuscany
+ <module ref="addressing"/>
+ -->
+
+ <!--Configuring module , providing parameters for modules whether they refer or not-->
+ <!--<moduleConfig name="addressing">-->
+ <!--<parameter name="addressingPara" locked="false">N/A</parameter>-->
+ <!--</moduleConfig>-->
+
+ <!-- ================================================= -->
+ <!-- Phases -->
+ <!-- ================================================= -->
+ <phaseOrder type="InFlow">
+ <!-- System pre defined phases -->
+ <phase name="Transport">
+ <handler name="RequestURIBasedDispatcher"
+ class="org.apache.axis2.engine.RequestURIBasedDispatcher">
+ <order phase="Transport"/>
+ </handler>
+ <handler name="SOAPActionBasedDispatcher"
+ class="org.apache.axis2.engine.SOAPActionBasedDispatcher">
+ <order phase="Transport"/>
+ </handler>
+ </phase>
+ <phase name="Security"/>
+ <phase name="PreDispatch"/>
+ <phase name="Dispatch" class="org.apache.axis2.engine.DispatchPhase">
+ <handler name="AddressingBasedDispatcher"
+ class="org.apache.axis2.engine.AddressingBasedDispatcher">
+ <order phase="Dispatch"/>
+ </handler>
+
+ <handler name="SOAPMessageBodyBasedDispatcher"
+ class="org.apache.axis2.engine.SOAPMessageBodyBasedDispatcher">
+ <order phase="Dispatch"/>
+ </handler>
+ <handler name="InstanceDispatcher"
+ class="org.apache.axis2.engine.InstanceDispatcher">
+ <order phase="Dispatch"/>
+ </handler>
+ </phase>
+ <!-- System pre defined phases -->
+ <!-- After Postdispatch phase module author or or service author can add any phase he want -->
+ <phase name="OperationInPhase"/>
+ </phaseOrder>
+ <phaseOrder type="OutFlow">
+ <!-- user can add his own phases to this area -->
+ <phase name="OperationOutPhase"/>
+ <!--system predefined phase-->
+ <!--these phase will run irrespective of the service-->
+ <phase name="PolicyDetermination"/>
+ <phase name="MessageOut"/>
+ <phase name="Security"/>
+ </phaseOrder>
+ <phaseOrder type="InFaultFlow">
+ <phase name="PreDispatch"/>
+ <phase name="Dispatch" class="org.apache.axis2.engine.DispatchPhase">
+ <handler name="RequestURIBasedDispatcher"
+ class="org.apache.axis2.engine.RequestURIBasedDispatcher">
+ <order phase="Dispatch"/>
+ </handler>
+
+ <handler name="SOAPActionBasedDispatcher"
+ class="org.apache.axis2.engine.SOAPActionBasedDispatcher">
+ <order phase="Dispatch"/>
+ </handler>
+
+ <handler name="AddressingBasedDispatcher"
+ class="org.apache.axis2.engine.AddressingBasedDispatcher">
+ <order phase="Dispatch"/>
+ </handler>
+
+ <handler name="SOAPMessageBodyBasedDispatcher"
+ class="org.apache.axis2.engine.SOAPMessageBodyBasedDispatcher">
+ <order phase="Dispatch"/>
+ </handler>
+ <handler name="InstanceDispatcher"
+ class="org.apache.axis2.engine.InstanceDispatcher">
+ <order phase="PostDispatch"/>
+ </handler>
+ </phase>
+ <!-- user can add his own phases to this area -->
+ <phase name="OperationInFaultPhase"/>
+ </phaseOrder>
+ <phaseOrder type="OutFaultFlow">
+ <!-- user can add his own phases to this area -->
+ <phase name="OperationOutFaultPhase"/>
+ <phase name="PolicyDetermination"/>
+ <phase name="MessageOut"/>
+ </phaseOrder>
+</axisconfig>
+
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/Axis2ReferenceTestCase.java b/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/Axis2ReferenceTestCase.java
new file mode 100755
index 0000000000..9605c50c51
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/Axis2ReferenceTestCase.java
@@ -0,0 +1,105 @@
+/*
+ * 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.binding.axis2;
+
+import java.lang.reflect.Type;
+import java.net.URL;
+import java.util.HashMap;
+
+import javax.wsdl.Definition;
+import javax.wsdl.Port;
+import javax.wsdl.Service;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLReader;
+import javax.xml.namespace.QName;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.idl.wsdl.WSDLServiceContract;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.idl.java.JavaServiceContract;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+import org.apache.tuscany.spi.wire.WireService;
+import org.easymock.EasyMock;
+import org.xml.sax.InputSource;
+
+public class Axis2ReferenceTestCase extends TestCase {
+
+ public void testInvokeService() throws Exception {
+ Axis2Reference axis2Reference = createAxis2Reference("testWebAppName", "testServiceName");
+ Operation operation = new Operation<Type>("sayHi", null, null, null, false, null);
+ TargetInvoker targetInvoker = axis2Reference.createTargetInvoker(null, operation);
+ assertNotNull(targetInvoker);
+ }
+
+ public void testAsyncTargetInvoker() throws Exception {
+ Axis2Reference axis2Reference = createAxis2Reference("testWebAppName", "testServiceName");
+ //Create a mocked InboundWire, make the call of ServiceExtension.getInterface() returns a Class
+ InboundWire inboundWire = EasyMock.createNiceMock(InboundWire.class);
+ JavaServiceContract contract = new JavaServiceContract(Greeter.class);
+ contract.setCallbackClass(GreetingCallback.class);
+ Operation<Type> callbackOp = new Operation<Type>("sayHiCallback", null, null, null, true, null);
+ HashMap<String,Operation<Type>> callbackOps = new HashMap<String,Operation<Type>>();
+ callbackOps.put("sayHiCallback", callbackOp);
+ contract.setCallbackOperations(callbackOps);
+ EasyMock.expect(inboundWire.getServiceContract()).andReturn(contract).anyTimes();
+ EasyMock.replay(inboundWire);
+
+ axis2Reference.setInboundWire(inboundWire);
+ Operation operation = new Operation<Type>("sayHi", null, null, null, true, null);
+ TargetInvoker asyncTargetInvoker = axis2Reference.createAsyncTargetInvoker(null, operation);
+ assertNotNull(asyncTargetInvoker);
+ }
+
+ private Axis2Reference createAxis2Reference(String webAppName, String serviceName) throws Exception {
+ //Create WebServiceBinding
+ String wsdlLocation = "/wsdl/hello_world_doc_lit.wsdl";
+ URL url = getClass().getResource(wsdlLocation);
+ assertNotNull("Could not find wsdl " + url.toString(), url);
+
+ WSDLFactory factory = WSDLFactory.newInstance();
+ WSDLReader reader = factory.newWSDLReader();
+ reader.setFeature("javax.wsdl.verbose", false);
+ InputSource input = new InputSource(url.openStream());
+ Definition wsdlDef = reader.readWSDL(url.toString(), input);
+ Service wsdlService = wsdlDef.getService(new QName("http://objectweb.org/hello_world_soap_http",
+ "SOAPService"));
+ Port port = wsdlService.getPort("SoapPort");
+ WebServiceBinding wsBinding = new WebServiceBinding(wsdlDef, port, "uri", "portURI", wsdlService);
+ //Create a mocked WireService, make the call of ServiceExtension.getServiceInstance() returns a proxy instance.
+ WireService wireService = EasyMock.createNiceMock(WireService.class);
+ EasyMock.replay(wireService);
+ CompositeComponent parent = EasyMock.createNiceMock(CompositeComponent.class);
+ // TODO figure out what to do with the service contract
+ ServiceContract<?> contract = new WSDLServiceContract();
+ contract.setInterfaceClass(Greeter.class);
+ WorkContext workContext = EasyMock.createNiceMock(WorkContext.class);
+ EasyMock.replay(workContext);
+ return new Axis2Reference(serviceName,
+ parent,
+ wireService,
+ wsBinding,
+ contract,
+ workContext);
+ }
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/Axis2ServiceTestCase.java b/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/Axis2ServiceTestCase.java
new file mode 100755
index 0000000000..6669226547
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/Axis2ServiceTestCase.java
@@ -0,0 +1,150 @@
+/*
+ * 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.binding.axis2;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Type;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+import javax.servlet.Servlet;
+import javax.wsdl.Definition;
+import javax.wsdl.Port;
+import javax.wsdl.Service;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLReader;
+import javax.xml.namespace.QName;
+
+import org.xml.sax.InputSource;
+
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.tuscany.binding.axis2.util.TuscanyAxisConfigurator;
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.host.ServletHost;
+import org.apache.tuscany.spi.idl.java.JavaServiceContract;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.OutboundInvocationChain;
+import org.apache.tuscany.spi.wire.OutboundWire;
+import org.apache.tuscany.spi.wire.WireService;
+
+import junit.framework.TestCase;
+import org.easymock.EasyMock;
+
+public class Axis2ServiceTestCase extends TestCase {
+
+ public void testInvokeService() throws Exception {
+ TestServletHost tomcatHost = new TestServletHost();
+ Axis2Service axis2Service = createAxis2Service("testServiceName", tomcatHost, false);
+ axis2Service.start();
+
+ if (true) return;
+ Servlet servlet = tomcatHost.getMapping("testWebAppName/services/testServiceName");
+ assertNotNull(servlet);
+
+ //Create mocked HttpRequest and HttpResponse object to test the Axis2Servlet
+ //To be done:
+
+ }
+
+ public void testAsyncMessageReceiver() throws Exception {
+
+ TestServletHost tomcatHost = new TestServletHost();
+ Axis2Service axis2Service = createAxis2Service("testServiceName", tomcatHost, true);
+ axis2Service.start();
+ }
+
+ private Axis2Service createAxis2Service(String serviceName, ServletHost tomcatHost, boolean callback)
+ throws Exception {
+ //Create WebServiceBinding
+ String wsdlLocation = "/wsdl/hello_world_doc_lit.wsdl";
+ URL url = getClass().getResource(wsdlLocation);
+ assertNotNull("Could not find wsdl " + url.toString(), url);
+
+ WSDLFactory factory = WSDLFactory.newInstance();
+ WSDLReader reader = factory.newWSDLReader();
+ reader.setFeature("javax.wsdl.verbose", false);
+ InputSource input = new InputSource(url.openStream());
+ Definition wsdlDef = reader.readWSDL(url.toString(), input);
+ Service wsdlService = wsdlDef.getService(new QName("http://objectweb.org/hello_world_soap_http",
+ "SOAPService"));
+ Port port = wsdlService.getPort("SoapPort");
+ WebServiceBinding wsBinding = new WebServiceBinding(wsdlDef, port, "uri", "portURI", wsdlService);
+
+ //Create a mocked WireService, make the call of ServiceExtension.getServiceInstance() returns a proxy instance.
+ WireService wireService = EasyMock.createNiceMock(WireService.class);
+ wireService.createProxy(EasyMock.isA(InboundWire.class));
+ EasyMock.expectLastCall().andReturn(null);
+ EasyMock.replay(wireService);
+
+ //Create a mocked InboundWire, make the call of ServiceExtension.getInterface() returns a Class
+ InboundWire inboundWire = EasyMock.createNiceMock(InboundWire.class);
+ JavaServiceContract contract = new JavaServiceContract(Greeter.class);
+ Map<String, Operation<Type>> opMap = new HashMap<String, Operation<Type>>();
+ for(Method m: Greeter.class.getMethods()) {
+ opMap.put(m.getName(), new Operation<Type>(m.getName(), null, null, null));
+ }
+ contract.setOperations(opMap);
+ EasyMock.expect(inboundWire.getServiceContract()).andReturn(contract).anyTimes();
+ if (callback) {
+ contract.setCallbackName("");
+ }
+ EasyMock.replay(inboundWire);
+
+ OutboundWire outboundWire = EasyMock.createNiceMock(OutboundWire.class);
+ Map<Operation<?>, OutboundInvocationChain> map = new HashMap<Operation<?>, OutboundInvocationChain>();
+ EasyMock.expect(outboundWire.getInvocationChains()).andReturn(map).once();
+ EasyMock.replay(outboundWire);
+
+ TuscanyAxisConfigurator tuscanyAxisConfigurator = new TuscanyAxisConfigurator();
+ ConfigurationContext configurationContext = tuscanyAxisConfigurator.getConfigurationContext();
+ WorkContext workContext = EasyMock.createNiceMock(WorkContext.class);
+ EasyMock.replay(workContext);
+ Axis2Service axis2Service =
+ new Axis2Service(serviceName,
+ contract,
+ null,
+ wireService,
+ wsBinding,
+ tomcatHost,
+ configurationContext,
+ workContext);
+ axis2Service.setInboundWire(inboundWire);
+ axis2Service.setOutboundWire(outboundWire);
+
+ return axis2Service;
+ }
+
+ protected class TestServletHost implements ServletHost {
+ private Map<String, Servlet> mappings = new HashMap<String, Servlet>();
+
+ public void registerMapping(String mapping, Servlet servlet) {
+ mappings.put(mapping, servlet);
+ }
+
+ public void unregisterMapping(String mapping) {
+ }
+
+ public Servlet getMapping(String mapping) {
+ return mappings.get(mapping);
+ }
+
+ }
+
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/Greeter.java b/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/Greeter.java
new file mode 100755
index 0000000000..39fccdadd3
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/Greeter.java
@@ -0,0 +1,31 @@
+/*
+ * 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.binding.axis2;
+
+public interface Greeter {
+
+ String sayHi();
+
+ String greetMe(String requestType);
+
+ void greetMeOneWay(String requestType);
+
+ void greetMeWithCallback(String requestType);
+
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/GreetingCallback.java b/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/GreetingCallback.java
new file mode 100644
index 0000000000..4c3b3304ea
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/GreetingCallback.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.binding.axis2;
+
+public interface GreetingCallback {
+
+ void greetMeCallback(String greetMeResponse);
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/test/resources/wsdl/hello_world_doc_lit.wsdl b/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/test/resources/wsdl/hello_world_doc_lit.wsdl
new file mode 100755
index 0000000000..2f56217f88
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.axis2/src/test/resources/wsdl/hello_world_doc_lit.wsdl
@@ -0,0 +1,169 @@
+<?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.
+-->
+<wsdl:definitions name="HelloWorld" targetNamespace="http://objectweb.org/hello_world_soap_http"
+ xmlns="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:tns="http://objectweb.org/hello_world_soap_http"
+ xmlns:x1="http://objectweb.org/hello_world_soap_http/types"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <wsdl:types>
+ <schema targetNamespace="http://objectweb.org/hello_world_soap_http/types"
+ xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:tns="http://objectweb.org/hello_world_soap_http/types"
+ elementFormDefault="qualified">
+ <simpleType name="MyStringType">
+ <restriction base="string">
+ <maxLength value="30" />
+ </restriction>
+ </simpleType>
+
+ <element name="sayHi">
+ <complexType/>
+ </element>
+ <element name="sayHiResponse">
+ <complexType>
+ <sequence>
+ <element name="responseType" type="string"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="greetMe">
+ <complexType>
+ <sequence>
+ <element name="requestType" type="tns:MyStringType"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="greetMeResponse">
+ <complexType>
+ <sequence>
+ <element name="responseType" type="string"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="greetMeOneWay">
+ <complexType>
+ <sequence>
+ <element name="requestType" type="string"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="pingMe">
+ <complexType/>
+ </element>
+ <element name="pingMeResponse">
+ <complexType/>
+ </element>
+ <element name="faultDetail">
+ <complexType>
+ <sequence>
+ <element name="minor" type="short"/>
+ <element name="major" type="short"/>
+ </sequence>
+ </complexType>
+ </element>
+ </schema>
+ </wsdl:types>
+ <wsdl:message name="sayHiRequest">
+ <wsdl:part element="x1:sayHi" name="in"/>
+ </wsdl:message>
+ <wsdl:message name="sayHiResponse">
+ <wsdl:part element="x1:sayHiResponse" name="out"/>
+ </wsdl:message>
+ <wsdl:message name="greetMeRequest">
+ <wsdl:part element="x1:greetMe" name="in"/>
+ </wsdl:message>
+ <wsdl:message name="greetMeResponse">
+ <wsdl:part element="x1:greetMeResponse" name="out"/>
+ </wsdl:message>
+ <wsdl:message name="greetMeOneWayRequest">
+ <wsdl:part element="x1:greetMeOneWay" name="in"/>
+ </wsdl:message>
+
+ <wsdl:portType name="Greeter">
+ <wsdl:operation name="sayHi">
+ <wsdl:input message="tns:sayHiRequest" name="sayHiRequest"/>
+ <wsdl:output message="tns:sayHiResponse" name="sayHiResponse"/>
+ </wsdl:operation>
+
+ <wsdl:operation name="greetMe">
+ <wsdl:input message="tns:greetMeRequest" name="greetMeRequest"/>
+ <wsdl:output message="tns:greetMeResponse" name="greetMeResponse"/>
+ </wsdl:operation>
+
+ <wsdl:operation name="greetMeOneWay">
+ <wsdl:input message="tns:greetMeOneWayRequest" name="greetMeOneWayRequest"/>
+ </wsdl:operation>
+
+ <wsdl:operation name="greetMeWithCallback">
+ <wsdl:input message="tns:greetMeRequest" name="greetMeRequest"/>
+ <wsdl:output message="tns:greetMeResponse" name="greetMeResponse"/>
+ </wsdl:operation>
+
+ </wsdl:portType>
+ <wsdl:binding name="Greeter_SOAPBinding" type="tns:Greeter">
+ <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+
+ <wsdl:operation name="sayHi">
+ <soap:operation soapAction="" style="document"/>
+ <wsdl:input name="sayHiRequest">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="sayHiResponse">
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+
+ <wsdl:operation name="greetMe">
+ <soap:operation soapAction="" style="document"/>
+ <wsdl:input name="greetMeRequest">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="greetMeResponse">
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+
+ <wsdl:operation name="greetMeOneWay">
+ <soap:operation soapAction="" style="document"/>
+ <wsdl:input name="greetMeOneWayRequest">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ </wsdl:operation>
+
+ <wsdl:operation name="greetMeWithCallback">
+ <soap:operation soapAction="" style="document"/>
+ <wsdl:input name="greetMeRequest">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="greetMeResponse">
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+
+ </wsdl:binding>
+ <wsdl:service name="SOAPService">
+ <wsdl:port binding="tns:Greeter_SOAPBinding" name="SoapPort">
+ <soap:address location="http://localhost:9000/SoapContext/SoapPort"/>
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
+
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.celtix/.checkstyle b/branches/sca-java-M2/sca/services/bindings/binding.celtix/.checkstyle
new file mode 100644
index 0000000000..a2af63613f
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.celtix/.checkstyle
@@ -0,0 +1,24 @@
+<?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.
+-->
+<fileset-config file-format-version="1.2.0" simple-config="true">
+ <fileset name="all" enabled="true" check-config-name="Tuscany Checks" local="false">
+ <file-match-pattern match-pattern="." include-pattern="true"/>
+ </fileset>
+</fileset-config>
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.celtix/.pmd b/branches/sca-java-M2/sca/services/bindings/binding.celtix/.pmd
new file mode 100644
index 0000000000..3e1ff77730
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.celtix/.pmd
@@ -0,0 +1,23 @@
+<?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.
+-->
+<pmd>
+ <useProjectRuleSet>true</useProjectRuleSet>
+ <rules/>
+</pmd>
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.celtix/.ruleset b/branches/sca-java-M2/sca/services/bindings/binding.celtix/.ruleset
new file mode 100644
index 0000000000..0933c1569c
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.celtix/.ruleset
@@ -0,0 +1,190 @@
+<?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.
+-->
+<ruleset name="pmd-eclipse">
+ <description>PMD Plugin preferences rule set</description>
+
+
+ <rule ref="rulesets/basic.xml/BooleanInstantiation"/>
+ <rule ref="rulesets/basic.xml/CollapsibleIfStatements"/>
+ <rule ref="rulesets/basic.xml/DoubleCheckedLocking"/>
+<!--<rule ref="rulesets/basic.xml/EmptyCatchBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyFinallyBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyIfStmt"/>-->
+ <rule ref="rulesets/basic.xml/EmptyStatementNotInLoop"/>
+<!--<rule ref="rulesets/basic.xml/EmptyStaticInitializer"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptySwitchStatements"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptySynchronizedBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyTryBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyWhileStmt"/>-->
+ <rule ref="rulesets/basic.xml/ForLoopShouldBeWhileLoop"/>
+ <rule ref="rulesets/basic.xml/JumbledIncrementer"/>
+<!--<rule ref="rulesets/basic.xml/OverrideBothEqualsAndHashcode"/>-->
+ <rule ref="rulesets/basic.xml/ReturnFromFinallyBlock"/>
+ <rule ref="rulesets/basic.xml/UnconditionalIfStatement"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryConversionTemporary"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryFinalModifier"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryReturn"/>
+<!--<rule ref="rulesets/basic.xml/UselessOverridingMethod"/>-->
+
+<!--<rule ref="rulesets/braces.xml/ForLoopsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/IfElseStmtsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/IfStmtsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/WhileLoopsMustUseBraces"/>-->
+
+<!--<rule ref="rulesets/clone.xml/CloneMethodMustImplementCloneable"/>-->
+<!--<rule ref="rulesets/clone.xml/CloneThrowsCloneNotSupportedException"/>-->
+<!--<rule ref="rulesets/clone.xml/ProperCloneImplementation"/>-->
+
+<!--<rule ref="rulesets/codesize.xml/CyclomaticComplexity"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveClassLength"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveMethodLength"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveParameterList"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessivePublicCount"/>-->
+<!--<rule ref="rulesets/codesize.xml/TooManyFields"/>-->
+
+<rule ref="rulesets/controversial.xml/AssignmentInOperand"/>
+<!--<rule ref="rulesets/controversial.xml/AtLeastOneConstructor"/>-->
+<!--<rule ref="rulesets/controversial.xml/CallSuperInConstructor"/>-->
+<!--<rule ref="rulesets/controversial.xml/DontImportSun"/>-->
+<!--<rule ref="rulesets/controversial.xml/NullAssignment"/>-->
+<!--<rule ref="rulesets/controversial.xml/OnlyOneReturn"/>-->
+<!--<rule ref="rulesets/controversial.xml/SingularField"/>-->
+<!--<rule ref="rulesets/controversial.xml/SuspiciousOctalEscape"/>-->
+<!--<rule ref="rulesets/controversial.xml/UnnecessaryConstructor"/>-->
+<rule ref="rulesets/controversial.xml/UnnecessaryParentheses"/>
+<!--<rule ref="rulesets/controversial.xml/UnusedModifier"/>-->
+
+<!--<rule ref="rulesets/coupling.xml/CouplingBetweenObjects"/>-->
+<!--<rule ref="rulesets/coupling.xml/ExcessiveImports"/>-->
+<!--<rule ref="rulesets/coupling.xml/LooseCoupling"/>-->
+
+<!--<rule ref="rulesets/design.xml/AbstractClassWithoutAbstractMethod"/>-->
+<!--<rule ref="rulesets/design.xml/AccessorClassGeneration"/>-->
+<!--<rule ref="rulesets/design.xml/AssignmentToNonFinalStatic"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidDeeplyNestedIfStmts"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidInstanceofChecksInCatchClause"/>-->
+<rule ref="rulesets/design.xml/AvoidProtectedFieldInFinalClass"/>
+<!--<rule ref="rulesets/design.xml/AvoidReassigningParameters"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidSynchronizedAtMethodLevel"/>-->
+<!--<rule ref="rulesets/design.xml/BadComparison"/>-->
+<!--<rule ref="rulesets/design.xml/CloseConnection"/>-->
+<!--<rule ref="rulesets/design.xml/CompareObjectsWithEquals"/>-->
+<!--<rule ref="rulesets/design.xml/ConfusingTernary"/>-->
+<rule ref="rulesets/design.xml/ConstructorCallsOverridableMethod"/>
+<!--<rule ref="rulesets/design.xml/DefaultLabelNotLastInSwitchStmt"/>-->
+<!--<rule ref="rulesets/design.xml/FinalFieldCouldBeStatic"/>-->
+<rule ref="rulesets/design.xml/IdempotentOperations"/>
+<!--<rule ref="rulesets/design.xml/ImmutableField"/>-->
+<!--<rule ref="rulesets/design.xml/InstantiationToGetClass"/>-->
+<!--<rule ref="rulesets/design.xml/MissingBreakInSwitch"/>-->
+<!--<rule ref="rulesets/design.xml/MissingStaticMethodInNonInstantiatableClass"/>-->
+<!--<rule ref="rulesets/design.xml/NonCaseLabelInSwitchStatement"/>-->
+<!--<rule ref="rulesets/design.xml/NonStaticInitializer"/>-->
+<rule ref="rulesets/design.xml/OptimizableToArrayCall"/>
+<rule ref="rulesets/design.xml/PositionLiteralsFirstInComparisons"/>
+<rule ref="rulesets/design.xml/SimplifyBooleanExpressions"/>
+<rule ref="rulesets/design.xml/SimplifyBooleanReturns"/>
+<rule ref="rulesets/design.xml/SimplifyConditional"/>
+<!--<rule ref="rulesets/design.xml/SwitchDensity"/>-->
+<!--<rule ref="rulesets/design.xml/SwitchStmtsShouldHaveDefault"/>-->
+<rule ref="rulesets/design.xml/UnnecessaryLocalBeforeReturn"/>
+<!--<rule ref="rulesets/design.xml/UseLocaleWithCaseConversions"/>-->
+<!--<rule ref="rulesets/design.xml/UseNotifyAllInsteadOfNotify"/>-->
+<!--<rule ref="rulesets/design.xml/UseSingleton"/>-->
+
+<!--<rule ref="rulesets/finalizers.xml/EmptyFinalizer"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeOnlyCallsSuperFinalize"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeOverloaded"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeDoesNotCallSuperFinalize"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeShouldBeProtected"/>-->
+<!--<rule ref="rulesets/finalizers.xml/AvoidCallingFinalize"/>-->
+
+<!--<rule ref="rulesets/imports.xml/DuplicateImports"/>-->
+<!--<rule ref="rulesets/imports.xml/DontImportJavaLang"/>-->
+<!--<rule ref="rulesets/imports.xml/UnusedImports"/>-->
+<!--<rule ref="rulesets/imports.xml/ImportFromSamePackage"/>-->
+
+<!--<rule ref="rulesets/javabeans.xml/BeanMembersShouldSerialize"/>-->
+<!--<rule ref="rulesets/javabeans.xml/MissingSerialVersionUID"/>-->
+
+<!--<rule ref="rulesets/junit.xml/JUnitStaticSuite"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitSpelling"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitAssertionsShouldIncludeMessage"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitTestsShouldIncludeAssert"/>-->
+<!--<rule ref="rulesets/junit.xml/TestClassWithoutTestCases"/>-->
+<!--<rule ref="rulesets/junit.xml/UnnecessaryBooleanAssertion"/>-->
+<!--<rule ref="rulesets/junit.xml/UseAssertEqualsInsteadOfAssertTrue"/>-->
+<!--<rule ref="rulesets/junit.xml/UseAssertSameInsteadOfAssertTrue"/>-->
+
+ <!--<rule ref="rulesets/logging-java.xml/AvoidPrintStackTrace"/>-->
+ <rule ref="rulesets/logging-java.xml/LoggerIsNotStaticFinal"/>
+ <!--<rule ref="rulesets/logging-java.xml/MoreThanOneLogger"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LoggerIsNotStaticFinal"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LogBlockWithoutIf"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/SystemPrintln"/>-->
+ <!--<rule ref="rulesets/logging-jakarta-commons.xml/UseCorrectExceptionLogging"/>-->
+ <!--<rule ref="rulesets/logging-jakarta-commons.xml/ProperLogger"/>-->
+
+ <!--<rule ref="rulesets/naming.xml/ShortVariable"/>-->
+ <!--<rule ref="rulesets/naming.xml/LongVariable"/>-->
+ <!--<rule ref="rulesets/naming.xml/ShortMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/VariableNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/MethodNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/ClassNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/AbstractNaming"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidDollarSigns"/>-->
+ <!--<rule ref="rulesets/naming.xml/MethodWithSameNameAsEnclosingClass"/>-->
+ <!--<rule ref="rulesets/naming.xml/SuspiciousHashcodeMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/SuspiciousConstantFieldName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidFieldNameMatchingTypeName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidFieldNameMatchingMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidNonConstructorMethodsWithClassName"/>-->
+ <!--<rule ref="rulesets/naming.xml/NoPackage"/>-->
+ <!--<rule ref="rulesets/naming.xml/PackageCase"/>-->
+
+ <!--<rule ref="rulesets/optimizations.xml/LocalVariableCouldBeFinal"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/MethodArgumentCouldBeFinal"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/AvoidInstantiatingObjectsInLoops"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/UseArrayListInsteadOfVector"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/SimplifyStartsWith"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/UseStringBufferForStringAppends"/>-->
+
+ <!--<rule ref="rulesets/strictexception.xml/AvoidCatchingThrowable"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/SignatureDeclareThrowsException"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/ExceptionAsFlowControl"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidCatchingNPE"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidThrowingRawExceptionTypes"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidThrowingNullPointerException"/>-->
+
+ <!--<rule ref="rulesets/strings.xml/AvoidDuplicateLiterals"/>-->
+ <!--<rule ref="rulesets/strings.xml/StringInstantiation"/>-->
+ <!--<rule ref="rulesets/strings.xml/StringToString"/>-->
+ <!--<rule ref="rulesets/strings.xml/AvoidConcatenatingNonLiteralsInStringBuffer"/>-->
+ <!--<rule ref="rulesets/strings.xml/UnnecessaryCaseChange"/>-->
+
+ <!--<rule ref="rulesets/sunsecure.xml/MethodReturnsInternalArray"/>-->
+ <!--<rule ref="rulesets/sunsecure.xml/ArrayIsStoredDirectly"/>-->
+
+ <rule ref="rulesets/unusedcode.xml/UnusedLocalVariable"/>
+ <rule ref="rulesets/unusedcode.xml/UnusedPrivateField"/>
+ <rule ref="rulesets/unusedcode.xml/UnusedPrivateMethod"/>
+ <!--<rule ref="rulesets/unusedcode.xml/UnusedFormalParameter"/>-->
+
+</ruleset>
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.celtix/LICENSE.txt b/branches/sca-java-M2/sca/services/bindings/binding.celtix/LICENSE.txt
new file mode 100644
index 0000000000..0084319535
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.celtix/LICENSE.txt
@@ -0,0 +1,202 @@
+
+ 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, serviceDefinition 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/branches/sca-java-M2/sca/services/bindings/binding.celtix/NOTICE.txt b/branches/sca-java-M2/sca/services/bindings/binding.celtix/NOTICE.txt
new file mode 100644
index 0000000000..d83ebbe236
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.celtix/NOTICE.txt
@@ -0,0 +1,14 @@
+${pom.name}
+Copyright (c) 2005 - 2006 The Apache Software Foundation
+
+Apache Tuscany is an effort undergoing incubation at The Apache Software
+Foundation (ASF), sponsored by the Apache Web Services PMC. Incubation is
+required of all newly accepted projects until a further review indicates that
+the infrastructure, communications, and decision making process have stabilized
+in a manner consistent with other successful ASF projects. While incubation
+status is not necessarily a reflection of the completeness or stability of the
+code, it does indicate that the project has yet to be fully endorsed by the ASF.
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.celtix/README.txt b/branches/sca-java-M2/sca/services/bindings/binding.celtix/README.txt
new file mode 100644
index 0000000000..9b26d1690a
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.celtix/README.txt
@@ -0,0 +1,35 @@
+Apache Tuscany M1 build (May, 2006)
+===================================
+
+http://incubator.apache.org/tuscany/
+
+Tuscany is an effort undergoing incubation at the Apache Software Foundation
+(ASF), sponsored by the Web Services PMC.
+
+Incubation is required of all newly accepted projects until a further review
+indicates that the infrastructure, communications, and decision making process
+have stabilized in a manner consistent with other successful ASF projects.
+
+While incubation status is not necessarily a reflection of the completeness or
+stability of the code, it does indicate that the project has yet to be fully
+endorsed by the ASF.
+
+
+Support
+-------
+
+Any problem with this release can be reported to the Tuscany mailing list
+or in the JIRA issue tracker.
+
+Mailing list subscription:
+ tuscany-dev-subscribe@ws.apache.org
+
+Jira:
+ http://issues.apache.org/jira/browse/Tuscany
+
+
+Thank you for using Tuscany!
+
+
+The Tuscany Team.
+
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.celtix/pom.xml b/branches/sca-java-M2/sca/services/bindings/binding.celtix/pom.xml
new file mode 100644
index 0000000000..0a71a1e338
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.celtix/pom.xml
@@ -0,0 +1,96 @@
+<?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 xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <parent>
+ <groupId>org.apache.tuscany.sca.services.bindings</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>celtix</artifactId>
+ <name>Apache Tuscany Binding for Celtix</name>
+ <description>Implementation of the SCA Web Services binding using Celtix.</description>
+
+ <properties>
+ <celtix.version>1.0</celtix.version>
+ <checkstyle.properties>checkstyle.severity=error</checkstyle.properties>
+ <sourcechecks.force>true</sourcechecks.force>
+ </properties>
+ <repositories>
+ <repository>
+ <id>objectweb</id>
+ <name>ObjectWeb repo</name>
+ <url>http://maven.objectweb.org/maven2</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.kernel</groupId>
+ <artifactId>core</artifactId>
+ <version>${sca.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca.services.idl</groupId>
+ <artifactId>wsdl</artifactId>
+ <version>${sca.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca.services.databinding</groupId>
+ <artifactId>databinding-sdo</artifactId>
+ <version>${sca.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <!-- Celtix -->
+ <dependency>
+ <groupId>org.objectweb.celtix</groupId>
+ <artifactId>celtix-rt</artifactId>
+ <version>${celtix.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymockclassextension</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>woodstox</groupId>
+ <artifactId>wstx-asl</artifactId>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/BusService.java b/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/BusService.java
new file mode 100644
index 0000000000..238fbe97b0
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/BusService.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.binding.celtix;
+
+import org.objectweb.celtix.Bus;
+
+/**
+ * A system service that returns the active Celtix <code>Bus</code> for the runtime
+ *
+ * @version $Rev$ $Date$
+ */
+public interface BusService {
+
+ /**
+ * Returns the active bus
+ */
+ Bus getBus();
+
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/BusServiceImpl.java b/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/BusServiceImpl.java
new file mode 100644
index 0000000000..3a1c95c95e
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/BusServiceImpl.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.binding.celtix;
+
+import java.util.Map;
+import java.util.WeakHashMap;
+
+import org.apache.tuscany.idl.wsdl.WSDLDefinitionRegistry;
+
+import org.objectweb.celtix.Bus;
+import org.objectweb.celtix.BusException;
+import org.osoa.sca.annotations.Destroy;
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Property;
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * The default implementation of the Celtix Bus system service
+ *
+ * @version $Rev$ $Date$
+ */
+@Scope("MODULE")
+public class BusServiceImpl implements BusService {
+
+ protected WSDLDefinitionRegistry wsdlRegistry;
+ private Bus bus;
+
+ public Bus getBus() {
+ return bus;
+ }
+
+ /**
+ * FIXME the annotation processing framework must inject this
+ * @param wsdlReg
+ */
+ @Property (override = "must")
+ public void setWsdlRegistry(WSDLDefinitionRegistry wsdlReg) {
+ wsdlRegistry = wsdlReg;
+ }
+
+ /**
+ * Initializes the bus, set to be called when the runtime initializes the Celtix system composite
+ * @throws BusException
+ */
+ @Init(eager = true)
+ public void init() throws BusException {
+ Map<String, Object> properties = new WeakHashMap<String, Object>();
+ properties.put("celtix.WSDLManager", new TuscanyWSDLManager(wsdlRegistry));
+ bus = Bus.init(new String[0], properties);
+ }
+
+ /**
+ * Shuts down the bus, called when the runtime stops the Celtix system composite
+ * @throws BusException
+ */
+ @Destroy
+ public void stop() throws BusException {
+ bus.shutdown(true);
+ }
+
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/CeltixBindingBuilder.java b/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/CeltixBindingBuilder.java
new file mode 100644
index 0000000000..ec1a71b19d
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/CeltixBindingBuilder.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.binding.celtix;
+
+import java.util.Map;
+import java.util.WeakHashMap;
+
+import org.apache.tuscany.idl.wsdl.WSDLDefinitionRegistry;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.Reference;
+import org.apache.tuscany.spi.component.Service;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.BindingBuilderExtension;
+import org.apache.tuscany.spi.model.BoundReferenceDefinition;
+import org.apache.tuscany.spi.model.BoundServiceDefinition;
+import org.objectweb.celtix.Bus;
+
+import commonj.sdo.helper.TypeHelper;
+
+/**
+ * Builds a {@link org.apache.tuscany.spi.component.Service} or {@link org.apache.tuscany.spi.component.Reference}
+ * configured with the Celtix binding
+ *
+ * @version $Rev$ $Date$
+ */
+public class CeltixBindingBuilder extends BindingBuilderExtension<WebServiceBinding> {
+
+ private Bus bus;
+
+ public Service build(CompositeComponent parent,
+ BoundServiceDefinition<WebServiceBinding> boundServiceDefinition,
+ DeploymentContext deploymentContext) {
+ WebServiceBinding wsBinding = boundServiceDefinition.getBinding();
+ TypeHelper typeHelper = (TypeHelper) deploymentContext.getExtension(TypeHelper.class.getName());
+ if (typeHelper == null) {
+ typeHelper = TypeHelper.INSTANCE;
+ }
+ if (bus == null) {
+ bus = getBus(wsBinding.getWSDLDefinitionRegistry());
+ }
+ return new CeltixService(
+ boundServiceDefinition.getName(),
+ boundServiceDefinition.getServiceContract().getInterfaceClass(),
+ parent,
+ wireService,
+ wsBinding,
+ bus,
+ typeHelper);
+ }
+
+ public Reference build(CompositeComponent parent,
+ BoundReferenceDefinition<WebServiceBinding> boundReferenceDefinition,
+ DeploymentContext deploymentContext) {
+ WebServiceBinding wsBinding = boundReferenceDefinition.getBinding();
+ TypeHelper typeHelper = (TypeHelper) deploymentContext.getExtension(TypeHelper.class.getName());
+ if (typeHelper == null) {
+ typeHelper = TypeHelper.INSTANCE;
+ }
+ if (bus == null) {
+ bus = getBus(wsBinding.getWSDLDefinitionRegistry());
+ }
+ return new CeltixReference(
+ boundReferenceDefinition.getName(),
+ boundReferenceDefinition.getServiceContract().getInterfaceClass(),
+ parent,
+ wireService,
+ wsBinding,
+ bus,
+ typeHelper);
+ }
+
+ protected Class<WebServiceBinding> getBindingType() {
+ return WebServiceBinding.class;
+ }
+
+ private Bus getBus(WSDLDefinitionRegistry wsdlDefinitionRegistry) {
+ Bus celtixBus = null;
+ try {
+ Map<String, Object> properties = new WeakHashMap<String, Object>();
+ properties.put("celtix.WSDLManager", new TuscanyWSDLManager(wsdlDefinitionRegistry));
+ celtixBus = Bus.init(new String[0], properties);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return celtixBus;
+ }
+
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/CeltixInvoker.java b/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/CeltixInvoker.java
new file mode 100644
index 0000000000..aba5fd5984
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/CeltixInvoker.java
@@ -0,0 +1,245 @@
+/*
+ * 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.binding.celtix;
+
+import java.io.IOException;
+import java.lang.reflect.Array;
+import java.lang.reflect.InvocationTargetException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.List;
+import javax.jws.WebParam;
+import javax.wsdl.Binding;
+import javax.wsdl.Definition;
+import javax.wsdl.Port;
+import javax.wsdl.Service;
+import javax.wsdl.WSDLException;
+import javax.wsdl.extensions.ExtensibilityElement;
+import javax.wsdl.extensions.soap.SOAPAddress;
+import javax.xml.namespace.QName;
+import javax.xml.ws.Holder;
+
+import org.apache.tuscany.spi.builder.BuilderException;
+import org.apache.tuscany.spi.wire.Interceptor;
+import org.apache.tuscany.spi.wire.Message;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+
+import commonj.sdo.helper.TypeHelper;
+import org.apache.tuscany.binding.celtix.io.SCADataBindingCallback;
+import org.objectweb.celtix.Bus;
+import org.objectweb.celtix.BusException;
+import org.objectweb.celtix.bindings.ClientBinding;
+import org.objectweb.celtix.bindings.DataBindingCallback;
+import org.objectweb.celtix.bus.bindings.WSDLMetaDataCache;
+import org.objectweb.celtix.bus.bindings.WSDLOperationInfo;
+import org.objectweb.celtix.context.ObjectMessageContext;
+import org.objectweb.celtix.ws.addressing.EndpointReferenceType;
+import org.objectweb.celtix.wsdl.EndpointReferenceUtils;
+import org.xmlsoap.schemas.wsdl.http.AddressType;
+
+
+/**
+ * Responsible for dispatching a service operation invocation on a reference to the active Celtix <code>Bus</code>
+ *
+ * @version $Rev$ $Date$
+ */
+public class CeltixInvoker implements TargetInvoker {
+
+ private WSDLMetaDataCache wsdlCache;
+
+ private ClientBinding clientBinding;
+
+ private String operationName;
+
+ private TypeHelper typeHelper;
+
+ public CeltixInvoker(String operationName,
+ Bus bus,
+ Port port,
+ Service wsdlService,
+ Definition wsdlDef,
+ TypeHelper theTypeHelper) throws BuilderException {
+ this.wsdlCache = new WSDLMetaDataCache(wsdlDef, port);
+ this.operationName = operationName;
+ this.typeHelper = theTypeHelper;
+ // Definition wsdlDef = wsBinding.getWSDLDefinition();
+ // wsdlCache = new WSDLMetaDataCache(wsdlDef, wsBinding.getWSDLPort());
+
+ try {
+ String key = wsdlDef.getDocumentBaseURI();
+ URL url = new URL(key);
+
+ QName qName = wsdlService.getQName();
+ EndpointReferenceType reference = EndpointReferenceUtils.getEndpointReference(url, qName, port.getName());
+
+ String bindingId = null;
+ Binding binding = port.getBinding();
+ if (null != binding) {
+ List list = binding.getExtensibilityElements();
+ if (!list.isEmpty()) {
+ bindingId = ((ExtensibilityElement) list.get(0)).getElementType().getNamespaceURI();
+ }
+ }
+ if (bindingId == null) {
+ List<?> list = port.getExtensibilityElements();
+ for (Object ep : list) {
+ ExtensibilityElement ext = (ExtensibilityElement) ep;
+ if (ext instanceof SOAPAddress) {
+ bindingId = ((SOAPAddress) ext).getLocationURI();
+ }
+ if (ext instanceof AddressType) {
+ bindingId = ((AddressType) ext).getLocation();
+ }
+ }
+
+ }
+ clientBinding = bus.getBindingManager().getBindingFactory(bindingId).createClientBinding(reference);
+ } catch (MalformedURLException e) {
+ throw new InvokerCreationException(e);
+ } catch (BusException e) {
+ throw new InvokerCreationException(e);
+ } catch (WSDLException e) {
+ throw new InvokerCreationException(e);
+ } catch (IOException e) {
+ throw new InvokerCreationException(e);
+ }
+ }
+
+ /**
+ * Invoke an operation on the external Web service.
+ *
+ * @param args the Java object arguments to the WS operation
+ * @return the response from the WS as a Java object
+ */
+ public Object invokeTarget(final Object args) throws InvocationTargetException {
+ WSDLOperationInfo opInfo = wsdlCache.getOperationInfo(operationName);
+ if (opInfo == null) {
+ // REVISIT - really map the operation name to a WSDL operation
+ for (String opName : wsdlCache.getAllOperationInfo().keySet()) {
+ if (operationName.equalsIgnoreCase(opName)) {
+ opInfo = wsdlCache.getOperationInfo(opName);
+ break;
+ }
+ }
+ }
+
+ ObjectMessageContext objMsgContext = clientBinding.createObjectContext();
+
+ boolean hasInOut = false;
+ int inOutCount = 0;
+ Object realArgs[];
+ Object argsArray[];
+ if (args.getClass().isArray()) {
+ argsArray = (Object[]) args;
+ realArgs = new Object[Array.getLength(args)];
+ } else {
+ argsArray = new Object[0];
+ realArgs = new Object[0];
+ }
+
+ if (opInfo.getParamsLength() == 0) {
+ // REVISIT - opInfo doesn't return the needed info for the wrapped doc/lit case.
+ // Bug in Celtix
+ realArgs = argsArray;
+ } else {
+ for (int x = 0; x < argsArray.length; x++) {
+ if (opInfo.getWebParam(x).mode() == WebParam.Mode.IN) {
+ realArgs[x] = argsArray[x];
+ } else {
+ realArgs[x] = new Holder<Object>(argsArray[x]);
+ inOutCount++;
+ hasInOut = true;
+ }
+ }
+ }
+ objMsgContext.setMessageObjects(realArgs);
+ boolean isOneway = opInfo.isOneWay();
+ DataBindingCallback callback = new SCADataBindingCallback(opInfo, hasInOut, typeHelper);
+ try {
+ if (isOneway) {
+ clientBinding.invokeOneWay(objMsgContext, callback);
+ } else {
+ objMsgContext = clientBinding.invoke(objMsgContext, callback);
+ }
+ } catch (IOException e) {
+ throw new InvocationTargetException(e);
+ }
+
+ if (objMsgContext.getException() != null) {
+ // REVISIT - Exceptions
+ /*
+ * if (isValidException(objMsgContext)) { throw
+ * (Exception)objMsgContext.getException(); } else { throw new
+ * ProtocolException(objMsgContext.getException()); }
+ */
+ throw new InvocationTargetException(objMsgContext.getException());
+ }
+
+ if (hasInOut) {
+ Object ret[] = new Object[inOutCount + 1];
+ ret[0] = objMsgContext.getReturn();
+ inOutCount = 1;
+ for (int x = 0; x < argsArray.length; x++) {
+ if (opInfo.getWebParam(x).mode() != WebParam.Mode.IN) {
+ Holder<?> holder = (Holder<?>) realArgs[x];
+ ret[inOutCount] = holder.value;
+ inOutCount++;
+ }
+ }
+ return ret;
+ }
+ return objMsgContext.getReturn();
+ }
+
+ public Message invoke(Message msg) {
+ try {
+ Object resp = invokeTarget(msg.getBody());
+ msg.setBody(resp);
+ } catch (Throwable e) {
+ msg.setBodyWithFault(e);
+ }
+ return msg;
+ }
+
+ public void setNext(Interceptor next) {
+ throw new UnsupportedOperationException();
+ }
+
+ public CeltixInvoker clone() throws CloneNotSupportedException {
+ try {
+ return (CeltixInvoker) super.clone();
+ } catch (CloneNotSupportedException e) {
+ // will not happen
+ return null;
+ }
+ }
+
+ public boolean isCacheable() {
+ return true;
+ }
+
+ public void setCacheable(boolean cacheable) {
+
+ }
+
+ public boolean isOptimizable() {
+ return false;
+ }
+
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/CeltixReference.java b/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/CeltixReference.java
new file mode 100644
index 0000000000..c32f332d4b
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/CeltixReference.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.binding.celtix;
+
+import javax.wsdl.Definition;
+import javax.wsdl.Port;
+import javax.wsdl.Service;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.extension.ReferenceExtension;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+import org.apache.tuscany.spi.wire.WireService;
+
+import commonj.sdo.helper.TypeHelper;
+import org.objectweb.celtix.Bus;
+
+/**
+ * The implementation of a {@link org.apache.tuscany.spi.component.Reference} configured with the Celtix binding
+ *
+ * @version $Rev$ $Date$
+ */
+public class CeltixReference<T> extends ReferenceExtension {
+
+ private Bus bus;
+ private Port port;
+ private Definition wsdlDef;
+ private Service wsdlService;
+ private TypeHelper typeHelper;
+
+ public CeltixReference(String name,
+ Class<T> interfaze,
+ CompositeComponent parent,
+ WireService wireService,
+ WebServiceBinding binding,
+ Bus theBus,
+ TypeHelper theTypeHelper) {
+ super(name, interfaze, parent, wireService);
+ this.wsdlDef = binding.getWSDLDefinition();
+ this.port = binding.getWSDLPort();
+ this.wsdlService = binding.getWSDLService();
+ this.bus = theBus;
+ this.typeHelper = theTypeHelper;
+ }
+
+ public TargetInvoker createTargetInvoker(ServiceContract contract, Operation operation) {
+ return new CeltixInvoker(operation.getName(), bus, port, wsdlService, wsdlDef, typeHelper);
+ }
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/CeltixService.java b/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/CeltixService.java
new file mode 100644
index 0000000000..097f0ac050
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/CeltixService.java
@@ -0,0 +1,270 @@
+/*
+ * 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.binding.celtix;
+
+import java.lang.reflect.Method;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.Executor;
+import javax.jws.soap.SOAPBinding;
+import javax.wsdl.Binding;
+import javax.wsdl.BindingInput;
+import javax.wsdl.BindingOperation;
+import javax.wsdl.Definition;
+import javax.wsdl.Port;
+import javax.wsdl.Service;
+import javax.wsdl.extensions.ExtensibilityElement;
+import javax.wsdl.extensions.soap.SOAPAddress;
+import javax.wsdl.extensions.soap.SOAPBody;
+import javax.xml.namespace.QName;
+import javax.xml.ws.WebServiceProvider;
+
+import org.osoa.sca.annotations.Destroy;
+
+import org.apache.tuscany.spi.CoreRuntimeException;
+import org.apache.tuscany.spi.builder.BuilderConfigException;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.extension.ServiceExtension;
+import org.apache.tuscany.spi.wire.WireService;
+
+import commonj.sdo.helper.TypeHelper;
+import org.apache.tuscany.binding.celtix.io.SCAServerDataBindingCallback;
+import org.objectweb.celtix.Bus;
+import org.objectweb.celtix.bindings.BindingFactory;
+import org.objectweb.celtix.bindings.DataBindingCallback;
+import org.objectweb.celtix.bindings.ServerBinding;
+import org.objectweb.celtix.bindings.ServerBindingEndpointCallback;
+import org.objectweb.celtix.bindings.ServerDataBindingCallback;
+import org.objectweb.celtix.bus.bindings.WSDLMetaDataCache;
+import org.objectweb.celtix.bus.bindings.WSDLOperationInfo;
+import org.objectweb.celtix.context.ObjectMessageContext;
+import org.objectweb.celtix.ws.addressing.AttributedURIType;
+import org.objectweb.celtix.ws.addressing.EndpointReferenceType;
+import org.objectweb.celtix.wsdl.EndpointReferenceUtils;
+import org.xmlsoap.schemas.wsdl.http.AddressType;
+
+
+/**
+ * An implementation of a {@link Service} configured with the Celtix binding
+ *
+ * @version $Rev$ $Date$
+ */
+public class CeltixService extends ServiceExtension implements ServerBindingEndpointCallback {
+
+ private Bus bus;
+ private Port port;
+ private Definition wsdlDef;
+ private Service wsdlService;
+ private WSDLMetaDataCache wsdlCache;
+ private TypeHelper typeHelper;
+
+ private Map<QName, ServerDataBindingCallback> opMap =
+ new ConcurrentHashMap<QName, ServerDataBindingCallback>();
+
+
+ public CeltixService(String theName,
+ Class<?> interfaze,
+ CompositeComponent parent,
+ WireService wireService,
+ WebServiceBinding binding,
+ Bus bus,
+ TypeHelper theTypeHelper) {
+ super(theName, interfaze, parent, wireService);
+ this.wsdlDef = binding.getWSDLDefinition();
+ this.port = binding.getWSDLPort();
+ this.wsdlService = binding.getWSDLService();
+ this.bus = bus;
+ this.wsdlCache = new WSDLMetaDataCache(wsdlDef, port);
+ this.typeHelper = theTypeHelper;
+ }
+
+ public void start() {
+ super.start();
+ initOperationMap();
+ startServerBinding();
+ }
+
+ private void startServerBinding() {
+ String key = wsdlDef.getDocumentBaseURI();
+ URL url;
+ try {
+ url = new URL(key);
+ } catch (MalformedURLException e) {
+ throw new CeltixServiceInitException(e);
+ }
+
+ QName qName = wsdlService.getQName();
+ String portName = port.getName();
+ EndpointReferenceType reference = EndpointReferenceUtils.getEndpointReference(url,qName,portName);
+
+ AttributedURIType address = new AttributedURIType();
+
+ String bindingId = null;
+ Binding binding = port.getBinding();
+ if (null != binding) {
+ List list = binding.getExtensibilityElements();
+ if (!list.isEmpty()) {
+ bindingId = ((ExtensibilityElement) list.get(0)).getElementType().getNamespaceURI();
+ }
+ }
+ List<?> list = port.getExtensibilityElements();
+ for (Object ep : list) {
+ ExtensibilityElement ext = (ExtensibilityElement) ep;
+ if (ext instanceof SOAPAddress) {
+ if (bindingId == null) {
+ bindingId = ((SOAPAddress) ext).getLocationURI();
+ }
+ address.setValue(((SOAPAddress) ext).getLocationURI());
+ }
+ if (ext instanceof AddressType) {
+ if (bindingId == null) {
+ bindingId = ((AddressType) ext).getLocation();
+ }
+ address.setValue(((AddressType) ext).getLocation());
+ }
+ }
+ if (reference.getAddress() == null) {
+ //REVIST - bug in Celtix that the HTTP transport won't find the address correctly
+ reference.setAddress(address);
+ }
+ ClassLoader previousLoader = null;
+ try {
+ //FIXME: This hack is because SAAJImpl uses Thread.currentThread().getContextClassLoader(),
+ //this classloader is different from current classLoader.
+ previousLoader = Thread.currentThread().getContextClassLoader();
+ Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
+ BindingFactory bindingFactory = bus.getBindingManager().getBindingFactory(bindingId);
+ ServerBinding serverBinding = bindingFactory.createServerBinding(reference, this);
+ serverBinding.activate();
+ } catch (Exception e) {
+ throw new CeltixServiceInitException(e);
+ } finally {
+ if (previousLoader != null) {
+ Thread.currentThread().setContextClassLoader(previousLoader);
+ }
+ }
+ }
+
+ private void initOperationMap() {
+ List ops = port.getBinding().getBindingOperations();
+ for (Object op1 : ops) {
+ BindingOperation op = (BindingOperation) op1;
+ BindingInput bindingInput = op.getBindingInput();
+ List elements = bindingInput.getExtensibilityElements();
+ QName qn = new QName(wsdlDef.getTargetNamespace(), op.getName());
+
+ //In case soap:body namespace is different from targetNamespace
+ for (Object element : elements) {
+ if (SOAPBody.class.isInstance(element)) {
+ SOAPBody body = (SOAPBody) element;
+ if (body.getNamespaceURI() != null) {
+ qn = new QName(body.getNamespaceURI(), op.getName());
+ }
+ }
+ }
+
+ ServerDataBindingCallback cb = getDataBindingCallback(qn, null, DataBindingCallback.Mode.PARTS);
+ opMap.put(qn, cb);
+ if (!"".equals(cb.getRequestWrapperQName().getLocalPart())) {
+ opMap.put(cb.getRequestWrapperQName(), cb);
+ }
+ }
+ }
+
+ @Destroy
+ public void stop() throws CoreRuntimeException {
+ super.stop();
+ }
+
+ public ServerDataBindingCallback getDataBindingCallback(QName operationName,
+ ObjectMessageContext objContext,
+ DataBindingCallback.Mode mode) {
+ if (opMap.containsKey(operationName)) {
+ return opMap.get(operationName);
+ }
+ WSDLOperationInfo opInfo = wsdlCache.getOperationInfo(operationName.getLocalPart());
+ if (opInfo == null) {
+ //REVISIT - really map the operation name to a WSDL operation
+ for (String opName : wsdlCache.getAllOperationInfo().keySet()) {
+ if (operationName.getLocalPart().equalsIgnoreCase(opName)) {
+ opInfo = wsdlCache.getOperationInfo(opName);
+ break;
+ }
+ }
+ }
+ boolean inout = false;
+
+ Class<?> serviceInterface = this.getInterface();
+ Method meth = getMethod(serviceInterface, operationName.getLocalPart());
+
+ Object proxy = this.getServiceInstance();
+
+ return new SCAServerDataBindingCallback(opInfo, inout, meth, proxy, typeHelper);
+ }
+
+ protected Method getMethod(Class<?> serviceInterface, String operationName) {
+ // Note: this doesn't support overloaded operations
+ Method[] methods = serviceInterface.getMethods();
+ for (Method m : methods) {
+ if (m.getName().equals(operationName)) {
+ return m;
+ }
+ // tolerate WSDL with capatalized operation name
+ StringBuilder sb = new StringBuilder(operationName);
+ sb.setCharAt(0, Character.toLowerCase(sb.charAt(0)));
+ if (m.getName().equals(sb.toString())) {
+ return m;
+ }
+ }
+ throw new BuilderConfigException("no operation named " + operationName
+ + " found on service interface: " + serviceInterface.getName());
+ }
+
+ public DataBindingCallback getFaultDataBindingCallback(ObjectMessageContext objContext) {
+ // REVISIT - what to do about faults
+ return null;
+ }
+
+ public Map<QName, ? extends DataBindingCallback> getOperations() {
+ return opMap;
+ }
+
+ public SOAPBinding.Style getStyle() {
+ return wsdlCache.getStyle();
+ }
+
+ public DataBindingCallback.Mode getServiceMode() {
+ return DataBindingCallback.Mode.PARTS;
+ }
+
+ public WebServiceProvider getWebServiceProvider() {
+ //not needed I think
+ return null;
+ }
+
+ public Executor getExecutor() {
+ //Let the transport handle it (or it goes to the Bus default wq
+ //if the transport cannot handle it
+ return null;
+ }
+
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/CeltixServiceInitException.java b/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/CeltixServiceInitException.java
new file mode 100644
index 0000000000..4eca4a3bd1
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/CeltixServiceInitException.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 org.apache.tuscany.binding.celtix;
+
+import org.apache.tuscany.spi.CoreRuntimeException;
+
+/**
+ * Denotes an exception starting a {@link CeltixService} instance
+ *
+ * @version $Rev$ $Date$
+ */
+public class CeltixServiceInitException extends CoreRuntimeException {
+ public CeltixServiceInitException() {
+ }
+
+ public CeltixServiceInitException(String message) {
+ super(message);
+ }
+
+ public CeltixServiceInitException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public CeltixServiceInitException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/InvokerCreationException.java b/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/InvokerCreationException.java
new file mode 100644
index 0000000000..e08a3193d8
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/InvokerCreationException.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 org.apache.tuscany.binding.celtix;
+
+import org.apache.tuscany.spi.builder.BuilderException;
+
+/**
+ * Thrown when an error is encountered creating a {@link CeltixInvoker}
+ *
+ * @version $Rev$ $Date$
+ */
+public class InvokerCreationException extends BuilderException {
+ public InvokerCreationException() {
+ }
+
+ public InvokerCreationException(String message) {
+ super(message);
+ }
+
+ public InvokerCreationException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public InvokerCreationException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/TuscanyWSDLManager.java b/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/TuscanyWSDLManager.java
new file mode 100644
index 0000000000..18efe80da5
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/TuscanyWSDLManager.java
@@ -0,0 +1,89 @@
+/*
+ * 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.binding.celtix;
+
+import java.io.IOException;
+import java.net.URL;
+import javax.wsdl.Definition;
+import javax.wsdl.WSDLException;
+import javax.wsdl.extensions.ExtensionRegistry;
+import javax.wsdl.factory.WSDLFactory;
+
+import org.w3c.dom.Element;
+import org.apache.tuscany.idl.wsdl.WSDLDefinitionRegistry;
+
+import org.objectweb.celtix.wsdl.WSDLManager;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class TuscanyWSDLManager implements WSDLManager {
+ WSDLDefinitionRegistry wsdlDefinitionRegistry;
+
+ public TuscanyWSDLManager(WSDLDefinitionRegistry w) {
+ wsdlDefinitionRegistry = w;
+ }
+
+ public WSDLFactory getWSDLFactory() {
+ //Not supported
+ return null;
+ }
+
+ public ExtensionRegistry getExtenstionRegistry() {
+ return wsdlDefinitionRegistry.getExtensionRegistry();
+ }
+
+ public Definition getDefinition(URL url) throws WSDLException {
+ try {
+ return wsdlDefinitionRegistry.loadDefinition(null, url);
+ } catch (IOException e) {
+ //FIXME
+ throw new WSDLException("", "", e);
+ }
+ }
+
+ public Definition getDefinition(String url) throws WSDLException {
+ try {
+ //The namespace is the wsdl targetNamesapce, it is only used
+ //when the wsdl is created into cache. we are ok here to set it to null.
+ //FIXME pass the current ResourceLoader
+ return wsdlDefinitionRegistry.loadDefinition(null, new URL(url));
+ } catch (IOException e) {
+ throw new WSDLException(WSDLException.CONFIGURATION_ERROR, e.getMessage());
+ }
+ }
+
+ public Definition getDefinition(Element el) throws WSDLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public Definition getDefinition(Class<?> sei) throws WSDLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void addDefinition(Object key, Definition wsdl) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void shutdown() {
+ }
+
+
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/WebServiceBinding.java b/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/WebServiceBinding.java
new file mode 100644
index 0000000000..49df9a6e28
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/WebServiceBinding.java
@@ -0,0 +1,90 @@
+/*
+ * 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.binding.celtix;
+
+import javax.wsdl.Definition;
+import javax.wsdl.Port;
+import javax.wsdl.Service;
+
+import org.apache.tuscany.idl.wsdl.WSDLDefinitionRegistry;
+import org.apache.tuscany.spi.model.Binding;
+
+/**
+ * Represents a Celtix binding configuration in an assembly
+ *
+ * @version $Rev$ $Date$
+ */
+public class WebServiceBinding extends Binding {
+
+ private Definition definition;
+ private Port port;
+ private Service service;
+ //private String portURI;
+ private String uri;
+ //We have to use WebServiceBinding to pass WSDLDefinitionRegistry to BindingBuilder
+ private WSDLDefinitionRegistry wsdlDefinitionRegistry;
+
+ public WebServiceBinding(Definition definition, Port port, String uri, String portURI, Service service) {
+ this.definition = definition;
+ this.port = port;
+ this.uri = uri;
+ //this.portURI = portURI;
+ this.service = service;
+ }
+
+ public Port getWSDLPort() {
+ return port;
+ }
+
+ public Service getWSDLService() {
+ return service;
+ }
+
+ public void setWSDLPort(Port value) {
+ port = value;
+ }
+
+ public Definition getWSDLDefinition() {
+ return definition;
+ }
+
+ public void setWSDLDefinition(Definition def) {
+ definition = def;
+ }
+
+ public WSDLDefinitionRegistry getWSDLDefinitionRegistry() {
+ return wsdlDefinitionRegistry;
+ }
+
+ public void setWSDLDefinitionRegistry(WSDLDefinitionRegistry theWsdlDefinitionRegistry) {
+ wsdlDefinitionRegistry = theWsdlDefinitionRegistry;
+ }
+
+// public void setPortURI(String uri) {
+// portURI = uri;
+// }
+
+ public String getURI() {
+ return uri;
+ }
+
+ public void setURI(String theUri) {
+ this.uri = theUri;
+ }
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/WebServiceBindingLoader.java b/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/WebServiceBindingLoader.java
new file mode 100644
index 0000000000..5b11d02931
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/WebServiceBindingLoader.java
@@ -0,0 +1,195 @@
+/*
+ * 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.binding.celtix;
+
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.List;
+import javax.wsdl.Definition;
+import javax.wsdl.Port;
+import javax.wsdl.Service;
+import javax.wsdl.WSDLException;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLReader;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.xml.sax.InputSource;
+import static org.osoa.sca.Version.XML_NAMESPACE_1_0;
+import org.osoa.sca.annotations.Constructor;
+import org.osoa.sca.annotations.Scope;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.LoaderExtension;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.loader.LoaderRegistry;
+
+import org.apache.tuscany.idl.wsdl.WSDLDefinitionRegistry;
+import org.apache.tuscany.idl.wsdl.WSDLDefinitionRegistryImpl;
+import org.apache.tuscany.idl.wsdl.WSDLDefinitionRegistryImpl.Monitor;
+
+/**
+ * Parses a <code>WebServiceBinding</code> entry in an assembly XML file
+ *
+ * @version $Rev$ $Date$
+ */
+@Scope("MODULE")
+public class WebServiceBindingLoader extends LoaderExtension<WebServiceBinding> {
+ public static final QName BINDING_WS = new QName(XML_NAMESPACE_1_0, "binding.ws");
+
+ protected WSDLDefinitionRegistry wsdlRegistry;
+
+ @Constructor({"registry"})
+ public WebServiceBindingLoader(@Autowire LoaderRegistry registry) {
+ super(registry);
+
+ //FIXME: this is a hack, WSDLDefinitionRegistry should not be created here
+ if (wsdlRegistry == null) {
+ try {
+ wsdlRegistry = new WSDLDefinitionRegistryImpl();
+ Monitor monitor = new Monitor() {
+ public void readingWSDL(String namespace, URL location) {
+ }
+
+ public void cachingDefinition(String namespace, URL location) {
+ }
+ };
+
+ ((WSDLDefinitionRegistryImpl) wsdlRegistry).setMonitor(monitor);
+ } catch (javax.wsdl.WSDLException e) {
+ //do nothing
+ }
+ }
+ }
+
+ public QName getXMLType() {
+ return BINDING_WS;
+ }
+
+ public WebServiceBinding load(CompositeComponent parent,
+ XMLStreamReader reader,
+ DeploymentContext deploymentContext)
+ throws XMLStreamException, LoaderException {
+ // not sure what uri was here ? String uri = reader.getAttributeValue(null, "uri");
+ String uri = null;
+ String endpointAttribute = reader.getAttributeValue(null, "endpoint");
+ //String portURI = reader.getAttributeValue(null, "port");
+ String wsdlLocation = reader.getAttributeValue(null, "location");
+ try {
+ return createBinding(uri, endpointAttribute, wsdlLocation, deploymentContext);
+ } catch (Exception e) {
+
+ throw new LoaderException(e);
+ }
+ }
+
+ private WebServiceBinding createBinding(String port, String portURI, String wsdlLocation,
+ DeploymentContext deploymentContext)
+ throws WSDLException, IOException {
+ List<Definition> definitions = null;
+ // FIXME wsdlRegistry.getDefinitionsForNamespace(portNamespace,
+ // resourceLoader);
+ // Get the WSDL port namespace and name
+ if (port == null && portURI != null) {
+ int h = portURI.indexOf('#');
+ String portNamespace = portURI.substring(0, h);
+ String serviceName;
+ String portName;
+
+ String fragment = portURI.substring(h + 1);
+ if (fragment.startsWith("wsdl.endpoint(") && fragment.endsWith(")")) {
+ fragment = fragment.substring(14, fragment.length() - 1);
+ int slash = fragment.indexOf('/');
+ if (slash != -1) {
+ serviceName = fragment.substring(0, slash);
+ portName = fragment.substring(slash + 1);
+ } else {
+ serviceName = null;
+ portName = fragment;
+ }
+ } else {
+ serviceName = null;
+ portName = fragment;
+ }
+
+ // FIXME need to find out how to get wsdl and what context to use --- terrible hack attack!
+ // URL wsdlurl = Thread.currentThread().getContextClassLoader().getResource(wsdlLocation);
+ if (null == wsdlLocation) {
+ throw new RuntimeException("Failed to determin wsdl location on binding. "
+ + "Try specifying 'location' attribute on binding.");
+ }
+ URL wsdlurl = deploymentContext.getClassLoader().getResource(wsdlLocation);
+ if (wsdlurl == null) {
+ throw new RuntimeException("Failed to load wsdl from '" + wsdlLocation + "'");
+ }
+
+ WSDLFactory factory = WSDLFactory.newInstance();
+ WSDLReader reader = factory.newWSDLReader();
+ reader.setFeature("javax.wsdl.verbose", false);
+ InputSource input = new InputSource(wsdlurl.openStream());
+ Definition wsdlDef = reader.readWSDL(wsdlurl.toString(), input);
+ definitions = new LinkedList<Definition>();
+ definitions.add(wsdlDef);
+ // FIXME all the above needs to better addressed.
+
+ //FIXME: if a global wsdl cached is used, we need to do a registration here
+ String namespace = wsdlDef.getTargetNamespace();
+ wsdlRegistry.loadDefinition(namespace, wsdlurl);
+
+ Definition definition = null;
+ Port thePort = null;
+ Service service = null;
+ for (Definition def : definitions) {
+
+ // Find the port with the given name
+ for (Service serv : (Collection<Service>) def.getServices().values()) {
+ QName sqn = serv.getQName();
+ if (serviceName != null
+ && !serviceName.equals(sqn.getLocalPart())) {
+ continue;
+ }
+
+ Port p = serv.getPort(portName);
+ if (p != null) {
+ service = serv;
+ definition = def;
+ thePort = p;
+ break;
+ }
+ }
+ }
+ if (thePort == null) {
+ throw new IllegalArgumentException("Cannot find WSDL port " + portURI);
+
+ }
+ WebServiceBinding wsBinding = new WebServiceBinding(definition, thePort, port, portURI, service);
+ wsBinding.setWSDLDefinitionRegistry(wsdlRegistry);
+ return wsBinding;
+ }
+ // FIXME - return a broken binding for now
+ return new WebServiceBinding(null, null, null, portURI, null);
+
+ }
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/io/NodeDataReader.java b/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/io/NodeDataReader.java
new file mode 100644
index 0000000000..7a14ab33fc
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/io/NodeDataReader.java
@@ -0,0 +1,205 @@
+/*
+ * 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.binding.celtix.io;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.util.List;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+import org.w3c.dom.Node;
+import org.w3c.dom.bootstrap.DOMImplementationRegistry;
+import static org.w3c.dom.bootstrap.DOMImplementationRegistry.PROPERTY;
+import org.w3c.dom.ls.DOMImplementationLS;
+import org.w3c.dom.ls.LSOutput;
+import org.w3c.dom.ls.LSSerializer;
+
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.model.DataType;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.Property;
+import commonj.sdo.Type;
+import commonj.sdo.helper.TypeHelper;
+import commonj.sdo.helper.XMLDocument;
+
+import org.apache.tuscany.core.databinding.impl.TransformationContextImpl;
+import org.apache.tuscany.databinding.sdo.XMLStreamReader2XMLDocument;
+import org.objectweb.celtix.bindings.DataReader;
+import org.objectweb.celtix.context.ObjectMessageContext;
+
+public class NodeDataReader implements DataReader<Node> {
+
+ private SCADataBindingCallback callback;
+
+ public NodeDataReader(SCADataBindingCallback cb) {
+ callback = cb;
+ }
+
+ public Object read(int idx, Node input) {
+ return read(null, idx, input);
+ }
+
+ public Object read(QName name, int idx, Node input) {
+ try {
+ InputStream in = getNodeStream(input);
+ XMLInputFactory staxFactory = XMLInputFactory.newInstance();
+ XMLStreamReader reader = staxFactory.createXMLStreamReader(in);
+
+ XMLStreamReader2XMLDocument transformer = new XMLStreamReader2XMLDocument();
+ TransformationContext context = new TransformationContextImpl();
+ DataType<QName> binding = new DataType<QName>(DataObject.class, null);
+ binding.setMetadata(TypeHelper.class.getName(), callback.getTypeHelper());
+ context.setTargetDataType(binding);
+ XMLDocument document = transformer.transform(reader, context);
+
+ boolean isWrapped = false;
+ return toObjects(document, isWrapped);
+ } catch (Exception e) {
+ //REVISIT: better handling of exceptions
+ }
+ return null;
+ }
+
+ public void readWrapper(ObjectMessageContext objCtx, boolean isOutBound, Node input) {
+ try {
+ QName wrapperName;
+ if (isOutBound) {
+ wrapperName = callback.getOperationInfo().getResponseWrapperQName();
+ } else {
+ wrapperName = callback.getOperationInfo().getRequestWrapperQName();
+ }
+
+ Node nd = input.getFirstChild();
+ while (nd != null
+ && !wrapperName.getNamespaceURI().equals(nd.getNamespaceURI())
+ && !wrapperName.getLocalPart().equals(nd.getLocalName())) {
+ nd = nd.getNextSibling();
+ }
+
+ //REVISIT - This is SUCH a HACK. This needs to be done with StAX or something
+ //a bit better than streaming and reparsing
+ InputStream in = getNodeStream(nd);
+ XMLInputFactory staxFactory = XMLInputFactory.newInstance(
+ "javax.xml.stream.XMLInputFactory", getClass().getClassLoader());
+ XMLStreamReader reader = staxFactory.createXMLStreamReader(in);
+
+ XMLStreamReader2XMLDocument transformer = new XMLStreamReader2XMLDocument();
+ TransformationContext context = new TransformationContextImpl();
+ DataType<QName> binding = new DataType<QName>(DataObject.class, null);
+ binding.setMetadata(TypeHelper.class.getName(), callback.getTypeHelper());
+ context.setTargetDataType(binding);
+ XMLDocument document = transformer.transform(reader, context);
+
+ //boolean isWrapped = true;
+ Object[] objects = toObjects(document, true);
+
+ if (callback.hasInOut()) {
+ //REVISIT - inOuts
+ } else {
+ if (isOutBound) {
+ objCtx.setReturn(objects[0]);
+ } else {
+ objCtx.setMessageObjects(objects);
+ }
+ }
+ } catch (Exception e) {
+ //REVISIT: better handling of exceptions
+ }
+ }
+
+ /**
+ * Convert a typed DataObject to Java objects
+ *
+ * @param document
+ * @param isWrapped
+ * @return the array of Objects from the DataObject
+ */
+ public static Object[] toObjects(XMLDocument document, boolean isWrapped) {
+ DataObject dataObject = document.getRootObject();
+ if (isWrapped) {
+ List ips = dataObject.getInstanceProperties();
+ Object[] os = new Object[ips.size()];
+ for (int i = 0; i < ips.size(); i++) {
+ os[i] = dataObject.get((Property) ips.get(i));
+ }
+ return os;
+ } else {
+ Object object = dataObject;
+ Type type = dataObject.getType();
+ if (type.isSequenced()) {
+ object = dataObject.getSequence().getValue(0);
+ }
+ return new Object[]{object};
+ }
+ }
+
+ byte[] getNodeBytes(Node node)
+ throws ClassCastException, ClassNotFoundException, InstantiationException, IllegalAccessException {
+
+ //This is also a hack, the JDK should already have this set, but it doesn't
+ DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
+ if (registry == null) {
+ System.setProperty(PROPERTY, "com.sun.org.apache.xerces.internal.dom.DOMImplementationSourceImpl");
+ registry = DOMImplementationRegistry.newInstance();
+ }
+ DOMImplementationLS impl = (DOMImplementationLS) registry.getDOMImplementation("LS");
+ if (impl == null) {
+ System.setProperty(PROPERTY, "com.sun.org.apache.xerces.internal.dom.DOMImplementationSourceImpl");
+ registry = DOMImplementationRegistry.newInstance();
+ impl = (DOMImplementationLS) registry.getDOMImplementation("LS");
+ }
+ LSOutput output = impl.createLSOutput();
+ ByteArrayOutputStream bout = new ByteArrayOutputStream();
+ output.setByteStream(bout);
+ LSSerializer writer = impl.createLSSerializer();
+ writer.write(node, output);
+
+ return bout.toByteArray();
+ }
+
+ InputStream getNodeStream(Node node)
+ throws ClassCastException, ClassNotFoundException,
+ InstantiationException, IllegalAccessException {
+
+ DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
+ if (registry == null) {
+ //This is also a hack, the JDK should already have this set, but it doesn't
+ System.setProperty(PROPERTY, "com.sun.org.apache.xerces.internal.dom.DOMImplementationSourceImpl");
+ registry = DOMImplementationRegistry.newInstance();
+ }
+ DOMImplementationLS impl = (DOMImplementationLS) registry.getDOMImplementation("LS");
+ if (impl == null) {
+ System.setProperty(PROPERTY, "com.sun.org.apache.xerces.internal.dom.DOMImplementationSourceImpl");
+ registry = DOMImplementationRegistry.newInstance();
+ impl = (DOMImplementationLS) registry.getDOMImplementation("LS");
+ }
+ LSOutput output = impl.createLSOutput();
+ RawByteArrayOutputStream bout = new RawByteArrayOutputStream();
+ output.setByteStream(bout);
+ LSSerializer writer = impl.createLSSerializer();
+ writer.write(node, output);
+
+ return new ByteArrayInputStream(bout.getBytes(), 0, bout.size());
+ }
+
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/io/NodeDataWriter.java b/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/io/NodeDataWriter.java
new file mode 100644
index 0000000000..d870cafa87
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/io/NodeDataWriter.java
@@ -0,0 +1,322 @@
+/*
+ * 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.binding.celtix.io;
+
+import java.util.List;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+import org.apache.tuscany.spi.wire.InvocationRuntimeException;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.Property;
+import commonj.sdo.Type;
+import commonj.sdo.helper.DataFactory;
+import commonj.sdo.helper.TypeHelper;
+import commonj.sdo.helper.XMLDocument;
+import commonj.sdo.helper.XMLHelper;
+import commonj.sdo.helper.XSDHelper;
+import org.apache.tuscany.databinding.sdo.XMLDocument2XMLStreamReader;
+import org.apache.tuscany.sdo.util.SDOUtil;
+import org.objectweb.celtix.bindings.DataWriter;
+import org.objectweb.celtix.context.ObjectMessageContext;
+
+public class NodeDataWriter implements DataWriter<Node> {
+ private static final String XML_NS = "http://www.w3.org/2000/xmlns/";
+ private SCADataBindingCallback callback;
+
+ public NodeDataWriter(SCADataBindingCallback cb) {
+ callback = cb;
+ }
+
+ public void write(Object obj, Node output) {
+ write(obj, null, output);
+ }
+
+ public void write(Object obj, QName elName, Node output) {
+ boolean isWrapped = false;
+
+ XMLDocument document = toXMLDocument(callback.getTypeHelper(), new Object[]{obj}, elName, isWrapped);
+ // HACK: [rfeng] We should use the transformer in an interceptor
+ XMLDocument2XMLStreamReader transformer = new XMLDocument2XMLStreamReader();
+ XMLStreamReader reader = transformer.transform(document, null);
+
+ try {
+ //CeltixFire supports Stax, we should not need to do following anymore.
+ readDocElements(output, reader, true, null);
+ } catch (XMLStreamException e) {
+ throw new InvocationRuntimeException(e.getMessage());
+ }
+ }
+
+ public void writeWrapper(ObjectMessageContext objCtx, boolean isOutbound, Node output) {
+ boolean isWrapped = true;
+ QName wrapperName;
+ if (isOutbound) {
+ wrapperName = callback.getOperationInfo().getResponseWrapperQName();
+ } else {
+ wrapperName = callback.getOperationInfo().getRequestWrapperQName();
+ }
+
+ XMLDocument document = toXMLDocument(
+ callback.getTypeHelper(), objCtx.getMessageObjects(), wrapperName, isWrapped);
+ // HACK: [rfeng] We should use the transformer in an interceptor
+ XMLDocument2XMLStreamReader transformer = new XMLDocument2XMLStreamReader();
+ XMLStreamReader reader = transformer.transform(document, null);
+
+ try {
+ readDocElements(output, reader, true, null);
+ } catch (XMLStreamException e) {
+ e.printStackTrace();
+ throw new InvocationRuntimeException(e.getMessage());
+ }
+ }
+/*
+ private DataObject toWrappedDataObject(TypeHelper typeHelper,
+ Object ret,
+ Object[] os,
+ QName typeQN) {
+ XSDHelper xsdHelper = new XSDHelperImpl(typeHelper);
+ Property property = xsdHelper.getGlobalProperty(typeQN.getNamespaceURI(),
+ typeQN.getLocalPart(), true);
+ DataObject dataObject = new DataFactoryImpl(typeHelper).create(property.getType());
+ List ips = dataObject.getInstanceProperties();
+ int offset = 0;
+ if (ret != null) {
+ dataObject.set(0, ret);
+ offset = 1;
+ }
+ for (int i = offset; i < ips.size(); i++) {
+ if (os[i - offset] instanceof Holder) {
+ Holder<?> holder = (Holder<?>)os[i - offset];
+ dataObject.set(i, holder.value);
+ } else {
+ dataObject.set(i, os[i - offset]);
+ }
+ }
+ return dataObject;
+ }
+*/
+
+ /**
+ * Convert objects to typed DataObject
+ *
+ * @param typeHelper
+ * @param os
+ * @param elementQName
+ * @param isWrapped
+ * @return the DataObject
+ */
+ private static XMLDocument toXMLDocument(TypeHelper typeHelper,
+ Object[] os,
+ QName elementQName,
+ boolean isWrapped) {
+ XSDHelper xsdHelper = SDOUtil.createXSDHelper(typeHelper);
+
+ Property property = xsdHelper.getGlobalProperty(
+ elementQName.getNamespaceURI(), elementQName.getLocalPart(), true);
+ if (null == property) {
+ throw new InvocationRuntimeException(
+ "Type '" + elementQName.toString() + "' not found in registered SDO types.");
+ }
+ DataObject dataObject;
+ if (isWrapped) {
+ DataFactory dataFactory = SDOUtil.createDataFactory(typeHelper);
+ dataObject = dataFactory.create(property.getType());
+ List ips = dataObject.getInstanceProperties();
+ for (int i = 0; i < ips.size(); i++) {
+ dataObject.set(i, os[i]);
+ }
+ } else {
+ Object value = os[0];
+ Type type = property.getType();
+ if (!type.isDataType()) {
+ dataObject = (DataObject) value;
+ } else {
+ dataObject = SDOUtil.createDataTypeWrapper(type, value);
+ }
+ }
+
+ XMLHelper xmlHelper = SDOUtil.createXMLHelper(typeHelper);
+ return xmlHelper.createDocument(dataObject, elementQName.getNamespaceURI(), elementQName.getLocalPart());
+
+ }
+
+ //REVISIT: We should not need to do following anymore with CeltixFire.
+ //As CeltixFire supports stax directly.
+
+ /**
+ * @param parent
+ * @param reader
+ * @param repairing
+ * @param stopAt: stop at the specified element
+ * @throws XMLStreamException
+ */
+ public static void readDocElements(Node parent, XMLStreamReader reader, boolean repairing, QName stopAt)
+ throws XMLStreamException {
+ Document doc = getDocument(parent);
+
+ int event = reader.getEventType();
+
+ while (reader.hasNext()) {
+ switch (event) {
+ case XMLStreamConstants.START_ELEMENT:
+ if (startElement(parent, reader, repairing, stopAt) == null) {
+ return;
+ }
+ if (parent instanceof Document && stopAt != null) {
+ if (reader.hasNext()) {
+ reader.next();
+ }
+ return;
+ }
+ break;
+ case XMLStreamConstants.END_ELEMENT:
+ return;
+ case XMLStreamConstants.NAMESPACE:
+ break;
+ case XMLStreamConstants.ATTRIBUTE:
+ break;
+ case XMLStreamConstants.CHARACTERS:
+ if (parent != null) {
+ parent.appendChild(doc.createTextNode(reader.getText()));
+ }
+
+ break;
+ case XMLStreamConstants.COMMENT:
+ if (parent != null) {
+ parent.appendChild(doc.createComment(reader.getText()));
+ }
+
+ break;
+ case XMLStreamConstants.CDATA:
+ parent.appendChild(doc.createCDATASection(reader.getText()));
+
+ break;
+ case XMLStreamConstants.PROCESSING_INSTRUCTION:
+ parent.appendChild(doc.createProcessingInstruction(reader.getPITarget(), reader.getPIData()));
+
+ break;
+ case XMLStreamConstants.ENTITY_REFERENCE:
+ parent.appendChild(doc.createProcessingInstruction(reader.getPITarget(), reader.getPIData()));
+
+ break;
+ default:
+ break;
+ }
+
+ if (reader.hasNext()) {
+ event = reader.next();
+ }
+ }
+ }
+
+ private static Document getDocument(Node parent) {
+ return (parent instanceof Document) ? (Document) parent : parent.getOwnerDocument();
+ }
+
+ /**
+ * @param parent
+ * @param reader
+ * @return
+ * @throws XMLStreamException
+ */
+ private static Element startElement(Node parent, XMLStreamReader reader, boolean repairing, QName stopAt)
+ throws XMLStreamException {
+ Document doc = getDocument(parent);
+
+ if (stopAt != null && stopAt.getNamespaceURI().equals(reader.getNamespaceURI())
+ && stopAt.getLocalPart().equals(reader.getLocalName())) {
+ return null;
+ }
+
+ Element e = doc.createElementNS(reader.getNamespaceURI(), reader.getLocalName());
+
+ if (reader.getPrefix() != null) {
+ e.setPrefix(reader.getPrefix());
+ }
+
+ parent.appendChild(e);
+
+ for (int ns = 0; ns < reader.getNamespaceCount(); ns++) {
+ String uri = reader.getNamespaceURI(ns);
+ String prefix = reader.getNamespacePrefix(ns);
+
+ declare(e, uri, prefix);
+ }
+
+ for (int att = 0; att < reader.getAttributeCount(); att++) {
+ String name = reader.getAttributeLocalName(att);
+ String prefix = reader.getAttributePrefix(att);
+ if (prefix != null && prefix.length() > 0) {
+ name = prefix + ":" + name;
+ }
+
+ Attr attr = doc.createAttributeNS(reader.getAttributeNamespace(att), name);
+ attr.setValue(reader.getAttributeValue(att));
+ e.setAttributeNode(attr);
+ }
+
+ reader.next();
+
+ readDocElements(e, reader, repairing, stopAt);
+
+ if (repairing && !isDeclared(e, reader.getNamespaceURI(), reader.getPrefix())) {
+ declare(e, reader.getNamespaceURI(), reader.getPrefix());
+ }
+
+ return e;
+ }
+
+ private static void declare(Element node, String uri, String prefix) {
+ if (prefix != null && prefix.length() > 0) {
+ node.setAttributeNS(XML_NS, "xmlns:" + prefix, uri);
+ } else {
+ if (uri != null /* && uri.length() > 0 */) {
+ node.setAttributeNS(XML_NS, "xmlns", uri);
+ }
+ }
+ }
+
+ private static boolean isDeclared(Element e, String namespaceURI, String prefix) {
+ Attr att;
+ if (prefix != null && prefix.length() > 0) {
+ att = e.getAttributeNodeNS(XML_NS, "xmlns:" + prefix);
+ } else {
+ att = e.getAttributeNode("xmlns");
+ }
+
+ if (att != null && att.getNodeValue().equals(namespaceURI)) {
+ return true;
+ }
+
+ if (e.getParentNode() instanceof Element) {
+ return isDeclared((Element) e.getParentNode(), namespaceURI, prefix);
+ }
+
+ return false;
+ }
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/io/RawByteArrayOutputStream.java b/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/io/RawByteArrayOutputStream.java
new file mode 100644
index 0000000000..057481041b
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/io/RawByteArrayOutputStream.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.binding.celtix.io;
+
+import java.io.ByteArrayOutputStream;
+
+/**
+ * Just to allow raw access to the byte[] to avoid a copy
+ */
+class RawByteArrayOutputStream extends ByteArrayOutputStream {
+ public byte[] getBytes() {
+ return buf;
+ }
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/io/SCADataBindingCallback.java b/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/io/SCADataBindingCallback.java
new file mode 100644
index 0000000000..47d130383f
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/io/SCADataBindingCallback.java
@@ -0,0 +1,83 @@
+/*
+ * 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.binding.celtix.io;
+
+import org.w3c.dom.Node;
+
+import commonj.sdo.helper.TypeHelper;
+import org.objectweb.celtix.bindings.DataReader;
+import org.objectweb.celtix.bindings.DataWriter;
+import org.objectweb.celtix.bus.bindings.AbstractWSDLOperationDataBindingCallback;
+import org.objectweb.celtix.bus.bindings.WSDLOperationInfo;
+import org.objectweb.celtix.context.ObjectMessageContext;
+
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class SCADataBindingCallback extends AbstractWSDLOperationDataBindingCallback {
+
+ protected boolean hasInOut;
+ protected TypeHelper typeHelper;
+
+ public SCADataBindingCallback(WSDLOperationInfo op, boolean inout, TypeHelper theTypeHelper) {
+ super(op);
+ this.hasInOut = inout;
+ this.typeHelper = theTypeHelper;
+ }
+
+ public boolean hasInOut() {
+ return hasInOut;
+ }
+
+ public Mode getMode() {
+ return Mode.PARTS;
+ }
+
+ public Class<?>[] getSupportedFormats() {
+ return new Class<?>[]{Node.class};
+ }
+
+ public TypeHelper getTypeHelper() {
+ return typeHelper;
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T> DataWriter<T> createWriter(Class<T> cls) {
+ if (cls == Node.class) {
+ return (DataWriter<T>) new NodeDataWriter(this);
+ }
+ return null;
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T> DataReader<T> createReader(Class<T> cls) {
+ if (cls == Node.class) {
+ return (DataReader<T>) new NodeDataReader(this);
+ }
+ //REVISIT - need to figure out what to do with Faults
+ return null;
+ }
+
+ public void initObjectContext(ObjectMessageContext octx) {
+ //REVISIT - is this even used?
+ }
+
+
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/io/SCAServerDataBindingCallback.java b/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/io/SCAServerDataBindingCallback.java
new file mode 100644
index 0000000000..db9c624bd4
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/java/org/apache/tuscany/binding/celtix/io/SCAServerDataBindingCallback.java
@@ -0,0 +1,69 @@
+/*
+ * 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.binding.celtix.io;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import commonj.sdo.helper.TypeHelper;
+
+import org.objectweb.celtix.bindings.ServerDataBindingCallback;
+import org.objectweb.celtix.bus.bindings.WSDLOperationInfo;
+import org.objectweb.celtix.context.ObjectMessageContext;
+
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class SCAServerDataBindingCallback extends SCADataBindingCallback
+ implements ServerDataBindingCallback {
+ Method method;
+ Object targetObject;
+
+ public SCAServerDataBindingCallback(WSDLOperationInfo op,
+ boolean inout,
+ Method meth,
+ Object target,
+ TypeHelper theTypeHelper) {
+ super(op, inout, theTypeHelper);
+ method = meth;
+ targetObject = target;
+ }
+
+
+ public void invoke(ObjectMessageContext octx) throws InvocationTargetException {
+ Object ret;
+ try {
+ ret = method.invoke(targetObject, octx.getMessageObjects());
+ } catch (RuntimeException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new InvocationTargetException(e);
+ }
+ octx.setReturn(ret);
+ }
+
+ public void initObjectContext(ObjectMessageContext octx) {
+ Object o[] = new Object[method.getParameterTypes().length];
+ //REVIST - holders?
+ octx.setMessageObjects(o);
+ }
+
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/resources/META-INF/sca/default.scdl b/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/resources/META-INF/sca/default.scdl
new file mode 100644
index 0000000000..b6a5334903
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/main/resources/META-INF/sca/default.scdl
@@ -0,0 +1,31 @@
+<?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:system="http://incubator.apache.org/tuscany/xmlns/system/1.0-incubator-M2"
+ name="org.apache.tuscany.binding.celtix.WebServiceBinding">
+
+ <component name="ws.implementationLoader">
+ <system:implementation.system class="org.apache.tuscany.binding.celtix.WebServiceBindingLoader" />
+ </component>
+
+ <component name="ws.componentBuilder">
+ <system:implementation.system class="org.apache.tuscany.binding.celtix.CeltixBindingBuilder" />
+ </component>
+
+</composite>
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/test/java/org/apache/tuscany/binding/celtix/BootstrapTestCase.java b/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/test/java/org/apache/tuscany/binding/celtix/BootstrapTestCase.java
new file mode 100644
index 0000000000..cba83a7792
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/test/java/org/apache/tuscany/binding/celtix/BootstrapTestCase.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.binding.celtix;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class BootstrapTestCase extends TestCase {
+
+ public void testReference() throws Exception {
+// BusServiceImpl busService = new BusServiceImpl();
+// WSDLDefinitionRegistry wsdlRegistry = new WSDLDefinitionRegistryImpl();
+// busService.setWsdlRegistry(wsdlRegistry);
+// busService.init();
+// CeltixReference reference = new CeltixReference("reference",);
+ }
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/test/java/org/apache/tuscany/binding/celtix/CeltixInvokerTestCase.java b/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/test/java/org/apache/tuscany/binding/celtix/CeltixInvokerTestCase.java
new file mode 100644
index 0000000000..5440fc22ce
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/test/java/org/apache/tuscany/binding/celtix/CeltixInvokerTestCase.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.binding.celtix;
+
+import java.net.URL;
+import javax.wsdl.Definition;
+import javax.wsdl.Port;
+import javax.wsdl.Service;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLReader;
+import javax.xml.namespace.QName;
+
+import org.xml.sax.InputSource;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.binding.celtix.io.SCADataBindingCallback;
+import org.easymock.classextension.EasyMock;
+import org.objectweb.celtix.Bus;
+import org.objectweb.celtix.bindings.BindingManager;
+import org.objectweb.celtix.bus.bindings.soap.SOAPBindingFactory;
+import org.objectweb.celtix.bus.bindings.soap.SOAPClientBinding;
+import org.objectweb.celtix.context.ObjectMessageContextImpl;
+import org.objectweb.celtix.ws.addressing.EndpointReferenceType;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class CeltixInvokerTestCase extends TestCase {
+
+ public void testProcessingInputWithoutInOut() throws Exception {
+ String wsdlLocation = "/wsdl/hello_world_doc_lit.wsdl";
+ String operationName = "greetMe";
+ ObjectMessageContextImpl inputCtx = new ObjectMessageContextImpl();
+ CeltixInvoker invoker = createCeltixInvoker(wsdlLocation,
+ operationName, inputCtx);
+
+ Object[] args = new Object[1];
+ args[0] = new String("hello");
+ invoker.invokeTarget(args);
+
+ // Check the input object after processing is correct
+ // Should be no change for input if only IN parameters involved
+ Object[] myrtn = (Object[]) inputCtx.getMessageObjects();
+
+ assertEquals("hello", myrtn[0]);
+ }
+
+ public void testProcessingInputWithInOut() throws Exception {
+ String wsdlLocation = "/wsdl/hello_world_doc_lit_inout.wsdl";
+ String operationName = "greetMe";
+ ObjectMessageContextImpl inputCtx = new ObjectMessageContextImpl();
+ CeltixInvoker invoker = createCeltixInvoker(wsdlLocation,
+ operationName, inputCtx);
+
+ Object[] args = new Object[1];
+ String inputvalue = new String("hello");
+ args[0] = inputvalue;
+ Object result = invoker.invokeTarget(args);
+
+ // Check the input object after processing is correct
+ // input should be wrapped as Holder type if it is INOUT parameter
+ Object[] myrtn = (Object[]) inputCtx.getMessageObjects();
+
+ //FIXME: this does not work for the wrapped doc/lit case due to a bug in Celtix
+ //assertTrue("input is not Holder type", myrtn[0] instanceof Holder);
+ }
+
+ // NOTE: For convenience this method presumes the soap service name is
+ // SOAPService and port name is SoapPort
+ private CeltixInvoker createCeltixInvoker(String wsdlLocation,
+ String operationName,
+ ObjectMessageContextImpl inputCtx)
+ throws Exception {
+
+ // Make following call to return a mocked SOAPClientBinding:
+ // bus.getBindingManager().getBindingFactory(bindingId).createClientBinding(reference)
+ SOAPClientBinding clientBinding = EasyMock
+ .createMock(SOAPClientBinding.class);
+ clientBinding.createObjectContext();
+ EasyMock.expectLastCall().andReturn(inputCtx);
+ clientBinding.invoke(EasyMock.isA(ObjectMessageContextImpl.class),
+ EasyMock.isA(SCADataBindingCallback.class));
+ EasyMock.expectLastCall().andReturn(new ObjectMessageContextImpl());
+ EasyMock.replay(clientBinding);
+
+ SOAPBindingFactory bindingFactory = EasyMock.createNiceMock(SOAPBindingFactory.class);
+ bindingFactory.createClientBinding(EasyMock.isA(EndpointReferenceType.class));
+ EasyMock.expectLastCall().andReturn(clientBinding);
+ EasyMock.replay(bindingFactory);
+
+ BindingManager bindingManager = EasyMock.createNiceMock(BindingManager.class);
+ String bindingId = "http://schemas.xmlsoap.org/wsdl/soap/";
+ bindingManager.getBindingFactory(bindingId);
+ EasyMock.expectLastCall().andReturn(bindingFactory);
+
+ Bus bus = EasyMock.createNiceMock(Bus.class);
+ bus.getBindingManager();
+ EasyMock.expectLastCall().andReturn(bindingManager);
+ EasyMock.replay(bindingManager);
+ EasyMock.replay(bus);
+
+ // Create WSDL Definition
+ URL url = getClass().getResource(wsdlLocation);
+ assertNotNull("Could not find wsdl " + url.toString(), url);
+
+ WSDLFactory factory = WSDLFactory.newInstance();
+ WSDLReader reader = factory.newWSDLReader();
+ reader.setFeature("javax.wsdl.verbose", false);
+ InputSource input = new InputSource(url.openStream());
+ Definition wsdlDef = reader.readWSDL(url.toString(), input);
+ QName qName = new QName("http://objectweb.org/hello_world_soap_http", "SOAPService");
+ Service wsdlService = wsdlDef.getService(qName);
+ Port port = wsdlService.getPort("SoapPort");
+
+ return new CeltixInvoker(operationName, bus, port, wsdlService, wsdlDef, null);
+ }
+
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/test/java/org/apache/tuscany/binding/celtix/CeltixServiceTestCase.java b/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/test/java/org/apache/tuscany/binding/celtix/CeltixServiceTestCase.java
new file mode 100644
index 0000000000..1a66aa4eb5
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/test/java/org/apache/tuscany/binding/celtix/CeltixServiceTestCase.java
@@ -0,0 +1,129 @@
+/*
+ * 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.binding.celtix;
+
+import java.net.URL;
+import javax.wsdl.Definition;
+import javax.wsdl.Port;
+import javax.wsdl.Service;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLReader;
+import javax.xml.namespace.QName;
+
+import org.xml.sax.InputSource;
+
+import org.apache.tuscany.spi.idl.java.JavaServiceContract;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.WireService;
+
+import junit.framework.TestCase;
+import org.easymock.classextension.EasyMock;
+import org.objectweb.celtix.Bus;
+import org.objectweb.celtix.bindings.BindingManager;
+import static org.objectweb.celtix.bindings.DataBindingCallback.Mode.PARTS;
+import org.objectweb.celtix.bindings.ServerBindingEndpointCallback;
+import org.objectweb.celtix.bindings.ServerDataBindingCallback;
+import org.objectweb.celtix.bus.bindings.soap.SOAPBindingFactory;
+import org.objectweb.celtix.bus.bindings.soap.SOAPServerBinding;
+import org.objectweb.celtix.context.ObjectMessageContextImpl;
+import org.objectweb.celtix.ws.addressing.EndpointReferenceType;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class CeltixServiceTestCase extends TestCase {
+
+ public void testGetDataBindingCallback() throws Exception {
+ CeltixService celtixService = createCeltixService();
+
+ QName operationName = new QName("greetMe");
+ ObjectMessageContextImpl ctx = new ObjectMessageContextImpl();
+ ctx.setMessageObjects(new String[]{"Celtix"});
+ ServerDataBindingCallback callback1 = celtixService.getDataBindingCallback(operationName, ctx, PARTS);
+ assertNotNull(callback1);
+
+ callback1.invoke(ctx);
+ Object rtn = (String) ctx.getReturn();
+ assertEquals("Hello Celtix", rtn);
+
+ }
+
+ private CeltixService createCeltixService() throws Exception {
+ //Make following call to return a mocked SOAPClientBinding:
+ //bus.getBindingManager().getBindingFactory(bindingId).createClientBinding(reference)
+ SOAPServerBinding serverBinding = EasyMock.createMock(SOAPServerBinding.class);
+ serverBinding.activate();
+ EasyMock.replay(serverBinding);
+
+ //ServerBindingEndpointCallback callback = EasyMock.createNiceMock(ServerBindingEndpointCallback.class);
+
+ SOAPBindingFactory bindingFactory = EasyMock.createNiceMock(SOAPBindingFactory.class);
+ bindingFactory.createServerBinding(EasyMock.isA(EndpointReferenceType.class),
+ EasyMock.isA(ServerBindingEndpointCallback.class));
+ EasyMock.expectLastCall().andReturn(serverBinding);
+ EasyMock.replay(bindingFactory);
+
+ BindingManager bindingManager = EasyMock.createNiceMock(BindingManager.class);
+ String bindingId = "http://schemas.xmlsoap.org/wsdl/soap/";
+ bindingManager.getBindingFactory(bindingId);
+ EasyMock.expectLastCall().andReturn(bindingFactory);
+
+ Bus bus = EasyMock.createNiceMock(Bus.class);
+ bus.getBindingManager();
+ EasyMock.expectLastCall().andReturn(bindingManager);
+ EasyMock.replay(bindingManager);
+ EasyMock.replay(bus);
+
+ //Create WSDL Definition
+ String wsdlLocation = "/wsdl/hello_world_doc_lit.wsdl";
+ URL url = getClass().getResource(wsdlLocation);
+ assertNotNull("Could not find wsdl " + url.toString(), url);
+
+ WSDLFactory factory = WSDLFactory.newInstance();
+ WSDLReader reader = factory.newWSDLReader();
+ reader.setFeature("javax.wsdl.verbose", false);
+ InputSource input = new InputSource(url.openStream());
+ Definition wsdlDef = reader.readWSDL(url.toString(), input);
+ Service wsdlService = wsdlDef.getService(new QName("http://objectweb.org/hello_world_soap_http",
+ "SOAPService"));
+ Port port = wsdlService.getPort("SoapPort");
+
+ WebServiceBinding wsBinding = new WebServiceBinding(wsdlDef, port, "uri", "portURI", wsdlService);
+
+ //Create mocked InboundWire, for ServiceExtension.getInterface()
+ InboundWire inboundWire = EasyMock.createNiceMock(InboundWire.class);
+ JavaServiceContract contract = new JavaServiceContract(Greeter.class);
+ EasyMock.expect(inboundWire.getServiceContract()).andReturn(contract).anyTimes();
+ EasyMock.replay(inboundWire);
+
+ //Create mocked WireService, for ServiceExtension.getServiceInstance()
+ WireService wireService = EasyMock.createNiceMock(WireService.class);
+ wireService.createProxy(EasyMock.isA(InboundWire.class));
+ EasyMock.expectLastCall().andReturn(new GreeterImpl()).anyTimes();
+ EasyMock.replay(wireService);
+
+ CeltixService celtixService = new CeltixService("name", Greeter.class, null, wireService, wsBinding, bus, null);
+ //Not sure how InboundWire is set to CeltixService, is the following way correct?
+ celtixService.setInboundWire(inboundWire);
+ celtixService.start();
+
+ return celtixService;
+ }
+
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/test/java/org/apache/tuscany/binding/celtix/Greeter.java b/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/test/java/org/apache/tuscany/binding/celtix/Greeter.java
new file mode 100644
index 0000000000..56de472774
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/test/java/org/apache/tuscany/binding/celtix/Greeter.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.binding.celtix;
+
+public interface Greeter {
+ java.lang.String sayHi();
+
+ java.lang.String greetMe(
+ java.lang.String requestType
+ );
+
+ void greetMeOneWay(
+ java.lang.String requestType
+ );
+
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/test/java/org/apache/tuscany/binding/celtix/GreeterImpl.java b/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/test/java/org/apache/tuscany/binding/celtix/GreeterImpl.java
new file mode 100644
index 0000000000..38237ad81a
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/test/java/org/apache/tuscany/binding/celtix/GreeterImpl.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.binding.celtix;
+
+public class GreeterImpl implements Greeter {
+ public java.lang.String sayHi() {
+ return "sayHi";
+ }
+
+ public java.lang.String greetMe(String requestType) {
+ return "Hello " + requestType;
+ }
+
+ public void greetMeOneWay(String requestType) {
+ }
+
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/test/resources/wsdl/hello_world.wsdl b/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/test/resources/wsdl/hello_world.wsdl
new file mode 100644
index 0000000000..e8767988f3
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/test/resources/wsdl/hello_world.wsdl
@@ -0,0 +1,181 @@
+<?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.
+-->
+<wsdl:definitions name="HelloWorld" targetNamespace="http://objectweb.org/hello_world_soap_http"
+ xmlns="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:tns="http://objectweb.org/hello_world_soap_http"
+ xmlns:x1="http://objectweb.org/hello_world_soap_http/types"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <wsdl:types>
+ <schema targetNamespace="http://objectweb.org/hello_world_soap_http/types"
+ xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:tns="http://objectweb.org/hello_world_soap_http/types"
+ elementFormDefault="qualified">
+ <simpleType name="MyStringType">
+ <restriction base="string">
+ <maxLength value="30" />
+ </restriction>
+ </simpleType>
+
+ <element name="sayHi">
+ <complexType/>
+ </element>
+ <element name="sayHiResponse">
+ <complexType>
+ <sequence>
+ <element name="responseType" type="string"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="greetMe">
+ <complexType>
+ <sequence>
+ <element name="requestType" type="tns:MyStringType"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="greetMeResponse">
+ <complexType>
+ <sequence>
+ <element name="responseType" type="string"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="greetMeOneWay">
+ <complexType>
+ <sequence>
+ <element name="requestType" type="string"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="pingMe">
+ <complexType/>
+ </element>
+ <element name="pingMeResponse">
+ <complexType/>
+ </element>
+ <element name="faultDetail">
+ <complexType>
+ <sequence>
+ <element name="minor" type="short"/>
+ <element name="major" type="short"/>
+ </sequence>
+ </complexType>
+ </element>
+ </schema>
+ </wsdl:types>
+ <wsdl:message name="sayHiRequest">
+ <wsdl:part element="x1:sayHi" name="in"/>
+ </wsdl:message>
+ <wsdl:message name="sayHiResponse">
+ <wsdl:part element="x1:sayHiResponse" name="out"/>
+ </wsdl:message>
+ <wsdl:message name="greetMeRequest">
+ <wsdl:part element="x1:greetMe" name="in"/>
+ </wsdl:message>
+ <wsdl:message name="greetMeResponse">
+ <wsdl:part element="x1:greetMeResponse" name="out"/>
+ </wsdl:message>
+ <wsdl:message name="greetMeOneWayRequest">
+ <wsdl:part element="x1:greetMeOneWay" name="in"/>
+ </wsdl:message>
+ <wsdl:message name="pingMeRequest">
+ <wsdl:part name="in" element="x1:pingMe"/>
+ </wsdl:message>
+ <wsdl:message name="pingMeResponse">
+ <wsdl:part name="out" element="x1:pingMeResponse"/>
+ </wsdl:message>
+ <wsdl:message name="pingMeFault">
+ <wsdl:part name="faultDetail" element="x1:faultDetail"/>
+ </wsdl:message>
+
+ <wsdl:portType name="Greeter">
+ <wsdl:operation name="sayHi">
+ <wsdl:input message="tns:sayHiRequest" name="sayHiRequest"/>
+ <wsdl:output message="tns:sayHiResponse" name="sayHiResponse"/>
+ </wsdl:operation>
+
+ <wsdl:operation name="greetMe">
+ <wsdl:input message="tns:greetMeRequest" name="greetMeRequest"/>
+ <wsdl:output message="tns:greetMeResponse" name="greetMeResponse"/>
+ </wsdl:operation>
+
+ <wsdl:operation name="greetMeOneWay">
+ <wsdl:input message="tns:greetMeOneWayRequest" name="greetMeOneWayRequest"/>
+ </wsdl:operation>
+
+ <wsdl:operation name="pingMe">
+ <wsdl:input name="pingMeRequest" message="tns:pingMeRequest"/>
+ <wsdl:output name="pingMeResponse" message="tns:pingMeResponse"/>
+ <wsdl:fault name="pingMeFault" message="tns:pingMeFault"/>
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name="Greeter_SOAPBinding" type="tns:Greeter">
+ <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+
+ <wsdl:operation name="sayHi">
+ <soap:operation soapAction="" style="document"/>
+ <wsdl:input name="sayHiRequest">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="sayHiResponse">
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+
+ <wsdl:operation name="greetMe">
+ <soap:operation soapAction="" style="document"/>
+ <wsdl:input name="greetMeRequest">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="greetMeResponse">
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+
+ <wsdl:operation name="greetMeOneWay">
+ <soap:operation soapAction="" style="document"/>
+ <wsdl:input name="greetMeOneWayRequest">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ </wsdl:operation>
+
+ <wsdl:operation name="pingMe">
+ <soap:operation style="document"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ <wsdl:fault name="pingMeFault">
+ <soap:fault name="pingMeFault" use="literal"/>
+ </wsdl:fault>
+ </wsdl:operation>
+
+ </wsdl:binding>
+ <wsdl:serviceDefinition name="SOAPService">
+ <wsdl:port binding="tns:Greeter_SOAPBinding" name="SoapPort">
+ <soap:address location="http://localhost:9000/SoapContext/SoapPort"/>
+ </wsdl:port>
+ </wsdl:serviceDefinition>
+</wsdl:definitions>
+
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/test/resources/wsdl/hello_world_doc_lit.wsdl b/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/test/resources/wsdl/hello_world_doc_lit.wsdl
new file mode 100644
index 0000000000..db625cb129
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/test/resources/wsdl/hello_world_doc_lit.wsdl
@@ -0,0 +1,154 @@
+<?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.
+-->
+<wsdl:definitions name="HelloWorld" targetNamespace="http://objectweb.org/hello_world_soap_http"
+ xmlns="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:tns="http://objectweb.org/hello_world_soap_http"
+ xmlns:x1="http://objectweb.org/hello_world_soap_http/types"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <wsdl:types>
+ <schema targetNamespace="http://objectweb.org/hello_world_soap_http/types"
+ xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:tns="http://objectweb.org/hello_world_soap_http/types"
+ elementFormDefault="qualified">
+ <simpleType name="MyStringType">
+ <restriction base="string">
+ <maxLength value="30" />
+ </restriction>
+ </simpleType>
+
+ <element name="sayHi">
+ <complexType/>
+ </element>
+ <element name="sayHiResponse">
+ <complexType>
+ <sequence>
+ <element name="responseType" type="string"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="greetMe">
+ <complexType>
+ <sequence>
+ <element name="requestType" type="tns:MyStringType"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="greetMeResponse">
+ <complexType>
+ <sequence>
+ <element name="responseType" type="string"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="greetMeOneWay">
+ <complexType>
+ <sequence>
+ <element name="requestType" type="string"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="pingMe">
+ <complexType/>
+ </element>
+ <element name="pingMeResponse">
+ <complexType/>
+ </element>
+ <element name="faultDetail">
+ <complexType>
+ <sequence>
+ <element name="minor" type="short"/>
+ <element name="major" type="short"/>
+ </sequence>
+ </complexType>
+ </element>
+ </schema>
+ </wsdl:types>
+ <wsdl:message name="sayHiRequest">
+ <wsdl:part element="x1:sayHi" name="in"/>
+ </wsdl:message>
+ <wsdl:message name="sayHiResponse">
+ <wsdl:part element="x1:sayHiResponse" name="out"/>
+ </wsdl:message>
+ <wsdl:message name="greetMeRequest">
+ <wsdl:part element="x1:greetMe" name="in"/>
+ </wsdl:message>
+ <wsdl:message name="greetMeResponse">
+ <wsdl:part element="x1:greetMeResponse" name="out"/>
+ </wsdl:message>
+ <wsdl:message name="greetMeOneWayRequest">
+ <wsdl:part element="x1:greetMeOneWay" name="in"/>
+ </wsdl:message>
+
+ <wsdl:portType name="Greeter">
+ <wsdl:operation name="sayHi">
+ <wsdl:input message="tns:sayHiRequest" name="sayHiRequest"/>
+ <wsdl:output message="tns:sayHiResponse" name="sayHiResponse"/>
+ </wsdl:operation>
+
+ <wsdl:operation name="greetMe">
+ <wsdl:input message="tns:greetMeRequest" name="greetMeRequest"/>
+ <wsdl:output message="tns:greetMeResponse" name="greetMeResponse"/>
+ </wsdl:operation>
+
+ <wsdl:operation name="greetMeOneWay">
+ <wsdl:input message="tns:greetMeOneWayRequest" name="greetMeOneWayRequest"/>
+ </wsdl:operation>
+
+ </wsdl:portType>
+ <wsdl:binding name="Greeter_SOAPBinding" type="tns:Greeter">
+ <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+
+ <wsdl:operation name="sayHi">
+ <soap:operation soapAction="" style="document"/>
+ <wsdl:input name="sayHiRequest">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="sayHiResponse">
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+
+ <wsdl:operation name="greetMe">
+ <soap:operation soapAction="" style="document"/>
+ <wsdl:input name="greetMeRequest">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="greetMeResponse">
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+
+ <wsdl:operation name="greetMeOneWay">
+ <soap:operation soapAction="" style="document"/>
+ <wsdl:input name="greetMeOneWayRequest">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ </wsdl:operation>
+
+ </wsdl:binding>
+ <wsdl:service name="SOAPService">
+ <wsdl:port binding="tns:Greeter_SOAPBinding" name="SoapPort">
+ <soap:address location="http://localhost:9000/SoapContext/SoapPort"/>
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
+
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/test/resources/wsdl/hello_world_doc_lit_inout.wsdl b/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/test/resources/wsdl/hello_world_doc_lit_inout.wsdl
new file mode 100644
index 0000000000..90634709ba
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.celtix/src/test/resources/wsdl/hello_world_doc_lit_inout.wsdl
@@ -0,0 +1,181 @@
+<?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.
+-->
+<wsdl:definitions name="HelloWorld" targetNamespace="http://objectweb.org/hello_world_soap_http"
+ xmlns="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:tns="http://objectweb.org/hello_world_soap_http"
+ xmlns:x1="http://objectweb.org/hello_world_soap_http/types"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <wsdl:types>
+ <schema targetNamespace="http://objectweb.org/hello_world_soap_http/types"
+ xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:tns="http://objectweb.org/hello_world_soap_http/types"
+ elementFormDefault="qualified">
+ <simpleType name="MyStringType">
+ <restriction base="string">
+ <maxLength value="30" />
+ </restriction>
+ </simpleType>
+
+ <element name="sayHi">
+ <complexType/>
+ </element>
+ <element name="sayHiResponse">
+ <complexType>
+ <sequence>
+ <element name="responseType" type="string"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="greetMe">
+ <complexType>
+ <sequence>
+ <element name="requestType" type="tns:MyStringType"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="greetMeResponse">
+ <complexType>
+ <sequence>
+ <element name="responseType" type="string"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="greetMeOneWay">
+ <complexType>
+ <sequence>
+ <element name="requestType" type="string"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="pingMe">
+ <complexType/>
+ </element>
+ <element name="pingMeResponse">
+ <complexType/>
+ </element>
+ <element name="faultDetail">
+ <complexType>
+ <sequence>
+ <element name="minor" type="short"/>
+ <element name="major" type="short"/>
+ </sequence>
+ </complexType>
+ </element>
+ </schema>
+ </wsdl:types>
+ <wsdl:message name="sayHiRequest">
+ <wsdl:part element="x1:sayHi" name="in"/>
+ </wsdl:message>
+ <wsdl:message name="sayHiResponse">
+ <wsdl:part element="x1:sayHiResponse" name="out"/>
+ </wsdl:message>
+ <wsdl:message name="greetMeRequest">
+ <wsdl:part element="x1:greetMe" name="in"/>
+ </wsdl:message>
+ <wsdl:message name="greetMeResponse">
+ <wsdl:part element="x1:greetMe" name="out"/>
+ </wsdl:message>
+ <wsdl:message name="greetMeOneWayRequest">
+ <wsdl:part element="x1:greetMeOneWay" name="in"/>
+ </wsdl:message>
+ <wsdl:message name="pingMeRequest">
+ <wsdl:part name="in" element="x1:pingMe"/>
+ </wsdl:message>
+ <wsdl:message name="pingMeResponse">
+ <wsdl:part name="out" element="x1:pingMeResponse"/>
+ </wsdl:message>
+ <wsdl:message name="pingMeFault">
+ <wsdl:part name="faultDetail" element="x1:faultDetail"/>
+ </wsdl:message>
+
+ <wsdl:portType name="Greeter">
+ <wsdl:operation name="sayHi">
+ <wsdl:input message="tns:sayHiRequest" name="sayHiRequest"/>
+ <wsdl:output message="tns:sayHiResponse" name="sayHiResponse"/>
+ </wsdl:operation>
+
+ <wsdl:operation name="greetMe">
+ <wsdl:input message="tns:greetMeRequest" name="greetMeRequest"/>
+ <wsdl:output message="tns:greetMeResponse" name="greetMeResponse"/>
+ </wsdl:operation>
+
+ <wsdl:operation name="greetMeOneWay">
+ <wsdl:input message="tns:greetMeOneWayRequest" name="greetMeOneWayRequest"/>
+ </wsdl:operation>
+
+ <wsdl:operation name="pingMe">
+ <wsdl:input name="pingMeRequest" message="tns:pingMeRequest"/>
+ <wsdl:output name="pingMeResponse" message="tns:pingMeResponse"/>
+ <wsdl:fault name="pingMeFault" message="tns:pingMeFault"/>
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name="Greeter_SOAPBinding" type="tns:Greeter">
+ <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+
+ <wsdl:operation name="sayHi">
+ <soap:operation soapAction="" style="document"/>
+ <wsdl:input name="sayHiRequest">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="sayHiResponse">
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+
+ <wsdl:operation name="greetMe">
+ <soap:operation soapAction="" style="document"/>
+ <wsdl:input name="greetMeRequest">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="greetMeResponse">
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+
+ <wsdl:operation name="greetMeOneWay">
+ <soap:operation soapAction="" style="document"/>
+ <wsdl:input name="greetMeOneWayRequest">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ </wsdl:operation>
+
+ <wsdl:operation name="pingMe">
+ <soap:operation style="document"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ <wsdl:fault name="pingMeFault">
+ <soap:fault name="pingMeFault" use="literal"/>
+ </wsdl:fault>
+ </wsdl:operation>
+
+ </wsdl:binding>
+ <wsdl:service name="SOAPService">
+ <wsdl:port binding="tns:Greeter_SOAPBinding" name="SoapPort">
+ <soap:address location="http://localhost:9000/SoapContext/SoapPort"/>
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
+
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.celtix/tuscany-checkstyle.xml b/branches/sca-java-M2/sca/services/bindings/binding.celtix/tuscany-checkstyle.xml
new file mode 100644
index 0000000000..df8a9483d5
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.celtix/tuscany-checkstyle.xml
@@ -0,0 +1,288 @@
+<?xml version="1.0"?>
+<!--
+ * 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.
+-->
+<!DOCTYPE module PUBLIC
+ "-//Puppy Crawl//DTD Check Configuration 1.2//EN"
+ "http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
+
+<!--
+Checks to make sure the code meets the Tuscany coding guidelines
+http://java.sun.com/docs/codeconv/index.html
+
+It also enforces aa bunch of other "BestPractices like method
+lengths, if/try depths, etc...
+
+-->
+
+<module name="Checker">
+ <property name="severity"
+ value="${checkstyle.severity}"
+ default="warning"/>
+
+ <!-- Checks whether files end with a new line. -->
+ <!-- See http://checkstyle.sf.net/config_misc.html#NewlineAtEndOfFile -->
+ <!--
+ <module name="NewlineAtEndOfFile"/>
+ -->
+
+ <!-- Checks that property files contain the same keys. -->
+ <!-- See http://checkstyle.sf.net/config_misc.html#Translation -->
+ <module name="Translation"/>
+
+ <!--<module name="StrictDuplicateCode"/>-->
+
+ <module name="TreeWalker">
+
+ <!-- Checks for Javadoc comments. -->
+ <!-- See http://checkstyle.sf.net/config_javadoc.html -->
+ <!--
+ <module name="PackageHtml"/>
+ <module name="JavadocMethod"/>
+ <module name="JavadocType"/>
+ <module name="JavadocVariable"/>
+ <module name="JavadocStyle"/>
+ -->
+
+
+ <!-- Checks for Naming Conventions. -->
+ <!-- See http://checkstyle.sf.net/config_naming.html -->
+ <module name="AbstractClassName">
+ <property name="format"
+ value="^Abstract.*$|^.*Factory$|^.*Bus$|^.*ConfigurationRepository$|^.*Base$|^Exception$|^.*Builder$"/>
+ </module>
+ <module name="ConstantName"/>
+ <module name="LocalFinalVariableName"/>
+ <module name="LocalVariableName"/>
+ <module name="MemberName"/>
+ <module name="MethodName"/>
+ <module name="PackageName"/>
+ <module name="ParameterName"/>
+ <module name="StaticVariableName"/>
+ <module name="TypeName"/>
+
+ <!-- Header checks -->
+ <!-- <module name="Header"/> -->
+ <!-- <module name="RegexpHeader"/> -->
+
+
+ <!-- Checks for imports -->
+ <!-- See http://checkstyle.sf.net/config_import.html -->
+ <module name="AvoidStarImport">
+ <property name="excludes"
+ value="java.io,java.util,java.net,java.nio,java.nio.channels,java.lang.reflect,org.w3c.dom,org.xml.sax,java.awt,javax.swing,junit.framework"/>
+ </module>
+ <module name="IllegalImport"/>
+ <!-- defaults to sun.* packages -->
+ <module name="RedundantImport"/>
+ <module name="UnusedImports"/>
+ <module name="ImportOrder">
+ <property name="groups" value="java,javax,org.w3c,org.xml,w3c"/>
+ <property name="ordered" value="true"/>
+ </module>
+ <!--
+ <module name="ImportControl">
+ <property name="file" value="etc/import-control.xml"/>
+ </module>
+ -->
+
+
+ <!-- Checks for Size Violations. -->
+ <!-- See http://checkstyle.sf.net/config_sizes.html -->
+ <module name="AnonInnerLength">
+ <property name="max" value="40"/>
+ </module>
+ <module name="ExecutableStatementCount">
+ <property name="max" value="50"/>
+ </module>
+ <module name="FileLength"/>
+ <module name="LineLength">
+ <property name="max" value="115"/>
+ </module>
+ <module name="MethodLength">
+ <property name="max" value="150"/>
+ <property name="countEmpty" value="false"/>
+ </module>
+ <module name="ParameterNumber">
+ <property name="max" value="7"/>
+ </module>
+
+ <!-- Checks for whitespace -->
+ <!-- See http://checkstyle.sf.net/config_whitespace.html -->
+ <module name="EmptyForIteratorPad"/>
+ <module name="EmptyForInitializerPad"/>
+ <module name="MethodParamPad"/>
+ <module name="NoWhitespaceAfter">
+ <property name="tokens" value="ARRAY_INIT,BNOT,DEC,DOT,INC,LNOT,UNARY_MINUS,UNARY_PLUS"/>
+ </module>
+ <module name="NoWhitespaceBefore"/>
+ <module name="OperatorWrap"/>
+ <module name="ParenPad"/>
+ <module name="TypecastParenPad"/>
+ <module name="TabCharacter"/>
+ <module name="WhitespaceAfter">
+ <property name="tokens" value="COMMA, SEMI"/>
+ </module>
+ <module name="WhitespaceAround">
+ <property name="tokens"
+ value="ASSIGN, BAND, BAND_ASSIGN, BOR, BOR_ASSIGN, BSR, BSR_ASSIGN, BXOR, BXOR_ASSIGN, COLON, DIV, DIV_ASSIGN, EQUAL, GE, GT, LAND, LCURLY, LE, LITERAL_ASSERT, LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, LITERAL_FOR, LITERAL_IF, LITERAL_RETURN, LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE, LOR, LT, MINUS, MINUS_ASSIGN, MOD, MOD_ASSIGN, NOT_EQUAL, PLUS, PLUS_ASSIGN, QUESTION, RCURLY, SL, SLIST, SL_ASSIGN, SR, SR_ASSIGN, STAR, STAR_ASSIGN,TYPE_EXTENSION_AND"/>
+ </module>
+
+
+ <!-- Modifier Checks -->
+ <!-- See http://checkstyle.sf.net/config_modifiers.html -->
+ <module name="ModifierOrder"/>
+ <module name="RedundantModifier"/>
+
+
+ <!-- Checks for blocks. You know, those {}'s -->
+ <!-- See http://checkstyle.sf.net/config_blocks.html -->
+ <module name="AvoidNestedBlocks">
+ <property name="allowInSwitchCase" value="true"/>
+ </module>
+ <module name="EmptyBlock">
+ <property name="option" value="text"/>
+ </module>
+ <module name="LeftCurly"/>
+ <module name="NeedBraces"/>
+ <module name="RightCurly"/>
+
+
+ <!-- Checks for common coding problems -->
+ <!-- See http://checkstyle.sf.net/config_coding.html -->
+ <!--<module name="ArrayTrailingComma"/>-->
+ <!--<module name="AvoidInlineConditionals"/>-->
+ <module name="CovariantEquals"/>
+ <module name="DoubleCheckedLocking"/>
+ <module name="EmptyStatement"/>
+ <module name="EqualsHashCode"/>
+ <!--<module name="FinalLocalVariable"/>-->
+ <module name="HiddenField">
+ <property name="ignoreConstructorParameter" value="true"/>
+ <property name="ignoreSetter" value="true"/>
+ <property name="ignoreAbstractMethods" value="true"/>
+ </module>
+ <module name="IllegalInstantiation"/>
+ <!--<module name="IllegalToken"/>-->
+ <!--<module name="IllegalTokenText"/>-->
+ <!--<module name="InnerAssignment"/>-->
+ <!--<module name="MagicNumber"/>-->
+ <module name="MissingSwitchDefault"/>
+ <module name="ModifiedControlVariable"/>
+ <module name="SimplifyBooleanExpression"/>
+ <module name="SimplifyBooleanReturn"/>
+ <module name="StringLiteralEquality"/>
+ <module name="NestedIfDepth">
+ <property name="max" value="3"/>
+ </module>
+ <module name="NestedTryDepth">
+ <property name="max" value="3"/>
+ </module>
+ <module name="SuperClone"/>
+ <module name="SuperFinalize"/>
+ <!--<module name="IllegalCatch"/>-->
+ <module name="IllegalThrows">
+ <property name="illegalClassNames" value="java.lang.Error,java.lang.RuntimeException"/>
+ </module>
+ <!--<module name="RedundantThrows"/>-->
+ <module name="PackageDeclaration"/>
+ <module name="JUnitTestCase"/>
+ <module name="ReturnCount">
+ <property name="max" value="6"/>
+ </module>
+
+ <module name="IllegalType">
+ <property name="format" value="^xxx$"/>
+ </module>
+ <module name="DeclarationOrder"/>
+ <!--<module name="ParameterAssignment"/>-->
+ <module name="ExplicitInitialization"/>
+ <module name="DefaultComesLast"/>
+ <!--<module name="MissingCtor"/>-->
+ <module name="FallThrough"/>
+ <!--<module name="MultipleStringLiterals"/>-->
+ <module name="MultipleVariableDeclarations"/>
+ <!--<module name="RequireThis"/>-->
+ <module name="UnnecessaryParentheses"/>
+
+
+ <!-- Checks for class design -->
+ <!-- See http://checkstyle.sf.net/config_design.html -->
+ <!--<module name="DesignForExtension"/>-->
+ <module name="FinalClass"/>
+ <module name="HideUtilityClassConstructor"/>
+ <module name="InterfaceIsType"/>
+ <module name="MutableException"/>
+ <module name="ThrowsCount">
+ <property name="max" value="5"/>
+ </module>
+ <module name="VisibilityModifier">
+ <property name="protectedAllowed" value="true"/>
+ <property name="packageAllowed" value="true"/>
+ </module>
+
+
+ <!-- Metrics checks. -->
+ <!-- See http://checkstyle.sf.net/config_metrics.html -->
+ <module name="BooleanExpressionComplexity">
+ <property name="max" value="6"/>
+ </module>
+ <!--<module name="ClassDataAbstractionCoupling"/>-->
+ <!--<module name="ClassFanOutComplexity"/>-->
+ <!--<module name="CyclomaticComplexity"/>-->
+ <!--<module name="NPathComplexity"/>-->
+ <module name="JavaNCSS">
+ <property name="methodMaximum" value="75"/>
+ </module>
+
+
+ <!-- Miscellaneous other checks. -->
+ <!-- See http://checkstyle.sf.net/config_misc.html -->
+ <!--
+ <module name="ArrayTypeStyle"/>
+ <module name="FinalParameters"/>
+ -->
+ <!--
+ <module name="GenericIllegalRegexp">
+ <property name="format" value="\s+$"/>
+ <property name="message" value="Line has trailing spaces."/>
+ </module>
+ -->
+ <module name="TodoComment">
+ <property name="format" value="WARNING"/>
+ </module>
+
+ <module name="UpperEll"/>
+
+ <!--Assert statement may have side effects:-->
+ <module name="DescendantToken">
+ <property name="tokens" value="LITERAL_ASSERT"/>
+ <property name="limitedTokens"
+ value="ASSIGN,DEC,INC,POST_DEC,POST_INC,PLUS_ASSIGN,MINUS_ASSIGN,STAR_ASSIGN,DIV_ASSIGN,MOD_ASSIGN,BSR_ASSIGN,SR_ASSIGN,SL_ASSIGN,BAND_ASSIGN,BXOR_ASSIGN,BOR_ASSIGN"/>
+ <property name="maximumNumber" value="0"/>
+ </module>
+
+ <!--<module name="UncommentedMain"/>-->
+ <module name="TrailingComment"/>
+ <module name="Indentation">
+ <property name="caseIndent" value="0"/>
+ </module>
+ <!--<module name="RequiredRegexp">-->
+ </module>
+
+</module>
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/.ruleset b/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/.ruleset
new file mode 100644
index 0000000000..ac8671859d
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/.ruleset
@@ -0,0 +1,190 @@
+<?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.
+-->
+<ruleset name="pmd-eclipse">
+ <description>PMD Plugin preferences rule set</description>
+
+
+ <rule ref="rulesets/basic.xml/BooleanInstantiation"/>
+ <rule ref="rulesets/basic.xml/CollapsibleIfStatements"/>
+ <rule ref="rulesets/basic.xml/DoubleCheckedLocking"/>
+<!--<rule ref="rulesets/basic.xml/EmptyCatchBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyFinallyBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyIfStmt"/>-->
+ <rule ref="rulesets/basic.xml/EmptyStatementNotInLoop"/>
+<!--<rule ref="rulesets/basic.xml/EmptyStaticInitializer"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptySwitchStatements"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptySynchronizedBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyTryBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyWhileStmt"/>-->
+ <rule ref="rulesets/basic.xml/ForLoopShouldBeWhileLoop"/>
+ <rule ref="rulesets/basic.xml/JumbledIncrementer"/>
+<!--<rule ref="rulesets/basic.xml/OverrideBothEqualsAndHashcode"/>-->
+ <rule ref="rulesets/basic.xml/ReturnFromFinallyBlock"/>
+ <rule ref="rulesets/basic.xml/UnconditionalIfStatement"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryConversionTemporary"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryFinalModifier"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryReturn"/>
+<!--<rule ref="rulesets/basic.xml/UselessOverridingMethod"/>-->
+
+<!--<rule ref="rulesets/braces.xml/ForLoopsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/IfElseStmtsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/IfStmtsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/WhileLoopsMustUseBraces"/>-->
+
+<!--<rule ref="rulesets/clone.xml/CloneMethodMustImplementCloneable"/>-->
+<!--<rule ref="rulesets/clone.xml/CloneThrowsCloneNotSupportedException"/>-->
+<!--<rule ref="rulesets/clone.xml/ProperCloneImplementation"/>-->
+
+<!--<rule ref="rulesets/codesize.xml/CyclomaticComplexity"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveClassLength"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveMethodLength"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveParameterList"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessivePublicCount"/>-->
+<!--<rule ref="rulesets/codesize.xml/TooManyFields"/>-->
+
+<rule ref="rulesets/controversial.xml/AssignmentInOperand"/>
+<!--<rule ref="rulesets/controversial.xml/AtLeastOneConstructor"/>-->
+<!--<rule ref="rulesets/controversial.xml/CallSuperInConstructor"/>-->
+<!--<rule ref="rulesets/controversial.xml/DontImportSun"/>-->
+<!--<rule ref="rulesets/controversial.xml/NullAssignment"/>-->
+<!--<rule ref="rulesets/controversial.xml/OnlyOneReturn"/>-->
+<!--<rule ref="rulesets/controversial.xml/SingularField"/>-->
+<!--<rule ref="rulesets/controversial.xml/SuspiciousOctalEscape"/>-->
+<!--<rule ref="rulesets/controversial.xml/UnnecessaryConstructor"/>-->
+<rule ref="rulesets/controversial.xml/UnnecessaryParentheses"/>
+<!--<rule ref="rulesets/controversial.xml/UnusedModifier"/>-->
+
+<!--<rule ref="rulesets/coupling.xml/CouplingBetweenObjects"/>-->
+<!--<rule ref="rulesets/coupling.xml/ExcessiveImports"/>-->
+<!--<rule ref="rulesets/coupling.xml/LooseCoupling"/>-->
+
+<!--<rule ref="rulesets/design.xml/AbstractClassWithoutAbstractMethod"/>-->
+<!--<rule ref="rulesets/design.xml/AccessorClassGeneration"/>-->
+<!--<rule ref="rulesets/design.xml/AssignmentToNonFinalStatic"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidDeeplyNestedIfStmts"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidInstanceofChecksInCatchClause"/>-->
+<rule ref="rulesets/design.xml/AvoidProtectedFieldInFinalClass"/>
+<!--<rule ref="rulesets/design.xml/AvoidReassigningParameters"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidSynchronizedAtMethodLevel"/>-->
+<!--<rule ref="rulesets/design.xml/BadComparison"/>-->
+<!--<rule ref="rulesets/design.xml/CloseConnection"/>-->
+<!--<rule ref="rulesets/design.xml/CompareObjectsWithEquals"/>-->
+<!--<rule ref="rulesets/design.xml/ConfusingTernary"/>-->
+<rule ref="rulesets/design.xml/ConstructorCallsOverridableMethod"/>
+<!--<rule ref="rulesets/design.xml/DefaultLabelNotLastInSwitchStmt"/>-->
+<!--<rule ref="rulesets/design.xml/FinalFieldCouldBeStatic"/>-->
+<rule ref="rulesets/design.xml/IdempotentOperations"/>
+<!--<rule ref="rulesets/design.xml/ImmutableField"/>-->
+<!--<rule ref="rulesets/design.xml/InstantiationToGetClass"/>-->
+<!--<rule ref="rulesets/design.xml/MissingBreakInSwitch"/>-->
+<!--<rule ref="rulesets/design.xml/MissingStaticMethodInNonInstantiatableClass"/>-->
+<!--<rule ref="rulesets/design.xml/NonCaseLabelInSwitchStatement"/>-->
+<!--<rule ref="rulesets/design.xml/NonStaticInitializer"/>-->
+<rule ref="rulesets/design.xml/OptimizableToArrayCall"/>
+<rule ref="rulesets/design.xml/PositionLiteralsFirstInComparisons"/>
+<rule ref="rulesets/design.xml/SimplifyBooleanExpressions"/>
+<rule ref="rulesets/design.xml/SimplifyBooleanReturns"/>
+<rule ref="rulesets/design.xml/SimplifyConditional"/>
+<!--<rule ref="rulesets/design.xml/SwitchDensity"/>-->
+<!--<rule ref="rulesets/design.xml/SwitchStmtsShouldHaveDefault"/>-->
+<rule ref="rulesets/design.xml/UnnecessaryLocalBeforeReturn"/>
+<!--<rule ref="rulesets/design.xml/UseLocaleWithCaseConversions"/>-->
+<!--<rule ref="rulesets/design.xml/UseNotifyAllInsteadOfNotify"/>-->
+<!--<rule ref="rulesets/design.xml/UseSingleton"/>-->
+
+<!--<rule ref="rulesets/finalizers.xml/EmptyFinalizer"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeOnlyCallsSuperFinalize"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeOverloaded"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeDoesNotCallSuperFinalize"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeShouldBeProtected"/>-->
+<!--<rule ref="rulesets/finalizers.xml/AvoidCallingFinalize"/>-->
+
+<!--<rule ref="rulesets/imports.xml/DuplicateImports"/>-->
+<!--<rule ref="rulesets/imports.xml/DontImportJavaLang"/>-->
+<!--<rule ref="rulesets/imports.xml/UnusedImports"/>-->
+<!--<rule ref="rulesets/imports.xml/ImportFromSamePackage"/>-->
+
+<!--<rule ref="rulesets/javabeans.xml/BeanMembersShouldSerialize"/>-->
+<!--<rule ref="rulesets/javabeans.xml/MissingSerialVersionUID"/>-->
+
+<!--<rule ref="rulesets/junit.xml/JUnitStaticSuite"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitSpelling"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitAssertionsShouldIncludeMessage"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitTestsShouldIncludeAssert"/>-->
+<!--<rule ref="rulesets/junit.xml/TestClassWithoutTestCases"/>-->
+<!--<rule ref="rulesets/junit.xml/UnnecessaryBooleanAssertion"/>-->
+<!--<rule ref="rulesets/junit.xml/UseAssertEqualsInsteadOfAssertTrue"/>-->
+<!--<rule ref="rulesets/junit.xml/UseAssertSameInsteadOfAssertTrue"/>-->
+
+ <!--<rule ref="rulesets/logging-java.xml/AvoidPrintStackTrace"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LoggerIsNotStaticFinal"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/MoreThanOneLogger"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LoggerIsNotStaticFinal"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LogBlockWithoutIf"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/SystemPrintln"/>-->
+ <!--<rule ref="rulesets/logging-jakarta-commons.xml/UseCorrectExceptionLogging"/>-->
+ <!--<rule ref="rulesets/logging-jakarta-commons.xml/ProperLogger"/>-->
+
+ <!--<rule ref="rulesets/naming.xml/ShortVariable"/>-->
+ <!--<rule ref="rulesets/naming.xml/LongVariable"/>-->
+ <!--<rule ref="rulesets/naming.xml/ShortMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/VariableNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/MethodNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/ClassNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/AbstractNaming"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidDollarSigns"/>-->
+ <!--<rule ref="rulesets/naming.xml/MethodWithSameNameAsEnclosingClass"/>-->
+ <!--<rule ref="rulesets/naming.xml/SuspiciousHashcodeMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/SuspiciousConstantFieldName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidFieldNameMatchingTypeName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidFieldNameMatchingMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidNonConstructorMethodsWithClassName"/>-->
+ <!--<rule ref="rulesets/naming.xml/NoPackage"/>-->
+ <!--<rule ref="rulesets/naming.xml/PackageCase"/>-->
+
+ <!--<rule ref="rulesets/optimizations.xml/LocalVariableCouldBeFinal"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/MethodArgumentCouldBeFinal"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/AvoidInstantiatingObjectsInLoops"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/UseArrayListInsteadOfVector"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/SimplifyStartsWith"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/UseStringBufferForStringAppends"/>-->
+
+ <!--<rule ref="rulesets/strictexception.xml/AvoidCatchingThrowable"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/SignatureDeclareThrowsException"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/ExceptionAsFlowControl"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidCatchingNPE"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidThrowingRawExceptionTypes"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidThrowingNullPointerException"/>-->
+
+ <!--<rule ref="rulesets/strings.xml/AvoidDuplicateLiterals"/>-->
+ <!--<rule ref="rulesets/strings.xml/StringInstantiation"/>-->
+ <!--<rule ref="rulesets/strings.xml/StringToString"/>-->
+ <!--<rule ref="rulesets/strings.xml/AvoidConcatenatingNonLiteralsInStringBuffer"/>-->
+ <!--<rule ref="rulesets/strings.xml/UnnecessaryCaseChange"/>-->
+
+ <!--<rule ref="rulesets/sunsecure.xml/MethodReturnsInternalArray"/>-->
+ <!--<rule ref="rulesets/sunsecure.xml/ArrayIsStoredDirectly"/>-->
+
+ <rule ref="rulesets/unusedcode.xml/UnusedLocalVariable"/>
+ <rule ref="rulesets/unusedcode.xml/UnusedPrivateField"/>
+ <rule ref="rulesets/unusedcode.xml/UnusedPrivateMethod"/>
+ <!--<rule ref="rulesets/unusedcode.xml/UnusedFormalParameter"/>-->
+
+</ruleset>
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/LICENSE.txt b/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/LICENSE.txt
new file mode 100644
index 0000000000..d645695673
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/LICENSE.txt
@@ -0,0 +1,202 @@
+
+ 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/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/NOTICE.txt b/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/NOTICE.txt
new file mode 100644
index 0000000000..d83ebbe236
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/NOTICE.txt
@@ -0,0 +1,14 @@
+${pom.name}
+Copyright (c) 2005 - 2006 The Apache Software Foundation
+
+Apache Tuscany is an effort undergoing incubation at The Apache Software
+Foundation (ASF), sponsored by the Apache Web Services PMC. Incubation is
+required of all newly accepted projects until a further review indicates that
+the infrastructure, communications, and decision making process have stabilized
+in a manner consistent with other successful ASF projects. While incubation
+status is not necessarily a reflection of the completeness or stability of the
+code, it does indicate that the project has yet to be fully endorsed by the ASF.
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/pom.xml b/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/pom.xml
new file mode 100644
index 0000000000..4fede9927d
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/pom.xml
@@ -0,0 +1,59 @@
+<?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 xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <parent>
+ <groupId>org.apache.tuscany.sca.services.bindings</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>binding-jsonrpc</artifactId>
+ <name>Apache Tuscany Binding for JSON-RPC</name>
+ <description>Implementation of the SCA JSON-RPC Binding</description>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca.kernel</groupId>
+ <artifactId>tuscany-spi</artifactId>
+ <version>${sca.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.metaparadigm</groupId>
+ <artifactId>json-rpc</artifactId>
+ <version>1.0</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>tomcat</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>5.0.18</version>
+ <scope>provided</scope>
+ </dependency>
+
+ </dependencies>
+</project>
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/java/org/apache/tuscany/binding/jsonrpc/JSONRPCBinding.java b/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/java/org/apache/tuscany/binding/jsonrpc/JSONRPCBinding.java
new file mode 100644
index 0000000000..101bfde6c2
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/java/org/apache/tuscany/binding/jsonrpc/JSONRPCBinding.java
@@ -0,0 +1,38 @@
+/*
+ * 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.binding.jsonrpc;
+
+import org.apache.tuscany.spi.model.Binding;
+
+/**
+ * Represents a binding to an RMI service.
+ *
+ * @version $Rev$ $Date$
+ */
+public class JSONRPCBinding extends Binding {
+ private String uri;
+
+ public String getURI() {
+ return uri;
+ }
+
+ public void setURI(String uri) {
+ this.uri = uri;
+ }
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/java/org/apache/tuscany/binding/jsonrpc/JSONRPCBindingBuilder.java b/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/java/org/apache/tuscany/binding/jsonrpc/JSONRPCBindingBuilder.java
new file mode 100644
index 0000000000..85654f1104
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/java/org/apache/tuscany/binding/jsonrpc/JSONRPCBindingBuilder.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.binding.jsonrpc;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.Service;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.BindingBuilderExtension;
+import org.apache.tuscany.spi.host.ServletHost;
+import org.apache.tuscany.spi.model.BoundServiceDefinition;
+
+/**
+ * Builds a Service for JSON-RPC binding.
+ *
+ * @version $Rev$ $Date$
+ */
+public class JSONRPCBindingBuilder extends BindingBuilderExtension<JSONRPCBinding> {
+
+ private ServletHost servletHost;
+
+ @Autowire()
+ public void setServletHost(ServletHost servletHost) {
+ this.servletHost = servletHost;
+ }
+
+ protected Class<JSONRPCBinding> getBindingType() {
+ return JSONRPCBinding.class;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Service build(CompositeComponent parent,
+ BoundServiceDefinition<JSONRPCBinding> serviceDefinition,
+ DeploymentContext deploymentContext) {
+ Class<?> interfaze = serviceDefinition.getServiceContract().getInterfaceClass();
+
+ return new JSONRPCService(serviceDefinition.getName(), interfaze, parent, wireService, servletHost);
+ }
+
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/java/org/apache/tuscany/binding/jsonrpc/JSONRPCBindingLoader.java b/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/java/org/apache/tuscany/binding/jsonrpc/JSONRPCBindingLoader.java
new file mode 100644
index 0000000000..9f2a35d912
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/java/org/apache/tuscany/binding/jsonrpc/JSONRPCBindingLoader.java
@@ -0,0 +1,57 @@
+/*
+ * 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.binding.jsonrpc;
+
+import static org.osoa.sca.Version.XML_NAMESPACE_1_0;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.LoaderExtension;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.loader.LoaderRegistry;
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * Loader for handling <binding.jsonrpc> elements.
+ *
+ * @version $Rev$ $Date$
+ */
+@Scope("MODULE")
+public class JSONRPCBindingLoader extends LoaderExtension<JSONRPCBinding> {
+ public static final QName BINDING_JSON = new QName(XML_NAMESPACE_1_0, "binding.jsonrpc");
+
+ public JSONRPCBindingLoader(@Autowire
+ LoaderRegistry registry) {
+ super(registry);
+ }
+
+ public QName getXMLType() {
+ return BINDING_JSON;
+ }
+
+ public JSONRPCBinding load(CompositeComponent parent, XMLStreamReader reader, DeploymentContext deploymentContext) throws XMLStreamException,
+ LoaderException {
+
+ return new JSONRPCBinding();
+ }
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/java/org/apache/tuscany/binding/jsonrpc/JSONRPCEntryPointServlet.java b/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/java/org/apache/tuscany/binding/jsonrpc/JSONRPCEntryPointServlet.java
new file mode 100644
index 0000000000..c7afc4742e
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/java/org/apache/tuscany/binding/jsonrpc/JSONRPCEntryPointServlet.java
@@ -0,0 +1,71 @@
+/*
+ * 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.binding.jsonrpc;
+
+import java.io.IOException;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+import com.metaparadigm.jsonrpc.JSONRPCBridge;
+import com.metaparadigm.jsonrpc.JSONRPCServlet;
+
+/**
+ *
+ *
+ */
+public class JSONRPCEntryPointServlet extends JSONRPCServlet {
+ private static final long serialVersionUID = 1L;
+
+ String serviceName;
+
+ Object serviceInstance;
+
+ public JSONRPCEntryPointServlet(String serviceName, Object serviceInstance) {
+ this.serviceName = serviceName;
+ this.serviceInstance = serviceInstance;
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.metaparadigm.jsonrpc.JSONRPCServlet#service(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
+ */
+ @Override
+ public void service(HttpServletRequest request, HttpServletResponse response) throws IOException, ClassCastException {
+
+ /*
+ * Create a new bridge for every request to aviod all the problems with JSON-RPC-Java storing the bridge in the session
+ */
+ HttpSession session = request.getSession();
+ try {
+
+ JSONRPCBridge jsonrpcBridge = new JSONRPCBridge();
+ jsonrpcBridge.registerObject(serviceName, serviceInstance);
+ session.setAttribute("JSONRPCBridge", jsonrpcBridge);
+
+ super.service(request, response);
+
+ } finally {
+ session.removeAttribute("JSONRPCBridge");
+ }
+ }
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/java/org/apache/tuscany/binding/jsonrpc/JSONRPCService.java b/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/java/org/apache/tuscany/binding/jsonrpc/JSONRPCService.java
new file mode 100644
index 0000000000..58d1d087ac
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/java/org/apache/tuscany/binding/jsonrpc/JSONRPCService.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.binding.jsonrpc;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.extension.ServiceExtension;
+import org.apache.tuscany.spi.host.ServletHost;
+import org.apache.tuscany.spi.wire.WireService;
+import org.osoa.sca.annotations.Destroy;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JSONRPCService extends ServiceExtension {
+ private ServletHost servletHost;
+
+ public JSONRPCService(String theName, Class<?> interfaze, CompositeComponent parent, WireService wireService, ServletHost servletHost) {
+
+ super(theName, interfaze, parent, wireService);
+
+ this.servletHost = servletHost;
+ }
+
+ public void start() {
+ super.start();
+
+ JSONRPCEntryPointServlet servlet = new JSONRPCEntryPointServlet(getName(), this.getServiceInstance());
+ servletHost.registerMapping("/" + getName(), servlet);
+ servletHost.registerMapping("/SCA/scripts", new ScriptGetterServlet());
+ }
+
+ @Destroy
+ public void stop() {
+ servletHost.unregisterMapping("/" + getName());
+ servletHost.unregisterMapping("/SCA/scripts");
+
+ super.stop();
+ }
+
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/java/org/apache/tuscany/binding/jsonrpc/ScriptGetterServlet.java b/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/java/org/apache/tuscany/binding/jsonrpc/ScriptGetterServlet.java
new file mode 100644
index 0000000000..8f8a96df20
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/java/org/apache/tuscany/binding/jsonrpc/ScriptGetterServlet.java
@@ -0,0 +1,52 @@
+/*
+ * 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.binding.jsonrpc;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+public class ScriptGetterServlet extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ // private static final String SCA_INIT_JS = "SCA = new JSONRpcClient(\"services/HelloWorldService\");";
+
+ public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
+ URL url = getClass().getResource("jsonrpc.js");
+ InputStream is = url.openStream();
+ writeToStream(response, is);
+
+ // writeToStream(response, new ByteArrayInputStream(SCA_INIT_JS.getBytes()));
+ }
+
+ private void writeToStream(HttpServletResponse response, InputStream is) throws IOException {
+ ServletOutputStream os = response.getOutputStream();
+ int i;
+ while ((i = is.read()) != -1) { // NOPMD
+ os.write(i);
+ }
+ }
+
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/resources/META-INF/sca/binding.jsonrpc.scdl b/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/resources/META-INF/sca/binding.jsonrpc.scdl
new file mode 100644
index 0000000000..4081d437c3
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/resources/META-INF/sca/binding.jsonrpc.scdl
@@ -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.
+-->
+<!--
+ Default system configuration for the launcher environment.
+
+ $Rev$ $Date$
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:system="http://incubator.apache.org/tuscany/xmlns/system/1.0-incubator-M2"
+ name="org.apache.tuscany.binding.jsonrpc">
+
+ <!-- dependency xmlns="http://incubator.apache.org/tuscany/xmlns/1.0-incubator-M2">
+ <groupId>com.metaparadigm</groupId>
+ <name>json-rpc</name>
+ <version>1.0</version>
+ </dependency -->
+
+ <component name="binding.jsonrpc.bindingLoader">
+ <system:implementation.system class="org.apache.tuscany.binding.jsonrpc.JSONRPCBindingLoader"/>
+ </component>
+
+ <component name="binding.jsonrpc.bindingBuilder">
+ <system:implementation.system class="org.apache.tuscany.binding.jsonrpc.JSONRPCBindingBuilder"/>
+ </component>
+</composite>
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/resources/META-INF/sca/default.scdl b/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/resources/META-INF/sca/default.scdl
new file mode 100644
index 0000000000..aec9bb440b
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/resources/META-INF/sca/default.scdl
@@ -0,0 +1,43 @@
+<?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.
+-->
+<!--
+ Default system configuration for the launcher environment.
+
+ $Rev$ $Date$
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:system="http://incubator.apache.org/tuscany/xmlns/system/1.0-incubator-M2"
+ name="org.apache.tuscany.binding.jsonrpc">
+
+ <dependency xmlns="http://incubator.apache.org/tuscany/xmlns/1.0-incubator-M2">
+ <group>com.metaparadigm</group>
+ <name>json-rpc</name>
+ <version>1.0</version>
+ </dependency>
+
+ <component name="binding.jsonrpc.bindingLoader">
+ <system:implementation.system class="org.apache.tuscany.binding.jsonrpc.JSONRPCBindingLoader"/>
+ </component>
+
+ <component name="binding.jsonrpc.bindingBuilder">
+ <system:implementation.system class="org.apache.tuscany.binding.jsonrpc.JSONRPCBindingBuilder"/>
+ </component>
+
+</composite>
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/resources/META-INF/sca/jsonrpc_extension.scdl b/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/resources/META-INF/sca/jsonrpc_extension.scdl
new file mode 100644
index 0000000000..4081d437c3
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/resources/META-INF/sca/jsonrpc_extension.scdl
@@ -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.
+-->
+<!--
+ Default system configuration for the launcher environment.
+
+ $Rev$ $Date$
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:system="http://incubator.apache.org/tuscany/xmlns/system/1.0-incubator-M2"
+ name="org.apache.tuscany.binding.jsonrpc">
+
+ <!-- dependency xmlns="http://incubator.apache.org/tuscany/xmlns/1.0-incubator-M2">
+ <groupId>com.metaparadigm</groupId>
+ <name>json-rpc</name>
+ <version>1.0</version>
+ </dependency -->
+
+ <component name="binding.jsonrpc.bindingLoader">
+ <system:implementation.system class="org.apache.tuscany.binding.jsonrpc.JSONRPCBindingLoader"/>
+ </component>
+
+ <component name="binding.jsonrpc.bindingBuilder">
+ <system:implementation.system class="org.apache.tuscany.binding.jsonrpc.JSONRPCBindingBuilder"/>
+ </component>
+</composite>
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/resources/org/apache/tuscany/binding/jsonrpc/jsonrpc.js b/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/resources/org/apache/tuscany/binding/jsonrpc/jsonrpc.js
new file mode 100644
index 0000000000..2b9efbb55c
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.jsonrpc/src/main/resources/org/apache/tuscany/binding/jsonrpc/jsonrpc.js
@@ -0,0 +1,484 @@
+/*
+ * JSON-RPC JavaScript client
+ *
+ * $Id: jsonrpc.js,v 1.36.2.3 2006/03/08 15:09:37 mclark Exp $
+ *
+ * Copyright (c) 2003-2004 Jan-Klaas Kollhof
+ * Copyright (c) 2005 Michael Clark, Metaparadigm Pte Ltd
+ *
+ * This code is based on Jan-Klaas' JavaScript o lait library (jsolait).
+ *
+ * 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.
+ *
+ */
+
+
+/* escape a character */
+
+escapeJSONChar =
+function escapeJSONChar(c)
+{
+ if(c == "\"" || c == "\\") return "\\" + c;
+ else if (c == "\b") return "\\b";
+ else if (c == "\f") return "\\f";
+ else if (c == "\n") return "\\n";
+ else if (c == "\r") return "\\r";
+ else if (c == "\t") return "\\t";
+ var hex = c.charCodeAt(0).toString(16);
+ if(hex.length == 1) return "\\u000" + hex;
+ else if(hex.length == 2) return "\\u00" + hex;
+ else if(hex.length == 3) return "\\u0" + hex;
+ else return "\\u" + hex;
+};
+
+
+/* encode a string into JSON format */
+
+escapeJSONString =
+function escapeJSONString(s)
+{
+ /* The following should suffice but Safari's regex is b0rken
+ (doesn't support callback substitutions)
+ return "\"" + s.replace(/([^\u0020-\u007f]|[\\\"])/g,
+ escapeJSONChar) + "\"";
+ */
+
+ /* Rather inefficient way to do it */
+ var parts = s.split("");
+ for(var i=0; i < parts.length; i++) {
+ var c =parts[i];
+ if(c == '"' ||
+ c == '\\' ||
+ c.charCodeAt(0) < 32 ||
+ c.charCodeAt(0) >= 128)
+ parts[i] = escapeJSONChar(parts[i]);
+ }
+ return "\"" + parts.join("") + "\"";
+};
+
+
+/* Marshall objects to JSON format */
+
+toJSON = function toJSON(o)
+{
+ if(o == null) {
+ return "null";
+ } else if(o.constructor == String) {
+ return escapeJSONString(o);
+ } else if(o.constructor == Number) {
+ return o.toString();
+ } else if(o.constructor == Boolean) {
+ return o.toString();
+ } else if(o.constructor == Date) {
+ return '{javaClass: "java.util.Date", time: ' + o.valueOf() +'}';
+ } else if(o.constructor == Array) {
+ var v = [];
+ for(var i = 0; i < o.length; i++) v.push(toJSON(o[i]));
+ return "[" + v.join(", ") + "]";
+ } else {
+ var v = [];
+ for(attr in o) {
+ if(o[attr] == null) v.push("\"" + attr + "\": null");
+ else if(typeof o[attr] == "function"); /* skip */
+ else v.push(escapeJSONString(attr) + ": " + toJSON(o[attr]));
+ }
+ return "{" + v.join(", ") + "}";
+ }
+};
+
+
+/* JSONRpcClient constructor */
+
+JSONRpcClient =
+function JSONRpcClient_ctor(serverURL, user, pass, objectID)
+{
+ this.serverURL = serverURL;
+ this.user = user;
+ this.pass = pass;
+ this.objectID = objectID;
+
+ /* Add standard methods */
+ if(this.objectID) {
+ this._addMethods(["listMethods"]);
+ var req = this._makeRequest("listMethods", []);
+ } else {
+ this._addMethods(["system.listMethods"]);
+ var req = this._makeRequest("system.listMethods", []);
+ }
+ var m = this._sendRequest(req);
+ this._addMethods(m);
+};
+
+
+/* JSONRpcCLient.Exception */
+
+JSONRpcClient.Exception =
+function JSONRpcClient_Exception_ctor(code, message, javaStack)
+{
+ this.code = code;
+ var name;
+ if(javaStack) {
+ this.javaStack = javaStack;
+ var m = javaStack.match(/^([^:]*)/);
+ if(m) name = m[0];
+ }
+ if(name) this.name = name;
+ else this.name = "JSONRpcClientException";
+ this.message = message;
+};
+
+JSONRpcClient.Exception.CODE_REMOTE_EXCEPTION = 490;
+JSONRpcClient.Exception.CODE_ERR_CLIENT = 550;
+JSONRpcClient.Exception.CODE_ERR_PARSE = 590;
+JSONRpcClient.Exception.CODE_ERR_NOMETHOD = 591;
+JSONRpcClient.Exception.CODE_ERR_UNMARSHALL = 592;
+JSONRpcClient.Exception.CODE_ERR_MARSHALL = 593;
+
+JSONRpcClient.Exception.prototype = new Error();
+
+JSONRpcClient.Exception.prototype.toString =
+function JSONRpcClient_Exception_toString(code, msg)
+{
+ return this.name + ": " + this.message;
+};
+
+
+/* Default top level exception handler */
+
+JSONRpcClient.default_ex_handler =
+function JSONRpcClient_default_ex_handler(e) { alert(e); };
+
+
+/* Client settable variables */
+
+JSONRpcClient.toplevel_ex_handler = JSONRpcClient.default_ex_handler;
+JSONRpcClient.profile_async = false;
+JSONRpcClient.max_req_active = 1;
+JSONRpcClient.requestId = 1;
+
+
+/* JSONRpcClient implementation */
+
+JSONRpcClient.prototype._createMethod =
+function JSONRpcClient_createMethod(methodName)
+{
+ var fn=function()
+ {
+ var args = [];
+ var callback = null;
+ for(var i=0;i<arguments.length;i++) args.push(arguments[i]);
+ if(typeof args[0] == "function") callback = args.shift();
+ var req = fn.client._makeRequest.call(fn.client, fn.methodName,
+ args, callback);
+ if(callback == null) {
+ return fn.client._sendRequest.call(fn.client, req);
+ } else {
+ JSONRpcClient.async_requests.push(req);
+ JSONRpcClient.kick_async();
+ return req.requestId;
+ }
+ };
+ fn.client = this;
+ fn.methodName = methodName;
+ return fn;
+};
+
+JSONRpcClient.prototype._addMethods =
+function JSONRpcClient_addMethods(methodNames)
+{
+ for(var i=0; i<methodNames.length; i++) {
+ var obj = this;
+ var names = methodNames[i].split(".");
+ for(var n=0; n<names.length-1; n++) {
+ var name = names[n];
+ if(obj[name]) {
+ obj = obj[name];
+ } else {
+ obj[name] = new Object();
+ obj = obj[name];
+ }
+ }
+ var name = names[names.length-1];
+ if(!obj[name]) {
+ var method = this._createMethod(methodNames[i]);
+ obj[name] = method;
+ }
+ }
+};
+
+JSONRpcClient._getCharsetFromHeaders =
+function JSONRpcClient_getCharsetFromHeaders(http)
+{
+ try {
+ var contentType = http.getResponseHeader("Content-type");
+ var parts = contentType.split(/\s*;\s*/);
+ for(var i =0; i < parts.length; i++) {
+ if(parts[i].substring(0, 8) == "charset=")
+ return parts[i].substring(8, parts[i].length);
+ }
+ } catch (e) {}
+ return "UTF-8"; /* default */
+};
+
+/* Async queue globals */
+JSONRpcClient.async_requests = [];
+JSONRpcClient.async_inflight = {};
+JSONRpcClient.async_responses = [];
+JSONRpcClient.async_timeout = null;
+JSONRpcClient.num_req_active = 0;
+
+JSONRpcClient._async_handler =
+function JSONRpcClient_async_handler()
+{
+ JSONRpcClient.async_timeout = null;
+
+ while(JSONRpcClient.async_responses.length > 0) {
+ var res = JSONRpcClient.async_responses.shift();
+ if(res.canceled) continue;
+ if(res.profile) res.profile.dispatch = new Date();
+ try {
+ res.cb(res.result, res.ex, res.profile);
+ } catch(e) {
+ JSONRpcClient.toplevel_ex_handler(e);
+ }
+ }
+
+ while(JSONRpcClient.async_requests.length > 0 &&
+ JSONRpcClient.num_req_active < JSONRpcClient.max_req_active) {
+ var req = JSONRpcClient.async_requests.shift();
+ if(req.canceled) continue;
+ req.client._sendRequest.call(req.client, req);
+ }
+};
+
+JSONRpcClient.kick_async =
+function JSONRpcClient_kick_async()
+{
+ if(JSONRpcClient.async_timeout == null)
+ JSONRpcClient.async_timeout =
+ setTimeout(JSONRpcClient._async_handler, 0);
+};
+
+JSONRpcClient.cancelRequest =
+function JSONRpcClient_cancelRequest(requestId)
+{
+ /* If it is in flight then mark it as canceled in the inflight map
+ and the XMLHttpRequest callback will discard the reply. */
+ if(JSONRpcClient.async_inflight[requestId]) {
+ JSONRpcClient.async_inflight[requestId].canceled = true;
+ return true;
+ }
+
+ /* If its not in flight yet then we can just mark it as canceled in
+ the the request queue and it will get discarded before being sent. */
+ for(var i in JSONRpcClient.async_requests) {
+ if(JSONRpcClient.async_requests[i].requestId == requestId) {
+ JSONRpcClient.async_requests[i].canceled = true;
+ return true;
+ }
+ }
+
+ /* It may have returned from the network and be waiting for its callback
+ to be dispatched, so mark it as canceled in the response queue
+ and the response will get discarded before calling the callback. */
+ for(var i in JSONRpcClient.async_responses) {
+ if(JSONRpcClient.async_responses[i].requestId == requestId) {
+ JSONRpcClient.async_responses[i].canceled = true;
+ return true;
+ }
+ }
+
+ return false;
+};
+
+JSONRpcClient.prototype._makeRequest =
+function JSONRpcClient_makeRequest(methodName, args, cb)
+{
+ var req = {};
+ req.client = this;
+ req.requestId = JSONRpcClient.requestId++;
+
+ var obj = {};
+ obj.id = req.requestId;
+ if (this.objectID)
+ obj.method = ".obj#" + this.objectID + "." + methodName;
+ else
+ obj.method = methodName;
+ obj.params = args;
+
+ if (cb) req.cb = cb;
+ if (JSONRpcClient.profile_async)
+ req.profile = { "submit": new Date() };
+ req.data = toJSON(obj);
+
+ return req;
+};
+
+JSONRpcClient.prototype._sendRequest =
+function JSONRpcClient_sendRequest(req)
+{
+ if(req.profile) req.profile.start = new Date();
+
+ /* Get free http object from the pool */
+ var http = JSONRpcClient.poolGetHTTPRequest();
+ JSONRpcClient.num_req_active++;
+
+ /* Send the request */
+ if (typeof(this.user) == "undefined") {
+ http.open("POST", this.serverURL, (req.cb != null));
+ } else {
+ http.open("POST", this.serverURL, (req.cb != null), this.user, this.pass);
+ }
+
+ /* setRequestHeader is missing in Opera 8 Beta */
+ try { http.setRequestHeader("Content-type", "text/plain"); } catch(e) {}
+
+ /* Construct call back if we have one */
+ if(req.cb) {
+ var self = this;
+ http.onreadystatechange = function() {
+ if(http.readyState == 4) {
+ http.onreadystatechange = function () {};
+ var res = { "cb": req.cb, "result": null, "ex": null};
+ if (req.profile) {
+ res.profile = req.profile;
+ res.profile.end = new Date();
+ }
+ try { res.result = self._handleResponse(http); }
+ catch(e) { res.ex = e; }
+ if(!JSONRpcClient.async_inflight[req.requestId].canceled)
+ JSONRpcClient.async_responses.push(res);
+ delete JSONRpcClient.async_inflight[req.requestId];
+ JSONRpcClient.kick_async();
+ }
+ };
+ } else {
+ http.onreadystatechange = function() {};
+ }
+
+ JSONRpcClient.async_inflight[req.requestId] = req;
+
+ try {
+ http.send(req.data);
+ } catch(e) {
+ JSONRpcClient.poolReturnHTTPRequest(http);
+ JSONRpcClient.num_req_active--;
+ throw new JSONRpcClient.Exception
+ (JSONRpcClient.Exception.CODE_ERR_CLIENT, "Connection failed");
+ }
+
+ if(!req.cb) return this._handleResponse(http);
+};
+
+JSONRpcClient.prototype._handleResponse =
+function JSONRpcClient_handleResponse(http)
+{
+ /* Get the charset */
+ if(!this.charset) {
+ this.charset = JSONRpcClient._getCharsetFromHeaders(http);
+ }
+
+ /* Get request results */
+ var status, statusText, data;
+ try {
+ status = http.status;
+ statusText = http.statusText;
+ data = http.responseText;
+ } catch(e) {
+ JSONRpcClient.poolReturnHTTPRequest(http);
+ JSONRpcClient.num_req_active--;
+ JSONRpcClient.kick_async();
+ throw new JSONRpcClient.Exception
+ (JSONRpcClient.Exception.CODE_ERR_CLIENT, "Connection failed");
+ }
+
+ /* Return http object to the pool; */
+ JSONRpcClient.poolReturnHTTPRequest(http);
+ JSONRpcClient.num_req_active--;
+
+ /* Unmarshall the response */
+ if(status != 200) {
+ throw new JSONRpcClient.Exception(status, statusText);
+ }
+ var obj;
+ try {
+ eval("obj = " + data);
+ } catch(e) {
+ throw new JSONRpcClient.Exception(550, "error parsing result");
+ }
+ if(obj.error)
+ throw new JSONRpcClient.Exception(obj.error.code, obj.error.msg,
+ obj.error.trace);
+ var res = obj.result;
+
+ /* Handle CallableProxy */
+ if(res && res.objectID && res.JSONRPCType == "CallableReference")
+ return new JSONRpcClient(this.serverURL, this.user,
+ this.pass, res.objectID);
+
+ return res;
+};
+
+
+/* XMLHttpRequest wrapper code */
+
+/* XMLHttpRequest pool globals */
+JSONRpcClient.http_spare = [];
+JSONRpcClient.http_max_spare = 8;
+
+JSONRpcClient.poolGetHTTPRequest =
+function JSONRpcClient_pool_getHTTPRequest()
+{
+ if(JSONRpcClient.http_spare.length > 0) {
+ return JSONRpcClient.http_spare.pop();
+ }
+ return JSONRpcClient.getHTTPRequest();
+};
+
+JSONRpcClient.poolReturnHTTPRequest =
+function JSONRpcClient_poolReturnHTTPRequest(http)
+{
+ if(JSONRpcClient.http_spare.length >= JSONRpcClient.http_max_spare)
+ delete http;
+ else
+ JSONRpcClient.http_spare.push(http);
+};
+
+JSONRpcClient.msxmlNames = [ "MSXML2.XMLHTTP.5.0",
+ "MSXML2.XMLHTTP.4.0",
+ "MSXML2.XMLHTTP.3.0",
+ "MSXML2.XMLHTTP",
+ "Microsoft.XMLHTTP" ];
+
+JSONRpcClient.getHTTPRequest =
+function JSONRpcClient_getHTTPRequest()
+{
+ /* Mozilla XMLHttpRequest */
+ try {
+ JSONRpcClient.httpObjectName = "XMLHttpRequest";
+ return new XMLHttpRequest();
+ } catch(e) {}
+
+ /* Microsoft MSXML ActiveX */
+ for (var i=0;i < JSONRpcClient.msxmlNames.length; i++) {
+ try {
+ JSONRpcClient.httpObjectName = JSONRpcClient.msxmlNames[i];
+ return new ActiveXObject(JSONRpcClient.msxmlNames[i]);
+ } catch (e) {}
+ }
+
+ /* None found */
+ JSONRpcClient.httpObjectName = null;
+ throw new JSONRpcClient.Exception(0, "Can't create XMLHttpRequest object");
+};
+
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.rmi/.ruleset b/branches/sca-java-M2/sca/services/bindings/binding.rmi/.ruleset
new file mode 100644
index 0000000000..3886f07f2d
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.rmi/.ruleset
@@ -0,0 +1,190 @@
+<?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.
+-->
+<ruleset name="pmd-eclipse">
+ <description>PMD Plugin preferences rule set</description>
+
+
+ <rule ref="rulesets/basic.xml/BooleanInstantiation"/>
+ <rule ref="rulesets/basic.xml/CollapsibleIfStatements"/>
+ <rule ref="rulesets/basic.xml/DoubleCheckedLocking"/>
+<!--<rule ref="rulesets/basic.xml/EmptyCatchBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyFinallyBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyIfStmt"/>-->
+ <rule ref="rulesets/basic.xml/EmptyStatementNotInLoop"/>
+<!--<rule ref="rulesets/basic.xml/EmptyStaticInitializer"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptySwitchStatements"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptySynchronizedBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyTryBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyWhileStmt"/>-->
+ <rule ref="rulesets/basic.xml/ForLoopShouldBeWhileLoop"/>
+ <rule ref="rulesets/basic.xml/JumbledIncrementer"/>
+<!--<rule ref="rulesets/basic.xml/OverrideBothEqualsAndHashcode"/>-->
+ <rule ref="rulesets/basic.xml/ReturnFromFinallyBlock"/>
+ <rule ref="rulesets/basic.xml/UnconditionalIfStatement"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryConversionTemporary"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryFinalModifier"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryReturn"/>
+<!--<rule ref="rulesets/basic.xml/UselessOverridingMethod"/>-->
+
+<!--<rule ref="rulesets/braces.xml/ForLoopsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/IfElseStmtsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/IfStmtsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/WhileLoopsMustUseBraces"/>-->
+
+<!--<rule ref="rulesets/clone.xml/CloneMethodMustImplementCloneable"/>-->
+<!--<rule ref="rulesets/clone.xml/CloneThrowsCloneNotSupportedException"/>-->
+<!--<rule ref="rulesets/clone.xml/ProperCloneImplementation"/>-->
+
+<!--<rule ref="rulesets/codesize.xml/CyclomaticComplexity"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveClassLength"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveMethodLength"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveParameterList"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessivePublicCount"/>-->
+<!--<rule ref="rulesets/codesize.xml/TooManyFields"/>-->
+
+<rule ref="rulesets/controversial.xml/AssignmentInOperand"/>
+<!--<rule ref="rulesets/controversial.xml/AtLeastOneConstructor"/>-->
+<!--<rule ref="rulesets/controversial.xml/CallSuperInConstructor"/>-->
+<!--<rule ref="rulesets/controversial.xml/DontImportSun"/>-->
+<!--<rule ref="rulesets/controversial.xml/NullAssignment"/>-->
+<!--<rule ref="rulesets/controversial.xml/OnlyOneReturn"/>-->
+<!--<rule ref="rulesets/controversial.xml/SingularField"/>-->
+<!--<rule ref="rulesets/controversial.xml/SuspiciousOctalEscape"/>-->
+<!--<rule ref="rulesets/controversial.xml/UnnecessaryConstructor"/>-->
+<rule ref="rulesets/controversial.xml/UnnecessaryParentheses"/>
+<!--<rule ref="rulesets/controversial.xml/UnusedModifier"/>-->
+
+<!--<rule ref="rulesets/coupling.xml/CouplingBetweenObjects"/>-->
+<!--<rule ref="rulesets/coupling.xml/ExcessiveImports"/>-->
+<!--<rule ref="rulesets/coupling.xml/LooseCoupling"/>-->
+
+<!--<rule ref="rulesets/design.xml/AbstractClassWithoutAbstractMethod"/>-->
+<!--<rule ref="rulesets/design.xml/AccessorClassGeneration"/>-->
+<!--<rule ref="rulesets/design.xml/AssignmentToNonFinalStatic"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidDeeplyNestedIfStmts"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidInstanceofChecksInCatchClause"/>-->
+<rule ref="rulesets/design.xml/AvoidProtectedFieldInFinalClass"/>
+<!--<rule ref="rulesets/design.xml/AvoidReassigningParameters"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidSynchronizedAtMethodLevel"/>-->
+<!--<rule ref="rulesets/design.xml/BadComparison"/>-->
+<!--<rule ref="rulesets/design.xml/CloseConnection"/>-->
+<!--<rule ref="rulesets/design.xml/CompareObjectsWithEquals"/>-->
+<!--<rule ref="rulesets/design.xml/ConfusingTernary"/>-->
+<rule ref="rulesets/design.xml/ConstructorCallsOverridableMethod"/>
+<!--<rule ref="rulesets/design.xml/DefaultLabelNotLastInSwitchStmt"/>-->
+<!--<rule ref="rulesets/design.xml/FinalFieldCouldBeStatic"/>-->
+<rule ref="rulesets/design.xml/IdempotentOperations"/>
+<!--<rule ref="rulesets/design.xml/ImmutableField"/>-->
+<!--<rule ref="rulesets/design.xml/InstantiationToGetClass"/>-->
+<!--<rule ref="rulesets/design.xml/MissingBreakInSwitch"/>-->
+<!--<rule ref="rulesets/design.xml/MissingStaticMethodInNonInstantiatableClass"/>-->
+<!--<rule ref="rulesets/design.xml/NonCaseLabelInSwitchStatement"/>-->
+<!--<rule ref="rulesets/design.xml/NonStaticInitializer"/>-->
+<rule ref="rulesets/design.xml/OptimizableToArrayCall"/>
+<rule ref="rulesets/design.xml/PositionLiteralsFirstInComparisons"/>
+<rule ref="rulesets/design.xml/SimplifyBooleanExpressions"/>
+<rule ref="rulesets/design.xml/SimplifyBooleanReturns"/>
+<rule ref="rulesets/design.xml/SimplifyConditional"/>
+<!--<rule ref="rulesets/design.xml/SwitchDensity"/>-->
+<!--<rule ref="rulesets/design.xml/SwitchStmtsShouldHaveDefault"/>-->
+<rule ref="rulesets/design.xml/UnnecessaryLocalBeforeReturn"/>
+<!--<rule ref="rulesets/design.xml/UseLocaleWithCaseConversions"/>-->
+<!--<rule ref="rulesets/design.xml/UseNotifyAllInsteadOfNotify"/>-->
+<!--<rule ref="rulesets/design.xml/UseSingleton"/>-->
+
+<!--<rule ref="rulesets/finalizers.xml/EmptyFinalizer"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeOnlyCallsSuperFinalize"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeOverloaded"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeDoesNotCallSuperFinalize"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeShouldBeProtected"/>-->
+<!--<rule ref="rulesets/finalizers.xml/AvoidCallingFinalize"/>-->
+
+<!--<rule ref="rulesets/imports.xml/DuplicateImports"/>-->
+<!--<rule ref="rulesets/imports.xml/DontImportJavaLang"/>-->
+<!--<rule ref="rulesets/imports.xml/UnusedImports"/>-->
+<!--<rule ref="rulesets/imports.xml/ImportFromSamePackage"/>-->
+
+<!--<rule ref="rulesets/javabeans.xml/BeanMembersShouldSerialize"/>-->
+<!--<rule ref="rulesets/javabeans.xml/MissingSerialVersionUID"/>-->
+
+<!--<rule ref="rulesets/junit.xml/JUnitStaticSuite"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitSpelling"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitAssertionsShouldIncludeMessage"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitTestsShouldIncludeAssert"/>-->
+<!--<rule ref="rulesets/junit.xml/TestClassWithoutTestCases"/>-->
+<!--<rule ref="rulesets/junit.xml/UnnecessaryBooleanAssertion"/>-->
+<!--<rule ref="rulesets/junit.xml/UseAssertEqualsInsteadOfAssertTrue"/>-->
+<!--<rule ref="rulesets/junit.xml/UseAssertSameInsteadOfAssertTrue"/>-->
+
+ <!--<rule ref="rulesets/logging-java.xml/AvoidPrintStackTrace"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LoggerIsNotStaticFinal"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/MoreThanOneLogger"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LoggerIsNotStaticFinal"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LogBlockWithoutIf"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/SystemPrintln"/>-->
+ <!--<rule ref="rulesets/logging-jakarta-commons.xml/UseCorrectExceptionLogging"/>-->
+ <!--<rule ref="rulesets/logging-jakarta-commons.xml/ProperLogger"/>-->
+
+ <!--<rule ref="rulesets/naming.xml/ShortVariable"/>-->
+ <!--<rule ref="rulesets/naming.xml/LongVariable"/>-->
+ <!--<rule ref="rulesets/naming.xml/ShortMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/VariableNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/MethodNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/ClassNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/AbstractNaming"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidDollarSigns"/>-->
+ <!--<rule ref="rulesets/naming.xml/MethodWithSameNameAsEnclosingClass"/>-->
+ <!--<rule ref="rulesets/naming.xml/SuspiciousHashcodeMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/SuspiciousConstantFieldName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidFieldNameMatchingTypeName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidFieldNameMatchingMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidNonConstructorMethodsWithClassName"/>-->
+ <!--<rule ref="rulesets/naming.xml/NoPackage"/>-->
+ <!--<rule ref="rulesets/naming.xml/PackageCase"/>-->
+
+ <!--<rule ref="rulesets/optimizations.xml/LocalVariableCouldBeFinal"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/MethodArgumentCouldBeFinal"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/AvoidInstantiatingObjectsInLoops"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/UseArrayListInsteadOfVector"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/SimplifyStartsWith"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/UseStringBufferForStringAppends"/>-->
+
+ <!--<rule ref="rulesets/strictexception.xml/AvoidCatchingThrowable"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/SignatureDeclareThrowsException"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/ExceptionAsFlowControl"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidCatchingNPE"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidThrowingRawExceptionTypes"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidThrowingNullPointerException"/>-->
+
+ <!--<rule ref="rulesets/strings.xml/AvoidDuplicateLiterals"/>-->
+ <!--<rule ref="rulesets/strings.xml/StringInstantiation"/>-->
+ <!--<rule ref="rulesets/strings.xml/StringToString"/>-->
+ <!--<rule ref="rulesets/strings.xml/AvoidConcatenatingNonLiteralsInStringBuffer"/>-->
+ <!--<rule ref="rulesets/strings.xml/UnnecessaryCaseChange"/>-->
+
+ <!--<rule ref="rulesets/sunsecure.xml/MethodReturnsInternalArray"/>-->
+ <!--<rule ref="rulesets/sunsecure.xml/ArrayIsStoredDirectly"/>-->
+
+ <rule ref="rulesets/unusedcode.xml/UnusedLocalVariable"/>
+ <rule ref="rulesets/unusedcode.xml/UnusedPrivateField"/>
+ <rule ref="rulesets/unusedcode.xml/UnusedPrivateMethod"/>
+ <!--<rule ref="rulesets/unusedcode.xml/UnusedFormalParameter"/>-->
+
+</ruleset>
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.rmi/LICENSE.txt b/branches/sca-java-M2/sca/services/bindings/binding.rmi/LICENSE.txt
new file mode 100755
index 0000000000..d645695673
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.rmi/LICENSE.txt
@@ -0,0 +1,202 @@
+
+ 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/branches/sca-java-M2/sca/services/bindings/binding.rmi/NOTICE.txt b/branches/sca-java-M2/sca/services/bindings/binding.rmi/NOTICE.txt
new file mode 100644
index 0000000000..d83ebbe236
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.rmi/NOTICE.txt
@@ -0,0 +1,14 @@
+${pom.name}
+Copyright (c) 2005 - 2006 The Apache Software Foundation
+
+Apache Tuscany is an effort undergoing incubation at The Apache Software
+Foundation (ASF), sponsored by the Apache Web Services PMC. Incubation is
+required of all newly accepted projects until a further review indicates that
+the infrastructure, communications, and decision making process have stabilized
+in a manner consistent with other successful ASF projects. While incubation
+status is not necessarily a reflection of the completeness or stability of the
+code, it does indicate that the project has yet to be fully endorsed by the ASF.
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.rmi/pom.xml b/branches/sca-java-M2/sca/services/bindings/binding.rmi/pom.xml
new file mode 100755
index 0000000000..31ef8047d4
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.rmi/pom.xml
@@ -0,0 +1,63 @@
+<?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 xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <parent>
+ <groupId>org.apache.tuscany.sca.services.bindings</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>rmi</artifactId>
+ <name>Apache Tuscany Binding for Java RMI</name>
+ <description>Implementation of the SCA RMI Binding</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>cglib</groupId>
+ <artifactId>cglib-nodep</artifactId>
+ <version>2.1_3</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.kernel</groupId>
+ <artifactId>tuscany-spi</artifactId>
+ <version>${sca.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>test</artifactId>
+ <version>${sca.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymock</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymockclassextension</artifactId>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/NoRemoteMethodException.java b/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/NoRemoteMethodException.java
new file mode 100644
index 0000000000..45404f087e
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/NoRemoteMethodException.java
@@ -0,0 +1,37 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * 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.
+ */
+package org.apache.tuscany.binding.rmi;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class NoRemoteMethodException extends RMIRuntimeException {
+ public NoRemoteMethodException() {
+ }
+
+ public NoRemoteMethodException(String message) {
+ super(message);
+ }
+
+ public NoRemoteMethodException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public NoRemoteMethodException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/NoRemoteServiceException.java b/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/NoRemoteServiceException.java
new file mode 100644
index 0000000000..af2d2fd582
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/NoRemoteServiceException.java
@@ -0,0 +1,37 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * 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.
+ */
+package org.apache.tuscany.binding.rmi;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class NoRemoteServiceException extends RMIRuntimeException {
+ public NoRemoteServiceException() {
+ }
+
+ public NoRemoteServiceException(String message) {
+ super(message);
+ }
+
+ public NoRemoteServiceException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public NoRemoteServiceException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBinding.java b/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBinding.java
new file mode 100644
index 0000000000..bc8c69851e
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBinding.java
@@ -0,0 +1,57 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * 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.
+ */
+package org.apache.tuscany.binding.rmi;
+
+import org.apache.tuscany.spi.model.Binding;
+
+/**
+ * Represents a binding to an RMI service.
+ *
+ * @version $Rev$ $Date$
+ */
+public class RMIBinding extends Binding {
+ private String host;
+
+ private String port;
+
+ private String serviceName;
+
+ public String getHost() {
+ return host;
+ }
+
+ public void setHost(String host) {
+ this.host = host;
+ }
+
+ public String getPort() {
+ return port;
+ }
+
+ public void setPort(String port) {
+ this.port = port;
+ }
+
+ public String getServiceName() {
+ return serviceName;
+ }
+
+ public void setServiceName(String serviceName) {
+ this.serviceName = serviceName;
+ }
+
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBindingBuilder.java b/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBindingBuilder.java
new file mode 100644
index 0000000000..1e2eb9633a
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBindingBuilder.java
@@ -0,0 +1,78 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * 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.
+ */
+package org.apache.tuscany.binding.rmi;
+
+import java.rmi.Remote;
+
+import org.apache.tuscany.host.rmi.RMIHost;
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.Reference;
+import org.apache.tuscany.spi.component.Service;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.BindingBuilderExtension;
+import org.apache.tuscany.spi.model.BoundReferenceDefinition;
+import org.apache.tuscany.spi.model.BoundServiceDefinition;
+import org.osoa.sca.annotations.Constructor;
+
+/**
+ * Builds a Service or Reference for an RMI binding.
+ *
+ * @version $Rev$ $Date$
+ */
+
+public class RMIBindingBuilder extends BindingBuilderExtension<RMIBinding> {
+
+ private RMIHost rmiHost;
+
+ @Constructor({"rmiHost"})
+ public RMIBindingBuilder(@Autowire RMIHost rHost) {
+ this.rmiHost = rHost;
+ }
+
+ protected Class<RMIBinding> getBindingType() {
+ return RMIBinding.class;
+ }
+
+ @SuppressWarnings({"unchecked"})
+ public Service build(CompositeComponent parent,
+ BoundServiceDefinition<RMIBinding> boundServiceDefinition,
+ DeploymentContext deploymentContext) {
+
+ Class intf = boundServiceDefinition.getServiceContract().getInterfaceClass();
+
+ return new RMIService<Remote>(boundServiceDefinition.getName(), parent, wireService, rmiHost,
+ boundServiceDefinition.getBinding().getHost(), boundServiceDefinition.getBinding().getPort(),
+ boundServiceDefinition.getBinding().getServiceName(), intf);
+ }
+
+ @SuppressWarnings({"unchecked"})
+ public Reference build(CompositeComponent parent,
+ BoundReferenceDefinition<RMIBinding> boundReferenceDefinition,
+ DeploymentContext deploymentContext) {
+ String name = boundReferenceDefinition.getName();
+ String host = boundReferenceDefinition.getBinding().getHost();
+ String port = boundReferenceDefinition.getBinding().getPort();
+ String svcName = boundReferenceDefinition.getBinding().getServiceName();
+ // Class<?> interfaze = boundReferenceDefinition.getServiceContract().getInterfaceClass();
+
+ return new RMIReference(name, parent, wireService, rmiHost, host, port, svcName,
+ boundReferenceDefinition.getServiceContract().getInterfaceClass());
+
+ }
+
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBindingLoader.java b/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBindingLoader.java
new file mode 100755
index 0000000000..bd9b165b6d
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBindingLoader.java
@@ -0,0 +1,64 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * 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.
+ */
+package org.apache.tuscany.binding.rmi;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.osoa.sca.annotations.Scope;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.LoaderExtension;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.loader.LoaderRegistry;
+import org.apache.tuscany.spi.loader.LoaderUtil;
+
+/**
+ * Loader for handling <binding.rmi> elements.
+ *
+ * @version $Rev$ $Date$
+ */
+@Scope("MODULE")
+public class RMIBindingLoader extends LoaderExtension<RMIBinding> {
+ public static final QName BINDING_RMI = new QName(
+ "http://incubator.apache.org/tuscany/xmlns/binding/rmi/1.0-incubator-M2", "binding.rmi");
+
+ public RMIBindingLoader(@Autowire LoaderRegistry registry) {
+ super(registry);
+ }
+
+ public QName getXMLType() {
+ return BINDING_RMI;
+ }
+
+ public RMIBinding load(CompositeComponent parent,
+ XMLStreamReader reader,
+ DeploymentContext deploymentContext) throws XMLStreamException, LoaderException {
+ String host = reader.getAttributeValue(null, "host");
+ String port = reader.getAttributeValue(null, "port");
+ String svcName = reader.getAttributeValue(null, "serviceName");
+ LoaderUtil.skipToEndElement(reader);
+ RMIBinding binding = new RMIBinding();
+ binding.setHost(host);
+ binding.setPort(port);
+ binding.setServiceName(svcName);
+ return binding;
+ }
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIInvoker.java b/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIInvoker.java
new file mode 100644
index 0000000000..afd1992d20
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIInvoker.java
@@ -0,0 +1,66 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * 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.
+ */
+package org.apache.tuscany.binding.rmi;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.rmi.Remote;
+
+import org.apache.tuscany.host.rmi.RMIHost;
+import org.apache.tuscany.host.rmi.RMIHostException;
+import org.apache.tuscany.spi.extension.TargetInvokerExtension;
+
+/**
+ * Invoke an RMI reference.
+ *
+ * @version $Rev$ $Date$
+ */
+public class RMIInvoker extends TargetInvokerExtension {
+ private Method remoteMethod;
+ private String host;
+ private String port;
+ private String svcName;
+ private RMIHost rmiHost;
+ private Remote proxy;
+
+ public RMIInvoker(RMIHost rmiHost, String host, String port, String svcName, Method remoteMethod) {
+ // assert remoteMethod.isAccessible();
+ this.remoteMethod = remoteMethod;
+ this.host = host;
+ this.port = port;
+ this.svcName = svcName;
+ this.rmiHost = rmiHost;
+ }
+
+ public Object invokeTarget(Object payload) throws InvocationTargetException {
+ try {
+ if (proxy == null) {
+ proxy = rmiHost.findService(host, port, svcName);
+ // proxy = Naming.lookup(serviceURI);
+ }
+ return remoteMethod.invoke(proxy, (Object[]) payload);
+ } catch (RMIHostException e) {
+ // the method we are passed must be accessible
+ throw new AssertionError(e);
+ } catch (IllegalAccessException e) {
+ // the method we are passed must be accessible
+ throw new AssertionError(e);
+ }
+
+ }
+
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIReference.java b/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIReference.java
new file mode 100644
index 0000000000..5e810892d9
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIReference.java
@@ -0,0 +1,87 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * 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.
+ */
+package org.apache.tuscany.binding.rmi;
+
+import static org.apache.tuscany.spi.idl.java.JavaIDLUtils.findMethod;
+
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.extension.ReferenceExtension;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+import org.apache.tuscany.spi.wire.WireService;
+
+import org.apache.tuscany.host.rmi.RMIHost;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class RMIReference<T> extends ReferenceExtension {
+ private final String host;
+
+ private final String port;
+
+ private final String svcName;
+
+ private RMIHost rmiHost;
+
+ public RMIReference(String name,
+ CompositeComponent parent,
+ WireService wireService,
+ RMIHost rmiHost,
+ String host,
+ String port,
+ String svcName,
+ Class<T> service) {
+ super(name, service, parent, wireService);
+ this.host = host;
+ this.port = port;
+ this.svcName = svcName;
+ this.rmiHost = rmiHost;
+ }
+
+ public TargetInvoker createTargetInvoker(ServiceContract contract, Operation operation) {
+ try {
+ /*Remote proxy = getProxy();
+ Method remoteMethod = proxy.getClass().getMethod(operation.getName(),
+ (Class[]) operation.getParameterTypes());
+ return new RMIInvoker(proxy, remoteMethod);
+ */
+ Method method = findMethod(operation, contract.getInterfaceClass().getMethods());
+ Method remoteMethod =
+ getInterface().getMethod(operation.getName(), (Class[]) method.getParameterTypes());
+ return new RMIInvoker(rmiHost, host, port, svcName, remoteMethod);
+ } catch (NoSuchMethodException e) {
+ throw new NoRemoteMethodException(operation.toString(), e);
+ }
+ }
+
+ /*protected Remote getProxy() {
+ try {
+ // todo do we need to cache this result?
+ return Naming.lookup(uri);
+ } catch (NotBoundException e) {
+ throw new NoRemoteServiceException(uri);
+ } catch (MalformedURLException e) {
+ throw new NoRemoteServiceException(uri);
+ } catch (RemoteException e) {
+ throw new NoRemoteServiceException(uri);
+ }
+ }*/
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIRuntimeException.java b/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIRuntimeException.java
new file mode 100644
index 0000000000..c36dec4531
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIRuntimeException.java
@@ -0,0 +1,39 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * 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.
+ */
+package org.apache.tuscany.binding.rmi;
+
+import org.apache.tuscany.api.TuscanyRuntimeException;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public abstract class RMIRuntimeException extends TuscanyRuntimeException {
+ protected RMIRuntimeException() {
+ }
+
+ protected RMIRuntimeException(String message) {
+ super(message);
+ }
+
+ protected RMIRuntimeException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ protected RMIRuntimeException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIService.java b/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIService.java
new file mode 100644
index 0000000000..0de833801f
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIService.java
@@ -0,0 +1,160 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * 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.
+ */
+package org.apache.tuscany.binding.rmi;
+
+import java.lang.reflect.Method;
+import java.rmi.Remote;
+import java.rmi.server.UnicastRemoteObject;
+
+import net.sf.cglib.asm.ClassWriter;
+import net.sf.cglib.asm.Constants;
+import net.sf.cglib.asm.Type;
+import net.sf.cglib.proxy.Enhancer;
+
+import org.apache.tuscany.host.rmi.RMIHost;
+import org.apache.tuscany.host.rmi.RMIHostException;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.extension.ServiceExtension;
+import org.apache.tuscany.spi.wire.WireService;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class RMIService<T extends Remote> extends ServiceExtension {
+
+ public static final String URI_PREFIX = "//localhost";
+ public static final String SLASH = "/";
+ public static final String COLON = ":";
+ //private final String host;
+ private final String port;
+ private final String serviceName;
+ private RMIHost rmiHost;
+
+ // need this member to morph the service interface to extend from Remote if it does not
+ // the base class's member variable interfaze is to be maintained to enable the connection
+ // of the service outbound to the component's inbound wire which requires that the service
+ // and the component match in their service contracts.
+ private Class serviceInterface;
+
+ public RMIService(String name,
+ CompositeComponent parent,
+ WireService wireService,
+ RMIHost rHost,
+ String host,
+ String port,
+ String svcName,
+ Class<T> service) {
+ super(name, service, parent, wireService);
+
+ this.serviceInterface = service;
+ this.rmiHost = rHost;
+ //this.host = host;
+ this.port = port;
+ this.serviceName = svcName;
+ }
+
+ public void start() {
+ super.start();
+ Remote rmiProxy = createRmiService();
+
+ try {
+ // startRMIRegistry();
+ rmiHost.registerService(serviceName,
+ getPort(port),
+ rmiProxy);
+ // bindRmiService(uri,rmiProxy);
+ } catch (RMIHostException e) {
+ throw new NoRemoteServiceException(e);
+ }
+ }
+
+ public void stop() {
+ try {
+ rmiHost.unregisterService(serviceName, getPort(port));
+ } catch (RMIHostException e) {
+ throw new NoRemoteServiceException(e.getMessage());
+ }
+ super.stop();
+ }
+
+ protected Remote createRmiService() {
+ Enhancer enhancer = new Enhancer();
+ enhancer.setSuperclass(UnicastRemoteObject.class);
+ enhancer.setCallback(new RemoteMethodHandler(getHandler(), interfaze));
+
+ if (!Remote.class.isAssignableFrom(serviceInterface)) {
+ RMIServiceClassLoader classloader =
+ new RMIServiceClassLoader(getClass().getClassLoader());
+ final byte[] byteCode = generateRemoteInterface(serviceInterface);
+ serviceInterface = classloader.defineClass(byteCode);
+ enhancer.setClassLoader(classloader);
+ }
+ enhancer.setInterfaces(new Class[]{serviceInterface});
+ return (Remote) enhancer.create();
+ }
+
+ protected int getPort(String port) {
+ int portNumber = RMIHost.RMI_DEFAULT_PORT;
+ if (port != null && port.length() > 0) {
+ portNumber = Integer.decode(port);
+ }
+
+ return portNumber;
+ }
+
+ // if the interface of the component whose services must be exposed as RMI Service, does not
+ // implement java.rmi.Remote, then generate such an interface. This method will stop with
+ // just generating the bytecode. Defining the class from the byte code must tbe the responsibility
+ // of the caller of this method, since it requires a classloader to be created to define and load
+ // this interface.
+ protected byte[] generateRemoteInterface(Class serviceInterface) {
+ String interfazeName = serviceInterface.getCanonicalName();
+ ClassWriter cw = new ClassWriter(false);
+
+ String simpleName = serviceInterface.getSimpleName();
+ cw.visit(Constants.V1_5, Constants.ACC_PUBLIC + Constants.ACC_ABSTRACT + Constants.ACC_INTERFACE,
+ interfazeName.replace('.', '/'), "java/lang/Object", new String[]{"java/rmi/Remote"}, simpleName + ".java");
+
+ StringBuffer argsAndReturn = null;
+ Method[] methods = serviceInterface.getMethods();
+ for (Method method : methods) {
+ argsAndReturn = new StringBuffer("(");
+ Class[] paramTypes = method.getParameterTypes();
+ Class returnType = method.getReturnType();
+
+ for (Class paramType : paramTypes) {
+ argsAndReturn.append(Type.getType(paramType));
+ }
+ argsAndReturn.append(")");
+ argsAndReturn.append(Type.getType(returnType));
+
+ cw.visitMethod(Constants.ACC_PUBLIC + Constants.ACC_ABSTRACT, method.getName(), argsAndReturn.toString(),
+ new String[]{"java/rmi/RemoteException"}, null);
+ }
+ cw.visitEnd();
+ return cw.toByteArray();
+ }
+
+ private class RMIServiceClassLoader extends ClassLoader {
+ public RMIServiceClassLoader(ClassLoader parent) {
+ super(parent);
+ }
+ public Class defineClass(byte[] byteArray) {
+ return defineClass(null, byteArray, 0, byteArray.length);
+ }
+ }
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RemoteMethodHandler.java b/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RemoteMethodHandler.java
new file mode 100644
index 0000000000..b27c87b510
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RemoteMethodHandler.java
@@ -0,0 +1,47 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * 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.
+ */
+package org.apache.tuscany.binding.rmi;
+
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.spi.wire.WireInvocationHandler;
+
+import net.sf.cglib.proxy.MethodInterceptor;
+import net.sf.cglib.proxy.MethodProxy;
+
+public class RemoteMethodHandler implements MethodInterceptor {
+ public static final String FINALIZE_METHOD = "finalize";
+
+ private WireInvocationHandler wireHandler;
+
+ private Class compSvcIntf;
+
+ public RemoteMethodHandler(WireInvocationHandler handler, Class intf) {
+ this.wireHandler = handler;
+ compSvcIntf = intf;
+ }
+
+ public Object intercept(Object object, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
+ // since incoming method signatures have 'remotemethod invocation' it will not match with the
+ // wired component's method signatures. Hence need to pull in the corresponding method from the
+ // component's service contract interface to make this invocation.
+ return wireHandler.invoke(compSvcIntf.getMethod(method.getName(),
+ (Class[]) method.getParameterTypes()),
+ args);
+ }
+
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/host/RMIHostImpl.java b/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/host/RMIHostImpl.java
new file mode 100644
index 0000000000..9355cf642e
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/host/RMIHostImpl.java
@@ -0,0 +1,136 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * 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.
+ */
+package org.apache.tuscany.binding.rmi.host;
+
+import java.rmi.AlreadyBoundException;
+import java.rmi.NotBoundException;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+import java.rmi.registry.LocateRegistry;
+import java.rmi.registry.Registry;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.apache.tuscany.host.rmi.RMIHost;
+import org.apache.tuscany.host.rmi.RMIHostException;
+import org.apache.tuscany.host.rmi.RMIHostRuntimeException;
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * This class provides an implementation for the RMI Host SPIs
+ */
+@Scope("MODULE")
+public class RMIHostImpl implements RMIHost {
+
+ // map of RMI registries started and running
+ private Map<String, Registry> rmiRegistries;
+
+ public RMIHostImpl() {
+ rmiRegistries = new ConcurrentHashMap<String, Registry>();
+ /*
+ * if (System.getSecurityManager() == null) { System.setSecurityManager(new RMISecurityManager()); }
+ */
+ }
+
+ @Init(eager = true)
+ public void init() {
+ }
+
+ public void registerService(String serviceName, int port, Remote serviceObject) throws RMIHostException,
+ RMIHostRuntimeException {
+ Registry registry;
+ try {
+ registry = rmiRegistries.get(Integer.toString(port));
+ if (registry == null) {
+ registry = LocateRegistry.createRegistry(port);
+ rmiRegistries.put(Integer.toString(port),
+ registry);
+ }
+ registry.bind(serviceName,
+ serviceObject);
+ } catch (AlreadyBoundException e) {
+ throw new RMIHostException(e.getMessage());
+ } catch (RemoteException e) {
+ RMIHostRuntimeException rmiExec = new RMIHostRuntimeException(e.getMessage());
+ rmiExec.setStackTrace(e.getStackTrace());
+ throw rmiExec;
+ }
+
+ }
+
+ public void registerService(String serviceName, Remote serviceObject) throws RMIHostException,
+ RMIHostRuntimeException {
+ registerService(serviceName,
+ RMI_DEFAULT_PORT,
+ serviceObject);
+ }
+
+ public void unregisterService(String serviceName, int port) throws RMIHostException,
+ RMIHostRuntimeException {
+ Registry registry;
+
+ try {
+ registry = rmiRegistries.get(Integer.toString(port));
+ if (registry == null) {
+ registry = LocateRegistry.createRegistry(port);
+ rmiRegistries.put(Integer.toString(port),
+ registry);
+ }
+ registry.unbind(serviceName);
+ } catch (RemoteException e) {
+ RMIHostRuntimeException rmiExec = new RMIHostRuntimeException(e.getMessage());
+ rmiExec.setStackTrace(e.getStackTrace());
+ throw rmiExec;
+ } catch (NotBoundException e) {
+ throw new RMIHostException(e.getMessage());
+ }
+ }
+
+ public void unregisterService(String serviceName) throws RMIHostException,
+ RMIHostRuntimeException {
+ unregisterService(serviceName,
+ RMI_DEFAULT_PORT);
+
+ }
+
+ public Remote findService(String host, String port, String svcName) throws RMIHostException,
+ RMIHostRuntimeException {
+ Registry registry;
+ Remote remoteService = null;
+ host = (host == null || host.length() <= 0) ? "localhost" : host;
+ int portNumber = (port == null || port.length() <= 0) ? RMI_DEFAULT_PORT : Integer
+ .decode(port);
+
+ try {
+ registry = LocateRegistry.getRegistry(host,
+ portNumber);
+
+ if (registry != null) {
+ remoteService = registry.lookup(svcName);
+ }
+ } catch (RemoteException e) {
+ RMIHostRuntimeException rmiExec = new RMIHostRuntimeException(e.getMessage());
+ rmiExec.setStackTrace(e.getStackTrace());
+ throw rmiExec;
+ } catch (NotBoundException e) {
+ throw new RMIHostException(e.getMessage());
+ }
+ return remoteService;
+ }
+
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/resources/META-INF/sca/default.scdl b/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/resources/META-INF/sca/default.scdl
new file mode 100644
index 0000000000..61d6523472
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/resources/META-INF/sca/default.scdl
@@ -0,0 +1,55 @@
+<?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.
+ -->
+<!--
+ Default system configuration for the launcher environment.
+
+ $Rev$ $Date$
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:system="http://incubator.apache.org/tuscany/xmlns/system/1.0-incubator-M2"
+ xmlns:tuscany="http://incubator.apache.org/tuscany/xmlns/1.0-incubator-M2"
+ name="org.apache.tuscany.binding.rmi">
+
+
+ <dependency xmlns="http://incubator.apache.org/tuscany/xmlns/1.0-incubator-M2">
+ <group>org.apache.tuscany.sca.services.bindings</group>
+ <name>rmi</name>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </dependency>
+
+ <dependency xmlns="http://incubator.apache.org/tuscany/xmlns/1.0-incubator-M2">
+ <group>org.apache.tuscany.sca.kernel</group>
+ <name>tuscany-api</name>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </dependency>
+
+ <component name="binding.rmi.bindingLoader">
+ <system:implementation.system class="org.apache.tuscany.binding.rmi.RMIBindingLoader"/>
+ </component>
+
+ <component name="binding.rmi.bindingBuilder">
+ <system:implementation.system class="org.apache.tuscany.binding.rmi.RMIBindingBuilder"/>
+ </component>
+
+ <!-- RMI Host service -->
+ <component name="rmiHost">
+ <system:implementation.system class="org.apache.tuscany.binding.rmi.host.RMIHostImpl"/>
+ </component>
+</composite> \ No newline at end of file
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/resources/META-INF/sca/rmi_extension.scdl b/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/resources/META-INF/sca/rmi_extension.scdl
new file mode 100644
index 0000000000..9417a1d5ad
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/main/resources/META-INF/sca/rmi_extension.scdl
@@ -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.
+ -->
+<!--
+ Default system configuration for the launcher environment.
+
+ $Rev$ $Date$
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:system="http://incubator.apache.org/tuscany/xmlns/system/1.0-incubator-M2"
+ xmlns:tuscany="http://incubator.apache.org/tuscany/xmlns/1.0-incubator-M2"
+ name="org.apache.tuscany.binding.rmi">
+
+ <component name="binding.rmi.bindingLoader">
+ <system:implementation.system class="org.apache.tuscany.binding.rmi.RMIBindingLoader"/>
+ </component>
+
+ <component name="binding.rmi.bindingBuilder">
+ <system:implementation.system class="org.apache.tuscany.binding.rmi.RMIBindingBuilder"/>
+ </component>
+
+ <!-- RMI Host service -->
+ <component name="rmiHost">
+ <system:implementation.system class="org.apache.tuscany.binding.rmi.host.RMIHostImpl"/>
+ </component>
+</composite> \ No newline at end of file
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/helloworld/HelloWorldImpl.java b/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/helloworld/HelloWorldImpl.java
new file mode 100644
index 0000000000..ef17df1e9d
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/helloworld/HelloWorldImpl.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 helloworld;
+
+import org.osoa.sca.annotations.Service;
+
+/**
+ * This class implements the HelloWorld service.
+ */
+@Service(HelloWorldService.class)
+public class HelloWorldImpl implements HelloWorldService {
+
+ public String sayHello(String name) {
+ return "Hello from the RMI Service to - " + name;
+ }
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/helloworld/HelloWorldRmiImpl.java b/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/helloworld/HelloWorldRmiImpl.java
new file mode 100644
index 0000000000..a63d8d162c
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/helloworld/HelloWorldRmiImpl.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 helloworld;
+
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Service;
+
+/**
+ * This class implements the HelloWorld service.
+ */
+@Service(HelloWorldRmiService.class)
+public class HelloWorldRmiImpl implements HelloWorldRmiService {
+ @Reference
+ private HelloWorldService extService;
+
+ public HelloWorldService getExtService() {
+ return extService;
+ }
+
+ @Reference
+ public void setExtService(HelloWorldService extService) {
+ this.extService = extService;
+ }
+
+ public String sayRmiHello(String name) {
+ return extService.sayHello(name) + " thro the RMI Reference";
+ }
+
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/helloworld/HelloWorldRmiService.java b/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/helloworld/HelloWorldRmiService.java
new file mode 100644
index 0000000000..b6b99f45e3
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/helloworld/HelloWorldRmiService.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 helloworld;
+
+/**
+ * This is the business interface of the HelloWorld greetings service.
+ */
+public interface HelloWorldRmiService {
+
+ String sayRmiHello(String name);
+
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/helloworld/HelloWorldService.java b/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/helloworld/HelloWorldService.java
new file mode 100644
index 0000000000..25f2b1da31
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/helloworld/HelloWorldService.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 helloworld;
+
+/**
+ * This is the business interface of the HelloWorld greetings service.
+ */
+public interface HelloWorldService {
+
+ String sayHello(String name);
+
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/BindingTestCase.java b/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/BindingTestCase.java
new file mode 100644
index 0000000000..7ebee2af66
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/BindingTestCase.java
@@ -0,0 +1,54 @@
+/*
+ * 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.binding.rmi;
+
+import helloworld.HelloWorldRmiService;
+
+import org.apache.tuscany.test.SCATestCase;
+import org.osoa.sca.CompositeContext;
+import org.osoa.sca.CurrentCompositeContext;
+
+// TODO: renamed to XXX as it doesn't work for me
+public class BindingTestCase extends SCATestCase {
+ private HelloWorldRmiService helloWorldRmiService;
+
+ public void testRmiService() {
+ System.out.println(helloWorldRmiService.sayRmiHello("Tuscany World!"));
+ assertEquals("Hello from the RMI Service to - Tuscany World! thro the RMI Reference",
+ helloWorldRmiService.sayRmiHello("Tuscany World!"));
+ }
+
+ protected void setUp() throws Exception {
+ addExtension("rmi.binding",
+ getClass().getClassLoader().getResource("META-INF/sca/rmi_extension.scdl"));
+ setApplicationSCDL(getClass().getClassLoader().getResource("META-INF/sca/default.scdl"));
+
+ super.setUp();
+
+ CompositeContext context = CurrentCompositeContext.getContext();
+ helloWorldRmiService = context.locateService(HelloWorldRmiService.class,
+ "HelloWorldRmiServiceComponent");
+ }
+
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/NoRemoteMethodExceptionTestCase.java b/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/NoRemoteMethodExceptionTestCase.java
new file mode 100644
index 0000000000..cb4911a0a5
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/NoRemoteMethodExceptionTestCase.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.binding.rmi;
+
+import junit.framework.TestCase;
+
+public class NoRemoteMethodExceptionTestCase extends TestCase {
+
+ public void testNoArgs() {
+ assertNotNull(new NoRemoteMethodException());
+ }
+
+ public void testMsgArg() {
+ NoRemoteMethodException e = new NoRemoteMethodException("foo");
+ assertEquals("foo", e.getMessage());
+ }
+
+ public void test2Args() {
+ Exception cause = new Exception();
+ NoRemoteMethodException e = new NoRemoteMethodException("foo", cause);
+ assertEquals("foo", e.getMessage());
+ assertEquals(cause, e.getCause());
+ }
+
+ public void testCauseArgs() {
+ Exception cause = new Exception();
+ NoRemoteMethodException e = new NoRemoteMethodException(cause);
+ assertEquals(cause, e.getCause());
+ }
+
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/NoRemoteServiceExceptionTestCase.java b/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/NoRemoteServiceExceptionTestCase.java
new file mode 100644
index 0000000000..a5da001ad9
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/NoRemoteServiceExceptionTestCase.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.binding.rmi;
+
+import junit.framework.TestCase;
+
+public class NoRemoteServiceExceptionTestCase extends TestCase {
+
+ public void testNoArgs() {
+ assertNotNull(new NoRemoteServiceException());
+ }
+
+ public void testMsgArg() {
+ NoRemoteServiceException e = new NoRemoteServiceException("foo");
+ assertEquals("foo", e.getMessage());
+ }
+
+ public void test2Args() {
+ Exception cause = new Exception();
+ NoRemoteServiceException e = new NoRemoteServiceException("foo", cause);
+ assertEquals("foo", e.getMessage());
+ assertEquals(cause, e.getCause());
+ }
+
+ public void testCauseArgs() {
+ Exception cause = new Exception();
+ NoRemoteServiceException e = new NoRemoteServiceException(cause);
+ assertEquals(cause, e.getCause());
+ }
+
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/RMIBindingBuilderTestCase.java b/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/RMIBindingBuilderTestCase.java
new file mode 100644
index 0000000000..b74be6d78b
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/RMIBindingBuilderTestCase.java
@@ -0,0 +1,48 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * 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.
+ */
+package org.apache.tuscany.binding.rmi;
+
+import static org.easymock.EasyMock.expect;
+import static org.easymock.classextension.EasyMock.createMock;
+import static org.easymock.classextension.EasyMock.replay;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.spi.model.BoundReferenceDefinition;
+import org.apache.tuscany.spi.model.ServiceContract;
+
+public class RMIBindingBuilderTestCase extends TestCase {
+
+ public void testGetBindingType() {
+ assertEquals(RMIBinding.class, new RMIBindingBuilder(null).getBindingType());
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testBuildService() {
+ RMIBindingBuilder builder = new RMIBindingBuilder(null);
+ BoundReferenceDefinition<RMIBinding> def = createMock(BoundReferenceDefinition.class);
+ expect(def.getName()).andReturn("petra");
+ RMIBinding binding = new RMIBinding();
+ expect(def.getBinding()).andReturn(binding );
+ expect(def.getBinding()).andReturn(binding );
+ expect(def.getBinding()).andReturn(binding );
+ ServiceContract sc = createMock(ServiceContract.class);
+ expect(def.getServiceContract()).andReturn(sc);
+ replay(def);
+ Object ref = builder.build(null, def, null);
+ assertTrue(ref instanceof RMIReference);
+ }
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/RMIBindingLoaderTestCase.java b/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/RMIBindingLoaderTestCase.java
new file mode 100644
index 0000000000..160ca19b8a
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/RMIBindingLoaderTestCase.java
@@ -0,0 +1,74 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * 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.
+ */
+package org.apache.tuscany.binding.rmi;
+
+import static org.easymock.EasyMock.expect;
+import static org.easymock.classextension.EasyMock.createMock;
+import static org.easymock.classextension.EasyMock.replay;
+import static org.easymock.classextension.EasyMock.verify;
+
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.loader.LoaderRegistry;
+
+public class RMIBindingLoaderTestCase extends TestCase {
+ private CompositeComponent parent;
+
+ private XMLStreamReader reader;
+
+ private DeploymentContext deploymentContext;
+
+ private LoaderRegistry registry;
+
+ private RMIBindingLoader loader;
+
+ public void testLoad() throws LoaderException, XMLStreamException {
+ expect(reader.getAttributeValue(null, "host")).andReturn("host");
+ expect(reader.getAttributeValue(null, "port")).andReturn("0");
+ expect(reader.getAttributeValue(null, "serviceName")).andReturn("servicename");
+ expect(reader.next()).andReturn(XMLStreamConstants.END_ELEMENT);
+
+ replay(reader);
+ replay(deploymentContext);
+
+ RMIBindingLoader mockLoader = new RMIBindingLoader(registry);
+ mockLoader.load(parent, reader, deploymentContext);
+ verify(reader);
+ verify(deploymentContext);
+ }
+
+ public void testGetXMLType() throws LoaderException {
+ assertEquals(RMIBindingLoader.BINDING_RMI, loader.getXMLType());
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ registry = createMock(LoaderRegistry.class);
+ loader = new RMIBindingLoader(registry);
+
+ parent = createMock(CompositeComponent.class);
+ reader = createMock(XMLStreamReader.class);
+ deploymentContext = createMock(DeploymentContext.class);
+ }
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/RMIBindingTestCase.java b/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/RMIBindingTestCase.java
new file mode 100644
index 0000000000..6dbb81437f
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/RMIBindingTestCase.java
@@ -0,0 +1,40 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * 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.
+ */
+package org.apache.tuscany.binding.rmi;
+
+import junit.framework.TestCase;
+
+public class RMIBindingTestCase extends TestCase {
+
+ public void testHost() {
+ RMIBinding binding = new RMIBinding();
+ binding.setHost("foo");
+ assertEquals("foo", binding.getHost());
+ }
+
+ public void testPort() {
+ RMIBinding binding = new RMIBinding();
+ binding.setPort("foo");
+ assertEquals("foo", binding.getPort());
+ }
+
+ public void testServiceName() {
+ RMIBinding binding = new RMIBinding();
+ binding.setServiceName("foo");
+ assertEquals("foo", binding.getServiceName());
+ }
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/RMIInvokerTestCase.java b/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/RMIInvokerTestCase.java
new file mode 100644
index 0000000000..72c0acacc4
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/RMIInvokerTestCase.java
@@ -0,0 +1,84 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * 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.
+ */
+package org.apache.tuscany.binding.rmi;
+
+import static org.easymock.EasyMock.expect;
+import static org.easymock.classextension.EasyMock.createMock;
+import static org.easymock.classextension.EasyMock.replay;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.rmi.Remote;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.host.rmi.RMIHost;
+import org.apache.tuscany.host.rmi.RMIHostException;
+import org.apache.tuscany.host.rmi.RMIHostRuntimeException;
+
+public class RMIInvokerTestCase extends TestCase {
+
+ public void testInvokeTarget() throws InvocationTargetException, RMIHostRuntimeException, RMIHostException, IllegalArgumentException,
+ IllegalAccessException, SecurityException, NoSuchMethodException {
+ Method method = Object.class.getDeclaredMethod("toString", new Class[] {});
+ RMIHost host = createMock(RMIHost.class);
+ expect(host.findService(null, null, null)).andReturn(new Remote() {
+ });
+ replay(host);
+ RMIInvoker invoker = new RMIInvoker(host, null, null, null, method);
+ assertNotNull(invoker.invokeTarget(new Object[] {}));
+ }
+
+// TODO: these don't seem to work
+// public void testInvokeTargetRMIHostException() throws InvocationTargetException, RMIHostRuntimeException, RMIHostException,
+// IllegalArgumentException, IllegalAccessException, SecurityException, NoSuchMethodException {
+// Method method = foo.class.getDeclaredMethod("bang", new Class[] {});
+// RMIHost host = createMock(RMIHost.class);
+// expect(host.findService(null, null, null)).andReturn(new foo());
+// replay(host);
+// try {
+// new RMIInvoker(host, null, null, null, method).invokeTarget(new Object[] {});
+// fail();
+// } catch (InvocationTargetException e) {
+// // expected
+// }
+// }
+//
+// public void testInvokeTargetIllegalAccessException() throws InvocationTargetException, RMIHostRuntimeException, RMIHostException,
+// IllegalArgumentException, IllegalAccessException, SecurityException, NoSuchMethodException {
+// Method method = foo.class.getDeclaredMethod("crash", new Class[] {});
+// RMIHost host = createMock(RMIHost.class);
+// expect(host.findService(null, null, null)).andReturn(new foo());
+// replay(host);
+// try {
+// new RMIInvoker(host, null, null, null, method).invokeTarget(new Object[] {});
+// fail();
+// } catch (InvocationTargetException e) {
+// // expected
+// }
+// }
+//
+// class foo implements Remote {
+// void crash() throws IllegalAccessException {
+// throw new IllegalAccessException();
+// }
+//
+// void bang() throws RMIHostException {
+// throw new RMIHostException();
+// }
+// }
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/RMIReferenceTestCase.java b/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/RMIReferenceTestCase.java
new file mode 100644
index 0000000000..5c935ec38a
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/RMIReferenceTestCase.java
@@ -0,0 +1,48 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * 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.
+ */
+package org.apache.tuscany.binding.rmi;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.spi.idl.java.JavaServiceContract;
+import org.apache.tuscany.spi.model.DataType;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.ServiceContract;
+
+public class RMIReferenceTestCase extends TestCase {
+
+ @SuppressWarnings("unchecked")
+ public void testCreateTargetInvoker() {
+ // TODO: this doesn't really test anything yet
+ RMIReference ref = new RMIReference(null, null, null, null, null, null, null, null);
+ ServiceContract contract = new JavaServiceContract();
+ contract.setInterfaceClass(String.class);
+ List l = new ArrayList();
+ l.add(new DataType(null, null));
+ DataType in = new DataType(null, l);
+ Operation operation = new Operation(null, in, null, null);
+ try {
+ ref.createTargetInvoker(contract, operation);
+ } catch (Exception e) {
+ // expected
+ }
+ }
+
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/RMIServiceTestCase.java b/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/RMIServiceTestCase.java
new file mode 100644
index 0000000000..1386cf2c72
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/RMIServiceTestCase.java
@@ -0,0 +1,53 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * 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.
+ */
+package org.apache.tuscany.binding.rmi;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.binding.rmi.host.RMIHostImpl;
+import org.apache.tuscany.host.rmi.RMIHostRuntimeException;
+import org.apache.tuscany.spi.wire.WireInvocationHandler;
+
+public class RMIServiceTestCase extends TestCase {
+
+ @SuppressWarnings("unchecked")
+ public void testGetPort() {
+ RMIService s = new RMIService(null, null, null, null, null, null, null, null);
+ assertEquals(0, s.getPort("0"));
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testGenerateRemoteInterface() {
+ RMIService s = new RMIService("foo27", null, null, null, null, null, null, null);
+ s.generateRemoteInterface(Runnable.class);
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testCreateRmiService() {
+ RMIService s = new RMIService("bla023", null, null, new RMIHostImpl(), null, "9996", "bla", Runnable.class) {
+ public WireInvocationHandler getHandler() {
+ return null;
+ }
+ };
+ s.start();
+ try {
+ s.stop();
+ } catch (RMIHostRuntimeException e) {
+ // expected
+ }
+ }
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/RemoteMethodHandlerTestCase.java b/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/RemoteMethodHandlerTestCase.java
new file mode 100644
index 0000000000..f5c9595aa3
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/RemoteMethodHandlerTestCase.java
@@ -0,0 +1,42 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * 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.
+ */
+package org.apache.tuscany.binding.rmi;
+
+import static org.easymock.EasyMock.expect;
+import static org.easymock.classextension.EasyMock.createMock;
+import static org.easymock.classextension.EasyMock.replay;
+
+import java.lang.reflect.Method;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.spi.wire.WireInvocationHandler;
+
+public class RemoteMethodHandlerTestCase extends TestCase {
+
+ public void testIntercept() throws SecurityException, NoSuchMethodException, Throwable {
+ WireInvocationHandler h2 = createMock(WireInvocationHandler.class);
+ Method method = Runnable.class.getDeclaredMethod("run", new Class[]{});
+ Object[] noArgs = new Object[]{};
+ expect(h2.invoke(method, noArgs)).andReturn("foo");
+ replay(h2);
+ RemoteMethodHandler handler = new RemoteMethodHandler(h2, Runnable.class);
+ Object o = handler.intercept(null, method, noArgs, null);
+ assertEquals("foo", o);
+ }
+
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/host/RMIHostImplTestCase.java b/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/host/RMIHostImplTestCase.java
new file mode 100644
index 0000000000..08f6172f3d
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/host/RMIHostImplTestCase.java
@@ -0,0 +1,76 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * 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.
+ */
+package org.apache.tuscany.binding.rmi.host;
+
+import java.rmi.Remote;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.host.rmi.RMIHostException;
+import org.apache.tuscany.host.rmi.RMIHostRuntimeException;
+
+public class RMIHostImplTestCase extends TestCase {
+
+ public void testInit() {
+ new RMIHostImpl().init();
+ }
+
+ public void testFindServiceBadHost() throws RMIHostRuntimeException, RMIHostException {
+ try {
+ new RMIHostImpl().findService(null, "0", null);
+ fail();
+ } catch (RMIHostRuntimeException e) {
+ // expected
+ }
+ }
+
+ public void testRegisterService1() throws RMIHostRuntimeException, RMIHostException {
+ RMIHostImpl host = new RMIHostImpl();
+ host.registerService("foo1", new MockRemote());
+ host.unregisterService("foo1");
+ }
+
+ public void testRegisterService2() throws RMIHostRuntimeException, RMIHostException {
+ RMIHostImpl host = new RMIHostImpl();
+ host.registerService("bar1", 9999, new MockRemote());
+ host.unregisterService("bar1", 9999);
+ }
+
+ public void testRegisterServiceAlreadyBound() throws RMIHostRuntimeException, RMIHostException {
+ RMIHostImpl host = new RMIHostImpl();
+ host.registerService("bar2", 9997, new MockRemote());
+ try {
+ host.registerService("bar2", 9997, new MockRemote());
+ } catch (RMIHostException e) {
+ // expected
+ host.unregisterService("bar2", 9997);
+ }
+ }
+
+ public void testUnRegisterService() throws RMIHostRuntimeException, RMIHostException {
+ RMIHostImpl host = new RMIHostImpl();
+ try {
+ host.unregisterService("bar3", 9998);
+ fail();
+ } catch (RMIHostException e) {
+ // expected
+ }
+ }
+
+ private static class MockRemote implements Remote {
+ }
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/resources/HelloWorldImpl.componentType b/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/resources/HelloWorldImpl.componentType
new file mode 100644
index 0000000000..a0beb4403d
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/resources/HelloWorldImpl.componentType
@@ -0,0 +1,27 @@
+<!--
+ * 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.
+-->
+
+<?xml version="1.0" encoding="ASCII"?>
+
+<componentType xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <service name="HelloWorldService">
+ <interface.java interface="helloworld.HelloWorldService"/>
+ </service>
+</componentType>
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/resources/HelloWorldRmiImpl.componentType b/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/resources/HelloWorldRmiImpl.componentType
new file mode 100644
index 0000000000..b0e0b007a6
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/resources/HelloWorldRmiImpl.componentType
@@ -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.
+-->
+<?xml version="1.0" encoding="ASCII"?>
+
+<componentType xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <service name="HelloWorldRmiService">
+ <interface.java interface="helloworld.HelloWorldRmiService"/>
+ </service>
+ <reference name="extService">
+ <interface.java interface="helloworld.HelloWorldService"/>
+ </reference>
+</componentType>
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/resources/META-INF/LICENSE.txt b/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/resources/META-INF/LICENSE.txt
new file mode 100644
index 0000000000..25d78feeac
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/resources/META-INF/LICENSE.txt
@@ -0,0 +1,1277 @@
+
+ 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 SUBCOMPONENTS:
+
+The Apache Tuscany distribution 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.
+
+===============================================================================
+
+For the Eclipse Modeling Framework component and the Celtix binding:
+
+Eclipse Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE
+PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF
+THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+a) in the case of the initial Contributor, the initial code and
+documentation distributed under this Agreement, and
+b) in the case of each subsequent Contributor:
+
+i) changes to the Program, and
+
+ii) additions to the Program;
+
+where such changes and/or additions to the Program originate from and
+are distributed by that particular Contributor. A Contribution
+'originates' from a Contributor if it was added to the Program by such
+Contributor itself or anyone acting on such Contributor's behalf.
+Contributions do not include additions to the Program which: (i) are
+separate modules of software distributed in conjunction with the
+Program under their own license agreement, and (ii) are not derivative
+works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor
+which are necessarily infringed by the use or sale of its Contribution
+alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this
+Agreement.
+
+"Recipient" means anyone who receives the Program under this
+Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+a) Subject to the terms of this Agreement, each Contributor hereby
+grants Recipient a non-exclusive, worldwide, royalty-free copyright
+license to reproduce, prepare derivative works of, publicly display,
+publicly perform, distribute and sublicense the Contribution of such
+Contributor, if any, and such derivative works, in source code and
+object code form.
+
+b) Subject to the terms of this Agreement, each Contributor hereby
+grants Recipient a non-exclusive, worldwide, royalty-free patent
+license under Licensed Patents to make, use, sell, offer to sell,
+import and otherwise transfer the Contribution of such Contributor, if
+any, in source code and object code form. This patent license shall
+apply to the combination of the Contribution and the Program if, at
+the time the Contribution is added by the Contributor, such addition
+of the Contribution causes such combination to be covered by the
+Licensed Patents. The patent license shall not apply to any other
+combinations which include the Contribution. No hardware per se is
+licensed hereunder.
+
+c) Recipient understands that although each Contributor grants the
+licenses to its Contributions set forth herein, no assurances are
+provided by any Contributor that the Program does not infringe the
+patent or other intellectual property rights of any other entity. Each
+Contributor disclaims any liability to Recipient for claims brought by
+any other entity based on infringement of intellectual property rights
+or otherwise. As a condition to exercising the rights and licenses
+granted hereunder, each Recipient hereby assumes sole responsibility
+to secure any other intellectual property rights needed, if any. For
+example, if a third party patent license is required to allow
+Recipient to distribute the Program, it is Recipient's responsibility
+to acquire that license before distributing the Program.
+
+d) Each Contributor represents that to its knowledge it has sufficient
+copyright rights in its Contribution, if any, to grant the copyright
+license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form
+under its own license agreement, provided that:
+
+a) it complies with the terms and conditions of this Agreement; and
+
+b) its license agreement:
+
+i) effectively disclaims on behalf of all Contributors all warranties
+and conditions, express and implied, including warranties or
+conditions of title and non-infringement, and implied warranties or
+conditions of merchantability and fitness for a particular purpose;
+
+ii) effectively excludes on behalf of all Contributors all liability
+for damages, including direct, indirect, special, incidental and
+consequential damages, such as lost profits;
+
+iii) states that any provisions which differ from this Agreement are
+offered by that Contributor alone and not by any other party; and
+
+iv) states that source code for the Program is available from such
+Contributor, and informs licensees how to obtain it in a reasonable
+manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+a) it must be made available under this Agreement; and
+
+b) a copy of this Agreement must be included with each copy of the
+Program.
+
+Contributors may not remove or alter any copyright notices contained
+within the Program.
+
+Each Contributor must identify itself as the originator of its
+Contribution, if any, in a manner that reasonably allows subsequent
+Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain
+responsibilities with respect to end users, business partners and the
+like. While this license is intended to facilitate the commercial use
+of the Program, the Contributor who includes the Program in a
+commercial product offering should do so in a manner which does not
+create potential liability for other Contributors. Therefore, if a
+Contributor includes the Program in a commercial product offering,
+such Contributor ("Commercial Contributor") hereby agrees to defend
+and indemnify every other Contributor ("Indemnified Contributor")
+against any losses, damages and costs (collectively "Losses") arising
+from claims, lawsuits and other legal actions brought by a third party
+against the Indemnified Contributor to the extent caused by the acts
+or omissions of such Commercial Contributor in connection with its
+distribution of the Program in a commercial product offering. The
+obligations in this section do not apply to any claims or Losses
+relating to any actual or alleged intellectual property infringement.
+In order to qualify, an Indemnified Contributor must: a) promptly
+notify the Commercial Contributor in writing of such claim, and b)
+allow the Commercial Contributor to control, and cooperate with the
+Commercial Contributor in, the defense and any related settlement
+negotiations. The Indemnified Contributor may participate in any such
+claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial
+product offering, Product X. That Contributor is then a Commercial
+Contributor. If that Commercial Contributor then makes performance
+claims, or offers warranties related to Product X, those performance
+claims and warranties are such Commercial Contributor's responsibility
+alone. Under this section, the Commercial Contributor would have to
+defend claims against the other Contributors related to those
+performance claims and warranties, and if a court requires any other
+Contributor to pay any damages as a result, the Commercial Contributor
+must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS
+PROVIDED 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. Each Recipient is solely
+responsible for determining the appropriateness of using and
+distributing the Program and assumes all risks associated with its
+exercise of rights under this Agreement , including but not limited to
+the risks and costs of program errors, compliance with applicable
+laws, damage to or loss of data, programs or equipment, and
+unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR
+ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING
+WITHOUT LIMITATION LOST PROFITS), 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 OR
+DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
+HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under
+applicable law, it shall not affect the validity or enforceability of
+the remainder of the terms of this Agreement, and without further
+action by the parties hereto, such provision shall be reformed to the
+minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against any entity
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+the Program itself (excluding combinations of the Program with other
+software or hardware) infringes such Recipient's patent(s), then such
+Recipient's rights granted under Section 2(b) shall terminate as of
+the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it
+fails to comply with any of the material terms or conditions of this
+Agreement and does not cure such failure in a reasonable period of
+time after becoming aware of such noncompliance. If all Recipient's
+rights under this Agreement terminate, Recipient agrees to cease use
+and distribution of the Program as soon as reasonably practicable.
+However, Recipient's obligations under this Agreement and any licenses
+granted by Recipient relating to the Program shall continue and
+survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement,
+but in order to avoid inconsistency the Agreement is copyrighted and
+may only be modified in the following manner. The Agreement Steward
+reserves the right to publish new versions (including revisions) of
+this Agreement from time to time. No one other than the Agreement
+Steward has the right to modify this Agreement. The Eclipse Foundation
+is the initial Agreement Steward. The Eclipse Foundation may assign
+the responsibility to serve as the Agreement Steward to a suitable
+separate entity. Each new version of the Agreement will be given a
+distinguishing version number. The Program (including Contributions)
+may always be distributed subject to the version of the Agreement
+under which it was received. In addition, after a new version of the
+Agreement is published, Contributor may elect to distribute the
+Program (including its Contributions) under the new version. Except as
+expressly stated in Sections 2(a) and 2(b) above, Recipient receives
+no rights or licenses to the intellectual property of any Contributor
+under this Agreement, whether expressly, by implication, estoppel or
+otherwise. All rights in the Program not expressly granted under this
+Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and
+the intellectual property laws of the United States of America. No
+party to this Agreement will bring a legal action under this Agreement
+more than one year after the cause of action arose. Each party waives
+its rights to a jury trial in any resulting litigation.
+
+===============================================================================
+
+For the Rhino JavaScript container component:
+
+Mozilla Public License 1.1 (MPL 1.1)
+
+1. Definitions.
+
+ 1.0.1. "Commercial Use" means distribution or otherwise making the
+Covered Code available to a third party.
+
+ 1.1. "Contributor" means each entity that creates or contributes to
+the creation of Modifications.
+
+ 1.2. "Contributor Version" means the combination of the Original Code,
+prior Modifications used by a Contributor, and the Modifications made by that
+particular Contributor.
+
+ 1.3. "Covered Code" means the Original Code or Modifications or the
+combination of the Original Code and Modifications, in each case including
+portions thereof.
+
+ 1.4. "Electronic Distribution Mechanism" means a mechanism generally
+accepted in the software development community for the electronic transfer of
+data.
+
+ 1.5. "Executable" means Covered Code in any form other than Source
+Code.
+
+ 1.6. "Initial Developer" means the individual or entity identified as
+the Initial Developer in the Source Code notice required by Exhibit A.
+
+ 1.7. "Larger Work" means a work which combines Covered Code or
+portions thereof with code not governed by the terms of this License.
+
+ 1.8. "License" means this document.
+
+ 1.8.1. "Licensable" means having the right to grant, to the maximum
+extent possible, whether at the time of the initial grant or subsequently
+acquired, any and all of the rights conveyed herein.
+
+ 1.9. "Modifications" means any addition to or deletion from the
+substance or structure of either the Original Code or any previous
+Modifications. When Covered Code is released as a series of files, a
+Modification is:
+ A. Any addition to or deletion from the contents of a file
+containing Original Code or previous Modifications.
+
+ B. Any new file that contains any part of the Original Code or
+previous Modifications.
+
+ 1.10. "Original Code" means Source Code of computer software code
+which is described in the Source Code notice required by Exhibit A as Original
+Code, and which, at the time of its release under this License is not already
+Covered Code governed by this License.
+
+ 1.10.1. "Patent Claims" means any patent claim(s), now owned or
+hereafter acquired, including without limitation, method, process, and
+apparatus claims, in any patent Licensable by grantor.
+
+ 1.11. "Source Code" means the preferred form of the Covered Code for
+making modifications to it, including all modules it contains, plus any
+associated interface definition files, scripts used to control compilation and
+installation of an Executable, or source code differential comparisons against
+either the Original Code or another well known, available Covered Code of the
+Contributor's choice. The Source Code can be in a compressed or archival form,
+provided the appropriate decompression or de-archiving software is widely
+available for no charge.
+
+ 1.12. "You" (or "Your") means an individual or a legal entity
+exercising rights under, and complying with all of the terms of, this License
+or a future version of this License issued under Section 6.1. For legal
+entities, "You" includes any entity which controls, is controlled by, or is
+under common control with You. For purposes of this definition, "control"
+means (a) the power, direct or indirect, to cause the direction or management
+of such entity, whether by contract or otherwise, or (b) ownership of more
+than fifty percent (50%) of the outstanding shares or beneficial ownership of
+such entity.
+
+2. Source Code License.
+
+ 2.1. The Initial Developer Grant.
+ The Initial Developer hereby grants You a world-wide, royalty-free,
+non-exclusive license, subject to third party intellectual property claims:
+ (a) under intellectual property rights (other than patent or
+trademark) Licensable by Initial Developer to use, reproduce, modify, display,
+perform, sublicense and distribute the Original Code (or portions thereof)
+with or without Modifications, and/or as part of a Larger Work; and
+
+ (b) under Patents Claims infringed by the making, using or selling
+of Original Code, to make, have made, use, practice, sell, and offer for sale,
+and/or otherwise dispose of the Original Code (or portions thereof).
+ (c) the licenses granted in this Section 2.1(a) and
+(b) are effective on the date Initial Developer first distributes Original
+Code under the terms of this License.
+
+ (d) Notwithstanding Section 2.1(b) above, no patent license is
+granted: 1) for code that You delete from the Original Code; 2) separate from
+the Original Code; or 3) for infringements caused by: i) the modification of
+the Original Code or ii) the combination of the Original Code with other
+software or devices.
+
+ 2.2. Contributor Grant.
+ Subject to third party intellectual property claims, each Contributor
+hereby grants You a world-wide, royalty-free, non-exclusive license
+
+ (a) under intellectual property rights (other than patent or
+trademark) Licensable by Contributor, to use, reproduce, modify, display,
+perform, sublicense and distribute the Modifications created by such
+Contributor (or portions thereof) either on an unmodified basis, with other
+Modifications, as Covered Code and/or as part of a Larger Work; and
+
+ (b) under Patent Claims infringed by the making, using, or selling
+of Modifications made by that Contributor either alone and/or in combination
+with its Contributor Version (or portions of such combination), to make, use,
+sell, offer for sale, have made, and/or otherwise dispose of: 1) Modifications
+made by that Contributor (or portions thereof); and 2) the combination of
+Modifications made by that Contributor with its Contributor Version (or
+portions of such combination).
+
+ (c) the licenses granted in Sections 2.2(a) and 2.2(b) are
+effective on the date Contributor first makes Commercial Use of the Covered
+Code.
+
+ (d) Notwithstanding Section 2.2(b) above, no patent license is
+granted: 1) for any code that Contributor has deleted from the Contributor
+Version; 2) separate from the Contributor Version; 3) for infringements
+caused by: i) third party modifications of Contributor Version or ii) the
+combination of Modifications made by that Contributor with other software
+(except as part of the Contributor Version) or other devices; or 4) under
+Patent Claims infringed by Covered Code in the absence of Modifications made
+by that Contributor.
+
+
+3. Distribution Obligations.
+
+ 3.1. Application of License.
+ The Modifications which You create or to which You contribute are
+governed by the terms of this License, including without limitation Section
+2.2. The Source Code version of Covered Code may be distributed only under the
+terms of this License or a future version of this License released under
+Section 6.1, and You must include a copy of this License with every copy of
+the Source Code You distribute. You may not offer or impose any terms on any
+Source Code version that alters or restricts the applicable version of this
+License or the recipients' rights hereunder. However, You may include an
+additional document offering the additional rights described in Section 3.5.
+
+ 3.2. Availability of Source Code.
+ Any Modification which You create or to which You contribute must be
+made available in Source Code form under the terms of this License either on
+the same media as an Executable version or via an accepted Electronic
+Distribution Mechanism to anyone to whom you made an Executable version
+available; and if made available via Electronic Distribution Mechanism, must
+remain available for at least twelve (12) months after the date it initially
+became available, or at least six (6) months after a subsequent version of
+that particular Modification has been made available to such recipients. You
+are responsible for ensuring that the Source Code version remains available
+even if the Electronic Distribution Mechanism is maintained by a third party.
+
+ 3.3. Description of Modifications.
+ You must cause all Covered Code to which You contribute to contain a
+file documenting the changes You made to create that Covered Code and the date
+of any change. You must include a prominent statement that the Modification is
+derived, directly or indirectly, from Original Code provided by the Initial
+Developer and including the name of the Initial Developer in (a) the Source
+Code, and (b) in any notice in an Executable version or related documentation
+in which You describe the origin or ownership of the Covered Code.
+
+ 3.4. Intellectual Property Matters
+ (a) Third Party Claims.
+ If Contributor has knowledge that a license under a third party's
+intellectual property rights is required to exercise the rights granted by
+such Contributor under Sections 2.1 or 2.2, Contributor must include a text
+file with the Source Code distribution titled "LEGAL" which describes the
+claim and the party making the claim in sufficient detail that a recipient
+will know whom to contact. If Contributor obtains such knowledge after the
+Modification is made available as described in Section 3.2, Contributor shall
+promptly modify the LEGAL file in all copies Contributor makes available
+thereafter and shall take other steps (such as notifying appropriate mailing
+lists or newsgroups) reasonably calculated to inform those who received the
+Covered Code that new knowledge has been obtained.
+
+ (b) Contributor APIs.
+ If Contributor's Modifications include an application programming
+interface and Contributor has knowledge of patent licenses which are
+reasonably necessary to implement that API, Contributor must also include this
+information in the LEGAL file.
+
+ (c) Representations.
+ Contributor represents that, except as disclosed pursuant to
+Section 3.4(a) above, Contributor believes that Contributor's Modifications
+are Contributor's original creation(s) and/or Contributor has sufficient
+rights to grant the rights conveyed by this License.
+
+
+ 3.5. Required Notices.
+ You must duplicate the notice in Exhibit A in each file of the Source
+Code. If it is not possible to put such notice in a particular Source Code
+file due to its structure, then You must include such notice in a location
+(such as a relevant directory) where a user would be likely to look for such a
+notice. If You created one or more Modification(s) You may add your name as a
+Contributor to the notice described in Exhibit A. You must also duplicate
+this License in any documentation for the Source Code where You describe
+recipients' rights or ownership rights relating to Covered Code. You may
+choose to offer, and to charge a fee for, warranty, support, indemnity or
+liability obligations to one or more recipients of Covered Code. However, You
+may do so only on Your own behalf, and not on behalf of the Initial Developer
+or any Contributor. You must make it absolutely clear than any such warranty,
+support, indemnity or liability obligation is offered by You alone, and You
+hereby agree to indemnify the Initial Developer and every Contributor for any
+liability incurred by the Initial Developer or such Contributor as a result of
+warranty, support, indemnity or liability terms You offer.
+
+ 3.6. Distribution of Executable Versions.
+ You may distribute Covered Code in Executable form only if the
+requirements of Section 3.1-3.5 have been met for that Covered Code, and if
+You include a notice stating that the Source Code version of the Covered Code
+is available under the terms of this License, including a description of how
+and where You have fulfilled the obligations of Section 3.2. The notice must
+be conspicuously included in any notice in an Executable version, related
+documentation or collateral in which You describe recipients' rights relating
+to the Covered Code. You may distribute the Executable version of Covered Code
+or ownership rights under a license of Your choice, which may contain terms
+different from this License, provided that You are in compliance with the
+terms of this License and that the license for the Executable version does not
+attempt to limit or alter the recipient's rights in the Source Code version
+from the rights set forth in this License. If You distribute the Executable
+version under a different license You must make it absolutely clear that any
+terms which differ from this License are offered by You alone, not by the
+Initial Developer or any Contributor. You hereby agree to indemnify the
+Initial Developer and every Contributor for any liability incurred by the
+Initial Developer or such Contributor as a result of any such terms You offer.
+
+ 3.7. Larger Works.
+ You may create a Larger Work by combining Covered Code with other code
+not governed by the terms of this License and distribute the Larger Work as a
+single product. In such a case, You must make sure the requirements of this
+License are fulfilled for the Covered Code.
+
+4. Inability to Comply Due to Statute or Regulation.
+
+ If it is impossible for You to comply with any of the terms of this
+License with respect to some or all of the Covered Code due to statute,
+judicial order, or regulation then You must: (a) comply with the terms of this
+License to the maximum extent possible; and (b) describe the limitations and
+the code they affect. Such description must be included in the LEGAL file
+described in Section 3.4 and must be included with all distributions of the
+Source Code. Except to the extent prohibited by statute or regulation, such
+description must be sufficiently detailed for a recipient of ordinary skill to
+be able to understand it.
+
+5. Application of this License.
+
+ This License applies to code to which the Initial Developer has attached
+the notice in Exhibit A and to related Covered Code.
+
+6. Versions of the License.
+
+ 6.1. New Versions.
+ Netscape Communications Corporation ("Netscape") may publish revised
+and/or new versions of the License from time to time. Each version will be
+given a distinguishing version number.
+
+ 6.2. Effect of New Versions.
+ Once Covered Code has been published under a particular version of the
+License, You may always continue to use it under the terms of that version.
+You may also choose to use such Covered Code under the terms of any subsequent
+version of the License published by Netscape. No one other than Netscape has
+the right to modify the terms applicable to Covered Code created under this
+License.
+
+ 6.3. Derivative Works.
+ If You create or use a modified version of this License (which you may
+only do in order to apply it to code which is not already Covered Code
+governed by this License), You must (a) rename Your license so that the
+phrases "Mozilla", "MOZILLAPL", "MOZPL", "Netscape", "MPL", "NPL" or
+any confusingly similar phrase do not appear in your license (except to note
+that your license differs from this License) and (b) otherwise make it clear
+that Your version of the license contains terms which differ from the Mozilla
+Public License and Netscape Public License. (Filling in the name of the
+Initial Developer, Original Code or Contributor in the notice described in
+Exhibit A shall not of themselves be deemed to be modifications of this
+License.)
+
+7. DISCLAIMER OF WARRANTY.
+
+ COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT
+LIMITATION, WARRANTIES THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE,
+FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE
+QUALITY AND PERFORMANCE OF THE COVERED CODE IS WITH YOU. SHOULD ANY COVERED
+CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE INITIAL DEVELOPER OR ANY
+OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY SERVICING, REPAIR OR
+CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS
+LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS
+DISCLAIMER.
+
+8. TERMINATION.
+
+ 8.1. This License and the rights granted hereunder will terminate
+automatically if You fail to comply with terms herein and fail to cure such
+breach within 30 days of becoming aware of the breach. All sublicenses to the
+Covered Code which are properly granted shall survive any termination of this
+License. Provisions which, by their nature, must remain in effect beyond the
+termination of this License shall survive.
+
+ 8.2. If You initiate litigation by asserting a patent infringement
+claim (excluding declatory judgment actions) against Initial Developer or a
+Contributor (the Initial Developer or Contributor against whom You file such
+action is referred to as "Participant") alleging that:
+
+ (a) such Participant's Contributor Version directly or indirectly
+infringes any patent, then any and all rights granted by such Participant to
+You under Sections 2.1 and/or 2.2 of this License shall, upon 60 days notice
+from Participant terminate prospectively, unless if within 60 days after
+receipt of notice You either: (i) agree in writing to pay Participant a
+mutually agreeable reasonable royalty for Your past and future use of
+Modifications made by such Participant, or (ii) withdraw Your litigation claim
+with respect to the Contributor Version against such Participant. If within
+60 days of notice, a reasonable royalty and payment arrangement are not
+mutually agreed upon in writing by the parties or the litigation claim is not
+withdrawn, the rights granted by Participant to You under Sections 2.1 and/or
+2.2 automatically terminate at the expiration of the 60 day notice period
+specified above.
+
+ (b) any software, hardware, or device, other than such Participant's
+Contributor Version, directly or indirectly infringes any patent, then any
+rights granted to You by such Participant under Sections 2.1(b) and 2.2(b) are
+revoked effective as of the date You first made, used, sold, distributed, or
+had made, Modifications made by that Participant.
+
+ 8.3. If You assert a patent infringement claim against Participant
+alleging that such Participant's Contributor Version directly or indirectly
+infringes any patent where such claim is resolved (such as by license or
+settlement) prior to the initiation of patent infringement litigation, then
+the reasonable value of the licenses granted by such Participant under
+Sections 2.1 or 2.2 shall be taken into account in determining the amount or
+value of any payment or license.
+
+ 8.4. In the event of termination under Sections 8.1 or 8.2 above, all
+end user license agreements (excluding distributors and resellers) which have
+been validly granted by You or any distributor hereunder prior to termination
+shall survive termination.
+
+9. LIMITATION OF LIABILITY.
+
+ UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT
+(INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL
+DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED CODE, OR ANY
+SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR ANY INDIRECT,
+SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING,
+WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL, WORK STOPPAGE, COMPUTER
+FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL DAMAGES OR LOSSES,
+EVEN IF SUCH PARTY SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF SUCH
+DAMAGES. THIS LIMITATION OF LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH
+OR PERSONAL INJURY RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT
+APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE
+EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THIS
+EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU.
+
+10. U.S. GOVERNMENT END USERS.
+
+ The Covered Code is a "commercial item," as that term is defined in 48
+C.F.R. 2.101 (Oct. 1995), consisting of "commercial computer software" and
+"commercial computer software documentation," as such terms are used in 48
+C.F.R. 12.212 (Sept. 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R.
+227.7202-1 through 227.7202-4 (June 1995), all U.S. Government End Users
+acquire Covered Code with only those rights set forth herein.
+
+11. MISCELLANEOUS.
+
+ This License represents the complete agreement concerning subject matter
+hereof. If any provision of this License is held to be unenforceable, such
+provision shall be reformed only to the extent necessary to make it
+enforceable. This License shall be governed by California law provisions
+(except to the extent applicable law, if any, provides otherwise), excluding
+its conflict-of-law provisions. With respect to disputes in which at least one
+party is a citizen of, or an entity chartered or registered to do business in
+the United States of America, any litigation relating to this License shall be
+subject to the jurisdiction of the Federal Courts of the Northern District of
+California, with venue lying in Santa Clara County, California, with the
+losing party responsible for costs, including without limitation, court costs
+and reasonable attorneys' fees and expenses. The application of the United
+Nations Convention on Contracts for the International Sale of Goods is
+expressly excluded. Any law or regulation which provides that the language of
+a contract shall be construed against the drafter shall not apply to this
+License.
+
+12. RESPONSIBILITY FOR CLAIMS.
+
+ As between Initial Developer and the Contributors, each party is
+responsible for claims and damages arising, directly or indirectly, out of its
+utilization of rights under this License and You agree to work with Initial
+Developer and Contributors to distribute such responsibility on an equitable
+basis. Nothing herein is intended or shall be deemed to constitute any
+admission of liability.
+
+13. MULTIPLE-LICENSED CODE.
+
+ Initial Developer may designate portions of the Covered Code as
+Multiple-Licensed. Multiple-Licensed means that the Initial Developer permits
+you to utilize portions of the Covered Code under Your choice of the MPL or
+the alternative licenses, if any, specified by the Initial Developer in the
+file described in Exhibit A.
+
+
+EXHIBIT A -Mozilla Public License.
+
+ ``The contents of this file are subject to the Mozilla Public License
+Version 1.1 (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.mozilla.org/MPL/
+
+ Software distributed under the License is distributed on an "AS IS"
+basis, WITHOUT WARRANTY OF
+ ANY KIND, either express or implied. See the License for the specific
+language governing rights and
+ limitations under the License.
+
+ The Original Code is ______________________________________.
+
+ The Initial Developer of the Original Code is ________________________.
+Portions created by
+ ______________________ are Copyright (C) ______
+_______________________. All Rights
+ Reserved.
+
+ Contributor(s): ______________________________________.
+
+ Alternatively, the contents of this file may be used under the terms of
+the _____ license (the [___] License), in which case the provisions of
+[______] License are applicable instead of those above. If you wish to allow
+use of your version of this file only under the terms of the [____] License
+and not to allow others to use your version of this file under the MPL,
+indicate your decision by deleting the provisions above and replace them
+with the notice and other provisions required by the [___] License. If you do
+not delete the provisions above, a recipient may use your version of this file
+under either the MPL or the [___] License."
+
+ [NOTE: The text of this Exhibit A may differ slightly from the text of
+the notices in the Source Code files of the Original Code. You should use the
+text of this Exhibit A rather than the text found in the Original Code Source
+Code for Your Modifications.]
+
+
+===============================================================================
+
+For the JAX-WS Reference Implementation component:
+
+COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
+
+
+ 1. Definitions.
+
+ 1.1. "Contributor" means each individual or entity that
+ creates or contributes to the creation of Modifications.
+
+ 1.2. "Contributor Version" means the combination of the
+ Original Software, prior Modifications used by a
+ Contributor (if any), and the Modifications made by that
+ particular Contributor.
+
+ 1.3. "Covered Software" means (a) the Original Software, or
+ (b) Modifications, or (c) the combination of files
+ containing Original Software with files containing
+ Modifications, in each case including portions thereof.
+
+ 1.4. "Executable" means the Covered Software in any form
+ other than Source Code.
+
+ 1.5. "Initial Developer" means the individual or entity
+ that first makes Original Software available under this
+ License.
+
+ 1.6. "Larger Work" means a work which combines Covered
+ Software or portions thereof with code not governed by the
+ terms of this License.
+
+ 1.7. "License" means this document.
+
+ 1.8. "Licensable" means having the right to grant, to the
+ maximum extent possible, whether at the time of the initial
+ grant or subsequently acquired, any and all of the rights
+ conveyed herein.
+
+ 1.9. "Modifications" means the Source Code and Executable
+ form of any of the following:
+
+ A. Any file that results from an addition to,
+ deletion from or modification of the contents of a
+ file containing Original Software or previous
+ Modifications;
+
+ B. Any new file that contains any part of the
+ Original Software or previous Modification; or
+
+ C. Any new file that is contributed or otherwise made
+ available under the terms of this License.
+
+ 1.10. "Original Software" means the Source Code and
+ Executable form of computer software code that is
+ originally released under this License.
+
+ 1.11. "Patent Claims" means any patent claim(s), now owned
+ or hereafter acquired, including without limitation,
+ method, process, and apparatus claims, in any patent
+ Licensable by grantor.
+
+ 1.12. "Source Code" means (a) the common form of computer
+ software code in which modifications are made and (b)
+ associated documentation included in or with such code.
+
+ 1.13. "You" (or "Your") means an individual or a legal
+ entity exercising rights under, and complying with all of
+ the terms of, this License. For legal entities, "You"
+ includes any entity which controls, is controlled by, or is
+ under common control with You. For purposes of this
+ definition, "control" means (a) the power, direct or
+ indirect, to cause the direction or management of such
+ entity, whether by contract or otherwise, or (b) ownership
+ of more than fifty percent (50%) of the outstanding shares
+ or beneficial ownership of such entity.
+
+ 2. License Grants.
+
+ 2.1. The Initial Developer Grant.
+
+ Conditioned upon Your compliance with Section 3.1 below and
+ subject to third party intellectual property claims, the
+ Initial Developer hereby grants You a world-wide,
+ royalty-free, non-exclusive license:
+
+ (a) under intellectual property rights (other than
+ patent or trademark) Licensable by Initial Developer,
+ to use, reproduce, modify, display, perform,
+ sublicense and distribute the Original Software (or
+ portions thereof), with or without Modifications,
+ and/or as part of a Larger Work; and
+
+ (b) under Patent Claims infringed by the making,
+ using or selling of Original Software, to make, have
+ made, use, practice, sell, and offer for sale, and/or
+ otherwise dispose of the Original Software (or
+ portions thereof).
+
+ (c) The licenses granted in Sections 2.1(a) and (b)
+ are effective on the date Initial Developer first
+ distributes or otherwise makes the Original Software
+ available to a third party under the terms of this
+ License.
+
+ (d) Notwithstanding Section 2.1(b) above, no patent
+ license is granted: (1) for code that You delete from
+ the Original Software, or (2) for infringements
+ caused by: (i) the modification of the Original
+ Software, or (ii) the combination of the Original
+ Software with other software or devices.
+
+ 2.2. Contributor Grant.
+
+ Conditioned upon Your compliance with Section 3.1 below and
+ subject to third party intellectual property claims, each
+ Contributor hereby grants You a world-wide, royalty-free,
+ non-exclusive license:
+
+ (a) under intellectual property rights (other than
+ patent or trademark) Licensable by Contributor to
+ use, reproduce, modify, display, perform, sublicense
+ and distribute the Modifications created by such
+ Contributor (or portions thereof), either on an
+ unmodified basis, with other Modifications, as
+ Covered Software and/or as part of a Larger Work; and
+
+
+ (b) under Patent Claims infringed by the making,
+ using, or selling of Modifications made by that
+ Contributor either alone and/or in combination with
+ its Contributor Version (or portions of such
+ combination), to make, use, sell, offer for sale,
+ have made, and/or otherwise dispose of: (1)
+ Modifications made by that Contributor (or portions
+ thereof); and (2) the combination of Modifications
+ made by that Contributor with its Contributor Version
+ (or portions of such combination).
+
+ (c) The licenses granted in Sections 2.2(a) and
+ 2.2(b) are effective on the date Contributor first
+ distributes or otherwise makes the Modifications
+ available to a third party.
+
+ (d) Notwithstanding Section 2.2(b) above, no patent
+ license is granted: (1) for any code that Contributor
+ has deleted from the Contributor Version; (2) for
+ infringements caused by: (i) third party
+ modifications of Contributor Version, or (ii) the
+ combination of Modifications made by that Contributor
+ with other software (except as part of the
+ Contributor Version) or other devices; or (3) under
+ Patent Claims infringed by Covered Software in the
+ absence of Modifications made by that Contributor.
+
+ 3. Distribution Obligations.
+
+ 3.1. Availability of Source Code.
+
+ Any Covered Software that You distribute or otherwise make
+ available in Executable form must also be made available in
+ Source Code form and that Source Code form must be
+ distributed only under the terms of this License. You must
+ include a copy of this License with every copy of the
+ Source Code form of the Covered Software You distribute or
+ otherwise make available. You must inform recipients of any
+ such Covered Software in Executable form as to how they can
+ obtain such Covered Software in Source Code form in a
+ reasonable manner on or through a medium customarily used
+ for software exchange.
+
+ 3.2. Modifications.
+
+ The Modifications that You create or to which You
+ contribute are governed by the terms of this License. You
+ represent that You believe Your Modifications are Your
+ original creation(s) and/or You have sufficient rights to
+ grant the rights conveyed by this License.
+
+ 3.3. Required Notices.
+
+ You must include a notice in each of Your Modifications
+ that identifies You as the Contributor of the Modification.
+ You may not remove or alter any copyright, patent or
+ trademark notices contained within the Covered Software, or
+ any notices of licensing or any descriptive text giving
+ attribution to any Contributor or the Initial Developer.
+
+ 3.4. Application of Additional Terms.
+
+ You may not offer or impose any terms on any Covered
+ Software in Source Code form that alters or restricts the
+ applicable version of this License or the recipients'
+ rights hereunder. You may choose to offer, and to charge a
+ fee for, warranty, support, indemnity or liability
+ obligations to one or more recipients of Covered Software.
+ However, you may do so only on Your own behalf, and not on
+ behalf of the Initial Developer or any Contributor. You
+ must make it absolutely clear that any such warranty,
+ support, indemnity or liability obligation is offered by
+ You alone, and You hereby agree to indemnify the Initial
+ Developer and every Contributor for any liability incurred
+ by the Initial Developer or such Contributor as a result of
+ warranty, support, indemnity or liability terms You offer.
+
+
+ 3.5. Distribution of Executable Versions.
+
+ You may distribute the Executable form of the Covered
+ Software under the terms of this License or under the terms
+ of a license of Your choice, which may contain terms
+ different from this License, provided that You are in
+ compliance with the terms of this License and that the
+ license for the Executable form does not attempt to limit
+ or alter the recipient's rights in the Source Code form
+ from the rights set forth in this License. If You
+ distribute the Covered Software in Executable form under a
+ different license, You must make it absolutely clear that
+ any terms which differ from this License are offered by You
+ alone, not by the Initial Developer or Contributor. You
+ hereby agree to indemnify the Initial Developer and every
+ Contributor for any liability incurred by the Initial
+ Developer or such Contributor as a result of any such terms
+ You offer.
+
+ 3.6. Larger Works.
+
+ You may create a Larger Work by combining Covered Software
+ with other code not governed by the terms of this License
+ and distribute the Larger Work as a single product. In such
+ a case, You must make sure the requirements of this License
+ are fulfilled for the Covered Software.
+
+ 4. Versions of the License.
+
+ 4.1. New Versions.
+
+ Sun Microsystems, Inc. is the initial license steward and
+ may publish revised and/or new versions of this License
+ from time to time. Each version will be given a
+ distinguishing version number. Except as provided in
+ Section 4.3, no one other than the license steward has the
+ right to modify this License.
+
+ 4.2. Effect of New Versions.
+
+ You may always continue to use, distribute or otherwise
+ make the Covered Software available under the terms of the
+ version of the License under which You originally received
+ the Covered Software. If the Initial Developer includes a
+ notice in the Original Software prohibiting it from being
+ distributed or otherwise made available under any
+ subsequent version of the License, You must distribute and
+ make the Covered Software available under the terms of the
+ version of the License under which You originally received
+ the Covered Software. Otherwise, You may also choose to
+ use, distribute or otherwise make the Covered Software
+ available under the terms of any subsequent version of the
+ License published by the license steward.
+
+ 4.3. Modified Versions.
+
+ When You are an Initial Developer and You want to create a
+ new license for Your Original Software, You may create and
+ use a modified version of this License if You: (a) rename
+ the license and remove any references to the name of the
+ license steward (except to note that the license differs
+ from this License); and (b) otherwise make it clear that
+ the license contains terms which differ from this License.
+
+
+ 5. DISCLAIMER OF WARRANTY.
+
+ COVERED SOFTWARE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS"
+ BASIS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
+ INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE COVERED
+ SOFTWARE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR
+ PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND
+ PERFORMANCE OF THE COVERED SOFTWARE IS WITH YOU. SHOULD ANY
+ COVERED SOFTWARE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE
+ INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF
+ ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF
+ WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF
+ ANY COVERED SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS
+ DISCLAIMER.
+
+ 6. TERMINATION.
+
+ 6.1. This License and the rights granted hereunder will
+ terminate automatically if You fail to comply with terms
+ herein and fail to cure such breach within 30 days of
+ becoming aware of the breach. Provisions which, by their
+ nature, must remain in effect beyond the termination of
+ this License shall survive.
+
+ 6.2. If You assert a patent infringement claim (excluding
+ declaratory judgment actions) against Initial Developer or
+ a Contributor (the Initial Developer or Contributor against
+ whom You assert such claim is referred to as "Participant")
+ alleging that the Participant Software (meaning the
+ Contributor Version where the Participant is a Contributor
+ or the Original Software where the Participant is the
+ Initial Developer) directly or indirectly infringes any
+ patent, then any and all rights granted directly or
+ indirectly to You by such Participant, the Initial
+ Developer (if the Initial Developer is not the Participant)
+ and all Contributors under Sections 2.1 and/or 2.2 of this
+ License shall, upon 60 days notice from Participant
+ terminate prospectively and automatically at the expiration
+ of such 60 day notice period, unless if within such 60 day
+ period You withdraw Your claim with respect to the
+ Participant Software against such Participant either
+ unilaterally or pursuant to a written agreement with
+ Participant.
+
+ 6.3. In the event of termination under Sections 6.1 or 6.2
+ above, all end user licenses that have been validly granted
+ by You or any distributor hereunder prior to termination
+ (excluding licenses granted to You by any distributor)
+ shall survive termination.
+
+ 7. LIMITATION OF LIABILITY.
+
+ UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT
+ (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE
+ INITIAL DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF
+ COVERED SOFTWARE, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE
+ LIABLE TO ANY PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR
+ CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT
+ LIMITATION, DAMAGES FOR LOST PROFITS, LOSS OF GOODWILL, WORK
+ STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER
+ COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN
+ INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF
+ LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL
+ INJURY RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT
+ APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO
+ NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR
+ CONSEQUENTIAL DAMAGES, SO THIS EXCLUSION AND LIMITATION MAY NOT
+ APPLY TO YOU.
+
+ 8. U.S. GOVERNMENT END USERS.
+
+ The Covered Software is a "commercial item," as that term is
+ defined in 48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial
+ computer software" (as that term is defined at 48 C.F.R.
+ 252.227-7014(a)(1)) and "commercial computer software
+ documentation" as such terms are used in 48 C.F.R. 12.212 (Sept.
+ 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1
+ through 227.7202-4 (June 1995), all U.S. Government End Users
+ acquire Covered Software with only those rights set forth herein.
+ This U.S. Government Rights clause is in lieu of, and supersedes,
+ any other FAR, DFAR, or other clause or provision that addresses
+ Government rights in computer software under this License.
+
+ 9. MISCELLANEOUS.
+
+ This License represents the complete agreement concerning subject
+ matter hereof. If any provision of this License is held to be
+ unenforceable, such provision shall be reformed only to the
+ extent necessary to make it enforceable. This License shall be
+ governed by the law of the jurisdiction specified in a notice
+ contained within the Original Software (except to the extent
+ applicable law, if any, provides otherwise), excluding such
+ jurisdiction's conflict-of-law provisions. Any litigation
+ relating to this License shall be subject to the jurisdiction of
+ the courts located in the jurisdiction and venue specified in a
+ notice contained within the Original Software, with the losing
+ party responsible for costs, including, without limitation, court
+ costs and reasonable attorneys' fees and expenses. The
+ application of the United Nations Convention on Contracts for the
+ International Sale of Goods is expressly excluded. Any law or
+ regulation which provides that the language of a contract shall
+ be construed against the drafter shall not apply to this License.
+ You agree that You alone are responsible for compliance with the
+ United States export administration regulations (and the export
+ control laws and regulation of any other countries) when You use,
+ distribute or otherwise make available any Covered Software.
+
+ 10. RESPONSIBILITY FOR CLAIMS.
+
+ As between Initial Developer and the Contributors, each party is
+ responsible for claims and damages arising, directly or
+ indirectly, out of its utilization of rights under this License
+ and You agree to work with Initial Developer and Contributors to
+ distribute such responsibility on an equitable basis. Nothing
+ herein is intended or shall be deemed to constitute any admission
+ of liability.
+
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/resources/META-INF/NOTICE b/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/resources/META-INF/NOTICE
new file mode 100644
index 0000000000..d48810c0ec
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/resources/META-INF/NOTICE
@@ -0,0 +1,18 @@
+=========================================================================
+== NOTICE file corresponding to the section 4 d of ==
+== the Apache License, Version 2.0, ==
+== in this case for the Apache Tuscany distribution. ==
+=========================================================================
+
+This product includes software developed by the Apache Software Foundation
+(http://www.apache.org/).
+
+This product also includes software developed by:
+- the Eclipse Modeling Framework project (http://www.eclipse.org/emf/)
+- the Celtix project (http://celtix.objectweb.org/)
+- the Mozilla Rhino project (http://www.mozilla.org/rhino/)
+- the GlassFish JAX-WS project (https://jax-ws.dev.java.net/)
+
+Please read the LICENSE.txt file present in the root directory of this
+distribution.
+
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/resources/META-INF/sca/default.scdl b/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/resources/META-INF/sca/default.scdl
new file mode 100644
index 0000000000..5bb55f2405
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.rmi/src/test/resources/META-INF/sca/default.scdl
@@ -0,0 +1,44 @@
+<?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:rmi="http://incubator.apache.org/tuscany/xmlns/binding/rmi/1.0-incubator-M2"
+ name="HelloWorldRmiComposite">
+
+ <service name="HelloWorldRmiService" target="HelloWorldServiceComponent">
+ <interface.java interface="helloworld.HelloWorldService"/>
+ <rmi:binding.rmi host="localhost" port="8099" serviceName="HelloWorldRemoteService" />
+ <reference>HelloWorldServiceComponent</reference>
+ </service>
+
+ <component name="HelloWorldServiceComponent">
+ <implementation.java class="helloworld.HelloWorldImpl"/>
+ </component>
+
+ <component name="HelloWorldRmiServiceComponent">
+ <implementation.java class="helloworld.HelloWorldRmiImpl"/>
+ <reference name="extService" target="HelloWorldRmiReference">HelloWorldRmiReference</reference>
+ </component>
+
+ <reference name="HelloWorldRmiReference" target="Nothing">
+ <interface.java interface="helloworld.HelloWorldService"/>
+ <rmi:binding.rmi host="localhost" port="8099" serviceName="HelloWorldRemoteService" />
+ </reference>
+
+</composite>
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.servicemix/pom.xml b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/pom.xml
new file mode 100644
index 0000000000..fcb4b086c4
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/pom.xml
@@ -0,0 +1,60 @@
+<?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 xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <parent>
+ <groupId>org.apache.tuscany.sca.services.bindings</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>binding-servicemix</artifactId>
+ <name>Apache Tuscany Binding for ServiceMix</name>
+ <description>Implementation of the SCA JBI Binding</description>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca.kernel</groupId>
+ <artifactId>tuscany-spi</artifactId>
+ <version>${sca.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.servicemix</groupId>
+ <artifactId>servicemix-core</artifactId>
+ <version>3.0-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.servicemix</groupId>
+ <artifactId>servicemix-common</artifactId>
+ <version>3.0-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/ScaBootstrap.java b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/ScaBootstrap.java
new file mode 100644
index 0000000000..ad407553b4
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/ScaBootstrap.java
@@ -0,0 +1,169 @@
+/*
+ * 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.servicemix.sca;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.jbi.JBIException;
+import javax.jbi.component.Bootstrap;
+import javax.jbi.component.InstallationContext;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+/**
+ * Base class for components bootstrap.
+ *
+ * @author Guillaume Nodet
+ * @version $Revision$
+ * @since 3.0
+ */
+public class ScaBootstrap implements Bootstrap {
+
+ protected final transient Log logger = LogFactory.getLog(getClass());
+
+ protected InstallationContext context;
+ protected ObjectName mbeanName;
+
+ public ScaBootstrap() {
+ }
+
+ public ObjectName getExtensionMBeanName() {
+ return mbeanName;
+ }
+
+ protected Object getExtensionMBean() throws Exception {
+ return null;
+ }
+
+ protected ObjectName createExtensionMBeanName() throws Exception {
+ return this.context.getContext().getMBeanNames().createCustomComponentMBeanName("bootstrap");
+ }
+
+ /* (non-Javadoc)
+ * @see javax.jbi.component.Bootstrap#init(javax.jbi.component.InstallationContext)
+ */
+ public void init(InstallationContext installContext) throws JBIException {
+ try {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Initializing bootstrap");
+ }
+ this.context = installContext;
+ doInit();
+ if (logger.isDebugEnabled()) {
+ logger.debug("Bootstrap initialized");
+ }
+ } catch (JBIException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new JBIException("Error calling init", e);
+ }
+ }
+
+ protected void doInit() throws Exception {
+ Object mbean = getExtensionMBean();
+ if (mbean != null) {
+ this.mbeanName = createExtensionMBeanName();
+ MBeanServer server = this.context.getContext().getMBeanServer();
+ if (server == null) {
+ throw new JBIException("null mBeanServer");
+ }
+ if (server.isRegistered(this.mbeanName)) {
+ server.unregisterMBean(this.mbeanName);
+ }
+ server.registerMBean(mbean, this.mbeanName);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see javax.jbi.component.Bootstrap#cleanUp()
+ */
+ public void cleanUp() throws JBIException {
+ try {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Cleaning up bootstrap");
+ }
+ doCleanUp();
+ if (logger.isDebugEnabled()) {
+ logger.debug("Bootstrap cleaned up");
+ }
+ } catch (JBIException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new JBIException("Error calling cleanUp", e);
+ }
+ }
+
+ protected void doCleanUp() throws Exception {
+ if (this.mbeanName != null) {
+ MBeanServer server = this.context.getContext().getMBeanServer();
+ if (server == null) {
+ throw new JBIException("null mBeanServer");
+ }
+ if (server.isRegistered(this.mbeanName)) {
+ server.unregisterMBean(this.mbeanName);
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see javax.jbi.component.Bootstrap#onInstall()
+ */
+ public void onInstall() throws JBIException {
+ try {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Bootstrap onInstall");
+ }
+ doOnInstall();
+ if (logger.isDebugEnabled()) {
+ logger.debug("Bootstrap onInstall done");
+ }
+ } catch (JBIException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new JBIException("Error calling onInstall", e);
+ }
+ }
+
+ protected void doOnInstall() throws Exception {
+ }
+
+ /* (non-Javadoc)
+ * @see javax.jbi.component.Bootstrap#onUninstall()
+ */
+ public void onUninstall() throws JBIException {
+ try {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Bootstrap onUninstall");
+ }
+ doOnUninstall();
+ if (logger.isDebugEnabled()) {
+ logger.debug("Bootstrap onUninstall done");
+ }
+ } catch (JBIException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new JBIException("Error calling onUninstall", e);
+ }
+ }
+
+ protected void doOnUninstall() throws Exception {
+ }
+
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/ScaComponent.java b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/ScaComponent.java
new file mode 100644
index 0000000000..93470e0707
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/ScaComponent.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 org.apache.servicemix.sca;
+
+import org.apache.servicemix.common.BaseComponent;
+import org.apache.servicemix.common.BaseLifeCycle;
+import org.apache.servicemix.common.BaseServiceUnitManager;
+import org.apache.servicemix.common.Deployer;
+
+public class ScaComponent extends BaseComponent {
+
+ /* (non-Javadoc)
+ * @see org.servicemix.common.BaseComponent#createLifeCycle()
+ */
+ protected BaseLifeCycle createLifeCycle() {
+ return new ScaLifeCycle(this);
+ }
+
+ /* (non-Javadoc)
+ * @see org.servicemix.common.BaseComponent#createServiceUnitManager()
+ */
+ public BaseServiceUnitManager createServiceUnitManager() {
+ Deployer[] deployers = new Deployer[] { new ScaDeployer(this) };
+ return new BaseServiceUnitManager(this, deployers);
+ }
+
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/ScaDeployer.java b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/ScaDeployer.java
new file mode 100644
index 0000000000..199721cb88
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/ScaDeployer.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.servicemix.sca;
+
+import java.io.File;
+
+import javax.jbi.management.DeploymentException;
+
+import org.apache.servicemix.common.AbstractDeployer;
+import org.apache.servicemix.common.BaseComponent;
+import org.apache.servicemix.common.ServiceUnit;
+
+public class ScaDeployer extends AbstractDeployer {
+
+ public static final String SCA_MODULE_FILE = "sca.module";
+
+ public ScaDeployer(BaseComponent component) {
+ super(component);
+ }
+
+ public boolean canDeploy(String serviceUnitName, String serviceUnitRootPath) {
+ File module = new File(serviceUnitRootPath, SCA_MODULE_FILE);
+ return module.exists() && module.isFile();
+ }
+
+ public ServiceUnit deploy(String serviceUnitName, String serviceUnitRootPath)
+ throws DeploymentException {
+ File module = new File(serviceUnitRootPath, SCA_MODULE_FILE);
+ if (!module.exists() || !module.isFile()) {
+ throw failure("deploy", "No sca.module found", null);
+ }
+ try {
+ ScaServiceUnit su = new ScaServiceUnit();
+ su.setComponent(component);
+ su.setName(serviceUnitName);
+ su.setRootPath(serviceUnitRootPath);
+ su.init();
+ return su;
+ } catch (Exception e) {
+ throw failure("deploy", "Error loading sca module", e);
+ }
+ }
+
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/ScaEndpoint.java b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/ScaEndpoint.java
new file mode 100644
index 0000000000..8da798d26f
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/ScaEndpoint.java
@@ -0,0 +1,157 @@
+/*
+ * 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.servicemix.sca;
+
+import java.io.StringWriter;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.UndeclaredThrowableException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.jbi.component.ComponentContext;
+import javax.jbi.messaging.DeliveryChannel;
+import javax.jbi.messaging.ExchangeStatus;
+import javax.jbi.messaging.MessageExchange;
+import javax.jbi.messaging.NormalizedMessage;
+import javax.jbi.messaging.MessageExchange.Role;
+import javax.jbi.servicedesc.ServiceEndpoint;
+import javax.xml.bind.JAXBContext;
+
+import org.apache.servicemix.common.Endpoint;
+import org.apache.servicemix.common.ExchangeProcessor;
+import org.apache.servicemix.jbi.jaxp.StringSource;
+import org.apache.tuscany.core.context.EntryPointContext;
+import org.apache.tuscany.model.assembly.ConfiguredReference;
+import org.apache.tuscany.model.assembly.ConfiguredService;
+import org.apache.tuscany.model.assembly.EntryPoint;
+
+/**
+ *
+ * @author gnodet
+ * @version $Revision$
+ * @org.apache.xbean.XBean element="endpoint" description="A sca endpoint"
+ *
+ */
+public class ScaEndpoint extends Endpoint implements ExchangeProcessor {
+
+ protected ServiceEndpoint activated;
+
+ protected EntryPoint entryPoint;
+
+ protected Map<Class, Method> methodMap;
+
+ protected JAXBContext jaxbContext;
+
+ protected DeliveryChannel channel;
+
+ public ScaEndpoint(EntryPoint entryPoint) {
+ this.entryPoint = entryPoint;
+ }
+
+ public Role getRole() {
+ return Role.PROVIDER;
+ }
+
+ public void activate() throws Exception {
+ logger = this.serviceUnit.getComponent().getLogger();
+ ComponentContext ctx = this.serviceUnit.getComponent().getComponentContext();
+ activated = ctx.activateEndpoint(service, endpoint);
+ channel = ctx.getDeliveryChannel();
+ // Get the target service
+ ConfiguredReference referenceValue = entryPoint.getConfiguredReference();
+ ConfiguredService targetServiceEndpoint = referenceValue.getTargetConfiguredServices().get(0);
+ // Get the business interface
+ Class serviceInterface = targetServiceEndpoint.getService().getServiceContract().getInterface();
+ List<Class> classes = new ArrayList<Class>();
+ methodMap = new HashMap<Class, Method>();
+ for (Method mth : serviceInterface.getMethods()) {
+ Class[] params = mth.getParameterTypes();
+ if (params.length != 1) {
+ throw new IllegalStateException("Supports only methods with one parameter");
+ }
+ methodMap.put(params[0], mth);
+ classes.add(mth.getReturnType());
+ classes.add(params[0]);
+ }
+ jaxbContext = JAXBContext.newInstance(classes.toArray(new Class[0]));
+ }
+
+ public void deactivate() throws Exception {
+ ServiceEndpoint ep = activated;
+ activated = null;
+ ComponentContext ctx = this.serviceUnit.getComponent().getComponentContext();
+ ctx.deactivateEndpoint(ep);
+ }
+
+ public ExchangeProcessor getProcessor() {
+ return this;
+ }
+
+ public void process(MessageExchange exchange) throws Exception {
+ if (exchange.getStatus() == ExchangeStatus.DONE) {
+ return;
+ } else if (exchange.getStatus() == ExchangeStatus.ERROR) {
+ return;
+ }
+ Object input = jaxbContext.createUnmarshaller().unmarshal(exchange.getMessage("in").getContent());
+ Method method = methodMap.get(input.getClass());
+ if (method == null) {
+ throw new IllegalStateException("Could not determine invoked web method");
+ }
+ boolean oneWay = method.getReturnType() == null;
+ Object output;
+ try {
+ EntryPointContext entryPointContext = (EntryPointContext) ((ScaServiceUnit) serviceUnit)
+ .getTuscanyRuntime().getModuleContext().getContext(entryPoint.getName());
+ InvocationHandler handler = (InvocationHandler) entryPointContext.getImplementationInstance();
+ output = handler.invoke(null, method, new Object[] { input });
+ } catch (UndeclaredThrowableException e) {
+ throw e;
+ } catch (RuntimeException e) {
+ throw e;
+ } catch (Error e) {
+ throw e;
+ } catch (Exception e) {
+ throw e;
+ } catch (Throwable e) {
+ throw new RuntimeException(e);
+ }
+ if (oneWay) {
+ exchange.setStatus(ExchangeStatus.DONE);
+ channel.send(exchange);
+ } else {
+ NormalizedMessage msg = exchange.createMessage();
+ exchange.setMessage(msg, "out");
+ StringWriter writer = new StringWriter();
+ jaxbContext.createMarshaller().marshal(output, writer);
+ msg.setContent(new StringSource(writer.toString()));
+ channel.send(exchange);
+ }
+ }
+
+ public void start() throws Exception {
+ }
+
+ public void stop() throws Exception {
+ }
+
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/ScaLifeCycle.java b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/ScaLifeCycle.java
new file mode 100644
index 0000000000..499459dc71
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/ScaLifeCycle.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.servicemix.sca;
+
+import org.apache.servicemix.common.BaseComponent;
+import org.apache.servicemix.common.BaseLifeCycle;
+
+public class ScaLifeCycle extends BaseLifeCycle {
+
+ public ScaLifeCycle(BaseComponent component) {
+ super(component);
+ }
+
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/ScaServiceUnit.java b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/ScaServiceUnit.java
new file mode 100644
index 0000000000..e391edf071
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/ScaServiceUnit.java
@@ -0,0 +1,113 @@
+/*
+ * 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.servicemix.sca;
+
+import java.io.File;
+import java.io.FilenameFilter;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.Iterator;
+
+import javax.wsdl.Definition;
+import javax.wsdl.factory.WSDLFactory;
+
+import org.apache.servicemix.common.ServiceUnit;
+import org.apache.servicemix.sca.assembly.JbiBinding;
+import org.apache.servicemix.sca.tuscany.CommonsLoggingMonitorFactory;
+import org.apache.servicemix.sca.tuscany.TuscanyRuntime;
+import org.apache.tuscany.model.assembly.Binding;
+import org.apache.tuscany.model.assembly.EntryPoint;
+import org.apache.tuscany.model.assembly.Module;
+
+public class ScaServiceUnit extends ServiceUnit {
+
+ protected static final ThreadLocal<ScaServiceUnit> SERVICE_UNIT = new ThreadLocal<ScaServiceUnit>();
+
+ public static ScaServiceUnit getCurrentScaServiceUnit() {
+ return SERVICE_UNIT.get();
+ }
+
+ protected TuscanyRuntime tuscanyRuntime;
+ protected ClassLoader classLoader;
+
+ public void init() throws Exception {
+ SERVICE_UNIT.set(this);
+ createScaRuntime();
+ createEndpoints();
+ SERVICE_UNIT.set(null);
+ }
+
+ protected void createScaRuntime() throws Exception {
+ File root = new File(getRootPath());
+ File[] files = root.listFiles(new JarFileFilter());
+ URL[] urls = new URL[files.length + 1];
+ for (int i = 0; i < files.length; i++) {
+ urls[i] = files[i].toURL();
+ }
+ urls[urls.length - 1] = root.toURL();
+ classLoader = new URLClassLoader(urls, getClass().getClassLoader());
+
+ tuscanyRuntime = new TuscanyRuntime(getName(), getRootPath(), classLoader, new CommonsLoggingMonitorFactory());
+ }
+
+ protected void createEndpoints() throws Exception {
+ Module module = tuscanyRuntime.getModuleComponent().getModuleImplementation();
+ for (Iterator i = module.getEntryPoints().iterator(); i.hasNext();) {
+ EntryPoint entryPoint = (EntryPoint) i.next();
+ Binding binding = (Binding) entryPoint.getBindings().get(0);
+ if (binding instanceof JbiBinding) {
+ JbiBinding jbiBinding = (JbiBinding) binding;
+ ScaEndpoint endpoint = new ScaEndpoint(entryPoint);
+ endpoint.setServiceUnit(this);
+ endpoint.setService(jbiBinding.getServiceName());
+ endpoint.setEndpoint(jbiBinding.getEndpointName());
+ endpoint.setInterfaceName(jbiBinding.getInterfaceName());
+ Definition definition = jbiBinding.getDefinition();
+ if (definition != null) {
+ endpoint.setDefinition(definition);
+ endpoint.setDescription(WSDLFactory.newInstance().newWSDLWriter().getDocument(definition));
+ }
+ addEndpoint(endpoint);
+ }
+ }
+ }
+
+ private static class JarFileFilter implements FilenameFilter {
+ public boolean accept(File dir, String name) {
+ return name.endsWith(".jar");
+ }
+ }
+
+ public TuscanyRuntime getTuscanyRuntime() {
+ return tuscanyRuntime;
+ }
+
+ @Override
+ public void start() throws Exception {
+ tuscanyRuntime.start();
+ super.start();
+ }
+
+ @Override
+ public void stop() throws Exception {
+ super.stop();
+ tuscanyRuntime.stop();
+ }
+
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/assembly/JbiAssemblyFactory.java b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/assembly/JbiAssemblyFactory.java
new file mode 100644
index 0000000000..ef7812f175
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/assembly/JbiAssemblyFactory.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.servicemix.sca.assembly;
+
+import org.apache.tuscany.model.assembly.AssemblyFactory;
+
+/**
+ * The <b>Factory</b> for the model.
+ */
+public interface JbiAssemblyFactory extends AssemblyFactory {
+
+ /**
+ * Returns a new JbiBinding
+ */
+ JbiBinding createJbiBinding();
+
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/assembly/JbiBinding.java b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/assembly/JbiBinding.java
new file mode 100644
index 0000000000..8bfbf80590
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/assembly/JbiBinding.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.servicemix.sca.assembly;
+
+import javax.wsdl.Definition;
+import javax.wsdl.Port;
+import javax.wsdl.PortType;
+import javax.wsdl.Service;
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.model.assembly.Binding;
+
+public interface JbiBinding extends Binding {
+
+ /**
+ * Returns the URI of the WSDL port for this binding.
+ * @return the URI of the WSDL port for this binding
+ */
+ String getPortURI();
+
+ /**
+ * Set the URI of the WSDL port for this binding.
+ * @param portURI the URI of the WSDL port
+ */
+ void setPortURI(String portURI);
+
+ /**
+ * Returns the service name.
+ * @return the service name
+ */
+ QName getServiceName();
+
+ /**
+ * Returns the endpoint name.
+ * @return the endpoint name
+ */
+ String getEndpointName();
+
+ /**
+ * Returns the interface name.
+ * @returnthe interface name
+ */
+ QName getInterfaceName();
+
+ /**
+ * Returns the WSDL definition containing the WSDL port.
+ * @return the WSDL definition containing the WSDL port
+ */
+ Definition getDefinition();
+
+ /**
+ * Returns the the WSDL service.
+ * @return the WSDL service
+ */
+ Service getService();
+
+ /**
+ * Returns the WSDL port defining this binding.
+ * @return the WSDL port defining this binding
+ */
+ Port getPort();
+
+ /**
+ * Returns the WSDL port type.
+ * @return the WSDL port type
+ */
+ PortType getPortType();
+
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/assembly/impl/JbiAssemblyFactoryImpl.java b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/assembly/impl/JbiAssemblyFactoryImpl.java
new file mode 100644
index 0000000000..4cd6a98689
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/assembly/impl/JbiAssemblyFactoryImpl.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.servicemix.sca.assembly.impl;
+
+import org.apache.servicemix.sca.assembly.JbiAssemblyFactory;
+import org.apache.servicemix.sca.assembly.JbiBinding;
+import org.apache.tuscany.model.assembly.impl.AssemblyFactoryImpl;
+
+/**
+ * An implementation of the model <b>Factory</b>.
+ */
+public class JbiAssemblyFactoryImpl extends AssemblyFactoryImpl implements JbiAssemblyFactory {
+
+ /**
+ * Creates an instance of the factory.
+ */
+ public JbiAssemblyFactoryImpl() {
+ super();
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.servicemix.sca.assembly.JbiAssemblyFactory#createJbiBinding()
+ */
+ public JbiBinding createJbiBinding() {
+ return new JbiBindingImpl();
+ }
+
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/assembly/impl/JbiBindingImpl.java b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/assembly/impl/JbiBindingImpl.java
new file mode 100644
index 0000000000..e44b9c6f45
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/assembly/impl/JbiBindingImpl.java
@@ -0,0 +1,166 @@
+/*
+ * 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.servicemix.sca.assembly.impl;
+
+import java.util.List;
+
+import javax.wsdl.Definition;
+import javax.wsdl.Port;
+import javax.wsdl.PortType;
+import javax.wsdl.Service;
+import javax.xml.namespace.QName;
+
+import org.apache.servicemix.sca.assembly.JbiBinding;
+import org.apache.tuscany.model.assembly.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.impl.BindingImpl;
+
+/**
+ * An implementation of the model object '<em><b>Web Service Binding</b></em>'.
+ */
+public class JbiBindingImpl extends BindingImpl implements JbiBinding {
+
+ private String portURI;
+ private QName serviceName;
+ private String endpointName;
+ private QName interfaceName;
+ private Definition definition;
+ private Service service;
+ private PortType portType;
+ private Port port;
+
+
+ /**
+ * Constructor
+ */
+ protected JbiBindingImpl() {
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.servicemix.sca.assembly.JbiBinding#getPortURI()
+ */
+ public String getPortURI() {
+ return portURI;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.servicemix.sca.assembly.JbiBinding#setPortURI(java.lang.String)
+ */
+ public void setPortURI(String portURI) {
+ this.portURI = portURI;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.servicemix.sca.assembly.JbiBinding#getServiceName()
+ */
+ public QName getServiceName() {
+ return serviceName;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.servicemix.sca.assembly.JbiBinding#getEndpointName()
+ */
+ public String getEndpointName() {
+ return endpointName;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.servicemix.sca.assembly.JbiBinding#getInterfaceName()
+ */
+ public QName getInterfaceName() {
+ return interfaceName;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.servicemix.sca.assembly.JbiBinding#getDefinition()
+ */
+ public Definition getDefinition() {
+ return definition;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.servicemix.sca.assembly.JbiBinding#getService()
+ */
+ public Service getService() {
+ return service;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.servicemix.sca.assembly.JbiBinding#getPort()
+ */
+ public Port getPort() {
+ return port;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.servicemix.sca.assembly.JbiBinding#getPortType()
+ */
+ public PortType getPortType() {
+ return portType;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.impl.BindingImpl#initialize(org.apache.tuscany.model.assembly.AssemblyModelContext)
+ */
+ public void initialize(AssemblyModelContext modelContext) {
+ if (isInitialized())
+ return;
+ super.initialize(modelContext);
+
+ // Get the service name and endpoint name
+ String[] parts = split(portURI);
+ serviceName = new QName(parts[0], parts[1]);
+ endpointName = parts[2];
+
+ // Load the WSDL definitions for the given namespace
+ List<Definition> definitions = modelContext.getAssemblyLoader().loadDefinitions(parts[0]);
+ if (definitions != null) {
+ for (Definition definition : definitions) {
+ Service service = definition.getService(serviceName);
+ if (service != null) {
+ Port port = service.getPort(endpointName);
+ if (port != null) {
+ this.service = service;
+ this.port = port;
+ this.portType = port.getBinding().getPortType();
+ this.interfaceName = portType.getQName();
+ this.definition = definition;
+ return;
+ }
+ }
+ }
+ }
+ }
+
+ protected String[] split(String uri) {
+ char sep;
+ uri = uri.trim();
+ if (uri.indexOf('/') > 0) {
+ sep = '/';
+ } else {
+ sep = ':';
+ }
+ int idx1 = uri.lastIndexOf(sep);
+ int idx2 = uri.lastIndexOf(sep, idx1 - 1);
+ String epName = uri.substring(idx1 + 1);
+ String svcName = uri.substring(idx2 + 1, idx1);
+ String nsUri = uri.substring(0, idx2);
+ return new String[] { nsUri, svcName, epName };
+ }
+
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/builder/ExternalJbiServiceBuilder.java b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/builder/ExternalJbiServiceBuilder.java
new file mode 100644
index 0000000000..e5a7b59a75
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/builder/ExternalJbiServiceBuilder.java
@@ -0,0 +1,151 @@
+/*
+ * 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.servicemix.sca.builder;
+
+import java.lang.reflect.Method;
+import java.util.Collection;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.servicemix.sca.assembly.JbiBinding;
+import org.apache.servicemix.sca.config.ExternalJbiServiceContextFactory;
+import org.apache.servicemix.sca.handler.ExternalJbiServiceClient;
+import org.apache.tuscany.core.builder.BuilderException;
+import org.apache.tuscany.core.builder.ContextFactoryBuilder;
+import org.apache.tuscany.core.config.JavaIntrospectionHelper;
+import org.apache.tuscany.core.context.QualifiedName;
+import org.apache.tuscany.core.injection.SingletonObjectFactory;
+import org.apache.tuscany.core.invocation.InvocationConfiguration;
+import org.apache.tuscany.core.invocation.MethodHashMap;
+import org.apache.tuscany.core.invocation.ProxyConfiguration;
+import org.apache.tuscany.core.invocation.impl.InvokerInterceptor;
+import org.apache.tuscany.core.invocation.spi.ProxyFactory;
+import org.apache.tuscany.core.invocation.spi.ProxyFactoryFactory;
+import org.apache.tuscany.core.message.MessageFactory;
+import org.apache.tuscany.core.runtime.RuntimeContext;
+import org.apache.tuscany.core.system.annotation.Autowire;
+import org.apache.tuscany.model.assembly.AssemblyModelObject;
+import org.apache.tuscany.model.assembly.ConfiguredService;
+import org.apache.tuscany.model.assembly.ExternalService;
+import org.apache.tuscany.model.assembly.Service;
+import org.apache.tuscany.model.assembly.ServiceContract;
+import org.apache.tuscany.model.scdl.WebServiceBinding;
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * Creates a <code>RuntimeConfigurationBuilder</code> for an external service configured with the {@link WebServiceBinding}
+ */
+@Scope("MODULE")
+public class ExternalJbiServiceBuilder implements ContextFactoryBuilder {
+
+ private RuntimeContext runtimeContext;
+
+ private ProxyFactoryFactory proxyFactoryFactory;
+
+ private MessageFactory messageFactory;
+
+ private ContextFactoryBuilder policyBuilder;
+
+ public ExternalJbiServiceBuilder() {
+ }
+
+ @Init(eager = true)
+ public void init() {
+ runtimeContext.addBuilder(this);
+ }
+
+ /**
+ * @param runtimeContext The runtimeContext to set.
+ */
+ @Autowire
+ public void setRuntimeContext(RuntimeContext runtimeContext) {
+ this.runtimeContext = runtimeContext;
+ }
+
+ /**
+ * Sets the factory used to construct proxies implmementing the business interface required by a reference
+ */
+ @Autowire
+ public void setProxyFactoryFactory(ProxyFactoryFactory factory) {
+ this.proxyFactoryFactory = factory;
+ }
+
+ /**
+ * Sets the factory used to construct invocation messages
+ *
+ * @param msgFactory
+ */
+ @Autowire
+ public void setMessageFactory(MessageFactory msgFactory) {
+ this.messageFactory = msgFactory;
+ }
+
+ /**
+ * Sets a builder responsible for creating source-side and target-side invocation chains for a reference. The
+ * reference builder may be hierarchical, containing other child reference builders that operate on specific
+ * metadata used to construct and invocation chain.
+ *
+ * @see org.apache.tuscany.core.builder.impl.HierarchicalBuilder
+ */
+ public void setPolicyBuilder(ContextFactoryBuilder builder) {
+ policyBuilder = builder;
+ }
+
+ public void build(AssemblyModelObject object) throws BuilderException {
+ if (!(object instanceof ExternalService)) {
+ return;
+ }
+ ExternalService externalService = (ExternalService) object;
+ if (externalService.getBindings().size() < 1 || !(externalService.getBindings().get(0) instanceof JbiBinding)) {
+ return;
+ }
+
+ ExternalJbiServiceClient externalJbiServiceClient = new ExternalJbiServiceClient(externalService);
+ ExternalJbiServiceContextFactory config = new ExternalJbiServiceContextFactory(externalService.getName(), new SingletonObjectFactory<ExternalJbiServiceClient>(externalJbiServiceClient));
+
+ ConfiguredService configuredService = externalService.getConfiguredService();
+ Service service = configuredService.getService();
+ ServiceContract serviceContract = service.getServiceContract();
+ Map<Method, InvocationConfiguration> iConfigMap = new MethodHashMap();
+ ProxyFactory proxyFactory = proxyFactoryFactory.createProxyFactory();
+ Set<Method> javaMethods = JavaIntrospectionHelper.getAllUniqueMethods(serviceContract.getInterface());
+ for (Method method : javaMethods) {
+ InvocationConfiguration iConfig = new InvocationConfiguration(method);
+ iConfigMap.put(method, iConfig);
+ }
+ QualifiedName qName = new QualifiedName(externalService.getName() + "/" + service.getName());
+ ProxyConfiguration pConfiguration = new ProxyConfiguration(qName, iConfigMap, serviceContract.getInterface().getClassLoader(), messageFactory);
+ proxyFactory.setBusinessInterface(serviceContract.getInterface());
+ proxyFactory.setProxyConfiguration(pConfiguration);
+ config.addTargetProxyFactory(service.getName(), proxyFactory);
+ configuredService.setProxyFactory(proxyFactory);
+ if (policyBuilder != null) {
+ // invoke the reference builder to handle additional policy metadata
+ policyBuilder.build(configuredService);
+ }
+ // add tail interceptor
+ for (InvocationConfiguration iConfig : (Collection<InvocationConfiguration>) iConfigMap.values()) {
+ iConfig.addTargetInterceptor(new InvokerInterceptor());
+ }
+
+ externalService.getConfiguredService().setContextFactory(config);
+ }
+
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/builder/ExternalJbiServiceWireBuilder.java b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/builder/ExternalJbiServiceWireBuilder.java
new file mode 100644
index 0000000000..1dc7d9f454
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/builder/ExternalJbiServiceWireBuilder.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.servicemix.sca.builder;
+
+import org.apache.servicemix.sca.config.ExternalJbiServiceContextFactory;
+import org.apache.servicemix.sca.handler.ExternalJbiServiceTargetInvoker;
+import org.apache.tuscany.core.builder.BuilderConfigException;
+import org.apache.tuscany.core.builder.WireBuilder;
+import org.apache.tuscany.core.context.ScopeContext;
+import org.apache.tuscany.core.invocation.InvocationConfiguration;
+import org.apache.tuscany.core.invocation.spi.ProxyFactory;
+import org.apache.tuscany.core.runtime.RuntimeContext;
+import org.apache.tuscany.core.system.annotation.Autowire;
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Scope;
+
+@Scope("MODULE")
+public class ExternalJbiServiceWireBuilder implements WireBuilder {
+
+ private RuntimeContext runtimeContext;
+
+ /**
+ * Constructs a new ExternalWebServiceWireBuilder.
+ */
+ public ExternalJbiServiceWireBuilder() {
+ super();
+ }
+
+ @Autowire
+ public void setRuntimeContext(RuntimeContext context) {
+ runtimeContext = context;
+ }
+
+ @Init(eager=true)
+ public void init() {
+ runtimeContext.addBuilder(this);
+ }
+
+ public void connect(ProxyFactory sourceFactory, ProxyFactory targetFactory, Class targetType, boolean downScope, ScopeContext targetScopeContext) throws BuilderConfigException {
+ if (!(ExternalJbiServiceContextFactory.class.isAssignableFrom(targetType))) {
+ return;
+ }
+ for (InvocationConfiguration sourceInvocationConfig : sourceFactory.getProxyConfiguration().getInvocationConfigurations().values()) {
+ ExternalJbiServiceTargetInvoker invoker = new ExternalJbiServiceTargetInvoker(sourceFactory.getProxyConfiguration().getTargetName(), sourceInvocationConfig.getMethod(), targetScopeContext);
+ sourceInvocationConfig.setTargetInvoker(invoker);
+ }
+ }
+
+ public void completeTargetChain(ProxyFactory targetFactory, Class targetType, ScopeContext targetScopeContext)
+ throws BuilderConfigException {
+ //TODO implement
+ }
+
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/builder/JbiServiceEntryPointBuilder.java b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/builder/JbiServiceEntryPointBuilder.java
new file mode 100644
index 0000000000..af83c7c714
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/builder/JbiServiceEntryPointBuilder.java
@@ -0,0 +1,169 @@
+/*
+ * 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.servicemix.sca.builder;
+
+import java.lang.reflect.Method;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.servicemix.sca.assembly.JbiBinding;
+import org.apache.servicemix.sca.config.JbiServiceEntryPointContextFactory;
+import org.apache.tuscany.core.builder.BuilderException;
+import org.apache.tuscany.core.builder.ContextFactoryBuilder;
+import org.apache.tuscany.core.builder.impl.EntryPointContextFactory;
+import org.apache.tuscany.core.config.JavaIntrospectionHelper;
+import org.apache.tuscany.core.context.AggregateContext;
+import org.apache.tuscany.core.context.QualifiedName;
+import org.apache.tuscany.core.invocation.Interceptor;
+import org.apache.tuscany.core.invocation.InvocationConfiguration;
+import org.apache.tuscany.core.invocation.InvocationRuntimeException;
+import org.apache.tuscany.core.invocation.ProxyConfiguration;
+import org.apache.tuscany.core.invocation.TargetInvoker;
+import org.apache.tuscany.core.invocation.spi.ProxyFactory;
+import org.apache.tuscany.core.invocation.spi.ProxyFactoryFactory;
+import org.apache.tuscany.core.message.Message;
+import org.apache.tuscany.core.message.MessageFactory;
+import org.apache.tuscany.core.runtime.RuntimeContext;
+import org.apache.tuscany.core.system.annotation.Autowire;
+import org.apache.tuscany.model.assembly.AssemblyModelObject;
+import org.apache.tuscany.model.assembly.ConfiguredService;
+import org.apache.tuscany.model.assembly.EntryPoint;
+import org.apache.tuscany.model.assembly.Service;
+import org.apache.tuscany.model.assembly.ServiceContract;
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Scope;
+
+@Scope("MODULE")
+public class JbiServiceEntryPointBuilder implements ContextFactoryBuilder<AggregateContext> {
+
+ private RuntimeContext runtimeContext;
+
+ private ProxyFactoryFactory proxyFactoryFactory;
+
+ private MessageFactory messageFactory;
+
+ private ContextFactoryBuilder policyBuilder;
+
+ public JbiServiceEntryPointBuilder() {
+ }
+
+ @Init(eager = true)
+ public void init() {
+ runtimeContext.addBuilder(this);
+ }
+
+ /**
+ * @param runtimeContext The runtimeContext to set.
+ */
+ @Autowire
+ public void setRuntimeContext(RuntimeContext runtimeContext) {
+ this.runtimeContext = runtimeContext;
+ }
+
+ /**
+ * Sets the factory used to construct proxies implmementing the business interface required by a reference
+ */
+ @Autowire
+ public void setProxyFactoryFactory(ProxyFactoryFactory factory) {
+ this.proxyFactoryFactory = factory;
+ }
+
+ /**
+ * Sets the factory used to construct invocation messages
+ *
+ * @param msgFactory
+ */
+ @Autowire
+ public void setMessageFactory(MessageFactory msgFactory) {
+ this.messageFactory = msgFactory;
+ }
+
+ /**
+ * Sets a builder responsible for creating source-side and target-side invocation chains for a reference. The
+ * reference builder may be hierarchical, containing other child reference builders that operate on specific
+ * metadata used to construct and invocation chain.
+ *
+ * @see org.apache.tuscany.core.builder.impl.HierarchicalBuilder
+ */
+ public void setPolicyBuilder(ContextFactoryBuilder builder) {
+ policyBuilder = builder;
+ }
+
+ public void build(AssemblyModelObject object) throws BuilderException {
+ if (!(object instanceof EntryPoint)) {
+ return;
+ }
+ EntryPoint entryPoint = (EntryPoint) object;
+ if (entryPoint.getBindings().size() < 1 || !(entryPoint.getBindings().get(0) instanceof JbiBinding)) {
+ return;
+ }
+
+ EntryPointContextFactory config = new JbiServiceEntryPointContextFactory(entryPoint.getName(), entryPoint.getConfiguredService().getService().getName(), messageFactory);
+
+ ConfiguredService configuredService = entryPoint.getConfiguredService();
+ Service service = configuredService.getService();
+ ServiceContract serviceContract = service.getServiceContract();
+ Map<Method, InvocationConfiguration> iConfigMap = new HashMap<Method, InvocationConfiguration>();
+ ProxyFactory proxyFactory = proxyFactoryFactory.createProxyFactory();
+ Set<Method> javaMethods = JavaIntrospectionHelper.getAllUniqueMethods(serviceContract.getInterface());
+ for (Method method : javaMethods) {
+ InvocationConfiguration iConfig = new InvocationConfiguration(method);
+ iConfigMap.put(method, iConfig);
+ }
+ QualifiedName qName = new QualifiedName(entryPoint.getConfiguredReference().getTargetConfiguredServices().get(0).getAggregatePart().getName() + "/" + service.getName());
+ ProxyConfiguration pConfiguration = new ProxyConfiguration(qName, iConfigMap, serviceContract.getInterface().getClassLoader(), messageFactory);
+ proxyFactory.setBusinessInterface(serviceContract.getInterface());
+ proxyFactory.setProxyConfiguration(pConfiguration);
+ config.addSourceProxyFactory(service.getName(), proxyFactory);
+ configuredService.setProxyFactory(proxyFactory);
+ if (policyBuilder != null) {
+ // invoke the reference builder to handle additional policy metadata
+ policyBuilder.build(configuredService);
+ }
+ // add tail interceptor
+ for (InvocationConfiguration iConfig : (Collection<InvocationConfiguration>) iConfigMap.values()) {
+ iConfig.addTargetInterceptor(new EntryPointInvokerInterceptor());
+ }
+ entryPoint.getConfiguredReference().setContextFactory(config);
+ }
+
+ //FIXME same as the InvokerInterceptor except that it doesn't throw an exception in setNext
+ // For some reason another InvokerInterceptor is added after this one, need Jim to look into it
+ // and figure out why.
+ public class EntryPointInvokerInterceptor implements Interceptor {
+
+ public EntryPointInvokerInterceptor() {
+ }
+
+ public Message invoke(Message msg) throws InvocationRuntimeException {
+ TargetInvoker invoker = msg.getTargetInvoker();
+ if (invoker == null) {
+ throw new InvocationRuntimeException("No target invoker specified on message");
+ }
+ return invoker.invoke(msg);
+ }
+
+ public void setNext(Interceptor next) {
+ }
+
+ }
+
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/config/ExternalJbiServiceContextFactory.java b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/config/ExternalJbiServiceContextFactory.java
new file mode 100644
index 0000000000..93b846db8a
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/config/ExternalJbiServiceContextFactory.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.servicemix.sca.config;
+
+import org.apache.tuscany.core.builder.ObjectFactory;
+import org.apache.tuscany.core.builder.impl.BaseExternalServiceContextFactory;
+
+public class ExternalJbiServiceContextFactory extends BaseExternalServiceContextFactory {
+
+ public ExternalJbiServiceContextFactory(String name, ObjectFactory objectFactory) {
+ super(name, objectFactory);
+ }
+
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/config/JbiServiceEntryPointContextFactory.java b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/config/JbiServiceEntryPointContextFactory.java
new file mode 100644
index 0000000000..b6adb6481d
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/config/JbiServiceEntryPointContextFactory.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.servicemix.sca.config;
+
+import org.apache.tuscany.core.builder.impl.EntryPointContextFactory;
+import org.apache.tuscany.core.message.MessageFactory;
+
+public class JbiServiceEntryPointContextFactory extends EntryPointContextFactory {
+
+ public JbiServiceEntryPointContextFactory(String name, String referenceName, MessageFactory msgFactory) {
+ super(name, referenceName, msgFactory);
+ }
+
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/handler/ExternalJbiServiceClient.java b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/handler/ExternalJbiServiceClient.java
new file mode 100644
index 0000000000..22b457687f
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/handler/ExternalJbiServiceClient.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.servicemix.sca.handler;
+
+import java.io.ByteArrayOutputStream;
+import java.lang.reflect.Method;
+
+import javax.jbi.messaging.DeliveryChannel;
+import javax.jbi.messaging.ExchangeStatus;
+import javax.jbi.messaging.InOut;
+import javax.jbi.messaging.NormalizedMessage;
+import javax.xml.bind.JAXBContext;
+
+import org.apache.servicemix.jbi.jaxp.StringSource;
+import org.apache.servicemix.sca.ScaServiceUnit;
+import org.apache.servicemix.sca.assembly.JbiBinding;
+import org.apache.tuscany.model.assembly.ExternalService;
+
+public class ExternalJbiServiceClient {
+
+ private ExternalService externalService;
+
+ private JbiBinding jbiBinding;
+
+ private ScaServiceUnit serviceUnit;
+
+ /**
+ * Constructs a new ExternalWebServiceClient.
+ *
+ * @param externalService
+ * @param wsBinding
+ */
+ public ExternalJbiServiceClient(ExternalService externalService) {
+ this.serviceUnit = ScaServiceUnit.getCurrentScaServiceUnit();
+ this.externalService = externalService;
+ this.jbiBinding = (JbiBinding) this.externalService.getBindings().get(0);
+ }
+
+ /**
+ * Invoke an operation on the external Web service.
+ *
+ * @param method
+ * @param args
+ * @return
+ */
+ public Object invoke(Method method, Object[] args) {
+ if (args == null || args.length != 1) {
+ throw new IllegalStateException("args should have exactly one object");
+ }
+ try {
+ Object payload = args[0];
+ Class inputClass = method.getParameterTypes()[0];
+ Class outputClass = method.getReturnType();
+ JAXBContext context = JAXBContext.newInstance(inputClass, outputClass);
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ context.createMarshaller().marshal(payload, baos);
+
+ DeliveryChannel channel = serviceUnit.getComponent().getComponentContext().getDeliveryChannel();
+ // TODO: in-only case ?
+ // TODO: interface based routing ?
+ // TODO: explicit endpoint selection ?
+ InOut inout = channel.createExchangeFactory().createInOutExchange();
+ inout.setService(jbiBinding.getServiceName());
+ NormalizedMessage in = inout.createMessage();
+ inout.setInMessage(in);
+ in.setContent(new StringSource(baos.toString()));
+ boolean sent = channel.sendSync(inout);
+ // TODO: check for error ?
+ NormalizedMessage out = inout.getOutMessage();
+ Object response = context.createUnmarshaller().unmarshal(out.getContent());
+ inout.setStatus(ExchangeStatus.DONE);
+ channel.send(inout);
+ return response;
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/handler/ExternalJbiServiceTargetInvoker.java b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/handler/ExternalJbiServiceTargetInvoker.java
new file mode 100644
index 0000000000..cd0560c5b5
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/handler/ExternalJbiServiceTargetInvoker.java
@@ -0,0 +1,110 @@
+/*
+ * 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.servicemix.sca.handler;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.core.context.ExternalServiceContext;
+import org.apache.tuscany.core.context.InstanceContext;
+import org.apache.tuscany.core.context.QualifiedName;
+import org.apache.tuscany.core.context.ScopeContext;
+import org.apache.tuscany.core.context.TargetException;
+import org.apache.tuscany.core.invocation.Interceptor;
+import org.apache.tuscany.core.invocation.TargetInvoker;
+import org.apache.tuscany.core.message.Message;
+
+public class ExternalJbiServiceTargetInvoker implements TargetInvoker {
+
+ private QualifiedName serviceName;
+ private String esName;
+ private Method method;
+ private ScopeContext container;
+
+ private ExternalServiceContext context;
+
+ /**
+ * Constructs a new ExternalJbiServiceTargetInvoker.
+ * @param esName
+ * @param container
+ */
+ public ExternalJbiServiceTargetInvoker(QualifiedName serviceName, Method method, ScopeContext container) {
+ assert (serviceName != null) : "No service name specified";
+ assert (method != null) : "No method specified";
+ assert (container != null) : "No scope container specified";
+ this.serviceName = serviceName;
+ this.esName = serviceName.getPartName();
+ this.method = method;
+ this.container = container;
+ }
+
+ public Object invokeTarget(Object payload) throws InvocationTargetException {
+ if (context == null) {
+ InstanceContext iContext = container.getContext(esName);
+ if (!(iContext instanceof ExternalServiceContext)) {
+ TargetException te = new TargetException("Unexpected target context type");
+ te.setIdentifier(iContext.getClass().getName());
+ te.addContextName(iContext.getName());
+ throw te;
+ }
+ context = (ExternalServiceContext) iContext;
+ }
+ ExternalJbiServiceClient client = (ExternalJbiServiceClient) context.getImplementationInstance(true);
+ if (payload != null) {
+ return client.invoke(method, (Object[])payload);
+ } else {
+ return client.invoke(method, null);
+ }
+ }
+
+ public boolean isCacheable() {
+ return false;
+ }
+
+ public Message invoke(Message msg) {
+ try {
+ Object resp = invokeTarget(msg.getBody());
+ msg.setBody(resp);
+ } catch (InvocationTargetException e) {
+ msg.setBody(e.getCause());
+ } catch (Throwable e) {
+ msg.setBody(e);
+ }
+ return msg;
+ }
+
+ public void setNext(Interceptor next) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Object clone() {
+ try {
+ ExternalJbiServiceTargetInvoker invoker = (ExternalJbiServiceTargetInvoker) super.clone();
+ invoker.container = container;
+ invoker.context = this.context;
+ invoker.esName = this.esName;
+ invoker.method = this.method;
+ invoker.serviceName = this.serviceName;
+ return invoker;
+ } catch (CloneNotSupportedException e) {
+ return null; // will not happen
+ }
+ }
+
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/loader/JbiBindingLoader.java b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/loader/JbiBindingLoader.java
new file mode 100644
index 0000000000..ac67433720
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/loader/JbiBindingLoader.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.servicemix.sca.loader;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.servicemix.sca.assembly.JbiAssemblyFactory;
+import org.apache.servicemix.sca.assembly.JbiBinding;
+import org.apache.servicemix.sca.assembly.impl.JbiAssemblyFactoryImpl;
+import org.apache.tuscany.common.resource.ResourceLoader;
+import org.apache.tuscany.core.config.ConfigurationLoadException;
+import org.apache.tuscany.core.loader.StAXElementLoader;
+import org.apache.tuscany.core.loader.StAXLoaderRegistry;
+import org.apache.tuscany.core.system.annotation.Autowire;
+import org.osoa.sca.annotations.Destroy;
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Scope;
+
+@Scope("MODULE")
+public class JbiBindingLoader implements StAXElementLoader<JbiBinding>{
+
+ public static final QName BINDING_JBI = new QName("http://www.osoa.org/xmlns/sca/0.9", "binding.jbi");
+
+ private static final JbiAssemblyFactory jbiFactory = new JbiAssemblyFactoryImpl();
+
+ private StAXLoaderRegistry registry;
+
+ @Autowire
+ public void setRegistry(StAXLoaderRegistry registry) {
+ this.registry = registry;
+ }
+
+ @Init(eager = true)
+ public void start() {
+ registry.registerLoader(this);
+ }
+
+ @Destroy
+ public void stop() {
+ registry.unregisterLoader(this);
+ }
+
+ public QName getXMLType() {
+ return BINDING_JBI;
+ }
+
+ public Class<JbiBinding> getModelType() {
+ return JbiBinding.class;
+ }
+
+ public JbiBinding load(XMLStreamReader reader, ResourceLoader resourceLoader) throws XMLStreamException, ConfigurationLoadException {
+ JbiBinding binding = jbiFactory.createJbiBinding();
+ binding.setURI(reader.getAttributeValue(null, "uri"));
+ binding.setPortURI(reader.getAttributeValue(null, "port"));
+ return binding;
+ }
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/tuscany/BootstrapHelper.java b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/tuscany/BootstrapHelper.java
new file mode 100644
index 0000000000..154afe4377
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/tuscany/BootstrapHelper.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.servicemix.sca.tuscany;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.stream.XMLInputFactory;
+
+import org.apache.tuscany.common.resource.ResourceLoader;
+import org.apache.tuscany.common.resource.impl.ResourceLoaderImpl;
+import org.apache.tuscany.core.builder.ContextFactoryBuilder;
+import org.apache.tuscany.core.config.ConfigurationException;
+import org.apache.tuscany.core.config.ModuleComponentConfigurationLoader;
+import org.apache.tuscany.core.config.impl.ModuleComponentConfigurationLoaderImpl;
+import org.apache.tuscany.core.config.impl.StAXModuleComponentConfigurationLoaderImpl;
+import org.apache.tuscany.core.context.AggregateContext;
+import org.apache.tuscany.core.context.EventContext;
+import org.apache.tuscany.core.context.SystemAggregateContext;
+import org.apache.tuscany.core.loader.StAXLoaderRegistry;
+import org.apache.tuscany.core.loader.StAXUtil;
+import org.apache.tuscany.core.system.assembly.impl.SystemAssemblyFactoryImpl;
+import org.apache.tuscany.core.system.builder.SystemContextFactoryBuilder;
+import org.apache.tuscany.core.system.builder.SystemEntryPointBuilder;
+import org.apache.tuscany.core.system.builder.SystemExternalServiceBuilder;
+import org.apache.tuscany.core.system.loader.SystemSCDLModelLoader;
+import org.apache.tuscany.model.assembly.AssemblyFactory;
+import org.apache.tuscany.model.assembly.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.ModuleComponent;
+import org.apache.tuscany.model.assembly.impl.AssemblyModelContextImpl;
+import org.apache.tuscany.model.assembly.loader.AssemblyModelLoader;
+import org.apache.tuscany.model.scdl.loader.SCDLModelLoader;
+import org.apache.tuscany.model.scdl.loader.impl.SCDLAssemblyModelLoaderImpl;
+
+public class BootstrapHelper {
+
+ /**
+ * Returns a default AssemblyModelContext.
+ *
+ * @param classLoader the classloader to use for application artifacts
+ * @return a default AssemblyModelContext
+ */
+ public static AssemblyModelContext getModelContext(ClassLoader classLoader) {
+ // Create an assembly model factory
+ AssemblyFactory modelFactory = new SystemAssemblyFactoryImpl();
+
+ // Create a default assembly model loader
+ List<SCDLModelLoader> scdlLoaders = new ArrayList<SCDLModelLoader>();
+ scdlLoaders.add(new SystemSCDLModelLoader());
+ AssemblyModelLoader modelLoader = new SCDLAssemblyModelLoaderImpl(scdlLoaders);
+
+ // Create a resource loader from the supplied classloader
+ ResourceLoader resourceLoader = new ResourceLoaderImpl(classLoader);
+
+ // Create an assembly model context
+ return new AssemblyModelContextImpl(modelFactory, modelLoader, resourceLoader);
+ }
+
+ /**
+ * Returns a default list of configuration builders.
+ *
+ * @return a default list of configuration builders
+ */
+ public static List<ContextFactoryBuilder> getBuilders() {
+ List<ContextFactoryBuilder> configBuilders = new ArrayList<ContextFactoryBuilder>();
+ configBuilders.add((new SystemContextFactoryBuilder()));
+ configBuilders.add(new SystemEntryPointBuilder());
+ configBuilders.add(new SystemExternalServiceBuilder());
+ return configBuilders;
+ }
+
+ private static final boolean useStax = true;
+ private static final String SYSTEM_LOADER_COMPONENT = "tuscany.loader";
+
+ /**
+ * Returns the default module configuration loader.
+ *
+ * @param systemContext the runtime's system context
+ * @param modelContext the model context the loader will use
+ * @return the default module configuration loader
+ */
+ public static ModuleComponentConfigurationLoader getConfigurationLoader(SystemAggregateContext systemContext, AssemblyModelContext modelContext) throws ConfigurationException {
+ if (useStax) {
+ // Bootstrap the StAX loader module
+ bootstrapStaxLoader(systemContext, modelContext);
+ return new StAXModuleComponentConfigurationLoaderImpl(modelContext, XMLInputFactory.newInstance(), systemContext.resolveInstance(StAXLoaderRegistry.class));
+ } else {
+ return new ModuleComponentConfigurationLoaderImpl(modelContext);
+ }
+ }
+
+ private static AggregateContext bootstrapStaxLoader(SystemAggregateContext systemContext, AssemblyModelContext modelContext) throws ConfigurationException {
+ AggregateContext loaderContext = (AggregateContext) systemContext.getContext(SYSTEM_LOADER_COMPONENT);
+ if (loaderContext == null) {
+ ModuleComponent loaderComponent = StAXUtil.bootstrapLoader(SYSTEM_LOADER_COMPONENT, modelContext);
+ loaderContext = registerModule(systemContext, loaderComponent);
+ loaderContext.fireEvent(EventContext.MODULE_START, null);
+ }
+ return loaderContext;
+ }
+
+ public static AggregateContext registerModule(AggregateContext parent, ModuleComponent component) throws ConfigurationException {
+ // register the component
+ parent.registerModelObject(component);
+
+ // Get the aggregate context representing the component
+ return (AggregateContext) parent.getContext(component.getName());
+ }
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/tuscany/CommonsLoggingMonitorFactory.java b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/tuscany/CommonsLoggingMonitorFactory.java
new file mode 100644
index 0000000000..04bcc0bcea
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/tuscany/CommonsLoggingMonitorFactory.java
@@ -0,0 +1,90 @@
+/*
+ * 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.servicemix.sca.tuscany;
+
+import java.lang.ref.WeakReference;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.util.Map;
+import java.util.WeakHashMap;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.tuscany.common.monitor.MonitorFactory;
+
+public class CommonsLoggingMonitorFactory implements MonitorFactory {
+
+ private final Map<Class<?>, WeakReference<?>> proxies = new WeakHashMap<Class<?>, WeakReference<?>>();
+
+ public CommonsLoggingMonitorFactory() {
+ }
+
+ public <T> T getMonitor(Class<T> monitorInterface) {
+ T proxy = getCachedMonitor(monitorInterface);
+ if (proxy == null) {
+ proxy = createMonitor(monitorInterface);
+ proxies.put(monitorInterface, new WeakReference<T>(proxy));
+ }
+ return proxy;
+ }
+
+ private <T>T getCachedMonitor(Class<T> monitorInterface) {
+ WeakReference<T> ref = (WeakReference<T>) proxies.get(monitorInterface);
+ return (ref != null) ? ref.get() : null;
+ }
+
+ private <T>T createMonitor(Class<T> monitorInterface) {
+ String className = monitorInterface.getName();
+ Log logger = LogFactory.getLog(className);
+ InvocationHandler handler = new LoggingHandler(logger);
+ return (T) Proxy.newProxyInstance(monitorInterface.getClassLoader(), new Class<?>[]{monitorInterface}, handler);
+ }
+
+ private static final class LoggingHandler implements InvocationHandler {
+ private final Log logger;
+
+ public LoggingHandler(Log logger) {
+ this.logger = logger;
+ }
+
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+ String sourceMethod = method.getName();
+ if (logger.isDebugEnabled()) {
+ // if the only argument is a Throwable use the special logger for it
+ if (args != null && args.length == 1 && args[0] instanceof Throwable) {
+ logger.debug(sourceMethod, (Throwable) args[0]);
+ } else {
+ StringBuilder sb = new StringBuilder();
+ sb.append(sourceMethod);
+ sb.append("(");
+ for (int i = 0; i < args.length; i++) {
+ if (i > 0) {
+ sb.append(", ");
+ }
+ sb.append(args[i]);
+ }
+ sb.append(")");
+ logger.debug(sb.toString());
+ }
+ }
+ return null;
+ }
+ }
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/tuscany/TuscanyRuntime.java b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/tuscany/TuscanyRuntime.java
new file mode 100644
index 0000000000..ee5960dfb5
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/servicemix/sca/tuscany/TuscanyRuntime.java
@@ -0,0 +1,174 @@
+/*
+ * 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.servicemix.sca.tuscany;
+
+import java.util.List;
+
+import org.apache.tuscany.common.monitor.MonitorFactory;
+import org.apache.tuscany.common.monitor.impl.NullMonitorFactory;
+import org.apache.tuscany.core.builder.ContextFactoryBuilder;
+import org.apache.tuscany.core.builder.impl.DefaultWireBuilder;
+import org.apache.tuscany.core.config.ConfigurationException;
+import org.apache.tuscany.core.config.ModuleComponentConfigurationLoader;
+import org.apache.tuscany.core.context.AggregateContext;
+import org.apache.tuscany.core.context.CoreRuntimeException;
+import org.apache.tuscany.core.context.EventContext;
+import org.apache.tuscany.core.context.SystemAggregateContext;
+import org.apache.tuscany.core.runtime.RuntimeContext;
+import org.apache.tuscany.core.runtime.RuntimeContextImpl;
+import org.apache.tuscany.model.assembly.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.ModuleComponent;
+import org.apache.tuscany.model.scdl.loader.SCDLModelLoader;
+import org.osoa.sca.ModuleContext;
+import org.osoa.sca.SCA;
+import org.osoa.sca.ServiceRuntimeException;
+
+public class TuscanyRuntime extends SCA {
+ private final TuscanyRuntime.Monitor monitor;
+ private final Object sessionKey = new Object();
+
+ private final RuntimeContext runtime;
+ private final AggregateContext moduleContext;
+
+ private final ModuleComponent moduleComponent;
+
+ private static final String SYSTEM_MODULE_COMPONENT = "org.apache.tuscany.core.system";
+
+ /**
+ * Construct a runtime using a null MonitorFactory.
+ *
+ * @param name the name of the module component
+ * @param uri the URI to assign to the module component
+ * @throws ConfigurationException if there was a problem loading the SCA configuration
+ * @see TuscanyRuntime#TuscanyRuntime(String, String, org.apache.tuscany.common.monitor.MonitorFactory)
+ */
+ public TuscanyRuntime(String name, String uri) throws ConfigurationException {
+ this(name, uri,
+ Thread.currentThread().getContextClassLoader(),
+ new NullMonitorFactory());
+ }
+
+ /**
+ * Construct a runtime containing a single module component with the
+ * specified name. The module definition is loaded from a "/sca.module"
+ * resource found on the classpath of the current Thread context classloader.
+ *
+ * @param name the name of the module component
+ * @param uri the URI to assign to the module component
+ * @param classLoader the class loader to use for the assembly
+ * @param monitorFactory the MonitorFactory for this runtime
+ * @throws ConfigurationException if there was a problem loading the SCA configuration
+ */
+ public TuscanyRuntime(String name, String uri, ClassLoader classLoader, MonitorFactory monitorFactory) throws ConfigurationException {
+ this.monitor = monitorFactory.getMonitor(TuscanyRuntime.Monitor.class);
+
+ // Create an assembly model context
+ AssemblyModelContext modelContext = BootstrapHelper.getModelContext(classLoader);
+
+ // Create a runtime context and start it
+ List<SCDLModelLoader> loaders = modelContext.getAssemblyLoader().getLoaders();
+ List<ContextFactoryBuilder> configBuilders = BootstrapHelper.getBuilders();
+ runtime = new RuntimeContextImpl(monitorFactory, loaders, configBuilders, new DefaultWireBuilder());
+ runtime.start();
+ monitor.started(runtime);
+
+ // Load and start the system configuration
+ SystemAggregateContext systemContext = runtime.getSystemContext();
+ ModuleComponentConfigurationLoader loader = BootstrapHelper.getConfigurationLoader(systemContext, modelContext);
+ ModuleComponent systemModuleComponent = loader.loadSystemModuleComponent(SYSTEM_MODULE_COMPONENT, SYSTEM_MODULE_COMPONENT);
+ AggregateContext context = BootstrapHelper.registerModule(systemContext, systemModuleComponent);
+ context.fireEvent(EventContext.MODULE_START, null);
+
+ // Load the SCDL configuration of the application module
+ AggregateContext rootContext = runtime.getRootContext();
+ moduleComponent = loader.loadModuleComponent(name, uri);
+ moduleContext = BootstrapHelper.registerModule(rootContext, moduleComponent);
+ }
+
+ public ModuleComponent getModuleComponent() {
+ return moduleComponent;
+ }
+
+ public AggregateContext getModuleContext() {
+ return moduleContext;
+ }
+
+ /**
+ * Start the runtime and associate the module context with the calling thread.
+ */
+ @Override
+ public void start() {
+ setModuleContext((ModuleContext) moduleContext);
+ try {
+ //moduleContext.start();
+ moduleContext.fireEvent(EventContext.MODULE_START, null);
+ moduleContext.fireEvent(EventContext.REQUEST_START, null);
+ moduleContext.fireEvent(EventContext.SESSION_NOTIFY, sessionKey);
+ monitor.started(moduleContext);
+ } catch (CoreRuntimeException e) {
+ setModuleContext(null);
+ monitor.startFailed(moduleContext, e);
+ //FIXME throw a better exception
+ throw new ServiceRuntimeException(e);
+ }
+ }
+
+ /**
+ * Disassociate the module context from the current thread and shut down the runtime.
+ */
+ @Override
+ public void stop() {
+ setModuleContext(null);
+ moduleContext.fireEvent(EventContext.REQUEST_END, null);
+ moduleContext.fireEvent(EventContext.SESSION_END, sessionKey);
+ moduleContext.fireEvent(EventContext.MODULE_STOP, null);
+ moduleContext.stop();
+ monitor.stopped(moduleContext);
+ runtime.stop();
+ monitor.stopped(runtime);
+ }
+
+ /**
+ * Monitor interface for a TuscanyRuntime.
+ */
+ public static interface Monitor {
+ /**
+ * Event emitted after the runtime has been started.
+ *
+ * @param ctx the runtime's module component context
+ */
+ void started(AggregateContext ctx);
+
+ /**
+ * Event emitted when an attempt to start the runtime failed.
+ *
+ * @param ctx the runtime's module component context
+ * @param e the exception that caused the failure
+ */
+ void startFailed(AggregateContext ctx, CoreRuntimeException e);
+
+ /**
+ * Event emitted after the runtime has been stopped.
+ *
+ * @param ctx the runtime's module component context
+ */
+ void stopped(AggregateContext ctx);
+ }
+
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/tuscany/servicemix/JBIBinding.java b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/tuscany/servicemix/JBIBinding.java
new file mode 100644
index 0000000000..04781d6d69
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/tuscany/servicemix/JBIBinding.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.servicemix;
+
+import org.apache.tuscany.spi.model.Binding;
+
+/**
+ * Represents a JBI binding
+ */
+public class JBIBinding extends Binding {
+
+ private String uri;
+
+ private String port;
+
+ public String getPort() {
+ return port;
+ }
+
+ public void setPort(String port) {
+ this.port = port;
+ }
+
+ public String getURI() {
+ return uri;
+ }
+
+ public void setURI(String uri) {
+ this.uri = uri;
+ }
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/tuscany/servicemix/JBIBindingLoader.java b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/tuscany/servicemix/JBIBindingLoader.java
new file mode 100644
index 0000000000..8b6806a731
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/tuscany/servicemix/JBIBindingLoader.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.servicemix;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.LoaderExtension;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.loader.LoaderRegistry;
+import org.apache.tuscany.spi.loader.LoaderUtil;
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * Loader for handling <binding.jbi> elements.
+ */
+@Scope("MODULE")
+public class JBIBindingLoader extends LoaderExtension<JBIBinding> {
+
+ public static final QName BINDING_JBI = new QName("http://tuscany.apache.org/xmlns/binding/rmi/1.0-SNAPSHOT", "binding.jbi");
+
+ public JBIBindingLoader(@Autowire LoaderRegistry registry) {
+ super(registry);
+ }
+
+ public QName getXMLType() {
+ return BINDING_JBI;
+ }
+
+ public JBIBinding load(CompositeComponent parent, XMLStreamReader reader, DeploymentContext deploymentContext) throws XMLStreamException,
+ LoaderException {
+
+ String port = reader.getAttributeValue(null, "port");
+ String uri = reader.getAttributeValue(null, "uri");
+ LoaderUtil.skipToEndElement(reader);
+
+ JBIBinding binding = new JBIBinding();
+ binding.setPort(port);
+ binding.setURI(uri);
+
+ return binding;
+ }
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/tuscany/servicemix/ServiceMixBuilder.java b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/tuscany/servicemix/ServiceMixBuilder.java
new file mode 100644
index 0000000000..227d56d0b7
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/tuscany/servicemix/ServiceMixBuilder.java
@@ -0,0 +1,57 @@
+/*
+ * 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 pejbissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.servicemix;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.SCAObject;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.BindingBuilderExtension;
+import org.apache.tuscany.spi.model.BoundReferenceDefinition;
+import org.apache.tuscany.spi.model.BoundServiceDefinition;
+
+/**
+ * Builds a Service or Reference for a JBI binding.
+ */
+public class ServiceMixBuilder extends BindingBuilderExtension<JBIBinding> {
+
+ protected Class<JBIBinding> getBindingType() {
+ return JBIBinding.class;
+ }
+
+ @SuppressWarnings( { "unchecked" })
+ public SCAObject build(CompositeComponent parent, BoundServiceDefinition<JBIBinding> boundServiceDefinition, DeploymentContext deploymentContext) {
+
+ String name = boundServiceDefinition.getName();
+
+ ServiceMixService serviceMixService = new ServiceMixService(name, parent, wireService, null);
+
+ return serviceMixService;
+ }
+
+ @SuppressWarnings( { "unchecked" })
+ public ServiceMixReference build(CompositeComponent parent, BoundReferenceDefinition<JBIBinding> boundReferenceDefinition,
+ DeploymentContext deploymentContext) {
+
+
+ ServiceMixReference serviceMixReference = new ServiceMixReference(null, parent, wireService, null, null);
+
+ return serviceMixReference;
+
+ }
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/tuscany/servicemix/ServiceMixInvoker.java b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/tuscany/servicemix/ServiceMixInvoker.java
new file mode 100644
index 0000000000..5ad2aae7b5
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/tuscany/servicemix/ServiceMixInvoker.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.servicemix;
+
+import java.lang.reflect.InvocationTargetException;
+
+import javax.jbi.messaging.DeliveryChannel;
+import javax.jbi.messaging.ExchangeStatus;
+import javax.jbi.messaging.InOut;
+import javax.jbi.messaging.MessagingException;
+import javax.jbi.messaging.NormalizedMessage;
+import javax.xml.namespace.QName;
+
+import org.apache.servicemix.jbi.jaxp.StringSource;
+import org.apache.servicemix.sca.ScaServiceUnit;
+import org.apache.tuscany.spi.extension.TargetInvokerExtension;
+
+/**
+ * Invoke a JBI reference.
+ */
+public class ServiceMixInvoker extends TargetInvokerExtension {
+
+ private QName serviceName;
+
+ private ScaServiceUnit serviceUnit;
+
+ public ServiceMixInvoker(QName serviceName) {
+ this.serviceName = serviceName;
+ this.serviceUnit = ScaServiceUnit.getCurrentScaServiceUnit();
+ }
+
+ public Object invokeTarget(Object payload) throws InvocationTargetException {
+ try {
+ DeliveryChannel channel = serviceUnit.getComponent().getComponentContext().getDeliveryChannel();
+
+ // TODO: in-only case ?
+ // TODO: interface based routing ?
+ // TODO: explicit endpoint selection ?
+
+ InOut inout = channel.createExchangeFactory().createInOutExchange();
+ inout.setService(serviceName);
+ NormalizedMessage in = inout.createMessage();
+ inout.setInMessage(in);
+ in.setContent(new StringSource(payload.toString()));
+
+ boolean sent = channel.sendSync(inout);
+ // TODO: check for error ?
+
+ NormalizedMessage out = inout.getOutMessage();
+ Object response = out.getContent();
+ inout.setStatus(ExchangeStatus.DONE);
+ channel.send(inout);
+
+ return response;
+
+ } catch (MessagingException e) {
+ throw new InvocationTargetException(e);
+ }
+ }
+
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/tuscany/servicemix/ServiceMixReference.java b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/tuscany/servicemix/ServiceMixReference.java
new file mode 100644
index 0000000000..e9898f8f15
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/tuscany/servicemix/ServiceMixReference.java
@@ -0,0 +1,54 @@
+/*
+ * 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.servicemix;
+
+import java.lang.reflect.Method;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.extension.ReferenceExtension;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+import org.apache.tuscany.spi.wire.WireService;
+
+/**
+ *
+ */
+public class ServiceMixReference<T> extends ReferenceExtension<T> {
+
+ private final String uri;
+
+ public ServiceMixReference(String name,
+ CompositeComponent<?> parent,
+ WireService wireService,
+ String uri,
+ Class<T> service)
+ {
+ super(name, service, parent, wireService);
+ setInterface(service);
+ this.uri = uri;
+ }
+
+ public TargetInvoker createTargetInvoker(Method arg0) {
+ QName serviceName = null;
+ ServiceMixInvoker invoker = new ServiceMixInvoker(serviceName);
+ return invoker;
+ }
+
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/tuscany/servicemix/ServiceMixService.java b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/tuscany/servicemix/ServiceMixService.java
new file mode 100644
index 0000000000..ae7e9e3f1b
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/java/org/apache/tuscany/servicemix/ServiceMixService.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.servicemix;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.extension.ServiceExtension;
+import org.apache.tuscany.spi.wire.WireService;
+
+/**
+ *
+ */
+public class ServiceMixService<T> extends ServiceExtension<T> {
+
+ public ServiceMixService(String name, CompositeComponent parent, WireService wireService, Class<T> service) {
+ super(name, service, parent, wireService);
+ }
+
+ public void start() {
+ super.start();
+ }
+
+ public void stop() {
+ super.stop();
+ }
+
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/jbi/META-INF/DISCLAIMER b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/jbi/META-INF/DISCLAIMER
new file mode 100644
index 0000000000..14eddf5d92
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/jbi/META-INF/DISCLAIMER
@@ -0,0 +1,6 @@
+Apache ServiceMix is an effort undergoing incubation at the Apache Software Foundation (ASF), sponsored by the Geronimo PMC.
+Incubation is required of all newly accepted projects until a further review indicates that the infrastructure,
+communications, and decision making process have stabilized in a manner consistent with other successful ASF projects.
+
+While incubation status is not necessarily a reflection of the completeness or stability of the code, it does
+indicate that the project has yet to be fully endorsed by the ASF.
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/jbi/META-INF/LICENSE b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/jbi/META-INF/LICENSE
new file mode 100644
index 0000000000..6b0b1270ff
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/jbi/META-INF/LICENSE
@@ -0,0 +1,203 @@
+
+ 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/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/jbi/META-INF/NOTICE b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/jbi/META-INF/NOTICE
new file mode 100644
index 0000000000..c035229231
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/main/jbi/META-INF/NOTICE
@@ -0,0 +1,11 @@
+ =========================================================================
+ == NOTICE file corresponding to the section 4 d of ==
+ == the Apache License, Version 2.0, ==
+ == in this case for the Apache ServiceMix distribution. ==
+ =========================================================================
+
+ This product includes software developed by
+ The Apache Software Foundation (http://www.apache.org/).
+
+ Additional copyright notices and license terms applicable are
+ present in the licenses directory of this distribution.
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/AssemblyLoaderTest.java b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/AssemblyLoaderTest.java
new file mode 100644
index 0000000000..2edf9882ec
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/AssemblyLoaderTest.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.servicemix.sca;
+
+import java.io.File;
+import java.net.URL;
+import java.net.URLClassLoader;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.servicemix.sca.assembly.JbiBinding;
+import org.apache.servicemix.sca.tuscany.TuscanyRuntime;
+import org.apache.tuscany.common.monitor.impl.NullMonitorFactory;
+import org.apache.tuscany.model.assembly.Binding;
+import org.apache.tuscany.model.assembly.Component;
+import org.apache.tuscany.model.assembly.EntryPoint;
+import org.apache.tuscany.model.assembly.ExternalService;
+import org.apache.tuscany.model.assembly.Module;
+
+/**
+ * @author delfinoj
+ */
+public class AssemblyLoaderTest extends TestCase {
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
+ }
+
+ public void testLoader() throws Exception {
+ String name = "bigbank";
+ String uri = getClass().getResource("bigbank/sca.module").toString();
+
+ URL url = getClass().getResource("bigbank/sca.module");
+ URL parentUrl = new File(url.toURI()).getParentFile().toURL();
+ ClassLoader cl = new URLClassLoader(new URL[] { parentUrl }, getClass().getClassLoader());
+
+ TuscanyRuntime rt = new TuscanyRuntime(name, uri, cl, new NullMonitorFactory());
+ assertNotNull(rt);
+
+ Module module = rt.getModuleComponent().getModuleImplementation();
+
+ Assert.assertTrue(module.getName().equals("org.apache.servicemix.sca.bigbank"));
+
+ Component component = module.getComponent("AccountServiceComponent");
+ Assert.assertTrue(component != null);
+
+ EntryPoint entryPoint = module.getEntryPoint("AccountService");
+ Assert.assertTrue(entryPoint != null);
+
+ ExternalService externalService = module.getExternalService("StockQuoteService");
+ Assert.assertTrue(externalService != null);
+
+ Binding binding = externalService.getBindings().get(0);
+ Assert.assertTrue(binding instanceof JbiBinding);
+ }
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/ScaComponentTest.java b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/ScaComponentTest.java
new file mode 100644
index 0000000000..bd6c4b3e88
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/ScaComponentTest.java
@@ -0,0 +1,110 @@
+/*
+ * 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.servicemix.sca;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.net.URL;
+
+import javax.naming.InitialContext;
+import javax.xml.bind.JAXBContext;
+import javax.xml.namespace.QName;
+import javax.xml.transform.Source;
+import javax.xml.transform.dom.DOMSource;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.servicemix.client.DefaultServiceMixClient;
+import org.apache.servicemix.client.ServiceMixClient;
+import org.apache.servicemix.components.util.MockServiceComponent;
+import org.apache.servicemix.jbi.container.ActivationSpec;
+import org.apache.servicemix.jbi.container.JBIContainer;
+import org.apache.servicemix.jbi.jaxp.SourceTransformer;
+import org.apache.servicemix.jbi.jaxp.StringSource;
+import org.apache.servicemix.jbi.resolver.ServiceNameEndpointResolver;
+import org.apache.servicemix.sca.bigbank.stockquote.StockQuoteResponse;
+import org.w3c.dom.Node;
+
+public class ScaComponentTest extends TestCase {
+
+ private static Log log = LogFactory.getLog(ScaComponentTest.class);
+
+ protected JBIContainer container;
+
+ protected void setUp() throws Exception {
+ container = new JBIContainer();
+ container.setUseMBeanServer(false);
+ container.setCreateMBeanServer(false);
+ container.setMonitorInstallationDirectory(false);
+ container.setNamingContext(new InitialContext());
+ container.setEmbedded(true);
+ container.init();
+ }
+
+ protected void tearDown() throws Exception {
+ if (container != null) {
+ container.shutDown();
+ }
+ }
+
+ public void testDeploy() throws Exception {
+ ScaComponent component = new ScaComponent();
+ container.activateComponent(component, "JSR181Component");
+
+ MockServiceComponent mock = new MockServiceComponent();
+ mock.setService(new QName("http://www.quickstockquote.com", "StockQuoteService"));
+ mock.setEndpoint("StockQuoteServiceJBI");
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ StockQuoteResponse r = new StockQuoteResponse();
+ r.setResult(8.23f);
+ JAXBContext.newInstance(StockQuoteResponse.class).createMarshaller().marshal(r, baos);
+ mock.setResponseXml(baos.toString());
+ ActivationSpec as = new ActivationSpec();
+ as.setComponent(mock);
+ container.activateComponent(as);
+
+ // Start container
+ container.start();
+
+ // Deploy SU
+ component.getServiceUnitManager().deploy("su", getServiceUnitPath("org/apache/servicemix/sca/bigbank"));
+ component.getServiceUnitManager().init("su", getServiceUnitPath("org/apache/servicemix/sca/bigbank"));
+ component.getServiceUnitManager().start("su");
+
+ ServiceMixClient client = new DefaultServiceMixClient(container);
+ Source req = new StringSource("<AccountReportRequest><CustomerID>id</CustomerID></AccountReportRequest>");
+ Object rep = client.request(new ServiceNameEndpointResolver(
+ new QName("http://sca.servicemix.apache.org/Bigbank/Account", "AccountService")),
+ null, null, req);
+ if (rep instanceof Node) {
+ rep = new DOMSource((Node) rep);
+ }
+ log.info(new SourceTransformer().toString((Source) rep));
+ }
+
+ protected String getServiceUnitPath(String name) {
+ URL url = getClass().getClassLoader().getResource(name + "/sca.module");
+ File path = new File(url.getFile());
+ path = path.getParentFile();
+ return path.getAbsolutePath();
+ }
+
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountReportRequest.java b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountReportRequest.java
new file mode 100644
index 0000000000..00c55aeffc
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountReportRequest.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 org.apache.servicemix.sca.bigbank.account;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "", propOrder = { "customerID" })
+@XmlRootElement(name = "AccountReportRequest")
+public class AccountReportRequest {
+
+ @XmlElement(name = "CustomerID")
+ private String customerID;
+
+ public String getCustomerID() {
+ return customerID;
+ }
+
+ public void setCustomerID(String customerID) {
+ this.customerID = customerID;
+ }
+
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountReportResponse.java b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountReportResponse.java
new file mode 100644
index 0000000000..f52985d2c1
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountReportResponse.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.servicemix.sca.bigbank.account;
+
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "", propOrder = { "accountSummaries" })
+@XmlRootElement(name = "AccountReportResponse")
+public class AccountReportResponse {
+
+ @XmlElement(name = "AccountSummaries")
+ private List<AccountSummary> accountSummaries;
+
+ public List<AccountSummary> getAccountSummaries() {
+ return accountSummaries;
+ }
+
+ public void setAccountSummaries(List<AccountSummary> accountSummaries) {
+ this.accountSummaries = accountSummaries;
+ }
+
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountService.java b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountService.java
new file mode 100644
index 0000000000..5c2997f2c3
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountService.java
@@ -0,0 +1,27 @@
+/*
+ * 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.servicemix.sca.bigbank.account;
+
+import org.osoa.sca.annotations.Remotable;
+
+@Remotable
+public interface AccountService {
+
+ public AccountReportResponse getAccountReport(AccountReportRequest request);
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountServiceImpl.java b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountServiceImpl.java
new file mode 100644
index 0000000000..f0cad13f5c
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountServiceImpl.java
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.servicemix.sca.bigbank.account;
+
+import java.util.ArrayList;
+
+import org.apache.servicemix.sca.bigbank.accountdata.AccountDataService;
+import org.apache.servicemix.sca.bigbank.accountdata.CheckingAccount;
+import org.apache.servicemix.sca.bigbank.accountdata.SavingsAccount;
+import org.apache.servicemix.sca.bigbank.accountdata.StockAccount;
+import org.apache.servicemix.sca.bigbank.stockquote.StockQuoteRequest;
+import org.apache.servicemix.sca.bigbank.stockquote.StockQuoteResponse;
+import org.apache.servicemix.sca.bigbank.stockquote.StockQuoteService;
+import org.osoa.sca.annotations.Property;
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Service;
+
+@Service(interfaces=AccountService.class)
+public class AccountServiceImpl implements AccountService {
+
+ @Property
+ public String currency = "USD";
+
+ @Reference
+ public AccountDataService accountDataService;
+ @Reference
+ public StockQuoteService stockQuoteService;
+
+ public AccountServiceImpl() {
+ }
+
+ public AccountReportResponse getAccountReport(AccountReportRequest request) {
+ AccountReportResponse report = new AccountReportResponse();
+ String customerID = request.getCustomerID();
+ report.setAccountSummaries(new ArrayList<AccountSummary>());
+ report.getAccountSummaries().add(getCheckAccountSummary(customerID));
+ report.getAccountSummaries().add(getSavingsAccountSummary(customerID));
+ report.getAccountSummaries().add(getStockAccountSummary(customerID));
+ return report;
+ }
+
+ private AccountSummary getCheckAccountSummary(String customerID) {
+ CheckingAccount checking = accountDataService.getCheckingAccount(customerID);
+ AccountSummary summary = new AccountSummary();
+ summary.setAccountNumber(checking.getAccountNumber());
+ summary.setAccountType("Checking");
+ summary.setBalance(checking.getBalance());
+ return summary;
+ }
+
+ private AccountSummary getSavingsAccountSummary(String customerID) {
+ SavingsAccount savings = accountDataService.getSavingsAccount(customerID);
+ AccountSummary summary = new AccountSummary();
+ summary.setAccountNumber(savings.getAccountNumber());
+ summary.setAccountType("Savings");
+ summary.setBalance(savings.getBalance());
+ return summary;
+ }
+
+ private AccountSummary getStockAccountSummary(String customerID) {
+ StockAccount stock = accountDataService.getStockAccount(customerID);
+ AccountSummary summary = new AccountSummary();
+ summary.setAccountNumber(stock.getAccountNumber());
+ summary.setAccountType("Stock");
+ float quote = getQuote(stock.getSymbol());
+ summary.setBalance(quote * stock.getQuantity());
+ return summary;
+ }
+
+ private float getQuote(String symbol) {
+ StockQuoteRequest req = new StockQuoteRequest();
+ req.setSymbol(symbol);
+ StockQuoteResponse rep = stockQuoteService.getQuote(req);
+ return rep.getResult();
+ }
+
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountSummary.java b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountSummary.java
new file mode 100644
index 0000000000..f6e5a060af
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountSummary.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.servicemix.sca.bigbank.account;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "", propOrder = { "accountNumber", "accountType", "balance" })
+@XmlRootElement(name = "AccountSummary")
+public class AccountSummary {
+
+ @XmlElement(name = "AccountNumber")
+ private String accountNumber;
+
+ @XmlElement(name = "AccountType")
+ private String accountType;
+
+ @XmlElement(name = "Balance")
+ private float balance;
+
+ public AccountSummary() {
+ }
+
+ public String getAccountNumber() {
+ return accountNumber;
+ }
+
+ public void setAccountNumber(String accountNumber) {
+ this.accountNumber = accountNumber;
+ }
+
+ public String getAccountType() {
+ return accountType;
+ }
+
+ public void setAccountType(String accountType) {
+ this.accountType = accountType;
+ }
+
+ public float getBalance() {
+ return balance;
+ }
+
+ public void setBalance(float balance) {
+ this.balance = balance;
+ }
+
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/accountdata/AccountDataService.java b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/accountdata/AccountDataService.java
new file mode 100644
index 0000000000..972b9dc704
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/accountdata/AccountDataService.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.servicemix.sca.bigbank.accountdata;
+
+public interface AccountDataService {
+
+ CheckingAccount getCheckingAccount(String customerID);
+
+ SavingsAccount getSavingsAccount(String customerID);
+
+ StockAccount getStockAccount(String customerID);
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/accountdata/AccountDataServiceImpl.java b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/accountdata/AccountDataServiceImpl.java
new file mode 100644
index 0000000000..f9d0c08df7
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/accountdata/AccountDataServiceImpl.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.servicemix.sca.bigbank.accountdata;
+
+public class AccountDataServiceImpl implements AccountDataService {
+
+ public CheckingAccount getCheckingAccount(String customerID) {
+
+ CheckingAccount checkingAccount = new CheckingAccount();
+ checkingAccount.setAccountNumber(customerID + "_" + "CHA12345");
+ checkingAccount.setBalance(1500.0f);
+
+ return checkingAccount;
+ }
+
+ public SavingsAccount getSavingsAccount(String customerID) {
+
+ SavingsAccount savingsAccount = new SavingsAccount();
+ savingsAccount.setAccountNumber(customerID + "_" + "SAA12345");
+ savingsAccount.setBalance(1500.0f);
+
+ return savingsAccount;
+ }
+
+ public StockAccount getStockAccount(String customerID) {
+
+ StockAccount stockAccount = new StockAccount();
+ stockAccount.setAccountNumber(customerID + "_" + "STA12345");
+ stockAccount.setSymbol("IBM");
+ stockAccount.setQuantity(100);
+
+ return stockAccount;
+ }
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/accountdata/CheckingAccount.java b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/accountdata/CheckingAccount.java
new file mode 100644
index 0000000000..596dcc8d06
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/accountdata/CheckingAccount.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.servicemix.sca.bigbank.accountdata;
+
+public class CheckingAccount {
+
+ private String accountNumber;
+ private float balance;
+
+ public String getAccountNumber() {
+ return accountNumber;
+ }
+
+ public void setAccountNumber(String accountNumber) {
+ this.accountNumber = accountNumber;
+ }
+
+ public float getBalance() {
+ return balance;
+ }
+
+ public void setBalance(float balance) {
+ this.balance = balance;
+ }
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/accountdata/SavingsAccount.java b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/accountdata/SavingsAccount.java
new file mode 100644
index 0000000000..c208788ca8
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/accountdata/SavingsAccount.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.servicemix.sca.bigbank.accountdata;
+
+public class SavingsAccount {
+
+ private String accountNumber;
+ private float balance;
+
+ public String getAccountNumber() {
+ return accountNumber;
+ }
+
+ public void setAccountNumber(String accountNumber) {
+ this.accountNumber = accountNumber;
+ }
+
+ public float getBalance() {
+ return balance;
+ }
+
+ public void setBalance(float balance) {
+ this.balance = balance;
+ }
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/accountdata/StockAccount.java b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/accountdata/StockAccount.java
new file mode 100644
index 0000000000..1005bceb91
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/accountdata/StockAccount.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.servicemix.sca.bigbank.accountdata;
+
+public class StockAccount {
+
+ private String accountNumber;
+ private String symbol;
+ private int quantity;
+
+ public String getAccountNumber() {
+ return accountNumber;
+ }
+
+ public void setAccountNumber(String accountNumber) {
+ this.accountNumber = accountNumber;
+ }
+
+ public int getQuantity() {
+ return quantity;
+ }
+
+ public void setQuantity(int quantity) {
+ this.quantity = quantity;
+ }
+
+ public String getSymbol() {
+ return symbol;
+ }
+
+ public void setSymbol(String symbol) {
+ this.symbol = symbol;
+ }
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/stockquote/StockQuoteRequest.java b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/stockquote/StockQuoteRequest.java
new file mode 100644
index 0000000000..4f12b18601
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/stockquote/StockQuoteRequest.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 org.apache.servicemix.sca.bigbank.stockquote;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "", propOrder = { "symbol" })
+@XmlRootElement(name = "StockQuoteRequest")
+public class StockQuoteRequest {
+
+ @XmlElement(name = "Symbol")
+ private String symbol;
+
+ public String getSymbol() {
+ return symbol;
+ }
+
+ public void setSymbol(String symbol) {
+ this.symbol = symbol;
+ }
+
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/stockquote/StockQuoteResponse.java b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/stockquote/StockQuoteResponse.java
new file mode 100644
index 0000000000..bf2d7c7c00
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/stockquote/StockQuoteResponse.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 org.apache.servicemix.sca.bigbank.stockquote;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "", propOrder = { "result" })
+@XmlRootElement(name = "StockQuoteResponse")
+public class StockQuoteResponse {
+
+ @XmlElement(name = "Result")
+ private float result;
+
+ public float getResult() {
+ return result;
+ }
+
+ public void setResult(float result) {
+ this.result = result;
+ }
+
+}
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/stockquote/StockQuoteService.java b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/stockquote/StockQuoteService.java
new file mode 100644
index 0000000000..3fa1558907
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/java/org/apache/servicemix/sca/bigbank/stockquote/StockQuoteService.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.servicemix.sca.bigbank.stockquote;
+
+import org.osoa.sca.annotations.Remotable;
+
+@Remotable
+public interface StockQuoteService {
+
+ public StockQuoteResponse getQuote(StockQuoteRequest stockQuote);
+}
+
+
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/resources/log4j-tests.properties b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/resources/log4j-tests.properties
new file mode 100644
index 0000000000..ec53858ed2
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/resources/log4j-tests.properties
@@ -0,0 +1,38 @@
+#
+# 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.
+#
+# The logging properties used during tests..
+#
+log4j.rootLogger=DEBUG, out
+
+log4j.logger.org.apache.activemq=INFO
+log4j.logger.org.apache.activemq.spring=WARN
+log4j.logger.org.apache.activemq.store.journal=INFO
+log4j.logger.org.activeio.journal=INFO
+
+# CONSOLE appender not used by default
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+
+# File appender
+log4j.appender.out=org.apache.log4j.FileAppender
+log4j.appender.out.layout=org.apache.log4j.PatternLayout
+log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+log4j.appender.out.file=target/servicemix-test.log
+log4j.appender.out.append=true
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/resources/log4j.properties b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/resources/log4j.properties
new file mode 100644
index 0000000000..992c894051
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/resources/log4j.properties
@@ -0,0 +1,39 @@
+#
+# 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.
+#
+#
+# The logging properties used during tests..
+#
+log4j.rootLogger=DEBUG, stdout
+
+log4j.logger.org.apache.activemq=INFO
+log4j.logger.org.apache.activemq.spring=WARN
+log4j.logger.org.apache.activemq.store.journal=INFO
+log4j.logger.org.activeio.journal=INFO
+
+# CONSOLE appender not used by default
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+
+# File appender
+log4j.appender.out=org.apache.log4j.FileAppender
+log4j.appender.out.layout=org.apache.log4j.PatternLayout
+log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+log4j.appender.out.file=target/servicemix-test.log
+log4j.appender.out.append=true
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/resources/org/apache/servicemix/sca/bigbank/account/AccountService.wsdl b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/resources/org/apache/servicemix/sca/bigbank/account/AccountService.wsdl
new file mode 100644
index 0000000000..9797a5739c
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/resources/org/apache/servicemix/sca/bigbank/account/AccountService.wsdl
@@ -0,0 +1,80 @@
+<?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.
+-->
+<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:tns="http://sca.servicemix.apache.org/Bigbank/Account"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://sca.servicemix.apache.org/Bigbank/Account"
+ name="AccountService">
+
+ <wsdl:types>
+ <xsd:schema targetNamespace="http://sca.servicemix.apache.org/Bigbank/Account" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <xsd:element name="getAccountReportRequest" type="tns:AccountReportRequest"/>
+ <xsd:complexType name="AccountReportRequest">
+ <xsd:sequence>
+ <xsd:element name="CustomerID" type="xsd:string"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:element name="getAccountReportResponse" type="tns:AccountReportResponse"/>
+
+ <xsd:complexType name="AccountReportResponse">
+ <xsd:sequence>
+ <xsd:element name="AccountSummaries">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="AccountSummary"
+ type="tns:AccountSummary" maxOccurs="unbounded" minOccurs="0"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:sequence>
+ </xsd:complexType>
+ <xsd:complexType name="AccountSummary">
+ <xsd:sequence>
+ <xsd:element name="AccountNumber" type="xsd:string"/>
+ <xsd:element name="AccountType" type="xsd:string"/>
+ <xsd:element name="Balance" type="xsd:float"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ </xsd:schema>
+ </wsdl:types>
+ <wsdl:message name="getAccountReportRequest">
+ <wsdl:part element="tns:getAccountReportRequest" name="getAccountReportRequest"/>
+ </wsdl:message>
+ <wsdl:message name="getAccountReportResponse">
+ <wsdl:part element="tns:getAccountReportResponse" name="getAccountReportResponse"/>
+ </wsdl:message>
+ <wsdl:portType name="AccountService">
+ <wsdl:operation name="getAccountReport">
+ <wsdl:input message="tns:getAccountReportRequest"/>
+ <wsdl:output message="tns:getAccountReportResponse"/>
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name="AccountServiceJBI" type="tns:AccountService">
+ </wsdl:binding>
+ <wsdl:service name="AccountService">
+ <wsdl:port binding="tns:AccountServiceJBI"
+ name="AccountServiceJBI">
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
diff --git a/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/resources/org/apache/servicemix/sca/bigbank/sca.module b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/resources/org/apache/servicemix/sca/bigbank/sca.module
new file mode 100644
index 0000000000..ae520dd54e
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/binding.servicemix/src/test/resources/org/apache/servicemix/sca/bigbank/sca.module
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * 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.
+-->
+<module xmlns="http://www.osoa.org/xmlns/sca/0.9" xmlns:v="http://www.osoa.org/xmlns/sca/values/0.9"
+
+ name="org.apache.servicemix.sca.bigbank">
+
+ <entryPoint name="AccountService">
+ <interface.java interface="org.apache.servicemix.sca.bigbank.account.AccountService"/>
+ <interface.wsdl interface="http://sca.servicemix.apache.org/Bigbank/Account#AccountService"/>
+ <binding.jbi port="http://sca.servicemix.apache.org/Bigbank/Account/AccountService/AccountServiceJBI"/>
+ <reference>AccountServiceComponent</reference>
+ </entryPoint>
+
+ <component name="AccountServiceComponent">
+ <implementation.java class="org.apache.servicemix.sca.bigbank.account.AccountServiceImpl"/>
+ <properties>
+ <v:currency>EURO</v:currency>
+ </properties>
+ <references>
+ <v:accountDataService>AccountDataServiceComponent</v:accountDataService>
+ <v:stockQuoteService>StockQuoteService</v:stockQuoteService>
+ </references>
+ </component>
+
+ <component name="AccountDataServiceComponent">
+ <implementation.java class="org.apache.servicemix.sca.bigbank.accountdata.AccountDataServiceImpl"/>
+ </component>
+
+ <externalService name="StockQuoteService">
+ <interface.java interface="org.apache.servicemix.sca.bigbank.stockquote.StockQuoteService"/>
+ <binding.jbi port="http://www.quickstockquote.com/StockQuoteService/StockQuoteServiceJBI"/>
+ </externalService>
+
+ <import.wsdl
+ location="org/apache/servicemix/sca/bigbank/account/AccountService.wsdl"
+ namespace="http://sca.servicemix.apache.org/Bigbank/Account" />
+
+</module>
+
diff --git a/branches/sca-java-M2/sca/services/bindings/pom.xml b/branches/sca-java-M2/sca/services/bindings/pom.xml
new file mode 100644
index 0000000000..8b255c7b2f
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/pom.xml
@@ -0,0 +1,63 @@
+<?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>
+
+ <parent>
+ <groupId>org.apache.tuscany.sca.services</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.tuscany.sca.services.bindings</groupId>
+ <artifactId>parent</artifactId>
+ <packaging>pom</packaging>
+ <name>Tuscany SCA Bindings</name>
+
+ <profiles>
+ <profile>
+ <id>full</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <modules>
+ <!-- temporary project to download and install the celtix required sun jars. The jars
+ are all CDDL so will be available on ibiblio when Sun releases them. This is just temporary.-->
+
+ <module>sunjars</module>
+ <module>binding.celtix</module>
+ <module>binding.axis2</module>
+ <module>binding.jsonrpc</module>
+ <module>binding.rmi</module>
+ </modules>
+ </profile>
+ <profile>
+ <id>release</id>
+ <activation>
+ <activeByDefault>false</activeByDefault>
+ </activation>
+ <modules>
+ <module>binding.axis2</module>
+ <module>binding.rmi</module>
+ </modules>
+ </profile>
+ </profiles>
+
+</project>
diff --git a/branches/sca-java-M2/sca/services/bindings/sunjars/build.xml b/branches/sca-java-M2/sca/services/bindings/sunjars/build.xml
new file mode 100644
index 0000000000..e6fec45356
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/sunjars/build.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 name="CeltixSunJarsInstaller">
+ <target name="checkinstalled">
+ <condition property="already.installed" >
+ <and>
+ <available file="${localRepository}/javax/annotation/jsr250-api/2.0-JAXWS-2.0-EA3/jsr250-api-2.0-JAXWS-2.0-EA3.jar"/>
+ <available file="${localRepository}/javax/jws/jsr181-api/2.0-JAXWS-2.0-EA3/jsr181-api-2.0-JAXWS-2.0-EA3.jar"/>
+ <available file="${localRepository}/javax/xml/jaxws-api/2.0-JAXWS-2.0-EA3/jaxws-api-2.0-JAXWS-2.0-EA3.jar"/>
+ <available file="${localRepository}/com/sun/xml/saaj-impl/1.3/saaj-impl-1.3.jar"/>
+ <available file="${localRepository}/javax/xml/saaj-api/1.3/saaj-api-1.3.jar"/>
+ </and>
+ </condition>
+ <condition property="maven.suffix" value="">
+ <os family="unix"/>
+ </condition>
+ <condition property="maven.suffix" value=".bat">
+ <os family="windows"/>
+ </condition>
+ </target>
+
+ <target name="installJars" depends="checkinstalled" unless="already.installed">
+ <exec executable="mvn${maven.suffix}" dir="${basedir}" failonerror="false">
+ <arg line="install:install-file -DgroupId=javax.annotation -DartifactId=jsr250-api -Dversion=2.0-JAXWS-2.0-EA3 -Dpackaging=jar -DgeneratePom=true -Dfile=${basedir}/target/celtix-install/celtix/lib/jsr250-api-2.0-JAXWS-2.0-EA3.jar"/>
+ </exec>
+ <exec executable="mvn${maven.suffix}" dir="${basedir}" failonerror="false">
+ <arg line="install:install-file -DgroupId=javax.jws -DartifactId=jsr181-api -Dversion=2.0-JAXWS-2.0-EA3 -Dpackaging=jar -DgeneratePom=true -Dfile=${basedir}/target/celtix-install/celtix/lib/jsr181-api-2.0-JAXWS-2.0-EA3.jar"/>
+ </exec>
+ <exec executable="mvn${maven.suffix}" dir="${basedir}" failonerror="false">
+ <arg line="install:install-file -DgroupId=javax.xml -DartifactId=jaxws-api -Dversion=2.0-JAXWS-2.0-EA3 -Dpackaging=jar -DgeneratePom=true -Dfile=${basedir}/target/celtix-install/celtix/lib/jaxws-api-2.0-JAXWS-2.0-EA3.jar"/>
+ </exec>
+ <exec executable="mvn${maven.suffix}" dir="${basedir}" failonerror="false">
+ <arg line="install:install-file -DgroupId=javax.xml -DartifactId=saaj-api -Dversion=1.3 -Dpackaging=jar -DgeneratePom=true -Dfile=${basedir}/target/celtix-install/celtix/lib/saaj-api-1.3.jar"/>
+ </exec>
+ <exec executable="mvn${maven.suffix}" dir="${basedir}" failonerror="false">
+ <arg line="install:install-file -DgroupId=com.sun.xml -DartifactId=saaj-impl -Dversion=1.3 -Dpackaging=jar -DgeneratePom=true -Dfile=${basedir}/target/celtix-install/celtix/lib/saaj-impl-1.3.jar"/>
+ </exec>
+ </target>
+</project>
diff --git a/branches/sca-java-M2/sca/services/bindings/sunjars/pom.xml b/branches/sca-java-M2/sca/services/bindings/sunjars/pom.xml
new file mode 100644
index 0000000000..d227956013
--- /dev/null
+++ b/branches/sca-java-M2/sca/services/bindings/sunjars/pom.xml
@@ -0,0 +1,102 @@
+<?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 xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.apache.tuscany.sca.services.bindings</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>sunjars</artifactId>
+ <packaging>pom</packaging>
+ <name>Project to install the Sun jars</name>
+
+ <properties>
+ <celtix.version>1.0</celtix.version>
+ </properties>
+ <repositories>
+ <repository>
+ <id>objectweb</id>
+ <name>ObjectWeb repo</name>
+ <url>http://maven.objectweb.org/maven2</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+
+ <build>
+ <plugins>
+ <!-- This is a "hack" to overcome the Sun jar issue. Basically, we download a
+ complete celtix install kit (epl version) and then extract the Sun jars that we
+ need and install them. We use the dependency plugin to download it from the
+ objectweb snapshot mirror, then use antrun to fork a build.xml that will conditionally
+ call mvn to install the jars if they aren't already there. -->
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>dependency-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>getdeps</id>
+ <phase>validate</phase>
+ <goals>
+ <goal>unpack</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>${project.build.directory}/celtix-install</outputDirectory>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.objectweb.celtix</groupId>
+ <artifactId>celtix-distribution</artifactId>
+ <version>${celtix.version}</version>
+ <classifier>bin-epl</classifier>
+ </artifactItem>
+ </artifactItems>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>install</id>
+ <phase>install</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <tasks>
+ <ant target="installJars">
+ <property name="localRepository" value="${settings.localRepository}"/>
+ </ant>
+ </tasks>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>