summaryrefslogtreecommitdiffstats
path: root/sca-java-1.x/tags/java-stable-20060304/sca
diff options
context:
space:
mode:
Diffstat (limited to 'sca-java-1.x/tags/java-stable-20060304/sca')
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/LICENSE.txt202
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/pom.xml70
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/assembly/WebServiceAssemblyFactory.java31
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/assembly/WebServiceBinding.java51
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/assembly/impl/WebServiceAssemblyFactoryImpl.java42
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/assembly/impl/WebServiceBindingImpl.java116
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/builder/ExternalWebServiceConfigurationBuilder.java150
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/builder/ExternalWebServiceWireBuilder.java61
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/builder/WebServiceEntryPointConfigurationBuilder.java170
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/config/ExternalWebServiceRuntimeConfiguration.java32
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/config/WebServiceEntryPointRuntimeConfiguration.java32
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/engine/config/AxisEngineConfigurationFactory.java265
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/handler/ExternalWebServiceClient.java119
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/handler/ExternalWebServiceTargetInvoker.java109
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/handler/WebServiceEntryPointServlet.java82
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/handler/WebServiceOperationMetaData.java484
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/handler/WebServicePortMetaData.java362
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/loader/WebServiceSCDLModelLoader.java74
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/resources/org/apache/tuscany/binding/axis/Messages.properties28
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/resources/org/apache/tuscany/binding/axis/engine/config/server-config.wsdd60
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/resources/system.fragment37
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/test/java/org/apache/tuscany/binding/axis/assembly/tests/WebServiceAssemblyLoaderTestCase.java87
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/test/java/org/apache/tuscany/binding/axis/assembly/tests/bigbank/account/services/account/AccountReport.java32
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/test/java/org/apache/tuscany/binding/axis/assembly/tests/bigbank/account/services/account/AccountService.java25
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/test/java/org/apache/tuscany/binding/axis/assembly/tests/bigbank/account/services/account/AccountServiceImpl.java42
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/test/java/org/apache/tuscany/binding/axis/assembly/tests/bigbank/account/services/account/AccountSummary.java46
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/test/java/org/apache/tuscany/binding/axis/assembly/tests/bigbank/account/services/accountdata/AccountDataService.java26
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/test/java/org/apache/tuscany/binding/axis/assembly/tests/bigbank/account/services/accountdata/AccountDataServiceImpl.java48
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/test/java/org/apache/tuscany/binding/axis/assembly/tests/bigbank/account/services/accountdata/CheckingAccount.java39
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/test/java/org/apache/tuscany/binding/axis/assembly/tests/bigbank/account/services/accountdata/SavingsAccount.java39
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/test/java/org/apache/tuscany/binding/axis/assembly/tests/bigbank/account/services/accountdata/StockAccount.java48
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/test/java/org/apache/tuscany/binding/axis/assembly/tests/bigbank/account/services/stockquote/StockQuoteService.java24
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/test/resources/org/apache/tuscany/binding/axis/assembly/tests/bigbank/account/services/account/AccountService.wsdl78
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/test/resources/org/apache/tuscany/binding/axis/assembly/tests/bigbank/account/services/stockquote/StockQuoteWebService.wsdl98
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/test/resources/org/apache/tuscany/binding/axis/assembly/tests/sca.module66
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/test/resources/org/apache/tuscany/binding/axis/mediator/tests/DocLit.wsdl76
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/test/resources/org/apache/tuscany/binding/axis/mediator/tests/DocLitWrapped.wsdl83
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/test/resources/org/apache/tuscany/binding/axis/mediator/tests/RpcLit.wsdl75
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/test/resources/org/apache/tuscany/binding/axis/mediator/tests/sca.module20
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/LICENSE.txt202
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/pom.xml130
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/assembly/WebServiceAssemblyFactory.java31
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/assembly/WebServiceBinding.java51
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/assembly/impl/WebServiceAssemblyFactoryImpl.java42
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/assembly/impl/WebServiceBindingImpl.java116
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/builder/ExternalWebServiceConfigurationBuilder.java153
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/builder/ExternalWebServiceWireBuilder.java61
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/builder/WebServiceEntryPointConfigurationBuilder.java170
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/config/ExternalWebServiceRuntimeConfiguration.java32
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/config/WebServiceEntryPointRuntimeConfiguration.java32
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/handler/ExternalWebServiceClient.java143
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/handler/ExternalWebServiceTargetInvoker.java110
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/handler/WebServiceEntryPointInOutSyncMessageReceiver.java177
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/handler/WebServiceEntryPointServlet.java480
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/handler/WebServiceOperationMetaData.java484
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/handler/WebServicePortMetaData.java362
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/loader/WebServiceSCDLModelLoader.java74
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/util/AxiomHelper.java185
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/resources/org/apache/tuscany/binding/axis2/engine/config/axis2.xml167
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/resources/system.fragment37
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/assembly/tests/WebServiceAssemblyLoaderTestCase.java87
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/account/AccountReport.java32
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/account/AccountService.java25
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/account/AccountServiceImpl.java42
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/account/AccountSummary.java46
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/accountdata/AccountDataService.java26
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/accountdata/AccountDataServiceImpl.java48
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/accountdata/CheckingAccount.java39
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/accountdata/SavingsAccount.java39
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/accountdata/StockAccount.java48
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/stockquote/StockQuoteService.java24
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/util/AxiomHelperTestCase.java88
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/resources/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/account/AccountService.wsdl78
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/resources/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/stockquote/StockQuoteWebService.wsdl98
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/resources/org/apache/tuscany/binding/axis2/assembly/tests/sca.module66
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/resources/org/apache/tuscany/binding/axis2/mediator/tests/DocLit.wsdl76
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/resources/org/apache/tuscany/binding/axis2/mediator/tests/DocLitWrapped.wsdl83
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/resources/org/apache/tuscany/binding/axis2/mediator/tests/RpcLit.wsdl75
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/resources/org/apache/tuscany/binding/axis2/mediator/tests/sca.module20
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/resources/org/apache/tuscany/binding/axis2/util/helloworld.wsdl106
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/common/LICENSE.txt202
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/common/pom.xml37
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/common/src/main/java/org/apache/tuscany/common/TuscanyException.java85
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/common/src/main/java/org/apache/tuscany/common/TuscanyRuntimeException.java91
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/common/src/main/java/org/apache/tuscany/common/discovery/util/ServiceProviderRegistry.java177
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/common/src/main/java/org/apache/tuscany/common/io/util/ClassLoaderObjectInputStream.java73
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/common/src/main/java/org/apache/tuscany/common/io/util/FixedURLClassLoader.java310
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/common/src/main/java/org/apache/tuscany/common/io/util/FixedURLInputStream.java119
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/common/src/main/java/org/apache/tuscany/common/io/util/IOHelper.java128
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/common/src/main/java/org/apache/tuscany/common/io/util/UTF8String.java107
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/common/src/main/java/org/apache/tuscany/common/monitor/LogLevel.java37
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/common/src/main/java/org/apache/tuscany/common/monitor/MonitorFactory.java35
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/common/src/main/java/org/apache/tuscany/common/monitor/impl/InvalidLevelException.java43
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/common/src/main/java/org/apache/tuscany/common/monitor/impl/JavaLoggingMonitorFactory.java139
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/common/src/main/java/org/apache/tuscany/common/monitor/impl/NullMonitorFactory.java48
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/common/src/main/java/org/apache/tuscany/common/resource/ResourceLoader.java94
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/common/src/main/java/org/apache/tuscany/common/resource/impl/ResourceLoaderImpl.java175
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/common/src/main/resources/META-INF/services/org.apache.tuscany.common.logging.LogProvider1
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/common/src/main/resources/META-INF/services/org.apache.tuscany.common.resource.loader.ResourceLoaderProvider1
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/common/src/main/resources/org/apache/tuscany/common/Messages.properties25
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/common/src/test/java/org/apache/tuscany/common/monitor/impl/JavaLoggingTestCase.java145
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/common/src/test/resources/org/apache/tuscany/common/monitor/impl/JavaLoggingTestCase$Monitor.properties1
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/LICENSE.txt202
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/pom.xml44
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/main/java/org/apache/tuscany/container/java/assembly/JavaAssemblyFactory.java32
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/main/java/org/apache/tuscany/container/java/assembly/JavaImplementation.java37
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/main/java/org/apache/tuscany/container/java/assembly/impl/JavaAssemblyFactoryImpl.java42
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/main/java/org/apache/tuscany/container/java/assembly/impl/JavaImplementationImpl.java97
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/main/java/org/apache/tuscany/container/java/builder/JavaComponentContextBuilder.java348
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/main/java/org/apache/tuscany/container/java/builder/JavaTargetWireBuilder.java85
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/main/java/org/apache/tuscany/container/java/config/JavaComponentRuntimeConfiguration.java151
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/main/java/org/apache/tuscany/container/java/context/JavaComponentContext.java206
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/main/java/org/apache/tuscany/container/java/invocation/AbstractJavaComponentInvoker.java92
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/main/java/org/apache/tuscany/container/java/invocation/ScopedJavaComponentInvoker.java86
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/main/java/org/apache/tuscany/container/java/invocation/StaticJavaComponentTargetInvoker.java50
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/main/java/org/apache/tuscany/container/java/loader/JavaSCDLModelLoader.java81
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/main/resources/org/apache/tuscany/container/java/Messages.properties25
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/main/resources/system.fragment38
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/main/test/sca.module75
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/impl/JavaImplementationTestCase.java137
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/mock/HelloWorldImpl.componentType23
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/mock/HelloWorldImpl.java36
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/mock/HelloWorldService.java27
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/mock/HelloWorldWithFieldProperties.java40
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/mock/NakedHelloWorld.java26
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/mock/NakedHelloWorldWithInterface.java28
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/JavaAssemblyLoaderTestCase.java88
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/account/AccountReport.java32
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/account/AccountService.java25
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/account/AccountService.wsdl78
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/account/AccountServiceImpl.java42
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/account/AccountSummary.java46
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/accountdata/AccountDataService.java26
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/accountdata/AccountDataServiceImpl.java48
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/accountdata/CheckingAccount.java39
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/accountdata/SavingsAccount.java39
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/accountdata/StockAccount.java48
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/stockquote/StockQuoteService.java24
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/stockquote/StockQuoteServiceImpl.java28
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/stockquote/StockQuoteWebService.wsdl98
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/builder/JavaComponentContextBuilderTestCase.java111
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/builder/JavaTargetWireBuilderTestCase.java115
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/builder/MockHandlerBuilder.java86
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/builder/MockInterceptorBuilder.java74
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/config/ModuleComponentConfigurationLoaderTestCase.java80
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/context/BadPojoTestCase.java70
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/context/PojoLifecycleTestCase.java71
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/context/PojoTestCase.java94
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/integration/JavaBuilderContextIntegrationTestCase.java240
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/integration/JavaIntegrationTestCase.java64
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/integration/JavaRuntimeBootstrapTestCase.java54
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/integration/binding/EntryPointToJavaTestCase.java248
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/integration/binding/JavaToExternalServiceTestCase.java61
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/integration/context/ScopeReferenceTestCase.java709
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/invocation/MediationTestCase.java53
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/invocation/ScopedPojoInvokerTestCase.java54
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/invocation/StaticPojoInvokerTestCase.java155
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/invocation/mock/MockHandler.java25
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/invocation/mock/MockSyncInterceptor.java45
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/invocation/mock/SimpleSource.java25
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/invocation/mock/SimpleSourceImpl.java36
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/invocation/mock/SimpleTarget.java28
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/invocation/mock/SimpleTargetImpl.java39
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/MockConfigContext.java56
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/MockFactory.java548
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/MockScopeContext.java137
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooBinding.java59
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooBindingBuilder.java192
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooBindingWireBuilder.java56
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooClient.java37
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooESTargetInvoker.java97
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooEntryPointRuntimeConfiguration.java31
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooExternalServiceRuntimeConfiguration.java32
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/AbstractGenericComponent.java296
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/BadContextPojo.java26
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/BadNamePojo.java24
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/DataObject.java38
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/GenericComponent.java142
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/HelloWorldClient.java46
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/LocalComponentImpl.java97
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/ModuleScopeComponent.java29
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/ModuleScopeComponentImpl.componentType32
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/ModuleScopeComponentImpl.java47
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/ModuleScopeDestroyOnlyComponent.java34
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/ModuleScopeEagerInitComponent.java39
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/ModuleScopeEagerInitDestroyComponent.java33
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/ModuleScopeInitDestroyComponent.java34
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/ModuleScopeInitOnlyComponent.java38
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/RemotableService.java40
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/RemotableServiceImpl.java61
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/RequestScopeComponent.java28
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/RequestScopeComponentImpl.java25
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/SessionScopeComponent.java28
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/SessionScopeComponentImpl.java25
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/SessionScopeDestroyOnlyComponent.java34
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/SessionScopeInitDestroyComponent.java34
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/SessionScopeInitOnlyComponent.java35
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/StatelessComponent.java28
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/StatelessComponentImpl.java25
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/scopes/AggregateScopeTestCase.java178
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/scopes/BasicHttpSessionScopeTestCase.java223
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/scopes/BasicModuleScopeTestCase.java126
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/scopes/BasicRequestScopeTestCase.java148
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/scopes/BasicStatelessScopeTestCase.java125
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/scopes/HttpSessionScopeLifecycleTestCase.java157
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/scopes/ModuleScopeLifecycleTestCase.java224
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/scopes/OrderException.java38
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/scopes/OrderedEagerInitPojo.java54
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/scopes/OrderedInitPojo.java54
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/scopes/RequestScopeLifecycleTestCase.java146
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/resources/org/apache/tuscany/container/java/assembly/tests/sca.module54
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/resources/org/apache/tuscany/container/java/config/ModuleComponentLoaderTest1.module24
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/LICENSE.txt202
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/pom.xml75
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/main/java/org/apache/tuscany/container/js/assembly/JavaScriptAssemblyFactory.java28
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/main/java/org/apache/tuscany/container/js/assembly/JavaScriptImplementation.java34
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/main/java/org/apache/tuscany/container/js/assembly/impl/JavaScriptAssemblyFactoryImpl.java33
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/main/java/org/apache/tuscany/container/js/assembly/impl/JavaScriptImplementationImpl.java116
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/main/java/org/apache/tuscany/container/js/builder/JavaScriptComponentContextBuilder.java217
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/main/java/org/apache/tuscany/container/js/builder/JavaScriptTargetWireBuilder.java75
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/main/java/org/apache/tuscany/container/js/config/JavaScriptComponentRuntimeConfiguration.java101
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/main/java/org/apache/tuscany/container/js/context/JavaScriptComponentContext.java161
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/main/java/org/apache/tuscany/container/js/loader/JavaScriptSCDLModelLoader.java77
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/main/java/org/apache/tuscany/container/js/rhino/RhinoScript.java298
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/main/java/org/apache/tuscany/container/js/rhino/RhinoTargetInvoker.java81
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/main/resources/model/sca-implementation-js.xsd41
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/main/resources/org/apache/tuscany/container/js/handler/JavaScriptComponentConfigurationHandler.componentType23
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/main/resources/system.fragment33
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/samples/java/org/apache/tuscany/container/js/sample/helloworld/HelloWorld.java7
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/samples/java/org/apache/tuscany/container/js/sample/helloworld/HelloWorldImpl.componentType9
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/samples/java/org/apache/tuscany/container/js/sample/helloworld/HelloWorldImpl.js4
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/samples/java/org/apache/tuscany/container/js/sample/helloworld/Main.java25
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/samples/java/sca.module25
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/impl/JavaScriptImplementationTestCase.java75
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/mock/HelloWorldService.java24
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/JavaScriptAssemblyLoaderTestCase.java76
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/account/AccountReport.java32
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/account/AccountService.java25
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/account/AccountSummary.java46
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/accountdata/AccountDataService.java26
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/accountdata/AccountDataServiceImpl.java48
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/accountdata/CheckingAccount.java39
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/accountdata/SavingsAccount.java39
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/accountdata/StockAccount.java48
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/stockquote/StockQuoteService.java24
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/stockquote/StockQuoteServiceImpl.java28
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/stockquote/StockQuoteWebService.wsdl98
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/builder/JSComponentContextBuilderTestCase.java51
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/builder/MockHandlerBuilder.java86
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/builder/MockInterceptorBuilder.java74
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/config/ModuleComponentConfigurationLoaderTestCase.java78
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/integration/JSComponentContextTestCase.java91
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/invocation/mock/MockHandler.java27
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/invocation/mock/MockSyncInterceptor.java50
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/mock/MockAssemblyFactory.java156
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/mock/MockModuleFactory.java115
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/rhino/RhinoInvokerTestCase.java184
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/resources/org/apache/tuscany/container/js/assembly/mock/HelloWorldImpl.componentType23
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/resources/org/apache/tuscany/container/js/assembly/mock/HelloWorldImpl.js4
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/resources/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/AccountService.wsdl78
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/resources/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/AccountServiceImpl.componentType19
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/resources/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/account/AccountService.wsdl78
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/resources/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/account/AccountServiceImpl.componentType19
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/resources/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/accountdata/AccountDataServiceImpl.componentType9
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/resources/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/stockquote/StockQuoteServiceImpl.componentType9
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/resources/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/stockquote/StockQuoteWebService.wsdl98
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/resources/org/apache/tuscany/container/js/assembly/tests/sca.module54
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/resources/org/apache/tuscany/container/js/config/ModuleComponentLoaderTest1.module25
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/resources/org/apache/tuscany/container/js/rhino/RhinoInvokerTestCase.js22
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/LICENSE.txt202
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/pom.xml75
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/addressing/AddressingConstants.java33
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/addressing/AddressingFactory.java37
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/addressing/EndpointReference.java120
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/addressing/impl/AddressingFactoryImpl.java50
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/addressing/impl/EndpointReferenceImpl.java182
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/BuilderConfigException.java26
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/BuilderException.java41
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/BuilderInitException.java39
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/ConfigurationException.java26
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/ContextCreationException.java41
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/HierarchicalWireBuilder.java29
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/NoAccessorException.java39
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/ObjectFactory.java19
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/RuntimeConfiguration.java69
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/RuntimeConfigurationBuilder.java24
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/UnknownTypeException.java26
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/WireBuilder.java60
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/impl/AssemblyVisitor.java62
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/impl/BaseExternalServiceRuntimeConfiguration.java106
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/impl/DefaultWireBuilder.java110
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/impl/EntryPointRuntimeConfiguration.java104
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/impl/HierarchicalBuilder.java58
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/impl/ProxyObjectFactory.java42
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/client/TuscanyRuntime.java204
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/config/ComponentTypeIntrospector.java37
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/config/ConfigurationException.java42
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/config/ConfigurationLoadException.java47
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/config/ImplementationCache.java46
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/config/InvalidRootElementException.java51
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/config/JavaIntrospectionHelper.java349
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/config/MissingResourceException.java43
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/config/ModuleComponentConfigurationLoader.java74
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/config/impl/Java5ComponentTypeIntrospector.java423
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/config/impl/ModuleComponentConfigurationLoaderImpl.java142
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/AbstractContext.java89
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/AggregateContext.java85
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/AutowireContext.java35
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/AutowireResolutionException.java40
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/ConfigurationContext.java66
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/Context.java106
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/ContextInitException.java43
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/ContextRuntimeException.java39
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/CoreRuntimeException.java27
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/DuplicateNameException.java39
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/EntryPointContext.java57
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/EventContext.java66
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/EventException.java43
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/ExternalServiceContext.java24
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/InstanceContext.java75
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/InvalidNameException.java43
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/LifecycleEventListener.java32
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/QualifiedName.java83
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/RuntimeEventListener.java36
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/ScopeAwareContext.java31
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/ScopeContext.java72
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/ScopeIdentifier.java33
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/ScopeInitializationException.java42
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/ScopeRuntimeException.java43
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/ScopeStrategy.java43
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/ServiceNotFoundException.java42
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/SimpleComponentContext.java36
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/SystemAggregateContext.java36
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/TargetException.java42
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/impl/AbstractAggregateContext.java652
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/impl/AggregateContextImpl.java222
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/impl/EntryPointContextImpl.java112
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/impl/EventContextImpl.java77
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/impl/ExternalServiceContextImpl.java92
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/scope/AbstractScopeContext.java158
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/scope/AbstractScopeStrategy.java67
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/scope/AggregateScopeContext.java184
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/scope/DefaultScopeStrategy.java52
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/scope/HttpSessionScopeContext.java254
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/scope/ModuleScopeContext.java182
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/scope/RequestScopeContext.java224
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/scope/StatelessScopeContext.java145
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/webapp/HTTPSessionExpirationListener.java62
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/webapp/LazyHTTPSessionId.java56
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/webapp/TuscanyRequestFilter.java107
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/webapp/TuscanyWebAppRuntime.java59
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/injection/EventInvoker.java17
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/injection/FactoryInitException.java27
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/injection/FieldInjector.java45
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/injection/InjectionRuntimeException.java29
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/injection/Injector.java17
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/injection/MethodEventInvoker.java39
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/injection/MethodInjector.java30
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/injection/NullEventInvoker.java14
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/injection/ObjectCallbackException.java26
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/injection/ObjectCreationException.java27
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/injection/PojoObjectFactory.java75
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/injection/ReferenceTargetFactory.java133
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/injection/SDOObjectFactory.java37
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/injection/SingletonObjectFactory.java29
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/Interceptor.java42
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/InvocationConfiguration.java279
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/InvocationException.java29
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/InvocationRuntimeException.java44
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/MessageChannel.java33
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/MessageHandler.java34
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/MethodHashMap.java53
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/ProxyConfiguration.java101
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/TargetInvoker.java44
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/impl/InvokerInterceptor.java46
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/impl/MessageChannelImpl.java68
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/impl/MessageDispatcher.java46
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/impl/NullProxyFactory.java57
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/impl/OneWayInterceptor.java48
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/impl/RequestResponseInterceptor.java73
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/jdk/JDKInvocationHandler.java143
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/jdk/JDKProxyFactory.java96
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/jdk/JDKProxyFactoryFactory.java52
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/spi/ProxyCreationException.java43
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/spi/ProxyException.java40
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/spi/ProxyFactory.java79
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/spi/ProxyFactoryFactory.java42
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/spi/ProxyInitializationException.java43
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/loader/SCDLModelLoaderRegistry.java51
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/loader/impl/SCDLModelLoaderRegistryImpl.java49
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/message/Message.java182
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/message/MessageFactory.java31
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/message/impl/MessageFactoryImpl.java40
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/message/impl/MessageImpl.java249
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/runtime/RuntimeContext.java83
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/runtime/RuntimeContextImpl.java286
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/runtime/RuntimeMonitor.java32
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/runtime/RuntimeScopeStrategy.java46
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/annotation/Autowire.java21
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/annotation/ParentContext.java33
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/assembly/SystemAssemblyFactory.java38
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/assembly/SystemBinding.java37
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/assembly/SystemImplementation.java38
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/assembly/impl/SystemAssemblyFactoryImpl.java41
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/assembly/impl/SystemBindingImpl.java41
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/assembly/impl/SystemImplementationImpl.java94
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/builder/SystemComponentContextBuilder.java383
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/builder/SystemEntryPointBuilder.java63
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/builder/SystemExternalServiceBuilder.java77
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/config/SystemComponentRuntimeConfiguration.java140
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/config/SystemEntryPointRuntimeConfiguration.java92
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/config/SystemExternalServiceRuntimeConfiguration.java97
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/config/SystemObjectRuntimeConfiguration.java92
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/context/SystemAggregateContextImpl.java666
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/context/SystemComponentContext.java198
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/context/SystemEntryPointContext.java82
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/context/SystemExternalServiceContext.java82
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/context/SystemScopeStrategy.java56
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/injection/AutowireFactory.java50
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/loader/SystemSCDLModelLoader.java49
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/webapp/ContextBinder.java39
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/webapp/TuscanyRequestFilter.java97
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/webapp/TuscanyServletListener.java168
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/resources/META-INF/services/org.apache.tuscany.core.runtime.proxy.ServiceProxyFactory1
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/resources/model/anyobject.xsd35
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/resources/model/tuscany-system.xsd52
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/resources/org/apache/tuscany/core/Messages.properties25
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/resources/system.module26
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/builder/impl/DefaultWireBuilderTestCase.java447
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/builder/impl/NegativeDefaultWireBuilderTestCase.java71
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/config/JavaIntrospectionHelperTestCase.java37
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/config/ModuleComponentConfigurationLoaderTestCase.java68
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/context/AbstractAggregateHierarchyTests.java107
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/context/AggregateComponentContextRegisterTestCase.java130
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/context/AggregateHierarchyTestCase.java96
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/context/QualifiedNameTestCase.java52
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/context/scope/DefaultScopeStrategyTestCase.java52
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/injection/Bean1.java26
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/injection/ReflectionHelperTestCase.java74
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/injection/SuperBean.java27
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/InvocationConfigurationErrorTestCase.java158
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/InvocationConfigurationTestCase.java156
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/InvocationErrorTestCase.java124
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/jdk/JDKInvocationHandlerTestCase.java112
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/jdk/JDKProxyFactoryTestCase.java66
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/mock/MockHandler.java25
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/mock/MockScopeContext.java136
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/mock/MockStaticInvoker.java70
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/mock/MockSyncInterceptor.java45
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/mock/SimpleSource.java25
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/mock/SimpleSourceImpl.java36
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/mock/SimpleTarget.java28
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/mock/SimpleTargetImpl.java39
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/mock/MockConfigContext.java56
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/mock/MockFactory.java329
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/mock/component/GenericSystemComponent.java6
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/mock/component/ModuleScopeSystemComponent.java28
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/mock/component/ModuleScopeSystemComponentImpl.java25
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/runtime/RuntimeBootTestCase.java96
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/runtime/RuntimeContextImplTestCase.java305
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/system/builder/SystemComponentContextBuilderTestCase.java137
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/system/builder/SystemComponentImpl.java165
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/system/builder/impl/AssemblyVisitorTestCase.java123
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/system/context/SystemAggregateComponentContextRegisterTestCase.java40
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/system/context/SystemAggregateComponentContextTestCase.java127
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/system/context/SystemAggregateHierarchyTestCase.java49
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/system/context/SystemBootstrapTestCase.java130
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/system/context/SystemObjectRegistrationTestCase.java59
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/system/context/TestBuilder.java36
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/resources/org/apache/tuscany/core/config/ModuleComponentLoaderTest1.module24
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/resources/system.fragment21
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/LICENSE.txt202
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/pom.xml101
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/ModelRuntimeException.java41
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Aggregate.java117
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/AggregatePart.java40
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/AssemblyFactory.java162
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/AssemblyModelContext.java64
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/AssemblyModelObject.java45
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/AssemblyModelVisitor.java32
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Binding.java40
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Component.java80
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ComponentImplementation.java40
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ComponentType.java66
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ConfiguredPort.java57
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ConfiguredProperty.java62
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ConfiguredReference.java44
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ConfiguredService.java36
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/EntryPoint.java64
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Extensible.java38
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ExternalService.java59
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ModelInitException.java43
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Module.java39
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ModuleComponent.java47
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ModuleFragment.java25
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Multiplicity.java47
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/OverrideOption.java40
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Port.java47
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Property.java91
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Reference.java36
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/RuntimeConfigurationHolder.java36
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Scope.java32
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Service.java24
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ServiceContract.java62
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ServiceURI.java53
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/SimpleComponent.java25
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Subsystem.java38
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Wire.java48
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/AggregateImpl.java305
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/AggregatePartImpl.java67
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/AssemblyFactoryImpl.java204
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/AssemblyModelContextImpl.java92
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/AssemblyModelObjectImpl.java132
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/BindingImpl.java96
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ComponentImpl.java222
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ComponentImplementationImpl.java108
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ComponentTypeImpl.java152
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ConfiguredPortImpl.java142
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ConfiguredPropertyImpl.java123
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ConfiguredReferenceImpl.java72
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ConfiguredServiceImpl.java48
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/EntryPointImpl.java145
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ExtensibleImpl.java92
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ExternalServiceImpl.java135
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ModuleComponentImpl.java65
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ModuleFragmentImpl.java32
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ModuleImpl.java243
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/PortImpl.java106
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/PropertyImpl.java178
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ReferenceImpl.java50
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ServiceContractImpl.java81
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ServiceImpl.java32
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ServiceURIImpl.java198
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/SimpleComponentImpl.java32
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/SubsystemImpl.java49
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/WireImpl.java66
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/loader/AssemblyModelLoader.java81
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/scdl/loader/SCDLModelLoader.java36
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/scdl/loader/impl/AssemblyModelLoadException.java41
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/scdl/loader/impl/SCDLAssemblyModelLoaderImpl.java198
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/scdl/loader/impl/SCDLModelContentHandlerImpl.java708
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/scdl/loader/impl/SCDLXMLReader.java109
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/types/java/JavaServiceContract.java27
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/types/java/impl/JavaServiceContractImpl.java81
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/types/wsdl/WSDLServiceContract.java52
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/types/wsdl/impl/WSDLServiceContractImpl.java212
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/util/ModelContentHandler.java71
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/util/ModelTransformer.java51
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/util/ModelTransformerImpl.java125
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/util/XMLNameUtil.java227
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/resources/model/assembly.mdl6092
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/resources/model/assembly.pptbin0 -> 60416 bytes
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/resources/model/sca-binding-sca.xsd21
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/resources/model/sca-binding-webservice.xsd22
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/resources/model/sca-core.xsd225
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/resources/model/sca-implementation-java.xsd22
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/resources/model/sca-interface-java.xsd23
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/resources/model/sca-interface-wsdl.xsd39
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/resources/model/sca.xsd19
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/resources/org/apache/tuscany/model/Messages.properties25
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/SCDLAssemblyLoaderTestCase.java69
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/SCDLXMLReaderTestCase.java67
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/account/AccountReport.java32
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/account/AccountService.java25
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/account/AccountService.wsdl78
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/account/AccountServiceImpl.java42
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/account/AccountSummary.java46
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/accountdata/AccountDataService.java26
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/accountdata/AccountDataServiceImpl.java48
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/accountdata/CheckingAccount.java39
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/accountdata/SavingsAccount.java39
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/accountdata/StockAccount.java48
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/stockquote/StockQuoteService.java24
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/stockquote/StockQuoteServiceImpl.java28
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/stockquote/StockQuoteWebService.wsdl98
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/test/resources/org/apache/tuscany/model/assembly/tests/sca.module58
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/test/resources/org/apache/tuscany/model/assembly/tests/sca.subsystem24
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/plugin/LICENSE.txt202
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/plugin/pom.xml42
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/plugin/src/main/java/org/apache/tuscany/tools/wsdl2java/plugin/WSDL2JavaGeneratorMojo.java101
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/pom.xml69
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/tomcat/LICENSE.txt202
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/tomcat/pom.xml106
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/ContainerLoader.java100
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/TuscanyContextListener.java144
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/TuscanyHost.java162
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/TuscanyValve.java118
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/lifecycle/listener/BootstrapConfigurationException.java41
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/lifecycle/listener/RuntimeBootstrap.java113
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/lifecycle/listener/TomcatServerLifecycleListener.java40
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/lifecycle/listener/TomcatWebAppLifecycleListener.java249
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/lifecycle/listener/WebAppLifecycleListener.java152
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/main/resources/org/apache/tuscany/tomcat/LocalStrings.properties20
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/main/resources/org/apache/tuscany/tomcat/Messages.properties39
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/test/java/org/apache/tuscany/tomcat/integration/AbstractTomcatTest.java250
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/test/java/org/apache/tuscany/tomcat/integration/TestServlet.java50
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/test/java/org/apache/tuscany/tomcat/integration/TomcatIntegrationTestCase.java109
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/test/java/org/apache/tuscany/tomcat/integration/TomcatStandaloneTestCase.java63
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/test/resources/app1/WEB-INF/axis2.xml167
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/test/resources/app1/WEB-INF/classes/sca.module21
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/test/resources/app1/WEB-INF/web.xml6
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/test/resources/app1/index.html3
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/test/resources/app2/WEB-INF/classes/sca.module21
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/test/resources/app2/WEB-INF/web.xml29
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/test/resources/app2/index.html3
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/tools/LICENSE.txt202
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/tools/pom.xml110
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/tools/src/main/java/org/apache/tuscany/tools/wsdl2java/generate/JavaInterfaceGenerator.java142
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/tools/src/main/java/org/apache/tuscany/tools/wsdl2java/generate/SDODataBindingCodegenExtension.java48
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/tools/src/main/java/org/apache/tuscany/tools/wsdl2java/generate/WSDL2JavaGenerator.java319
610 files changed, 58317 insertions, 0 deletions
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/LICENSE.txt b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/LICENSE.txt
new file mode 100644
index 0000000000..d645695673
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/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/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/pom.xml b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/pom.xml
new file mode 100644
index 0000000000..64e3dcb19c
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/pom.xml
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Copyright (c) 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.
+ -->
+<project>
+ <parent>
+ <groupId>org.apache.tuscany</groupId>
+ <artifactId>tuscany-sca</artifactId>
+ <version>SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>tuscany-binding-axis</artifactId>
+ <name>Tuscany Axis Binding</name>
+ <description>Implementation of the SCA Web Services binding using Axis.</description>
+ <version>SNAPSHOT</version>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany</groupId>
+ <artifactId>tuscany-core</artifactId>
+ <version>${pom.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>axis</groupId>
+ <artifactId>axis</artifactId>
+ <version>1.2.1</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>axis</groupId>
+ <artifactId>axis-jaxrpc</artifactId>
+ <version>1.2.1</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>axis</groupId>
+ <artifactId>axis-saaj</artifactId>
+ <version>1.2.1</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>tomcat</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>5.0.18</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/assembly/WebServiceAssemblyFactory.java b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/assembly/WebServiceAssemblyFactory.java
new file mode 100644
index 0000000000..5d8f286944
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/assembly/WebServiceAssemblyFactory.java
@@ -0,0 +1,31 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.axis.assembly;
+
+import org.apache.tuscany.model.assembly.AssemblyFactory;
+
+/**
+ * The <b>Factory</b> for the model.
+ */
+public interface WebServiceAssemblyFactory extends AssemblyFactory {
+
+ /**
+ * Returns a new WebServiceBinding.
+ */
+ WebServiceBinding createWebServiceBinding();
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/assembly/WebServiceBinding.java b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/assembly/WebServiceBinding.java
new file mode 100644
index 0000000000..3c223ffa8e
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/assembly/WebServiceBinding.java
@@ -0,0 +1,51 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.axis.assembly;
+
+import javax.wsdl.Definition;
+import javax.wsdl.Port;
+
+import org.apache.tuscany.model.assembly.Binding;
+
+/**
+ * Represents a Web service binding.
+ */
+public interface WebServiceBinding extends Binding {
+
+ /**
+ * Returns the WSDL port defining this binding.
+ */
+ Port getWSDLPort();
+
+ /**
+ * Returns the WSDL definition containing the WSDL port.
+ * @return
+ */
+ Definition getWSDLDefinition();
+
+ /**
+ * Sets the WSDL port defining this binding.
+ */
+ void setWSDLPort(Port value);
+
+ /**
+ * Sets the WSDL definition containing the WSDL port.
+ * @param definition
+ */
+ void setWSDLDefinition(Definition definition);
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/assembly/impl/WebServiceAssemblyFactoryImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/assembly/impl/WebServiceAssemblyFactoryImpl.java
new file mode 100644
index 0000000000..4a3154f2c1
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/assembly/impl/WebServiceAssemblyFactoryImpl.java
@@ -0,0 +1,42 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.axis.assembly.impl;
+
+import org.apache.tuscany.binding.axis.assembly.WebServiceAssemblyFactory;
+import org.apache.tuscany.binding.axis.assembly.WebServiceBinding;
+import org.apache.tuscany.model.assembly.impl.AssemblyFactoryImpl;
+
+/**
+ * An implementation of the model <b>Factory</b>.
+ */
+public class WebServiceAssemblyFactoryImpl extends AssemblyFactoryImpl implements WebServiceAssemblyFactory {
+
+ /**
+ * Creates an instance of the factory.
+ */
+ public WebServiceAssemblyFactoryImpl() {
+ super();
+ }
+
+ /**
+ * @see org.apache.tuscany.binding.axis.assembly.WebServiceAssemblyFactory#createWebServiceBinding()
+ */
+ public WebServiceBinding createWebServiceBinding() {
+ return new WebServiceBindingImpl();
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/assembly/impl/WebServiceBindingImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/assembly/impl/WebServiceBindingImpl.java
new file mode 100644
index 0000000000..37ed0191e6
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/assembly/impl/WebServiceBindingImpl.java
@@ -0,0 +1,116 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.axis.assembly.impl;
+
+import java.util.Collection;
+import java.util.List;
+
+import javax.wsdl.Definition;
+import javax.wsdl.Port;
+import javax.wsdl.Service;
+
+import org.apache.tuscany.binding.axis.assembly.WebServiceBinding;
+import org.apache.tuscany.model.assembly.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.impl.BindingImpl;
+
+/**
+ * An implementation of WebServiceBinding.
+ */
+public class WebServiceBindingImpl extends BindingImpl implements WebServiceBinding {
+
+ private Definition definition;
+ private Port port;
+ private String portURI;
+
+ /**
+ * Constructor
+ */
+ protected WebServiceBindingImpl() {
+ }
+
+ /**
+ * @see org.apache.tuscany.binding.axis.assembly.WebServiceBinding#getWSDLPort()
+ */
+ public Port getWSDLPort() {
+ return port;
+ }
+
+ /**
+ * @see org.apache.tuscany.binding.axis.assembly.WebServiceBinding#setWSDLPort(javax.wsdl.Port)
+ */
+ public void setWSDLPort(Port value) {
+ checkNotFrozen();
+ this.port=value;
+ }
+
+ /**
+ * @see org.apache.tuscany.binding.axis.assembly.WebServiceBinding#getWSDLDefinition()
+ */
+ public Definition getWSDLDefinition() {
+ return definition;
+ }
+
+ /**
+ * @see org.apache.tuscany.binding.axis.assembly.WebServiceBinding#setWSDLDefinition(javax.wsdl.Definition)
+ */
+ public void setWSDLDefinition(Definition definition) {
+ checkNotFrozen();
+ this.definition=definition;
+ }
+
+ /**
+ * @param portURI The portURI to set.
+ */
+ public void setPortURI(String portURI) {
+ this.portURI = portURI;
+ }
+
+ /**
+ * @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 WSDL port namespace and name
+ if (port==null && portURI!=null) {
+ int h=portURI.indexOf('#');
+ String portNamespace=portURI.substring(0,h);
+ String portName=portURI.substring(h+1);
+
+ // Load the WSDL definitions for the given namespace
+ List<Definition> definitions=modelContext.getAssemblyLoader().loadDefinitions(portNamespace);
+ if (definitions==null)
+ throw new IllegalArgumentException("Cannot find WSDL definition for "+portNamespace);
+ for (Definition definition: definitions) {
+
+ // Find the port with the given name
+ for (Service service : (Collection<Service>)definition.getServices().values()) {
+ Port port=service.getPort(portName);
+ if (port!=null) {
+ this.definition=definition;
+ this.port=port;
+ return;
+ }
+ }
+ }
+ throw new IllegalArgumentException("Cannot find WSDL port "+portURI);
+ }
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/builder/ExternalWebServiceConfigurationBuilder.java b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/builder/ExternalWebServiceConfigurationBuilder.java
new file mode 100644
index 0000000000..c9c87e1e11
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/builder/ExternalWebServiceConfigurationBuilder.java
@@ -0,0 +1,150 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.axis.builder;
+
+import java.lang.reflect.Method;
+import java.util.Collection;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.tuscany.binding.axis.assembly.WebServiceBinding;
+import org.apache.tuscany.binding.axis.config.ExternalWebServiceRuntimeConfiguration;
+import org.apache.tuscany.binding.axis.handler.ExternalWebServiceClient;
+import org.apache.tuscany.core.builder.BuilderException;
+import org.apache.tuscany.core.builder.RuntimeConfigurationBuilder;
+import org.apache.tuscany.core.config.JavaIntrospectionHelper;
+import org.apache.tuscany.core.context.Context;
+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.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * Creates a <code>RuntimeConfigurationBuilder</code> for an external service configured with the {@link WebServiceBinding}
+ *
+ * @version $Rev$ $Date$
+ */
+@Scope("MODULE")
+public class ExternalWebServiceConfigurationBuilder implements RuntimeConfigurationBuilder {
+
+ private RuntimeContext runtimeContext;
+
+ private ProxyFactoryFactory proxyFactoryFactory;
+
+ private MessageFactory messageFactory;
+
+ private RuntimeConfigurationBuilder policyBuilder;
+
+ public ExternalWebServiceConfigurationBuilder() {
+ }
+
+ @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(RuntimeConfigurationBuilder builder) {
+ policyBuilder = builder;
+ }
+
+ public void build(AssemblyModelObject object, Context context) throws BuilderException {
+ if (!(object instanceof ExternalService)) {
+ return;
+ }
+ ExternalService externalService = (ExternalService) object;
+ if (externalService.getBindings().size() < 1 || !(externalService.getBindings().get(0) instanceof WebServiceBinding)) {
+ return;
+ }
+
+ WebServiceBinding wsBinding=(WebServiceBinding)externalService.getBindings().get(0);
+
+ ExternalWebServiceClient externalWebServiceClient=new ExternalWebServiceClient(externalService, wsBinding);
+ ExternalWebServiceRuntimeConfiguration config = new ExternalWebServiceRuntimeConfiguration(externalService.getName(), new SingletonObjectFactory<ExternalWebServiceClient>(externalWebServiceClient));
+
+ 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() + QualifiedName.NAME_SEPARATOR + 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, context);
+ }
+ // add tail interceptor
+ for (InvocationConfiguration iConfig : (Collection<InvocationConfiguration>) iConfigMap.values()) {
+ iConfig.addTargetInterceptor(new InvokerInterceptor());
+ }
+
+ externalService.getConfiguredService().setRuntimeConfiguration(config);
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/builder/ExternalWebServiceWireBuilder.java b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/builder/ExternalWebServiceWireBuilder.java
new file mode 100644
index 0000000000..e006b0e4ff
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/builder/ExternalWebServiceWireBuilder.java
@@ -0,0 +1,61 @@
+package org.apache.tuscany.binding.axis.builder;
+
+import org.apache.tuscany.binding.axis.config.ExternalWebServiceRuntimeConfiguration;
+import org.apache.tuscany.binding.axis.handler.ExternalWebServiceTargetInvoker;
+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 ExternalWebServiceWireBuilder implements WireBuilder {
+
+ private RuntimeContext runtimeContext;
+
+ /**
+ * Constructs a new ExternalWebServiceWireBuilder.
+ */
+ public ExternalWebServiceWireBuilder() {
+ 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 (!(ExternalWebServiceRuntimeConfiguration.class.isAssignableFrom(targetType))) {
+ return;
+ }
+ for (InvocationConfiguration sourceInvocationConfig : sourceFactory.getProxyConfiguration().getInvocationConfigurations().values()) {
+
+ ExternalWebServiceTargetInvoker invoker = new ExternalWebServiceTargetInvoker(sourceFactory.getProxyConfiguration().getTargetName(), sourceInvocationConfig.getMethod(), targetScopeContext);
+
+ // if (downScope) {
+ // // the source scope is shorter than the target, so the invoker can cache the target instance
+ // invoker.setCacheable(true);
+ // } else {
+ // invoker.setCacheable(false);
+ // }
+ sourceInvocationConfig.setTargetInvoker(invoker);
+ }
+
+ }
+
+ public void completeTargetChain(ProxyFactory targetFactory, Class targetType, ScopeContext targetScopeContext)
+ throws BuilderConfigException {
+ //TODO implement
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/builder/WebServiceEntryPointConfigurationBuilder.java b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/builder/WebServiceEntryPointConfigurationBuilder.java
new file mode 100644
index 0000000000..ac4b8b16eb
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/builder/WebServiceEntryPointConfigurationBuilder.java
@@ -0,0 +1,170 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.axis.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.tuscany.binding.axis.assembly.WebServiceBinding;
+import org.apache.tuscany.binding.axis.config.WebServiceEntryPointRuntimeConfiguration;
+import org.apache.tuscany.core.builder.BuilderException;
+import org.apache.tuscany.core.builder.RuntimeConfigurationBuilder;
+import org.apache.tuscany.core.builder.impl.EntryPointRuntimeConfiguration;
+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;
+
+/**
+ * Creates a <code>RuntimeConfigurationBuilder</code> for an entry point configured with the {@link WebServiceBinding}
+ *
+ * @version $Rev$ $Date$
+ */
+@Scope("MODULE")
+public class WebServiceEntryPointConfigurationBuilder implements RuntimeConfigurationBuilder<AggregateContext> {
+
+ private RuntimeContext runtimeContext;
+
+ private ProxyFactoryFactory proxyFactoryFactory;
+
+ private MessageFactory messageFactory;
+
+ private RuntimeConfigurationBuilder policyBuilder;
+
+ public WebServiceEntryPointConfigurationBuilder() {
+ }
+
+ @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(RuntimeConfigurationBuilder builder) {
+ policyBuilder = builder;
+ }
+
+ public void build(AssemblyModelObject object, AggregateContext parentContext) throws BuilderException {
+ if (!(object instanceof EntryPoint)) {
+ return;
+ }
+ EntryPoint entryPoint = (EntryPoint) object;
+ if (entryPoint.getBindings().size() < 1 || !(entryPoint.getBindings().get(0) instanceof WebServiceBinding)) {
+ return;
+ }
+
+ EntryPointRuntimeConfiguration config = new WebServiceEntryPointRuntimeConfiguration(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();
+ 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() + QualifiedName.NAME_SEPARATOR + 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, parentContext);
+ }
+ // add tail interceptor
+ for (InvocationConfiguration iConfig : (Collection<InvocationConfiguration>) iConfigMap.values()) {
+ iConfig.addTargetInterceptor(new EntryPointInvokerInterceptor());
+ }
+ entryPoint.getConfiguredReference().setRuntimeConfiguration(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/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/config/ExternalWebServiceRuntimeConfiguration.java b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/config/ExternalWebServiceRuntimeConfiguration.java
new file mode 100644
index 0000000000..c3145137dd
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/config/ExternalWebServiceRuntimeConfiguration.java
@@ -0,0 +1,32 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.axis.config;
+
+import org.apache.tuscany.core.builder.ObjectFactory;
+import org.apache.tuscany.core.builder.impl.BaseExternalServiceRuntimeConfiguration;
+
+/**
+ * Creates instances of {@link org.apache.tuscany.core.context.ExternalServiceContext} configured with the appropriate
+ * invocation chains and bindings. This implementation serves as a marker for
+ * {@link org.apache.tuscany.binding.axis.builder.ExternalWebServiceWireBuilder}
+ *
+ * @version $Rev$ $Date$
+ */
+public class ExternalWebServiceRuntimeConfiguration extends BaseExternalServiceRuntimeConfiguration {
+
+ public ExternalWebServiceRuntimeConfiguration(String name, ObjectFactory objectFactory) {
+ super(name, objectFactory);
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/config/WebServiceEntryPointRuntimeConfiguration.java b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/config/WebServiceEntryPointRuntimeConfiguration.java
new file mode 100644
index 0000000000..37fbd325e5
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/config/WebServiceEntryPointRuntimeConfiguration.java
@@ -0,0 +1,32 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.axis.config;
+
+import org.apache.tuscany.core.builder.impl.EntryPointRuntimeConfiguration;
+import org.apache.tuscany.core.message.MessageFactory;
+
+/**
+ * Creates instances of {@link org.apache.tuscany.core.context.EntryPointContext} configured with the appropriate
+ * invocation chains and bindings. This implementation serves as a marker for
+ * {@link org.apache.tuscany.binding.axis.builder.WebServiceEntryPointWireBuilder}
+ *
+ * @version $Rev$ $Date$
+ */
+public class WebServiceEntryPointRuntimeConfiguration extends EntryPointRuntimeConfiguration {
+
+ public WebServiceEntryPointRuntimeConfiguration(String name, String serviceName, MessageFactory messageFactory) {
+ super(name, serviceName, messageFactory);
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/engine/config/AxisEngineConfigurationFactory.java b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/engine/config/AxisEngineConfigurationFactory.java
new file mode 100644
index 0000000000..a14f3de037
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/engine/config/AxisEngineConfigurationFactory.java
@@ -0,0 +1,265 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.axis.engine.config;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.Method;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import javax.servlet.ServletConfig;
+import javax.wsdl.Definition;
+import javax.wsdl.Operation;
+import javax.wsdl.Port;
+import javax.wsdl.PortType;
+import javax.xml.namespace.QName;
+import javax.xml.rpc.Service;
+import javax.xml.rpc.ServiceException;
+import javax.xml.rpc.ServiceFactory;
+
+import org.apache.axis.EngineConfiguration;
+import org.apache.axis.EngineConfigurationFactory;
+import org.apache.axis.MessageContext;
+import org.apache.axis.configuration.FileProvider;
+import org.apache.axis.configuration.SimpleProvider;
+import org.apache.axis.constants.Style;
+import org.apache.axis.constants.Use;
+import org.apache.axis.description.JavaServiceDesc;
+import org.apache.axis.description.OperationDesc;
+import org.apache.axis.description.ParameterDesc;
+import org.apache.axis.handlers.soap.SOAPService;
+import org.apache.axis.providers.java.RPCProvider;
+import org.apache.tuscany.binding.axis.assembly.WebServiceBinding;
+import org.apache.tuscany.binding.axis.handler.WebServicePortMetaData;
+import org.apache.tuscany.common.resource.ResourceLoader;
+import org.apache.tuscany.core.config.JavaIntrospectionHelper;
+import org.apache.tuscany.core.context.AggregateContext;
+import org.apache.tuscany.core.context.webapp.TuscanyWebAppRuntime;
+import org.apache.tuscany.core.invocation.spi.ProxyFactory;
+import org.apache.tuscany.model.assembly.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.Binding;
+import org.apache.tuscany.model.assembly.EntryPoint;
+import org.apache.tuscany.model.assembly.Module;
+import org.osoa.sca.ServiceRuntimeException;
+import org.osoa.sca.ServiceUnavailableException;
+
+/**
+ */
+public class AxisEngineConfigurationFactory implements EngineConfigurationFactory {
+
+ private TuscanyWebAppRuntime tuscanyRuntime;
+
+ /**
+ * Constructor
+ *
+ */
+ public AxisEngineConfigurationFactory(TuscanyWebAppRuntime tuscanyRuntime) {
+ this.tuscanyRuntime = tuscanyRuntime;
+ }
+
+ /**
+ * Creates a new factory.
+ *
+ * @see org.apache.axis.configuration.EngineConfigurationFactoryFinder
+ */
+ public static EngineConfigurationFactory newFactory(Object param) {
+ if (param instanceof ServletConfig) {
+
+ // Only configure Tuscany apps
+ // Get the Tuscany runtime out of the servlet context
+ TuscanyWebAppRuntime tuscanyRuntime = (TuscanyWebAppRuntime) ((ServletConfig) param).getServletContext().getAttribute(TuscanyWebAppRuntime.class.getName());
+ if (tuscanyRuntime == null)
+ return null;
+
+ return new AxisEngineConfigurationFactory(tuscanyRuntime);
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * @see org.apache.axis.EngineConfigurationFactory#getClientEngineConfig()
+ */
+ public EngineConfiguration getClientEngineConfig() {
+
+ // Used only on the server side
+ return null;
+ }
+
+ /**
+ * @see org.apache.axis.EngineConfigurationFactory#getServerEngineConfig()
+ */
+ public EngineConfiguration getServerEngineConfig() {
+
+ // Get the current SCA module context
+ AggregateContext moduleContext = tuscanyRuntime.getModuleComponentContext();
+ tuscanyRuntime.start();
+ try {
+
+ Module module = (Module)moduleContext.getAggregate();
+ AssemblyModelContext modelContext = module.getAssemblyModelContext();
+
+ // Load the .wsdd configuration
+ ResourceLoader bundleContext = modelContext.getApplicationResourceLoader();
+ InputStream wsdd;
+ try {
+ URL url = bundleContext.getResource("org/apache/tuscany/binding/axis/engine/config/server-config.wsdd");
+ wsdd = url.openStream();
+ } catch (IOException e1) {
+ throw new ServiceRuntimeException(e1);
+ }
+ FileProvider wsddConfigurationProvider = new FileProvider(wsdd);
+
+ // Create our dynamic configuration
+ SimpleProvider dynamicConfigurationProvider = new SimpleProvider(wsddConfigurationProvider);
+
+ // Register all the Web service entry points
+ for (Iterator i = module.getEntryPoints().iterator(); i.hasNext();) {
+ EntryPoint entryPoint = (EntryPoint) i.next();
+ Binding binding = (Binding) entryPoint.getBindings().get(0);
+ if (binding instanceof WebServiceBinding) {
+ //FIXME This should not use the proxy factory - use EntryPointContext#getInstance()
+ // Get the proxy factory associated with the entry point
+ final ProxyFactory proxyFactory=(ProxyFactory)entryPoint.getConfiguredService().getProxyFactory();
+
+ // Create a new SOAP service
+ SOAPService service = new SOAPService(new RPCProvider() {
+ protected Object makeNewServiceObject(MessageContext arg0, String arg1) throws Exception {
+
+ // The SOAP service will delegate to a dynamic proxy
+ return proxyFactory.createProxy();
+ }
+ });
+
+ // Get the WSDL definition and port
+ WebServiceBinding wsBinding = (WebServiceBinding) binding;
+ Definition definition=wsBinding.getWSDLDefinition();
+ Port port=wsBinding.getWSDLPort();
+ WebServicePortMetaData wsPortMetaData = new WebServicePortMetaData(definition, port, null, false);
+
+ // Configure the SOAP service
+ service.setOption(RPCProvider.OPTION_WSDL_TARGETNAMESPACE, wsPortMetaData.getPortName().getNamespaceURI());
+ service.setOption(RPCProvider.OPTION_WSDL_SERVICEELEMENT, wsPortMetaData.getServiceName().getLocalPart());
+ service.setOption(RPCProvider.OPTION_WSDL_SERVICEPORT, wsPortMetaData.getPortName().getLocalPart());
+ service.setOption(RPCProvider.OPTION_WSDL_PORTTYPE, wsPortMetaData.getPortTypeName().getLocalPart());
+ //FIXME RPCProvider is not happy if you don't give it a class name...
+ service.setOption(RPCProvider.OPTION_CLASSNAME, Object.class.getName());
+
+ // Create a service description
+ JavaServiceDesc serviceDesc = (JavaServiceDesc) service.getServiceDescription();
+ serviceDesc.setName(entryPoint.getName());
+ String wsdlFile = definition.getDocumentBaseURI();
+ if (wsdlFile.startsWith("file:"))
+ wsdlFile = wsdlFile.substring(5);
+ serviceDesc.setWSDLFile(wsdlFile);
+ serviceDesc.setDefaultNamespace(wsPortMetaData.getPortName().getNamespaceURI());
+ serviceDesc.setStyle(Style.DOCUMENT);
+ serviceDesc.setUse(Use.LITERAL);
+
+ // Get the service interface
+ Class serviceInterface=entryPoint.getConfiguredService().getService().getServiceContract().getInterface();
+ Set methods=JavaIntrospectionHelper.getAllUniqueMethods(serviceInterface);
+ serviceDesc.setAllowedMethods(new ArrayList(methods));
+
+ // Create a JAX-RPC service
+ QName wsdlServiceName = wsPortMetaData.getService().getQName();
+ Service jaxrpcService;
+ try {
+ URL url=new URL(wsBinding.getWSDLDefinition().getDocumentBaseURI());
+ jaxrpcService = ServiceFactory.newInstance().createService(url, wsdlServiceName);
+ } catch (ServiceException e) {
+ throw new ServiceUnavailableException(e);
+ } catch (MalformedURLException e) {
+ throw new ServiceUnavailableException(e);
+ }
+
+ // Create operation descriptions for all the operations
+ PortType wsdlPortType = wsPortMetaData.getPortType();
+ for (Iterator j = wsdlPortType.getOperations().iterator(); j.hasNext();) {
+ Operation wsdlOperation = (Operation) j.next();
+ String operationName = wsdlOperation.getName();
+
+ // Create a JAX RPC call object
+ QName portName = wsPortMetaData.getPortName();
+ org.apache.axis.client.Call call;
+ try {
+ call = (org.apache.axis.client.Call) jaxrpcService.createCall(portName, operationName);
+ } catch (ServiceException e) {
+ throw new IllegalArgumentException(e);
+ }
+
+ OperationDesc operationDesc = call.getOperation();
+ operationDesc.setName(operationName);
+ List<Class> argTypes=new ArrayList<Class>();
+ for (ParameterDesc parameterDesc : (List<ParameterDesc>)operationDesc.getAllInParams()) {
+ argTypes.add(parameterDesc.getJavaType());
+ }
+ Method method=JavaIntrospectionHelper.findClosestMatchingMethod(operationName, argTypes.toArray(new Class[argTypes.size()]), methods);
+ operationDesc.setMethod(method);
+
+// OperationDesc operationDesc = new OperationDesc();
+// operationDesc.setName(operationName);
+// Method method=JavaIntrospectionHelper.findClosestMatchingMethod(operationName, new Class[]{String.class}, methods);
+// operationDesc.setMethod(method);
+//
+// WebServiceOperationMetaData wsOperationMetaData = wsPortMetaData.getOperationMetaData(operationName);
+// String soapAction = wsOperationMetaData.getSOAPAction();
+// if (soapAction != null && soapAction.length()!=0)
+// operationDesc.setSoapAction(soapAction);
+//
+// operationDesc.setElementQName((QName) wsOperationMetaData.getOperationSignature().get(0));
+//
+// Message inputMessage=wsdlOperation.getInput()!=null? wsdlOperation.getInput().getMessage():null;
+// if (inputMessage!=null & !inputMessage.getParts().isEmpty()) {
+// ParameterDesc parameterDesc = new ParameterDesc();
+// QName anyQName = new QName(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001, "any");
+// parameterDesc.setTypeQName(anyQName);
+// parameterDesc.setQName(anyQName);
+// parameterDesc.setJavaType(Object.class);
+// operationDesc.addParameter(parameterDesc);
+// }
+//
+// Message outputMessage=wsdlOperation.getOutput()!=null? wsdlOperation.getOutput().getMessage():null;
+// if (outputMessage!=null & !outputMessage.getParts().isEmpty()) {
+// QName anyQName = new QName(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001, "any");
+// operationDesc.setReturnType(anyQName);
+// operationDesc.setReturnQName(anyQName);
+// operationDesc.setReturnClass(Object.class);
+// }
+
+ serviceDesc.addOperationDesc(operationDesc);
+ }
+
+ // Deploy the service
+ dynamicConfigurationProvider.deployService(entryPoint.getName(), service);
+
+ }
+ }
+ return dynamicConfigurationProvider;
+
+ } finally {
+ tuscanyRuntime.stop();
+ }
+
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/handler/ExternalWebServiceClient.java b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/handler/ExternalWebServiceClient.java
new file mode 100644
index 0000000000..9d024bb036
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/handler/ExternalWebServiceClient.java
@@ -0,0 +1,119 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.axis.handler;
+
+import java.lang.reflect.Method;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.rmi.RemoteException;
+import java.util.Map;
+import java.util.Set;
+
+import javax.xml.namespace.QName;
+import javax.xml.rpc.Call;
+import javax.xml.rpc.Service;
+import javax.xml.rpc.ServiceException;
+import javax.xml.rpc.ServiceFactory;
+
+import org.apache.tuscany.binding.axis.assembly.WebServiceBinding;
+import org.apache.tuscany.core.config.JavaIntrospectionHelper;
+import org.apache.tuscany.core.invocation.MethodHashMap;
+import org.apache.tuscany.model.assembly.ExternalService;
+import org.osoa.sca.ServiceRuntimeException;
+import org.osoa.sca.ServiceUnavailableException;
+
+/**
+ * A mock client for a transport binding
+ *
+ * @version $Rev$ $Date$
+ */
+public class ExternalWebServiceClient {
+
+
+ private WebServicePortMetaData wsPortMetaData;
+ private Service jaxrpcService;
+ private Map<Method, Call> jaxrpcCalls=new MethodHashMap();
+
+ /**
+ * Constructs a new ExternalWebServiceClient.
+ * @param externalService
+ * @param wsBinding
+ */
+ public ExternalWebServiceClient(ExternalService externalService, WebServiceBinding wsBinding) {
+
+ // Create a port metadata info object to hold the port information
+ wsPortMetaData = new WebServicePortMetaData(wsBinding.getWSDLDefinition(), wsBinding.getWSDLPort(), wsBinding.getURI(), false);
+
+ // Create a JAX-RPC service
+ QName wsdlServiceName = wsPortMetaData.getService().getQName();
+ try {
+ URL url=new URL(wsBinding.getWSDLDefinition().getDocumentBaseURI());
+ jaxrpcService = ServiceFactory.newInstance().createService(url, wsdlServiceName);
+ } catch (ServiceException e) {
+ throw new ServiceUnavailableException(e);
+ } catch (MalformedURLException e) {
+ throw new ServiceUnavailableException(e);
+ }
+
+ // Create JAX-RPC calls for all the methods on the service contract
+ Set<Method> methods=JavaIntrospectionHelper.getAllUniqueMethods(externalService.getConfiguredService().getService().getServiceContract().getInterface());
+ for (Method method : methods) {
+ Call call=createCall(method);
+ jaxrpcCalls.put(method, call);
+ }
+
+ }
+
+ /**
+ * Create a JAX-RPC call for the given method.
+ * @param method
+ * @return
+ */
+ private Call createCall(Method method) {
+
+ // Create a JAX RPC call object
+ QName portName = wsPortMetaData.getPortName();
+ Call call;
+ try {
+ call = (Call) jaxrpcService.createCall(portName, method.getName());
+ } catch (ServiceException e) {
+ throw new IllegalArgumentException(e);
+ }
+
+ // Set the target endpoint address
+ String endpoint = wsPortMetaData.getEndpoint();
+ if (endpoint != null) {
+ String originalEndpoint = call.getTargetEndpointAddress();
+ if (!endpoint.equals(originalEndpoint))
+ call.setTargetEndpointAddress(endpoint);
+ }
+
+ return call;
+ }
+
+ /**
+ * Invoke an operation on the external Web service.
+ * @param method
+ * @param args
+ * @return
+ */
+ public Object invoke(Method method, Object[] args) {
+ Call call=jaxrpcCalls.get(method);
+ try {
+ return call.invoke(args);
+ } catch (RemoteException e) {
+ throw new ServiceRuntimeException(e);
+ }
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/handler/ExternalWebServiceTargetInvoker.java b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/handler/ExternalWebServiceTargetInvoker.java
new file mode 100644
index 0000000000..64f33a1829
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/handler/ExternalWebServiceTargetInvoker.java
@@ -0,0 +1,109 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.axis.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;
+
+/**
+ * Responsible for invoking an external web service
+ *
+ * @version $Rev$ $Date$
+ */
+public class ExternalWebServiceTargetInvoker implements TargetInvoker {
+
+ private QualifiedName serviceName;
+ private String esName;
+ private Method method;
+ private ScopeContext container;
+
+ private ExternalServiceContext context;
+
+ /**
+ * Constructs a new ExternalWebServiceTargetInvoker.
+ * @param esName
+ * @param container
+ */
+ public ExternalWebServiceTargetInvoker(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;
+ }
+ ExternalWebServiceClient client = (ExternalWebServiceClient) 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 {
+ ExternalWebServiceTargetInvoker invoker = (ExternalWebServiceTargetInvoker) 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/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/handler/WebServiceEntryPointServlet.java b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/handler/WebServiceEntryPointServlet.java
new file mode 100644
index 0000000000..d3773ca415
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/handler/WebServiceEntryPointServlet.java
@@ -0,0 +1,82 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.axis.handler;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.axis.AxisEngine;
+import org.apache.axis.AxisFault;
+import org.apache.axis.EngineConfiguration;
+import org.apache.axis.server.AxisServer;
+import org.apache.axis.transport.http.AxisServlet;
+
+import org.apache.tuscany.binding.axis.engine.config.AxisEngineConfigurationFactory;
+import org.apache.tuscany.core.context.webapp.TuscanyWebAppRuntime;
+
+/**
+ */
+public class WebServiceEntryPointServlet extends AxisServlet {
+
+ /**
+ *
+ */
+ public WebServiceEntryPointServlet() {
+ super();
+ }
+
+ /**
+ * @see org.apache.axis.transport.http.AxisServletBase#getEngine()
+ */
+ public AxisServer getEngine() throws AxisFault {
+ AxisServer engine = null;
+ ServletContext context = getServletContext();
+ synchronized (context) {
+ engine = (AxisServer) getServletContext().getAttribute(getServletName() + ".WebServiceEntryPointAxisEngine");
+ if (engine == null) {
+ Map environment = new HashMap();
+ environment.put(AxisEngine.ENV_SERVLET_CONTEXT, context);
+ String webInfPath = context.getRealPath("/WEB-INF");
+ if (webInfPath != null)
+ environment.put(AxisEngine.ENV_SERVLET_REALPATH, webInfPath + File.separator + "attachments");
+ TuscanyWebAppRuntime tuscanyRuntime = (TuscanyWebAppRuntime) context.getAttribute(TuscanyWebAppRuntime.class.getName());
+ EngineConfiguration config = new AxisEngineConfigurationFactory(tuscanyRuntime).getServerEngineConfig();
+ if (config != null) {
+ environment.put(EngineConfiguration.PROPERTY_NAME, config);
+ }
+ engine = AxisServer.getServer(environment);
+ engine.setName(getServletName());
+ context.setAttribute(getServletName() + ".WebServiceEntryPointAxisEngine", engine);
+ }
+ }
+ return engine;
+ }
+
+ /**
+ * @see org.apache.axis.transport.http.AxisServlet#doPost(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
+ */
+ public void doPost(HttpServletRequest arg0, HttpServletResponse arg1) throws ServletException, IOException {
+ super.doPost(arg0, arg1);
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/handler/WebServiceOperationMetaData.java b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/handler/WebServiceOperationMetaData.java
new file mode 100644
index 0000000000..99aa62f78f
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/handler/WebServiceOperationMetaData.java
@@ -0,0 +1,484 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.axis.handler;
+
+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
+ *
+ */
+public class WebServiceOperationMetaData {
+ // WSDL Binding and BindingOperation
+ private Binding binding;
+ private BindingOperation bindingOperation;
+
+ // Fields to cache derived metadata
+ private transient Set inputHeaderParts;
+ private transient Set outputHeaderParts;
+ private transient String style;
+ private transient String use;
+ private transient String soapAction;
+ private transient List 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 getInputHeaderParts() {
+ if (inputHeaderParts == null) {
+ // Build a set of header parts that we need to exclude
+ inputHeaderParts = new HashSet();
+ 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 getOutputHeaderParts() {
+ if (outputHeaderParts == null) {
+ // Build a set of header parts that we need to exclude
+ outputHeaderParts = new HashSet();
+ 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 = (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.
+ *
+ * @param wsdlBindingOperation
+ * @return
+ */
+ public String getSOAPAction() {
+ if (soapAction == null) {
+ final List wsdlBindingOperationExtensions = bindingOperation.getExtensibilityElements();
+ final SOAPOperation soapOp = (SOAPOperation) 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 getSOAPBodyParts(boolean input) {
+ javax.wsdl.extensions.soap.SOAPBody soapBody = getSOAPBody(input);
+ if (soapBody != null) {
+ List parts = soapBody.getParts();
+ if (parts!=null) {
+ List names = new ArrayList();
+ for (Iterator i = parts.iterator(); i.hasNext();) {
+ Object part = i.next();
+ if (part instanceof String)
+ names.add(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 = (javax.wsdl.extensions.soap.SOAPBody) WebServicePortMetaData.getExtensibilityElement(elements,
+ javax.wsdl.extensions.soap.SOAPBody.class);
+ return soapBody;
+ }
+
+ /**
+ * Returns the use attribute
+ *
+ * @param wsdlOperation
+ * @return
+ */
+ 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;
+ }
+
+ 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
+ *
+ * @param wsdlBinding
+ * @param bindingOperation
+ * @return
+ */
+ public List getOperationSignature() {
+ if (signature == null) {
+ signature = new ArrayList();
+
+ Operation operation = bindingOperation.getOperation();
+ if (operation == null)
+ return signature;
+
+ final Input input = operation.getInput();
+ if (input == null) {
+ return signature;
+ }
+
+ String style = getStyle();
+
+ if (style.equals("rpc")) {
+ 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, since a wrapper with the operation
+ * name is not present, the message signatures must be
+ * correctly 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 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 TODO
+ * @return
+ */
+ public List getBodyPartIndexes(boolean isInput) {
+ List indexes = new ArrayList();
+
+ Message message = getMessage(isInput);
+ if (message == null)
+ return indexes;
+
+ List 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(new Integer(index));
+ } else {
+ // "parts" in soap:body
+ if (bodyParts.contains(part.getName()))
+ indexes.add(new Integer(index));
+
+ }
+ }
+ return indexes;
+ }
+
+ /**
+ * Get the corresponding index for a part in the SOAP header by element
+ * name
+ *
+ * @param elementName
+ * @param isInput TODO
+ * @return
+ */
+ 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;
+ }
+
+} \ No newline at end of file
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/handler/WebServicePortMetaData.java b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/handler/WebServicePortMetaData.java
new file mode 100644
index 0000000000..9ce85d3ca8
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/handler/WebServicePortMetaData.java
@@ -0,0 +1,362 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.axis.handler;
+
+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.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 javax.xml.soap.Name;
+import javax.xml.soap.SOAPBodyElement;
+import javax.xml.soap.SOAPElement;
+
+import org.apache.tuscany.model.types.wsdl.WSDLServiceContract;
+
+/**
+ * Metadata for a WSDL port
+ *
+ */
+public class WebServicePortMetaData {
+
+ private final static String SOAP_ENCODING_URI = "http://schemas.xmlsoap.org/wsdl/soap/";
+
+ 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 allOperationMetaData;
+ private WSDLServiceContract interfaceType;
+
+ /**
+ * Constructor
+ *
+ * @param wsdlDefinition
+ * @param portName
+ */
+ 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<Service> services=(Collection<Service>)wsdlDefinition.getServices().values();
+ for (Service service : services) {
+ 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 portType
+ */
+ 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.
+ *
+ * @param wsdlPort
+ * @return
+ */
+ 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 (Iterator i = wsdlPortExtensions.iterator(); i.hasNext();) {
+ final Object extension = i.next();
+ if (extension instanceof SOAPAddress) {
+ final SOAPAddress address = (SOAPAddress) extension;
+ return address.getLocationURI();
+ }
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Returns the SOAP binding style.
+ * @return
+ */
+ public String getStyle() {
+
+ // Find the binding style
+ String style = null;
+ if (wsdlBinding != null) {
+ final List wsdlBindingExtensions = wsdlBinding.getExtensibilityElements();
+ SOAPBinding soapBinding = (SOAPBinding) getExtensibilityElement(wsdlBindingExtensions, SOAPBinding.class);
+ if (soapBinding != null)
+ style = soapBinding.getStyle();
+ }
+
+ // Default to document
+ return (style == null) ? "document" : style;
+ }
+
+ /**
+ * Returns the use attribute
+ * @return
+ */
+ public String getUse() {
+ List list = getAllOperationMetaData();
+ WebServiceOperationMetaData operationMetaData = (WebServiceOperationMetaData) list.get(0);
+ return operationMetaData.getUse();
+ }
+
+ /**
+ * Returns the encoding attribute
+ * @return
+ */
+ public String getEncoding() {
+ List list = getAllOperationMetaData();
+ WebServiceOperationMetaData operationMetaData = (WebServiceOperationMetaData) list.get(0);
+ return operationMetaData.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
+ * @return
+ */
+ public static Object getExtensibilityElement(List elements, Class type) {
+ for (Iterator i = elements.iterator(); i.hasNext();) {
+ Object element = i.next();
+ if (type.isInstance(element))
+ return element;
+ }
+ return null;
+ }
+
+ /**
+ * Returns the extensibility elements of the given type.
+ * @param elements
+ * @param type
+ * @return
+ */
+ public static List getExtensibilityElements(List elements, Class type) {
+ List result = new ArrayList();
+ for (Iterator i = elements.iterator(); i.hasNext();) {
+ Object element = i.next();
+ if (type.isInstance(element))
+ result.add(element);
+ }
+ return result;
+ }
+
+ /**
+ * Get the operation signature from the SOAP Body
+ * @param 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 getAllOperationMetaData() {
+ if (allOperationMetaData == null) {
+ allOperationMetaData = new ArrayList();
+ 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) {
+ for (Iterator it = getAllOperationMetaData().iterator(); it.hasNext();) {
+ WebServiceOperationMetaData descriptor = (WebServiceOperationMetaData) it.next();
+ String opName = descriptor.getBindingOperation().getOperation().getName();
+
+ if (opName.equals(operationName))
+ return descriptor;
+ }
+ return null;
+ }
+
+ /**
+ * Returns the WSDL service contract
+ * @return
+ */
+ public WSDLServiceContract getInterfaceType() {
+ return interfaceType;
+ }
+
+} \ No newline at end of file
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/loader/WebServiceSCDLModelLoader.java b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/loader/WebServiceSCDLModelLoader.java
new file mode 100644
index 0000000000..e60d77525f
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/java/org/apache/tuscany/binding/axis/loader/WebServiceSCDLModelLoader.java
@@ -0,0 +1,74 @@
+package org.apache.tuscany.binding.axis.loader;
+
+import org.apache.tuscany.binding.axis.assembly.WebServiceAssemblyFactory;
+import org.apache.tuscany.binding.axis.assembly.WebServiceBinding;
+import org.apache.tuscany.binding.axis.assembly.impl.WebServiceAssemblyFactoryImpl;
+import org.apache.tuscany.binding.axis.assembly.impl.WebServiceBindingImpl;
+import org.apache.tuscany.core.runtime.RuntimeContext;
+import org.apache.tuscany.core.system.annotation.Autowire;
+import org.apache.tuscany.core.loader.SCDLModelLoaderRegistry;
+import org.apache.tuscany.model.assembly.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.AssemblyModelObject;
+import org.apache.tuscany.model.scdl.loader.SCDLModelLoader;
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Destroy;
+
+/**
+ * Populates the assembly model from an SCDL model
+ */
+@org.osoa.sca.annotations.Scope("MODULE")
+public class WebServiceSCDLModelLoader implements SCDLModelLoader {
+
+ private RuntimeContext runtimeContext;
+ private SCDLModelLoaderRegistry loaderRegistry;
+ private WebServiceAssemblyFactory wsFactory;
+
+ /**
+ * Constructs a new WebServiceSCDLModelLoader.
+ */
+ public WebServiceSCDLModelLoader() {
+ this.wsFactory=new WebServiceAssemblyFactoryImpl();
+ }
+
+ /**
+ * @param runtimeContext The runtimeContext to set.
+ */
+ @Autowire
+ public void setRuntimeContext(RuntimeContext runtimeContext) {
+ this.runtimeContext = runtimeContext;
+ }
+
+ // @Autowire
+ public void setLoaderRegistry(SCDLModelLoaderRegistry registry) {
+ this.loaderRegistry = registry;
+ }
+
+ @Init(eager=true)
+ public void init() {
+ runtimeContext.addLoader(this);
+// loaderRegistry.registerLoader(this);
+ }
+
+ @Destroy
+ public void destroy() {
+ loaderRegistry.unregisterLoader(this);
+ }
+
+ /**
+ * @see org.apache.tuscany.model.scdl.loader.SCDLModelLoader#load(org.apache.tuscany.model.assembly.AssemblyModelContext, java.lang.Object)
+ */
+ public AssemblyModelObject load(AssemblyModelContext modelContext, Object object) {
+ if (object instanceof org.apache.tuscany.model.scdl.WebServiceBinding) {
+ org.apache.tuscany.model.scdl.WebServiceBinding scdlBinding=(org.apache.tuscany.model.scdl.WebServiceBinding)object;
+ WebServiceBinding binding=wsFactory.createWebServiceBinding();
+ binding.setURI(scdlBinding.getUri());
+
+ // Set the port URI into the assembly binding, it'll be resolved in the initialize method
+ ((WebServiceBindingImpl)binding).setPortURI(scdlBinding.getPort());
+
+ return binding;
+
+ } else
+ return null;
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/resources/org/apache/tuscany/binding/axis/Messages.properties b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/resources/org/apache/tuscany/binding/axis/Messages.properties
new file mode 100644
index 0000000000..ac3fc641e5
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/resources/org/apache/tuscany/binding/axis/Messages.properties
@@ -0,0 +1,28 @@
+# ====================================================================
+# Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
+#
+# 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.
+# ====================================================================
+
+# ====================================================================
+# To code developer:
+# Do NOT change the properties between this line and the
+# "%%% END OF TRANSLATED PROPERTIES %%%" line.
+# Make a new property name, append to the end of the file and change
+# the code to use the new property.
+# ====================================================================
+
+# =====================================================================
+# %%% END OF TRANSLATED PROPERTIES %%%
+# =====================================================================
+# NLS_MESSAGEFORMAT_ALL
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/resources/org/apache/tuscany/binding/axis/engine/config/server-config.wsdd b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/resources/org/apache/tuscany/binding/axis/engine/config/server-config.wsdd
new file mode 100644
index 0000000000..6790888ee6
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/resources/org/apache/tuscany/binding/axis/engine/config/server-config.wsdd
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.
+ -->
+<deployment name="defaultClientConfig"
+ xmlns="http://xml.apache.org/axis/wsdd/"
+ xmlns:java="http://xml.apache.org/axis/wsdd/providers/java"
+ xmlns:handler="http://xml.apache.org/axis/wsdd/providers/handler">
+
+ <globalConfiguration>
+ <parameter name="disablePrettyXML" value="false"/>
+ <parameter name="dotNetSoapEncFix" value="true"/>
+ <parameter name="axis.servicesPath" value="/sca/"/>
+ <parameter name="axis.disableServiceList" value="true"/>
+
+ <requestFlow>
+ <handler type="java:org.apache.axis.handlers.SOAPMonitorHandler"/>
+ </requestFlow>
+ <responseFlow>
+ <handler type="java:org.apache.axis.handlers.SOAPMonitorHandler"/>
+ </responseFlow>
+
+ </globalConfiguration>
+
+ <handler type="java:org.apache.axis.handlers.http.URLMapper" name="URLMapper"/>
+ <handler type="java:org.apache.axis.transport.local.LocalResponder" name="LocalResponder"/>
+ <handler type="java:org.apache.axis.handlers.SimpleAuthenticationHandler" name="Authenticate"/>
+
+ <transport name="http">
+ <parameter name="qs:list"
+ value="org.apache.axis.transport.http.QSListHandler"/>
+ <parameter name="qs:method"
+ value="org.apache.axis.transport.http.QSMethodHandler"/>
+ <parameter name="qs:wsdl"
+ value="org.apache.axis.transport.http.QSWSDLHandler"/>
+ <requestFlow>
+ <handler type="URLMapper"/>
+ <handler type="java:org.apache.axis.handlers.http.HTTPAuthHandler"/>
+ </requestFlow>
+ </transport>
+
+ <transport name="local">
+ <responseFlow>
+ <handler type="LocalResponder"/>
+ </responseFlow>
+ </transport>
+
+</deployment>
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/resources/system.fragment b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/resources/system.fragment
new file mode 100644
index 0000000000..ebfefa309a
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/main/resources/system.fragment
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
+
+ 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.
+ -->
+<moduleFragment xmlns="http://www.osoa.org/xmlns/sca/0.9" xmlns:v="http://www.osoa.org/xmlns/sca/values/0.9"
+ xmlns:system="http://org.apache.tuscany/xmlns/system/0.9"
+ name="org.apache.tuscany.binding.axis">
+
+ <component name="org.apache.tuscany.binding.axis.builder.ExternalWebServiceConfigurationBuilder">
+ <system:implementation.system class="org.apache.tuscany.binding.axis.builder.ExternalWebServiceConfigurationBuilder"/>
+ </component>
+
+ <component name="org.apache.tuscany.binding.axis.builder.ExternalWebServiceWireBuilder">
+ <system:implementation.system class="org.apache.tuscany.binding.axis.builder.ExternalWebServiceWireBuilder"/>
+ </component>
+
+ <component name="org.apache.tuscany.binding.axis.loader.WebServiceSCDLModelLoader">
+ <system:implementation.system class="org.apache.tuscany.binding.axis.loader.WebServiceSCDLModelLoader"/>
+ </component>
+
+ <component name="org.apache.tuscany.binding.axis.builder.WebServiceEntryPointConfigurationBuilder">
+ <system:implementation.system class="org.apache.tuscany.binding.axis.builder.WebServiceEntryPointConfigurationBuilder"/>
+ </component>
+
+</moduleFragment>
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/test/java/org/apache/tuscany/binding/axis/assembly/tests/WebServiceAssemblyLoaderTestCase.java b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/test/java/org/apache/tuscany/binding/axis/assembly/tests/WebServiceAssemblyLoaderTestCase.java
new file mode 100644
index 0000000000..6c8b58b0d1
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/test/java/org/apache/tuscany/binding/axis/assembly/tests/WebServiceAssemblyLoaderTestCase.java
@@ -0,0 +1,87 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.axis.assembly.tests;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.binding.axis.assembly.WebServiceBinding;
+import org.apache.tuscany.binding.axis.loader.WebServiceSCDLModelLoader;
+import org.apache.tuscany.common.resource.ResourceLoader;
+import org.apache.tuscany.common.resource.impl.ResourceLoaderImpl;
+import org.apache.tuscany.model.assembly.AssemblyFactory;
+import org.apache.tuscany.model.assembly.AssemblyModelContext;
+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;
+import org.apache.tuscany.model.assembly.impl.AssemblyFactoryImpl;
+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 WebServiceAssemblyLoaderTestCase extends TestCase {
+
+ /**
+ *
+ */
+ public WebServiceAssemblyLoaderTestCase() {
+ super();
+ }
+
+ public void testLoader() {
+
+ ResourceLoader resourceLoader=new ResourceLoaderImpl(Thread.currentThread().getContextClassLoader());
+ WebServiceSCDLModelLoader wsLoader=new WebServiceSCDLModelLoader();
+ List<SCDLModelLoader> scdlLoaders=new ArrayList<SCDLModelLoader>();
+ scdlLoaders.add(wsLoader);
+ AssemblyModelLoader assemblyLoader=new SCDLAssemblyModelLoaderImpl(scdlLoaders);
+ AssemblyFactory assemblyFactory=new AssemblyFactoryImpl();
+ AssemblyModelContext modelContext=new AssemblyModelContextImpl(assemblyFactory, assemblyLoader, resourceLoader);
+
+ Module module = assemblyLoader.loadModule(getClass().getResource("sca.module").toString());
+ module.initialize(modelContext);
+
+ Assert.assertTrue(module.getName().equals("tuscany.binding.axis.assembly.tests.bigbank.account"));
+
+ 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 WebServiceBinding);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/test/java/org/apache/tuscany/binding/axis/assembly/tests/bigbank/account/services/account/AccountReport.java b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/test/java/org/apache/tuscany/binding/axis/assembly/tests/bigbank/account/services/account/AccountReport.java
new file mode 100644
index 0000000000..6ac32e9c9a
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/test/java/org/apache/tuscany/binding/axis/assembly/tests/bigbank/account/services/account/AccountReport.java
@@ -0,0 +1,32 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.axis.assembly.tests.bigbank.account.services.account;
+
+import java.util.List;
+
+/**
+ * @model
+ */
+
+public interface AccountReport {
+
+ /**
+ * @model type="services.account.AccountSummary"
+ */
+
+ List getAccountSummaries();
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/test/java/org/apache/tuscany/binding/axis/assembly/tests/bigbank/account/services/account/AccountService.java b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/test/java/org/apache/tuscany/binding/axis/assembly/tests/bigbank/account/services/account/AccountService.java
new file mode 100644
index 0000000000..58f842878d
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/test/java/org/apache/tuscany/binding/axis/assembly/tests/bigbank/account/services/account/AccountService.java
@@ -0,0 +1,25 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.axis.assembly.tests.bigbank.account.services.account;
+
+import org.osoa.sca.annotations.Remotable;
+
+@Remotable
+public interface AccountService {
+
+ public AccountReport getAccountReport(String customerID);
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/test/java/org/apache/tuscany/binding/axis/assembly/tests/bigbank/account/services/account/AccountServiceImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/test/java/org/apache/tuscany/binding/axis/assembly/tests/bigbank/account/services/account/AccountServiceImpl.java
new file mode 100644
index 0000000000..91fd5e0164
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/test/java/org/apache/tuscany/binding/axis/assembly/tests/bigbank/account/services/account/AccountServiceImpl.java
@@ -0,0 +1,42 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.axis.assembly.tests.bigbank.account.services.account;
+
+import org.osoa.sca.annotations.Property;
+import org.osoa.sca.annotations.Reference;
+
+import org.apache.tuscany.binding.axis.assembly.tests.bigbank.account.services.accountdata.AccountDataService;
+import org.apache.tuscany.binding.axis.assembly.tests.bigbank.account.services.stockquote.StockQuoteService;
+
+public class AccountServiceImpl implements AccountService {
+
+ @Property
+ public String currency = "USD";
+
+ @Reference
+ public AccountDataService accountDataService;
+ @Reference
+ public StockQuoteService stockQuoteService;
+
+ public AccountServiceImpl() {
+ }
+
+ public AccountReport getAccountReport(String customerID) {
+ return null;
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/test/java/org/apache/tuscany/binding/axis/assembly/tests/bigbank/account/services/account/AccountSummary.java b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/test/java/org/apache/tuscany/binding/axis/assembly/tests/bigbank/account/services/account/AccountSummary.java
new file mode 100644
index 0000000000..85825013a2
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/test/java/org/apache/tuscany/binding/axis/assembly/tests/bigbank/account/services/account/AccountSummary.java
@@ -0,0 +1,46 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.axis.assembly.tests.bigbank.account.services.account;
+
+/**
+ * @model
+ */
+
+public interface AccountSummary {
+
+ /**
+ * @model
+ */
+ String getAccountNumber();
+
+ void setAccountNumber(String accountNumber);
+
+ /**
+ * @model
+ */
+ String getAccountType();
+
+ void setAccountType(String accountType);
+
+ /**
+ * @model
+ */
+ float getBalance();
+
+ void setBalance(float balance);
+}
+
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/test/java/org/apache/tuscany/binding/axis/assembly/tests/bigbank/account/services/accountdata/AccountDataService.java b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/test/java/org/apache/tuscany/binding/axis/assembly/tests/bigbank/account/services/accountdata/AccountDataService.java
new file mode 100644
index 0000000000..4242d2fcc7
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/test/java/org/apache/tuscany/binding/axis/assembly/tests/bigbank/account/services/accountdata/AccountDataService.java
@@ -0,0 +1,26 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.axis.assembly.tests.bigbank.account.services.accountdata;
+
+public interface AccountDataService {
+
+ CheckingAccount getCheckingAccount(String customerID);
+
+ SavingsAccount getSavingsAccount(String customerID);
+
+ StockAccount getStockAccount(String customerID);
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/test/java/org/apache/tuscany/binding/axis/assembly/tests/bigbank/account/services/accountdata/AccountDataServiceImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/test/java/org/apache/tuscany/binding/axis/assembly/tests/bigbank/account/services/accountdata/AccountDataServiceImpl.java
new file mode 100644
index 0000000000..66ae034d9a
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/test/java/org/apache/tuscany/binding/axis/assembly/tests/bigbank/account/services/accountdata/AccountDataServiceImpl.java
@@ -0,0 +1,48 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.axis.assembly.tests.bigbank.account.services.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/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/test/java/org/apache/tuscany/binding/axis/assembly/tests/bigbank/account/services/accountdata/CheckingAccount.java b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/test/java/org/apache/tuscany/binding/axis/assembly/tests/bigbank/account/services/accountdata/CheckingAccount.java
new file mode 100644
index 0000000000..6c48b7120a
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/test/java/org/apache/tuscany/binding/axis/assembly/tests/bigbank/account/services/accountdata/CheckingAccount.java
@@ -0,0 +1,39 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.axis.assembly.tests.bigbank.account.services.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/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/test/java/org/apache/tuscany/binding/axis/assembly/tests/bigbank/account/services/accountdata/SavingsAccount.java b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/test/java/org/apache/tuscany/binding/axis/assembly/tests/bigbank/account/services/accountdata/SavingsAccount.java
new file mode 100644
index 0000000000..718145feb5
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/test/java/org/apache/tuscany/binding/axis/assembly/tests/bigbank/account/services/accountdata/SavingsAccount.java
@@ -0,0 +1,39 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.axis.assembly.tests.bigbank.account.services.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/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/test/java/org/apache/tuscany/binding/axis/assembly/tests/bigbank/account/services/accountdata/StockAccount.java b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/test/java/org/apache/tuscany/binding/axis/assembly/tests/bigbank/account/services/accountdata/StockAccount.java
new file mode 100644
index 0000000000..05f7644d80
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/test/java/org/apache/tuscany/binding/axis/assembly/tests/bigbank/account/services/accountdata/StockAccount.java
@@ -0,0 +1,48 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.axis.assembly.tests.bigbank.account.services.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/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/test/java/org/apache/tuscany/binding/axis/assembly/tests/bigbank/account/services/stockquote/StockQuoteService.java b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/test/java/org/apache/tuscany/binding/axis/assembly/tests/bigbank/account/services/stockquote/StockQuoteService.java
new file mode 100644
index 0000000000..a1c8f131a1
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/test/java/org/apache/tuscany/binding/axis/assembly/tests/bigbank/account/services/stockquote/StockQuoteService.java
@@ -0,0 +1,24 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.axis.assembly.tests.bigbank.account.services.stockquote;
+
+public interface StockQuoteService {
+
+ public float getQuote(String symbol);
+}
+
+ \ No newline at end of file
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/test/resources/org/apache/tuscany/binding/axis/assembly/tests/bigbank/account/services/account/AccountService.wsdl b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/test/resources/org/apache/tuscany/binding/axis/assembly/tests/bigbank/account/services/account/AccountService.wsdl
new file mode 100644
index 0000000000..921218c5b9
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/test/resources/org/apache/tuscany/binding/axis/assembly/tests/bigbank/account/services/account/AccountService.wsdl
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
+
+ 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.
+ -->
+<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:tns="http://www.bigbank.com/AccountService/"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://www.bigbank.com/AccountService/"
+
+ name="AccountService">
+
+ <wsdl:types>
+ <xsd:schema targetNamespace="http://www.bigbank.com/AccountService/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <xsd:element name="customerID" type="xsd:string"/>
+ <xsd:element name="getAccountReportResponse" type="tns:AccountReport"/>
+
+ <xsd:complexType name="AccountReport">
+ <xsd:sequence>
+ <xsd:element name="accountSummary" type="tns:AccountSummary" maxOccurs="unbounded"/>
+ </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:customerID" 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="AccountServiceSOAP" type="tns:AccountService">
+ <soap:binding style="document"
+ transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="getAccountReport">
+ <soap:operation
+ soapAction="http://www.bigbank.com/AccountService/getAccountReport"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="AccountService">
+ <wsdl:port binding="tns:AccountServiceSOAP"
+ name="AccountServiceSOAP">
+ <soap:address location=""/>
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/test/resources/org/apache/tuscany/binding/axis/assembly/tests/bigbank/account/services/stockquote/StockQuoteWebService.wsdl b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/test/resources/org/apache/tuscany/binding/axis/assembly/tests/bigbank/account/services/stockquote/StockQuoteWebService.wsdl
new file mode 100644
index 0000000000..9678d9d6ea
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/test/resources/org/apache/tuscany/binding/axis/assembly/tests/bigbank/account/services/stockquote/StockQuoteWebService.wsdl
@@ -0,0 +1,98 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
+
+ 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.
+ -->
+<wsdl:definitions targetNamespace="http://webservice.stockquote" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://webservice.stockquote" xmlns:intf="http://webservice.stockquote" xmlns:tns1="http://stockquote" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="">
+ <!--WSDL created by Apache Axis version: 1.2.1
+Built on Jun 14, 2005 (09:15:57 EDT)-->
+ <wsdl:types>
+ <schema elementFormDefault="qualified" targetNamespace="http://stockquote" xmlns="http://www.w3.org/2001/XMLSchema">
+ <complexType name="GetQuoteRequest">
+ <sequence>
+ <element name="symbol" nillable="true" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ <complexType name="GetQuoteResponse">
+ <sequence>
+ <element name="price" type="xsd:float"/>
+ </sequence>
+ </complexType>
+ </schema>
+ <schema elementFormDefault="qualified" targetNamespace="http://webservice.stockquote" xmlns="http://www.w3.org/2001/XMLSchema">
+ <import namespace="http://stockquote"/>
+ <element name="request" type="tns1:GetQuoteRequest"/>
+ <element name="getQuoteReturn" type="tns1:GetQuoteResponse"/>
+ </schema>
+ </wsdl:types>
+
+ <wsdl:message name="getQuoteResponse">
+
+ <wsdl:part element="impl:getQuoteReturn" name="getQuoteReturn"/>
+
+ </wsdl:message>
+
+ <wsdl:message name="getQuoteRequest">
+
+ <wsdl:part element="impl:request" name="request"/>
+
+ </wsdl:message>
+
+ <wsdl:portType name="StockQuoteWebService">
+
+ <wsdl:operation name="getQuote" parameterOrder="request">
+
+ <wsdl:input message="impl:getQuoteRequest" name="getQuoteRequest"/>
+
+ <wsdl:output message="impl:getQuoteResponse" name="getQuoteResponse"/>
+
+ </wsdl:operation>
+
+ </wsdl:portType>
+
+ <wsdl:binding name="StockQuoteWebServiceSoapBinding" type="impl:StockQuoteWebService">
+
+ <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+
+ <wsdl:operation name="getQuote">
+
+ <wsdlsoap:operation soapAction=""/>
+
+ <wsdl:input name="getQuoteRequest">
+
+ <wsdlsoap:body use="literal"/>
+
+ </wsdl:input>
+
+ <wsdl:output name="getQuoteResponse">
+
+ <wsdlsoap:body use="literal"/>
+
+ </wsdl:output>
+
+ </wsdl:operation>
+
+ </wsdl:binding>
+
+ <wsdl:service name="StockQuoteWebServiceService">
+
+ <wsdl:port binding="impl:StockQuoteWebServiceSoapBinding" name="StockQuoteWebService">
+
+ <wsdlsoap:address location="http://localhost:8123/StockQuoteWebService/services/StockQuoteWebService"/>
+
+ </wsdl:port>
+
+ </wsdl:service>
+
+</wsdl:definitions>
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/test/resources/org/apache/tuscany/binding/axis/assembly/tests/sca.module b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/test/resources/org/apache/tuscany/binding/axis/assembly/tests/sca.module
new file mode 100644
index 0000000000..7057907864
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/test/resources/org/apache/tuscany/binding/axis/assembly/tests/sca.module
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.
+ -->
+<module xmlns="http://www.osoa.org/xmlns/sca/0.9" xmlns:v="http://www.osoa.org/xmlns/sca/values/0.9"
+
+ name="tuscany.binding.axis.assembly.tests.bigbank.account">
+
+ <entryPoint name="AccountService">
+ <interface.java interface="org.apache.tuscany.binding.axis.assembly.tests.bigbank.account.services.account.AccountService"/>
+ <binding.ws port="http://www.bigbank.com/AccountService/#AccountServiceSOAP"/>
+ <reference>AccountExternalService</reference>
+ </entryPoint>
+
+ <entryPoint name="AccountService2">
+ <interface.wsdl interface="http://www.bigbank.com/AccountService/#AccountService"/>
+ <binding.ws port="http://www.bigbank.com/AccountService/#AccountServiceSOAP"/>
+ <reference>AccountExternalService</reference>
+ </entryPoint>
+
+ <component name="AccountServiceComponent">
+ <implementation.java class="org.apache.tuscany.binding.axis.assembly.tests.bigbank.account.services.account.AccountServiceImpl"/>
+ </component>
+
+ <component name="AccountDataServiceComponent">
+ <implementation.java class="org.apache.tuscany.binding.axis.assembly.tests.bigbank.account.services.accountdata.AccountDataServiceImpl"/>
+ </component>
+
+ <!--
+ <component name="StockQuoteService">
+ <implementation.java class="org.apache.tuscany.binding.axis.assembly.tests.bigbank.account.services.stockquote.StockQuoteServiceImpl"/>
+ </component>
+ -->
+
+ <externalService name="AccountExternalService">
+ <interface.wsdl interface="http://www.bigbank.com/AccountService/#AccountService"/>
+ <binding.ws port="http://www.bigbank.com/AccountService/#AccountServiceSOAP"/>
+ </externalService>
+
+ <externalService name="StockQuoteService">
+ <interface.java interface="org.apache.tuscany.binding.axis.assembly.tests.bigbank.account.services.stockquote.StockQuoteService"/>
+ <binding.ws port="http://webservice.stockquote#StockQuoteWebService"/>
+ </externalService>
+
+ <import.wsdl
+ location="org/apache/tuscany/binding/axis/assembly/tests/bigbank/account/services/account/AccountService.wsdl"
+ namespace="http://www.bigbank.com/AccountService/"/>
+
+ <import.wsdl
+ location="org/apache/tuscany/binding/axis/assembly/tests/bigbank/account/services/stockquote/StockQuoteWebService.wsdl"
+ namespace="http://webservice.stockquote"/>
+
+</module>
+
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/test/resources/org/apache/tuscany/binding/axis/mediator/tests/DocLit.wsdl b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/test/resources/org/apache/tuscany/binding/axis/mediator/tests/DocLit.wsdl
new file mode 100644
index 0000000000..4aec526803
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/test/resources/org/apache/tuscany/binding/axis/mediator/tests/DocLit.wsdl
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.
+ -->
+<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:tns="http://www.example.org/Test/DocLit"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="Test"
+ targetNamespace="http://www.example.org/Test/DocLit">
+ <wsdl:types>
+ <xsd:schema targetNamespace="http://www.example.org/Test/DocLit"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:tns="http://www.example.org/Test/DocLit">
+ <xsd:element name="source" type="xsd:string"/>
+ <xsd:element name="target" type="xsd:string"/>
+ <xsd:element name="context" type="xsd:string"/>
+ <xsd:element name="index" type="xsd:int"/>
+ <xsd:element name="exception" type="xsd:string"/>
+ </xsd:schema>
+ </wsdl:types>
+ <wsdl:message name="testRequest">
+ <wsdl:part element="tns:source" name="part1"/>
+ <wsdl:part element="tns:target" name="part2"/>
+ <wsdl:part element="tns:context" name="part3"/>
+ </wsdl:message>
+ <wsdl:message name="testResponse">
+ <wsdl:part element="tns:index" name="part1"/>
+ </wsdl:message>
+ <wsdl:message name="testFault">
+ <wsdl:part name="testFault" element="tns:exception"></wsdl:part>
+ </wsdl:message>
+ <wsdl:portType name="Test">
+ <wsdl:operation name="indexOf">
+ <wsdl:input name="input" message="tns:testRequest"/>
+ <wsdl:output name="output" message="tns:testResponse"/>
+ <wsdl:fault name="fault" message="tns:testFault"/>
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name="TestSOAP" type="tns:Test">
+ <soap:binding style="document"
+ transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="indexOf">
+ <soap:operation
+ soapAction="http://www.example.org/Test/indexOf"/>
+ <wsdl:input>
+ <soap:body parts="part1 part2" use="literal"/>
+ <soap:header message="tns:testRequest" part="part3" use="literal"></soap:header>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ <wsdl:fault name="fault">
+ <soap:fault namespace="http://www.example.org/Test/"
+ use="literal" name="fault"/>
+ </wsdl:fault>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="Test">
+ <wsdl:port binding="tns:TestSOAP" name="TestSOAP">
+ <soap:address
+ location="http://localhost:8080/TestWebServiceMediator/services/Test"/>
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/test/resources/org/apache/tuscany/binding/axis/mediator/tests/DocLitWrapped.wsdl b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/test/resources/org/apache/tuscany/binding/axis/mediator/tests/DocLitWrapped.wsdl
new file mode 100644
index 0000000000..7839d3ea71
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/test/resources/org/apache/tuscany/binding/axis/mediator/tests/DocLitWrapped.wsdl
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.
+ -->
+<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:tns="http://www.example.org/Test/DocLitWrapped"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="Test"
+ targetNamespace="http://www.example.org/Test/DocLitWrapped">
+ <wsdl:types>
+ <xsd:schema targetNamespace="http://www.example.org/Test/DocLitWrapped"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://www.example.org/Test/DocLitWrapped">
+ <xsd:element name="indexOf">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="source" type="xsd:string"/>
+ <xsd:element name="target" type="xsd:string"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="indexOfResponse">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="index" type="xsd:int"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="exception" type="xsd:string"/>
+ </xsd:schema>
+ </wsdl:types>
+ <wsdl:message name="testRequest">
+ <wsdl:part element="tns:indexOf" name="part1"/>
+ </wsdl:message>
+ <wsdl:message name="testResponse">
+ <wsdl:part element="tns:indexOfResponse" name="part1"/>
+ </wsdl:message>
+ <wsdl:message name="testFault">
+ <wsdl:part name="testFault" element="tns:exception"></wsdl:part>
+ </wsdl:message>
+ <wsdl:portType name="Test">
+ <wsdl:operation name="indexOf">
+ <wsdl:input name="input" message="tns:testRequest"/>
+ <wsdl:output name="output" message="tns:testResponse"/>
+ <wsdl:fault name="fault" message="tns:testFault"/>
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name="TestSOAP" type="tns:Test">
+ <soap:binding style="document"
+ transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="indexOf">
+ <soap:operation
+ soapAction="http://www.example.org/Test/indexOf"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ <wsdl:fault name="fault">
+ <soap:fault namespace="http://www.example.org/Test/"
+ use="literal" name="fault"/>
+ </wsdl:fault>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="Test">
+ <wsdl:port binding="tns:TestSOAP" name="TestSOAP">
+ <soap:address
+ location="http://localhost:8080/TestWebServiceMediator/services/Test"/>
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/test/resources/org/apache/tuscany/binding/axis/mediator/tests/RpcLit.wsdl b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/test/resources/org/apache/tuscany/binding/axis/mediator/tests/RpcLit.wsdl
new file mode 100644
index 0000000000..8f94f9c66f
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/test/resources/org/apache/tuscany/binding/axis/mediator/tests/RpcLit.wsdl
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.
+ -->
+<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:tns="http://www.example.org/Test/RpcLit"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="Test"
+ targetNamespace="http://www.example.org/Test/RpcLit">
+ <wsdl:types>
+ <xsd:schema targetNamespace="http://www.example.org/Test/RpcLit"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:tns="http://www.example.org/Test/RpcLit">
+ <!--
+ <xsd:element name="source" type="xsd:string"/>
+ <xsd:element name="target" type="xsd:string"/>
+ <xsd:element name="index" type="xsd:int" />
+ -->
+ <xsd:element name="exception" type="xsd:string"/>
+ </xsd:schema>
+ </wsdl:types>
+ <wsdl:message name="testRequest">
+ <wsdl:part type="xsd:string" name="part1"/>
+ <wsdl:part type="xsd:string" name="part2"/>
+ </wsdl:message>
+ <wsdl:message name="testResponse">
+ <wsdl:part type="xsd:int" name="part1"/>
+ </wsdl:message>
+ <wsdl:message name="testFault">
+ <wsdl:part name="testFault" element="tns:exception"></wsdl:part>
+ </wsdl:message>
+ <wsdl:portType name="Test">
+ <wsdl:operation name="indexOf">
+ <wsdl:input name="input" message="tns:testRequest"/>
+ <wsdl:output name="output" message="tns:testResponse"/>
+ <wsdl:fault name="fault" message="tns:testFault"/>
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name="TestSOAP" type="tns:Test">
+ <soap:binding style="rpc"
+ transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="indexOf">
+ <soap:operation
+ soapAction="http://www.example.org/Test/indexOf"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ <wsdl:fault name="fault">
+ <soap:fault namespace="http://www.example.org/Test/"
+ use="literal" name="fault"/>
+ </wsdl:fault>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="Test">
+ <wsdl:port binding="tns:TestSOAP" name="TestSOAP">
+ <soap:address
+ location="http://localhost:8080/TestWebServiceMediator/services/Test"/>
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/test/resources/org/apache/tuscany/binding/axis/mediator/tests/sca.module b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/test/resources/org/apache/tuscany/binding/axis/mediator/tests/sca.module
new file mode 100644
index 0000000000..7d8bb7861f
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis/src/test/resources/org/apache/tuscany/binding/axis/mediator/tests/sca.module
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.
+ -->
+<module xmlns="http://www.osoa.org/xmlns/sca/0.9" xmlns:v="http://www.osoa.org/xmlns/sca/values/0.9"
+ name="TestModule">
+
+</module>
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/LICENSE.txt b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/LICENSE.txt
new file mode 100644
index 0000000000..75b52484ea
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/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, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/pom.xml b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/pom.xml
new file mode 100644
index 0000000000..813a1765de
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/pom.xml
@@ -0,0 +1,130 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Copyright (c) 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.
+ -->
+<project>
+ <parent>
+ <groupId>org.apache.tuscany</groupId>
+ <artifactId>tuscany-sca</artifactId>
+ <version>SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>tuscany-binding-axis2</artifactId>
+ <name>Tuscany Axis2 Binding</name>
+ <description>Implementation of the SCA Web Services binding using Axis2.</description>
+ <version>SNAPSHOT</version>
+
+ <repositories>
+ <repository>
+ <id>jeremy</id>
+ <url>http://people.apache.org/~jboynes/maven2</url>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany</groupId>
+ <artifactId>tuscany-core</artifactId>
+ <version>${pom.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <!-- axis 2.0 -->
+ <dependency>
+ <groupId>axis2</groupId>
+ <artifactId>axis2-core</artifactId>
+ <version>0.94</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>ws-commons</groupId>
+ <artifactId>ws-policy</artifactId>
+ <version>SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-httpclient</groupId>
+ <artifactId>commons-httpclient</artifactId>
+ <version>3.0</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ <version>1.3</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>axis</groupId>
+ <artifactId>axis-wsdl4j</artifactId>
+ <version>1.2</version>
+ </dependency>
+
+
+ <dependency>
+ <groupId>stax</groupId>
+ <artifactId>stax-api</artifactId>
+ <version>1.0</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>woodstox</groupId>
+ <artifactId>wstx-asl</artifactId>
+ <version>2.8.2</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.12</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <!-- end of axis 2.0 -->
+
+ <dependency>
+ <groupId>tomcat</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>5.0.18</version>
+ <scope>provided</scope>
+ </dependency>
+
+ </dependencies>
+ <!-- build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ <excludes>
+ <exclude>**/org/apache/tuscany/binding/axis/engine/config/AxisEngineConfigurationFactory.java</exclude>
+ <exclude>**/org/apache/tuscany/binding/axis/handler/WebServiceEntryPointBean.java</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+ </plugins>
+
+ </build -->
+</project>
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/assembly/WebServiceAssemblyFactory.java b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/assembly/WebServiceAssemblyFactory.java
new file mode 100644
index 0000000000..2906435ac4
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/assembly/WebServiceAssemblyFactory.java
@@ -0,0 +1,31 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.axis2.assembly;
+
+import org.apache.tuscany.model.assembly.AssemblyFactory;
+
+/**
+ * The <b>Factory</b> for the model.
+ */
+public interface WebServiceAssemblyFactory extends AssemblyFactory {
+
+ /**
+ * Returns a new WebServiceBinding.
+ */
+ WebServiceBinding createWebServiceBinding();
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/assembly/WebServiceBinding.java b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/assembly/WebServiceBinding.java
new file mode 100644
index 0000000000..6eabebd358
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/assembly/WebServiceBinding.java
@@ -0,0 +1,51 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.axis2.assembly;
+
+import javax.wsdl.Definition;
+import javax.wsdl.Port;
+
+import org.apache.tuscany.model.assembly.Binding;
+
+/**
+ * Represents a Web service binding.
+ */
+public interface WebServiceBinding extends Binding {
+
+ /**
+ * Returns the WSDL port defining this binding.
+ */
+ Port getWSDLPort();
+
+ /**
+ * Returns the WSDL definition containing the WSDL port.
+ * @return
+ */
+ Definition getWSDLDefinition();
+
+ /**
+ * Sets the WSDL port defining this binding.
+ */
+ void setWSDLPort(Port value);
+
+ /**
+ * Sets the WSDL definition containing the WSDL port.
+ * @param definition
+ */
+ void setWSDLDefinition(Definition definition);
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/assembly/impl/WebServiceAssemblyFactoryImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/assembly/impl/WebServiceAssemblyFactoryImpl.java
new file mode 100644
index 0000000000..7840ebf6ef
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/assembly/impl/WebServiceAssemblyFactoryImpl.java
@@ -0,0 +1,42 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.axis2.assembly.impl;
+
+import org.apache.tuscany.binding.axis2.assembly.WebServiceAssemblyFactory;
+import org.apache.tuscany.binding.axis2.assembly.WebServiceBinding;
+import org.apache.tuscany.model.assembly.impl.AssemblyFactoryImpl;
+
+/**
+ * An implementation of the model <b>Factory</b>.
+ */
+public class WebServiceAssemblyFactoryImpl extends AssemblyFactoryImpl implements WebServiceAssemblyFactory {
+
+ /**
+ * Creates an instance of the factory.
+ */
+ public WebServiceAssemblyFactoryImpl() {
+ super();
+ }
+
+ /**
+ * @see org.apache.tuscany.binding.axis2.assembly.WebServiceAssemblyFactory#createWebServiceBinding()
+ */
+ public WebServiceBinding createWebServiceBinding() {
+ return new WebServiceBindingImpl();
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/assembly/impl/WebServiceBindingImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/assembly/impl/WebServiceBindingImpl.java
new file mode 100644
index 0000000000..d89055ff73
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/assembly/impl/WebServiceBindingImpl.java
@@ -0,0 +1,116 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.axis2.assembly.impl;
+
+import java.util.Collection;
+import java.util.List;
+
+import javax.wsdl.Definition;
+import javax.wsdl.Port;
+import javax.wsdl.Service;
+
+import org.apache.tuscany.binding.axis2.assembly.WebServiceBinding;
+import org.apache.tuscany.model.assembly.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.impl.BindingImpl;
+
+/**
+ * An implementation of WebServiceBinding.
+ */
+public class WebServiceBindingImpl extends BindingImpl implements WebServiceBinding {
+
+ private Definition definition;
+ private Port port;
+ private String portURI;
+
+ /**
+ * Constructor
+ */
+ protected WebServiceBindingImpl() {
+ }
+
+ /**
+ * @see org.apache.tuscany.binding.axis2.assembly.WebServiceBinding#getWSDLPort()
+ */
+ public Port getWSDLPort() {
+ return port;
+ }
+
+ /**
+ * @see org.apache.tuscany.binding.axis2.assembly.WebServiceBinding#setWSDLPort(javax.wsdl.Port)
+ */
+ public void setWSDLPort(Port value) {
+ checkNotFrozen();
+ this.port=value;
+ }
+
+ /**
+ * @see org.apache.tuscany.binding.axis2.assembly.WebServiceBinding#getWSDLDefinition()
+ */
+ public Definition getWSDLDefinition() {
+ return definition;
+ }
+
+ /**
+ * @see org.apache.tuscany.binding.axis2.assembly.WebServiceBinding#setWSDLDefinition(javax.wsdl.Definition)
+ */
+ public void setWSDLDefinition(Definition definition) {
+ checkNotFrozen();
+ this.definition=definition;
+ }
+
+ /**
+ * @param portURI The portURI to set.
+ */
+ public void setPortURI(String portURI) {
+ this.portURI = portURI;
+ }
+
+ /**
+ * @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 WSDL port namespace and name
+ if (port==null && portURI!=null) {
+ int h=portURI.indexOf('#');
+ String portNamespace=portURI.substring(0,h);
+ String portName=portURI.substring(h+1);
+
+ // Load the WSDL definitions for the given namespace
+ List<Definition> definitions=modelContext.getAssemblyLoader().loadDefinitions(portNamespace);
+ if (definitions==null)
+ throw new IllegalArgumentException("Cannot find WSDL definition for "+portNamespace);
+ for (Definition definition: definitions) {
+
+ // Find the port with the given name
+ for (Service service : (Collection<Service>)definition.getServices().values()) {
+ Port port=service.getPort(portName);
+ if (port!=null) {
+ this.definition=definition;
+ this.port=port;
+ return;
+ }
+ }
+ }
+ throw new IllegalArgumentException("Cannot find WSDL port "+portURI);
+ }
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/builder/ExternalWebServiceConfigurationBuilder.java b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/builder/ExternalWebServiceConfigurationBuilder.java
new file mode 100644
index 0000000000..bae333ad85
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/builder/ExternalWebServiceConfigurationBuilder.java
@@ -0,0 +1,153 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.axis2.builder;
+
+import java.lang.reflect.Method;
+import java.util.Collection;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.tuscany.binding.axis2.assembly.WebServiceBinding;
+import org.apache.tuscany.binding.axis2.config.ExternalWebServiceRuntimeConfiguration;
+import org.apache.tuscany.binding.axis2.handler.ExternalWebServiceClient;
+import org.apache.tuscany.core.builder.BuilderException;
+import org.apache.tuscany.core.builder.RuntimeConfigurationBuilder;
+import org.apache.tuscany.core.config.JavaIntrospectionHelper;
+import org.apache.tuscany.core.context.Context;
+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.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Scope;
+
+import commonj.sdo.helper.TypeHelper;
+
+/**
+ * Creates a <code>RuntimeConfigurationBuilder</code> for an external service configured with the {@link WebServiceBinding}
+ *
+ * @version $Rev$ $Date$
+ */
+@Scope("MODULE")
+public class ExternalWebServiceConfigurationBuilder implements RuntimeConfigurationBuilder {
+
+ private RuntimeContext runtimeContext;
+
+ private ProxyFactoryFactory proxyFactoryFactory;
+
+ private MessageFactory messageFactory;
+
+ private RuntimeConfigurationBuilder policyBuilder;
+
+ public ExternalWebServiceConfigurationBuilder() {
+ }
+
+ @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(RuntimeConfigurationBuilder builder) {
+ policyBuilder = builder;
+ }
+
+ public void build(AssemblyModelObject object, Context context) throws BuilderException {
+ if (!(object instanceof ExternalService)) {
+ return;
+ }
+ ExternalService externalService = (ExternalService) object;
+ if (externalService.getBindings().size() < 1 || !(externalService.getBindings().get(0) instanceof WebServiceBinding)) {
+ return;
+ }
+
+ WebServiceBinding wsBinding=(WebServiceBinding)externalService.getBindings().get(0);
+
+ TypeHelper typeHelper=externalService.getAggregate().getAssemblyModelContext().getTypeHelper();
+ ExternalWebServiceClient externalWebServiceClient=new ExternalWebServiceClient(externalService, wsBinding, typeHelper);
+ ExternalWebServiceRuntimeConfiguration config = new ExternalWebServiceRuntimeConfiguration(externalService.getName(), new SingletonObjectFactory<ExternalWebServiceClient>(externalWebServiceClient));
+
+ 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, context);
+ }
+ // add tail interceptor
+ for (InvocationConfiguration iConfig : (Collection<InvocationConfiguration>) iConfigMap.values()) {
+ iConfig.addTargetInterceptor(new InvokerInterceptor());
+ }
+
+ externalService.getConfiguredService().setRuntimeConfiguration(config);
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/builder/ExternalWebServiceWireBuilder.java b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/builder/ExternalWebServiceWireBuilder.java
new file mode 100644
index 0000000000..4daf167d74
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/builder/ExternalWebServiceWireBuilder.java
@@ -0,0 +1,61 @@
+package org.apache.tuscany.binding.axis2.builder;
+
+import org.apache.tuscany.binding.axis2.config.ExternalWebServiceRuntimeConfiguration;
+import org.apache.tuscany.binding.axis2.handler.ExternalWebServiceTargetInvoker;
+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 ExternalWebServiceWireBuilder implements WireBuilder {
+
+ private RuntimeContext runtimeContext;
+
+ /**
+ * Constructs a new ExternalWebServiceWireBuilder.
+ */
+ public ExternalWebServiceWireBuilder() {
+ 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 (!(ExternalWebServiceRuntimeConfiguration.class.isAssignableFrom(targetType))) {
+ return;
+ }
+ for (InvocationConfiguration sourceInvocationConfig : sourceFactory.getProxyConfiguration().getInvocationConfigurations().values()) {
+
+ ExternalWebServiceTargetInvoker invoker = new ExternalWebServiceTargetInvoker(sourceFactory.getProxyConfiguration().getTargetName(), sourceInvocationConfig.getMethod(), targetScopeContext);
+
+ // if (downScope) {
+ // // the source scope is shorter than the target, so the invoker can cache the target instance
+ // invoker.setCacheable(true);
+ // } else {
+ // invoker.setCacheable(false);
+ // }
+ sourceInvocationConfig.setTargetInvoker(invoker);
+ }
+
+ }
+
+ public void completeTargetChain(ProxyFactory targetFactory, Class targetType, ScopeContext targetScopeContext)
+ throws BuilderConfigException {
+ //TODO implement
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/builder/WebServiceEntryPointConfigurationBuilder.java b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/builder/WebServiceEntryPointConfigurationBuilder.java
new file mode 100644
index 0000000000..a164f5bc44
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/builder/WebServiceEntryPointConfigurationBuilder.java
@@ -0,0 +1,170 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.axis2.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.tuscany.binding.axis2.assembly.WebServiceBinding;
+import org.apache.tuscany.binding.axis2.config.WebServiceEntryPointRuntimeConfiguration;
+import org.apache.tuscany.core.builder.BuilderException;
+import org.apache.tuscany.core.builder.RuntimeConfigurationBuilder;
+import org.apache.tuscany.core.builder.impl.EntryPointRuntimeConfiguration;
+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;
+
+/**
+ * Creates a <code>RuntimeConfigurationBuilder</code> for an entry point configured with the {@link WebServiceBinding}
+ *
+ * @version $Rev$ $Date$
+ */
+@Scope("MODULE")
+public class WebServiceEntryPointConfigurationBuilder implements RuntimeConfigurationBuilder<AggregateContext> {
+
+ private RuntimeContext runtimeContext;
+
+ private ProxyFactoryFactory proxyFactoryFactory;
+
+ private MessageFactory messageFactory;
+
+ private RuntimeConfigurationBuilder policyBuilder;
+
+ public WebServiceEntryPointConfigurationBuilder() {
+ }
+
+ @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(RuntimeConfigurationBuilder builder) {
+ policyBuilder = builder;
+ }
+
+ public void build(AssemblyModelObject object, AggregateContext parentContext) throws BuilderException {
+ if (!(object instanceof EntryPoint)) {
+ return;
+ }
+ EntryPoint entryPoint = (EntryPoint) object;
+ if (entryPoint.getBindings().size() < 1 || !(entryPoint.getBindings().get(0) instanceof WebServiceBinding)) {
+ return;
+ }
+
+ EntryPointRuntimeConfiguration config = new WebServiceEntryPointRuntimeConfiguration(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();
+ 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, parentContext);
+ }
+ // add tail interceptor
+ for (InvocationConfiguration iConfig : (Collection<InvocationConfiguration>) iConfigMap.values()) {
+ iConfig.addTargetInterceptor(new EntryPointInvokerInterceptor());
+ }
+ entryPoint.getConfiguredReference().setRuntimeConfiguration(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/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/config/ExternalWebServiceRuntimeConfiguration.java b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/config/ExternalWebServiceRuntimeConfiguration.java
new file mode 100644
index 0000000000..c776e861e2
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/config/ExternalWebServiceRuntimeConfiguration.java
@@ -0,0 +1,32 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.axis2.config;
+
+import org.apache.tuscany.core.builder.ObjectFactory;
+import org.apache.tuscany.core.builder.impl.BaseExternalServiceRuntimeConfiguration;
+
+/**
+ * Creates instances of {@link org.apache.tuscany.core.context.ExternalServiceContext} configured with the appropriate
+ * invocation chains and bindings. This implementation serves as a marker for
+ * {@link org.apache.tuscany.binding.axis2.builder.ExternalWebServiceWireBuilder}
+ *
+ * @version $Rev$ $Date$
+ */
+public class ExternalWebServiceRuntimeConfiguration extends BaseExternalServiceRuntimeConfiguration {
+
+ public ExternalWebServiceRuntimeConfiguration(String name, ObjectFactory objectFactory) {
+ super(name, objectFactory);
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/config/WebServiceEntryPointRuntimeConfiguration.java b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/config/WebServiceEntryPointRuntimeConfiguration.java
new file mode 100644
index 0000000000..3038fa258e
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/config/WebServiceEntryPointRuntimeConfiguration.java
@@ -0,0 +1,32 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.axis2.config;
+
+import org.apache.tuscany.core.builder.impl.EntryPointRuntimeConfiguration;
+import org.apache.tuscany.core.message.MessageFactory;
+
+/**
+ * Creates instances of {@link org.apache.tuscany.core.context.EntryPointContext} configured with the appropriate
+ * invocation chains and bindings. This implementation serves as a marker for
+ * {@link org.apache.tuscany.binding.axis2.builder.WebServiceEntryPointWireBuilder}
+ *
+ * @version $Rev$ $Date$
+ */
+public class WebServiceEntryPointRuntimeConfiguration extends EntryPointRuntimeConfiguration {
+
+ public WebServiceEntryPointRuntimeConfiguration(String name, String serviceName, MessageFactory messageFactory) {
+ super(name, serviceName, messageFactory);
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/handler/ExternalWebServiceClient.java b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/handler/ExternalWebServiceClient.java
new file mode 100644
index 0000000000..39bd26f72d
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/handler/ExternalWebServiceClient.java
@@ -0,0 +1,143 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.axis2.handler;
+
+import java.lang.reflect.Method;
+
+import javax.xml.namespace.QName;
+import javax.xml.parsers.FactoryConfigurationError;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
+import org.apache.axis2.context.MessageContextConstants;
+import org.apache.axis2.om.OMElement;
+import org.apache.tuscany.binding.axis2.assembly.WebServiceBinding;
+import org.apache.tuscany.binding.axis2.util.AxiomHelper;
+import org.apache.tuscany.model.assembly.ExternalService;
+import org.osoa.sca.ServiceRuntimeException;
+
+import commonj.sdo.helper.TypeHelper;
+
+/**
+ * An ExternalWebServiceClient using Axis2
+ */
+public class ExternalWebServiceClient {
+
+ private ExternalService externalService;
+ private TypeHelper typeHelper;
+ private WebServicePortMetaData wsPortMetaData;
+
+ /**
+ * Constructs a new ExternalWebServiceClient.
+ *
+ * @param externalService
+ * @param wsBinding
+ */
+ public ExternalWebServiceClient(ExternalService externalService, WebServiceBinding wsBinding, TypeHelper typeHelper) {
+ this.externalService = externalService;
+ this.typeHelper=typeHelper;
+ this.wsPortMetaData = new WebServicePortMetaData(wsBinding.getWSDLDefinition(), wsBinding.getWSDLPort(), wsBinding.getURI(), false);
+ }
+
+ /**
+ * Invoke an operation on the external Web service.
+ *
+ * @param method
+ * @param args
+ * @return
+ */
+ public Object invoke(Method method, Object[] args) {
+
+ ServiceClient serviceClient;
+ ClassLoader ccl=Thread.currentThread().getContextClassLoader();
+ try {
+ Thread.currentThread().setContextClassLoader(ExternalWebServiceClient.class.getClassLoader());
+
+ serviceClient = createServiceClient(method);
+
+ } finally {
+ Thread.currentThread().setContextClassLoader(ccl);
+ }
+
+ String typeName = method.getName();
+ String typeNS = wsPortMetaData.getPortType().getQName().getNamespaceURI();
+
+ OMElement requestOM = AxiomHelper.toOMElement(typeHelper, args, new QName(typeNS, typeName));
+
+ OMElement responseOM;
+ ccl=Thread.currentThread().getContextClassLoader();
+ try {
+ Thread.currentThread().setContextClassLoader(ExternalWebServiceClient.class.getClassLoader());
+
+ responseOM = serviceClient.sendReceive(requestOM);
+
+ } catch (AxisFault e) {
+ throw new ServiceRuntimeException(e);
+ } finally {
+ Thread.currentThread().setContextClassLoader(ccl);
+ }
+
+ Object[] os = AxiomHelper.toObjects(typeHelper, responseOM);
+ Object response;
+ if (os == null || os.length < 1) {
+ response = null;
+ } else {
+ response = os[0];
+ }
+
+ return response;
+ }
+
+ private ServiceClient createServiceClient(Method method) throws FactoryConfigurationError {
+
+ /*
+ * TODO: Simlistic impl for now, needs to be redone. Should cache our ConfigurationContext and pass in on ServiceClient constructor, should
+ * probably use WSDL configured Axis2 OperationClient
+ */
+
+ Options options = new Options();
+
+ options.setProperty(Constants.Configuration.DISABLE_ADDRESSING_FOR_OUT_MESSAGES, Boolean.TRUE);
+
+ WebServiceOperationMetaData operationMetaData = wsPortMetaData.getOperationMetaData(method.getName());
+
+ EndpointReference targetEPR = new EndpointReference(wsPortMetaData.getEndpoint());
+ options.setTo(targetEPR);
+
+ String soapAction = operationMetaData.getSOAPAction();
+ if (soapAction != null) {
+ options.setSoapAction(soapAction);
+ }
+
+ // If use is encoded assume its an old style service and wont understand chunking
+ if ("encoded".equals(operationMetaData.getUse())) {
+ options.setProperty(MessageContextConstants.CHUNKED, Boolean.FALSE);
+ }
+
+ ServiceClient serviceClient;
+ try {
+ serviceClient = new ServiceClient();
+ } catch (org.apache.axis2.AxisFault e) {
+ throw new RuntimeException(e);
+ }
+
+ serviceClient.setOptions(options);
+
+ return serviceClient;
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/handler/ExternalWebServiceTargetInvoker.java b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/handler/ExternalWebServiceTargetInvoker.java
new file mode 100644
index 0000000000..fcb2e2e944
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/handler/ExternalWebServiceTargetInvoker.java
@@ -0,0 +1,110 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.axis2.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;
+
+/**
+ * Responsible for invoking an external web service
+ *
+ * @version $Rev$ $Date$
+ */
+public class ExternalWebServiceTargetInvoker implements TargetInvoker {
+
+ private QualifiedName serviceName;
+ private String esName;
+ private Method method;
+ private ScopeContext container;
+
+ private ExternalServiceContext context;
+
+ /**
+ * Constructs a new ExternalWebServiceTargetInvoker.
+ * @param esName
+ * @param container
+ */
+ public ExternalWebServiceTargetInvoker(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;
+ }
+ ExternalWebServiceClient client = (ExternalWebServiceClient) 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 {
+ ExternalWebServiceTargetInvoker invoker = (ExternalWebServiceTargetInvoker) 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/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/handler/WebServiceEntryPointInOutSyncMessageReceiver.java b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/handler/WebServiceEntryPointInOutSyncMessageReceiver.java
new file mode 100644
index 0000000000..f0f49d5654
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/handler/WebServiceEntryPointInOutSyncMessageReceiver.java
@@ -0,0 +1,177 @@
+package org.apache.tuscany.binding.axis2.handler;
+
+import java.io.IOException;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.ListIterator;
+
+import javax.wsdl.Part;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.context.OperationContext;
+import org.apache.axis2.description.AxisOperation;
+import org.apache.axis2.engine.MessageReceiver;
+import org.apache.axis2.om.OMAbstractFactory;
+import org.apache.axis2.om.OMDocument;
+import org.apache.axis2.om.OMElement;
+import org.apache.axis2.om.OMFactory;
+import org.apache.axis2.om.OMNamespace;
+import org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver;
+import org.apache.axis2.soap.SOAPBody;
+import org.apache.axis2.soap.SOAPEnvelope;
+import org.apache.axis2.soap.SOAPFactory;
+import org.apache.tuscany.binding.axis2.util.AxiomHelper;
+import org.apache.tuscany.core.context.AggregateContext;
+import org.apache.tuscany.core.context.EntryPointContext;
+import org.apache.tuscany.core.context.InstanceContext;
+import org.apache.tuscany.model.assembly.EntryPoint;
+import org.apache.tuscany.sdo.helper.TypeHelperImpl;
+import org.apache.tuscany.sdo.util.SDOUtil;
+import org.apache.wsdl.WSDLConstants;
+import org.eclipse.emf.common.util.UniqueEList;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.Property;
+import commonj.sdo.Sequence;
+import commonj.sdo.Type;
+import commonj.sdo.helper.TypeHelper;
+
+public class WebServiceEntryPointInOutSyncMessageReceiver extends AbstractInOutSyncMessageReceiver {
+ // public static final String MEP_URL = "http://www.w3.org/2004/08/wsdl/tuscany/in-out";
+ public static final String MEP_URL = WSDLConstants.MEP_URI_OUT_IN;
+
+ protected final AggregateContext moduleContext;
+
+ protected final EntryPoint entryPoint;
+ protected final EntryPointContext entryPointContext;
+
+ private final WebServicePortMetaData wsdlPortInfo;
+
+ /**
+ * Field log
+ */
+
+ /**
+ * Constructor WebServiceEntryPointInOutSyncMessageReceiver
+ *
+ * @param entryPoint
+ * @param moduleContext
+ * @param context
+ * @param wsdlPortInfo
+ */
+ public WebServiceEntryPointInOutSyncMessageReceiver(AggregateContext moduleContext, EntryPoint entryPoint, EntryPointContext context, WebServicePortMetaData wsdlPortInfo) {
+ this.moduleContext = moduleContext;
+ this.entryPoint = entryPoint;
+ this.entryPointContext= context;
+ this.wsdlPortInfo = wsdlPortInfo;
+ }
+
+ public void invokeBusinessLogic(MessageContext msgContext, MessageContext outMsgContext) throws AxisFault {
+
+ ClassLoader ccl=Thread.currentThread().getContextClassLoader();
+ try {
+ Thread.currentThread().setContextClassLoader(entryPoint.getAggregate().getAssemblyModelContext().getApplicationResourceLoader().getClassLoader());
+
+ AxisOperation axisOperation = msgContext.getAxisOperation();
+ String axisOperationName= axisOperation.getName().getLocalPart();
+
+ TypeHelper typeHelper=entryPoint.getAggregate().getAssemblyModelContext().getTypeHelper();
+
+ OMElement requestOM = msgContext.getEnvelope().getBody().getFirstElement();
+ DataObject msgdo = AxiomHelper.toDataObject(typeHelper, requestOM);
+ // Sequence parmSeq = msgdo.getSequence("mixed");
+
+ requestOM = msgContext.getEnvelope().getBody().getFirstElement();
+ Object[] args = AxiomHelper.toObjects(typeHelper, requestOM);
+
+
+
+
+// ArrayList parms = new ArrayList(parmSeq.size());
+// for (int i = 0; i < parmSeq.size(); ++i) {
+// Object parmDO = (Object) parmSeq.getValue(i);// parm element
+// if (parmDO instanceof DataObject) {
+//
+// Sequence nn = ((DataObject) parmDO).getSequence("mixed");
+//
+// for (int j = 0; j < nn.size(); j++) {
+//
+// Object valueDO = (Object) nn.getValue(j); // data array s
+// if (valueDO instanceof DataObject) {
+//
+// Sequence seqVal = ((DataObject) valueDO).getSequence("mixed");
+// Object seqDO = seqVal.getValue(0);
+// if (seqDO instanceof String) {
+// parms.add(seqDO);
+// } else {
+// parms.add(valueDO); // no sure if this is right?
+//
+// }
+// }
+// }
+// }
+// }
+// Object[] args= parms.toArray(new Object[parms.size()]);
+ Class[] argsClazz= new Class[args.length];
+ for(int i= args.length -1; i> -1; --i){
+ argsClazz[i]= args[i].getClass();
+
+ }
+ Class clazz = entryPoint.getConfiguredService().getService().getServiceContract().getInterface();
+ Method operationMethod= clazz.getMethod(axisOperationName, argsClazz);
+
+
+ InvocationHandler handler = (InvocationHandler) entryPointContext.getImplementationInstance();
+
+
+ Object response = handler.invoke(null, operationMethod, args);
+
+
+ SOAPFactory fac = getSOAPFactory(msgContext);
+ SOAPEnvelope soapenv = fac.getDefaultEnvelope();
+ SOAPBody soapbody = soapenv.getBody();
+ //new SDO way....
+ QName responseTypeQN = getResponseTypeName(operationMethod.getName());
+ OMElement responseOM = AxiomHelper.toOMElement(typeHelper, new Object[] {response}, responseTypeQN);
+ soapbody.addChild(responseOM);
+
+
+
+ //Endof new SDO way
+
+
+
+
+
+ // se.addChild(sf.createText(response, true));
+ outMsgContext.setEnvelope(soapenv);
+ // outMsgContext.setAxisOperation(axisOperation);
+ // outMsgContext.setAxisService(msgContext.getAxisService());
+
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new AxisFault("Error creating DataObject from Soapenvelope. " + e.getClass() + " " + e.getMessage(), e);
+
+ } catch (Throwable e) {
+
+ e.printStackTrace();
+ throw new AxisFault("Error creating DataObject from Soapenvelope. " + e.getClass() + " " + e.getMessage(), e);
+ } finally {
+ Thread.currentThread().setContextClassLoader(ccl);
+ }
+
+ }
+ protected QName getResponseTypeName(String operationName) {
+ WebServiceOperationMetaData op = wsdlPortInfo.getOperationMetaData(operationName);
+ Part part = op.getOutputPart(0);
+ QName elementName = part.getElementName();
+ return elementName;
+ }
+
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/handler/WebServiceEntryPointServlet.java b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/handler/WebServiceEntryPointServlet.java
new file mode 100644
index 0000000000..cfcac3acdd
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/handler/WebServiceEntryPointServlet.java
@@ -0,0 +1,480 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.axis2.handler;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.wsdl.Definition;
+import javax.wsdl.Operation;
+import javax.wsdl.Port;
+import javax.wsdl.PortType;
+import javax.xml.namespace.QName;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ConfigurationContextFactory;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.context.SessionContext;
+import org.apache.axis2.description.AxisOperation;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.AxisServiceGroup;
+import org.apache.axis2.description.InOutAxisOperation;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.engine.AxisEngine;
+import org.apache.axis2.transport.http.HTTPConstants;
+import org.apache.axis2.transport.http.HTTPTransportUtils;
+import org.apache.axis2.transport.http.ListingAgent;
+import org.apache.axis2.transport.http.ServletBasedOutTransportInfo;
+import org.apache.tuscany.binding.axis2.assembly.WebServiceBinding;
+import org.apache.tuscany.core.context.AggregateContext;
+import org.apache.tuscany.core.context.EntryPointContext;
+import org.apache.tuscany.core.context.InstanceContext;
+import org.apache.tuscany.core.runtime.RuntimeContext;
+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.Module;
+
+/**
+ * Class AxisServlet
+ */
+public class WebServiceEntryPointServlet
+ extends HttpServlet
+{
+
+ private static final long serialVersionUID = -2085869393709833372L;
+
+ private static final String CONFIGURATION_CONTEXT = "CONFIGURATION_CONTEXT";
+
+ public static final String SESSION_ID = "SessionId";
+
+ private ConfigurationContext configContext;
+
+ private AxisConfiguration axisConfiguration;
+
+ private ListingAgent lister;
+
+ private MessageContext createAndSetInitialParamsToMsgCtxt( Object sessionContext, MessageContext msgContext,
+ HttpServletResponse httpServletResponse,
+ HttpServletRequest httpServletRequest )
+ throws AxisFault
+ {
+ msgContext = new MessageContext();
+ msgContext.setConfigurationContext( configContext );
+ msgContext.setSessionContext( (SessionContext) sessionContext );
+ msgContext.setTransportIn( axisConfiguration.getTransportIn( new QName( Constants.TRANSPORT_HTTP ) ) );
+ msgContext.setTransportOut( axisConfiguration.getTransportOut( new QName( Constants.TRANSPORT_HTTP ) ) );
+
+ msgContext.setProperty( Constants.OUT_TRANSPORT_INFO, new ServletBasedOutTransportInfo( httpServletResponse ) );
+ msgContext.setProperty( MessageContext.TRANSPORT_HEADERS, getTransportHeaders( httpServletRequest ) );
+ msgContext.setProperty( SESSION_ID, httpServletRequest.getSession().getId() );
+
+ return msgContext;
+ }
+
+ public void destroy()
+ {
+ super.destroy();
+ }
+
+ /**
+ * Method doGet
+ *
+ * @param httpServletRequest
+ * @param httpServletResponse
+ * @throws ServletException
+ * @throws IOException
+ */
+ protected void doGet( HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse )
+ throws ServletException, IOException
+ {
+ MessageContext msgContext = null;
+ OutputStream out = null;
+
+ try
+ {
+ Object sessionContext = getSessionContext( httpServletRequest );
+ HashMap map = getHTTPParameters( httpServletRequest );
+
+ msgContext = createAndSetInitialParamsToMsgCtxt( sessionContext, msgContext, httpServletResponse,
+ httpServletRequest );
+ msgContext.setDoingREST( true );
+ msgContext.setServerSide( true );
+ out = httpServletResponse.getOutputStream();
+
+ boolean processed = HTTPTransportUtils.processHTTPGetRequest( msgContext, httpServletRequest
+ .getInputStream(), out, httpServletRequest.getContentType(), httpServletRequest
+ .getHeader( HTTPConstants.HEADER_SOAP_ACTION ), httpServletRequest.getRequestURL().toString(),
+ configContext, map );
+
+ if ( !processed )
+ {
+ lister.handle( httpServletRequest, httpServletResponse, out );
+ }
+ }
+ catch ( AxisFault e )
+ {
+ if ( msgContext != null )
+ {
+ handleFault( msgContext, out, e );
+ }
+ else
+ {
+ throw new ServletException( e );
+ }
+ }
+ catch ( Exception e )
+ {
+ throw new ServletException( e );
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see javax.servlet.http.HttpServlet#doPost(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
+ */
+
+ /**
+ * Method doPost
+ *
+ * @param req
+ * @param res
+ * @throws ServletException
+ * @throws IOException
+ */
+ protected void doPost( HttpServletRequest req, HttpServletResponse res )
+ throws ServletException, IOException
+ {
+ MessageContext msgContext = null;
+ OutputStream out = null;
+
+ ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+ ClassLoader mycl = getClass().getClassLoader();
+ try
+ {
+ if ( tccl != mycl )
+ {
+ Thread.currentThread().setContextClassLoader( mycl );
+ }
+ Object sessionContext = getSessionContext( req );
+
+ msgContext = createAndSetInitialParamsToMsgCtxt( sessionContext, msgContext, res, req );
+
+ // adding ServletContext into msgContext;
+ msgContext.setProperty( Constants.SERVLET_CONTEXT, sessionContext );
+ out = res.getOutputStream();
+ HTTPTransportUtils.processHTTPPostRequest( msgContext, req.getInputStream(), out, req.getContentType(), req
+ .getHeader( HTTPConstants.HEADER_SOAP_ACTION ), req.getRequestURL().toString() );
+
+ Object contextWritten = msgContext.getOperationContext().getProperty( Constants.RESPONSE_WRITTEN );
+
+ res.setContentType( "text/xml; charset=" + msgContext.getProperty( MessageContext.CHARACTER_SET_ENCODING ) );
+
+ if ( ( contextWritten == null ) || !Constants.VALUE_TRUE.equals( contextWritten ) )
+ {
+ res.setStatus( HttpServletResponse.SC_ACCEPTED );
+ }
+ }
+ catch ( AxisFault e )
+ {
+ if ( msgContext != null )
+ {
+ res.setStatus( HttpServletResponse.SC_INTERNAL_SERVER_ERROR );
+ handleFault( msgContext, out, e );
+ }
+ else
+ {
+ throw new ServletException( e );
+ }
+ }
+ finally
+ {
+ if ( tccl != mycl )
+ {
+ Thread.currentThread().setContextClassLoader( tccl );
+ }
+ }
+ }
+
+ private void handleFault( MessageContext msgContext, OutputStream out, AxisFault e )
+ throws AxisFault
+ {
+ msgContext.setProperty( MessageContext.TRANSPORT_OUT, out );
+
+ AxisEngine engine = new AxisEngine( configContext );
+ MessageContext faultContext = engine.createFaultMessageContext( msgContext, e );
+
+ engine.sendFault( faultContext );
+ }
+
+ /**
+ * Method init
+ *
+ * @param config
+ * @throws ServletException
+ */
+ public void init( ServletConfig config )
+ throws ServletException
+ {
+ ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+ ClassLoader mycl = getClass().getClassLoader();
+ try
+ {
+ if ( tccl != mycl )
+ {
+ Thread.currentThread().setContextClassLoader( mycl );
+ }
+ configContext = initConfigContext( config );
+ initTuscany( configContext.getAxisConfiguration(), config );
+ lister = new ListingAgent( configContext );
+ axisConfiguration = configContext.getAxisConfiguration();
+ config.getServletContext().setAttribute( CONFIGURATION_CONTEXT, configContext );
+ }
+ catch ( Exception e )
+ {
+ e.printStackTrace();
+ throw new ServletException( e );
+ }
+ finally
+ {
+ if ( tccl != mycl )
+ {
+ Thread.currentThread().setContextClassLoader( tccl );
+ }
+ }
+ }
+
+ RuntimeContext getTuscanyWebAppRuntime( ServletConfig config )
+ {
+
+ Object ret = (RuntimeContext) ( config ).getServletContext()
+ .getAttribute( "org.apache.tuscany.core.runtime.RuntimeContext" );
+ if ( !( ret instanceof RuntimeContext ) )
+ {
+ RuntimeException rete = new RuntimeException( "Tuscany configuration not found! "
+ + ( ( ret == null ) ? "" : "unexpected class" + ret.getClass() ) );
+ rete.printStackTrace();//pretty majar make sure something gets logged.
+ throw rete;
+
+ }
+ return (RuntimeContext) ret;
+ }
+
+ void initTuscany( final AxisConfiguration axisConfig, ServletConfig config )
+ throws AxisFault
+ {
+
+ // Register all the Web service entry points
+ RuntimeContext tuscanyRuntime = getTuscanyWebAppRuntime( config );
+
+ // Get the current SCA module context
+
+ // AggregateContext moduleContext = (AggregateContext) tuscanyRuntime.getAggregate().getAssemblyModelContext();//getRootContext();//.getModuleComponentContext();
+ try
+ {
+ tuscanyRuntime.start();
+ AggregateContext moduleContext = tuscanyRuntime.getRootContext();
+ Module rootModule = (Module) moduleContext.getAggregate();
+
+ for ( Iterator m = rootModule.getComponents().iterator(); m.hasNext(); )
+ {
+ Module module = (Module) ( (Component) m.next() ).getComponentImplementation();
+
+ for ( Iterator i = module.getEntryPoints().iterator(); i.hasNext(); )
+ {
+ EntryPoint entryPoint = (EntryPoint) i.next();
+ final String epName = entryPoint.getName();
+
+ ServletContext servletContext = config.getServletContext();
+ AggregateContext moduleContext2 = (AggregateContext) servletContext
+ .getAttribute( "org.apache.tuscany.core.webapp.ModuleComponentContext" );
+ InstanceContext entryPointContext = moduleContext2.getContext( epName );
+
+ Binding binding = (Binding) entryPoint.getBindings().get( 0 );
+ if ( binding instanceof WebServiceBinding )
+ {
+
+ WebServiceBinding wsBinding = (WebServiceBinding) binding;
+ Definition definition = wsBinding.getWSDLDefinition();
+ Port port = wsBinding.getWSDLPort();
+ QName qname = new QName( definition.getTargetNamespace(), port.getName() );
+ if ( qname != null )
+ {
+
+ WebServicePortMetaData wsdlPortInfo = new WebServicePortMetaData( definition, port, null,
+ false );
+
+ WebServiceEntryPointInOutSyncMessageReceiver msgrec = new WebServiceEntryPointInOutSyncMessageReceiver(
+ moduleContext,
+ entryPoint,
+ (EntryPointContext) entryPointContext,
+ wsdlPortInfo );
+
+ AxisServiceGroup serviceGroup = new AxisServiceGroup( axisConfig );
+ axisConfig
+ .addMessageReceiver( WebServiceEntryPointInOutSyncMessageReceiver.MEP_URL, msgrec );
+ serviceGroup.setServiceGroupName( wsdlPortInfo.getServiceName().getLocalPart() );
+
+ // to create service from wsdl stream --->
+ // AxisServiceBuilder axisServiceBuilder = new AxisServiceBuilder();
+ // return axisServiceBuilder.getAxisService(in);
+
+ AxisService axisService = new AxisService( epName );
+ axisService.setParent( serviceGroup );
+ axisService.setServiceDescription( "Tuscany configured service EntryPoint name '" + epName
+ + "'" );
+ // axisService.setTargetNamespace(wsdlPortInfo.getPortName().getNamespaceURI());
+ axisService.addMessageReceiver( WebServiceEntryPointInOutSyncMessageReceiver.MEP_URL,
+ msgrec );
+
+ // Create operation descriptions for all the operations
+ PortType wsdlPortType = wsdlPortInfo.getPortType();
+ for ( Iterator j = wsdlPortType.getOperations().iterator(); j.hasNext(); )
+ {
+ Operation wsdlOperation = (Operation) j.next();
+ String operationName = wsdlOperation.getName();
+ AxisOperation axisOp = new InOutAxisOperation( new javax.xml.namespace.QName( qname
+ .getNamespaceURI(), operationName ) );
+ axisOp.setMessageReceiver( msgrec );
+ axisService.addOperation( axisOp );
+ axisOp.setMessageExchangePattern( WebServiceEntryPointInOutSyncMessageReceiver.MEP_URL );
+
+ axisConfig.addService( axisService );
+
+ }
+ axisConfig.addServiceGroup( serviceGroup );
+
+ }
+
+ }
+ }
+ }
+ }
+ finally
+ {
+ // tuscanyRuntime.stop();
+ }
+ }
+
+ /**
+ * Initialize the Axis configuration context
+ *
+ * @param config Servlet configuration
+ * @throws ServletException
+ */
+ protected ConfigurationContext initConfigContext( ServletConfig config )
+ throws ServletException
+ {
+ try
+ {
+ ServletContext context = config.getServletContext();
+ String repoDir = context.getRealPath( "/WEB-INF" );
+ ConfigurationContextFactory erfac = new ConfigurationContextFactory();
+ ConfigurationContext configContext = erfac.createConfigurationContextFromFileSystem( repoDir );
+ configContext.setProperty( Constants.CONTAINER_MANAGED, Constants.VALUE_TRUE );
+ configContext.setRootDir( new File( context.getRealPath( "/WEB-INF" ) ) );
+ return configContext;
+ }
+ catch ( Exception e )
+ {
+ throw new ServletException( e );
+ }
+ }
+
+ private HashMap getHTTPParameters( HttpServletRequest httpServletRequest )
+ {
+ HashMap map = new HashMap();
+ Enumeration enu = httpServletRequest.getParameterNames();
+
+ while ( enu.hasMoreElements() )
+ {
+ String name = (String) enu.nextElement();
+ String value = httpServletRequest.getParameter( name );
+
+ map.put( name, value );
+ }
+
+ return map;
+ }
+
+ private Object getSessionContext( HttpServletRequest httpServletRequest )
+ {
+ Object sessionContext = httpServletRequest.getSession( true ).getAttribute( Constants.SESSION_CONTEXT_PROPERTY );
+
+ if ( sessionContext == null )
+ {
+ sessionContext = new SessionContext( null );
+ httpServletRequest.getSession().setAttribute( Constants.SESSION_CONTEXT_PROPERTY, sessionContext );
+ }
+
+ return sessionContext;
+ }
+
+ private Map getTransportHeaders( HttpServletRequest req )
+ {
+ HashMap headerMap = new HashMap();
+ Enumeration headerNames = req.getHeaderNames();
+
+ while ( headerNames.hasMoreElements() )
+ {
+ String key = (String) headerNames.nextElement();
+ String value = req.getHeader( key );
+
+ headerMap.put( key, value );
+ }
+
+ return headerMap;
+ }
+ //RRFOO
+ //TODO get axis2.xml in
+ /*
+ *
+ // Get the current SCA module context
+ AggregateContext moduleContext = tuscanyRuntime.getModuleComponentContext();
+ tuscanyRuntime.start();
+ try {
+
+ Module module = (Module)moduleContext.getAggregate();
+ AssemblyModelContext modelContext = module.getAssemblyModelContext();
+
+ // Load the .wsdd configuration
+ ResourceLoader bundleContext = modelContext.getResourceLoader();
+ InputStream wsdd;
+ try {
+ URL url = bundleContext.getResource("org/apache/tuscany/binding/axis/engine/config/server-config.wsdd");
+ wsdd = url.openStream();
+ } catch (IOException e1) {
+ throw new ServiceRuntimeException(e1);
+ }
+
+ *
+ */
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/handler/WebServiceOperationMetaData.java b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/handler/WebServiceOperationMetaData.java
new file mode 100644
index 0000000000..04c05b95dd
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/handler/WebServiceOperationMetaData.java
@@ -0,0 +1,484 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.axis2.handler;
+
+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
+ *
+ */
+public class WebServiceOperationMetaData {
+ // WSDL Binding and BindingOperation
+ private Binding binding;
+ private BindingOperation bindingOperation;
+
+ // Fields to cache derived metadata
+ private transient Set inputHeaderParts;
+ private transient Set outputHeaderParts;
+ private transient String style;
+ private transient String use;
+ private transient String soapAction;
+ private transient List 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 getInputHeaderParts() {
+ if (inputHeaderParts == null) {
+ // Build a set of header parts that we need to exclude
+ inputHeaderParts = new HashSet();
+ 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 getOutputHeaderParts() {
+ if (outputHeaderParts == null) {
+ // Build a set of header parts that we need to exclude
+ outputHeaderParts = new HashSet();
+ 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 = (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.
+ *
+ * @param wsdlBindingOperation
+ * @return
+ */
+ public String getSOAPAction() {
+ if (soapAction == null) {
+ final List wsdlBindingOperationExtensions = bindingOperation.getExtensibilityElements();
+ final SOAPOperation soapOp = (SOAPOperation) 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 getSOAPBodyParts(boolean input) {
+ javax.wsdl.extensions.soap.SOAPBody soapBody = getSOAPBody(input);
+ if (soapBody != null) {
+ List parts = soapBody.getParts();
+ if (parts!=null) {
+ List names = new ArrayList();
+ for (Iterator i = parts.iterator(); i.hasNext();) {
+ Object part = i.next();
+ if (part instanceof String)
+ names.add(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 = (javax.wsdl.extensions.soap.SOAPBody) WebServicePortMetaData.getExtensibilityElement(elements,
+ javax.wsdl.extensions.soap.SOAPBody.class);
+ return soapBody;
+ }
+
+ /**
+ * Returns the use attribute
+ *
+ * @param wsdlOperation
+ * @return
+ */
+ 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;
+ }
+
+ 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
+ *
+ * @param wsdlBinding
+ * @param bindingOperation
+ * @return
+ */
+ public List getOperationSignature() {
+ if (signature == null) {
+ signature = new ArrayList();
+
+ Operation operation = bindingOperation.getOperation();
+ if (operation == null)
+ return signature;
+
+ final Input input = operation.getInput();
+ if (input == null) {
+ return signature;
+ }
+
+ String style = getStyle();
+
+ if (style.equals("rpc")) {
+ 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, since a wrapper with the operation
+ * name is not present, the message signatures must be
+ * correctly 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 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 TODO
+ * @return
+ */
+ public List getBodyPartIndexes(boolean isInput) {
+ List indexes = new ArrayList();
+
+ Message message = getMessage(isInput);
+ if (message == null)
+ return indexes;
+
+ List 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(new Integer(index));
+ } else {
+ // "parts" in soap:body
+ if (bodyParts.contains(part.getName()))
+ indexes.add(new Integer(index));
+
+ }
+ }
+ return indexes;
+ }
+
+ /**
+ * Get the corresponding index for a part in the SOAP header by element
+ * name
+ *
+ * @param elementName
+ * @param isInput TODO
+ * @return
+ */
+ 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;
+ }
+
+} \ No newline at end of file
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/handler/WebServicePortMetaData.java b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/handler/WebServicePortMetaData.java
new file mode 100644
index 0000000000..15eec4dc7e
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/handler/WebServicePortMetaData.java
@@ -0,0 +1,362 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.axis2.handler;
+
+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.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 javax.xml.soap.Name;
+//import javax.xml.soap.SOAPBodyElement;
+//import javax.xml.soap.SOAPElement;
+
+import org.apache.tuscany.model.types.wsdl.WSDLServiceContract;
+
+/**
+ * Metadata for a WSDL port
+ *
+ */
+public class WebServicePortMetaData {
+
+ private final static String SOAP_ENCODING_URI = "http://schemas.xmlsoap.org/wsdl/soap/";
+
+ 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 allOperationMetaData;
+ private WSDLServiceContract interfaceType;
+
+ /**
+ * Constructor
+ *
+ * @param wsdlDefinition
+ * @param portName
+ */
+ 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<Service> services=(Collection<Service>)wsdlDefinition.getServices().values();
+ for (Service service : services) {
+ 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 portType
+ */
+ 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.
+ *
+ * @param wsdlPort
+ * @return
+ */
+ 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 (Iterator i = wsdlPortExtensions.iterator(); i.hasNext();) {
+ final Object extension = i.next();
+ if (extension instanceof SOAPAddress) {
+ final SOAPAddress address = (SOAPAddress) extension;
+ return address.getLocationURI();
+ }
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Returns the SOAP binding style.
+ * @return
+ */
+ public String getStyle() {
+
+ // Find the binding style
+ String style = null;
+ if (wsdlBinding != null) {
+ final List wsdlBindingExtensions = wsdlBinding.getExtensibilityElements();
+ SOAPBinding soapBinding = (SOAPBinding) getExtensibilityElement(wsdlBindingExtensions, SOAPBinding.class);
+ if (soapBinding != null)
+ style = soapBinding.getStyle();
+ }
+
+ // Default to document
+ return (style == null) ? "document" : style;
+ }
+
+ /**
+ * Returns the use attribute
+ * @return
+ */
+ public String getUse() {
+ List list = getAllOperationMetaData();
+ WebServiceOperationMetaData operationMetaData = (WebServiceOperationMetaData) list.get(0);
+ return operationMetaData.getUse();
+ }
+
+ /**
+ * Returns the encoding attribute
+ * @return
+ */
+ public String getEncoding() {
+ List list = getAllOperationMetaData();
+ WebServiceOperationMetaData operationMetaData = (WebServiceOperationMetaData) list.get(0);
+ return operationMetaData.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
+ * @return
+ */
+ public static Object getExtensibilityElement(List elements, Class type) {
+ for (Iterator i = elements.iterator(); i.hasNext();) {
+ Object element = i.next();
+ if (type.isInstance(element))
+ return element;
+ }
+ return null;
+ }
+
+ /**
+ * Returns the extensibility elements of the given type.
+ * @param elements
+ * @param type
+ * @return
+ */
+ public static List getExtensibilityElements(List elements, Class type) {
+ List result = new ArrayList();
+ for (Iterator i = elements.iterator(); i.hasNext();) {
+ Object element = i.next();
+ if (type.isInstance(element))
+ result.add(element);
+ }
+ return result;
+ }
+
+ /**
+ * Get the operation signature from the SOAP Body
+ * @param 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 getAllOperationMetaData() {
+ if (allOperationMetaData == null) {
+ allOperationMetaData = new ArrayList();
+ 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) {
+ for (Iterator it = getAllOperationMetaData().iterator(); it.hasNext();) {
+ WebServiceOperationMetaData descriptor = (WebServiceOperationMetaData) it.next();
+ String opName = descriptor.getBindingOperation().getOperation().getName();
+
+ if (opName.equals(operationName))
+ return descriptor;
+ }
+ return null;
+ }
+
+ /**
+ * Returns the WSDL service contract
+ * @return
+ */
+ public WSDLServiceContract getInterfaceType() {
+ return interfaceType;
+ }
+
+} \ No newline at end of file
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/loader/WebServiceSCDLModelLoader.java b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/loader/WebServiceSCDLModelLoader.java
new file mode 100644
index 0000000000..d587a4680f
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/loader/WebServiceSCDLModelLoader.java
@@ -0,0 +1,74 @@
+package org.apache.tuscany.binding.axis2.loader;
+
+import org.apache.tuscany.binding.axis2.assembly.WebServiceAssemblyFactory;
+import org.apache.tuscany.binding.axis2.assembly.WebServiceBinding;
+import org.apache.tuscany.binding.axis2.assembly.impl.WebServiceAssemblyFactoryImpl;
+import org.apache.tuscany.binding.axis2.assembly.impl.WebServiceBindingImpl;
+import org.apache.tuscany.core.runtime.RuntimeContext;
+import org.apache.tuscany.core.system.annotation.Autowire;
+import org.apache.tuscany.core.loader.SCDLModelLoaderRegistry;
+import org.apache.tuscany.model.assembly.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.AssemblyModelObject;
+import org.apache.tuscany.model.scdl.loader.SCDLModelLoader;
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Destroy;
+
+/**
+ * Populates the assembly model from an SCDL model
+ */
+@org.osoa.sca.annotations.Scope("MODULE")
+public class WebServiceSCDLModelLoader implements SCDLModelLoader {
+
+ private RuntimeContext runtimeContext;
+ private SCDLModelLoaderRegistry loaderRegistry;
+ private WebServiceAssemblyFactory wsFactory;
+
+ /**
+ * Constructs a new WebServiceSCDLModelLoader.
+ */
+ public WebServiceSCDLModelLoader() {
+ this.wsFactory=new WebServiceAssemblyFactoryImpl();
+ }
+
+ /**
+ * @param runtimeContext The runtimeContext to set.
+ */
+ @Autowire
+ public void setRuntimeContext(RuntimeContext runtimeContext) {
+ this.runtimeContext = runtimeContext;
+ }
+
+ // @Autowire
+ public void setLoaderRegistry(SCDLModelLoaderRegistry registry) {
+ this.loaderRegistry = registry;
+ }
+
+ @Init(eager=true)
+ public void init() {
+ runtimeContext.addLoader(this);
+// loaderRegistry.registerLoader(this);
+ }
+
+ @Destroy
+ public void destroy() {
+ loaderRegistry.unregisterLoader(this);
+ }
+
+ /**
+ * @see org.apache.tuscany.model.scdl.loader.SCDLModelLoader#load(org.apache.tuscany.model.assembly.AssemblyModelContext, java.lang.Object)
+ */
+ public AssemblyModelObject load(AssemblyModelContext modelContext, Object object) {
+ if (object instanceof org.apache.tuscany.model.scdl.WebServiceBinding) {
+ org.apache.tuscany.model.scdl.WebServiceBinding scdlBinding=(org.apache.tuscany.model.scdl.WebServiceBinding)object;
+ WebServiceBinding binding=wsFactory.createWebServiceBinding();
+ binding.setURI(scdlBinding.getUri());
+
+ // Set the port URI into the assembly binding, it'll be resolved in the initialize method
+ ((WebServiceBindingImpl)binding).setPortURI(scdlBinding.getPort());
+
+ return binding;
+
+ } else
+ return null;
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/util/AxiomHelper.java b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/util/AxiomHelper.java
new file mode 100644
index 0000000000..3df1a4104d
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/util/AxiomHelper.java
@@ -0,0 +1,185 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.axis2.util;
+
+import java.io.IOException;
+import java.io.PipedInputStream;
+import java.io.PipedOutputStream;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.FactoryConfigurationError;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.axis2.om.OMAbstractFactory;
+import org.apache.axis2.om.OMElement;
+import org.apache.axis2.om.OMXMLParserWrapper;
+import org.apache.axis2.om.impl.llom.factory.OMXMLBuilderFactory;
+import org.apache.tuscany.sdo.helper.DataFactoryImpl;
+import org.apache.tuscany.sdo.helper.XMLHelperImpl;
+import org.apache.tuscany.sdo.helper.XSDHelperImpl;
+import org.osoa.sca.ServiceRuntimeException;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.Property;
+import commonj.sdo.helper.TypeHelper;
+import commonj.sdo.helper.XMLDocument;
+import commonj.sdo.helper.XSDHelper;
+
+/**
+ * Utility methods to convert between Axis2 AXIOM, SDO DataObjects and Java objects.
+ *
+ * Most of these methods rely on the schemas having been registered with XSDHelper.define
+ */
+public class AxiomHelper {
+
+ /**
+ * Deserialize an OMElement into Java Objects
+ *
+ * @param om
+ * the OMElement
+ * @return the array of deserialized Java objects
+ */
+ public static Object[] toObjects(TypeHelper typeHelper, OMElement om) {
+ DataObject dataObject = toDataObject(typeHelper, om);
+ Object[] os = toObjects(dataObject);
+ return os;
+ }
+
+ /**
+ * Convert a typed DataObject to Java objects
+ *
+ * @param dataObject
+ * @return the array of Objects from the DataObject
+ */
+ public static Object[] toObjects(DataObject dataObject) {
+ 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;
+ }
+
+ /**
+ * Convert objects to an AXIOM OMElement
+ *
+ * @param os
+ * @param typeNS
+ * @param typeName
+ * @return an AXIOM OMElement
+ */
+ public static OMElement toOMElement(TypeHelper typeHelper, Object[] os, QName typeQN) {
+ DataObject dataObject = toDataObject(typeHelper, os, typeQN);
+ OMElement omElement = toOMElement(typeHelper, dataObject, typeQN);
+ return omElement;
+ }
+
+ /**
+ * Convert a DataObject to AXIOM OMElement
+ *
+ * @param dataObject
+ * @param typeNS
+ * @param typeName
+ * @return
+ * @throws XMLStreamException
+ * @throws IOException
+ */
+ public static OMElement toOMElement(TypeHelper typeHelper, DataObject dataObject, QName typeQN) {
+ try {
+
+ PipedOutputStream pos = new PipedOutputStream();
+ PipedInputStream pis = new PipedInputStream(pos);
+ new XMLHelperImpl(typeHelper).save(dataObject, typeQN.getNamespaceURI(), typeQN.getLocalPart(), pos);
+ pos.close();
+
+ XMLStreamReader parser;
+ ClassLoader ccl=Thread.currentThread().getContextClassLoader();
+ try {
+ Thread.currentThread().setContextClassLoader(AxiomHelper.class.getClassLoader());
+ parser = XMLInputFactory.newInstance().createXMLStreamReader(pis);
+ } finally {
+ Thread.currentThread().setContextClassLoader(ccl);
+ }
+ OMXMLParserWrapper builder = OMXMLBuilderFactory.createStAXOMBuilder(OMAbstractFactory.getOMFactory(), parser);
+ OMElement root = builder.getDocumentElement();
+
+ return root;
+
+ } catch (IOException e) {
+ throw new ServiceRuntimeException(e);
+ } catch (XMLStreamException e) {
+ throw new ServiceRuntimeException(e);
+ } catch (FactoryConfigurationError e) {
+ throw new ServiceRuntimeException(e);
+ }
+ }
+
+ /**
+ * Deserialize an AXIOM OMElement into a DataObject
+ *
+ * @param omElement
+ * @return
+ */
+ public static DataObject toDataObject(TypeHelper typeHelper, OMElement omElement) {
+ try {
+
+ PipedOutputStream pos = new PipedOutputStream();
+ PipedInputStream pis = new PipedInputStream(pos);
+
+ ClassLoader ccl=Thread.currentThread().getContextClassLoader();
+ try {
+ Thread.currentThread().setContextClassLoader(AxiomHelper.class.getClassLoader());
+ omElement.serialize(pos);
+ } finally {
+ Thread.currentThread().setContextClassLoader(ccl);
+ }
+
+ pos.flush();
+ pos.close();
+
+ XMLDocument document = new XMLHelperImpl(typeHelper).load(pis);
+
+ return document.getRootObject();
+
+ } catch (IOException e) {
+ throw new ServiceRuntimeException(e);
+ } catch (XMLStreamException e) {
+ throw new ServiceRuntimeException(e);
+ }
+ }
+
+ /**
+ * Convert objects to typed DataObject
+ *
+ * @param typeNS
+ * @param typeName
+ * @param os
+ * @return the DataObject
+ */
+ public static DataObject toDataObject(TypeHelper typeHelper, 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();
+ for (int i = 0; i < ips.size(); i++) {
+ Property p = (Property) ips.get(i);
+ dataObject.set(i, os[i]);
+ }
+ return dataObject;
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/resources/org/apache/tuscany/binding/axis2/engine/config/axis2.xml b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/resources/org/apache/tuscany/binding/axis2/engine/config/axis2.xml
new file mode 100644
index 0000000000..d42457fdf6
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/resources/org/apache/tuscany/binding/axis2/engine/config/axis2.xml
@@ -0,0 +1,167 @@
+<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>
+ <!-- Uncomment this to enable REST support -->
+ <!-- <parameter name="enableREST" locked="false">true</parameter>-->
+
+
+ <parameter name="userName" locked="false">admin</parameter>
+ <parameter name="password" locked="false">axis2</parameter>
+
+ <parameter name="seralizeLocation" locked="false">.</parameter>
+ <hostConfiguration>
+ <ip>127.0.0.1</ip>
+ <port>5555</port>
+ </hostConfiguration>
+
+
+ <!--if you want to extract the service archive file and work with that please uncomment this-->
+ <!--else , it wont extract archive file or does not take into consideration if someone drop-->
+ <!--exploded directory into /service directory-->
+ <!--<parameter name="extractServiceArchive" locked="false">true</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.axis2.receivers.RawXMLINOnlyMessageReceiver"/>
+ <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out"
+ class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
+ </messageReceivers>
+ <!-- ================================================= -->
+ <!-- Transport Ins -->
+ <!-- ================================================= -->
+ <transportReceiver name="http" class="org.apache.axis2.transport.http.SimpleHTTPServer">
+ <parameter name="port" locked="false">6060</parameter>
+ </transportReceiver>
+
+ <!-- Uncomment this one with the appropriate papameters to enable the SMTP transport Receiver
+ <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> -->
+
+ <!--REMOVED FOR TUSCANY transportReceiver name="tcp" class="org.apache.axis2.transport.tcp.TCPServer">
+ <parameter name="port" locked="false">6060</parameter>
+ </transportReceiver -->
+
+ <!--REMOVED FOR TUSCANY transportReceiver name="jms" class="org.apache.axis2.transport.jms.SimpleJMSListener">
+ <parameter name="transport.jms.Destination" locked="false">dynamicQueues/FOO</parameter>
+ <parameter name="java.naming.factory.initial" locked="false">
+ org.activemq.jndi.ActiveMQInitialContextFactory</parameter>
+ <parameter name="java.naming.provider.url" locked="false">tcp://localhost:61616</parameter>
+ </transportReceiver>
+ -->
+
+ <!-- ================================================= -->
+ <!-- Transport Outs -->
+ <!-- ================================================= -->
+
+ <!--REMOVED FOR TUSCANY transportSender name="tcp" class="org.apache.axis2.transport.tcp.TCPTransportSender"/> -->
+ <transportSender name="local" class="org.apache.axis2.transport.local.LocalTransportSender"/>
+ <!--REMOVED FOR TUSCANY transportSender name="jms" class="org.apache.axis2.transport.jms.JMSSender"/> -->
+ <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>
+
+ <!-- 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 -->
+ <!--REMOVED FOR 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="TransportIn"/>
+ <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="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="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>
+ <!-- System pre defined phases -->
+ <!-- After Postdispatch phase module author or or service author can add any phase he want -->
+ <phase name="userphase1"/>
+ </phaseOrder>
+ <phaseOrder type="outflow">
+ <!-- user can add his own phases to this area -->
+ <phase name="userphase1"/>
+ <!--system predefined phase-->
+ <!--these phase will run irrespective of the service-->
+ <phase name="PolicyDetermination"/>
+ <phase name="MessageOut"/>
+ </phaseOrder>
+ <phaseOrder type="INfaultflow">
+ <!-- user can add his own phases to this area -->
+ <phase name="userphase1"/>
+ </phaseOrder>
+ <phaseOrder type="Outfaultflow">
+ <!-- user can add his own phases to this area -->
+ <phase name="userphase1"/>
+ <phase name="PolicyDetermination"/>
+ <phase name="MessageOut"/>
+ </phaseOrder>
+</axisconfig>
+
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/resources/system.fragment b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/resources/system.fragment
new file mode 100644
index 0000000000..cef83e6d65
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/main/resources/system.fragment
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
+
+ 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.
+ -->
+<moduleFragment xmlns="http://www.osoa.org/xmlns/sca/0.9" xmlns:v="http://www.osoa.org/xmlns/sca/values/0.9"
+ xmlns:system="http://org.apache.tuscany/xmlns/system/0.9"
+ name="org.apache.tuscany.binding.axis">
+
+ <component name="org.apache.tuscany.binding.axis2.builder.ExternalWebServiceConfigurationBuilder">
+ <system:implementation.system class="org.apache.tuscany.binding.axis2.builder.ExternalWebServiceConfigurationBuilder"/>
+ </component>
+
+ <component name="org.apache.tuscany.binding.axis2.builder.ExternalWebServiceWireBuilder">
+ <system:implementation.system class="org.apache.tuscany.binding.axis2.builder.ExternalWebServiceWireBuilder"/>
+ </component>
+
+ <component name="org.apache.tuscany.binding.axis2.loader.WebServiceSCDLModelLoader">
+ <system:implementation.system class="org.apache.tuscany.binding.axis2.loader.WebServiceSCDLModelLoader"/>
+ </component>
+
+ <component name="org.apache.tuscany.binding.axis2.builder.WebServiceEntryPointConfigurationBuilder">
+ <system:implementation.system class="org.apache.tuscany.binding.axis2.builder.WebServiceEntryPointConfigurationBuilder"/>
+ </component>
+
+</moduleFragment>
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/assembly/tests/WebServiceAssemblyLoaderTestCase.java b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/assembly/tests/WebServiceAssemblyLoaderTestCase.java
new file mode 100644
index 0000000000..b9abe418ca
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/assembly/tests/WebServiceAssemblyLoaderTestCase.java
@@ -0,0 +1,87 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.axis2.assembly.tests;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.binding.axis2.assembly.WebServiceBinding;
+import org.apache.tuscany.binding.axis2.loader.WebServiceSCDLModelLoader;
+import org.apache.tuscany.common.resource.ResourceLoader;
+import org.apache.tuscany.common.resource.impl.ResourceLoaderImpl;
+import org.apache.tuscany.model.assembly.AssemblyFactory;
+import org.apache.tuscany.model.assembly.AssemblyModelContext;
+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;
+import org.apache.tuscany.model.assembly.impl.AssemblyFactoryImpl;
+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 WebServiceAssemblyLoaderTestCase extends TestCase {
+
+ /**
+ *
+ */
+ public WebServiceAssemblyLoaderTestCase() {
+ super();
+ }
+
+ public void testLoader() {
+
+ ResourceLoader resourceLoader=new ResourceLoaderImpl(Thread.currentThread().getContextClassLoader());
+ WebServiceSCDLModelLoader wsLoader=new WebServiceSCDLModelLoader();
+ List<SCDLModelLoader> scdlLoaders=new ArrayList<SCDLModelLoader>();
+ scdlLoaders.add(wsLoader);
+ AssemblyModelLoader assemblyLoader=new SCDLAssemblyModelLoaderImpl(scdlLoaders);
+ AssemblyFactory assemblyFactory=new AssemblyFactoryImpl();
+ AssemblyModelContext modelContext=new AssemblyModelContextImpl(assemblyFactory, assemblyLoader, resourceLoader);
+
+ Module module = assemblyLoader.loadModule(getClass().getResource("sca.module").toString());
+ module.initialize(modelContext);
+
+ Assert.assertTrue(module.getName().equals("tuscany.binding.axis2.assembly.tests.bigbank.account"));
+
+ 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 WebServiceBinding);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/account/AccountReport.java b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/account/AccountReport.java
new file mode 100644
index 0000000000..a50594a243
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/account/AccountReport.java
@@ -0,0 +1,32 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.axis2.assembly.tests.bigbank.account.services.account;
+
+import java.util.List;
+
+/**
+ * @model
+ */
+
+public interface AccountReport {
+
+ /**
+ * @model type="services.account.AccountSummary"
+ */
+
+ List getAccountSummaries();
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/account/AccountService.java b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/account/AccountService.java
new file mode 100644
index 0000000000..241a11333f
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/account/AccountService.java
@@ -0,0 +1,25 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.axis2.assembly.tests.bigbank.account.services.account;
+
+import org.osoa.sca.annotations.Remotable;
+
+@Remotable
+public interface AccountService {
+
+ public AccountReport getAccountReport(String customerID);
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/account/AccountServiceImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/account/AccountServiceImpl.java
new file mode 100644
index 0000000000..8e66b18324
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/account/AccountServiceImpl.java
@@ -0,0 +1,42 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.axis2.assembly.tests.bigbank.account.services.account;
+
+import org.osoa.sca.annotations.Property;
+import org.osoa.sca.annotations.Reference;
+
+import org.apache.tuscany.binding.axis2.assembly.tests.bigbank.account.services.accountdata.AccountDataService;
+import org.apache.tuscany.binding.axis2.assembly.tests.bigbank.account.services.stockquote.StockQuoteService;
+
+public class AccountServiceImpl implements AccountService {
+
+ @Property
+ public String currency = "USD";
+
+ @Reference
+ public AccountDataService accountDataService;
+ @Reference
+ public StockQuoteService stockQuoteService;
+
+ public AccountServiceImpl() {
+ }
+
+ public AccountReport getAccountReport(String customerID) {
+ return null;
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/account/AccountSummary.java b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/account/AccountSummary.java
new file mode 100644
index 0000000000..3b30161cf5
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/account/AccountSummary.java
@@ -0,0 +1,46 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.axis2.assembly.tests.bigbank.account.services.account;
+
+/**
+ * @model
+ */
+
+public interface AccountSummary {
+
+ /**
+ * @model
+ */
+ String getAccountNumber();
+
+ void setAccountNumber(String accountNumber);
+
+ /**
+ * @model
+ */
+ String getAccountType();
+
+ void setAccountType(String accountType);
+
+ /**
+ * @model
+ */
+ float getBalance();
+
+ void setBalance(float balance);
+}
+
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/accountdata/AccountDataService.java b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/accountdata/AccountDataService.java
new file mode 100644
index 0000000000..fba6d582da
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/accountdata/AccountDataService.java
@@ -0,0 +1,26 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.axis2.assembly.tests.bigbank.account.services.accountdata;
+
+public interface AccountDataService {
+
+ CheckingAccount getCheckingAccount(String customerID);
+
+ SavingsAccount getSavingsAccount(String customerID);
+
+ StockAccount getStockAccount(String customerID);
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/accountdata/AccountDataServiceImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/accountdata/AccountDataServiceImpl.java
new file mode 100644
index 0000000000..c34ce84bc3
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/accountdata/AccountDataServiceImpl.java
@@ -0,0 +1,48 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.axis2.assembly.tests.bigbank.account.services.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/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/accountdata/CheckingAccount.java b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/accountdata/CheckingAccount.java
new file mode 100644
index 0000000000..d7b116da30
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/accountdata/CheckingAccount.java
@@ -0,0 +1,39 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.axis2.assembly.tests.bigbank.account.services.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/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/accountdata/SavingsAccount.java b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/accountdata/SavingsAccount.java
new file mode 100644
index 0000000000..cd7f74bb6e
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/accountdata/SavingsAccount.java
@@ -0,0 +1,39 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.axis2.assembly.tests.bigbank.account.services.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/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/accountdata/StockAccount.java b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/accountdata/StockAccount.java
new file mode 100644
index 0000000000..70756fd817
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/accountdata/StockAccount.java
@@ -0,0 +1,48 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.axis2.assembly.tests.bigbank.account.services.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/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/stockquote/StockQuoteService.java b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/stockquote/StockQuoteService.java
new file mode 100644
index 0000000000..d2db111fbe
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/stockquote/StockQuoteService.java
@@ -0,0 +1,24 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.axis2.assembly.tests.bigbank.account.services.stockquote;
+
+public interface StockQuoteService {
+
+ public float getQuote(String symbol);
+}
+
+ \ No newline at end of file
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/util/AxiomHelperTestCase.java b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/util/AxiomHelperTestCase.java
new file mode 100644
index 0000000000..3d9a5b8bf1
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/util/AxiomHelperTestCase.java
@@ -0,0 +1,88 @@
+package org.apache.tuscany.binding.axis2.util;
+
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+
+import junit.framework.TestCase;
+
+import org.apache.axis2.om.OMElement;
+import org.apache.tuscany.sdo.helper.TypeHelperImpl;
+import org.apache.tuscany.sdo.helper.XSDHelperImpl;
+import org.apache.tuscany.sdo.util.DataObjectUtil;
+import org.apache.tuscany.sdo.util.SDOUtil;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.util.BasicExtendedMetaData;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.helper.TypeHelper;
+
+public class AxiomHelperTestCase extends TestCase {
+
+ public static final QName GREETING_QN = new QName("http://helloworldaxis.samples.tuscany.apache.org", "getGreetings");
+
+ private TypeHelper typeHelper;
+
+ public void testToObjects1() {
+ String s = "petra";
+ OMElement omElement = AxiomHelper.toOMElement(typeHelper, new Object[] { s }, GREETING_QN);
+ assertNotNull(omElement);
+
+ Object[] os = AxiomHelper.toObjects(typeHelper, omElement);
+ assertNotNull(os);
+ assertEquals(os.length, 1);
+ assertEquals(os[0], s);
+ }
+
+ public void testToObjects2() {
+ String s = "sue";
+ DataObject dataObject = AxiomHelper.toDataObject(typeHelper, new Object[] { s }, GREETING_QN);
+ assertNotNull(dataObject);
+
+ Object[] os = AxiomHelper.toObjects(dataObject);
+ assertNotNull(os);
+ assertEquals(os.length, 1);
+ assertEquals(os[0], s);
+ }
+
+ public void testToOMElement1() {
+ String s = "beate";
+ OMElement omElement = AxiomHelper.toOMElement(typeHelper, new Object[] { s }, GREETING_QN);
+ assertNotNull(omElement);
+ }
+
+ public void testToOMElement2() {
+ String s = "emma";
+ DataObject dataObject = AxiomHelper.toDataObject(typeHelper, new Object[] { s }, GREETING_QN);
+ assertNotNull(dataObject);
+
+ OMElement omElement = AxiomHelper.toOMElement(typeHelper, dataObject, GREETING_QN);
+ assertNotNull(omElement);
+ }
+
+ public void testToDataObject() {
+ String s = "bersi";
+ DataObject dataObject = AxiomHelper.toDataObject(typeHelper, new Object[] { s }, GREETING_QN);
+ assertNotNull(dataObject);
+
+ Object[] os = AxiomHelper.toObjects(dataObject);
+ assertNotNull(os);
+ assertEquals(os.length, 1);
+ assertEquals(os[0], s);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ DataObjectUtil.initRuntime();
+ ClassLoader cl=Thread.currentThread().getContextClassLoader();
+ try {
+ Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
+ typeHelper=SDOUtil.createTypeHelper();
+ URL url = getClass().getResource("helloworld.wsdl");
+ new XSDHelperImpl(typeHelper).define(url.openStream(), null);
+ } finally {
+ Thread.currentThread().setContextClassLoader(cl);
+ }
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/resources/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/account/AccountService.wsdl b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/resources/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/account/AccountService.wsdl
new file mode 100644
index 0000000000..921218c5b9
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/resources/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/account/AccountService.wsdl
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
+
+ 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.
+ -->
+<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:tns="http://www.bigbank.com/AccountService/"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://www.bigbank.com/AccountService/"
+
+ name="AccountService">
+
+ <wsdl:types>
+ <xsd:schema targetNamespace="http://www.bigbank.com/AccountService/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <xsd:element name="customerID" type="xsd:string"/>
+ <xsd:element name="getAccountReportResponse" type="tns:AccountReport"/>
+
+ <xsd:complexType name="AccountReport">
+ <xsd:sequence>
+ <xsd:element name="accountSummary" type="tns:AccountSummary" maxOccurs="unbounded"/>
+ </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:customerID" 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="AccountServiceSOAP" type="tns:AccountService">
+ <soap:binding style="document"
+ transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="getAccountReport">
+ <soap:operation
+ soapAction="http://www.bigbank.com/AccountService/getAccountReport"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="AccountService">
+ <wsdl:port binding="tns:AccountServiceSOAP"
+ name="AccountServiceSOAP">
+ <soap:address location=""/>
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/resources/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/stockquote/StockQuoteWebService.wsdl b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/resources/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/stockquote/StockQuoteWebService.wsdl
new file mode 100644
index 0000000000..9678d9d6ea
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/resources/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/stockquote/StockQuoteWebService.wsdl
@@ -0,0 +1,98 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
+
+ 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.
+ -->
+<wsdl:definitions targetNamespace="http://webservice.stockquote" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://webservice.stockquote" xmlns:intf="http://webservice.stockquote" xmlns:tns1="http://stockquote" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="">
+ <!--WSDL created by Apache Axis version: 1.2.1
+Built on Jun 14, 2005 (09:15:57 EDT)-->
+ <wsdl:types>
+ <schema elementFormDefault="qualified" targetNamespace="http://stockquote" xmlns="http://www.w3.org/2001/XMLSchema">
+ <complexType name="GetQuoteRequest">
+ <sequence>
+ <element name="symbol" nillable="true" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ <complexType name="GetQuoteResponse">
+ <sequence>
+ <element name="price" type="xsd:float"/>
+ </sequence>
+ </complexType>
+ </schema>
+ <schema elementFormDefault="qualified" targetNamespace="http://webservice.stockquote" xmlns="http://www.w3.org/2001/XMLSchema">
+ <import namespace="http://stockquote"/>
+ <element name="request" type="tns1:GetQuoteRequest"/>
+ <element name="getQuoteReturn" type="tns1:GetQuoteResponse"/>
+ </schema>
+ </wsdl:types>
+
+ <wsdl:message name="getQuoteResponse">
+
+ <wsdl:part element="impl:getQuoteReturn" name="getQuoteReturn"/>
+
+ </wsdl:message>
+
+ <wsdl:message name="getQuoteRequest">
+
+ <wsdl:part element="impl:request" name="request"/>
+
+ </wsdl:message>
+
+ <wsdl:portType name="StockQuoteWebService">
+
+ <wsdl:operation name="getQuote" parameterOrder="request">
+
+ <wsdl:input message="impl:getQuoteRequest" name="getQuoteRequest"/>
+
+ <wsdl:output message="impl:getQuoteResponse" name="getQuoteResponse"/>
+
+ </wsdl:operation>
+
+ </wsdl:portType>
+
+ <wsdl:binding name="StockQuoteWebServiceSoapBinding" type="impl:StockQuoteWebService">
+
+ <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+
+ <wsdl:operation name="getQuote">
+
+ <wsdlsoap:operation soapAction=""/>
+
+ <wsdl:input name="getQuoteRequest">
+
+ <wsdlsoap:body use="literal"/>
+
+ </wsdl:input>
+
+ <wsdl:output name="getQuoteResponse">
+
+ <wsdlsoap:body use="literal"/>
+
+ </wsdl:output>
+
+ </wsdl:operation>
+
+ </wsdl:binding>
+
+ <wsdl:service name="StockQuoteWebServiceService">
+
+ <wsdl:port binding="impl:StockQuoteWebServiceSoapBinding" name="StockQuoteWebService">
+
+ <wsdlsoap:address location="http://localhost:8123/StockQuoteWebService/services/StockQuoteWebService"/>
+
+ </wsdl:port>
+
+ </wsdl:service>
+
+</wsdl:definitions>
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/resources/org/apache/tuscany/binding/axis2/assembly/tests/sca.module b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/resources/org/apache/tuscany/binding/axis2/assembly/tests/sca.module
new file mode 100644
index 0000000000..8e25576168
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/resources/org/apache/tuscany/binding/axis2/assembly/tests/sca.module
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.
+ -->
+<module xmlns="http://www.osoa.org/xmlns/sca/0.9" xmlns:v="http://www.osoa.org/xmlns/sca/values/0.9"
+
+ name="tuscany.binding.axis2.assembly.tests.bigbank.account">
+
+ <entryPoint name="AccountService">
+ <interface.java interface="org.apache.tuscany.binding.axis2.assembly.tests.bigbank.account.services.account.AccountService"/>
+ <binding.ws port="http://www.bigbank.com/AccountService/#AccountServiceSOAP"/>
+ <reference>AccountExternalService</reference>
+ </entryPoint>
+
+ <entryPoint name="AccountService2">
+ <interface.wsdl interface="http://www.bigbank.com/AccountService/#AccountService"/>
+ <binding.ws port="http://www.bigbank.com/AccountService/#AccountServiceSOAP"/>
+ <reference>AccountExternalService</reference>
+ </entryPoint>
+
+ <component name="AccountServiceComponent">
+ <implementation.java class="org.apache.tuscany.binding.axis2.assembly.tests.bigbank.account.services.account.AccountServiceImpl"/>
+ </component>
+
+ <component name="AccountDataServiceComponent">
+ <implementation.java class="org.apache.tuscany.binding.axis2.assembly.tests.bigbank.account.services.accountdata.AccountDataServiceImpl"/>
+ </component>
+
+ <!--
+ <component name="StockQuoteService">
+ <implementation.java class="org.apache.tuscany.binding.axis2.assembly.tests.bigbank.account.services.stockquote.StockQuoteServiceImpl"/>
+ </component>
+ -->
+
+ <externalService name="AccountExternalService">
+ <interface.wsdl interface="http://www.bigbank.com/AccountService/#AccountService"/>
+ <binding.ws port="http://www.bigbank.com/AccountService/#AccountServiceSOAP"/>
+ </externalService>
+
+ <externalService name="StockQuoteService">
+ <interface.java interface="org.apache.tuscany.binding.axis2.assembly.tests.bigbank.account.services.stockquote.StockQuoteService"/>
+ <binding.ws port="http://webservice.stockquote#StockQuoteWebService"/>
+ </externalService>
+
+ <import.wsdl
+ location="org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/account/AccountService.wsdl"
+ namespace="http://www.bigbank.com/AccountService/"/>
+
+ <import.wsdl
+ location="org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/stockquote/StockQuoteWebService.wsdl"
+ namespace="http://webservice.stockquote"/>
+
+</module>
+
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/resources/org/apache/tuscany/binding/axis2/mediator/tests/DocLit.wsdl b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/resources/org/apache/tuscany/binding/axis2/mediator/tests/DocLit.wsdl
new file mode 100644
index 0000000000..4aec526803
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/resources/org/apache/tuscany/binding/axis2/mediator/tests/DocLit.wsdl
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.
+ -->
+<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:tns="http://www.example.org/Test/DocLit"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="Test"
+ targetNamespace="http://www.example.org/Test/DocLit">
+ <wsdl:types>
+ <xsd:schema targetNamespace="http://www.example.org/Test/DocLit"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:tns="http://www.example.org/Test/DocLit">
+ <xsd:element name="source" type="xsd:string"/>
+ <xsd:element name="target" type="xsd:string"/>
+ <xsd:element name="context" type="xsd:string"/>
+ <xsd:element name="index" type="xsd:int"/>
+ <xsd:element name="exception" type="xsd:string"/>
+ </xsd:schema>
+ </wsdl:types>
+ <wsdl:message name="testRequest">
+ <wsdl:part element="tns:source" name="part1"/>
+ <wsdl:part element="tns:target" name="part2"/>
+ <wsdl:part element="tns:context" name="part3"/>
+ </wsdl:message>
+ <wsdl:message name="testResponse">
+ <wsdl:part element="tns:index" name="part1"/>
+ </wsdl:message>
+ <wsdl:message name="testFault">
+ <wsdl:part name="testFault" element="tns:exception"></wsdl:part>
+ </wsdl:message>
+ <wsdl:portType name="Test">
+ <wsdl:operation name="indexOf">
+ <wsdl:input name="input" message="tns:testRequest"/>
+ <wsdl:output name="output" message="tns:testResponse"/>
+ <wsdl:fault name="fault" message="tns:testFault"/>
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name="TestSOAP" type="tns:Test">
+ <soap:binding style="document"
+ transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="indexOf">
+ <soap:operation
+ soapAction="http://www.example.org/Test/indexOf"/>
+ <wsdl:input>
+ <soap:body parts="part1 part2" use="literal"/>
+ <soap:header message="tns:testRequest" part="part3" use="literal"></soap:header>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ <wsdl:fault name="fault">
+ <soap:fault namespace="http://www.example.org/Test/"
+ use="literal" name="fault"/>
+ </wsdl:fault>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="Test">
+ <wsdl:port binding="tns:TestSOAP" name="TestSOAP">
+ <soap:address
+ location="http://localhost:8080/TestWebServiceMediator/services/Test"/>
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/resources/org/apache/tuscany/binding/axis2/mediator/tests/DocLitWrapped.wsdl b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/resources/org/apache/tuscany/binding/axis2/mediator/tests/DocLitWrapped.wsdl
new file mode 100644
index 0000000000..7839d3ea71
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/resources/org/apache/tuscany/binding/axis2/mediator/tests/DocLitWrapped.wsdl
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.
+ -->
+<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:tns="http://www.example.org/Test/DocLitWrapped"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="Test"
+ targetNamespace="http://www.example.org/Test/DocLitWrapped">
+ <wsdl:types>
+ <xsd:schema targetNamespace="http://www.example.org/Test/DocLitWrapped"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://www.example.org/Test/DocLitWrapped">
+ <xsd:element name="indexOf">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="source" type="xsd:string"/>
+ <xsd:element name="target" type="xsd:string"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="indexOfResponse">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="index" type="xsd:int"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="exception" type="xsd:string"/>
+ </xsd:schema>
+ </wsdl:types>
+ <wsdl:message name="testRequest">
+ <wsdl:part element="tns:indexOf" name="part1"/>
+ </wsdl:message>
+ <wsdl:message name="testResponse">
+ <wsdl:part element="tns:indexOfResponse" name="part1"/>
+ </wsdl:message>
+ <wsdl:message name="testFault">
+ <wsdl:part name="testFault" element="tns:exception"></wsdl:part>
+ </wsdl:message>
+ <wsdl:portType name="Test">
+ <wsdl:operation name="indexOf">
+ <wsdl:input name="input" message="tns:testRequest"/>
+ <wsdl:output name="output" message="tns:testResponse"/>
+ <wsdl:fault name="fault" message="tns:testFault"/>
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name="TestSOAP" type="tns:Test">
+ <soap:binding style="document"
+ transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="indexOf">
+ <soap:operation
+ soapAction="http://www.example.org/Test/indexOf"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ <wsdl:fault name="fault">
+ <soap:fault namespace="http://www.example.org/Test/"
+ use="literal" name="fault"/>
+ </wsdl:fault>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="Test">
+ <wsdl:port binding="tns:TestSOAP" name="TestSOAP">
+ <soap:address
+ location="http://localhost:8080/TestWebServiceMediator/services/Test"/>
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/resources/org/apache/tuscany/binding/axis2/mediator/tests/RpcLit.wsdl b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/resources/org/apache/tuscany/binding/axis2/mediator/tests/RpcLit.wsdl
new file mode 100644
index 0000000000..8f94f9c66f
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/resources/org/apache/tuscany/binding/axis2/mediator/tests/RpcLit.wsdl
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.
+ -->
+<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:tns="http://www.example.org/Test/RpcLit"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="Test"
+ targetNamespace="http://www.example.org/Test/RpcLit">
+ <wsdl:types>
+ <xsd:schema targetNamespace="http://www.example.org/Test/RpcLit"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:tns="http://www.example.org/Test/RpcLit">
+ <!--
+ <xsd:element name="source" type="xsd:string"/>
+ <xsd:element name="target" type="xsd:string"/>
+ <xsd:element name="index" type="xsd:int" />
+ -->
+ <xsd:element name="exception" type="xsd:string"/>
+ </xsd:schema>
+ </wsdl:types>
+ <wsdl:message name="testRequest">
+ <wsdl:part type="xsd:string" name="part1"/>
+ <wsdl:part type="xsd:string" name="part2"/>
+ </wsdl:message>
+ <wsdl:message name="testResponse">
+ <wsdl:part type="xsd:int" name="part1"/>
+ </wsdl:message>
+ <wsdl:message name="testFault">
+ <wsdl:part name="testFault" element="tns:exception"></wsdl:part>
+ </wsdl:message>
+ <wsdl:portType name="Test">
+ <wsdl:operation name="indexOf">
+ <wsdl:input name="input" message="tns:testRequest"/>
+ <wsdl:output name="output" message="tns:testResponse"/>
+ <wsdl:fault name="fault" message="tns:testFault"/>
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name="TestSOAP" type="tns:Test">
+ <soap:binding style="rpc"
+ transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="indexOf">
+ <soap:operation
+ soapAction="http://www.example.org/Test/indexOf"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ <wsdl:fault name="fault">
+ <soap:fault namespace="http://www.example.org/Test/"
+ use="literal" name="fault"/>
+ </wsdl:fault>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="Test">
+ <wsdl:port binding="tns:TestSOAP" name="TestSOAP">
+ <soap:address
+ location="http://localhost:8080/TestWebServiceMediator/services/Test"/>
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/resources/org/apache/tuscany/binding/axis2/mediator/tests/sca.module b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/resources/org/apache/tuscany/binding/axis2/mediator/tests/sca.module
new file mode 100644
index 0000000000..7d8bb7861f
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/resources/org/apache/tuscany/binding/axis2/mediator/tests/sca.module
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.
+ -->
+<module xmlns="http://www.osoa.org/xmlns/sca/0.9" xmlns:v="http://www.osoa.org/xmlns/sca/values/0.9"
+ name="TestModule">
+
+</module>
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/resources/org/apache/tuscany/binding/axis2/util/helloworld.wsdl b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/resources/org/apache/tuscany/binding/axis2/util/helloworld.wsdl
new file mode 100644
index 0000000000..2c5f5041a8
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/binding.axis2/src/test/resources/org/apache/tuscany/binding/axis2/util/helloworld.wsdl
@@ -0,0 +1,106 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
+
+ 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.
+ -->
+<wsdl:definitions targetNamespace="http://helloworldaxis.samples.tuscany.apache.org" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://helloworldaxis.samples.tuscany.apache.org" xmlns:intf="http://helloworldaxis.samples.tuscany.apache.org" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="">
+ <!--WSDL created by Apache Axis version: 1.2.1
+Built on Jun 14, 2005 (09:15:57 EDT)-->
+ <wsdl:types>
+ <schema elementFormDefault="qualified" targetNamespace="http://helloworldaxis.samples.tuscany.apache.org" xmlns="http://www.w3.org/2001/XMLSchema">
+ <element name="getGreetings">
+ <complexType>
+ <sequence>
+ <element name="in0" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="getGreetingsResponse">
+ <complexType>
+ <sequence>
+ <element name="getGreetingsReturn" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ </element>
+ </schema>
+ </wsdl:types>
+
+ <wsdl:message name="getGreetingsRequest">
+
+ <wsdl:part element="impl:getGreetings" name="parameters"/>
+
+ </wsdl:message>
+
+ <wsdl:message name="getGreetingsResponse">
+
+ <wsdl:part element="impl:getGreetingsResponse" name="parameters"/>
+
+ </wsdl:message>
+
+ <wsdl:portType name="HelloWorldServiceImpl">
+
+ <wsdl:operation name="getGreetings">
+
+ <wsdl:input message="impl:getGreetingsRequest" name="getGreetingsRequest"/>
+
+ <wsdl:output message="impl:getGreetingsResponse" name="getGreetingsResponse"/>
+
+ </wsdl:operation>
+
+ </wsdl:portType>
+
+ <wsdl:binding name="helloworldSoapBinding" type="impl:HelloWorldServiceImpl">
+
+ <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+
+ <wsdl:operation name="getGreetings">
+
+ <wsdlsoap:operation soapAction=""/>
+
+ <wsdl:input name="getGreetingsRequest">
+
+ <wsdlsoap:body use="literal"/>
+
+ </wsdl:input>
+
+ <wsdl:output name="getGreetingsResponse">
+
+ <wsdlsoap:body use="literal"/>
+
+ </wsdl:output>
+
+ </wsdl:operation>
+
+ </wsdl:binding>
+
+ <wsdl:service name="HelloWorldServiceImplService">
+
+ <wsdl:port binding="impl:helloworldSoapBinding" name="helloworld">
+
+ <!-- Tuscany SCA Service -->
+<!--
+ <wsdlsoap:address location="http://localhost:8080/tuscany-samples-helloworldws-service/services/HelloWorldService"/>
+-->
+ <wsdlsoap:address location="http://localhost:9876/tuscany-samples-helloworldws-service/services/HelloWorldService"/>
+
+ <!-- Axis Web Service -->
+ <!--
+ <wsdlsoap:address location="http://localhost:8081/helloworldaxissvc-SNAPSHOT/services/helloworld"/>
+ -->
+
+ </wsdl:port>
+
+ </wsdl:service>
+
+</wsdl:definitions>
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/common/LICENSE.txt b/sca-java-1.x/tags/java-stable-20060304/sca/common/LICENSE.txt
new file mode 100644
index 0000000000..d645695673
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/common/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/sca-java-1.x/tags/java-stable-20060304/sca/common/pom.xml b/sca-java-1.x/tags/java-stable-20060304/sca/common/pom.xml
new file mode 100644
index 0000000000..b903d8f6a6
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/common/pom.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Copyright (c) 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.
+ -->
+<project>
+ <parent>
+ <groupId>org.apache.tuscany</groupId>
+ <artifactId>tuscany-sca</artifactId>
+ <version>SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>tuscany-common</artifactId>
+ <name>Tuscany Common</name>
+ <description>Tuscany classes common to runtime and tools.</description>
+ <version>SNAPSHOT</version>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/common/src/main/java/org/apache/tuscany/common/TuscanyException.java b/sca-java-1.x/tags/java-stable-20060304/sca/common/src/main/java/org/apache/tuscany/common/TuscanyException.java
new file mode 100644
index 0000000000..74110fef99
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/common/src/main/java/org/apache/tuscany/common/TuscanyException.java
@@ -0,0 +1,85 @@
+package org.apache.tuscany.common;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * The root checked exception for the Tuscany rubntime
+ *
+ * @version $Rev: 368822 $ $Date: 2006-01-13 10:54:38 -0800 (Fri, 13 Jan 2006) $
+ */
+public abstract class TuscanyException extends Exception {
+
+ protected List<String> contextStack;
+
+ public TuscanyException() {
+ super();
+ }
+
+ public TuscanyException(String message) {
+ super(message);
+ }
+
+ public TuscanyException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public TuscanyException(Throwable cause) {
+ super(cause);
+ }
+
+ /**
+ * Returns a collection of names representing the context call stack where the error occured. The top of the stack
+ * is the first element in the collection.
+ */
+ public List<String> returnContextNames(String name) {
+ if (contextStack == null) {
+ contextStack = new ArrayList();
+ }
+ return contextStack;
+ }
+
+ /**
+ * Pushes a context name where an error occured onto the call stack
+ */
+ public void addContextName(String name) {
+ if (contextStack == null) {
+ contextStack = new ArrayList();
+ }
+ contextStack.add(name);
+ }
+
+ private String identifier;
+
+ /**
+ * Returns a string representing additional error information referred to in the error message
+ */
+ public String getIdentifier() {
+ return identifier;
+ }
+
+ /**
+ * Sets an additional error information referred to in the error message
+ */
+ public void setIdentifier(String identifier) {
+ this.identifier = identifier;
+ }
+
+ public String getMessage() {
+ if (identifier == null && contextStack == null) {
+ return super.getMessage();
+ }
+ StringBuffer b = new StringBuffer();
+ if (identifier != null) {
+ b.append(" [" + identifier + "]");
+ }
+ if (contextStack != null) {
+ b.append("\nContext stack trace: ");
+ for (int i = contextStack.size() - 1; i >= 0; i--) {
+ b.append("[" + contextStack.get(i) + "]");
+ }
+ }
+ return super.getMessage() + b.toString();
+
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/common/src/main/java/org/apache/tuscany/common/TuscanyRuntimeException.java b/sca-java-1.x/tags/java-stable-20060304/sca/common/src/main/java/org/apache/tuscany/common/TuscanyRuntimeException.java
new file mode 100644
index 0000000000..922705f7b5
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/common/src/main/java/org/apache/tuscany/common/TuscanyRuntimeException.java
@@ -0,0 +1,91 @@
+package org.apache.tuscany.common;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * The root unchecked exception for the Tuscany runtime
+ *
+ * @version $Rev: 368822 $ $Date: 2006-01-13 10:54:38 -0800 (Fri, 13 Jan 2006) $
+ */
+
+public abstract class TuscanyRuntimeException extends RuntimeException {
+
+ protected List<String> contextStack;
+
+ protected String moduleComponentName;
+
+ protected String componentName;
+
+ public TuscanyRuntimeException() {
+ super();
+ }
+
+ public TuscanyRuntimeException(String message) {
+ super(message);
+ }
+
+ public TuscanyRuntimeException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public TuscanyRuntimeException(Throwable cause) {
+ super(cause);
+ }
+
+ /**
+ * Returns a collection of names representing the context call stack where the error occured. The top of the stack
+ * is the first element in the collection.
+ */
+ public List<String> returnContextNames(String name) {
+ if (contextStack == null) {
+ contextStack = new ArrayList();
+ }
+ return contextStack;
+ }
+
+ /**
+ * Pushes a context name where an error occured onto the call stack
+ */
+ public void addContextName(String name) {
+ if (contextStack == null) {
+ contextStack = new ArrayList();
+ }
+ contextStack.add(name);
+ }
+
+ private String identifier;
+
+ /**
+ * Returns a string representing additional error information referred to in the error message
+ */
+ public String getIdentifier() {
+ return identifier;
+ }
+
+ /**
+ * Sets an additional error information referred to in the error message
+ */
+ public void setIdentifier(String identifier) {
+ this.identifier = identifier;
+ }
+
+ public String getMessage() {
+ if (identifier == null && contextStack == null) {
+ return super.getMessage();
+ }
+ StringBuffer b = new StringBuffer();
+ if (identifier != null) {
+ b.append(" [" + identifier + "]");
+ }
+ if (contextStack != null) {
+ b.append("\nContext stack trace: ");
+ for (int i = contextStack.size() - 1; i >= 0; i--) {
+ b.append("[" + contextStack.get(i) + "]");
+ }
+ }
+ return super.getMessage() + b.toString();
+
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/common/src/main/java/org/apache/tuscany/common/discovery/util/ServiceProviderRegistry.java b/sca-java-1.x/tags/java-stable-20060304/sca/common/src/main/java/org/apache/tuscany/common/discovery/util/ServiceProviderRegistry.java
new file mode 100644
index 0000000000..65ede08a32
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/common/src/main/java/org/apache/tuscany/common/discovery/util/ServiceProviderRegistry.java
@@ -0,0 +1,177 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.common.discovery.util;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.WeakHashMap;
+
+import org.apache.tuscany.common.io.util.FixedURLInputStream;
+
+//FIXME Port to 1.5 collections
+
+/**
+ * A Registry for service providers defined using the
+ * <a href="http://java.sun.com/j2se/1.5.0/docs/guide/jar/jar.html#Service%20Provider">JAR service provider mechanism</a>.
+ *
+ */
+public class ServiceProviderRegistry {
+
+ private Map registry = Collections.synchronizedMap(new WeakHashMap());
+
+ private final static ServiceProviderRegistry instance = new ServiceProviderRegistry();
+
+ /**
+ * Constructor.
+ */
+ public ServiceProviderRegistry() {
+ super();
+ }
+
+ /**
+ * @return Returns the instance.
+ */
+ public static ServiceProviderRegistry getInstance() {
+ return instance;
+ }
+
+ /**
+ * Get the available providers of a given type.
+ *
+ * @param clazz
+ * @return
+ */
+ public List getServiceProviders(final Class clazz) {
+ List providers = (List) registry.get(clazz);
+ if (providers != null)
+ return providers;
+
+ providers = (List) AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return loadServiceProviders(clazz);
+ }
+ });
+
+ registry.put(clazz, providers);
+ return providers;
+ }
+
+ /**
+ * Get an provider of a given type.
+ *
+ * @param clazz
+ * @return
+ */
+ public Object getServiceProvider(Class clazz) {
+ List providers = getServiceProviders(clazz);
+ if (providers.isEmpty())
+ return null;
+ else {
+ return providers.get(0);
+ }
+ }
+
+ /**
+ * Registers an provider programatically
+ *
+ * @param clazz
+ * @param provider
+ */
+ public void registerServiceProvider(Class clazz, Object provider) {
+ getServiceProviders(clazz).add(provider);
+ }
+
+ /**
+ * Load providers of the given type
+ *
+ * @param clazz
+ * @return
+ */
+ private List loadServiceProviders(Class clazz) {
+ List classNames = new ArrayList();
+
+ // First look for a system property named <SPI className>
+ String className = System.getProperty(clazz.getName());
+ if (className != null)
+ classNames.add(className);
+
+ // Find all the class names mentioned in all the META-INF/services/<SPI className>
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ try {
+ Enumeration files = loader.getResources("META-INF/services/" + clazz.getName());
+ while (files.hasMoreElements()) {
+ URL url = (URL) files.nextElement();
+ readClassNames(url, classNames);
+ }
+ } catch (IOException e) {
+ }
+
+ // Instantiate an provider for each of the named classes
+ List providers = new ArrayList();
+ Iterator i = classNames.iterator();
+ while (i.hasNext()) {
+ String name = (String) i.next();
+ try {
+ Class providerClass = Class.forName(name, true, loader);
+ providers.add(providerClass.newInstance());
+ } catch (Exception e) {
+ // Ignore ClassNotFoundException
+ }
+ }
+ return providers;
+ }
+
+ /**
+ * Read class names from the given URL.
+ * @param url
+ * @param classNames
+ * @throws IOException
+ */
+ private void readClassNames(URL url, List classNames) throws IOException {
+ InputStream is = new FixedURLInputStream(url);
+ try {
+ BufferedReader in = new BufferedReader(new InputStreamReader(is, "UTF-8"));
+ String inputLine = null;
+ while ((inputLine = in.readLine()) != null) {
+ int i = inputLine.indexOf('#');
+ if (i >= 0) {
+ inputLine = inputLine.substring(0, i);
+ }
+ inputLine = inputLine.trim();
+ if (inputLine.length() > 0) {
+ if (!classNames.contains(inputLine)) {
+ classNames.add(inputLine);
+ }
+ }
+ }
+ } finally {
+ is.close();
+ }
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/common/src/main/java/org/apache/tuscany/common/io/util/ClassLoaderObjectInputStream.java b/sca-java-1.x/tags/java-stable-20060304/sca/common/src/main/java/org/apache/tuscany/common/io/util/ClassLoaderObjectInputStream.java
new file mode 100644
index 0000000000..607267a464
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/common/src/main/java/org/apache/tuscany/common/io/util/ClassLoaderObjectInputStream.java
@@ -0,0 +1,73 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.common.io.util;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectStreamClass;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
+/**
+ * <p/>
+ * An implementation of an ObjectInputStream that takes a ClassLoader or works
+ * with the current Thread context ClassLoader.
+ */
+public class ClassLoaderObjectInputStream extends ObjectInputStream {
+ protected ClassLoader classLoader;
+
+ /**
+ * Constructor
+ *
+ * @param in
+ * @param classLoader
+ * @throws IOException
+ */
+ public ClassLoaderObjectInputStream(InputStream in, ClassLoader classLoader) throws IOException {
+ super(in);
+ this.classLoader = classLoader;
+ }
+
+ /**
+ * @see java.io.ObjectInputStream#resolveClass(java.io.ObjectStreamClass)
+ */
+ protected Class resolveClass(final ObjectStreamClass desc) throws IOException, ClassNotFoundException {
+
+ final String name = desc.getName();
+ try {
+ return (Class) AccessController.doPrivileged(new PrivilegedExceptionAction() {
+ public Object run() throws ClassNotFoundException, IOException {
+ try {
+ return Class.forName(name, false, classLoader);
+ } catch (ClassNotFoundException e) {
+ return ClassLoaderObjectInputStream.super.resolveClass(desc);
+ }
+ }
+ });
+ } catch (PrivilegedActionException ex) {
+ Exception e = ex.getException();
+ if (e instanceof ClassNotFoundException) {
+ throw (ClassNotFoundException) e;
+ } else if (e instanceof IOException) {
+ throw (IOException) e;
+ }
+ return null;
+ }
+ }
+} \ No newline at end of file
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/common/src/main/java/org/apache/tuscany/common/io/util/FixedURLClassLoader.java b/sca-java-1.x/tags/java-stable-20060304/sca/common/src/main/java/org/apache/tuscany/common/io/util/FixedURLClassLoader.java
new file mode 100644
index 0000000000..f2f6f958f7
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/common/src/main/java/org/apache/tuscany/common/io/util/FixedURLClassLoader.java
@@ -0,0 +1,310 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.common.io.util;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.JarURLConnection;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.net.URLConnection;
+import java.net.URLStreamHandler;
+import java.net.URLStreamHandlerFactory;
+import java.security.Permission;
+import java.util.Map;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+
+/**
+ * <p/>
+ * This class is a workaround for URL stream issue as illustrated below.
+ * <p/>
+ * InputStream is=url.getInputStream();
+ * is.close(); // This line doesn't close the JAR file if the URL is a jar entry like "jar:file:/a.jar!/sca.module"
+ * <p/>
+ * We also need to turn off the JarFile cache.
+ */
+public class FixedURLClassLoader extends URLClassLoader {
+
+ /**
+ * @param urls
+ * @param parent
+ */
+ public FixedURLClassLoader(URL[] urls, ClassLoader parent) {
+ super(normalizeURLs(urls), parent, new FixedURLStreamHandlerFactory());
+ }
+
+ private static URL[] normalizeURLs(URL[] urls) {
+ URL[] newURLs = new URL[urls.length];
+ for (int i = 0; i < urls.length; i++)
+ try {
+ /**
+ * Any URL that ends with a '/' is assumed to refer to a directory. Otherwise, the URL is assumed to
+ * refer to a JAR file which will be downloaded and opened as needed.
+ */
+ String spec = urls[i].toString();
+ if (!(urls[i].getProtocol().equals("jar") || urls[i].getFile().endsWith("/"))) {
+ spec = "jar:" + spec + "!/";
+ }
+ newURLs[i] = new URL(null, spec, FixedURLStreamHandler.instance);
+ } catch (MalformedURLException e) {
+ }
+ return newURLs;
+ }
+
+ /**
+ * @see java.lang.Object#finalize()
+ */
+ protected void finalize() throws Throwable {
+ super.finalize();
+ }
+
+ public static class FixedURLStreamHandlerFactory implements URLStreamHandlerFactory {
+ public URLStreamHandler createURLStreamHandler(String protocol) {
+ return FixedURLStreamHandler.instance;
+ }
+ }
+
+ public static class FixedURLStreamHandler extends URLStreamHandler {
+ public static final URLStreamHandler instance = new FixedURLStreamHandler();
+
+ public FixedURLStreamHandler() {
+ super();
+ }
+
+ protected URLConnection openConnection(URL url) throws IOException {
+ URLConnection connection = new URL(url.toString()).openConnection();
+ connection.setUseCaches(false);
+ return new FixedURLConnection(connection, url);
+ }
+ }
+
+ public static class FixedURLConnection extends URLConnection {
+ private URLConnection connection;
+
+ public FixedURLConnection(URLConnection connection, URL url) {
+ super(url);
+ this.connection = connection;
+ }
+
+ public void addRequestProperty(String key, String value) {
+ connection.addRequestProperty(key, value);
+ }
+
+ public void connect() throws IOException {
+ connection.connect();
+ }
+
+ public boolean getAllowUserInteraction() {
+ return connection.getAllowUserInteraction();
+ }
+
+ public Object getContent() throws IOException {
+ return connection.getContent();
+ }
+
+ public Object getContent(Class[] classes) throws IOException {
+ return connection.getContent(classes);
+ }
+
+ public String getContentEncoding() {
+ return connection.getContentEncoding();
+ }
+
+ public int getContentLength() {
+ return connection.getContentLength();
+ }
+
+ public String getContentType() {
+ return connection.getContentType();
+ }
+
+ public long getDate() {
+ return connection.getDate();
+ }
+
+ public boolean getDefaultUseCaches() {
+ return connection.getDefaultUseCaches();
+ }
+
+ public boolean getDoInput() {
+ return connection.getDoInput();
+ }
+
+ public boolean getDoOutput() {
+ return connection.getDoOutput();
+ }
+
+ public long getExpiration() {
+ return connection.getExpiration();
+ }
+
+ public String getHeaderField(int n) {
+ return connection.getHeaderField(n);
+ }
+
+ public String getHeaderField(String name) {
+ return connection.getHeaderField(name);
+ }
+
+ public long getHeaderFieldDate(String name, long Default) {
+ return connection.getHeaderFieldDate(name, Default);
+ }
+
+ public int getHeaderFieldInt(String name, int Default) {
+ return connection.getHeaderFieldInt(name, Default);
+ }
+
+ public String getHeaderFieldKey(int n) {
+ return connection.getHeaderFieldKey(n);
+ }
+
+ public Map getHeaderFields() {
+ return connection.getHeaderFields();
+ }
+
+ public long getIfModifiedSince() {
+ return connection.getIfModifiedSince();
+ }
+
+ public InputStream getInputStream() throws IOException {
+ if (connection instanceof JarURLConnection && url.toString().startsWith("jar:file:")) {
+ return getByteArrayInputStream();
+ // return new FixedURLInputStream((JarURLConnection) connection);
+ } else {
+ return connection.getInputStream();
+ }
+ }
+
+ private InputStream getByteArrayInputStream() throws IOException {
+ JarFile jFile = null;
+ try {
+ String spec = url.toString();
+ spec = spec.substring("jar:".length());
+ int index = spec.lastIndexOf("!/");
+ String file = new URL(spec.substring(0, index)).getFile();
+ jFile = new JarFile(file);
+ String entryName = spec.substring(index + 2);
+ JarEntry jarEntry = jFile.getJarEntry(entryName);
+ if (jarEntry != null) {
+ InputStream jarStream = null;
+ try {
+ jarStream = jFile.getInputStream(jarEntry);
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ byte buf[] = new byte[4096];
+ int length = 0;
+ length = jarStream.read(buf);
+ while (length > 0) {
+ out.write(buf, 0, length);
+ length = jarStream.read(buf);
+ }
+ // out.flush();
+ jarStream.close();
+ // out.close();
+ return new ByteArrayInputStream(out.toByteArray());
+ } catch (IOException e) {
+ if (jarStream != null)
+ jarStream.close();
+ throw e;
+ }
+ } else {
+ throw new IOException("Entry " + entryName + " is not found in " + file);
+ }
+ } catch (IOException ex) {
+ throw ex;
+ } finally {
+ if (jFile != null) {
+ try {
+ jFile.close();
+ } catch (IOException e) {
+ // Ignore it
+ }
+ }
+ }
+ }
+
+ public long getLastModified() {
+ return connection.getLastModified();
+ }
+
+ public OutputStream getOutputStream() throws IOException {
+ return connection.getOutputStream();
+ }
+
+ public Permission getPermission() throws IOException {
+ return connection.getPermission();
+ }
+
+ public Map getRequestProperties() {
+ return connection.getRequestProperties();
+ }
+
+ public String getRequestProperty(String key) {
+ return connection.getRequestProperty(key);
+ }
+
+ public URL getURL() {
+ return url;
+ }
+
+ public boolean getUseCaches() {
+ return connection.getUseCaches();
+ }
+
+ public int hashCode() {
+ return connection.hashCode();
+ }
+
+ public void setAllowUserInteraction(boolean allowuserinteraction) {
+ connection.setAllowUserInteraction(allowuserinteraction);
+ }
+
+ public void setDefaultUseCaches(boolean defaultusecaches) {
+ connection.setDefaultUseCaches(defaultusecaches);
+ }
+
+ public void setDoInput(boolean doinput) {
+ connection.setDoInput(doinput);
+ }
+
+ public void setDoOutput(boolean dooutput) {
+ connection.setDoOutput(dooutput);
+ }
+
+ public void setIfModifiedSince(long ifmodifiedsince) {
+ connection.setIfModifiedSince(ifmodifiedsince);
+ }
+
+ public void setRequestProperty(String key, String value) {
+ connection.setRequestProperty(key, value);
+ }
+
+ public void setUseCaches(boolean usecaches) {
+ connection.setUseCaches(usecaches);
+ }
+
+ public String toString() {
+ return connection.toString();
+ }
+
+ }
+
+} \ No newline at end of file
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/common/src/main/java/org/apache/tuscany/common/io/util/FixedURLInputStream.java b/sca-java-1.x/tags/java-stable-20060304/sca/common/src/main/java/org/apache/tuscany/common/io/util/FixedURLInputStream.java
new file mode 100644
index 0000000000..192798ff26
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/common/src/main/java/org/apache/tuscany/common/io/util/FixedURLInputStream.java
@@ -0,0 +1,119 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.common.io.util;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.JarURLConnection;
+import java.net.URL;
+import java.util.jar.JarFile;
+
+/**
+ * <p/>
+ * This class is a workaround for URL stream issue as illustrated below.
+ * <p/>
+ * InputStream is=url.getInputStream();
+ * is.close(); // This line doesn't close the JAR file if the URL is a jar entry like "jar:file:/a.jar!/sca.module"
+ * <p/>
+ * We also need to turn off the JarFile cache.
+ */
+public class FixedURLInputStream extends InputStream {
+
+ private JarFile jarFile;
+ private InputStream is;
+
+ /**
+ * Constructor
+ *
+ * @param url
+ * @throws IOException
+ */
+ public FixedURLInputStream(URL url) throws IOException {
+ String protocol = url.getProtocol();
+ if (protocol != null && (protocol.equals("jar") || protocol.equals("wsjar"))) {
+ String urlStr = url.toString();
+ if (urlStr.startsWith("wsjar:")) {
+ url = new URL("jar:" + urlStr.substring(6));
+ }
+ JarURLConnection connection = (JarURLConnection) url.openConnection();
+ // We cannot use cache
+ connection.setUseCaches(false);
+ try {
+ is = connection.getInputStream();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ jarFile = connection.getJarFile();
+ } else {
+ is = url.openStream();
+ }
+ }
+
+ /**
+ * Constructor
+ *
+ * @param connection
+ * @throws IOException
+ */
+ public FixedURLInputStream(JarURLConnection connection) throws IOException {
+ // We cannot use cache
+ connection.setUseCaches(false);
+ is = connection.getInputStream();
+ jarFile = connection.getJarFile();
+ }
+
+ public int available() throws IOException {
+ return is.available();
+ }
+
+ public void close() throws IOException {
+ is.close();
+ // We need to close the JAR file
+ if (jarFile != null)
+ jarFile.close();
+ }
+
+ public synchronized void mark(int readlimit) {
+ is.mark(readlimit);
+ }
+
+ public boolean markSupported() {
+ return is.markSupported();
+ }
+
+ public int read() throws IOException {
+ return is.read();
+ }
+
+ public int read(byte[] b, int off, int len) throws IOException {
+ return is.read(b, off, len);
+ }
+
+ public int read(byte[] b) throws IOException {
+ return is.read(b);
+ }
+
+ public synchronized void reset() throws IOException {
+ is.reset();
+ }
+
+ public long skip(long n) throws IOException {
+ return is.skip(n);
+ }
+
+} \ No newline at end of file
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/common/src/main/java/org/apache/tuscany/common/io/util/IOHelper.java b/sca-java-1.x/tags/java-stable-20060304/sca/common/src/main/java/org/apache/tuscany/common/io/util/IOHelper.java
new file mode 100644
index 0000000000..8227a052df
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/common/src/main/java/org/apache/tuscany/common/io/util/IOHelper.java
@@ -0,0 +1,128 @@
+/*
+ *
+ * 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.common.io.util;
+
+import java.io.BufferedInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+/**
+ * I/O utility methods
+ *
+ * @version $Rev$ $Date$
+ */
+public class IOHelper {
+
+ // ----------------------------------
+ // Fields
+ // ----------------------------------
+
+ public static int BYTES = 8192;
+
+ // ----------------------------------
+ // Constructors
+ // ----------------------------------
+
+ private IOHelper() {
+ }
+
+ // ----------------------------------
+ // Methods
+ // ----------------------------------
+
+ public static void copy(InputStream in, OutputStream out) throws IOException {
+ copy(in, out, -1);
+ }
+
+ public static void copy(InputStream in, OutputStream out, long byteCount) throws IOException {
+ byte buffer[] = new byte[BYTES];
+ int len = BYTES;
+
+ if (byteCount >= 0) {
+ while (byteCount > 0) {
+ if (byteCount < BYTES) {
+ len = in.read(buffer, 0, (int) byteCount);
+ } else {
+ len = in.read(buffer, 0, BYTES);
+ }
+ if (len == -1) {
+ break;
+ }
+ byteCount -= len;
+ out.write(buffer, 0, len);
+ }
+ } else {
+ while (true) {
+ len = in.read(buffer, 0, BYTES);
+ if (len < 0) {
+ break;
+ }
+ out.write(buffer, 0, len);
+ }
+ }
+ }
+
+ public static byte[] read(InputStream in) throws IOException {
+ byte buffer[] = new byte[BYTES];
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ int len = BYTES;
+ while (true) {
+ len = in.read(buffer, 0, BYTES);
+ if (len < 0) {
+ break;
+ }
+ out.write(buffer, 0, len);
+ }
+ return out.toByteArray();
+ }
+
+ /**
+ * Removes a directory from the file sytsem
+ */
+ public static boolean deleteDir(File pDir) {
+ if (pDir.isDirectory()) {
+ String[] children = pDir.list();
+ for (int i = 0; i < children.length; i++) {
+ boolean success = deleteDir(new File(pDir, children[i]));
+ if (!success) {
+ return false;
+ }
+ }
+ }
+ return pDir.delete();
+ }
+
+ /**
+ * Returns a stream to the resource associated with pPath in the directory
+ * pRoot
+ */
+ public static InputStream getResource(File pRoot, String pPath) throws FileNotFoundException {
+
+ File[] files = pRoot.listFiles();
+ for (int i = 0; i < files.length; i++) {
+ if (files[i].isFile() && files[i].getName().equals(pPath)) {
+ return new BufferedInputStream(new FileInputStream(files[i]));
+ }
+ }
+ return null;
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/common/src/main/java/org/apache/tuscany/common/io/util/UTF8String.java b/sca-java-1.x/tags/java-stable-20060304/sca/common/src/main/java/org/apache/tuscany/common/io/util/UTF8String.java
new file mode 100644
index 0000000000..651c81f92a
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/common/src/main/java/org/apache/tuscany/common/io/util/UTF8String.java
@@ -0,0 +1,107 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.common.io.util;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.UnsupportedEncodingException;
+
+/**
+ * String encoded with UTF-8
+ *
+ */
+public class UTF8String {
+ public static final String UTF8 = "UTF-8";
+ private String string;
+
+ /**
+ *
+ */
+ public UTF8String(String str) {
+ super();
+ this.string = str;
+ }
+
+ public UTF8String(byte[] bytes) {
+ this(toString(bytes));
+ }
+
+ public static String toString(byte[] bytes) {
+ try {
+ if (bytes == null)
+ return null;
+ return new String(bytes, UTF8);
+ } catch (UnsupportedEncodingException e) {
+ throw new UnsupportedOperationException(e.getMessage());
+ }
+ }
+
+ public static byte[] getBytes(String str) {
+ try {
+ if (str == null)
+ return null;
+ return str.getBytes(UTF8);
+ } catch (UnsupportedEncodingException e) {
+ throw new UnsupportedOperationException(e.getMessage());
+ }
+ }
+
+ public ByteArrayInputStream getInputStream() {
+ return new ByteArrayInputStream(getBytes());
+ }
+
+ public static ByteArrayInputStream getInputStream(String str) {
+ return new ByteArrayInputStream(getBytes(str));
+ }
+
+ public static String toString(ByteArrayOutputStream bos) {
+ try {
+ return bos.toString(UTF8);
+ } catch (UnsupportedEncodingException e) {
+ throw new UnsupportedOperationException(e.getMessage());
+ }
+ }
+
+ public byte[] getBytes() {
+ try {
+ if (string == null)
+ return null;
+ return string.getBytes(UTF8);
+ } catch (UnsupportedEncodingException e) {
+ throw new UnsupportedOperationException(e.getMessage());
+ }
+ }
+
+ public String toString() {
+ return string;
+ }
+
+ public int hashCode() {
+ return (string == null) ? 0 : string.hashCode();
+ }
+
+ public boolean equals(Object object) {
+ if (!(object instanceof UTF8String))
+ return false;
+ UTF8String s = (UTF8String) object;
+ if (string == s.string)
+ return true;
+ if (string == null || s.string == null)
+ return false;
+ return string.equals(s.string);
+ }
+} \ No newline at end of file
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/common/src/main/java/org/apache/tuscany/common/monitor/LogLevel.java b/sca-java-1.x/tags/java-stable-20060304/sca/common/src/main/java/org/apache/tuscany/common/monitor/LogLevel.java
new file mode 100644
index 0000000000..f3362b13cb
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/common/src/main/java/org/apache/tuscany/common/monitor/LogLevel.java
@@ -0,0 +1,37 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.common.monitor;
+
+import static java.lang.annotation.ElementType.METHOD;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+
+/**
+ * Annotation that can be applied to methods in a monitoring interface
+ * to indicate to logging frameworks the severity of the event.
+ *
+ * @version $Rev$ $Date$
+ */
+@Target({METHOD})
+@Retention(RUNTIME)
+public @interface LogLevel {
+ /**
+ * The log level as specified by {@link java.util.logging.Level}.
+ */
+ String value();
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/common/src/main/java/org/apache/tuscany/common/monitor/MonitorFactory.java b/sca-java-1.x/tags/java-stable-20060304/sca/common/src/main/java/org/apache/tuscany/common/monitor/MonitorFactory.java
new file mode 100644
index 0000000000..aa92092005
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/common/src/main/java/org/apache/tuscany/common/monitor/MonitorFactory.java
@@ -0,0 +1,35 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.common.monitor;
+
+/**
+ * A MonitorFactory creates implementations of components' monitor interfaces
+ * that interface with a its monitoring scheme. For example, a implementation
+ * may create versions that emit appropriate logging events or which send
+ * notifications to a management API.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface MonitorFactory {
+ /**
+ * Return a monitor for a component's monitor interface.
+ *
+ * @param monitorInterface the component's monitoring interface
+ * @return an implementation of the monitoring interface; will not be null
+ */
+ <T> T getMonitor(Class<T> monitorInterface);
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/common/src/main/java/org/apache/tuscany/common/monitor/impl/InvalidLevelException.java b/sca-java-1.x/tags/java-stable-20060304/sca/common/src/main/java/org/apache/tuscany/common/monitor/impl/InvalidLevelException.java
new file mode 100644
index 0000000000..cfb924d8fb
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/common/src/main/java/org/apache/tuscany/common/monitor/impl/InvalidLevelException.java
@@ -0,0 +1,43 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.common.monitor.impl;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class InvalidLevelException extends IllegalArgumentException {
+ private final String method;
+ private final String level;
+
+ public InvalidLevelException(String method, String level) {
+ super();
+ this.method = method;
+ this.level = level;
+ }
+
+ public String getMethod() {
+ return method;
+ }
+
+ public String getLevel() {
+ return level;
+ }
+
+ public String getMessage() {
+ return "Invalid level for method " + method + " : " + level;
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/common/src/main/java/org/apache/tuscany/common/monitor/impl/JavaLoggingMonitorFactory.java b/sca-java-1.x/tags/java-stable-20060304/sca/common/src/main/java/org/apache/tuscany/common/monitor/impl/JavaLoggingMonitorFactory.java
new file mode 100644
index 0000000000..06bb87d6dd
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/common/src/main/java/org/apache/tuscany/common/monitor/impl/JavaLoggingMonitorFactory.java
@@ -0,0 +1,139 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.common.monitor.impl;
+
+import java.lang.ref.WeakReference;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.util.WeakHashMap;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Properties;
+import java.util.Iterator;
+import java.util.logging.Logger;
+import java.util.logging.Level;
+
+import org.apache.tuscany.common.monitor.MonitorFactory;
+import org.apache.tuscany.common.monitor.LogLevel;
+
+/**
+ * A factory for monitors that forwards events to a {@link java.util.logging.Logger Java Logging (JSR47) Logger}.
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaLoggingMonitorFactory implements MonitorFactory {
+ private final String bundleName;
+ private final Level defaultLevel;
+ private final Map<String, Level> levels;
+
+ private final Map<Class<?>, WeakReference<?>> proxies = new WeakHashMap();
+
+ /**
+ *
+ * @param levels
+ * @param defaultLevel
+ * @param bundleName
+ */
+ public JavaLoggingMonitorFactory(Properties levels, Level defaultLevel, String bundleName) {
+ this.defaultLevel = defaultLevel;
+ this.bundleName = bundleName;
+ this.levels = new HashMap(levels.size());
+ for (Iterator<Map.Entry<Object, Object>> i = levels.entrySet().iterator(); i.hasNext();) {
+ Map.Entry<Object, Object> entry = i.next();
+ String method = (String) entry.getKey();
+ String level = (String) entry.getValue();
+ try {
+ this.levels.put(method, Level.parse(level));
+ } catch (IllegalArgumentException e) {
+ throw new InvalidLevelException(method, level);
+ }
+ }
+ }
+
+ public synchronized <T> T getMonitor(Class<T> monitorInterface) {
+ T proxy = getCachedMonitor(monitorInterface);
+ if (proxy == null) {
+ proxy = createMonitor(monitorInterface);
+ proxies.put(monitorInterface, new WeakReference(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();
+ Logger logger = Logger.getLogger(className, bundleName);
+ Method[] methods = monitorInterface.getMethods();
+ Map<String, Level> levels = new HashMap(methods.length);
+ for (int i = 0; i < methods.length; i++) {
+ Method method = methods[i];
+ String key = className + '#' + method.getName();
+ Level level = this.levels.get(key);
+
+ // if not specified the in config properties, look for an annotation on the method
+ if (level == null) {
+ LogLevel annotation = method.getAnnotation(LogLevel.class);
+ if (annotation != null && annotation.value() != null) {
+ try {
+ level = Level.parse(annotation.value());
+ } catch (IllegalArgumentException e) {
+ // bad value, just use the default
+ level = defaultLevel;
+ }
+ }
+ }
+ if (level != null) {
+ levels.put(method.getName(), level);
+ }
+ }
+ InvocationHandler handler = new LoggingHandler(logger, levels);
+ return (T) Proxy.newProxyInstance(monitorInterface.getClassLoader(), new Class<?>[]{monitorInterface}, handler);
+ }
+
+ private static final class LoggingHandler implements InvocationHandler {
+ private final Logger logger;
+ private final Map<String, Level> methodLevels;
+
+ public LoggingHandler(Logger logger, Map<String, Level> methodLevels) {
+ this.logger = logger;
+ this.methodLevels = methodLevels;
+ }
+
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+ String sourceMethod = method.getName();
+ Level level = methodLevels.get(sourceMethod);
+ if (level != null && logger.isLoggable(level)) {
+ // construct the key for the resource bundle
+ String className = logger.getName();
+ String key = className + '#' + sourceMethod;
+
+ // if the only argument is a Throwable use the special logger for it
+ if (args != null && args.length == 1 && args[0] instanceof Throwable) {
+ logger.logp(level, className, sourceMethod, key, (Throwable) args[0]);
+ } else {
+ logger.logp(level, className, sourceMethod, key, args);
+ }
+ }
+ return null;
+ }
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/common/src/main/java/org/apache/tuscany/common/monitor/impl/NullMonitorFactory.java b/sca-java-1.x/tags/java-stable-20060304/sca/common/src/main/java/org/apache/tuscany/common/monitor/impl/NullMonitorFactory.java
new file mode 100644
index 0000000000..a2bbbd3965
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/common/src/main/java/org/apache/tuscany/common/monitor/impl/NullMonitorFactory.java
@@ -0,0 +1,48 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.common.monitor.impl;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+
+import org.apache.tuscany.common.monitor.MonitorFactory;
+
+/**
+ * Implementation of a {@link MonitorFactory} that produces implementations that simply return.
+ *
+ * @version $Rev$ $Date$
+ */
+public class NullMonitorFactory implements MonitorFactory {
+ public <T> T getMonitor(Class<T> monitorInterface) {
+ /*
+ * This uses a reflection proxy to implement the monitor interface which
+ * is a simple but perhaps not very performant solution. Performance
+ * might be improved by code generating an implementation with empty methods.
+ */
+ return monitorInterface.cast(Proxy.newProxyInstance(monitorInterface.getClassLoader(), new Class<?>[]{monitorInterface}, NULL_MONITOR));
+ }
+
+ /**
+ * Singleton invocation hander that does nothing.
+ */
+ private static final InvocationHandler NULL_MONITOR = new InvocationHandler() {
+ public Object invoke(Object proxy, Method method, Object[] args) {
+ return null;
+ }
+ };
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/common/src/main/java/org/apache/tuscany/common/resource/ResourceLoader.java b/sca-java-1.x/tags/java-stable-20060304/sca/common/src/main/java/org/apache/tuscany/common/resource/ResourceLoader.java
new file mode 100644
index 0000000000..9771c1e966
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/common/src/main/java/org/apache/tuscany/common/resource/ResourceLoader.java
@@ -0,0 +1,94 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.common.resource;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * Interface which abstracts the implementation of something that is able to
+ * load resources (such as a ClassLoader). All Tuscany code should use this
+ * API rather than a ClassLoader directly in order to reduce the risk of
+ * memory leaks due to ClassLoader references.
+ *
+ * @version $Rev: 379878 $ $Date: 2006-02-22 12:45:50 -0800 (Wed, 22 Feb 2006) $
+ */
+public interface ResourceLoader {
+
+ /**
+ * Returns the parent resource loaders.
+ *
+ * @return resource loaders that are parents to this one
+ */
+ List<ResourceLoader> getParents();
+
+ /**
+ * Loads the class with the specified binary name.
+ *
+ * @param name the binary name of the class
+ * @return the resulting Class object
+ * @throws ClassNotFoundException if the class was not found
+ * @see ClassLoader#loadClass(String)
+ */
+ Class<?> loadClass(String name) throws ClassNotFoundException;
+
+ /**
+ * Converts an array of bytes into a Class.
+ * @param bytes
+ * @return
+ */
+ Class<?> addClass(byte[] bytes);
+
+ /**
+ * Finds the first resource with the given name.
+ * <p/>
+ * Each parent is searched first (in the order returned by {@link #getParents()})
+ * and the first resource located is found. If no parent returns a resource then
+ * the first resource defined by this ResourceLoader is returned.
+ *
+ * @param name the resource name
+ * @return a {@link URL} that can be used to read the resource, or null if no resource could be found
+ * @throws IOException if there was a problem locating the resource
+ */
+ URL getResource(String name) throws IOException;
+
+ /**
+ * Find resources with the given name that are available directly from this
+ * ResourceLoader. Resources from parent ResourceLoaders are not returned.
+ *
+ * @param name the resource name
+ * @return an Iterator of {@link URL} objects for the resource
+ * @throws IOException if there was a problem locating the resources
+ */
+ Iterator<URL> getResources(String name) throws IOException;
+
+ /**
+ * Find resources with the given name that are available from this
+ * ResourceLoader or any of its parents.
+ *
+ * @param name the resource name
+ * @return an Iterator of {@link URL} objects for the resource
+ * @throws IOException if there was a problem locating the resources
+ */
+ Iterator<URL> getAllResources(String name) throws IOException;
+
+ //FIXME this is temporary to work around classloader problems with SDO when running in Tomcat
+ ClassLoader getClassLoader();
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/common/src/main/java/org/apache/tuscany/common/resource/impl/ResourceLoaderImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/common/src/main/java/org/apache/tuscany/common/resource/impl/ResourceLoaderImpl.java
new file mode 100644
index 0000000000..5f83596f19
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/common/src/main/java/org/apache/tuscany/common/resource/impl/ResourceLoaderImpl.java
@@ -0,0 +1,175 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.common.resource.impl;
+
+import java.io.IOException;
+import java.lang.ref.WeakReference;
+import java.net.URL;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.tuscany.common.resource.ResourceLoader;
+
+/**
+ * Default implementation of the ResourceLoader interface.
+ *
+ * @version $Rev: 369102 $ $Date: 2006-01-14 13:48:56 -0800 (Sat, 14 Jan 2006) $
+ */
+public class ResourceLoaderImpl implements ResourceLoader {
+ private final WeakReference<ClassLoader> classLoaderReference;
+ private WeakReference<GeneratedClassLoader> generatedClassLoaderReference;
+ private final List<ResourceLoader> parents;
+
+ /**
+ * A class loader that allows new classes to be defined from an array of bytes
+ */
+ private class GeneratedClassLoader extends ClassLoader {
+
+ /**
+ * Constructs a new ResourceLoaderImpl.GeneratedClassLoader.
+ */
+ public GeneratedClassLoader(ClassLoader classLoader) {
+ super(classLoader);
+ }
+
+ /**
+ * Converts an array of bytes into a Class.
+ * @param bytes
+ * @return
+ */
+ private Class<?> addClass(byte[] bytes) {
+ return defineClass(null, bytes, 0, bytes.length);
+ }
+
+ }
+
+ /**
+ * Constructs a new ResourceLoaderImpl.
+ * @param classLoader
+ */
+ public ResourceLoaderImpl(ClassLoader classLoader) {
+ classLoaderReference = new WeakReference(classLoader);
+ generatedClassLoaderReference = new WeakReference(new GeneratedClassLoader(classLoader));
+ ClassLoader parentCL = classLoader.getParent();
+ parents = parentCL == null ? Collections.EMPTY_LIST : Collections.singletonList(new ResourceLoaderImpl(parentCL));
+ }
+
+
+ /**
+ * Return the classloader backing this resource loader.
+ *
+ * @return the classloader that backs this resource loader
+ * @throws IllegalStateException if the classloader has been garbage collected
+ */
+ //FIXME Temporary used to set the classloader on the thread context, need to changed to private
+ public ClassLoader getClassLoader() throws IllegalStateException {
+ ClassLoader cl = classLoaderReference.get();
+ if (cl == null) {
+ throw new IllegalStateException("Referenced ClassLoader has been garbage collected");
+ }
+ return cl;
+ }
+
+ public List<ResourceLoader> getParents() {
+ return parents;
+ }
+
+ public Class loadClass(String name) throws ClassNotFoundException {
+ GeneratedClassLoader cl = generatedClassLoaderReference.get();
+ if (cl != null) {
+ return Class.forName(name, true, cl);
+ } else {
+ return Class.forName(name, true, getClassLoader());
+ }
+ }
+
+ public Class<?> addClass(byte[] bytes) {
+ GeneratedClassLoader cl = generatedClassLoaderReference.get();
+ if (cl == null) {
+ cl=new GeneratedClassLoader(getClassLoader());
+ generatedClassLoaderReference = new WeakReference(cl);
+ }
+ return cl.addClass(bytes);
+ }
+
+ public Iterator<URL> getResources(String name) throws IOException {
+ // This implementation used to cache but users are not likely
+ // to ask for the same resource multiple times.
+
+ // Create a new set, add all the resources visible from the current ClassLoader
+ Set<URL> set = new HashSet();
+ ClassLoader classLoader = getClassLoader();
+ for (Enumeration<URL> e = classLoader.getResources(name); e.hasMoreElements();) {
+ set.add(e.nextElement());
+ }
+
+ // Remove the resources visible from the parent ClassLoaders
+ for (ResourceLoader parent : getParents()) {
+ for (Iterator<URL> i = parent.getAllResources(name); i.hasNext();) {
+ set.remove(i.next());
+ }
+ }
+ return set.iterator();
+ }
+
+ public Iterator<URL> getAllResources(String name) throws IOException {
+ return new EnumerationIterator(getClassLoader().getResources(name));
+ }
+
+ public URL getResource(String name) throws IOException {
+ return getClassLoader().getResource(name);
+ }
+
+ public boolean equals(Object obj) {
+ if (obj == this) {
+ return true;
+ }
+ if (!(obj instanceof ResourceLoaderImpl)) {
+ return false;
+ }
+ final ResourceLoaderImpl other = (ResourceLoaderImpl) obj;
+ return getClassLoader() == other.getClassLoader();
+ }
+
+ public int hashCode() {
+ return getClassLoader().hashCode();
+ }
+
+ private static class EnumerationIterator<E> implements Iterator<E> {
+ private final Enumeration<E> e;
+
+ public EnumerationIterator(Enumeration<E> e) {
+ this.e = e;
+ }
+
+ public boolean hasNext() {
+ return e.hasMoreElements();
+ }
+
+ public E next() {
+ return e.nextElement();
+ }
+
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/common/src/main/resources/META-INF/services/org.apache.tuscany.common.logging.LogProvider b/sca-java-1.x/tags/java-stable-20060304/sca/common/src/main/resources/META-INF/services/org.apache.tuscany.common.logging.LogProvider
new file mode 100644
index 0000000000..6cf181502c
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/common/src/main/resources/META-INF/services/org.apache.tuscany.common.logging.LogProvider
@@ -0,0 +1 @@
+org.apache.tuscany.common.logging.impl.JSR47LogProviderImpl \ No newline at end of file
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/common/src/main/resources/META-INF/services/org.apache.tuscany.common.resource.loader.ResourceLoaderProvider b/sca-java-1.x/tags/java-stable-20060304/sca/common/src/main/resources/META-INF/services/org.apache.tuscany.common.resource.loader.ResourceLoaderProvider
new file mode 100644
index 0000000000..70456ec1d0
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/common/src/main/resources/META-INF/services/org.apache.tuscany.common.resource.loader.ResourceLoaderProvider
@@ -0,0 +1 @@
+org.apache.tuscany.common.resource.loader.impl.ResourceLoaderProviderImpl \ No newline at end of file
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/common/src/main/resources/org/apache/tuscany/common/Messages.properties b/sca-java-1.x/tags/java-stable-20060304/sca/common/src/main/resources/org/apache/tuscany/common/Messages.properties
new file mode 100644
index 0000000000..4581e44bff
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/common/src/main/resources/org/apache/tuscany/common/Messages.properties
@@ -0,0 +1,25 @@
+# Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
+#
+# 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.
+# ====================================================================
+# To code developer:
+# Do NOT change the properties between this line and the
+# "%%% END OF TRANSLATED PROPERTIES %%%" line.
+# Make a new property name, append to the end of the file and change
+# the code to use the new property.
+# ====================================================================
+
+# =====================================================================
+# %%% END OF TRANSLATED PROPERTIES %%%
+# =====================================================================
+# NLS_MESSAGEFORMAT_ALL
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/common/src/test/java/org/apache/tuscany/common/monitor/impl/JavaLoggingTestCase.java b/sca-java-1.x/tags/java-stable-20060304/sca/common/src/test/java/org/apache/tuscany/common/monitor/impl/JavaLoggingTestCase.java
new file mode 100644
index 0000000000..011ccf63ab
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/common/src/test/java/org/apache/tuscany/common/monitor/impl/JavaLoggingTestCase.java
@@ -0,0 +1,145 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.common.monitor.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+import java.util.logging.Handler;
+import java.util.logging.Level;
+import java.util.logging.LogRecord;
+import java.util.logging.Logger;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.common.monitor.MonitorFactory;
+import org.apache.tuscany.common.monitor.LogLevel;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JavaLoggingTestCase extends TestCase {
+ private static final Logger logger = Logger.getLogger(Monitor.class.getName());
+ private static final MockHandler handler = new MockHandler();
+
+ private MonitorFactory factory;
+
+ /**
+ * Smoke test to ensure the logger is working
+ */
+ public void testLogger() {
+ logger.info("test");
+ assertEquals(1, handler.logs.size());
+ }
+
+ public void testUnloggedEvent() {
+ Monitor mon = factory.getMonitor(Monitor.class);
+ mon.eventNotToLog();
+ assertEquals(0, handler.logs.size());
+ }
+
+ public void testEventWithNoArgs() {
+ Monitor mon = factory.getMonitor(Monitor.class);
+ mon.eventWithNoArgs();
+ assertEquals(1, handler.logs.size());
+ LogRecord record = handler.logs.get(0);
+ assertEquals(Level.INFO, record.getLevel());
+ assertEquals(logger.getName(), record.getLoggerName());
+ assertEquals(Monitor.class.getName() + "#eventWithNoArgs", record.getMessage());
+ }
+
+ public void testEventWithAnnotation() {
+ Monitor mon = factory.getMonitor(Monitor.class);
+ mon.eventWithAnnotation();
+ assertEquals(1, handler.logs.size());
+ LogRecord record = handler.logs.get(0);
+ assertEquals(Level.INFO, record.getLevel());
+ assertEquals(logger.getName(), record.getLoggerName());
+ assertEquals(Monitor.class.getName() + "#eventWithAnnotation", record.getMessage());
+ }
+
+ public void testEventWithThrowable() {
+ Exception e = new Exception();
+ Monitor mon = factory.getMonitor(Monitor.class);
+ mon.eventWithThrowable(e);
+ assertEquals(1, handler.logs.size());
+ LogRecord record = handler.logs.get(0);
+ assertEquals(Level.WARNING, record.getLevel());
+ assertEquals(logger.getName(), record.getLoggerName());
+ assertEquals(Monitor.class.getName() + "#eventWithThrowable", record.getMessage());
+ assertSame(e, record.getThrown());
+ }
+
+ public void testEventWithOneArg() {
+ Monitor mon = factory.getMonitor(Monitor.class);
+ mon.eventWithOneArg("ARG");
+ assertEquals(1, handler.logs.size());
+ LogRecord record = handler.logs.get(0);
+ assertEquals(Monitor.class.getName() + "#eventWithOneArg", record.getMessage());
+ assertEquals(Monitor.class.getName(), record.getResourceBundleName());
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ logger.setUseParentHandlers(false);
+ logger.addHandler(handler);
+ handler.flush();
+
+ String sourceClass = Monitor.class.getName();
+ Properties levels = new Properties();
+ levels.setProperty(sourceClass + "#eventWithNoArgs", "INFO");
+ levels.setProperty(sourceClass + "#eventWithOneArg", "INFO");
+ levels.setProperty(sourceClass + "#eventWithThrowable", "WARNING");
+ factory = new JavaLoggingMonitorFactory(levels, Level.FINE, sourceClass);
+ }
+
+ protected void tearDown() throws Exception {
+ logger.removeHandler(handler);
+ handler.flush();
+ super.tearDown();
+ }
+
+ public static class MockHandler extends Handler {
+ List<LogRecord> logs = new ArrayList();
+
+ public void publish(LogRecord record) {
+ logs.add(record);
+ }
+
+ public void flush() {
+ logs.clear();
+ }
+
+ public void close() throws SecurityException {
+ }
+ }
+
+ public static interface Monitor {
+ void eventNotToLog();
+
+ void eventWithNoArgs();
+
+ void eventWithOneArg(String msg);
+
+ void eventWithTwoArgs(String m1, String m2);
+
+ void eventWithThrowable(Exception e);
+
+ @LogLevel("INFO")
+ void eventWithAnnotation();
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/common/src/test/resources/org/apache/tuscany/common/monitor/impl/JavaLoggingTestCase$Monitor.properties b/sca-java-1.x/tags/java-stable-20060304/sca/common/src/test/resources/org/apache/tuscany/common/monitor/impl/JavaLoggingTestCase$Monitor.properties
new file mode 100644
index 0000000000..e16fa437fa
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/common/src/test/resources/org/apache/tuscany/common/monitor/impl/JavaLoggingTestCase$Monitor.properties
@@ -0,0 +1 @@
+org.apache.tuscany.common.monitor.impl.JavaLoggingTestCase$Monitor#eventWithOneArg=Log message with arg={0} \ No newline at end of file
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/LICENSE.txt b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/LICENSE.txt
new file mode 100644
index 0000000000..d645695673
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/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/sca-java-1.x/tags/java-stable-20060304/sca/container.java/pom.xml b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/pom.xml
new file mode 100644
index 0000000000..a6558658b3
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/pom.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Copyright (c) 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.
+ -->
+<project>
+ <parent>
+ <groupId>org.apache.tuscany</groupId>
+ <artifactId>tuscany-sca</artifactId>
+ <version>SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>tuscany-container-java</artifactId>
+ <name>Tuscany Java IoC Container</name>
+ <description>Container for managing components as defined by the SCA implementation specification.</description>
+ <version>SNAPSHOT</version>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany</groupId>
+ <artifactId>tuscany-core</artifactId>
+ <version>${pom.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/main/java/org/apache/tuscany/container/java/assembly/JavaAssemblyFactory.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/main/java/org/apache/tuscany/container/java/assembly/JavaAssemblyFactory.java
new file mode 100644
index 0000000000..3ed37e70ff
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/main/java/org/apache/tuscany/container/java/assembly/JavaAssemblyFactory.java
@@ -0,0 +1,32 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.assembly;
+
+import org.apache.tuscany.model.assembly.AssemblyFactory;
+
+
+/**
+ * The Factory for the model.
+ */
+public interface JavaAssemblyFactory extends AssemblyFactory {
+
+ /**
+ * Returns a new JavaImplementation.
+ */
+ JavaImplementation createJavaImplementation();
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/main/java/org/apache/tuscany/container/java/assembly/JavaImplementation.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/main/java/org/apache/tuscany/container/java/assembly/JavaImplementation.java
new file mode 100644
index 0000000000..e8cf6b4014
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/main/java/org/apache/tuscany/container/java/assembly/JavaImplementation.java
@@ -0,0 +1,37 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.assembly;
+
+import org.apache.tuscany.model.assembly.ComponentImplementation;
+
+
+/**
+ * Represents a java implementation.
+ */
+public interface JavaImplementation extends ComponentImplementation {
+
+ /**
+ * Returns the implementation class.
+ */
+ Class getImplementationClass();
+
+ /**
+ * Sets the implementation class.
+ */
+ void setImplementationClass(Class value);
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/main/java/org/apache/tuscany/container/java/assembly/impl/JavaAssemblyFactoryImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/main/java/org/apache/tuscany/container/java/assembly/impl/JavaAssemblyFactoryImpl.java
new file mode 100644
index 0000000000..c8f29a2140
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/main/java/org/apache/tuscany/container/java/assembly/impl/JavaAssemblyFactoryImpl.java
@@ -0,0 +1,42 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.assembly.impl;
+
+import org.apache.tuscany.container.java.assembly.JavaAssemblyFactory;
+import org.apache.tuscany.container.java.assembly.JavaImplementation;
+import org.apache.tuscany.model.assembly.impl.AssemblyFactoryImpl;
+
+/**
+ * A factory for the model.
+ */
+public class JavaAssemblyFactoryImpl extends AssemblyFactoryImpl implements JavaAssemblyFactory {
+
+ /**
+ * Constructor
+ */
+ public JavaAssemblyFactoryImpl() {
+ super();
+ }
+
+ /**
+ * @see org.apache.tuscany.container.java.assembly.JavaAssemblyFactory#createJavaImplementation()
+ */
+ public JavaImplementation createJavaImplementation() {
+ return new JavaImplementationImpl();
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/main/java/org/apache/tuscany/container/java/assembly/impl/JavaImplementationImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/main/java/org/apache/tuscany/container/java/assembly/impl/JavaImplementationImpl.java
new file mode 100644
index 0000000000..5ed0109b1d
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/main/java/org/apache/tuscany/container/java/assembly/impl/JavaImplementationImpl.java
@@ -0,0 +1,97 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.assembly.impl;
+
+import java.net.URL;
+
+import org.apache.tuscany.container.java.assembly.JavaAssemblyFactory;
+import org.apache.tuscany.container.java.assembly.JavaImplementation;
+import org.apache.tuscany.core.config.impl.Java5ComponentTypeIntrospector;
+import org.apache.tuscany.core.config.ComponentTypeIntrospector;
+import org.apache.tuscany.core.config.ConfigurationException;
+import org.apache.tuscany.core.config.JavaIntrospectionHelper;
+import org.apache.tuscany.model.assembly.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.ComponentType;
+import org.apache.tuscany.model.assembly.impl.ComponentImplementationImpl;
+
+/**
+ * An implementation of JavaImplementation.
+ */
+public class JavaImplementationImpl extends ComponentImplementationImpl implements JavaImplementation {
+
+ private Class<?> implementationClass;
+
+ /**
+ * Constructor
+ */
+ protected JavaImplementationImpl() {
+ }
+
+ /**
+ * @see org.apache.tuscany.container.java.assembly.JavaImplementation#getImplementationClass()
+ */
+ public Class getImplementationClass() {
+ return implementationClass;
+ }
+
+ /**
+ * @see org.apache.tuscany.container.java.assembly.JavaImplementation#setImplementationClass(java.lang.Class)
+ */
+ public void setImplementationClass(Class value) {
+ checkNotFrozen();
+ implementationClass=value;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyModelObject#initialize(org.apache.tuscany.model.assembly.AssemblyModelContext)
+ */
+ public void initialize(AssemblyModelContext modelContext) {
+ if (isInitialized())
+ return;
+
+ // Initialize the component type
+ ComponentType componentType=getComponentType();
+ if (componentType==null) {
+ componentType=createComponentType(modelContext, implementationClass);
+ setComponentType(componentType);
+ }
+
+ super.initialize(modelContext);
+ }
+
+ /**
+ * Create the component type
+ * @param modelContext
+ * @param implClass
+ */
+ private static ComponentType createComponentType(AssemblyModelContext modelContext, Class<?> implClass) {
+ String baseName = JavaIntrospectionHelper.getBaseName(implClass);
+ URL componentTypeFile = implClass.getResource(baseName + ".componentType");
+ if (componentTypeFile != null) {
+ return modelContext.getAssemblyLoader().loadComponentType(componentTypeFile.toString());
+ } else {
+ JavaAssemblyFactory factory = new JavaAssemblyFactoryImpl();
+ ComponentTypeIntrospector introspector = new Java5ComponentTypeIntrospector(factory);
+ try {
+ return introspector.introspect(implClass);
+ } catch (ConfigurationException e) {
+ throw new IllegalArgumentException("Unable to introspect implementation class: " + implClass.getName(), e);
+ }
+ }
+ }
+
+ }
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/main/java/org/apache/tuscany/container/java/builder/JavaComponentContextBuilder.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/main/java/org/apache/tuscany/container/java/builder/JavaComponentContextBuilder.java
new file mode 100644
index 0000000000..9ac030dfb9
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/main/java/org/apache/tuscany/container/java/builder/JavaComponentContextBuilder.java
@@ -0,0 +1,348 @@
+package org.apache.tuscany.container.java.builder;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.tuscany.container.java.assembly.JavaImplementation;
+import org.apache.tuscany.container.java.config.JavaComponentRuntimeConfiguration;
+import org.apache.tuscany.core.builder.BuilderConfigException;
+import org.apache.tuscany.core.builder.BuilderException;
+import org.apache.tuscany.core.builder.NoAccessorException;
+import org.apache.tuscany.core.builder.RuntimeConfigurationBuilder;
+import org.apache.tuscany.core.builder.impl.HierarchicalBuilder;
+import org.apache.tuscany.core.builder.impl.ProxyObjectFactory;
+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.injection.EventInvoker;
+import org.apache.tuscany.core.injection.FactoryInitException;
+import org.apache.tuscany.core.injection.FieldInjector;
+import org.apache.tuscany.core.injection.Injector;
+import org.apache.tuscany.core.injection.MethodEventInvoker;
+import org.apache.tuscany.core.injection.MethodInjector;
+import org.apache.tuscany.core.injection.SDOObjectFactory;
+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.ConfiguredProperty;
+import org.apache.tuscany.model.assembly.ConfiguredReference;
+import org.apache.tuscany.model.assembly.ConfiguredService;
+import org.apache.tuscany.model.assembly.Scope;
+import org.apache.tuscany.model.assembly.Service;
+import org.apache.tuscany.model.assembly.ServiceContract;
+import org.apache.tuscany.model.assembly.SimpleComponent;
+import org.osoa.sca.annotations.ComponentName;
+import org.osoa.sca.annotations.Context;
+import org.osoa.sca.annotations.Destroy;
+import org.osoa.sca.annotations.Init;
+
+import commonj.sdo.DataObject;
+
+/**
+ * Builds runtime configurations for component implementations that map to
+ * {@link org.apache.tuscany.container.java.assembly.JavaImplementation}. The logical model is then decorated with the
+ * runtime configuration.
+ *
+ * @see org.apache.tuscany.core.builder.RuntimeConfiguration
+ *
+ * @version $Rev: 368822 $ $Date: 2006-01-13 10:54:38 -0800 (Fri, 13 Jan 2006) $
+ */
+@org.osoa.sca.annotations.Scope("MODULE")
+public class JavaComponentContextBuilder implements RuntimeConfigurationBuilder<AggregateContext> {
+
+ private RuntimeContext runtimeContext;
+
+ private ProxyFactoryFactory proxyFactoryFactory;
+
+ private MessageFactory messageFactory;
+
+ /* the top-level builder responsible for evaluating policies */
+ private HierarchicalBuilder policyBuilder = new HierarchicalBuilder();
+
+ @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;
+ }
+
+ /**
+ * Adds 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.
+ */
+ public void addPolicyBuilder(RuntimeConfigurationBuilder builder) {
+ policyBuilder.addBuilder(builder);
+ }
+
+ // ----------------------------------
+ // Constructors
+ // ----------------------------------
+
+ public JavaComponentContextBuilder() {
+ }
+
+ // ----------------------------------
+ // Methods
+ // ----------------------------------
+
+ public void build(AssemblyModelObject modelObject, AggregateContext parentContext) throws BuilderException {
+ if (!(modelObject instanceof SimpleComponent)) {
+ return;
+ }
+ SimpleComponent component = (SimpleComponent) modelObject;
+ if (component.getComponentImplementation() instanceof JavaImplementation) {
+ JavaImplementation javaImpl = (JavaImplementation) component.getComponentImplementation();
+ // FIXME scope
+ Scope scope = component.getComponentImplementation().getComponentType().getServices().get(0).getServiceContract()
+ .getScope();
+ Class implClass = null;
+ Set<Field> fields;
+ Set<Method> methods;
+ try {
+ implClass = javaImpl.getImplementationClass();
+ fields = JavaIntrospectionHelper.getAllFields(implClass);
+ methods = JavaIntrospectionHelper.getAllUniqueMethods(implClass);
+ String name = component.getName();
+ Constructor ctr = implClass.getConstructor((Class[]) null);
+
+ List<Injector> injectors = new ArrayList();
+
+ EventInvoker initInvoker = null;
+ boolean eagerInit = false;
+ EventInvoker destroyInvoker = null;
+ for (Field field : fields) {
+ ComponentName compName = field.getAnnotation(ComponentName.class);
+ if (compName != null) {
+ Injector injector = new FieldInjector(field, new SingletonObjectFactory(name));
+ injectors.add(injector);
+ }
+ Context context = field.getAnnotation(Context.class);
+ if (context != null) {
+ Injector injector = new FieldInjector(field, new SingletonObjectFactory(parentContext));
+ injectors.add(injector);
+ }
+ }
+ for (Method method : methods) {
+ Init init = method.getAnnotation(Init.class);
+ if (init != null && initInvoker == null) {
+ initInvoker = new MethodEventInvoker(method);
+ eagerInit = init.eager();
+ continue;
+ }
+ // @spec - should we allow the same method to have @init and
+ // @destroy?
+ Destroy destroy = method.getAnnotation(Destroy.class);
+ if (destroy != null && destroyInvoker == null) {
+ destroyInvoker = new MethodEventInvoker(method);
+ continue;
+ }
+ ComponentName compName = method.getAnnotation(ComponentName.class);
+ if (compName != null) {
+ Injector injector = new MethodInjector(method, new SingletonObjectFactory(name));
+ injectors.add(injector);
+ }
+ Context context = method.getAnnotation(Context.class);
+ if (context != null) {
+ Injector injector = new MethodInjector(method, new SingletonObjectFactory(parentContext));
+ injectors.add(injector);
+ }
+ }
+ // handle properties
+ List<ConfiguredProperty> configuredProperties = component.getConfiguredProperties();
+ if (configuredProperties != null) {
+ for (ConfiguredProperty property : configuredProperties) {
+ Injector injector = createPropertyInjector(property, fields, methods);
+ injectors.add(injector);
+ }
+ }
+ JavaComponentRuntimeConfiguration config = new JavaComponentRuntimeConfiguration(name, JavaIntrospectionHelper
+ .getDefaultConstructor(implClass), eagerInit, initInvoker, destroyInvoker, scope);
+ component.getComponentImplementation().setRuntimeConfiguration(config);
+
+ // create target-side invocation chains for each service offered by the implementation
+ for (ConfiguredService configuredService : component.getConfiguredServices()) {
+ 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(component.getName() + QualifiedName.NAME_SEPARATOR + 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 target-side metadata
+ policyBuilder.build(configuredService, parentContext);
+ }
+ // add tail interceptor
+ for (InvocationConfiguration iConfig : (Collection<InvocationConfiguration>) iConfigMap.values()) {
+ iConfig.addTargetInterceptor(new InvokerInterceptor());
+ }
+
+ }
+
+ // handle references
+ List<ConfiguredReference> configuredReferences = component.getConfiguredReferences();
+ if (configuredReferences != null) {
+ for (ConfiguredReference reference : configuredReferences) {
+ ProxyFactory proxyFactory = proxyFactoryFactory.createProxyFactory();
+ ServiceContract serviceContract = reference.getReference().getServiceContract();
+ Map<Method, InvocationConfiguration> iConfigMap = new HashMap();
+ Set<Method> javaMethods = JavaIntrospectionHelper.getAllUniqueMethods(serviceContract.getInterface());
+ for (Method method : javaMethods) {
+ InvocationConfiguration iConfig = new InvocationConfiguration(method);
+ iConfigMap.put(method, iConfig);
+ }
+ String targetCompName = reference.getTargetConfiguredServices().get(0).getAggregatePart().getName();
+ String targetSerivceName = reference.getTargetConfiguredServices().get(0).getService().getName();
+
+ QualifiedName qName = new QualifiedName(targetCompName + "/" + targetSerivceName);
+ // QualifiedName qName = new QualifiedName(reference.getAggregatePart().getName() + "/"
+ // + reference.getPort().getName());
+ ProxyConfiguration pConfiguration = new ProxyConfiguration(qName, iConfigMap, serviceContract.getInterface().getClassLoader(), messageFactory);
+ proxyFactory.setBusinessInterface(serviceContract.getInterface());
+ proxyFactory.setProxyConfiguration(pConfiguration);
+ config.addSourceProxyFactory(reference.getReference().getName(), proxyFactory);
+ reference.setProxyFactory(proxyFactory);
+ if (policyBuilder != null) {
+ // invoke the reference builder to handle metadata associated with the reference
+ policyBuilder.build(reference, parentContext);
+ }
+ Injector injector = createReferenceInjector(reference.getReference().getName(), proxyFactory, fields,
+ methods);
+ injectors.add(injector);
+ }
+ }
+ config.setSetters(injectors);
+ } catch (BuilderException e) {
+ e.addContextName(component.getName());
+ e.addContextName(parentContext.getName());
+ throw e;
+ } catch (NoSuchMethodException e) {
+ BuilderConfigException ce = new BuilderConfigException("Class does not have a no-arg constructor", e);
+ ce.setIdentifier(implClass.getName());
+ ce.addContextName(component.getName());
+ ce.addContextName(parentContext.getName());
+ throw ce;
+ }
+ }
+ }
+
+ // ----------------------------------
+ // Private methods
+ // ----------------------------------
+
+ /**
+ * Creates an <code>Injector</code> for component properties
+ */
+ private Injector createPropertyInjector(ConfiguredProperty property, Set<Field> fields, Set<Method> methods)
+ throws NoAccessorException {
+ Object value = property.getValue();
+ String propName = property.getProperty().getName();
+ Class type = value.getClass();
+
+ // There is no efficient way to do this
+ Method method = null;
+ Field field = JavaIntrospectionHelper.findClosestMatchingField(propName, type, fields);
+ if (field == null) {
+ method = JavaIntrospectionHelper.findClosestMatchingMethod(propName, new Class[] { type }, methods);
+ if (method == null) {
+ throw new NoAccessorException(propName);
+ }
+ }
+ Injector injector = null;
+ if (value instanceof DataObject) {
+ if (field != null) {
+ injector = new FieldInjector(field, new SDOObjectFactory((DataObject) value));
+ } else {
+ injector = new MethodInjector(method, new SDOObjectFactory((DataObject) value));
+ }
+ } else if (JavaIntrospectionHelper.isImmutable(type)) {
+ if (field != null) {
+ injector = new FieldInjector(field, new SingletonObjectFactory(value));
+ } else {
+ injector = new MethodInjector(method, new SingletonObjectFactory(value));
+ }
+ }
+ return injector;
+
+ }
+
+ /**
+ * Creates an <code>Injector</code> for service references
+ */
+ private Injector createReferenceInjector(String refName, ProxyFactory proxyFactory, Set<Field> fields, Set<Method> methods)
+ throws NoAccessorException, BuilderConfigException {
+ Method method = null;
+ Field field = JavaIntrospectionHelper.findClosestMatchingField(refName, proxyFactory.getBusinessInterface(), fields);
+ if (field == null) {
+ method = JavaIntrospectionHelper.findClosestMatchingMethod(refName,
+ new Class[] { proxyFactory.getBusinessInterface() }, methods);
+ if (method == null) {
+ throw new NoAccessorException(refName);
+ }
+ }
+ Injector injector;
+ try {
+ if (field != null) {
+ injector = new FieldInjector(field, new ProxyObjectFactory(proxyFactory));
+ } else {
+ injector = new MethodInjector(method, new ProxyObjectFactory(proxyFactory));
+ }
+ } catch (FactoryInitException e) {
+ BuilderConfigException ce = new BuilderConfigException("Error configuring reference", e);
+ ce.setIdentifier(refName);
+ throw ce;
+ }
+ return injector;
+
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/main/java/org/apache/tuscany/container/java/builder/JavaTargetWireBuilder.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/main/java/org/apache/tuscany/container/java/builder/JavaTargetWireBuilder.java
new file mode 100644
index 0000000000..5df160cb54
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/main/java/org/apache/tuscany/container/java/builder/JavaTargetWireBuilder.java
@@ -0,0 +1,85 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.builder;
+
+import org.apache.tuscany.container.java.config.JavaComponentRuntimeConfiguration;
+import org.apache.tuscany.container.java.invocation.ScopedJavaComponentInvoker;
+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;
+
+/**
+ * Completes a wire to a Java-based target component by adding a scoped java invoker to the source chain
+ *
+ * @version $Rev$ $Date$
+ */
+@Scope("MODULE")
+public class JavaTargetWireBuilder implements WireBuilder {
+
+ private RuntimeContext runtimeContext;
+
+ @Autowire
+ public void setRuntimeContext(RuntimeContext context) {
+ runtimeContext = context;
+ }
+
+ public JavaTargetWireBuilder() {
+ }
+
+ @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 (!(JavaComponentRuntimeConfiguration.class.isAssignableFrom(targetType))) {
+ return;
+ }
+ for (InvocationConfiguration sourceInvocationConfig : sourceFactory.getProxyConfiguration().getInvocationConfigurations()
+ .values()) {
+ ScopedJavaComponentInvoker invoker = new ScopedJavaComponentInvoker(sourceFactory.getProxyConfiguration()
+ .getTargetName(), sourceInvocationConfig.getMethod(), targetScopeContext);
+ if (downScope) {
+ // the source scope is shorter than the target, so the invoker can cache the target instance
+ invoker.setCacheable(false);
+ } else {
+ invoker.setCacheable(true); //TODO set to true
+ }
+ sourceInvocationConfig.setTargetInvoker(invoker);
+ }
+ }
+
+ public void completeTargetChain(ProxyFactory targetFactory, Class targetType, ScopeContext targetScopeContext)
+ throws BuilderConfigException {
+ // TODO implement.
+ // if (!(JavaComponentRuntimeConfiguration.class.isAssignableFrom(targetType))) {
+ // return;
+ // }
+ // for (InvocationConfiguration targetInvocationConfig :
+ // targetFactory.getProxyConfiguration().getInvocationConfigurations()
+ // .values()) {
+ // ScopedJavaComponentInvoker invoker = new ScopedJavaComponentInvoker(targetFactory.getProxyConfiguration()
+ // .getTargetName(), ((JavaOperationType) targetInvocationConfig.getOperationType()).getJavaMethod(),
+ // targetScopeContext);
+ // targetInvocationConfig.setTargetInvoker(invoker);
+ // }
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/main/java/org/apache/tuscany/container/java/config/JavaComponentRuntimeConfiguration.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/main/java/org/apache/tuscany/container/java/config/JavaComponentRuntimeConfiguration.java
new file mode 100644
index 0000000000..bfe6dc25d5
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/main/java/org/apache/tuscany/container/java/config/JavaComponentRuntimeConfiguration.java
@@ -0,0 +1,151 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.config;
+
+import java.lang.reflect.Constructor;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.container.java.context.JavaComponentContext;
+import org.apache.tuscany.core.builder.ContextCreationException;
+import org.apache.tuscany.core.builder.RuntimeConfiguration;
+import org.apache.tuscany.core.context.SimpleComponentContext;
+import org.apache.tuscany.core.injection.EventInvoker;
+import org.apache.tuscany.core.injection.Injector;
+import org.apache.tuscany.core.injection.PojoObjectFactory;
+import org.apache.tuscany.core.invocation.spi.ProxyFactory;
+import org.apache.tuscany.model.assembly.Scope;
+
+/**
+ * A RuntimeConfiguration that handles POJO component implementation types
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaComponentRuntimeConfiguration implements RuntimeConfiguration<SimpleComponentContext> {
+
+ // the component name as configured in the hosting module
+ private String name;
+
+ // the implementation type constructor
+ private Constructor ctr;
+
+ // injectors for properties, references and other metadata values such as
+ private List<Injector> setters;
+
+ // an invoker for a method decorated with @Init
+ private EventInvoker init;
+
+ // whether the component should be eagerly initialized when its scope starts
+ private boolean eagerInit;
+
+ // an invoker for a method decorated with @Destroy
+ private EventInvoker destroy;
+
+ // the scope of the implementation instance
+ private Scope scope;
+
+ private boolean stateless;
+
+ // ----------------------------------
+ // Constructors
+ // ----------------------------------
+
+ /**
+ * Creates the runtime configuration
+ *
+ * @param name the SCDL name of the component the context refers to
+ * @param ctr the implementation type constructor
+ * @param setters a collection of <code>Injectors</code> used to configure properties, references and other meta
+ * data values on implementation instances
+ * @param eagerInit whether the component should be eagerly initialized
+ * @param init an <code>Invoker</code> pointing to a method on the implementation type decorated with
+ * <code>@Init</code>
+ * @param destroy an <code>Invoker</code> pointing to a method on the implementation type decorated with
+ * <code>@Destroy</code>
+ * @param scope the scope of the component implementation type
+ */
+ public JavaComponentRuntimeConfiguration(String name, Constructor ctr, List<Injector> setters, boolean eagerInit,
+ EventInvoker init, EventInvoker destroy, Scope scope) {
+ assert (name != null) : "Name was null";
+ assert (ctr != null) : "Constructor was null";
+ this.name = name;
+ this.ctr = ctr;
+ this.setters = setters;
+ this.eagerInit = eagerInit;
+ this.init = init;
+ this.destroy = destroy;
+ this.scope = scope;
+ stateless = (scope == Scope.INSTANCE);
+ }
+
+ public JavaComponentRuntimeConfiguration(String name, Constructor ctr, boolean eagerInit, EventInvoker init,
+ EventInvoker destroy, Scope scope) {
+ this(name, ctr, null, eagerInit, init, destroy, scope);
+ }
+
+ // ----------------------------------
+ // Methods
+ // ----------------------------------
+
+ public String getName() {
+ return name;
+ }
+
+ public Scope getScope() {
+ return scope;
+ }
+
+ public SimpleComponentContext createInstanceContext() throws ContextCreationException {
+ PojoObjectFactory objectFactory = new PojoObjectFactory(ctr, null, setters);
+ return new JavaComponentContext(name, objectFactory, eagerInit, init, destroy, stateless);
+ }
+
+ private Map<String, ProxyFactory> targetProxyFactories = new HashMap();
+
+ public void addTargetProxyFactory(String serviceName, ProxyFactory factory) {
+ targetProxyFactories.put(serviceName, factory);
+ }
+
+ public ProxyFactory getTargetProxyFactory(String serviceName) {
+ return targetProxyFactories.get(serviceName);
+ }
+
+ public Map<String, ProxyFactory> getTargetProxyFactories() {
+ return targetProxyFactories;
+ }
+
+ private Map<String, ProxyFactory> sourceProxyFactories = new HashMap();
+
+ public void addSourceProxyFactory(String referenceName, ProxyFactory factory) {
+ sourceProxyFactories.put(referenceName, factory);
+ }
+
+ public ProxyFactory getSourceProxyFactory(String referenceName) {
+ return sourceProxyFactories.get(referenceName);
+ }
+
+ public Map<String, ProxyFactory> getSourceProxyFactories() {
+ return sourceProxyFactories;
+ }
+
+ public void setSetters(List<Injector> setters) {
+ this.setters = setters;
+ }
+
+ public void prepare(){
+
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/main/java/org/apache/tuscany/container/java/context/JavaComponentContext.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/main/java/org/apache/tuscany/container/java/context/JavaComponentContext.java
new file mode 100644
index 0000000000..0b4a800f1f
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/main/java/org/apache/tuscany/container/java/context/JavaComponentContext.java
@@ -0,0 +1,206 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.context;
+
+import java.util.Iterator;
+
+import org.apache.tuscany.core.builder.ObjectFactory;
+import org.apache.tuscany.core.context.AbstractContext;
+import org.apache.tuscany.core.context.Context;
+import org.apache.tuscany.core.context.ContextInitException;
+import org.apache.tuscany.core.context.LifecycleEventListener;
+import org.apache.tuscany.core.context.QualifiedName;
+import org.apache.tuscany.core.context.SimpleComponentContext;
+import org.apache.tuscany.core.context.TargetException;
+import org.apache.tuscany.core.injection.EventInvoker;
+import org.apache.tuscany.core.injection.Injector;
+import org.apache.tuscany.core.injection.ObjectCallbackException;
+import org.apache.tuscany.core.injection.ObjectCreationException;
+
+/**
+ * Manages Java service component implementation instances
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaComponentContext extends AbstractContext implements SimpleComponentContext {
+
+ private boolean eagerInit;
+
+ private EventInvoker initInvoker;
+
+ private EventInvoker destroyInvoker;
+
+ private Injector componentName;
+
+ private Injector moduleContext;
+
+ private boolean stateless;
+
+ // the cached target instance
+ private Object cachedTargetInstance;
+
+ // creates a new implementation instance with injected references and properties
+ private ObjectFactory objectFactory;
+
+ // ----------------------------------
+ // Constructors
+ // ----------------------------------
+
+ public JavaComponentContext(String name, ObjectFactory objectFactory, boolean eagerInit, EventInvoker initInvoker,
+ EventInvoker destroyInvoker, boolean stateless) {
+ super(name);
+ assert (objectFactory != null) : "Object factory was null";
+ if (eagerInit == true && initInvoker == null) {
+ ContextInitException e = new ContextInitException("No intialization method found for implementation");
+ e.setIdentifier(getName());
+ throw e;
+ }
+ this.objectFactory = objectFactory;
+
+ this.eagerInit = eagerInit;
+ this.initInvoker = initInvoker;
+ this.destroyInvoker = destroyInvoker;
+ this.stateless = stateless;
+ }
+
+ // ----------------------------------
+ // Methods
+ // ----------------------------------
+
+ public void setName(String name) {
+ super.setName(name);
+ }
+
+ protected int type;
+
+ public int getType() {
+ return type;
+ }
+
+ public void setType(int type) {
+ this.type = type;
+ }
+
+ public synchronized Object getInstance(QualifiedName qName) throws TargetException {
+ return getInstance(qName, true);
+ }
+
+ public synchronized Object getInstance(QualifiedName qName, boolean notify) throws TargetException {
+ //TODO implement returning of proxy and invocation chain for service
+ if (cachedTargetInstance != null) {
+ return cachedTargetInstance; // already cached, just return
+ }
+
+ if (getLifecycleState() == ERROR || getLifecycleState() == CONFIG_ERROR) {
+ return null;
+ }
+ synchronized (this) {
+ try {
+ Object instance = objectFactory.getInstance();
+ startInstance(instance);
+ if (notify) {
+ for (Iterator iter = contextListener.iterator(); iter.hasNext();) {
+ LifecycleEventListener listener = (LifecycleEventListener) iter.next();
+ listener.onInstanceCreate(this);
+ }
+ }
+ setLifecycleState(RUNNING);
+ if (stateless) {
+ return instance;
+ } else {
+ // cache the actual instance
+ cachedTargetInstance = instance;
+ return cachedTargetInstance;
+ }
+ } catch (ObjectCreationException e) {
+ setLifecycleState(Context.ERROR);
+ TargetException te = new TargetException("Error creating instance for component", e);
+ te.setIdentifier(getName());
+ throw te;
+ }
+ }
+
+ }
+
+ public Object getImplementationInstance() throws TargetException{
+ //TODO refactor when getInstance() returns a proxy
+ return getInstance(null);
+ }
+
+ public Object getImplementationInstance(boolean notify) throws TargetException{
+ //TODO refactor when getInstance() returns a proxy
+ return getInstance(null,notify);
+ }
+
+
+ public boolean isEagerInit() {
+ return eagerInit;
+ }
+
+ public boolean isDestroyable() {
+ return (destroyInvoker != null);
+ }
+
+ // ----------------------------------
+ // Lifecycle methods
+ // ----------------------------------
+
+ public void start() throws ContextInitException {
+ if (getLifecycleState() != UNINITIALIZED && getLifecycleState() != STOPPED) {
+ throw new IllegalStateException("Component must be in UNINITIALIZED state [" + getLifecycleState() + "]");
+ }
+ if (objectFactory == null) {
+ setLifecycleState(ERROR);
+ ContextInitException e = new ContextInitException("Object factory not found");
+ e.setIdentifier(getName());
+ throw e;
+ }
+ setLifecycleState(INITIALIZED);
+ }
+
+ public void stop() {
+ if (cachedTargetInstance != null) {
+ if (destroyInvoker != null) {
+ try {
+ destroyInvoker.invokeEvent(cachedTargetInstance);
+ } catch (ObjectCallbackException e) {
+ TargetException te = new TargetException(e.getCause());
+ te.setIdentifier(getName());
+ throw te;
+ }
+ }
+ }
+ setLifecycleState(STOPPED);
+ }
+
+ // ----------------------------------
+ // Private methods
+ // ----------------------------------
+ private void startInstance(Object instance) throws TargetException {
+ try {
+ // handle @Init
+ if (initInvoker != null) {
+ initInvoker.invokeEvent(instance);
+ }
+ } catch (ObjectCallbackException e) {
+ TargetException te = new TargetException("Error initializing instance", e);
+ te.setIdentifier(getName());
+ throw te;
+ }
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/main/java/org/apache/tuscany/container/java/invocation/AbstractJavaComponentInvoker.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/main/java/org/apache/tuscany/container/java/invocation/AbstractJavaComponentInvoker.java
new file mode 100644
index 0000000000..0109416e75
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/main/java/org/apache/tuscany/container/java/invocation/AbstractJavaComponentInvoker.java
@@ -0,0 +1,92 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.invocation;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.Set;
+
+import org.apache.tuscany.core.config.JavaIntrospectionHelper;
+import org.apache.tuscany.core.context.TargetException;
+import org.apache.tuscany.core.invocation.Interceptor;
+import org.apache.tuscany.core.invocation.InvocationRuntimeException;
+import org.apache.tuscany.core.invocation.TargetInvoker;
+import org.apache.tuscany.core.message.Message;
+
+/**
+ * Base class for dispatching to a Java based component implementation. Subclasses implement a strategy for resolving
+ * implementation instances.
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class AbstractJavaComponentInvoker implements TargetInvoker {
+
+ protected Method operation;
+
+ public AbstractJavaComponentInvoker(Method operation) {
+ assert (operation != null) : "Operation method cannot be null";
+ this.operation = operation;
+ }
+
+ public Object invokeTarget(Object payload) throws InvocationTargetException {
+ try {
+ Object instance = getInstance();
+ if (!operation.getDeclaringClass().isInstance(instance)) {
+ Set methods = JavaIntrospectionHelper.getAllUniqueMethods(instance.getClass());
+ Method newOperation = JavaIntrospectionHelper.findClosestMatchingMethod(operation.getName(), operation
+ .getParameterTypes(), methods);
+ if (newOperation != null)
+ operation = newOperation;
+ }
+ if (payload != null && !payload.getClass().isArray()) {
+ return operation.invoke(instance, payload);
+ } else {
+ return operation.invoke(instance, (Object[]) payload);
+ }
+ } catch (IllegalAccessException e) {
+ throw new InvocationRuntimeException(e);
+ }
+ }
+
+ 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;
+ }
+
+ protected abstract Object getInstance() throws TargetException;
+
+ public void setNext(Interceptor next) {
+ throw new IllegalStateException("This interceptor must be the last interceptor in an interceptor chain");
+ }
+
+ public Object clone(){
+ try {
+ AbstractJavaComponentInvoker clone = (AbstractJavaComponentInvoker) super.clone();
+ clone.operation = this.operation;
+ return clone;
+ } catch (CloneNotSupportedException e) {
+ return null; // will not happen
+ }
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/main/java/org/apache/tuscany/container/java/invocation/ScopedJavaComponentInvoker.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/main/java/org/apache/tuscany/container/java/invocation/ScopedJavaComponentInvoker.java
new file mode 100644
index 0000000000..4d69ba51f5
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/main/java/org/apache/tuscany/container/java/invocation/ScopedJavaComponentInvoker.java
@@ -0,0 +1,86 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.invocation;
+
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.core.context.QualifiedName;
+import org.apache.tuscany.core.context.ScopeContext;
+import org.apache.tuscany.core.context.TargetException;
+
+/**
+ * Uses a scope container to resolve an implementation instance based on the current thread context
+ *
+ * @version $Rev$ $Date$
+ */
+public class ScopedJavaComponentInvoker extends AbstractJavaComponentInvoker {
+
+ private ScopeContext container;
+
+ private QualifiedName name;
+
+ private Object target;
+
+ public boolean cacheable;
+
+ public ScopedJavaComponentInvoker(QualifiedName serviceName, Method operation, ScopeContext container) {
+ super(operation);
+ assert (serviceName != null) : "No service name specified";
+ assert (container != null) : "No scope container specified";
+ name = serviceName;
+ this.container = container;
+ }
+
+ /**
+ * Returns whether the target is cacheable.
+ */
+ public boolean isCacheable() {
+ return cacheable;
+ }
+
+ /**
+ * Sets whether the target service instance may be cached by the invoker. This is a possible optimization when a
+ * wire is configured for a "down-scope" reference, i.e. a reference from a source of a shorter lifetime to a source
+ * of greater lifetime.
+ */
+ public void setCacheable(boolean val) {
+ cacheable = val;
+ }
+
+ /**
+ * Resolves the target service instance or returns a cached one
+ */
+ protected Object getInstance() throws TargetException {
+ if (!cacheable) {
+ return container.getInstance(name);
+ } else {
+ if (target == null) {
+ target = container.getInstance(name);
+ }
+ return target;
+ }
+ }
+
+ public Object clone() {
+ ScopedJavaComponentInvoker invoker = (ScopedJavaComponentInvoker) super.clone();
+ invoker.target = null;
+ invoker.cacheable = this.cacheable;
+ invoker.container = this.container;
+ invoker.name = this.name;
+ return invoker;
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/main/java/org/apache/tuscany/container/java/invocation/StaticJavaComponentTargetInvoker.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/main/java/org/apache/tuscany/container/java/invocation/StaticJavaComponentTargetInvoker.java
new file mode 100644
index 0000000000..8e0342beb7
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/main/java/org/apache/tuscany/container/java/invocation/StaticJavaComponentTargetInvoker.java
@@ -0,0 +1,50 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.invocation;
+
+import java.lang.reflect.Method;
+
+/**
+ * Caches component instances that do not need to be resolved for every invocation, e.g. an invocation originating from
+ * a lesser scope intended for a target with a wider scope
+ *
+ * @version $Rev$ $Date$
+ */
+public class StaticJavaComponentTargetInvoker extends AbstractJavaComponentInvoker {
+
+ private Object instance;
+
+ public StaticJavaComponentTargetInvoker(Method operation, Object instance) {
+ super(operation);
+ assert (instance != null) : "Instance cannot be null";
+ this.instance = instance;
+ }
+
+ protected Object getInstance() {
+ return instance;
+ }
+
+ public boolean isCacheable() {
+ return true;
+ }
+
+ public Object clone() {
+ StaticJavaComponentTargetInvoker invoker = (StaticJavaComponentTargetInvoker) super.clone();
+ invoker.instance = null;
+ return invoker;
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/main/java/org/apache/tuscany/container/java/loader/JavaSCDLModelLoader.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/main/java/org/apache/tuscany/container/java/loader/JavaSCDLModelLoader.java
new file mode 100644
index 0000000000..e1c50a9ff4
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/main/java/org/apache/tuscany/container/java/loader/JavaSCDLModelLoader.java
@@ -0,0 +1,81 @@
+package org.apache.tuscany.container.java.loader;
+
+import org.apache.tuscany.container.java.assembly.JavaAssemblyFactory;
+import org.apache.tuscany.container.java.assembly.JavaImplementation;
+import org.apache.tuscany.container.java.assembly.impl.JavaAssemblyFactoryImpl;
+import org.apache.tuscany.core.loader.SCDLModelLoaderRegistry;
+import org.apache.tuscany.core.runtime.RuntimeContext;
+import org.apache.tuscany.core.system.annotation.Autowire;
+import org.apache.tuscany.model.assembly.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.AssemblyModelObject;
+import org.apache.tuscany.model.scdl.loader.SCDLModelLoader;
+import org.osoa.sca.annotations.Destroy;
+import org.osoa.sca.annotations.Init;
+
+/**
+ * Populates the assembly model from an SCDL model
+ */
+@org.osoa.sca.annotations.Scope("MODULE")
+public class JavaSCDLModelLoader implements SCDLModelLoader {
+
+ private RuntimeContext runtimeContext;
+ private SCDLModelLoaderRegistry loaderRegistry;
+ private JavaAssemblyFactory javaFactory;
+
+ /**
+ * Constructs a new JavaSCDLModelLoader.
+ */
+ public JavaSCDLModelLoader() {
+ this.javaFactory=new JavaAssemblyFactoryImpl();
+ }
+
+ /**
+ * @param runtimeContext The runtimeContext to set.
+ */
+ @Autowire
+ public void setRuntimeContext(RuntimeContext runtimeContext) {
+ this.runtimeContext = runtimeContext;
+ }
+
+// @Reference
+ public void setLoaderRegistry(SCDLModelLoaderRegistry registry) {
+ this.loaderRegistry = registry;
+ }
+
+ @Init(eager=true)
+ public void init() {
+ runtimeContext.addLoader(this);
+// loaderRegistry.registerLoader(this);
+ }
+
+ @Destroy
+ public void destroy() {
+// loaderRegistry.unregisterLoader(this);
+ }
+
+ /**
+ * @see org.apache.tuscany.model.scdl.loader.SCDLModelLoader#load(org.apache.tuscany.model.assembly.AssemblyModelContext, java.lang.Object)
+ */
+ public AssemblyModelObject load(AssemblyModelContext modelContext, Object object) {
+ if (object instanceof org.apache.tuscany.model.scdl.JavaImplementation) {
+ org.apache.tuscany.model.scdl.JavaImplementation scdlJavaImplementation=(org.apache.tuscany.model.scdl.JavaImplementation)object;
+ JavaImplementation implementation=javaFactory.createJavaImplementation();
+
+ //FIXME Temp set the current app classloader on the class to load the impl class
+ ClassLoader ccl=Thread.currentThread().getContextClassLoader();
+ Class implementationClass;
+ try {
+ Thread.currentThread().setContextClassLoader(modelContext.getApplicationResourceLoader().getClassLoader());
+ implementationClass=modelContext.getApplicationResourceLoader().loadClass(scdlJavaImplementation.getClass_());
+ } catch (ClassNotFoundException e) {
+ throw new IllegalArgumentException(e);
+ } finally {
+ Thread.currentThread().setContextClassLoader(ccl);
+ }
+ implementation.setImplementationClass(implementationClass);
+
+ return implementation;
+ } else
+ return null;
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/main/resources/org/apache/tuscany/container/java/Messages.properties b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/main/resources/org/apache/tuscany/container/java/Messages.properties
new file mode 100644
index 0000000000..4581e44bff
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/main/resources/org/apache/tuscany/container/java/Messages.properties
@@ -0,0 +1,25 @@
+# Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
+#
+# 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.
+# ====================================================================
+# To code developer:
+# Do NOT change the properties between this line and the
+# "%%% END OF TRANSLATED PROPERTIES %%%" line.
+# Make a new property name, append to the end of the file and change
+# the code to use the new property.
+# ====================================================================
+
+# =====================================================================
+# %%% END OF TRANSLATED PROPERTIES %%%
+# =====================================================================
+# NLS_MESSAGEFORMAT_ALL
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/main/resources/system.fragment b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/main/resources/system.fragment
new file mode 100644
index 0000000000..e29d165b0b
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/main/resources/system.fragment
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
+
+ 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.
+ -->
+<moduleFragment xmlns="http://www.osoa.org/xmlns/sca/0.9" xmlns:v="http://www.osoa.org/xmlns/sca/values/0.9"
+ xmlns:system="http://org.apache.tuscany/xmlns/system/0.9"
+ name="org.apache.tuscany.container.java">
+
+ <component name="org.apache.tuscany.container.java.builder.JavaComponentContextBuilder">
+ <system:implementation.system class="org.apache.tuscany.container.java.builder.JavaComponentContextBuilder"/>
+ </component>
+
+ <component name="org.apache.tuscany.container.java.builder.JavaTargetWireBuilder">
+ <system:implementation.system class="org.apache.tuscany.container.java.builder.JavaTargetWireBuilder"/>
+ </component>
+
+ <component name="org.apache.tuscany.container.java.loader.JavaSCDLModelLoader">
+ <system:implementation.system class="org.apache.tuscany.container.java.loader.JavaSCDLModelLoader"/>
+<!--
+ <references>
+ <v:loaderRegistry>org.apache.tuscany.core.loader.SCDLModelLoaderRegistry</v:loaderRegistry>
+ </references>
+-->
+ </component>
+
+</moduleFragment>
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/main/test/sca.module b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/main/test/sca.module
new file mode 100644
index 0000000000..e1f10097f4
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/main/test/sca.module
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
+
+ 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.
+ -->
+<module xmlns="http://www.osoa.org/xmlns/sca/0.9" xmlns:v="http://www.osoa.org/xmlns/sca/values/0.9"
+
+ name="sample.myvaluemodule">
+ <!--
+ <entryPoint name="MyValueService">
+ <interface.java interface="services.myvalue.MyValueService"/>
+ <binding.ws port="http://webservice.myvalue#MyValueWebService"/>
+ <reference>MyValueServiceComponent</reference>
+ </entryPoint>
+
+ <component name="MyValueServiceComponent">
+ <implementation.java class="services.myvalue.MyValueServiceImpl"/>
+ <properties>
+ <v:currency>EURO</v:currency>
+ </properties>
+ <references>
+ <v:customerService>CustomerServiceComponent</v:customerService>
+ <v:stockQuoteService>StockQuoteMediatorComponent</v:stockQuoteService>
+ </references>
+ </component>
+
+ <component name="StockQuoteMediatorComponent">
+ <implementation.java class="services.mediator.StockQuoteMediatorImpl"/>
+ <references>
+ <v:stockQuoteService>StockQuoteService</v:stockQuoteService>
+ </references>
+ </component>
+
+ <component name="CustomerServiceComponent">
+ <implementation.java class="services.customer.CustomerServiceImpl"/>
+ </component>
+
+ <component name="StockQuoteService">
+ <implementation.java class="services.stockquote.StockQuoteServiceImpl"/>
+ </component>
+ -->
+ <component name="TestService">
+ <implementation.java class="test.org.apache.tuscany.container.java.components.ModuleScopeComponentImpl"/>
+ <properties>
+ <v:foo>MyFoo</v:foo>
+ <v:mInt>1</v:mInt>
+ </properties>
+ <references>
+ <v:mGenericComponent>TestService2</v:mGenericComponent>
+ </references>
+ </component>
+ <component name="TestService2">
+ <implementation.java class="test.org.apache.tuscany.container.java.components.ModuleScopeComponentImpl"/>
+ </component>
+
+ <!--
+ <externalService name="StockQuoteService">
+ <interface.java interface="services.stockquote.StockQuoteService"/>
+ <binding.ws port="http://webservice.stockquote#StockQuoteWebService"/>
+ </externalService>
+ -->
+
+</module>
+ \ No newline at end of file
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/impl/JavaImplementationTestCase.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/impl/JavaImplementationTestCase.java
new file mode 100644
index 0000000000..d916f67050
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/impl/JavaImplementationTestCase.java
@@ -0,0 +1,137 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.assembly.impl;
+
+import java.util.List;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.common.resource.impl.ResourceLoaderImpl;
+import org.apache.tuscany.container.java.assembly.mock.HelloWorldImpl;
+import org.apache.tuscany.container.java.assembly.mock.HelloWorldWithFieldProperties;
+import org.apache.tuscany.container.java.assembly.mock.NakedHelloWorld;
+import org.apache.tuscany.container.java.assembly.mock.NakedHelloWorldWithInterface;
+import org.apache.tuscany.model.assembly.ComponentType;
+import org.apache.tuscany.model.assembly.Property;
+import org.apache.tuscany.model.assembly.Service;
+import org.apache.tuscany.model.assembly.impl.AssemblyFactoryImpl;
+import org.apache.tuscany.model.assembly.impl.AssemblyModelContextImpl;
+import org.apache.tuscany.model.scdl.loader.impl.SCDLAssemblyModelLoaderImpl;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JavaImplementationTestCase extends TestCase {
+ private JavaImplementationImpl impl = (JavaImplementationImpl) new JavaAssemblyFactoryImpl().createJavaImplementation();
+
+ public void testFoo() {
+ impl.setImplementationClass(HelloWorldImpl.class);
+
+ // this is not needed anymore
+ //assertEquals("org/apache/tuscany/container/java/assembly/mock/HelloWorldImpl.componentType", impl.getComponentTypeName());
+ }
+
+ public void testNoImplementationClass() {
+ //FIXME this test fails with NPE
+// impl.setImplementationClass(null);
+// try {
+// impl.initialize(new AssemblyModelContextImpl(new AssemblyLoaderImpl(), ResourceLoaderFactory.getResourceLoader(Thread.currentThread().getContextClassLoader())));
+// impl.getComponentType();
+// fail("Expected IllegalArgumentException");
+// } catch (IllegalArgumentException e) {
+// // ok
+// }
+ }
+
+ public void testNakedHelloWorld() {
+ impl.setImplementationClass(NakedHelloWorld.class);
+ impl.initialize(new AssemblyModelContextImpl(new AssemblyFactoryImpl(), new SCDLAssemblyModelLoaderImpl(null), new ResourceLoaderImpl(Thread.currentThread().getContextClassLoader())));
+ ComponentType type = impl.getComponentType();
+ Assert.assertNotNull(type);
+ Assert.assertTrue(type.getProperties().isEmpty());
+ Assert.assertTrue(type.getReferences().isEmpty());
+ List<Service> services = type.getServices();
+ Assert.assertEquals(1, services.size());
+ Assert.assertTrue(services.get(0).getName().equals("NakedHelloWorld"));
+ }
+
+ public void testNakedHelloWorldWithInterface() {
+ impl.setImplementationClass(NakedHelloWorldWithInterface.class);
+ impl.initialize(new AssemblyModelContextImpl(new AssemblyFactoryImpl(), new SCDLAssemblyModelLoaderImpl(null), new ResourceLoaderImpl(Thread.currentThread().getContextClassLoader())));
+ ComponentType type = impl.getComponentType();
+ Assert.assertNotNull(type);
+ Assert.assertTrue(type.getProperties().isEmpty());
+ Assert.assertTrue(type.getReferences().isEmpty());
+ List<Service> services = type.getServices();
+ Assert.assertEquals(1, services.size());
+ Assert.assertTrue(services.get(0).getName().equals("NakedHelloWorldWithInterface"));
+ }
+
+ public void testHelloWorldWithSidefile() {
+ impl.setImplementationClass(HelloWorldImpl.class);
+ impl.initialize(new AssemblyModelContextImpl(new AssemblyFactoryImpl(), new SCDLAssemblyModelLoaderImpl(null), new ResourceLoaderImpl(Thread.currentThread().getContextClassLoader())));
+ ComponentType type = impl.getComponentType();
+ Assert.assertNotNull(type);
+ List<Property> props = type.getProperties();
+ Assert.assertEquals(1, props.size());
+ Assert.assertTrue(props.get(0).getName().equals("text"));
+
+ Assert.assertTrue(type.getReferences().isEmpty());
+
+ List<Service> services = type.getServices();
+ Assert.assertEquals(1, services.size());
+ Assert.assertTrue(services.get(0).getName().equals("HelloWorldService"));
+ }
+
+ public void testHelloWorldWithFieldProperties() {
+ impl.setImplementationClass(HelloWorldWithFieldProperties.class);
+ impl.initialize(new AssemblyModelContextImpl(new AssemblyFactoryImpl(), new SCDLAssemblyModelLoaderImpl(null), new ResourceLoaderImpl(Thread.currentThread().getContextClassLoader())));
+ ComponentType type = impl.getComponentType();
+ Assert.assertNotNull(type);
+ List<Property> props = type.getProperties();
+ Assert.assertEquals(3, props.size());
+
+ Property prop = type.getProperty("text");
+ Assert.assertNotNull(prop);
+ Assert.assertEquals("text", prop.getName());
+ Assert.assertEquals(false, prop.isRequired());
+ Assert.assertEquals(String.class, prop.getType());
+
+ prop = type.getProperty("text2");
+ Assert.assertNotNull(prop);
+ Assert.assertEquals("text2", prop.getName());
+ Assert.assertEquals(true, prop.isRequired());
+ Assert.assertEquals(Integer.class, prop.getType());
+
+ prop = type.getProperty("foo");
+ Assert.assertNotNull(prop);
+ Assert.assertEquals("foo", prop.getName());
+ Assert.assertEquals(false, prop.isRequired());
+ Assert.assertEquals(Integer.TYPE, prop.getType());
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ Thread.currentThread().setContextClassLoader(JavaImplementationTestCase.class.getClassLoader());
+ }
+
+ protected void tearDown() throws Exception {
+ Thread.currentThread().setContextClassLoader(null);
+ super.tearDown();
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/mock/HelloWorldImpl.componentType b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/mock/HelloWorldImpl.componentType
new file mode 100644
index 0000000000..784d8bf728
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/mock/HelloWorldImpl.componentType
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
+
+ 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.
+ -->
+<componentType xmlns="http://www.osoa.org/xmlns/sca/0.9"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <service name="HelloWorldService">
+ <interface.java interface="org.apache.tuscany.container.java.assembly.mock.HelloWorldService" remoteable="true"/>
+ </service>
+ <property name="text" type="xsd:string"/>
+</componentType> \ No newline at end of file
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/mock/HelloWorldImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/mock/HelloWorldImpl.java
new file mode 100644
index 0000000000..74f4c658ce
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/mock/HelloWorldImpl.java
@@ -0,0 +1,36 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.assembly.mock;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class HelloWorldImpl implements HelloWorldService {
+
+ private String text;
+
+ private int count;
+
+ public String hello(String name) {
+ ++count;
+ return "Hello " + name;
+ }
+
+ public int count() {
+ return count;
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/mock/HelloWorldService.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/mock/HelloWorldService.java
new file mode 100644
index 0000000000..a7d0fe7788
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/mock/HelloWorldService.java
@@ -0,0 +1,27 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.assembly.mock;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface HelloWorldService {
+ String hello(String name);
+
+ public int count();
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/mock/HelloWorldWithFieldProperties.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/mock/HelloWorldWithFieldProperties.java
new file mode 100644
index 0000000000..e015e611ae
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/mock/HelloWorldWithFieldProperties.java
@@ -0,0 +1,40 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.assembly.mock;
+
+import org.osoa.sca.annotations.Property;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class HelloWorldWithFieldProperties {
+ @Property
+ private String text;
+
+ @Property(required = true)
+ public Integer text2;
+
+ @Property(name = "foo")
+ public int text3;
+
+ @Property(name = "not exposed")
+ protected int field4;
+
+ public String hello(String name) {
+ return "Hello " + name;
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/mock/NakedHelloWorld.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/mock/NakedHelloWorld.java
new file mode 100644
index 0000000000..2f1ae5d17b
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/mock/NakedHelloWorld.java
@@ -0,0 +1,26 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.assembly.mock;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class NakedHelloWorld {
+ public String hello(String name) {
+ return "Hello " + name;
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/mock/NakedHelloWorldWithInterface.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/mock/NakedHelloWorldWithInterface.java
new file mode 100644
index 0000000000..9d5fe5e969
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/mock/NakedHelloWorldWithInterface.java
@@ -0,0 +1,28 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.assembly.mock;
+
+import java.io.Serializable;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class NakedHelloWorldWithInterface implements Serializable {
+ public String hello(String name) {
+ return "Hello " + name;
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/JavaAssemblyLoaderTestCase.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/JavaAssemblyLoaderTestCase.java
new file mode 100644
index 0000000000..d5cea8bea2
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/JavaAssemblyLoaderTestCase.java
@@ -0,0 +1,88 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.assembly.tests;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.common.resource.ResourceLoader;
+import org.apache.tuscany.common.resource.impl.ResourceLoaderImpl;
+import org.apache.tuscany.container.java.assembly.tests.bigbank.account.services.accountdata.AccountDataService;
+import org.apache.tuscany.container.java.loader.JavaSCDLModelLoader;
+import org.apache.tuscany.model.assembly.AssemblyFactory;
+import org.apache.tuscany.model.assembly.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.Component;
+import org.apache.tuscany.model.assembly.EntryPoint;
+import org.apache.tuscany.model.assembly.Module;
+import org.apache.tuscany.model.assembly.impl.AssemblyFactoryImpl;
+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 JavaAssemblyLoaderTestCase extends TestCase {
+
+ /**
+ *
+ */
+ public JavaAssemblyLoaderTestCase() {
+ super();
+ }
+
+ public void testLoader() {
+
+ ResourceLoader resourceLoader=new ResourceLoaderImpl(Thread.currentThread().getContextClassLoader());
+ JavaSCDLModelLoader javaLoader=new JavaSCDLModelLoader();
+ List<SCDLModelLoader> scdlLoaders=new ArrayList<SCDLModelLoader>();
+ scdlLoaders.add(javaLoader);
+ AssemblyModelLoader assemblyLoader=new SCDLAssemblyModelLoaderImpl(scdlLoaders);
+ AssemblyFactory assemblyFactory=new AssemblyFactoryImpl();
+ AssemblyModelContext modelContext=new AssemblyModelContextImpl(assemblyFactory, assemblyLoader, resourceLoader);
+
+ Module module = assemblyLoader.loadModule(getClass().getResource("sca.module").toString());
+ module.initialize(modelContext);
+ Assert.assertTrue(module.getName().equals("tuscany.container.java.assembly.tests.bigbank.account"));
+
+ Component component=module.getComponent("AccountServiceComponent");
+ Assert.assertTrue(component!= null);
+
+ EntryPoint entryPoint=module.getEntryPoint("AccountService");
+ Assert.assertTrue(entryPoint!= null);
+
+ Object value = component.getConfiguredProperty("currency").getValue();
+ Assert.assertTrue(value.equals("EURO"));
+
+ //ConfiguredService configuredService = component.getConfiguredReference("accountDataService").getTargetConfiguredServices().get(0);
+ //Assert.assertTrue(configuredService.getAggregatePart().getName().equals("AccountDataServiceComponent"));
+
+ Class interfaceClass = component.getConfiguredReference("accountDataService").getReference().getServiceContract().getInterface();
+ Assert.assertTrue(interfaceClass == AccountDataService.class);
+
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/account/AccountReport.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/account/AccountReport.java
new file mode 100644
index 0000000000..1770c2b011
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/account/AccountReport.java
@@ -0,0 +1,32 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.assembly.tests.bigbank.account.services.account;
+
+import java.util.List;
+
+/**
+ * @model
+ */
+
+public interface AccountReport {
+
+ /**
+ * @model type="services.account.AccountSummary"
+ */
+
+ List getAccountSummaries();
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/account/AccountService.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/account/AccountService.java
new file mode 100644
index 0000000000..1bb938655f
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/account/AccountService.java
@@ -0,0 +1,25 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.assembly.tests.bigbank.account.services.account;
+
+import org.osoa.sca.annotations.Remotable;
+
+@Remotable
+public interface AccountService {
+
+ public AccountReport getAccountReport(String customerID);
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/account/AccountService.wsdl b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/account/AccountService.wsdl
new file mode 100644
index 0000000000..921218c5b9
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/account/AccountService.wsdl
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
+
+ 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.
+ -->
+<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:tns="http://www.bigbank.com/AccountService/"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://www.bigbank.com/AccountService/"
+
+ name="AccountService">
+
+ <wsdl:types>
+ <xsd:schema targetNamespace="http://www.bigbank.com/AccountService/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <xsd:element name="customerID" type="xsd:string"/>
+ <xsd:element name="getAccountReportResponse" type="tns:AccountReport"/>
+
+ <xsd:complexType name="AccountReport">
+ <xsd:sequence>
+ <xsd:element name="accountSummary" type="tns:AccountSummary" maxOccurs="unbounded"/>
+ </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:customerID" 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="AccountServiceSOAP" type="tns:AccountService">
+ <soap:binding style="document"
+ transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="getAccountReport">
+ <soap:operation
+ soapAction="http://www.bigbank.com/AccountService/getAccountReport"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="AccountService">
+ <wsdl:port binding="tns:AccountServiceSOAP"
+ name="AccountServiceSOAP">
+ <soap:address location=""/>
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/account/AccountServiceImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/account/AccountServiceImpl.java
new file mode 100644
index 0000000000..9a5ddb0005
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/account/AccountServiceImpl.java
@@ -0,0 +1,42 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.assembly.tests.bigbank.account.services.account;
+
+import org.osoa.sca.annotations.Property;
+import org.osoa.sca.annotations.Reference;
+
+import org.apache.tuscany.container.java.assembly.tests.bigbank.account.services.accountdata.AccountDataService;
+import org.apache.tuscany.container.java.assembly.tests.bigbank.account.services.stockquote.StockQuoteService;
+
+public class AccountServiceImpl implements AccountService {
+
+ @Property
+ public String currency = "USD";
+
+ @Reference
+ public AccountDataService accountDataService;
+ @Reference
+ public StockQuoteService stockQuoteService;
+
+ public AccountServiceImpl() {
+ }
+
+ public AccountReport getAccountReport(String customerID) {
+ return null;
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/account/AccountSummary.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/account/AccountSummary.java
new file mode 100644
index 0000000000..2b11e23425
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/account/AccountSummary.java
@@ -0,0 +1,46 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.assembly.tests.bigbank.account.services.account;
+
+/**
+ * @model
+ */
+
+public interface AccountSummary {
+
+ /**
+ * @model
+ */
+ String getAccountNumber();
+
+ void setAccountNumber(String accountNumber);
+
+ /**
+ * @model
+ */
+ String getAccountType();
+
+ void setAccountType(String accountType);
+
+ /**
+ * @model
+ */
+ float getBalance();
+
+ void setBalance(float balance);
+}
+
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/accountdata/AccountDataService.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/accountdata/AccountDataService.java
new file mode 100644
index 0000000000..56f24ea4ac
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/accountdata/AccountDataService.java
@@ -0,0 +1,26 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.assembly.tests.bigbank.account.services.accountdata;
+
+public interface AccountDataService {
+
+ CheckingAccount getCheckingAccount(String customerID);
+
+ SavingsAccount getSavingsAccount(String customerID);
+
+ StockAccount getStockAccount(String customerID);
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/accountdata/AccountDataServiceImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/accountdata/AccountDataServiceImpl.java
new file mode 100644
index 0000000000..a7a40f954d
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/accountdata/AccountDataServiceImpl.java
@@ -0,0 +1,48 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.assembly.tests.bigbank.account.services.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/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/accountdata/CheckingAccount.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/accountdata/CheckingAccount.java
new file mode 100644
index 0000000000..ff84e9968a
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/accountdata/CheckingAccount.java
@@ -0,0 +1,39 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.assembly.tests.bigbank.account.services.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/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/accountdata/SavingsAccount.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/accountdata/SavingsAccount.java
new file mode 100644
index 0000000000..b39d9051de
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/accountdata/SavingsAccount.java
@@ -0,0 +1,39 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.assembly.tests.bigbank.account.services.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/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/accountdata/StockAccount.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/accountdata/StockAccount.java
new file mode 100644
index 0000000000..bce0821b25
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/accountdata/StockAccount.java
@@ -0,0 +1,48 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.assembly.tests.bigbank.account.services.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/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/stockquote/StockQuoteService.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/stockquote/StockQuoteService.java
new file mode 100644
index 0000000000..78ece12b41
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/stockquote/StockQuoteService.java
@@ -0,0 +1,24 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.assembly.tests.bigbank.account.services.stockquote;
+
+public interface StockQuoteService {
+
+ public float getQuote(String symbol);
+}
+
+ \ No newline at end of file
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/stockquote/StockQuoteServiceImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/stockquote/StockQuoteServiceImpl.java
new file mode 100644
index 0000000000..fa180d0ceb
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/stockquote/StockQuoteServiceImpl.java
@@ -0,0 +1,28 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.assembly.tests.bigbank.account.services.stockquote;
+
+/* Dummy'd up StockQuoteService, override webservice for now */
+
+public class StockQuoteServiceImpl implements StockQuoteService {
+
+ public float getQuote(String symbol) {
+ // Just hardcode for now
+ return 83.00f;
+ }
+
+} \ No newline at end of file
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/stockquote/StockQuoteWebService.wsdl b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/stockquote/StockQuoteWebService.wsdl
new file mode 100644
index 0000000000..9678d9d6ea
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/stockquote/StockQuoteWebService.wsdl
@@ -0,0 +1,98 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
+
+ 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.
+ -->
+<wsdl:definitions targetNamespace="http://webservice.stockquote" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://webservice.stockquote" xmlns:intf="http://webservice.stockquote" xmlns:tns1="http://stockquote" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="">
+ <!--WSDL created by Apache Axis version: 1.2.1
+Built on Jun 14, 2005 (09:15:57 EDT)-->
+ <wsdl:types>
+ <schema elementFormDefault="qualified" targetNamespace="http://stockquote" xmlns="http://www.w3.org/2001/XMLSchema">
+ <complexType name="GetQuoteRequest">
+ <sequence>
+ <element name="symbol" nillable="true" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ <complexType name="GetQuoteResponse">
+ <sequence>
+ <element name="price" type="xsd:float"/>
+ </sequence>
+ </complexType>
+ </schema>
+ <schema elementFormDefault="qualified" targetNamespace="http://webservice.stockquote" xmlns="http://www.w3.org/2001/XMLSchema">
+ <import namespace="http://stockquote"/>
+ <element name="request" type="tns1:GetQuoteRequest"/>
+ <element name="getQuoteReturn" type="tns1:GetQuoteResponse"/>
+ </schema>
+ </wsdl:types>
+
+ <wsdl:message name="getQuoteResponse">
+
+ <wsdl:part element="impl:getQuoteReturn" name="getQuoteReturn"/>
+
+ </wsdl:message>
+
+ <wsdl:message name="getQuoteRequest">
+
+ <wsdl:part element="impl:request" name="request"/>
+
+ </wsdl:message>
+
+ <wsdl:portType name="StockQuoteWebService">
+
+ <wsdl:operation name="getQuote" parameterOrder="request">
+
+ <wsdl:input message="impl:getQuoteRequest" name="getQuoteRequest"/>
+
+ <wsdl:output message="impl:getQuoteResponse" name="getQuoteResponse"/>
+
+ </wsdl:operation>
+
+ </wsdl:portType>
+
+ <wsdl:binding name="StockQuoteWebServiceSoapBinding" type="impl:StockQuoteWebService">
+
+ <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+
+ <wsdl:operation name="getQuote">
+
+ <wsdlsoap:operation soapAction=""/>
+
+ <wsdl:input name="getQuoteRequest">
+
+ <wsdlsoap:body use="literal"/>
+
+ </wsdl:input>
+
+ <wsdl:output name="getQuoteResponse">
+
+ <wsdlsoap:body use="literal"/>
+
+ </wsdl:output>
+
+ </wsdl:operation>
+
+ </wsdl:binding>
+
+ <wsdl:service name="StockQuoteWebServiceService">
+
+ <wsdl:port binding="impl:StockQuoteWebServiceSoapBinding" name="StockQuoteWebService">
+
+ <wsdlsoap:address location="http://localhost:8123/StockQuoteWebService/services/StockQuoteWebService"/>
+
+ </wsdl:port>
+
+ </wsdl:service>
+
+</wsdl:definitions>
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/builder/JavaComponentContextBuilderTestCase.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/builder/JavaComponentContextBuilderTestCase.java
new file mode 100644
index 0000000000..4459e9d01d
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/builder/JavaComponentContextBuilderTestCase.java
@@ -0,0 +1,111 @@
+package org.apache.tuscany.container.java.builder;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.common.monitor.impl.NullMonitorFactory;
+import org.apache.tuscany.container.java.invocation.mock.MockSyncInterceptor;
+import org.apache.tuscany.container.java.mock.MockConfigContext;
+import org.apache.tuscany.container.java.mock.MockFactory;
+import org.apache.tuscany.container.java.mock.components.GenericComponent;
+import org.apache.tuscany.container.java.mock.components.ModuleScopeComponent;
+import org.apache.tuscany.core.builder.RuntimeConfiguration;
+import org.apache.tuscany.core.builder.impl.DefaultWireBuilder;
+import org.apache.tuscany.core.context.AggregateContext;
+import org.apache.tuscany.core.context.EventContext;
+import org.apache.tuscany.core.context.InstanceContext;
+import org.apache.tuscany.core.context.ScopeContext;
+import org.apache.tuscany.core.context.ScopeStrategy;
+import org.apache.tuscany.core.context.impl.AggregateContextImpl;
+import org.apache.tuscany.core.context.impl.EventContextImpl;
+import org.apache.tuscany.core.context.scope.DefaultScopeStrategy;
+import org.apache.tuscany.core.context.scope.ModuleScopeContext;
+import org.apache.tuscany.core.invocation.ProxyConfiguration;
+import org.apache.tuscany.core.invocation.jdk.JDKProxyFactoryFactory;
+import org.apache.tuscany.core.invocation.spi.ProxyFactory;
+import org.apache.tuscany.core.message.impl.MessageFactoryImpl;
+import org.apache.tuscany.model.assembly.AssemblyFactory;
+import org.apache.tuscany.model.assembly.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.Component;
+import org.apache.tuscany.model.assembly.Module;
+import org.apache.tuscany.model.assembly.impl.AssemblyFactoryImpl;
+import org.apache.tuscany.model.assembly.impl.AssemblyModelContextImpl;
+
+public class JavaComponentContextBuilderTestCase extends TestCase {
+
+ private AssemblyFactory factory = new AssemblyFactoryImpl();
+
+ private AssemblyModelContext assemblyContext = new AssemblyModelContextImpl(null,null);
+
+ public JavaComponentContextBuilderTestCase() {
+ }
+
+ public void testBuilder() throws Exception {
+ JavaComponentContextBuilder builder = new JavaComponentContextBuilder();
+ builder.setMessageFactory(new MessageFactoryImpl());
+ // HierarchicalBuilder refBuilder = new HierarchicalBuilder();
+ MockSyncInterceptor interceptor = new MockSyncInterceptor();
+ builder.addPolicyBuilder(new MockInterceptorBuilder(interceptor, true));
+ //builder.setPolicyBuilder(refBuilder);
+ AggregateContext ctx = createContext();
+ builder.setProxyFactoryFactory(new JDKProxyFactoryFactory());
+ JavaTargetWireBuilder javaWireBuilder = new JavaTargetWireBuilder();
+ ScopeStrategy strategy = new DefaultScopeStrategy();
+ DefaultWireBuilder wireBuilder = new DefaultWireBuilder();
+ wireBuilder.addWireBuilder(javaWireBuilder);
+ Module module = MockFactory.createModule();
+ EventContext eCtx = new EventContextImpl();
+ ScopeContext scopeContext = new ModuleScopeContext(eCtx);
+ scopeContext.start();
+ scopeContext.onEvent(EventContext.MODULE_START, null);
+ List<Component> components = module.getComponents();
+ Map<String, Component> compMap = new HashMap(components.size());
+
+ for (Component component : components) {
+ compMap.put(component.getName(), component);
+ builder.build(component, ctx);
+ RuntimeConfiguration config = (RuntimeConfiguration) component.getComponentImplementation().getRuntimeConfiguration();
+ Assert.assertNotNull(config);
+ }
+ for (Component component : components) {
+ RuntimeConfiguration source = (RuntimeConfiguration) component.getComponentImplementation().getRuntimeConfiguration();
+ Assert.assertNotNull(source);
+ for (ProxyFactory pFactory : (Collection<ProxyFactory>) source.getSourceProxyFactories().values()) {
+ ProxyConfiguration pConfig = pFactory.getProxyConfiguration();
+ Component target = compMap.get(pConfig.getTargetName().getPartName());
+
+ if (target != null) {
+ RuntimeConfiguration targetConfig = (RuntimeConfiguration) target.getComponentImplementation()
+ .getRuntimeConfiguration();
+ boolean downScope = strategy.downScopeReference(source.getScope(), targetConfig.getScope());
+ wireBuilder.connect(pFactory, targetConfig.getTargetProxyFactory(pFactory.getProxyConfiguration().getTargetName()
+ .getPortName()), targetConfig.getClass(), downScope, scopeContext);
+ }
+ pFactory.initialize();
+ }
+
+ scopeContext.registerConfiguration(source);
+ }
+ for (Component component : components) {
+ RuntimeConfiguration config = (RuntimeConfiguration) component.getComponentImplementation().getRuntimeConfiguration();
+ InstanceContext context = (InstanceContext) config.createInstanceContext();
+ if ("source".equals(component.getName())) {
+ ModuleScopeComponent source = (ModuleScopeComponent) context.getInstance(null);
+ Assert.assertNotNull(source);
+ GenericComponent gComp = (GenericComponent) source.getGenericComponent();
+ gComp.getString();
+ }
+ }
+ }
+
+ private static AggregateContext createContext() {
+ return new AggregateContextImpl("test.parent", null, new DefaultScopeStrategy(), new EventContextImpl(),
+ new MockConfigContext(null), new NullMonitorFactory());
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/builder/JavaTargetWireBuilderTestCase.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/builder/JavaTargetWireBuilderTestCase.java
new file mode 100644
index 0000000000..c5b1ecd4fd
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/builder/JavaTargetWireBuilderTestCase.java
@@ -0,0 +1,115 @@
+package org.apache.tuscany.container.java.builder;
+
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.container.java.config.JavaComponentRuntimeConfiguration;
+import org.apache.tuscany.container.java.invocation.mock.MockHandler;
+import org.apache.tuscany.container.java.invocation.mock.MockSyncInterceptor;
+import org.apache.tuscany.container.java.invocation.mock.SimpleTarget;
+import org.apache.tuscany.container.java.invocation.mock.SimpleTargetImpl;
+import org.apache.tuscany.container.java.mock.MockScopeContext;
+import org.apache.tuscany.core.builder.impl.DefaultWireBuilder;
+import org.apache.tuscany.core.context.QualifiedName;
+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.jdk.JDKProxyFactory;
+import org.apache.tuscany.core.invocation.spi.ProxyFactory;
+import org.apache.tuscany.core.message.Message;
+import org.apache.tuscany.core.message.MessageFactory;
+import org.apache.tuscany.core.message.impl.MessageFactoryImpl;
+
+public class JavaTargetWireBuilderTestCase extends TestCase {
+
+ private Method hello;
+ private Method goodbye;
+
+ public JavaTargetWireBuilderTestCase() {
+ }
+
+ public JavaTargetWireBuilderTestCase(String arg0) {
+ super(arg0);
+ }
+
+ public void setUp() throws Exception {
+ hello = SimpleTarget.class.getMethod("hello", new Class[] { String.class });
+ goodbye = SimpleTarget.class.getMethod("goodbye", new Class[] { String.class });
+ }
+
+
+ /**
+ * Tests basic wiring of a source to a target, including handlers and interceptors
+ */
+ public void testInvocation() throws Exception {
+ MessageFactory msgFactory = new MessageFactoryImpl();
+
+ InvocationConfiguration source = new InvocationConfiguration(hello);
+ MockHandler sourceRequestHandler = new MockHandler();
+ MockHandler sourceResponseHandler = new MockHandler();
+ MockSyncInterceptor sourceInterceptor = new MockSyncInterceptor();
+ source.addRequestHandler(sourceRequestHandler);
+ source.addResponseHandler(sourceResponseHandler);
+ source.addSourceInterceptor(sourceInterceptor);
+
+ ProxyFactory sourceFactory = new JDKProxyFactory();
+ Map<Method, InvocationConfiguration> sourceInvocationConfigs = new MethodHashMap();
+ sourceInvocationConfigs.put(hello, source);
+ ProxyConfiguration sourceConfig = new ProxyConfiguration(new QualifiedName("target/SimpleTarget"),
+ sourceInvocationConfigs, Thread.currentThread().getContextClassLoader(), msgFactory);
+ sourceFactory.setProxyConfiguration(sourceConfig);
+ sourceFactory.setBusinessInterface(SimpleTarget.class);
+
+ InvocationConfiguration target = new InvocationConfiguration(hello);
+ MockHandler targetRequestHandler = new MockHandler();
+ MockHandler targetResponseHandler = new MockHandler();
+ MockSyncInterceptor targetInterceptor = new MockSyncInterceptor();
+ target.addRequestHandler(targetRequestHandler);
+ target.addResponseHandler(targetResponseHandler);
+ target.addTargetInterceptor(targetInterceptor);
+ target.addTargetInterceptor(new InvokerInterceptor());
+
+ ProxyFactory targetFactory = new JDKProxyFactory();
+ Map<Method, InvocationConfiguration> targetInvocationConfigs = new MethodHashMap();
+ targetInvocationConfigs.put(hello, target);
+ ProxyConfiguration targetConfig = new ProxyConfiguration(new QualifiedName("target/SimpleTarget"),
+ targetInvocationConfigs, Thread.currentThread().getContextClassLoader(), msgFactory);
+ targetFactory.setProxyConfiguration(targetConfig);
+ targetFactory.setBusinessInterface(SimpleTarget.class);
+
+ // bootstrap a scope container with the target in it
+ Map<String,Object> instances = new HashMap();
+ SimpleTarget simpleTarget = new SimpleTargetImpl();
+ instances.put("target",simpleTarget);
+ MockScopeContext scopeCtx = new MockScopeContext(instances);
+
+ // connect the source to the target
+ DefaultWireBuilder builder = new DefaultWireBuilder();
+ builder.addWireBuilder(new JavaTargetWireBuilder());
+
+ builder.connect(sourceFactory, targetFactory, JavaComponentRuntimeConfiguration.class, true, scopeCtx);
+ source.build();
+ target.build();
+ Assert.assertNotNull(source.getTargetInvoker());
+
+ Message msg = msgFactory.createMessage();
+ msg.setBody("foo");
+ msg.setTargetInvoker(source.getTargetInvoker());
+ Message response = (Message) source.getSourceInterceptor().invoke(msg);
+ Assert.assertEquals("foo", response.getBody());
+ Assert.assertEquals(1, sourceRequestHandler.getCount());
+ Assert.assertEquals(1, sourceResponseHandler.getCount());
+ Assert.assertEquals(1, sourceInterceptor.getCount());
+ Assert.assertEquals(1, targetRequestHandler.getCount());
+ Assert.assertEquals(1, targetResponseHandler.getCount());
+ Assert.assertEquals(1, targetInterceptor.getCount());
+ }
+
+
+}
+
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/builder/MockHandlerBuilder.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/builder/MockHandlerBuilder.java
new file mode 100644
index 0000000000..939d780e0f
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/builder/MockHandlerBuilder.java
@@ -0,0 +1,86 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.builder;
+
+import org.apache.tuscany.core.builder.BuilderException;
+import org.apache.tuscany.core.builder.RuntimeConfigurationBuilder;
+import org.apache.tuscany.core.context.Context;
+import org.apache.tuscany.core.invocation.InvocationConfiguration;
+import org.apache.tuscany.core.invocation.MessageHandler;
+import org.apache.tuscany.core.invocation.spi.ProxyFactory;
+import org.apache.tuscany.model.assembly.AssemblyModelObject;
+import org.apache.tuscany.model.assembly.ConfiguredReference;
+import org.apache.tuscany.model.assembly.ConfiguredService;
+
+/**
+ * Adds a handler to a source or target proxy configuration
+ *
+ * @version $Rev$ $Date$
+ */
+public class MockHandlerBuilder implements RuntimeConfigurationBuilder {
+
+ private MessageHandler handler;
+
+ private boolean source;
+
+ private boolean request;
+
+ /**
+ * Creates the builder.
+ *
+ * @param handler the handler to add to the source or target proxy configuration
+ * @param source true if the handler should be added on the source side; false if the handler should be added to the
+ * target side
+ * @param request true if the handler is a request handler; false if the handler is a response handler
+ */
+ public MockHandlerBuilder(MessageHandler handler, boolean source, boolean request) {
+ this.handler = handler;
+ this.source = source;
+ this.request = request;
+ }
+
+ public void build(AssemblyModelObject modelObject, Context context) throws BuilderException {
+ if (source) {
+ if (!(modelObject instanceof ConfiguredReference)) {
+ return;
+ } else {
+ ConfiguredReference cref = (ConfiguredReference) modelObject;
+ ProxyFactory pFactory = (ProxyFactory) cref.getProxyFactory();
+ for (InvocationConfiguration config : pFactory.getProxyConfiguration().getInvocationConfigurations().values()) {
+ if (request) {
+ config.addRequestHandler(handler);
+ } else {
+ config.addResponseHandler(handler);
+ }
+ }
+ }
+ } else {
+ if (!(modelObject instanceof ConfiguredService)) {
+ return;
+ } else {
+ ConfiguredService cservice = (ConfiguredService) modelObject;
+ ProxyFactory pFactory = (ProxyFactory) cservice.getProxyFactory();
+ for (InvocationConfiguration config : pFactory.getProxyConfiguration().getInvocationConfigurations().values()) {
+ if (request) {
+ config.addRequestHandler(handler);
+ } else {
+ config.addResponseHandler(handler);
+ }
+ }
+ }
+
+ }
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/builder/MockInterceptorBuilder.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/builder/MockInterceptorBuilder.java
new file mode 100644
index 0000000000..8bf6ed9e27
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/builder/MockInterceptorBuilder.java
@@ -0,0 +1,74 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.builder;
+
+import org.apache.tuscany.core.builder.BuilderException;
+import org.apache.tuscany.core.builder.RuntimeConfigurationBuilder;
+import org.apache.tuscany.core.context.Context;
+import org.apache.tuscany.core.invocation.Interceptor;
+import org.apache.tuscany.core.invocation.InvocationConfiguration;
+import org.apache.tuscany.core.invocation.spi.ProxyFactory;
+import org.apache.tuscany.model.assembly.AssemblyModelObject;
+import org.apache.tuscany.model.assembly.ConfiguredReference;
+import org.apache.tuscany.model.assembly.ConfiguredService;
+
+/**
+ * Adds an interceptor to a source or target proxy configuration
+ *
+ * @version $Rev$ $Date$
+ */
+public class MockInterceptorBuilder implements RuntimeConfigurationBuilder {
+
+ private Interceptor interceptor;
+
+ private boolean source;
+
+ /**
+ * Creates the builder
+ *
+ * @param interceptor the interceptor ot add
+ * @param source true if the interceptor should be added to the source side; false if the interceptor should be
+ * added to the target side
+ */
+ public MockInterceptorBuilder(Interceptor interceptor, boolean source) {
+ this.interceptor = interceptor;
+ this.source = source;
+ }
+
+ public void build(AssemblyModelObject modelObject, Context context) throws BuilderException {
+ if (source) {
+ if (!(modelObject instanceof ConfiguredReference)) {
+ return;
+ } else {
+ ConfiguredReference cref = (ConfiguredReference) modelObject;
+ ProxyFactory pFactory = (ProxyFactory) cref.getProxyFactory();
+ for (InvocationConfiguration config : pFactory.getProxyConfiguration().getInvocationConfigurations().values()) {
+ config.addSourceInterceptor(interceptor);
+ }
+ }
+ } else {
+ if (!(modelObject instanceof ConfiguredService)) {
+ return;
+ } else {
+ ConfiguredService cservice = (ConfiguredService) modelObject;
+ ProxyFactory pFactory = (ProxyFactory) cservice.getProxyFactory();
+ for (InvocationConfiguration config : pFactory.getProxyConfiguration().getInvocationConfigurations().values()) {
+ config.addTargetInterceptor(interceptor);
+ }
+ }
+
+ }
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/config/ModuleComponentConfigurationLoaderTestCase.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/config/ModuleComponentConfigurationLoaderTestCase.java
new file mode 100644
index 0000000000..1e8d7ebb9b
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/config/ModuleComponentConfigurationLoaderTestCase.java
@@ -0,0 +1,80 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.config;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.common.resource.impl.ResourceLoaderImpl;
+import org.apache.tuscany.container.java.assembly.impl.JavaImplementationImpl;
+import org.apache.tuscany.container.java.loader.JavaSCDLModelLoader;
+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.model.assembly.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.Component;
+import org.apache.tuscany.model.assembly.ComponentImplementation;
+import org.apache.tuscany.model.assembly.Module;
+import org.apache.tuscany.model.assembly.ModuleComponent;
+import org.apache.tuscany.model.assembly.impl.AssemblyFactoryImpl;
+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;
+
+/**
+ * @version $Rev: 379821 $ $Date: 2006-02-22 09:25:32 -0800 (Wed, 22 Feb 2006) $
+ */
+public class ModuleComponentConfigurationLoaderTestCase extends TestCase {
+ private ModuleComponentConfigurationLoader loader;
+ private AssemblyModelContext modelContext;
+
+ public void testFoo() throws ConfigurationException {
+ URL xml = ModuleComponentConfigurationLoaderTestCase.class.getResource("ModuleComponentLoaderTest1.module");
+ ModuleComponent moduleComponent = loader.loadModuleComponent("test", "test", xml.toString());
+
+ Assert.assertEquals("test", moduleComponent.getName());
+ Module module = moduleComponent.getModuleImplementation();
+ Assert.assertEquals("ModuleComponentLoaderTest1", module.getName());
+ List<Component> components = module.getComponents();
+ Assert.assertEquals(1, components.size());
+ Component component = components.get(0);
+ Assert.assertEquals("HelloWorldServiceComponent", component.getName());
+
+ component = module.getComponent("HelloWorldServiceComponent");
+ Assert.assertEquals("HelloWorldServiceComponent", component.getName());
+
+ ComponentImplementation implementation = component.getComponentImplementation();
+ Assert.assertTrue(implementation instanceof JavaImplementationImpl);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
+ List<SCDLModelLoader> scdlLoaders=new ArrayList<SCDLModelLoader>();
+ JavaSCDLModelLoader javaLoader=new JavaSCDLModelLoader();
+ scdlLoaders.add(javaLoader);
+ AssemblyModelLoader modelLoader=new SCDLAssemblyModelLoaderImpl(scdlLoaders);
+ modelContext=new AssemblyModelContextImpl(new AssemblyFactoryImpl(), modelLoader,
+ new ResourceLoaderImpl(this.getClass().getClassLoader()));
+ loader = new ModuleComponentConfigurationLoaderImpl(modelContext);
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/context/BadPojoTestCase.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/context/BadPojoTestCase.java
new file mode 100644
index 0000000000..56567e9535
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/context/BadPojoTestCase.java
@@ -0,0 +1,70 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.context;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.container.java.mock.MockFactory;
+import org.apache.tuscany.container.java.mock.components.BadContextPojo;
+import org.apache.tuscany.container.java.mock.components.BadNamePojo;
+import org.apache.tuscany.core.context.AggregateContext;
+import org.apache.tuscany.core.context.impl.AggregateContextImpl;
+import org.apache.tuscany.model.assembly.Scope;
+
+public class BadPojoTestCase extends TestCase {
+
+ /**
+ * Tests that a pojo with <code>@ComponentName</code> specified on a non-String type generates an error.
+ * <p/>
+ * <strong>NB:</strong> the test assumes an error with a message containing
+ * "@ComponentName" is generated
+ */
+ public void testBadNameType() throws Exception {
+ AggregateContext mc = new AggregateContextImpl();
+ mc.setName("mc");
+ try {
+ JavaComponentContext context = MockFactory.createPojoContext("BadNamePojo", BadNamePojo.class,
+ Scope.MODULE, mc);
+ } catch (NoSuchMethodException e) {
+ if (e.getMessage().indexOf("@ComponentName") < 0) {
+ throw e;
+ }
+ }
+
+ }
+
+ /**
+ * Tests that a pojo with <code>@Context</code> specified on a non-ModuleContext type generates an error.
+ * <p/>
+ * <strong>NB:</strong> the test assumes an error with a message containing
+ * "@Context" is generated
+ */
+ public void testContextType() throws Exception {
+ AggregateContext mc = new AggregateContextImpl();
+ mc.setName("mc");
+ try {
+ JavaComponentContext context = MockFactory.createPojoContext("BadContextPojo", BadContextPojo.class,
+ Scope.MODULE, mc);
+ } catch (NoSuchMethodException e) {
+ if (e.getMessage().indexOf("@Context") < 0) {
+ throw e;
+ }
+ }
+
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/context/PojoLifecycleTestCase.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/context/PojoLifecycleTestCase.java
new file mode 100644
index 0000000000..113351c592
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/context/PojoLifecycleTestCase.java
@@ -0,0 +1,71 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.context;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.container.java.mock.MockFactory;
+import org.apache.tuscany.container.java.mock.components.ModuleScopeInitOnlyComponent;
+import org.apache.tuscany.core.context.AggregateContext;
+import org.apache.tuscany.core.context.impl.AggregateContextImpl;
+import org.apache.tuscany.model.assembly.Scope;
+
+/**
+ * Tests <code>@Init</code> method called, <code>@Context</code> set for ModuleContext, <code>@ComponentName</code> set
+ *
+ * @version $Rev$ $Date$
+ */
+public class PojoLifecycleTestCase extends TestCase {
+
+ public void testComponentNameSet() throws Exception {
+ AggregateContext mc = new AggregateContextImpl();
+ mc.setName("mc");
+ JavaComponentContext context = MockFactory.createPojoContext("TestServiceInit",
+ ModuleScopeInitOnlyComponent.class, Scope.MODULE, mc);
+ context.start();
+ ModuleScopeInitOnlyComponent instance = (ModuleScopeInitOnlyComponent) context.getInstance(null);
+ Assert.assertNotNull(instance);
+ Assert.assertEquals("TestServiceInit", instance.getName());
+ context.stop();
+ }
+
+ public void testModuleContextSet() throws Exception {
+ AggregateContext mc = new AggregateContextImpl();
+ mc.setName("mc");
+ JavaComponentContext context = MockFactory.createPojoContext("TestServiceInit",
+ ModuleScopeInitOnlyComponent.class, Scope.MODULE, mc);
+ context.start();
+ ModuleScopeInitOnlyComponent instance = (ModuleScopeInitOnlyComponent) context.getInstance(null);
+ Assert.assertNotNull(instance);
+ Assert.assertEquals(mc, instance.getModuleContext());
+ context.stop();
+ }
+
+ public void testInit() throws Exception {
+ AggregateContext mc = new AggregateContextImpl();
+ mc.setName("mc");
+ JavaComponentContext context = MockFactory.createPojoContext("TestServiceInit",
+ ModuleScopeInitOnlyComponent.class, Scope.MODULE, mc);
+ context.start();
+ ModuleScopeInitOnlyComponent instance = (ModuleScopeInitOnlyComponent) context.getInstance(null);
+ Assert.assertNotNull(instance);
+ Assert.assertTrue(instance.isInitialized());
+ context.stop();
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/context/PojoTestCase.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/context/PojoTestCase.java
new file mode 100644
index 0000000000..5c30ad02a7
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/context/PojoTestCase.java
@@ -0,0 +1,94 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.context;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.container.java.assembly.JavaAssemblyFactory;
+import org.apache.tuscany.container.java.assembly.impl.JavaAssemblyFactoryImpl;
+import org.apache.tuscany.container.java.context.JavaComponentContext;
+import org.apache.tuscany.container.java.mock.components.GenericComponent;
+import org.apache.tuscany.container.java.mock.components.ModuleScopeComponentImpl;
+import org.apache.tuscany.container.java.mock.components.RequestScopeComponentImpl;
+import org.apache.tuscany.container.java.mock.components.SessionScopeComponentImpl;
+import org.apache.tuscany.container.java.mock.components.StatelessComponentImpl;
+import org.apache.tuscany.core.config.JavaIntrospectionHelper;
+import org.apache.tuscany.core.context.AggregateContext;
+import org.apache.tuscany.core.context.impl.AggregateContextImpl;
+import org.apache.tuscany.core.injection.PojoObjectFactory;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class PojoTestCase extends TestCase {
+
+ JavaAssemblyFactory factory = new JavaAssemblyFactoryImpl();
+
+ public void testGetModuleInstance() throws Exception {
+ AggregateContext mc = new AggregateContextImpl();
+ mc.setName("mc");
+ JavaComponentContext c = new JavaComponentContext("foo", new PojoObjectFactory(JavaIntrospectionHelper
+ .getDefaultConstructor(ModuleScopeComponentImpl.class), null, null), false, null, null, false);
+ GenericComponent service = (GenericComponent) c.getInstance(null);
+ Assert.assertNotNull(service);
+ service.setString("foo");
+ GenericComponent service2 = (GenericComponent) c.getInstance(null);
+ Assert.assertNotNull(service2);
+ Assert.assertSame(service, service2);
+ }
+
+ public void testGetSessionInstance() throws Exception {
+ AggregateContext mc = new AggregateContextImpl();
+ mc.setName("mc");
+ JavaComponentContext c = new JavaComponentContext("foo", new PojoObjectFactory(JavaIntrospectionHelper
+ .getDefaultConstructor(SessionScopeComponentImpl.class), null, null), false, null, null, false);
+ GenericComponent service = (GenericComponent) c.getInstance(null);
+ Assert.assertNotNull(service);
+ service.setString("foo");
+ GenericComponent service2 = (GenericComponent) c.getInstance(null);
+ Assert.assertNotNull(service2);
+ Assert.assertSame(service, service2);
+ }
+
+ public void testGetRequestInstance() throws Exception {
+ AggregateContext mc = new AggregateContextImpl();
+ mc.setName("mc");
+ JavaComponentContext c = new JavaComponentContext("foo", new PojoObjectFactory(JavaIntrospectionHelper
+ .getDefaultConstructor(RequestScopeComponentImpl.class), null, null), false, null, null, false);
+ GenericComponent service = (GenericComponent) c.getInstance(null);
+ Assert.assertNotNull(service);
+ service.setString("foo");
+ GenericComponent service2 = (GenericComponent) c.getInstance(null);
+ Assert.assertNotNull(service2);
+ Assert.assertSame(service, service2);
+ }
+
+ public void testGetStatelessInstance() throws Exception {
+ AggregateContext mc = new AggregateContextImpl();
+ mc.setName("fooContext");
+ JavaComponentContext c = new JavaComponentContext("foo", new PojoObjectFactory(JavaIntrospectionHelper
+ .getDefaultConstructor(StatelessComponentImpl.class), null, null), false, null, null, true);
+ GenericComponent service = (GenericComponent) c.getInstance(null);
+ Assert.assertNotNull(service);
+ service.setString("foo");
+ GenericComponent service2 = (GenericComponent) c.getInstance(null);
+ Assert.assertNotNull(service2);
+ Assert.assertTrue(!"foo".equals(service2.getString()));
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/integration/JavaBuilderContextIntegrationTestCase.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/integration/JavaBuilderContextIntegrationTestCase.java
new file mode 100644
index 0000000000..b935f19214
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/integration/JavaBuilderContextIntegrationTestCase.java
@@ -0,0 +1,240 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.integration;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.container.java.builder.JavaComponentContextBuilder;
+import org.apache.tuscany.container.java.builder.JavaTargetWireBuilder;
+import org.apache.tuscany.container.java.builder.MockHandlerBuilder;
+import org.apache.tuscany.container.java.builder.MockInterceptorBuilder;
+import org.apache.tuscany.container.java.invocation.mock.MockHandler;
+import org.apache.tuscany.container.java.invocation.mock.MockSyncInterceptor;
+import org.apache.tuscany.container.java.mock.MockFactory;
+import org.apache.tuscany.container.java.mock.components.GenericComponent;
+import org.apache.tuscany.core.builder.RuntimeConfigurationBuilder;
+import org.apache.tuscany.core.builder.impl.DefaultWireBuilder;
+import org.apache.tuscany.core.builder.impl.HierarchicalBuilder;
+import org.apache.tuscany.core.context.AggregateContext;
+import org.apache.tuscany.core.context.EventContext;
+import org.apache.tuscany.core.invocation.jdk.JDKProxyFactoryFactory;
+import org.apache.tuscany.core.invocation.spi.ProxyFactoryFactory;
+import org.apache.tuscany.core.message.MessageFactory;
+import org.apache.tuscany.core.message.impl.MessageFactoryImpl;
+import org.apache.tuscany.core.runtime.RuntimeContext;
+import org.apache.tuscany.core.runtime.RuntimeContextImpl;
+import org.apache.tuscany.core.system.builder.SystemComponentContextBuilder;
+import org.apache.tuscany.core.system.builder.SystemEntryPointBuilder;
+import org.apache.tuscany.core.system.builder.SystemExternalServiceBuilder;
+
+/**
+ * Verifies that the aggregate context implementation and java component builders construct references properly
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaBuilderContextIntegrationTestCase extends TestCase {
+
+ public JavaBuilderContextIntegrationTestCase(String arg0) {
+ super(arg0);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ public void testRefWithSourceInterceptor() throws Exception {
+ MessageFactory msgFactory = new MessageFactoryImpl();
+
+ List<RuntimeConfigurationBuilder> builders = new ArrayList();
+ builders.add((new SystemComponentContextBuilder()));
+ builders.add(new SystemEntryPointBuilder());
+ builders.add(new SystemExternalServiceBuilder());
+
+ ProxyFactoryFactory proxyFactoryFactory =new JDKProxyFactoryFactory();
+
+ JavaComponentContextBuilder javaBuilder = new JavaComponentContextBuilder();
+ javaBuilder.setMessageFactory(msgFactory);
+ javaBuilder.setProxyFactoryFactory(proxyFactoryFactory);
+
+ MockSyncInterceptor mockInterceptor = new MockSyncInterceptor();
+ MockInterceptorBuilder interceptorBuilder = new MockInterceptorBuilder(mockInterceptor, true);
+ //HierarchicalBuilder refBuilder = new HierarchicalBuilder();
+ //refBuilder.addBuilder(interceptorBuilder);
+ javaBuilder.addPolicyBuilder(interceptorBuilder);
+ builders.add(javaBuilder);
+
+ DefaultWireBuilder defaultWireBuilder = new DefaultWireBuilder();
+
+ RuntimeContext runtime = new RuntimeContextImpl(null, null, builders, defaultWireBuilder);
+ runtime.addBuilder(new JavaTargetWireBuilder());
+ runtime.start();
+ runtime.getRootContext().registerModelObject(
+ MockFactory.createAggregateComponent("test.module"));
+ AggregateContext child = (AggregateContext) runtime.getRootContext().getContext("test.module");
+ child.registerModelObject(MockFactory.createModule());
+ child.fireEvent(EventContext.MODULE_START, null);
+ GenericComponent source = (GenericComponent) child.locateInstance("source");
+ Assert.assertNotNull(source);
+ source.getGenericComponent().getString();
+ Assert.assertEquals(1, mockInterceptor.getCount());
+ source.getGenericComponent().getString();
+ Assert.assertEquals(2, mockInterceptor.getCount());
+ child.fireEvent(EventContext.MODULE_STOP, null);
+ runtime.stop();
+ }
+
+ public void testRefWithSourceInterceptorHandler() throws Exception {
+ MessageFactory msgFactory = new MessageFactoryImpl();
+
+ List<RuntimeConfigurationBuilder> builders = new ArrayList();
+ builders.add((new SystemComponentContextBuilder()));
+ builders.add(new SystemEntryPointBuilder());
+ builders.add(new SystemExternalServiceBuilder());
+
+ JavaComponentContextBuilder javaBuilder = new JavaComponentContextBuilder();
+ javaBuilder.setMessageFactory(msgFactory);
+ javaBuilder.setProxyFactoryFactory(new JDKProxyFactoryFactory());
+
+ MockSyncInterceptor mockInterceptor = new MockSyncInterceptor();
+ MockInterceptorBuilder interceptorBuilder = new MockInterceptorBuilder(mockInterceptor, true);
+ //HierarchicalBuilder refBuilder = new HierarchicalBuilder();
+ //refBuilder.addBuilder(interceptorBuilder);
+ MockHandler mockHandler = new MockHandler();
+ MockHandlerBuilder handlerBuilder = new MockHandlerBuilder(mockHandler, true, true);
+ //refBuilder.addBuilder(handlerBuilder);
+ javaBuilder.addPolicyBuilder(interceptorBuilder);
+ javaBuilder.addPolicyBuilder(handlerBuilder);
+
+ //javaBuilder.setPolicyBuilder(refBuilder);
+ builders.add(javaBuilder);
+
+ DefaultWireBuilder defaultWireBuilder = new DefaultWireBuilder();
+ RuntimeContext runtime = new RuntimeContextImpl(null, null, builders, defaultWireBuilder);
+ runtime.addBuilder(new JavaTargetWireBuilder());
+ runtime.start();
+ runtime.getRootContext().registerModelObject(
+ MockFactory.createAggregateComponent("test.module"));
+ AggregateContext child = (AggregateContext) runtime.getRootContext().getContext("test.module");
+ child.registerModelObject(MockFactory.createModule());
+ child.fireEvent(EventContext.MODULE_START, null);
+ GenericComponent source = (GenericComponent) child.locateInstance("source");
+ Assert.assertNotNull(source);
+ source.getGenericComponent().getString();
+ Assert.assertEquals(1, mockInterceptor.getCount());
+ Assert.assertEquals(1, mockHandler.getCount());
+ source.getGenericComponent().getString();
+ Assert.assertEquals(2, mockInterceptor.getCount());
+ Assert.assertEquals(2, mockHandler.getCount());
+ child.fireEvent(EventContext.MODULE_STOP, null);
+ runtime.stop();
+ }
+
+ public void testRefWithTargetInterceptorHandler() throws Exception {
+ MessageFactory msgFactory = new MessageFactoryImpl();
+
+ List<RuntimeConfigurationBuilder> builders = new ArrayList();
+ builders.add((new SystemComponentContextBuilder()));
+ builders.add(new SystemEntryPointBuilder());
+ builders.add(new SystemExternalServiceBuilder());
+
+ JavaComponentContextBuilder javaBuilder = new JavaComponentContextBuilder();
+ javaBuilder.setMessageFactory(msgFactory);
+ javaBuilder.setProxyFactoryFactory(new JDKProxyFactoryFactory());
+
+ MockSyncInterceptor mockInterceptor = new MockSyncInterceptor();
+ MockInterceptorBuilder interceptorBuilder = new MockInterceptorBuilder(mockInterceptor, false);
+ //HierarchicalBuilder refBuilder = new HierarchicalBuilder();
+ //refBuilder.addBuilder(interceptorBuilder);
+ MockHandler mockHandler = new MockHandler();
+ MockHandlerBuilder handlerBuilder = new MockHandlerBuilder(mockHandler, false, true);
+ //refBuilder.addBuilder(handlerBuilder);
+ javaBuilder.addPolicyBuilder(interceptorBuilder);
+ javaBuilder.addPolicyBuilder(handlerBuilder);
+
+ // javaBuilder.setPolicyBuilder(refBuilder);
+ builders.add(javaBuilder);
+
+ DefaultWireBuilder defaultWireBuilder = new DefaultWireBuilder();
+
+ RuntimeContext runtime = new RuntimeContextImpl(null, null, builders, defaultWireBuilder);
+ runtime.addBuilder(new JavaTargetWireBuilder());
+ runtime.start();
+ runtime.getRootContext().registerModelObject(
+ MockFactory.createAggregateComponent("test.module"));
+ AggregateContext child = (AggregateContext) runtime.getRootContext().getContext("test.module");
+ child.registerModelObject(MockFactory.createModule());
+ child.fireEvent(EventContext.MODULE_START, null);
+ GenericComponent source = (GenericComponent) child.locateInstance("source");
+ Assert.assertNotNull(source);
+ source.getGenericComponent().getString();
+ Assert.assertEquals(1, mockInterceptor.getCount());
+ Assert.assertEquals(1, mockHandler.getCount());
+ source.getGenericComponent().getString();
+ Assert.assertEquals(2, mockInterceptor.getCount());
+ Assert.assertEquals(2, mockHandler.getCount());
+ child.fireEvent(EventContext.MODULE_STOP, null);
+ runtime.stop();
+ }
+
+ public void testRefWithTargetInterceptor() throws Exception {
+ MessageFactory msgFactory = new MessageFactoryImpl();
+
+ List<RuntimeConfigurationBuilder> builders = new ArrayList();
+ builders.add((new SystemComponentContextBuilder()));
+ builders.add(new SystemEntryPointBuilder());
+ builders.add(new SystemExternalServiceBuilder());
+
+ JavaComponentContextBuilder javaBuilder = new JavaComponentContextBuilder();
+ javaBuilder.setMessageFactory(msgFactory);
+ javaBuilder.setProxyFactoryFactory(new JDKProxyFactoryFactory());
+
+ MockSyncInterceptor mockInterceptor = new MockSyncInterceptor();
+ MockInterceptorBuilder interceptorBuilder = new MockInterceptorBuilder(mockInterceptor, false);
+ //HierarchicalBuilder refBuilder = new HierarchicalBuilder();
+ //refBuilder.addBuilder(interceptorBuilder);
+ javaBuilder.addPolicyBuilder(interceptorBuilder);
+
+ //javaBuilder.setPolicyBuilder(refBuilder);
+ builders.add(javaBuilder);
+
+ DefaultWireBuilder defaultWireBuilder = new DefaultWireBuilder();
+
+ RuntimeContext runtime = new RuntimeContextImpl(null, null, builders, defaultWireBuilder);
+ runtime.addBuilder(new JavaTargetWireBuilder());
+
+ runtime.start();
+ runtime.getRootContext().registerModelObject(
+ MockFactory.createAggregateComponent("test.module"));
+ AggregateContext child = (AggregateContext) runtime.getRootContext().getContext("test.module");
+ child.registerModelObject(MockFactory.createModule());
+ child.fireEvent(EventContext.MODULE_START, null);
+ GenericComponent source = (GenericComponent) child.locateInstance("source");
+ Assert.assertNotNull(source);
+ source.getGenericComponent().getString();
+ Assert.assertEquals(1, mockInterceptor.getCount());
+ source.getGenericComponent().getString();
+ Assert.assertEquals(2, mockInterceptor.getCount());
+ child.fireEvent(EventContext.MODULE_STOP, null);
+ runtime.stop();
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/integration/JavaIntegrationTestCase.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/integration/JavaIntegrationTestCase.java
new file mode 100644
index 0000000000..795a6fe908
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/integration/JavaIntegrationTestCase.java
@@ -0,0 +1,64 @@
+/**
+ *
+ * Copyright 2005 BEA Systems Inc.
+ * Copyright 2005 International Business Machines Corporation
+ *
+ * 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.container.java.integration;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.container.java.assembly.JavaAssemblyFactory;
+import org.apache.tuscany.container.java.assembly.impl.JavaAssemblyFactoryImpl;
+import org.apache.tuscany.core.runtime.RuntimeContext;
+import org.apache.tuscany.core.runtime.RuntimeContextImpl;
+import org.apache.tuscany.model.assembly.Module;
+import org.apache.tuscany.model.assembly.ModuleComponent;
+
+/**
+ * Integration test that verifies container.java can be used to host components.
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaIntegrationTestCase extends TestCase {
+ private JavaAssemblyFactory factory;
+ private RuntimeContext runtime;
+
+ public void testModuleWithOneComponent() throws Exception {
+ Module module = factory.createModule();
+ ModuleComponent moduleComponent = factory.createModuleComponent();
+ moduleComponent.setModuleImplementation(module);
+
+// runtime.registerModelObject(moduleComponent);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ // Create a factory for model objects
+ factory = new JavaAssemblyFactoryImpl();
+
+ // Create and bootstrap an empty Tuscany runtime
+ this.runtime = new RuntimeContextImpl();
+ this.runtime.start();
+
+// Component component = MockSystemAssemblyFactory.createComponent(RuntimeContext.SYSTEM, SystemAggregateContextImpl.class.getName(), ContextConstants.AGGREGATE_SCOPE_ENUM);
+// runtime.registerModelObject(component);
+ }
+
+ protected void tearDown() throws Exception {
+ runtime.stop();
+ super.tearDown();
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/integration/JavaRuntimeBootstrapTestCase.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/integration/JavaRuntimeBootstrapTestCase.java
new file mode 100644
index 0000000000..d474d9cb4f
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/integration/JavaRuntimeBootstrapTestCase.java
@@ -0,0 +1,54 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.integration;
+
+import org.apache.tuscany.container.java.mock.MockFactory;
+import org.apache.tuscany.container.java.mock.components.GenericComponent;
+import org.apache.tuscany.core.context.AggregateContext;
+import org.apache.tuscany.core.context.EventContext;
+import org.apache.tuscany.core.context.InstanceContext;
+import org.apache.tuscany.core.runtime.RuntimeContext;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+/**
+ * Ensures basic runtime with Java support boots properly
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaRuntimeBootstrapTestCase extends TestCase {
+
+ /**
+ * Tests the runtime can be bootstrapped with Java builders and two module-scoped Java-based components can be wired
+ */
+ public void testRuntimeBoot() throws Exception{
+ RuntimeContext runtime = MockFactory.createJavaRuntime();
+ InstanceContext ctx = runtime.getSystemContext().getContext(MockFactory.SYSTEM_CHILD);
+ Assert.assertNotNull(ctx);
+ runtime.getRootContext().registerModelObject(MockFactory.createAggregateComponent("test"));
+ AggregateContext testCtx = (AggregateContext) runtime.getRootContext().getContext("test");
+ Assert.assertNotNull(testCtx);
+ testCtx.registerModelObject(MockFactory.createModule());
+ testCtx.fireEvent(EventContext.MODULE_START,null);
+ GenericComponent source = (GenericComponent)testCtx.getContext("source").getInstance(null);
+ Assert.assertNotNull(source);
+ GenericComponent target = (GenericComponent)testCtx.getContext("target").getInstance(null);
+ Assert.assertNotNull(target);
+ source.getGenericComponent().getString();
+
+ }
+
+}
+
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/integration/binding/EntryPointToJavaTestCase.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/integration/binding/EntryPointToJavaTestCase.java
new file mode 100644
index 0000000000..a9408ef9ee
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/integration/binding/EntryPointToJavaTestCase.java
@@ -0,0 +1,248 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.integration.binding;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.container.java.assembly.mock.HelloWorldService;
+import org.apache.tuscany.container.java.builder.MockInterceptorBuilder;
+import org.apache.tuscany.container.java.invocation.mock.MockSyncInterceptor;
+import org.apache.tuscany.container.java.mock.MockFactory;
+import org.apache.tuscany.container.java.mock.binding.foo.FooBindingBuilder;
+import org.apache.tuscany.core.context.AggregateContext;
+import org.apache.tuscany.core.context.EntryPointContext;
+import org.apache.tuscany.core.context.EventContext;
+import org.apache.tuscany.core.runtime.RuntimeContext;
+import org.apache.tuscany.model.assembly.Scope;
+
+/**
+ * Tests basic entry point functionality with Java components
+ *
+ * @version $Rev$ $Date$
+ */
+public class EntryPointToJavaTestCase extends TestCase {
+
+ private Method hello;
+
+ public void setUp() throws Exception {
+ hello = HelloWorldService.class.getMethod("hello", new Class[] { String.class });
+ }
+
+ /**
+ * Tests creation and invocation of an entry point wired to a module-scoped service offered by a Java component
+ */
+ public void testEPtoJavaModuleScopeInvoke() throws Throwable {
+ RuntimeContext runtime = MockFactory.registerFooBinding(MockFactory.createJavaRuntime());
+ FooBindingBuilder builder = (FooBindingBuilder) ((AggregateContext) runtime.getSystemContext().getContext(MockFactory.SYSTEM_CHILD))
+ .getContext(MockFactory.FOO_BUILDER).getInstance(null);
+ MockSyncInterceptor mockInterceptor = new MockSyncInterceptor();
+ MockInterceptorBuilder interceptorBuilder = new MockInterceptorBuilder(mockInterceptor, false);
+ builder.addPolicyBuilder(interceptorBuilder);
+ runtime.getRootContext().registerModelObject(MockFactory.createAggregateComponent("test.module"));
+ AggregateContext child = (AggregateContext) runtime.getRootContext().getContext("test.module");
+ child.registerModelObject(MockFactory.createModuleWithEntryPoint(Scope.MODULE));
+ child.fireEvent(EventContext.MODULE_START, null);
+ child.fireEvent(EventContext.REQUEST_START, null);
+ EntryPointContext ctx = (EntryPointContext) child.getContext("source");
+ Assert.assertNotNull(ctx);
+ InvocationHandler handler = (InvocationHandler) ctx.getImplementationInstance();
+ Assert.assertEquals(0, mockInterceptor.getCount());
+ Object response = handler.invoke(null, hello, new Object[] { "foo" });
+ Assert.assertEquals("Hello foo", response);
+ Assert.assertEquals(1, mockInterceptor.getCount());
+ child.fireEvent(EventContext.REQUEST_END, null);
+
+ // second request
+ child.fireEvent(EventContext.REQUEST_START, null);
+ ctx = (EntryPointContext) child.getContext("source");
+ Assert.assertNotNull(ctx);
+ handler = (InvocationHandler) ctx.getImplementationInstance();
+ Assert.assertEquals(1, mockInterceptor.getCount());
+ response = handler.invoke(null, hello, new Object[] { "foo" });
+ Assert.assertEquals("Hello foo", response);
+ Assert.assertEquals(2, mockInterceptor.getCount());
+ HelloWorldService service1 = (HelloWorldService)child.getContext("target").getInstance(null);
+ Assert.assertEquals(2, service1.count());
+ child.fireEvent(EventContext.REQUEST_END, null);
+
+ child.fireEvent(EventContext.MODULE_STOP, null);
+ runtime.stop();
+ }
+
+ /**
+ * Tests creation and invocation of an entry point wired to a session-scoped service offered by a Java component
+ */
+ public void testEPtoJavaSessionScopeInvoke() throws Throwable {
+ RuntimeContext runtime = MockFactory.registerFooBinding(MockFactory.createJavaRuntime());
+ FooBindingBuilder builder = (FooBindingBuilder) ((AggregateContext) runtime.getSystemContext().getContext(MockFactory.SYSTEM_CHILD))
+ .getContext(MockFactory.FOO_BUILDER).getInstance(null);
+ MockSyncInterceptor mockInterceptor = new MockSyncInterceptor();
+ MockInterceptorBuilder interceptorBuilder = new MockInterceptorBuilder(mockInterceptor, false);
+ builder.addPolicyBuilder(interceptorBuilder);
+ runtime.getRootContext().registerModelObject(MockFactory.createAggregateComponent("test.module"));
+ AggregateContext child = (AggregateContext) runtime.getRootContext().getContext("test.module");
+ child.registerModelObject(MockFactory.createModuleWithEntryPoint(Scope.SESSION));
+ child.fireEvent(EventContext.MODULE_START, null);
+
+ // first session
+ Object session = new Object();
+ child.fireEvent(EventContext.REQUEST_START, null);
+ child.fireEvent(EventContext.SESSION_NOTIFY, session);
+
+ EntryPointContext ctx = (EntryPointContext) child.getContext("source");
+ Assert.assertNotNull(ctx);
+ InvocationHandler handler = (InvocationHandler) ctx.getImplementationInstance();
+ Assert.assertEquals(0, mockInterceptor.getCount());
+ Object response = handler.invoke(null, hello, new Object[] { "foo" });
+ Assert.assertEquals("Hello foo", response);
+ Assert.assertEquals(1, mockInterceptor.getCount());
+ child.fireEvent(EventContext.REQUEST_END, session);
+
+ child.fireEvent(EventContext.REQUEST_START, null);
+ child.fireEvent(EventContext.SESSION_NOTIFY, session);
+ EntryPointContext ctx2 = (EntryPointContext) child.getContext("source");
+ Assert.assertNotNull(ctx2);
+ response = handler.invoke(null, hello, new Object[] { "foo" });
+ Assert.assertEquals("Hello foo", response);
+ Assert.assertEquals(2, mockInterceptor.getCount());
+ HelloWorldService service1 = (HelloWorldService)child.getContext("target").getInstance(null);
+ Assert.assertEquals(2, service1.count());
+ child.fireEvent(EventContext.REQUEST_END, session);
+ child.fireEvent(EventContext.SESSION_END, session);
+
+
+ // second session
+ Object session2 = new Object();
+ child.fireEvent(EventContext.REQUEST_START, null);
+ child.fireEvent(EventContext.SESSION_NOTIFY, session2);
+
+ ctx = (EntryPointContext) child.getContext("source");
+ Assert.assertNotNull(ctx);
+ Assert.assertEquals(2, mockInterceptor.getCount());
+ response = handler.invoke(null, hello, new Object[] { "foo" });
+ Assert.assertEquals("Hello foo", response);
+ Assert.assertEquals(3, mockInterceptor.getCount());
+ child.fireEvent(EventContext.REQUEST_END, session2);
+
+ child.fireEvent(EventContext.REQUEST_START, null);
+ child.fireEvent(EventContext.SESSION_NOTIFY, session2);
+ ctx2 = (EntryPointContext) child.getContext("source");
+ Assert.assertNotNull(ctx2);
+ response = handler.invoke(null, hello, new Object[] { "foo" });
+ Assert.assertEquals("Hello foo", response);
+ Assert.assertEquals(4, mockInterceptor.getCount());
+ HelloWorldService service2 = (HelloWorldService)child.getContext("target").getInstance(null);
+ Assert.assertEquals(2, service2.count());
+ Assert.assertEquals(2, service1.count()); //ensure sessions not crossed
+ child.fireEvent(EventContext.REQUEST_END, session2);
+ child.fireEvent(EventContext.SESSION_NOTIFY, session2);
+
+
+ child.fireEvent(EventContext.MODULE_STOP, null);
+ runtime.stop();
+ }
+
+
+ /**
+ * Tests creation and invocation of an entry point wired to a module-scoped service offered by a Java component
+ */
+ public void testEPtoJavaStatelessInvoke() throws Throwable {
+ RuntimeContext runtime = MockFactory.registerFooBinding(MockFactory.createJavaRuntime());
+ FooBindingBuilder builder = (FooBindingBuilder) ((AggregateContext) runtime.getSystemContext().getContext(MockFactory.SYSTEM_CHILD))
+ .getContext(MockFactory.FOO_BUILDER).getInstance(null);
+ MockSyncInterceptor mockInterceptor = new MockSyncInterceptor();
+ MockInterceptorBuilder interceptorBuilder = new MockInterceptorBuilder(mockInterceptor, false);
+ builder.addPolicyBuilder(interceptorBuilder);
+ runtime.getRootContext().registerModelObject(MockFactory.createAggregateComponent("test.module"));
+ AggregateContext child = (AggregateContext) runtime.getRootContext().getContext("test.module");
+ child.registerModelObject(MockFactory.createModuleWithEntryPoint(Scope.INSTANCE));
+ child.fireEvent(EventContext.MODULE_START, null);
+ child.fireEvent(EventContext.REQUEST_START, null);
+ EntryPointContext ctx = (EntryPointContext) child.getContext("source");
+ Assert.assertNotNull(ctx);
+ InvocationHandler handler = (InvocationHandler) ctx.getImplementationInstance();
+ Assert.assertEquals(0, mockInterceptor.getCount());
+ Object response = handler.invoke(null, hello, new Object[] { "foo" });
+ Assert.assertEquals("Hello foo", response);
+ Assert.assertEquals(1, mockInterceptor.getCount());
+ child.fireEvent(EventContext.REQUEST_END, null);
+
+ // second request
+ child.fireEvent(EventContext.REQUEST_START, null);
+ ctx = (EntryPointContext) child.getContext("source");
+ Assert.assertNotNull(ctx);
+ handler = (InvocationHandler) ctx.getImplementationInstance();
+ Assert.assertEquals(1, mockInterceptor.getCount());
+ response = handler.invoke(null, hello, new Object[] { "foo" });
+ Assert.assertEquals("Hello foo", response);
+ Assert.assertEquals(2, mockInterceptor.getCount());
+ HelloWorldService service1 = (HelloWorldService)child.getContext("target").getInstance(null);
+ Assert.assertEquals(0, service1.count());
+ child.fireEvent(EventContext.REQUEST_END, null);
+
+ child.fireEvent(EventContext.MODULE_STOP, null);
+ runtime.stop();
+ }
+
+ public void testEPtoJavaRequestInvoke() throws Throwable {
+ RuntimeContext runtime = MockFactory.registerFooBinding(MockFactory.createJavaRuntime());
+ FooBindingBuilder builder = (FooBindingBuilder) ((AggregateContext) runtime.getSystemContext().getContext(MockFactory.SYSTEM_CHILD))
+ .getContext(MockFactory.FOO_BUILDER).getInstance(null);
+ MockSyncInterceptor mockInterceptor = new MockSyncInterceptor();
+ MockInterceptorBuilder interceptorBuilder = new MockInterceptorBuilder(mockInterceptor, false);
+ builder.addPolicyBuilder(interceptorBuilder);
+ runtime.getRootContext().registerModelObject(MockFactory.createAggregateComponent("test.module"));
+ AggregateContext child = (AggregateContext) runtime.getRootContext().getContext("test.module");
+ child.registerModelObject(MockFactory.createModuleWithEntryPoint(Scope.REQUEST));
+ child.fireEvent(EventContext.MODULE_START, null);
+ child.fireEvent(EventContext.REQUEST_START, null);
+ EntryPointContext ctx = (EntryPointContext) child.getContext("source");
+ Assert.assertNotNull(ctx);
+ InvocationHandler handler = (InvocationHandler) ctx.getImplementationInstance();
+ Assert.assertEquals(0, mockInterceptor.getCount());
+ Object response = handler.invoke(null, hello, new Object[] { "foo" });
+ Assert.assertEquals("Hello foo", response);
+ Assert.assertEquals(1, mockInterceptor.getCount());
+
+ ctx = (EntryPointContext) child.getContext("source");
+ Assert.assertNotNull(ctx);
+ handler = (InvocationHandler) ctx.getImplementationInstance();
+ response = handler.invoke(null, hello, new Object[] { "foo" });
+ HelloWorldService service1 = (HelloWorldService)child.getContext("target").getInstance(null);
+ Assert.assertEquals(2, service1.count());
+
+ child.fireEvent(EventContext.REQUEST_END, null);
+
+ // second request
+ child.fireEvent(EventContext.REQUEST_START, null);
+ ctx = (EntryPointContext) child.getContext("source");
+ Assert.assertNotNull(ctx);
+ handler = (InvocationHandler) ctx.getImplementationInstance();
+ Assert.assertEquals(2, mockInterceptor.getCount());
+ response = handler.invoke(null, hello, new Object[] { "foo" });
+ Assert.assertEquals("Hello foo", response);
+ Assert.assertEquals(3, mockInterceptor.getCount());
+ HelloWorldService service2 = (HelloWorldService)child.getContext("target").getInstance(null);
+ Assert.assertEquals(1, service2.count());
+ child.fireEvent(EventContext.REQUEST_END, null);
+
+ child.fireEvent(EventContext.MODULE_STOP, null);
+ runtime.stop();
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/integration/binding/JavaToExternalServiceTestCase.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/integration/binding/JavaToExternalServiceTestCase.java
new file mode 100644
index 0000000000..a2c88e315a
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/integration/binding/JavaToExternalServiceTestCase.java
@@ -0,0 +1,61 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.integration.binding;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.container.java.assembly.mock.HelloWorldService;
+import org.apache.tuscany.container.java.builder.MockInterceptorBuilder;
+import org.apache.tuscany.container.java.invocation.mock.MockSyncInterceptor;
+import org.apache.tuscany.container.java.mock.MockFactory;
+import org.apache.tuscany.container.java.mock.binding.foo.FooBindingBuilder;
+import org.apache.tuscany.core.context.AggregateContext;
+import org.apache.tuscany.core.context.EventContext;
+import org.apache.tuscany.core.runtime.RuntimeContext;
+
+/**
+ * Tests basic Java to external service interaction
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaToExternalServiceTestCase extends TestCase {
+
+ /**
+ * Tests an invocation of an external service configured with the
+ * {@link org.apache.tuscany.container.java.mock.binding.foo.FooBinding} from a Java component
+ *
+ * @throws Exception
+ */
+ public void testJavaToESInvoke() throws Exception {
+ RuntimeContext runtime = MockFactory.registerFooBinding(MockFactory.createJavaRuntime());
+ FooBindingBuilder builder = (FooBindingBuilder) ((AggregateContext) runtime.getSystemContext().getContext(
+ MockFactory.SYSTEM_CHILD)).getContext(MockFactory.FOO_BUILDER).getInstance(null);
+ MockSyncInterceptor mockInterceptor = new MockSyncInterceptor();
+ MockInterceptorBuilder interceptorBuilder = new MockInterceptorBuilder(mockInterceptor, false);
+ builder.addPolicyBuilder(interceptorBuilder);
+ runtime.getRootContext().registerModelObject(MockFactory.createAggregateComponent("test.module"));
+ AggregateContext child = (AggregateContext) runtime.getRootContext().getContext("test.module");
+ child.registerModelObject(MockFactory.createModuleWithExternalService());
+ child.fireEvent(EventContext.MODULE_START, null);
+ HelloWorldService source = (HelloWorldService) child.locateInstance("source");
+ Assert.assertNotNull(source);
+ Assert.assertEquals(0, mockInterceptor.getCount());
+ Assert.assertEquals("foo", source.hello("foo"));
+ Assert.assertEquals(1, mockInterceptor.getCount());
+ child.fireEvent(EventContext.MODULE_STOP, null);
+ runtime.stop();
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/integration/context/ScopeReferenceTestCase.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/integration/context/ScopeReferenceTestCase.java
new file mode 100644
index 0000000000..fc9bab4ca3
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/integration/context/ScopeReferenceTestCase.java
@@ -0,0 +1,709 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.integration.context;
+
+import org.apache.tuscany.container.java.mock.MockFactory;
+import org.apache.tuscany.container.java.mock.components.GenericComponent;
+import org.apache.tuscany.core.context.AggregateContext;
+import org.apache.tuscany.core.context.EventContext;
+import org.apache.tuscany.core.context.InstanceContext;
+import org.apache.tuscany.core.runtime.RuntimeContext;
+import org.apache.tuscany.model.assembly.Scope;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+/**
+ * Tests scoping is properly handled for service references
+ *
+ * @version $Rev$ $Date$
+ */
+public class ScopeReferenceTestCase extends TestCase {
+
+ /**
+ * Tests a module-to-module scoped wire is setup properly by the runtime
+ */
+ public void testModuleToModule() throws Exception{
+ RuntimeContext runtime = MockFactory.createJavaRuntime();
+ InstanceContext ctx = runtime.getSystemContext().getContext("tuscany.system.child");
+ Assert.assertNotNull(ctx);
+ runtime.getRootContext().registerModelObject(MockFactory.createAggregateComponent("test"));
+ AggregateContext testCtx = (AggregateContext) runtime.getRootContext().getContext("test");
+ Assert.assertNotNull(testCtx);
+ testCtx.registerModelObject(MockFactory.createModule());
+ testCtx.fireEvent(EventContext.MODULE_START,null);
+ GenericComponent source = (GenericComponent)testCtx.getContext("source").getInstance(null);
+ Assert.assertNotNull(source);
+ GenericComponent target = (GenericComponent)testCtx.getContext("target").getInstance(null);
+ Assert.assertNotNull(target);
+ source.getGenericComponent().getString();
+ }
+
+ /**
+ * Tests a module-to-session scoped wire is setup properly by the runtime
+ */
+ public void testModuleToSession() throws Exception{
+ RuntimeContext runtime = MockFactory.createJavaRuntime();
+ InstanceContext ctx = runtime.getSystemContext().getContext("tuscany.system.child");
+ Assert.assertNotNull(ctx);
+ runtime.getRootContext().registerModelObject(MockFactory.createAggregateComponent("test"));
+ AggregateContext testCtx = (AggregateContext) runtime.getRootContext().getContext("test");
+ Assert.assertNotNull(testCtx);
+ testCtx.registerModelObject(MockFactory.createModule(Scope.MODULE,Scope.SESSION));
+ testCtx.fireEvent(EventContext.MODULE_START,null);
+
+ // first session
+ Object session = new Object();
+ testCtx.fireEvent(EventContext.REQUEST_START,null);
+ testCtx.fireEvent(EventContext.SESSION_NOTIFY,session);
+ GenericComponent source = (GenericComponent)testCtx.getContext("source").getInstance(null);
+ Assert.assertNotNull(source);
+ GenericComponent target = (GenericComponent)testCtx.getContext("target").getInstance(null);
+ Assert.assertNotNull(target);
+ source.getGenericComponent().setString("foo");
+ Assert.assertEquals("foo",target.getString());
+ testCtx.fireEvent(EventContext.REQUEST_END,session);
+
+ //second session
+ Object session2 = new Object();
+ testCtx.fireEvent(EventContext.REQUEST_START,null);
+ testCtx.fireEvent(EventContext.SESSION_NOTIFY,session2);
+ GenericComponent target2 = (GenericComponent)testCtx.getContext("target").getInstance(null);
+ Assert.assertNotNull(target2);
+ Assert.assertTrue(!"foo".equals(target2.getString()));
+
+ Assert.assertTrue(!"foo".equals(source.getGenericComponent().getString()));
+ source.getGenericComponent().setString("bar");
+ Assert.assertEquals("bar",target2.getString());
+ Assert.assertEquals("bar",source.getGenericComponent().getString());
+ //testCtx.fireEvent(EventContext.SESSION_NOTIFY,session);
+
+ }
+
+ /**
+ * Tests a module-to-request scoped wire is setup properly by the runtime
+ */
+ public void testModuleToRequest() throws Exception{
+ RuntimeContext runtime = MockFactory.createJavaRuntime();
+ InstanceContext ctx = runtime.getSystemContext().getContext("tuscany.system.child");
+ Assert.assertNotNull(ctx);
+ runtime.getRootContext().registerModelObject(MockFactory.createAggregateComponent("test"));
+ AggregateContext testCtx = (AggregateContext) runtime.getRootContext().getContext("test");
+ Assert.assertNotNull(testCtx);
+ testCtx.registerModelObject(MockFactory.createModule(Scope.MODULE,Scope.REQUEST));
+ testCtx.fireEvent(EventContext.MODULE_START,null);
+
+ // first request
+ testCtx.fireEvent(EventContext.REQUEST_START,null);
+ GenericComponent source = (GenericComponent)testCtx.getContext("source").getInstance(null);
+ Assert.assertNotNull(source);
+ GenericComponent target = (GenericComponent)testCtx.getContext("target").getInstance(null);
+ Assert.assertNotNull(target);
+ source.getGenericComponent().setString("foo");
+ Assert.assertEquals("foo",target.getString());
+ testCtx.fireEvent(EventContext.REQUEST_END,null);
+
+ //second request
+ testCtx.fireEvent(EventContext.REQUEST_START,null);
+ GenericComponent target2 = (GenericComponent)testCtx.getContext("target").getInstance(null);
+ Assert.assertNotNull(target2);
+ Assert.assertTrue(!"foo".equals(target2.getString()));
+
+ Assert.assertTrue(!"foo".equals(source.getGenericComponent().getString()));
+ source.getGenericComponent().setString("bar");
+ Assert.assertEquals("bar",target2.getString());
+ Assert.assertEquals("bar",source.getGenericComponent().getString());
+
+ }
+
+ /**
+ * Tests a module-to-stateless scoped wire is setup properly by the runtime
+ */
+ public void testModuleToStateless() throws Exception{
+ RuntimeContext runtime = MockFactory.createJavaRuntime();
+ InstanceContext ctx = runtime.getSystemContext().getContext("tuscany.system.child");
+ Assert.assertNotNull(ctx);
+ runtime.getRootContext().registerModelObject(MockFactory.createAggregateComponent("test"));
+ AggregateContext testCtx = (AggregateContext) runtime.getRootContext().getContext("test");
+ Assert.assertNotNull(testCtx);
+ testCtx.registerModelObject(MockFactory.createModule(Scope.MODULE,Scope.INSTANCE));
+ testCtx.fireEvent(EventContext.MODULE_START,null);
+
+ // first request
+ testCtx.fireEvent(EventContext.REQUEST_START,null);
+ GenericComponent source = (GenericComponent)testCtx.getContext("source").getInstance(null);
+ Assert.assertNotNull(source);
+ GenericComponent target = (GenericComponent)testCtx.getContext("target").getInstance(null);
+ Assert.assertNotNull(target);
+ source.getGenericComponent().setString("foo");
+ Assert.assertTrue(!"foo".equals(target.getString()));
+ testCtx.fireEvent(EventContext.REQUEST_END,null);
+
+ //second request
+ testCtx.fireEvent(EventContext.REQUEST_START,null);
+ GenericComponent target2 = (GenericComponent)testCtx.getContext("target").getInstance(null);
+ Assert.assertNotNull(target2);
+ Assert.assertTrue(!"foo".equals(target2.getString()));
+
+ Assert.assertTrue(!"foo".equals(source.getGenericComponent().getString()));
+ source.getGenericComponent().setString("bar");
+ Assert.assertTrue(!"bar".equals(target2.getString()));
+ }
+
+ /**
+ * Tests a session-to-session scoped wire is setup properly by the runtime
+ */
+ public void testSessionToSession() throws Exception{
+ RuntimeContext runtime = MockFactory.createJavaRuntime();
+ InstanceContext ctx = runtime.getSystemContext().getContext("tuscany.system.child");
+ Assert.assertNotNull(ctx);
+ runtime.getRootContext().registerModelObject(MockFactory.createAggregateComponent("test"));
+ AggregateContext testCtx = (AggregateContext) runtime.getRootContext().getContext("test");
+ Assert.assertNotNull(testCtx);
+ testCtx.registerModelObject(MockFactory.createModule(Scope.SESSION,Scope.SESSION));
+ testCtx.fireEvent(EventContext.MODULE_START,null);
+
+ // first session
+ Object session = new Object();
+ testCtx.fireEvent(EventContext.REQUEST_START,null);
+ testCtx.fireEvent(EventContext.SESSION_NOTIFY,session);
+ GenericComponent source = (GenericComponent)testCtx.getContext("source").getInstance(null);
+ Assert.assertNotNull(source);
+ GenericComponent target = (GenericComponent)testCtx.getContext("target").getInstance(null);
+ Assert.assertNotNull(target);
+ source.getGenericComponent().setString("foo");
+ source.getGenericComponent().setString("foo");
+ Assert.assertEquals("foo",target.getString());
+ testCtx.fireEvent(EventContext.REQUEST_END,session);
+
+ //second session
+ Object session2 = new Object();
+ testCtx.fireEvent(EventContext.REQUEST_START,null);
+ testCtx.fireEvent(EventContext.SESSION_NOTIFY,session2);
+ GenericComponent source2 = (GenericComponent)testCtx.getContext("source").getInstance(null);
+ Assert.assertNotNull(source2);
+ GenericComponent target2 = (GenericComponent)testCtx.getContext("target").getInstance(null);
+
+ Assert.assertNotNull(target2);
+ Assert.assertEquals(null,target2.getString());
+ Assert.assertEquals(null,source2.getGenericComponent().getString());
+ source2.getGenericComponent().setString("baz");
+ Assert.assertEquals("baz",source2.getGenericComponent().getString());
+ Assert.assertEquals("baz",target2.getString());
+
+ testCtx.fireEvent(EventContext.REQUEST_END,session2);
+
+ }
+
+
+ /**
+ * Tests a session-to-module scoped wire is setup properly by the runtime
+ */
+ public void testSessionToModule() throws Exception{
+ RuntimeContext runtime = MockFactory.createJavaRuntime();
+ InstanceContext ctx = runtime.getSystemContext().getContext("tuscany.system.child");
+ Assert.assertNotNull(ctx);
+ runtime.getRootContext().registerModelObject(MockFactory.createAggregateComponent("test"));
+ AggregateContext testCtx = (AggregateContext) runtime.getRootContext().getContext("test");
+ Assert.assertNotNull(testCtx);
+ testCtx.registerModelObject(MockFactory.createModule(Scope.SESSION,Scope.MODULE));
+ testCtx.fireEvent(EventContext.MODULE_START,null);
+
+ // first session
+ Object session = new Object();
+ testCtx.fireEvent(EventContext.REQUEST_START,null);
+ testCtx.fireEvent(EventContext.SESSION_NOTIFY,session);
+ GenericComponent source = (GenericComponent)testCtx.getContext("source").getInstance(null);
+ Assert.assertNotNull(source);
+ GenericComponent target = (GenericComponent)testCtx.getContext("target").getInstance(null);
+ Assert.assertNotNull(target);
+ source.getGenericComponent().setString("foo");
+ source.getGenericComponent().setString("foo");
+ Assert.assertEquals("foo",target.getString());
+ testCtx.fireEvent(EventContext.REQUEST_END,session);
+
+ //second session
+ Object session2 = new Object();
+ testCtx.fireEvent(EventContext.REQUEST_START,null);
+ testCtx.fireEvent(EventContext.SESSION_NOTIFY,session2);
+ GenericComponent source2 = (GenericComponent)testCtx.getContext("source").getInstance(null);
+ Assert.assertNotNull(source2);
+ GenericComponent target2 = (GenericComponent)testCtx.getContext("target").getInstance(null);
+
+ Assert.assertNotNull(target2);
+ Assert.assertEquals("foo",target2.getString());
+ Assert.assertEquals("foo",source2.getGenericComponent().getString());
+ source2.getGenericComponent().setString("baz");
+ Assert.assertEquals("baz",source2.getGenericComponent().getString());
+ Assert.assertEquals("baz",target2.getString());
+ Assert.assertEquals("baz",target.getString());
+
+ testCtx.fireEvent(EventContext.REQUEST_END,session2);
+
+ }
+
+ /**
+ * Tests a session-to-request scoped wire is setup properly by the runtime
+ */
+ public void testSessionToRequest() throws Exception{
+ RuntimeContext runtime = MockFactory.createJavaRuntime();
+ InstanceContext ctx = runtime.getSystemContext().getContext("tuscany.system.child");
+ Assert.assertNotNull(ctx);
+ runtime.getRootContext().registerModelObject(MockFactory.createAggregateComponent("test"));
+ AggregateContext testCtx = (AggregateContext) runtime.getRootContext().getContext("test");
+ Assert.assertNotNull(testCtx);
+ testCtx.registerModelObject(MockFactory.createModule(Scope.SESSION,Scope.REQUEST));
+ testCtx.fireEvent(EventContext.MODULE_START,null);
+
+ // first session
+ Object session = new Object();
+ testCtx.fireEvent(EventContext.REQUEST_START,null);
+ testCtx.fireEvent(EventContext.SESSION_NOTIFY,session);
+ GenericComponent source = (GenericComponent)testCtx.getContext("source").getInstance(null);
+ Assert.assertNotNull(source);
+ GenericComponent target = (GenericComponent)testCtx.getContext("target").getInstance(null);
+ Assert.assertNotNull(target);
+ source.getGenericComponent().setString("foo");
+ Assert.assertEquals("foo",target.getString());
+ testCtx.fireEvent(EventContext.REQUEST_END,session);
+
+ //second session
+ Object session2 = new Object();
+ testCtx.fireEvent(EventContext.REQUEST_START,null);
+ testCtx.fireEvent(EventContext.SESSION_NOTIFY,session2);
+ GenericComponent source2 = (GenericComponent)testCtx.getContext("source").getInstance(null);
+ Assert.assertNotNull(source);
+ GenericComponent target2 = (GenericComponent)testCtx.getContext("target").getInstance(null);
+
+ Assert.assertNotNull(target2);
+ Assert.assertEquals(null,target2.getString());
+ source2.getGenericComponent().setString("baz");
+ Assert.assertEquals("baz",target2.getString());
+ Assert.assertEquals("baz",source2.getGenericComponent().getString());
+
+ Assert.assertEquals("foo",target.getString());
+ testCtx.fireEvent(EventContext.REQUEST_END,session);
+
+ }
+
+
+ /**
+ * Tests a session-to-stateless scoped wire is setup properly by the runtime
+ */
+ public void testSessionToStateless() throws Exception{
+ RuntimeContext runtime = MockFactory.createJavaRuntime();
+ InstanceContext ctx = runtime.getSystemContext().getContext("tuscany.system.child");
+ Assert.assertNotNull(ctx);
+ runtime.getRootContext().registerModelObject(MockFactory.createAggregateComponent("test"));
+ AggregateContext testCtx = (AggregateContext) runtime.getRootContext().getContext("test");
+ Assert.assertNotNull(testCtx);
+ testCtx.registerModelObject(MockFactory.createModule(Scope.SESSION,Scope.INSTANCE));
+ testCtx.fireEvent(EventContext.MODULE_START,null);
+
+ // first session
+ Object session = new Object();
+ testCtx.fireEvent(EventContext.REQUEST_START,null);
+ testCtx.fireEvent(EventContext.SESSION_NOTIFY,session);
+ GenericComponent source = (GenericComponent)testCtx.getContext("source").getInstance(null);
+ Assert.assertNotNull(source);
+ GenericComponent target = (GenericComponent)testCtx.getContext("target").getInstance(null);
+ Assert.assertNotNull(target);
+ source.getGenericComponent().setString("foo");
+ Assert.assertEquals(null,target.getString());
+ testCtx.fireEvent(EventContext.REQUEST_END,session);
+
+ //second session
+ Object session2 = new Object();
+ testCtx.fireEvent(EventContext.REQUEST_START,null);
+ testCtx.fireEvent(EventContext.SESSION_NOTIFY,session2);
+ GenericComponent source2 = (GenericComponent)testCtx.getContext("source").getInstance(null);
+ Assert.assertNotNull(source);
+ GenericComponent target2 = (GenericComponent)testCtx.getContext("target").getInstance(null);
+
+ Assert.assertNotNull(target2);
+ Assert.assertEquals(null,target2.getString());
+ source2.getGenericComponent().setString("baz");
+ Assert.assertEquals(null,target2.getString()); //Note assumes no pooling
+ Assert.assertEquals(null,source2.getGenericComponent().getString());
+
+ Assert.assertEquals(null,target.getString()); //Note assumes no pooling
+ testCtx.fireEvent(EventContext.REQUEST_END,session);
+
+ }
+
+ /**
+ * Tests a request-to-request scoped wire is setup properly by the runtime
+ */
+ public void testRequestToRequest() throws Exception{
+ RuntimeContext runtime = MockFactory.createJavaRuntime();
+ InstanceContext ctx = runtime.getSystemContext().getContext("tuscany.system.child");
+ Assert.assertNotNull(ctx);
+ runtime.getRootContext().registerModelObject(MockFactory.createAggregateComponent("test"));
+ AggregateContext testCtx = (AggregateContext) runtime.getRootContext().getContext("test");
+ Assert.assertNotNull(testCtx);
+ testCtx.registerModelObject(MockFactory.createModule(Scope.REQUEST,Scope.REQUEST));
+ testCtx.fireEvent(EventContext.MODULE_START,null);
+
+ // first request
+ testCtx.fireEvent(EventContext.REQUEST_START,null);
+ GenericComponent source = (GenericComponent)testCtx.getContext("source").getInstance(null);
+ Assert.assertNotNull(source);
+ GenericComponent target = (GenericComponent)testCtx.getContext("target").getInstance(null);
+ Assert.assertNotNull(target);
+ source.getGenericComponent().setString("foo");
+ Assert.assertEquals("foo",target.getString());
+ testCtx.fireEvent(EventContext.REQUEST_END,null);
+
+ //second request
+ testCtx.fireEvent(EventContext.REQUEST_START,null);
+ GenericComponent source2 = (GenericComponent)testCtx.getContext("source").getInstance(null);
+ Assert.assertNotNull(source2);
+ GenericComponent target2 = (GenericComponent)testCtx.getContext("target").getInstance(null);
+
+ Assert.assertNotNull(target2);
+ Assert.assertEquals(null,target2.getString());
+ Assert.assertEquals(null,source2.getGenericComponent().getString());
+ source2.getGenericComponent().setString("baz");
+ Assert.assertEquals("baz",source2.getGenericComponent().getString());
+ Assert.assertEquals("baz",target2.getString());
+
+ testCtx.fireEvent(EventContext.REQUEST_END,null);
+
+ }
+
+ /**
+ * Tests a request-to-module scoped wire is setup properly by the runtime
+ */
+ public void testRequestToModule() throws Exception{
+ RuntimeContext runtime = MockFactory.createJavaRuntime();
+ InstanceContext ctx = runtime.getSystemContext().getContext("tuscany.system.child");
+ Assert.assertNotNull(ctx);
+ runtime.getRootContext().registerModelObject(MockFactory.createAggregateComponent("test"));
+ AggregateContext testCtx = (AggregateContext) runtime.getRootContext().getContext("test");
+ Assert.assertNotNull(testCtx);
+ testCtx.registerModelObject(MockFactory.createModule(Scope.REQUEST,Scope.MODULE));
+ testCtx.fireEvent(EventContext.MODULE_START,null);
+
+ // first request
+ testCtx.fireEvent(EventContext.REQUEST_START,null);
+ GenericComponent source = (GenericComponent)testCtx.getContext("source").getInstance(null);
+ Assert.assertNotNull(source);
+ GenericComponent target = (GenericComponent)testCtx.getContext("target").getInstance(null);
+ Assert.assertNotNull(target);
+ source.getGenericComponent().setString("foo");
+ Assert.assertEquals("foo",target.getString());
+ testCtx.fireEvent(EventContext.REQUEST_END,null);
+
+ //second request
+ testCtx.fireEvent(EventContext.REQUEST_START,null);
+ GenericComponent source2 = (GenericComponent)testCtx.getContext("source").getInstance(null);
+ Assert.assertNotNull(source2);
+ GenericComponent target2 = (GenericComponent)testCtx.getContext("target").getInstance(null);
+
+ Assert.assertNotNull(target2);
+ Assert.assertEquals("foo",target2.getString());
+ Assert.assertEquals("foo",source2.getGenericComponent().getString());
+ source2.getGenericComponent().setString("baz");
+ Assert.assertEquals("baz",source2.getGenericComponent().getString());
+ Assert.assertEquals("baz",target2.getString());
+ Assert.assertEquals("baz",target.getString());
+
+ testCtx.fireEvent(EventContext.REQUEST_END,null);
+
+ }
+
+ /**
+ * Tests a request-to-session scoped wire is setup properly by the runtime
+ */
+ public void testRequestToSession() throws Exception{
+ RuntimeContext runtime = MockFactory.createJavaRuntime();
+ InstanceContext ctx = runtime.getSystemContext().getContext("tuscany.system.child");
+ Assert.assertNotNull(ctx);
+ runtime.getRootContext().registerModelObject(MockFactory.createAggregateComponent("test"));
+ AggregateContext testCtx = (AggregateContext) runtime.getRootContext().getContext("test");
+ Assert.assertNotNull(testCtx);
+ testCtx.registerModelObject(MockFactory.createModule(Scope.REQUEST,Scope.SESSION));
+ testCtx.fireEvent(EventContext.MODULE_START,null);
+
+ // first session
+ Object session = new Object();
+ testCtx.fireEvent(EventContext.REQUEST_START,null);
+ testCtx.fireEvent(EventContext.SESSION_NOTIFY,session);
+ GenericComponent source = (GenericComponent)testCtx.getContext("source").getInstance(null);
+ Assert.assertNotNull(source);
+ GenericComponent target = (GenericComponent)testCtx.getContext("target").getInstance(null);
+ Assert.assertNotNull(target);
+ source.getGenericComponent().setString("foo");
+ Assert.assertEquals("foo",target.getString());
+ testCtx.fireEvent(EventContext.REQUEST_END,session);
+
+ //second request for session
+ testCtx.fireEvent(EventContext.REQUEST_START,null);
+ testCtx.fireEvent(EventContext.SESSION_NOTIFY,session);
+ GenericComponent targetR2 = (GenericComponent)testCtx.getContext("target").getInstance(null);
+ Assert.assertEquals("foo",targetR2.getString());
+ GenericComponent sourceR2 = (GenericComponent)testCtx.getContext("source").getInstance(null);
+ Assert.assertNotNull(sourceR2);
+ Assert.assertEquals("foo",sourceR2.getGenericComponent().getString());
+
+ testCtx.fireEvent(EventContext.REQUEST_END,session);
+
+ //second session
+ Object session2 = new Object();
+ testCtx.fireEvent(EventContext.REQUEST_START,null);
+ testCtx.fireEvent(EventContext.SESSION_NOTIFY,session2);
+ GenericComponent source2 = (GenericComponent)testCtx.getContext("source").getInstance(null);
+ Assert.assertNotNull(source2);
+ GenericComponent target2 = (GenericComponent)testCtx.getContext("target").getInstance(null);
+
+ Assert.assertNotNull(target2);
+ Assert.assertEquals(null,target2.getString());
+ Assert.assertEquals(null,source2.getGenericComponent().getString());
+ source2.getGenericComponent().setString("baz");
+ Assert.assertEquals("baz",source2.getGenericComponent().getString());
+ Assert.assertEquals("baz",target2.getString());
+
+ testCtx.fireEvent(EventContext.REQUEST_END,session2);
+ testCtx.fireEvent(EventContext.REQUEST_START,null);
+ testCtx.fireEvent(EventContext.SESSION_NOTIFY,session);
+ testCtx.fireEvent(EventContext.REQUEST_END,session);
+
+ }
+
+
+ /**
+ * Tests a request-to-stateless scoped wire is setup properly by the runtime
+ */
+ public void testRequestToStateless() throws Exception{
+ RuntimeContext runtime = MockFactory.createJavaRuntime();
+ InstanceContext ctx = runtime.getSystemContext().getContext("tuscany.system.child");
+ Assert.assertNotNull(ctx);
+ runtime.getRootContext().registerModelObject(MockFactory.createAggregateComponent("test"));
+ AggregateContext testCtx = (AggregateContext) runtime.getRootContext().getContext("test");
+ Assert.assertNotNull(testCtx);
+ testCtx.registerModelObject(MockFactory.createModule(Scope.REQUEST,Scope.INSTANCE));
+ testCtx.fireEvent(EventContext.MODULE_START,null);
+
+ // first request
+ testCtx.fireEvent(EventContext.REQUEST_START,null);
+ GenericComponent source = (GenericComponent)testCtx.getContext("source").getInstance(null);
+ Assert.assertNotNull(source);
+ GenericComponent target = (GenericComponent)testCtx.getContext("target").getInstance(null);
+ Assert.assertNotNull(target);
+ source.getGenericComponent().setString("foo");
+ Assert.assertEquals(null,target.getString());
+ testCtx.fireEvent(EventContext.REQUEST_END,null);
+
+ //second request
+ testCtx.fireEvent(EventContext.REQUEST_START,null);
+ GenericComponent source2 = (GenericComponent)testCtx.getContext("source").getInstance(null);
+ Assert.assertNotNull(source2);
+ GenericComponent target2 = (GenericComponent)testCtx.getContext("target").getInstance(null);
+
+ Assert.assertNotNull(target2);
+ Assert.assertEquals(null,target2.getString());
+ Assert.assertEquals(null,source2.getGenericComponent().getString());
+ source2.getGenericComponent().setString("baz");
+ Assert.assertEquals(null,source2.getGenericComponent().getString());
+ Assert.assertEquals(null,target2.getString());
+
+ testCtx.fireEvent(EventContext.REQUEST_END,null);
+
+ }
+
+
+ /**
+ * Tests a stateless-to-stateless scoped wire is setup properly by the runtime
+ */
+ public void testStatelessToStateless() throws Exception{
+ RuntimeContext runtime = MockFactory.createJavaRuntime();
+ InstanceContext ctx = runtime.getSystemContext().getContext("tuscany.system.child");
+ Assert.assertNotNull(ctx);
+ runtime.getRootContext().registerModelObject(MockFactory.createAggregateComponent("test"));
+ AggregateContext testCtx = (AggregateContext) runtime.getRootContext().getContext("test");
+ Assert.assertNotNull(testCtx);
+ testCtx.registerModelObject(MockFactory.createModule(Scope.INSTANCE,Scope.INSTANCE));
+ testCtx.fireEvent(EventContext.MODULE_START,null);
+
+ // first request
+ testCtx.fireEvent(EventContext.REQUEST_START,null);
+ GenericComponent source = (GenericComponent)testCtx.getContext("source").getInstance(null);
+ Assert.assertNotNull(source);
+ GenericComponent target = (GenericComponent)testCtx.getContext("target").getInstance(null);
+ Assert.assertNotNull(target);
+ source.getGenericComponent().setString("foo");
+ Assert.assertEquals(null,target.getString());
+ testCtx.fireEvent(EventContext.REQUEST_END,null);
+
+ //second request
+ testCtx.fireEvent(EventContext.REQUEST_START,null);
+ GenericComponent source2 = (GenericComponent)testCtx.getContext("source").getInstance(null);
+ Assert.assertNotNull(source2);
+ GenericComponent target2 = (GenericComponent)testCtx.getContext("target").getInstance(null);
+
+ Assert.assertNotNull(target2);
+ Assert.assertEquals(null,target2.getString());
+ Assert.assertEquals(null,source2.getGenericComponent().getString());
+ source2.getGenericComponent().setString("baz");
+ Assert.assertEquals(null,source2.getGenericComponent().getString());
+ Assert.assertEquals(null,target2.getString());
+
+ testCtx.fireEvent(EventContext.REQUEST_END,null);
+
+ }
+
+ /**
+ * Tests a stateless-to-request scoped wire is setup properly by the runtime
+ */
+ public void testStatelessToRequest() throws Exception{
+ RuntimeContext runtime = MockFactory.createJavaRuntime();
+ InstanceContext ctx = runtime.getSystemContext().getContext("tuscany.system.child");
+ Assert.assertNotNull(ctx);
+ runtime.getRootContext().registerModelObject(MockFactory.createAggregateComponent("test"));
+ AggregateContext testCtx = (AggregateContext) runtime.getRootContext().getContext("test");
+ Assert.assertNotNull(testCtx);
+ testCtx.registerModelObject(MockFactory.createModule(Scope.INSTANCE,Scope.REQUEST));
+ testCtx.fireEvent(EventContext.MODULE_START,null);
+
+ // first request
+ testCtx.fireEvent(EventContext.REQUEST_START,null);
+ GenericComponent source = (GenericComponent)testCtx.getContext("source").getInstance(null);
+ Assert.assertNotNull(source);
+ GenericComponent target = (GenericComponent)testCtx.getContext("target").getInstance(null);
+ Assert.assertNotNull(target);
+ source.getGenericComponent().setString("foo");
+ Assert.assertEquals("foo",target.getString());
+ testCtx.fireEvent(EventContext.REQUEST_END,null);
+
+ GenericComponent targetR1 = (GenericComponent)testCtx.getContext("target").getInstance(null);
+ Assert.assertNotNull(targetR1);
+ Assert.assertEquals("foo",target.getString());
+
+ //second request
+ testCtx.fireEvent(EventContext.REQUEST_START,null);
+ GenericComponent source2 = (GenericComponent)testCtx.getContext("source").getInstance(null);
+ Assert.assertNotNull(source2);
+ GenericComponent target2 = (GenericComponent)testCtx.getContext("target").getInstance(null);
+
+ Assert.assertNotNull(target2);
+ Assert.assertEquals(null,target2.getString());
+ Assert.assertEquals(null,source2.getGenericComponent().getString());
+ source2.getGenericComponent().setString("baz");
+ Assert.assertEquals("baz",source2.getGenericComponent().getString());
+ Assert.assertEquals("baz",target2.getString());
+
+ testCtx.fireEvent(EventContext.REQUEST_END,null);
+
+ }
+
+ /**
+ * Tests a stateless-to-session scoped wire is setup properly by the runtime
+ */
+ public void testStatelessToSession() throws Exception{
+ RuntimeContext runtime = MockFactory.createJavaRuntime();
+ InstanceContext ctx = runtime.getSystemContext().getContext("tuscany.system.child");
+ Assert.assertNotNull(ctx);
+ runtime.getRootContext().registerModelObject(MockFactory.createAggregateComponent("test"));
+ AggregateContext testCtx = (AggregateContext) runtime.getRootContext().getContext("test");
+ Assert.assertNotNull(testCtx);
+ testCtx.registerModelObject(MockFactory.createModule(Scope.INSTANCE,Scope.SESSION));
+ testCtx.fireEvent(EventContext.MODULE_START,null);
+
+ // first session
+ Object session = new Object();
+ testCtx.fireEvent(EventContext.REQUEST_START,null);
+ testCtx.fireEvent(EventContext.SESSION_NOTIFY,session);
+ GenericComponent source = (GenericComponent)testCtx.getContext("source").getInstance(null);
+ Assert.assertNotNull(source);
+ GenericComponent target = (GenericComponent)testCtx.getContext("target").getInstance(null);
+ Assert.assertNotNull(target);
+ source.getGenericComponent().setString("foo");
+ Assert.assertEquals("foo",target.getString());
+ testCtx.fireEvent(EventContext.REQUEST_END,session);
+
+ //second request for session
+ testCtx.fireEvent(EventContext.REQUEST_START,null);
+ testCtx.fireEvent(EventContext.SESSION_NOTIFY,session);
+ GenericComponent targetR2 = (GenericComponent)testCtx.getContext("target").getInstance(null);
+ Assert.assertEquals("foo",targetR2.getString());
+ GenericComponent sourceR2 = (GenericComponent)testCtx.getContext("source").getInstance(null);
+ Assert.assertNotNull(sourceR2);
+ Assert.assertEquals("foo",sourceR2.getGenericComponent().getString());
+
+ testCtx.fireEvent(EventContext.REQUEST_END,session);
+
+ //second session
+ Object session2 = new Object();
+ testCtx.fireEvent(EventContext.REQUEST_START,null);
+ testCtx.fireEvent(EventContext.SESSION_NOTIFY,session2);
+ GenericComponent source2 = (GenericComponent)testCtx.getContext("source").getInstance(null);
+ Assert.assertNotNull(source2);
+ GenericComponent target2 = (GenericComponent)testCtx.getContext("target").getInstance(null);
+
+ Assert.assertNotNull(target2);
+ Assert.assertEquals(null,target2.getString());
+ Assert.assertEquals(null,source2.getGenericComponent().getString());
+ source2.getGenericComponent().setString("baz");
+ Assert.assertEquals("baz",source2.getGenericComponent().getString());
+ Assert.assertEquals("baz",target2.getString());
+
+ testCtx.fireEvent(EventContext.REQUEST_END,session2);
+ testCtx.fireEvent(EventContext.REQUEST_START,null);
+ testCtx.fireEvent(EventContext.SESSION_NOTIFY,session);
+ testCtx.fireEvent(EventContext.REQUEST_END,session);
+
+ }
+
+
+ /**
+ * Tests a stateless-to-module scoped wire is setup properly by the runtime
+ */
+ public void testStatelessToModule() throws Exception{
+ RuntimeContext runtime = MockFactory.createJavaRuntime();
+ InstanceContext ctx = runtime.getSystemContext().getContext("tuscany.system.child");
+ Assert.assertNotNull(ctx);
+ runtime.getRootContext().registerModelObject(MockFactory.createAggregateComponent("test"));
+ AggregateContext testCtx = (AggregateContext) runtime.getRootContext().getContext("test");
+ Assert.assertNotNull(testCtx);
+ testCtx.registerModelObject(MockFactory.createModule(Scope.INSTANCE,Scope.MODULE));
+ testCtx.fireEvent(EventContext.MODULE_START,null);
+
+ testCtx.fireEvent(EventContext.REQUEST_START,null);
+ GenericComponent source = (GenericComponent)testCtx.getContext("source").getInstance(null);
+ Assert.assertNotNull(source);
+ GenericComponent target = (GenericComponent)testCtx.getContext("target").getInstance(null);
+ Assert.assertNotNull(target);
+ source.getGenericComponent().setString("foo");
+ Assert.assertEquals("foo",target.getString());
+ testCtx.fireEvent(EventContext.REQUEST_END,null);
+
+ //second session
+ testCtx.fireEvent(EventContext.REQUEST_START,null);
+ GenericComponent source2 = (GenericComponent)testCtx.getContext("source").getInstance(null);
+ Assert.assertNotNull(source2);
+ GenericComponent target2 = (GenericComponent)testCtx.getContext("target").getInstance(null);
+
+ Assert.assertNotNull(target2);
+ Assert.assertEquals("foo",target2.getString());
+ Assert.assertEquals("foo",source2.getGenericComponent().getString());
+ source2.getGenericComponent().setString("baz");
+ Assert.assertEquals("baz",source2.getGenericComponent().getString());
+ Assert.assertEquals("baz",target2.getString());
+
+ testCtx.fireEvent(EventContext.REQUEST_END,null);
+
+ }
+
+}
+
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/invocation/MediationTestCase.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/invocation/MediationTestCase.java
new file mode 100644
index 0000000000..6266f18b87
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/invocation/MediationTestCase.java
@@ -0,0 +1,53 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.invocation;
+
+import java.lang.reflect.Method;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.container.java.invocation.mock.SimpleTargetImpl;
+import org.apache.tuscany.core.message.Message;
+import org.apache.tuscany.core.message.MessageFactory;
+import org.apache.tuscany.core.message.impl.MessageFactoryImpl;
+
+/**
+ * Tests invoking on a different interface from the one actually implemented by the target
+ *
+ * @version $Rev$ $Date$
+ */
+public class MediationTestCase extends TestCase {
+
+ private Method hello;
+
+ private MessageFactory msgFactory = new MessageFactoryImpl();
+
+ public void setUp() throws Exception {
+ hello = Hello.class.getMethod("hello", new Class[] { String.class });
+ }
+
+ public void testMediation() throws Exception {
+ StaticJavaComponentTargetInvoker invoker = new StaticJavaComponentTargetInvoker(hello, new SimpleTargetImpl());
+ Message msg = msgFactory.createMessage();
+ msg.setBody("foo");
+ Assert.assertEquals("foo", invoker.invoke(msg).getBody());
+ }
+
+ public interface Hello {
+
+ public String hello(String message) throws Exception;
+
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/invocation/ScopedPojoInvokerTestCase.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/invocation/ScopedPojoInvokerTestCase.java
new file mode 100644
index 0000000000..6f532bc76a
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/invocation/ScopedPojoInvokerTestCase.java
@@ -0,0 +1,54 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.invocation;
+
+import java.lang.reflect.Method;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.container.java.invocation.ScopedJavaComponentInvoker;
+import org.apache.tuscany.container.java.invocation.mock.SimpleTarget;
+import org.apache.tuscany.container.java.mock.MockScopeContext;
+import org.apache.tuscany.core.context.QualifiedName;
+import org.apache.tuscany.core.context.ScopeContext;
+
+public class ScopedPojoInvokerTestCase extends TestCase {
+
+ private Method echoMethod;
+
+ public ScopedPojoInvokerTestCase() {
+ super();
+ }
+
+ public ScopedPojoInvokerTestCase(String arg0) {
+ super(arg0);
+ }
+
+ public void setUp() throws Exception {
+ echoMethod = SimpleTarget.class.getDeclaredMethod("echo", new Class[]{String.class});
+ Assert.assertNotNull(echoMethod);
+ }
+
+ public void testScopedInvoke() throws Exception {
+ ScopeContext container = new MockScopeContext();
+ ScopedJavaComponentInvoker invoker = new ScopedJavaComponentInvoker(new QualifiedName("foo"), echoMethod, container);
+ Object ret = invoker.invokeTarget("foo");
+ Assert.assertEquals("foo", ret);
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/invocation/StaticPojoInvokerTestCase.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/invocation/StaticPojoInvokerTestCase.java
new file mode 100644
index 0000000000..e90b7623e8
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/invocation/StaticPojoInvokerTestCase.java
@@ -0,0 +1,155 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.invocation;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.container.java.invocation.StaticJavaComponentTargetInvoker;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+public class StaticPojoInvokerTestCase extends TestCase {
+
+ private Method echoMethod;
+ private Method arrayMethod;
+ private Method nullParamMethod;
+ private Method primitiveMethod;
+ private Method checkedMethod;
+ private Method runtimeMethod;
+
+ public StaticPojoInvokerTestCase() {
+
+ }
+
+ public StaticPojoInvokerTestCase(String arg0) {
+ super(arg0);
+ }
+
+ public void setUp() throws Exception {
+ echoMethod = TestBean.class.getDeclaredMethod("echo", new Class[]{String.class});
+ arrayMethod = TestBean.class.getDeclaredMethod("arrayEcho", new Class[]{String[].class});
+ nullParamMethod = TestBean.class.getDeclaredMethod("nullParam", (Class[]) null);
+ primitiveMethod = TestBean.class.getDeclaredMethod("primitiveEcho", new Class[]{Integer.TYPE});
+ checkedMethod = TestBean.class.getDeclaredMethod("checkedException", (Class[]) null);
+ runtimeMethod = TestBean.class.getDeclaredMethod("runtimeException", (Class[]) null);
+ Assert.assertNotNull(echoMethod);
+ Assert.assertNotNull(checkedMethod);
+ Assert.assertNotNull(runtimeMethod);
+ }
+
+ public void testObjectInvoke() throws Throwable {
+ TestBean bean = new TestBean();
+ StaticJavaComponentTargetInvoker invoker = new StaticJavaComponentTargetInvoker(echoMethod, bean);
+ Object ret = invoker.invokeTarget("foo");
+ Assert.assertEquals("foo", ret);
+ }
+
+ public void testArrayInvoke() throws Throwable {
+ TestBean bean = new TestBean();
+ StaticJavaComponentTargetInvoker invoker = new StaticJavaComponentTargetInvoker(arrayMethod, bean);
+ String[] args = new String[]{"foo", "bar"};
+ Object ret = invoker.invokeTarget(new Object[]{args});
+ String[] retA = (String[]) ret;
+ Assert.assertNotNull(retA);
+ Assert.assertEquals(2, retA.length);
+ Assert.assertEquals("foo", retA[0]);
+ Assert.assertEquals("bar", retA[1]);
+ }
+
+ public void testNullInvoke() throws Throwable {
+ TestBean bean = new TestBean();
+ StaticJavaComponentTargetInvoker invoker = new StaticJavaComponentTargetInvoker(nullParamMethod, bean);
+ Object ret = invoker.invokeTarget(null);
+ String retS = (String) ret;
+ Assert.assertEquals("foo", retS);
+ }
+
+ public void testPrimitiveInvoke() throws Throwable {
+ TestBean bean = new TestBean();
+ StaticJavaComponentTargetInvoker invoker = new StaticJavaComponentTargetInvoker(primitiveMethod, bean);
+ Object ret = invoker.invokeTarget(new Integer[]{new Integer(1)});
+ Integer retI = (Integer) ret;
+ Assert.assertEquals(1, retI.intValue());
+ }
+
+ public void testInvokeCheckedException() throws Throwable {
+ TestBean bean = new TestBean();
+ StaticJavaComponentTargetInvoker invoker = new StaticJavaComponentTargetInvoker(checkedMethod, bean);
+ try {
+ invoker.invokeTarget(null);
+ } catch (InvocationTargetException e) {
+ if (e.getCause() != null && TestException.class.equals(e.getCause().getClass())) {
+ return;
+ }
+ } catch (Throwable e) {
+ }
+ fail(TestException.class.getName() + " should have been thrown");
+ }
+
+ public void testInvokeRuntimeException() throws Throwable {
+ TestBean bean = new TestBean();
+ StaticJavaComponentTargetInvoker invoker = new StaticJavaComponentTargetInvoker(runtimeMethod, bean);
+ try {
+ invoker.invokeTarget(null);
+ } catch (InvocationTargetException e) {
+ if (e.getCause() != null && e.getCause() instanceof TestRuntimeException) {
+ return;
+ }
+ }
+ fail(TestException.class.getName() + " should have been thrown");
+ }
+
+ private class TestBean {
+
+ public String echo(String msg) throws Exception {
+ Assert.assertEquals("foo", msg);
+ return msg;
+ }
+
+ public String[] arrayEcho(String[] msg) throws Exception {
+ Assert.assertNotNull(msg);
+ Assert.assertEquals(2, msg.length);
+ Assert.assertEquals("foo", msg[0]);
+ Assert.assertEquals("bar", msg[1]);
+ return msg;
+ }
+
+ public String nullParam() throws Exception {
+ return "foo";
+ }
+
+ public int primitiveEcho(int i) throws Exception {
+ return i;
+ }
+
+ public void checkedException() throws TestException {
+ throw new TestException();
+ }
+
+ public void runtimeException() throws TestRuntimeException {
+ throw new TestRuntimeException();
+ }
+ }
+
+ public class TestException extends Exception {
+ }
+
+ public class TestRuntimeException extends RuntimeException {
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/invocation/mock/MockHandler.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/invocation/mock/MockHandler.java
new file mode 100644
index 0000000000..da862b1bc1
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/invocation/mock/MockHandler.java
@@ -0,0 +1,25 @@
+/**
+ *
+ */
+package org.apache.tuscany.container.java.invocation.mock;
+
+import org.apache.tuscany.core.invocation.MessageHandler;
+import org.apache.tuscany.core.message.Message;
+
+/**
+ *
+ */
+public class MockHandler implements MessageHandler {
+
+ private int count =0;
+
+ public boolean processMessage(Message message) {
+ //System.out.println("Invoking handler");
+ count++;
+ return true;
+ }
+
+ public int getCount(){
+ return count;
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/invocation/mock/MockSyncInterceptor.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/invocation/mock/MockSyncInterceptor.java
new file mode 100644
index 0000000000..4a07f32e2c
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/invocation/mock/MockSyncInterceptor.java
@@ -0,0 +1,45 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.invocation.mock;
+
+import org.apache.tuscany.core.invocation.Interceptor;
+import org.apache.tuscany.core.message.Message;
+
+public class MockSyncInterceptor implements Interceptor {
+
+ private int count;
+
+ private Interceptor next;
+
+ public MockSyncInterceptor() {
+ }
+
+ public Message invoke(Message msg) {
+ ++count;
+ //System.out.println("Invoking interceptor");
+ return next.invoke(msg);
+ }
+
+ public int getCount() {
+ return count;
+ }
+
+ public void setNext(Interceptor next) {
+ this.next=next;
+ }
+}
+
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/invocation/mock/SimpleSource.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/invocation/mock/SimpleSource.java
new file mode 100644
index 0000000000..213caab7e9
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/invocation/mock/SimpleSource.java
@@ -0,0 +1,25 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.invocation.mock;
+
+public interface SimpleSource {
+
+ public void invokeHello() throws Exception;
+
+ public void invokeGoodbye() throws Exception;
+}
+
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/invocation/mock/SimpleSourceImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/invocation/mock/SimpleSourceImpl.java
new file mode 100644
index 0000000000..2e7bd75f11
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/invocation/mock/SimpleSourceImpl.java
@@ -0,0 +1,36 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.invocation.mock;
+
+public class SimpleSourceImpl implements SimpleSource {
+
+ private SimpleTarget proxy;
+
+ public SimpleSourceImpl(SimpleTarget proxy) {
+ this.proxy = proxy;
+ }
+
+ public void invokeHello() throws Exception {
+ proxy.hello("hello");
+ }
+
+ public void invokeGoodbye() throws Exception {
+ proxy.goodbye("hello");
+ }
+
+}
+
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/invocation/mock/SimpleTarget.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/invocation/mock/SimpleTarget.java
new file mode 100644
index 0000000000..cbd3037529
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/invocation/mock/SimpleTarget.java
@@ -0,0 +1,28 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.invocation.mock;
+
+public interface SimpleTarget {
+
+ public String hello(String message) throws Exception;
+
+ public String goodbye(String message) throws Exception;
+
+ public String echo(String message) throws Exception;
+
+}
+
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/invocation/mock/SimpleTargetImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/invocation/mock/SimpleTargetImpl.java
new file mode 100644
index 0000000000..18abf6108a
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/invocation/mock/SimpleTargetImpl.java
@@ -0,0 +1,39 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.invocation.mock;
+
+public class SimpleTargetImpl implements SimpleTarget {
+
+ public SimpleTargetImpl() {
+ super();
+ }
+
+ public String hello(String message) throws Exception {
+ return message;
+ }
+
+ public String goodbye(String message) throws Exception {
+ return message;
+ }
+
+ public String echo(String message) throws Exception {
+ return message;
+ }
+
+
+}
+
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/MockConfigContext.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/MockConfigContext.java
new file mode 100644
index 0000000000..413f4a5a5b
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/MockConfigContext.java
@@ -0,0 +1,56 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.mock;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.core.builder.BuilderConfigException;
+import org.apache.tuscany.core.builder.RuntimeConfigurationBuilder;
+import org.apache.tuscany.core.builder.impl.AssemblyVisitor;
+import org.apache.tuscany.core.config.ConfigurationException;
+import org.apache.tuscany.core.context.AggregateContext;
+import org.apache.tuscany.core.context.ConfigurationContext;
+import org.apache.tuscany.core.context.ScopeContext;
+import org.apache.tuscany.core.invocation.spi.ProxyFactory;
+import org.apache.tuscany.model.assembly.Extensible;
+
+/**
+ * A mock configuration context
+ *
+ * @version $Rev: 368822 $ $Date: 2006-01-13 10:54:38 -0800 (Fri, 13 Jan 2006) $
+ */
+public class MockConfigContext implements ConfigurationContext {
+
+ private List<RuntimeConfigurationBuilder> builders = new ArrayList();
+
+ public MockConfigContext(List<RuntimeConfigurationBuilder> builders) {
+ this.builders=builders;
+ }
+
+ public void configure(Extensible model) throws ConfigurationException {
+ }
+
+ public void build(AggregateContext parent, Extensible model) throws BuilderConfigException {
+ AssemblyVisitor visitor = new AssemblyVisitor(parent, builders);
+ visitor.start(model);
+ }
+
+ public void wire(ProxyFactory sourceFactory, ProxyFactory targetFactory, Class targetType, boolean downScope, ScopeContext targetScopeContext) throws BuilderConfigException {
+ }
+
+ public void wire(ProxyFactory targetFactory, Class targetType, ScopeContext targetScopeContext) throws BuilderConfigException {
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/MockFactory.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/MockFactory.java
new file mode 100644
index 0000000000..192ce328fb
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/MockFactory.java
@@ -0,0 +1,548 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.mock;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.container.java.assembly.JavaAssemblyFactory;
+import org.apache.tuscany.container.java.assembly.JavaImplementation;
+import org.apache.tuscany.container.java.assembly.impl.JavaAssemblyFactoryImpl;
+import org.apache.tuscany.container.java.assembly.mock.HelloWorldImpl;
+import org.apache.tuscany.container.java.assembly.mock.HelloWorldService;
+import org.apache.tuscany.container.java.builder.JavaComponentContextBuilder;
+import org.apache.tuscany.container.java.builder.JavaTargetWireBuilder;
+import org.apache.tuscany.container.java.context.JavaComponentContext;
+import org.apache.tuscany.container.java.invocation.mock.MockSyncInterceptor;
+import org.apache.tuscany.container.java.mock.binding.foo.FooBinding;
+import org.apache.tuscany.container.java.mock.binding.foo.FooBindingBuilder;
+import org.apache.tuscany.container.java.mock.binding.foo.FooBindingWireBuilder;
+import org.apache.tuscany.container.java.mock.components.GenericComponent;
+import org.apache.tuscany.container.java.mock.components.HelloWorldClient;
+import org.apache.tuscany.container.java.mock.components.ModuleScopeComponentImpl;
+import org.apache.tuscany.core.builder.BuilderException;
+import org.apache.tuscany.core.builder.RuntimeConfiguration;
+import org.apache.tuscany.core.builder.RuntimeConfigurationBuilder;
+import org.apache.tuscany.core.config.ConfigurationException;
+import org.apache.tuscany.core.config.JavaIntrospectionHelper;
+import org.apache.tuscany.core.context.AggregateContext;
+import org.apache.tuscany.core.context.EventContext;
+import org.apache.tuscany.core.context.InstanceContext;
+import org.apache.tuscany.core.context.SystemAggregateContext;
+import org.apache.tuscany.core.context.impl.AggregateContextImpl;
+import org.apache.tuscany.core.injection.EventInvoker;
+import org.apache.tuscany.core.injection.FieldInjector;
+import org.apache.tuscany.core.injection.Injector;
+import org.apache.tuscany.core.injection.MethodEventInvoker;
+import org.apache.tuscany.core.injection.MethodInjector;
+import org.apache.tuscany.core.injection.PojoObjectFactory;
+import org.apache.tuscany.core.injection.SingletonObjectFactory;
+import org.apache.tuscany.core.runtime.RuntimeContext;
+import org.apache.tuscany.core.runtime.RuntimeContextImpl;
+import org.apache.tuscany.core.system.assembly.SystemAssemblyFactory;
+import org.apache.tuscany.core.system.assembly.SystemBinding;
+import org.apache.tuscany.core.system.assembly.SystemImplementation;
+import org.apache.tuscany.core.system.assembly.impl.SystemAssemblyFactoryImpl;
+import org.apache.tuscany.core.system.builder.SystemComponentContextBuilder;
+import org.apache.tuscany.core.system.builder.SystemEntryPointBuilder;
+import org.apache.tuscany.core.system.builder.SystemExternalServiceBuilder;
+import org.apache.tuscany.core.system.context.SystemAggregateContextImpl;
+import org.apache.tuscany.model.assembly.AggregatePart;
+import org.apache.tuscany.model.assembly.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.Component;
+import org.apache.tuscany.model.assembly.ConfiguredReference;
+import org.apache.tuscany.model.assembly.ConfiguredService;
+import org.apache.tuscany.model.assembly.EntryPoint;
+import org.apache.tuscany.model.assembly.ExternalService;
+import org.apache.tuscany.model.assembly.Module;
+import org.apache.tuscany.model.assembly.Reference;
+import org.apache.tuscany.model.assembly.Scope;
+import org.apache.tuscany.model.assembly.Service;
+import org.apache.tuscany.model.assembly.SimpleComponent;
+import org.apache.tuscany.model.assembly.impl.AssemblyModelContextImpl;
+import org.apache.tuscany.model.types.java.JavaServiceContract;
+import org.osoa.sca.annotations.ComponentName;
+import org.osoa.sca.annotations.Context;
+import org.osoa.sca.annotations.Destroy;
+import org.osoa.sca.annotations.Init;
+
+/**
+ * Generates test components, modules, and runtime artifacts
+ *
+ * @version $Rev$ $Date$
+ */
+public class MockFactory {
+
+ public static final String JAVA_BUILDER = "java.runtime.builder";
+
+ public static final String JAVA_WIRE_BUILDER = "java.wire.builder";
+
+ public static final String FOO_BUILDER = "foo.binding.builder";
+
+ public static final String FOO_WIRE_BUILDER = "foo.binding.wire.builder";
+
+ public static final String SYSTEM_CHILD = "tuscany.system.child";
+
+ private static JavaAssemblyFactory factory = new JavaAssemblyFactoryImpl();
+
+ private static SystemAssemblyFactory systemFactory = new SystemAssemblyFactoryImpl();
+
+ private static AssemblyModelContext assemblyContext = new AssemblyModelContextImpl(null, null);
+
+ /**
+ * Creates an initialized simple component
+ *
+ * @param name the component name
+ * @param type the implementation type
+ * @param scope the component scope
+ */
+ public static SimpleComponent createComponent(String name, Class type, Scope scope) {
+ SimpleComponent sc = factory.createSimpleComponent();
+ JavaImplementation impl = factory.createJavaImplementation();
+ impl.setComponentType(factory.createComponentType());
+ impl.setImplementationClass(type);
+ sc.setComponentImplementation(impl);
+ Service s = factory.createService();
+ JavaServiceContract ji = factory.createJavaServiceContract();
+ s.setServiceContract(ji);
+ ji.setScope(scope);
+ impl.getComponentType().getServices().add(s);
+ sc.setName(name);
+ sc.setComponentImplementation(impl);
+ return sc;
+ }
+
+ /**
+ * Creates a system component of the given type with the given name and scope
+ */
+ public static Component createSystemComponent(String name, Class type, Scope scope) {
+
+ Component sc = null;
+ if (AggregateContext.class.isAssignableFrom(type)) {
+ sc = systemFactory.createModuleComponent();
+ } else {
+ sc = systemFactory.createSimpleComponent();
+ }
+ SystemImplementation impl = systemFactory.createSystemImplementation();
+ impl.setImplementationClass(type);
+ sc.setComponentImplementation(impl);
+ Service s = systemFactory.createService();
+ JavaServiceContract ji = systemFactory.createJavaServiceContract();
+ s.setServiceContract(ji);
+ ji.setScope(scope);
+ impl.setComponentType(systemFactory.createComponentType());
+ impl.getComponentType().getServices().add(s);
+ sc.setName(name);
+ sc.setComponentImplementation(impl);
+ return sc;
+ }
+
+ /**
+ * Creates an aggregate component with the given name
+ */
+ public static Component createAggregateComponent(String name) {
+ Component sc = sc = systemFactory.createModuleComponent();
+ SystemImplementation impl = systemFactory.createSystemImplementation();
+ impl.setImplementationClass(AggregateContextImpl.class);
+ sc.setComponentImplementation(impl);
+ Service s = systemFactory.createService();
+ JavaServiceContract ji = systemFactory.createJavaServiceContract();
+ s.setServiceContract(ji);
+ ji.setScope(Scope.AGGREGATE);
+ impl.setComponentType(systemFactory.createComponentType());
+ impl.getComponentType().getServices().add(s);
+ sc.setName(name);
+ sc.setComponentImplementation(impl);
+ return sc;
+ }
+
+ /**
+ * Creates a system aggregate component with the given name
+ */
+ public static Component createSystemAggregateComponent(String name) {
+ Component sc = sc = systemFactory.createModuleComponent();
+ SystemImplementation impl = systemFactory.createSystemImplementation();
+ impl.setImplementationClass(SystemAggregateContextImpl.class);
+ sc.setComponentImplementation(impl);
+ Service s = systemFactory.createService();
+ JavaServiceContract ji = systemFactory.createJavaServiceContract();
+ s.setServiceContract(ji);
+ ji.setScope(Scope.AGGREGATE);
+ impl.setComponentType(systemFactory.createComponentType());
+ impl.getComponentType().getServices().add(s);
+ sc.setName(name);
+ sc.setComponentImplementation(impl);
+ return sc;
+ }
+
+ /**
+ * Creates an external service configured with the 'Foo' test binding
+ */
+ public static ExternalService createFooBindingExternalService(String name, Class interfaz) {
+ ExternalService es = factory.createExternalService();
+ es.setName(name);
+ Service s = factory.createService();
+ JavaServiceContract ji = factory.createJavaServiceContract();
+ ji.setScope(Scope.MODULE);
+ ji.setInterface(interfaz);
+ s.setServiceContract(ji);
+ ConfiguredService configuredService = factory.createConfiguredService();
+ es.setConfiguredService(configuredService);
+
+ FooBinding binding = new FooBinding();
+ es.getBindings().add(binding);
+ return es;
+ }
+
+ /**
+ * Creates an entry point with the given name configured with the given interface and the {@link FooBinding}
+ */
+ public static EntryPoint createFooBindingEntryPoint(String name, Class interfaz) {
+ EntryPoint ep = factory.createEntryPoint();
+ ep.setName(name);
+ Service s = factory.createService();
+ JavaServiceContract ji = factory.createJavaServiceContract();
+ ji.setScope(Scope.MODULE);
+ ji.setInterface(interfaz);
+ s.setServiceContract(ji);
+ ConfiguredService configuredService = factory.createConfiguredService();
+ configuredService.setService(s);
+ ep.setConfiguredService(configuredService);
+ FooBinding binding = new FooBinding();
+ ep.getBindings().add(binding);
+ return ep;
+ }
+
+ /**
+ * Creates an entry point wired to the given target (e.g. component, external service) using the system binding
+ *
+ * @param name the name of the entry point
+ * @param interfaz the inteface exposed by the entry point
+ * @param refName the name of the entry point reference
+ * @param target the target the entry point is wired to
+ */
+ public static EntryPoint createEPSystemBinding(String name, Class interfaz, String refName, AggregatePart target) {
+ JavaServiceContract contract = systemFactory.createJavaServiceContract();
+ contract.setInterface(interfaz);
+
+ EntryPoint ep = systemFactory.createEntryPoint();
+ ep.setName(name);
+
+ Reference ref = systemFactory.createReference();
+ ref.setName(refName);
+ ref.setServiceContract(contract);
+ ConfiguredReference configuredReference = systemFactory.createConfiguredReference();
+ configuredReference.setReference(ref);
+ Service service = systemFactory.createService();
+ service.setServiceContract(contract);
+
+ ConfiguredService cService = systemFactory.createConfiguredService();
+ cService.setService(service);
+ cService.initialize(MockFactory.assemblyContext);
+
+ configuredReference.getTargetConfiguredServices().add(cService);
+ ep.setConfiguredReference(configuredReference);
+
+ Service epService = systemFactory.createService();
+ epService.setServiceContract(contract);
+
+ ConfiguredService epCService = systemFactory.createConfiguredService();
+ epCService.initialize(MockFactory.assemblyContext);
+ epCService.setService(epService);
+
+ ep.setConfiguredService(epCService);
+ SystemBinding binding = systemFactory.createSystemBinding();
+ ep.getBindings().add(binding);
+ if (target != null) {
+ if (target instanceof Component) {
+ ((Component) target).getConfiguredServices().add(cService);
+ } else if (target instanceof ExternalService) {
+ ((ExternalService) target).setConfiguredService(cService);
+ }
+ target.initialize(MockFactory.assemblyContext);
+ }
+ ep.initialize(null);
+ return ep;
+ }
+
+ /**
+ * Creates an external service configured with a {@link SystemBinding}
+ */
+ public static ExternalService createESSystemBinding(String name, String refName) {
+ ExternalService es = systemFactory.createExternalService();
+ es.setName(name);
+ ConfiguredService configuredService = systemFactory.createConfiguredService();
+ es.setConfiguredService(configuredService);
+ SystemBinding binding = systemFactory.createSystemBinding();
+ binding.setTargetName(refName);
+ es.getBindings().add(binding);
+ es.initialize(null);
+ return es;
+ }
+
+ /**
+ * Creates a module with a Java-based "target" module-scoped component wired to a module-scoped "source"
+ */
+ public static Module createModule() {
+ return createModule(Scope.MODULE, Scope.MODULE);
+ }
+
+ /**
+ * Creates a module with a Java-based "target" component wired to a "source"
+ */
+ public static Module createModule(Scope sourceScope, Scope targetScope) {
+ Component sourceComponent = createComponent("source", ModuleScopeComponentImpl.class, sourceScope);
+ Component targetComponent = createComponent("target", ModuleScopeComponentImpl.class, targetScope);
+
+ Service targetService = factory.createService();
+ JavaServiceContract targetContract = factory.createJavaServiceContract();
+ targetContract.setInterface(GenericComponent.class);
+ targetService.setServiceContract(targetContract);
+ targetService.setName("GenericComponent");
+ ConfiguredService cTargetService = factory.createConfiguredService();
+ cTargetService.setService(targetService);
+ cTargetService.initialize(assemblyContext);
+ targetComponent.getConfiguredServices().add(cTargetService);
+ targetComponent.initialize(assemblyContext);
+
+ Reference ref = factory.createReference();
+ ConfiguredReference cref = factory.createConfiguredReference();
+ ref.setName("setGenericComponent");
+ JavaServiceContract inter = factory.createJavaServiceContract();
+ inter.setInterface(GenericComponent.class);
+ ref.setServiceContract(inter);
+ cref.setReference(ref);
+ cref.getTargetConfiguredServices().add(cTargetService);
+ cref.initialize(assemblyContext);
+ sourceComponent.getConfiguredReferences().add(cref);
+ sourceComponent.initialize(assemblyContext);
+
+ Module module = factory.createModule();
+ module.setName("test.module");
+ module.getComponents().add(sourceComponent);
+ module.getComponents().add(targetComponent);
+ module.initialize(assemblyContext);
+ return module;
+ }
+
+ /**
+ * Creates a module with a Java-based source component wired to a "target" external service configured with the
+ * {@link FooBinding}
+ */
+ public static Module createModuleWithExternalService() {
+ Component sourceComponent = createComponent("source", HelloWorldClient.class, Scope.MODULE);
+ ExternalService targetES = createFooBindingExternalService("target", HelloWorldService.class);
+
+ Service targetService = factory.createService();
+ JavaServiceContract targetContract = factory.createJavaServiceContract();
+ targetContract.setInterface(HelloWorldService.class);
+ targetService.setServiceContract(targetContract);
+ targetService.setName("HelloWorld");
+ ConfiguredService cTargetService = factory.createConfiguredService();
+ cTargetService.setService(targetService);
+ targetES.setConfiguredService(cTargetService);
+ targetES.initialize(assemblyContext);
+
+ Reference ref = factory.createReference();
+ ConfiguredReference cref = factory.createConfiguredReference();
+ ref.setName("setHelloWorldService");
+ JavaServiceContract inter = factory.createJavaServiceContract();
+ inter.setInterface(HelloWorldService.class);
+ ref.setServiceContract(inter);
+ cref.setReference(ref);
+ cref.getTargetConfiguredServices().add(cTargetService);
+ cref.initialize(assemblyContext);
+ sourceComponent.getConfiguredReferences().add(cref);
+ sourceComponent.initialize(assemblyContext);
+
+ Module module = factory.createModule();
+ module.setName("test.module");
+ module.getComponents().add(sourceComponent);
+ module.getExternalServices().add(targetES);
+ module.initialize(assemblyContext);
+ return module;
+ }
+
+ /**
+ * Creates a module with an entry point named "source" configured with the {@link FooBinding} wired to a service
+ * offered by a Java-based component named "target"
+ *
+ * @param scope the scope of the target service
+ */
+ public static Module createModuleWithEntryPoint(Scope scope) {
+ EntryPoint sourceEP = createFooBindingEntryPoint("source", HelloWorldService.class);
+ Component targetComponent = createComponent("target", HelloWorldImpl.class, scope);
+
+ Service targetService = factory.createService();
+ JavaServiceContract targetContract = factory.createJavaServiceContract();
+ targetContract.setInterface(HelloWorldService.class);
+ targetService.setServiceContract(targetContract);
+ targetService.setName("HelloWorldService");
+ ConfiguredService cTargetService = factory.createConfiguredService();
+ cTargetService.setService(targetService);
+ targetComponent.getConfiguredServices().add(cTargetService);
+ targetComponent.initialize(assemblyContext);
+
+ Reference ref = factory.createReference();
+ ConfiguredReference cref = factory.createConfiguredReference();
+ ref.setName("setHelloWorldService");
+ JavaServiceContract inter = factory.createJavaServiceContract();
+ inter.setInterface(HelloWorldService.class);
+ ref.setServiceContract(inter);
+ cref.setReference(ref);
+ cref.getTargetConfiguredServices().add(cTargetService);
+ cref.initialize(assemblyContext);
+ sourceEP.setConfiguredReference(cref);
+ sourceEP.getConfiguredService().getService().setName("HelloWorldService");
+ sourceEP.initialize(assemblyContext);
+
+ Module module = factory.createModule();
+ module.setName("test.module");
+ module.getEntryPoints().add(sourceEP);
+ module.getComponents().add(targetComponent);
+ module.initialize(assemblyContext);
+ return module;
+ }
+
+ /**
+ * Returns a collection of bootstrap configuration builders
+ */
+ public static List<RuntimeConfigurationBuilder> createSystemBuilders() {
+ List<RuntimeConfigurationBuilder> builders = new ArrayList();
+ builders.add((new SystemComponentContextBuilder()));
+ builders.add(new SystemEntryPointBuilder());
+ builders.add(new SystemExternalServiceBuilder());
+ return builders;
+ }
+
+ /**
+ * Creates an aggregate runtime configuration
+ *
+ * @param name the name of the component
+ * @param aggregateContext the containing aggregate context
+ * @throws BuilderException
+ * @see RuntimeConfiguration
+ */
+ public static RuntimeConfiguration<InstanceContext> createAggregateConfiguration(String name,
+ AggregateContext aggregateContext) throws BuilderException {
+
+ Component sc = createAggregateComponent(name);
+ SystemComponentContextBuilder builder = new SystemComponentContextBuilder();
+ builder.build(sc, aggregateContext);
+ return (RuntimeConfiguration<InstanceContext>) sc.getComponentImplementation().getRuntimeConfiguration();
+ }
+
+ /**
+ * Creates a Java POJO component context
+ *
+ * @param name the name of the context
+ * @param implType the POJO class
+ * @param scope the component scope
+ * @param moduleComponentContext the containing aggregate context
+ * @throws NoSuchMethodException if the POJO does not have a default noi-args constructor
+ */
+ public static JavaComponentContext createPojoContext(String name, Class implType, Scope scope,
+ AggregateContext moduleComponentContext) throws NoSuchMethodException {
+ SimpleComponent component = createComponent(name, implType, scope);
+
+ Set<Field> fields = JavaIntrospectionHelper.getAllFields(implType);
+ Set<Method> methods = JavaIntrospectionHelper.getAllUniqueMethods(implType);
+ List<Injector> injectors = new ArrayList();
+ EventInvoker initInvoker = null;
+ boolean eagerInit = false;
+ EventInvoker destroyInvoker = null;
+ for (Field field : fields) {
+ ComponentName compName = field.getAnnotation(ComponentName.class);
+ if (compName != null) {
+ Injector injector = new FieldInjector(field, new SingletonObjectFactory(name));
+ injectors.add(injector);
+ }
+ Context context = field.getAnnotation(Context.class);
+ if (context != null) {
+ Injector injector = new FieldInjector(field, new SingletonObjectFactory(moduleComponentContext));
+ injectors.add(injector);
+ }
+ }
+ for (Method method : methods) {
+ // FIXME Java5
+ Init init = method.getAnnotation(Init.class);
+ if (init != null && initInvoker == null) {
+ initInvoker = new MethodEventInvoker(method);
+ eagerInit = init.eager();
+ continue;
+ }
+ Destroy destroy = method.getAnnotation(Destroy.class);
+ if (destroy != null && destroyInvoker == null) {
+ destroyInvoker = new MethodEventInvoker(method);
+ continue;
+ }
+ ComponentName compName = method.getAnnotation(ComponentName.class);
+ if (compName != null) {
+ Injector injector = new MethodInjector(method, new SingletonObjectFactory(name));
+ injectors.add(injector);
+ }
+ Context context = method.getAnnotation(Context.class);
+ if (context != null) {
+ Injector injector = new MethodInjector(method, new SingletonObjectFactory(moduleComponentContext));
+ injectors.add(injector);
+ }
+ }
+ boolean stateless = (scope == Scope.INSTANCE);
+ JavaComponentContext context = new JavaComponentContext("foo", new PojoObjectFactory(JavaIntrospectionHelper
+ .getDefaultConstructor(implType), null, injectors), eagerInit, initInvoker, destroyInvoker, stateless);
+ return context;
+ }
+
+ /**
+ * Creates a default {@link RuntimeContext} configured with support for Java component implementations
+ *
+ * @throws ConfigurationException
+ */
+ public static RuntimeContext createJavaRuntime() throws ConfigurationException {
+ RuntimeContext runtime = new RuntimeContextImpl(null, null, MockFactory.createSystemBuilders(), null);
+ runtime.start();
+ runtime.getSystemContext().registerModelObject(createSystemAggregateComponent(SYSTEM_CHILD));
+ SystemAggregateContext ctx = (SystemAggregateContext) runtime.getSystemContext().getContext(SYSTEM_CHILD);
+ ctx.registerModelObject(createSystemComponent(JAVA_BUILDER, JavaComponentContextBuilder.class, Scope.MODULE));
+ ctx.registerModelObject(createSystemComponent(JAVA_WIRE_BUILDER, JavaTargetWireBuilder.class, Scope.MODULE));
+ ctx.fireEvent(EventContext.MODULE_START, null);
+ return runtime;
+ }
+
+ /**
+ * Registers the {@link FooBinding} builders with a given runtime
+ *
+ * @throws ConfigurationException
+ */
+ public static RuntimeContext registerFooBinding(RuntimeContext runtime) throws ConfigurationException {
+ AggregateContext child = (AggregateContext) runtime.getSystemContext().getContext(MockFactory.SYSTEM_CHILD);
+ JavaComponentContextBuilder javaBuilder = (JavaComponentContextBuilder) child.getContext(MockFactory.JAVA_BUILDER)
+ .getInstance(null);
+ MockSyncInterceptor mockInterceptor = new MockSyncInterceptor();
+ child.registerModelObject(MockFactory.createSystemComponent(FOO_BUILDER, FooBindingBuilder.class, Scope.MODULE));
+ child.registerModelObject(MockFactory.createSystemComponent(FOO_WIRE_BUILDER, FooBindingWireBuilder.class, Scope.MODULE));
+ // since the child context is already started, we need to manually retrieve the components to init them
+ Assert.assertNotNull(child.getContext(FOO_BUILDER).getInstance(null));
+ Assert.assertNotNull(child.getContext(FOO_WIRE_BUILDER).getInstance(null));
+ return runtime;
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/MockScopeContext.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/MockScopeContext.java
new file mode 100644
index 0000000000..a6d9c0b2c5
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/MockScopeContext.java
@@ -0,0 +1,137 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.mock;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.container.java.invocation.mock.SimpleTargetImpl;
+import org.apache.tuscany.core.builder.RuntimeConfiguration;
+import org.apache.tuscany.core.context.InstanceContext;
+import org.apache.tuscany.core.context.EventException;
+import org.apache.tuscany.core.context.QualifiedName;
+import org.apache.tuscany.core.context.LifecycleEventListener;
+import org.apache.tuscany.core.context.ScopeContext;
+import org.apache.tuscany.core.context.ScopeRuntimeException;
+import org.apache.tuscany.core.context.SimpleComponentContext;
+import org.apache.tuscany.core.context.TargetException;
+import org.apache.tuscany.model.assembly.SimpleComponent;
+
+public class MockScopeContext implements ScopeContext {
+
+ Map<String, Object> components;
+
+ public MockScopeContext() {
+ components = new HashMap();
+ components.put("foo", new SimpleTargetImpl());
+ components.put("bar", new SimpleTargetImpl());
+ }
+
+ public MockScopeContext(Map<String,Object> instances) {
+ components = instances;
+ }
+
+
+ public void start() {
+ }
+
+ public void stop() {
+ }
+
+ public String getName() {
+ return "Mock Scope Container";
+ }
+
+ public boolean isCacheable() {
+ return false;
+ }
+
+ public int[] getEventTypes() {
+ return null;
+ }
+
+ public SimpleComponentContext getContext(String name) {
+ return null;
+ }
+
+ public Object getInstance(QualifiedName name) throws ScopeRuntimeException {
+ return components.get(name.getPartName());
+ }
+
+ public Object getInstance(QualifiedName componentName, boolean notify) throws TargetException {
+ return getInstance(componentName);
+ }
+
+ public SimpleComponentContext getContextByKey(String name, Object key) {
+ return null;
+ }
+
+ public void setComponent(SimpleComponent component) throws ScopeRuntimeException {
+ }
+
+ public void removeContext(String name) throws ScopeRuntimeException {
+ }
+
+ public void removeContextByKey(String name, Object key) throws ScopeRuntimeException {
+ }
+
+ public SimpleComponent[] getComponents() {
+ return null;
+ }
+
+ public void onEvent(int type, Object message) throws EventException {
+ }
+
+
+ public void registerConfigurations(List<RuntimeConfiguration<InstanceContext>> configurations) {
+ }
+
+ public void registerConfiguration(RuntimeConfiguration<InstanceContext> configuration) {
+ }
+
+ public int getLifecycleState(){
+ return RUNNING;
+ }
+
+
+ public void setLifecycleState(int state) {
+ }
+
+
+ public void setName(String name) {
+ }
+
+
+ public void addContextListener(LifecycleEventListener listener) {
+ }
+
+
+ public void removeContextListener(LifecycleEventListener listener) {
+ }
+
+ public Object getImplementationInstance() throws TargetException{
+ return this;
+ }
+
+ public Object getImplementationInstance(boolean notify) throws TargetException{
+ return this;
+ }
+
+
+}
+
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooBinding.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooBinding.java
new file mode 100644
index 0000000000..75aabff105
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooBinding.java
@@ -0,0 +1,59 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.mock.binding.foo;
+
+import org.apache.tuscany.model.assembly.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.AssemblyModelVisitor;
+import org.apache.tuscany.model.assembly.Binding;
+import org.apache.tuscany.model.assembly.ModelInitException;
+
+/**
+ * Represents a mock binding that echoes back a single parameter
+ *
+ * @version $Rev$ $Date$
+ */
+public class FooBinding implements Binding {
+
+ public FooBinding() {
+ }
+
+ public String getURI() {
+ return null;
+ }
+
+ public void setURI(String value) {
+ }
+
+ public void initialize(AssemblyModelContext modelContext) throws ModelInitException {
+ }
+
+ public void freeze() {
+ }
+
+ public boolean accept(AssemblyModelVisitor visitor) {
+ return false;
+ }
+
+ private Object config;
+
+ public void setRuntimeConfiguration(Object configuration) {
+ config = configuration;
+ }
+
+ public Object getRuntimeConfiguration() {
+ System.out.println("retting");
+ return config;
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooBindingBuilder.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooBindingBuilder.java
new file mode 100644
index 0000000000..248f7e54bc
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooBindingBuilder.java
@@ -0,0 +1,192 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.mock.binding.foo;
+
+import java.lang.reflect.Method;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.tuscany.core.builder.BuilderException;
+import org.apache.tuscany.core.builder.ObjectFactory;
+import org.apache.tuscany.core.builder.RuntimeConfigurationBuilder;
+import org.apache.tuscany.core.builder.impl.EntryPointRuntimeConfiguration;
+import org.apache.tuscany.core.builder.impl.HierarchicalBuilder;
+import org.apache.tuscany.core.config.JavaIntrospectionHelper;
+import org.apache.tuscany.core.context.Context;
+import org.apache.tuscany.core.context.QualifiedName;
+import org.apache.tuscany.core.injection.ObjectCreationException;
+import org.apache.tuscany.core.invocation.InvocationConfiguration;
+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.EntryPoint;
+import org.apache.tuscany.model.assembly.ExternalService;
+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;
+
+/**
+ * Creates a <code>RuntimeConfigurationBuilder</code> for an entry point or external service configured with the
+ * {@link FooBinding}
+ *
+ * @version $Rev$ $Date$
+ */
+@Scope("MODULE")
+public class FooBindingBuilder implements RuntimeConfigurationBuilder {
+
+ @Autowire
+ private RuntimeContext runtimeContext;
+
+ private ProxyFactoryFactory proxyFactoryFactory;
+
+ private MessageFactory messageFactory;
+
+ /* the top-level builder responsible for evaluating policies */
+ private HierarchicalBuilder policyBuilder = new HierarchicalBuilder();
+
+ public FooBindingBuilder() {
+ }
+
+ @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;
+ }
+
+ /**
+ * Adds 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.
+ */
+ public void addPolicyBuilder(RuntimeConfigurationBuilder builder) {
+ policyBuilder.addBuilder(builder);
+ }
+
+ public void build(AssemblyModelObject object, Context context) throws BuilderException {
+ if (object instanceof EntryPoint) {
+ EntryPoint ep = (EntryPoint) object;
+ if (ep.getBindings().size() < 1 || !(ep.getBindings().get(0) instanceof FooBinding)) {
+ return;
+ }
+ EntryPointRuntimeConfiguration config = new FooEntryPointRuntimeConfiguration(ep.getName(), ep.getConfiguredService()
+ .getService().getName(), messageFactory);
+
+ ConfiguredService configuredService = ep.getConfiguredService();
+ Service service = configuredService.getService();
+ ServiceContract serviceContract = service.getServiceContract();
+ Map<Method, InvocationConfiguration> iConfigMap = new HashMap();
+ 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(ep.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, context);
+ }
+ // add tail interceptor
+ for (InvocationConfiguration iConfig : (Collection<InvocationConfiguration>) iConfigMap.values()) {
+ iConfig.addTargetInterceptor(new InvokerInterceptor());
+ }
+ ep.getConfiguredReference().setRuntimeConfiguration(config);
+
+ } else if (object instanceof ExternalService) {
+ ExternalService es = (ExternalService) object;
+ if (es.getBindings().size() < 1 || !(es.getBindings().get(0) instanceof FooBinding)) {
+ return;
+ }
+
+ FooExternalServiceRuntimeConfiguration config = new FooExternalServiceRuntimeConfiguration(es.getName(),
+ new FooClientFactory());
+
+ ConfiguredService configuredService = es.getConfiguredService();
+ Service service = configuredService.getService();
+ ServiceContract serviceContract = service.getServiceContract();
+ Map<Method, InvocationConfiguration> iConfigMap = new HashMap();
+ 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(es.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, context);
+ }
+ // add tail interceptor
+ for (InvocationConfiguration iConfig : (Collection<InvocationConfiguration>) iConfigMap.values()) {
+ iConfig.addTargetInterceptor(new InvokerInterceptor());
+ }
+
+ es.getConfiguredService().setRuntimeConfiguration(config);
+ } else {
+ return;
+
+ }
+ }
+
+ private class FooClientFactory implements ObjectFactory {
+
+ public Object getInstance() throws ObjectCreationException {
+ return new FooClient();
+ }
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooBindingWireBuilder.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooBindingWireBuilder.java
new file mode 100644
index 0000000000..bba70e4c84
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooBindingWireBuilder.java
@@ -0,0 +1,56 @@
+package org.apache.tuscany.container.java.mock.binding.foo;
+
+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;
+
+public class FooBindingWireBuilder implements WireBuilder {
+
+ public FooBindingWireBuilder() {
+ super();
+ }
+
+ private RuntimeContext runtimeContext;
+
+ @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 (!FooExternalServiceRuntimeConfiguration.class.isAssignableFrom(targetType)) {
+ return;
+ }
+ for (InvocationConfiguration sourceInvocationConfig : sourceFactory.getProxyConfiguration().getInvocationConfigurations()
+ .values()) {
+ FooESTargetInvoker invoker = new FooESTargetInvoker(sourceFactory.getProxyConfiguration().getTargetName()
+ .getPartName(), targetScopeContext);
+ sourceInvocationConfig.setTargetInvoker(invoker);
+ // if (downScope) {
+ // // the source scope is shorter than the target, so the invoker can cache the target instance
+ // invoker.setCacheable(true);
+ // } else {
+ // invoker.setCacheable(false);
+ // }
+ }
+
+ }
+
+ public void completeTargetChain(ProxyFactory targetFactory, Class targetType, ScopeContext targetScopeContext)
+ throws BuilderConfigException {
+ // TODO implement
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooClient.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooClient.java
new file mode 100644
index 0000000000..9f67eb7786
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooClient.java
@@ -0,0 +1,37 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.mock.binding.foo;
+
+import java.lang.reflect.Array;
+
+import org.apache.tuscany.core.context.TargetException;
+
+/**
+ * A mock client for a transport binding
+ *
+ * @version $Rev$ $Date$
+ */
+public class FooClient {
+
+ public FooClient() {
+ }
+
+ public Object invoke(Object msg) {
+ if (msg!=null && msg.getClass().isArray() && Array.getLength(msg) == 1){
+ return Array.get(msg,0);
+ }else{
+ throw new TargetException("This binding only understands operations with a single parameter");
+ }
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooESTargetInvoker.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooESTargetInvoker.java
new file mode 100644
index 0000000000..6dd42ef4d6
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooESTargetInvoker.java
@@ -0,0 +1,97 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.mock.binding.foo;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.apache.tuscany.core.context.ExternalServiceContext;
+import org.apache.tuscany.core.context.InstanceContext;
+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;
+
+/**
+ * Responsible for invoking a mock transport binding client configured for an external service
+ *
+ * @version $Rev$ $Date$
+ */
+public class FooESTargetInvoker implements TargetInvoker {
+
+ private String name;
+
+ private ScopeContext container;
+
+ private ExternalServiceContext context;
+
+ public FooESTargetInvoker(String esName, ScopeContext container) {
+ assert (esName != null) : "No external service name specified";
+ assert (container != null) : "No scope container specified";
+ name = esName;
+ this.container = container;
+ }
+
+ public Object invokeTarget(Object payload) throws InvocationTargetException {
+ if (context == null) {
+ InstanceContext iContext = container.getContext(name);
+ 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;
+ }
+ FooClient client = (FooClient) context.getImplementationInstance(true);
+ if (payload != null) {
+ return client.invoke(payload);
+ } else {
+ return client.invoke(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 {
+ FooESTargetInvoker invoker = (FooESTargetInvoker) super.clone();
+ invoker.container = container;
+ invoker.context = this.context;
+ invoker.name = this.name;
+ return invoker;
+ } catch (CloneNotSupportedException e) {
+ return null; // will not happen
+ }
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooEntryPointRuntimeConfiguration.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooEntryPointRuntimeConfiguration.java
new file mode 100644
index 0000000000..bee388127e
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooEntryPointRuntimeConfiguration.java
@@ -0,0 +1,31 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.mock.binding.foo;
+
+import org.apache.tuscany.core.builder.impl.EntryPointRuntimeConfiguration;
+import org.apache.tuscany.core.message.MessageFactory;
+
+/**
+ *
+ *
+ * @version $Rev$ $Date$
+ */
+public class FooEntryPointRuntimeConfiguration extends EntryPointRuntimeConfiguration {
+
+ public FooEntryPointRuntimeConfiguration(String name, String serviceName, MessageFactory msgFactory) {
+ super(name, serviceName, msgFactory);
+ }
+
+}
+
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooExternalServiceRuntimeConfiguration.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooExternalServiceRuntimeConfiguration.java
new file mode 100644
index 0000000000..e06a78d529
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooExternalServiceRuntimeConfiguration.java
@@ -0,0 +1,32 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.mock.binding.foo;
+
+import org.apache.tuscany.core.builder.ObjectFactory;
+import org.apache.tuscany.core.builder.impl.BaseExternalServiceRuntimeConfiguration;
+
+/**
+ * Creates instances of {@link org.apache.tuscany.core.context.ExternalServiceContext} configured with the appropriate
+ * invocation chains and bindings. This implementation serves as a marker for
+ * {@link org.apache.tuscany.container.java.mock.binding.foo.FooBindingWireBuilder}
+ *
+ * @version $Rev$ $Date$
+ */
+public class FooExternalServiceRuntimeConfiguration extends BaseExternalServiceRuntimeConfiguration {
+
+ public FooExternalServiceRuntimeConfiguration(String name, ObjectFactory objectFactory) {
+ super(name, objectFactory);
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/AbstractGenericComponent.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/AbstractGenericComponent.java
new file mode 100644
index 0000000000..0c9d8172f8
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/AbstractGenericComponent.java
@@ -0,0 +1,296 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.mock.components;
+
+import java.util.List;
+import java.util.Map;
+
+import org.osoa.sca.ModuleContext;
+import org.osoa.sca.annotations.ComponentName;
+import org.osoa.sca.annotations.Context;
+import org.osoa.sca.annotations.Property;
+
+/**
+ * Base test component implementation
+ *
+ * @version $Rev$ $Date$
+ */
+public class AbstractGenericComponent implements GenericComponent {
+
+ @ComponentName
+ private String name;
+
+ public String getName() {
+ return name;
+ }
+
+ @Context
+ private ModuleContext context;
+
+ public ModuleContext getModuleContext() {
+ return context;
+ }
+
+ //----------------------------------
+ // Collections
+ //----------------------------------
+
+ Map testMap;
+
+ public Map getTestMap() {
+ return testMap;
+ }
+
+ public void setTestMap(Map testMap) {
+ this.testMap = testMap;
+ }
+
+ List testList;
+
+ public List getTestList() {
+ return testList;
+ }
+
+ public void setTestList(List testList) {
+ this.testList = testList;
+ }
+
+ //----------------------------------
+ // Arrays
+ //----------------------------------
+
+ private int[] arrayInt;
+
+ public int[] getArrayInt() {
+ return arrayInt;
+ }
+
+ public void setArrayInt(int[] arrayInt) {
+ this.arrayInt = arrayInt;
+ }
+
+ private float[] arrayFloat;
+
+ public float[] getArrayFloat() {
+ return arrayFloat;
+ }
+
+ public void setArrayFloat(float[] pArrayFloat) {
+ arrayFloat = pArrayFloat;
+ }
+
+ private double[] arrayDouble;
+
+ public double[] getArrayDouble() {
+ return arrayDouble;
+ }
+
+ public void setArrayDouble(double[] pArrayDouble) {
+ arrayDouble = pArrayDouble;
+ }
+
+ private long[] arrayLong;
+
+ public long[] getArrayLong() {
+ return arrayLong;
+ }
+
+ public void setArrayLong(long[] arrayLong) {
+ this.arrayLong = arrayLong;
+ }
+
+ private short[] arrayShort;
+
+ public short[] getArrayShort() {
+ return arrayShort;
+ }
+
+ public void setArrayShort(short[] arrayShort) {
+ this.arrayShort = arrayShort;
+ }
+
+ private boolean[] arrayBoolean;
+
+ public boolean[] getArrayBoolean() {
+ return arrayBoolean;
+ }
+
+ public void setArrayBoolean(boolean[] arrayBoolean) {
+ this.arrayBoolean = arrayBoolean;
+ }
+
+ private String[] arrayString;
+
+ public String[] getArrayString() {
+ return arrayString;
+ }
+
+ public void setArrayString(String[] arrayString) {
+ this.arrayString = arrayString;
+ }
+
+ //----------------------------------
+ // Primitives
+ //----------------------------------
+
+ private boolean mBoolean;
+
+ public boolean getBoolean() {
+ return mBoolean;
+ }
+
+ public void setBoolean(boolean pBoolean) {
+ mBoolean = pBoolean;
+ }
+
+ private short mShort;
+
+ public short getShort() {
+ return mShort;
+ }
+
+ public void setShort(short pShort) {
+ mShort = pShort;
+ }
+
+ private int mInt;
+
+ public int getInt() {
+ return mInt;
+ }
+
+ public void setInt(int pInt) {
+ mInt = pInt;
+ }
+
+ private long mLong;
+
+ public long getLong() {
+ return mLong;
+ }
+
+ public void setLong(long pLong) {
+ mLong = pLong;
+ }
+
+ private double mDouble;
+
+ public double getDouble() {
+ return mDouble;
+ }
+
+ public void setDouble(double pDouble) {
+ mDouble = pDouble;
+ }
+
+ private float mFloat;
+
+ public float getFloat() {
+ return mFloat;
+ }
+
+ public void setFloat(float pFloat) {
+ mFloat = pFloat;
+ }
+
+ private char mChar;
+
+ public char getChar() {
+ return mChar;
+ }
+
+ public void setChar(char pChar) {
+ mChar = pChar;
+ }
+
+ //----------------------------------
+ // Object types
+ //----------------------------------
+
+ private String mString;
+
+ public String getString() {
+ return mString;
+ }
+
+ public void setString(String pString) {
+ mString = pString;
+ }
+
+ private Short mOShort;
+
+ public Short getOShort() {
+ return mOShort;
+ }
+
+ public void setOShort(Short pOShort) {
+ mOShort = pOShort;
+ }
+
+ private Integer mOInteger;
+
+ public Integer getOInteger() {
+ return mOInteger;
+ }
+
+ public void setOInteger(Integer pOInteger) {
+ mOInteger = pOInteger;
+ }
+
+ private Long mOLong;
+
+ public Long getOLong() {
+ return mOLong;
+ }
+
+ public void setOLong(Long pOLong) {
+ mOLong = pOLong;
+ }
+
+ private Float mOFloat;
+
+ public Float getOFloat() {
+ return mOFloat;
+ }
+
+ public void setOFloat(Float pOFloat) {
+ mOFloat = pOFloat;
+ }
+
+ private Double mODouble;
+
+ public Double getODouble() {
+ return mODouble;
+ }
+
+ public void setODouble(Double pODouble) {
+ mODouble = pODouble;
+ }
+
+ @Property(name = "genericComponent")
+ private GenericComponent mGenericComponent;
+
+ public GenericComponent getGenericComponent() {
+ return mGenericComponent;
+ }
+
+ public void setGenericComponent(GenericComponent pGenericComponent) {
+ mGenericComponent = pGenericComponent;
+ }
+
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/BadContextPojo.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/BadContextPojo.java
new file mode 100644
index 0000000000..7840b57dea
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/BadContextPojo.java
@@ -0,0 +1,26 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.mock.components;
+
+import org.osoa.sca.annotations.Context;
+
+public class BadContextPojo {
+
+ @Context
+ String moduleContext;
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/BadNamePojo.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/BadNamePojo.java
new file mode 100644
index 0000000000..d9753fa9f0
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/BadNamePojo.java
@@ -0,0 +1,24 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.mock.components;
+
+import org.osoa.sca.annotations.ComponentName;
+
+public class BadNamePojo {
+ @ComponentName
+ private int name;
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/DataObject.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/DataObject.java
new file mode 100644
index 0000000000..695cc2a5a1
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/DataObject.java
@@ -0,0 +1,38 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.mock.components;
+
+import java.io.Serializable;
+
+/**
+ * A complex type for testing
+ *
+ * @version $Rev$ $Date$
+ */
+public class DataObject implements Serializable {
+
+ private String stringValue;
+
+ public String getStringValue() {
+ return stringValue;
+ }
+
+ public void setStringValue(String stringValue) {
+ this.stringValue = stringValue;
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/GenericComponent.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/GenericComponent.java
new file mode 100644
index 0000000000..44f1c02bfd
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/GenericComponent.java
@@ -0,0 +1,142 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.mock.components;
+
+import java.util.List;
+import java.util.Map;
+
+import org.osoa.sca.ModuleContext;
+
+/**
+ * Generic test component
+ *
+ * @version $Rev$ $Date$
+ */
+public interface GenericComponent {
+
+ public String getName();
+
+ public ModuleContext getModuleContext();
+
+ // ----------------------------------
+ // Collections
+ // ----------------------------------
+
+ public Map getTestMap();
+
+ public void setTestMap(Map pTestMap);
+
+ public List getTestList();
+
+ public void setTestList(List pTestList);
+
+ // ----------------------------------
+ // Arrays
+ // ----------------------------------
+
+ public int[] getArrayInt();
+
+ public void setArrayInt(int[] pArrayInt);
+
+ public float[] getArrayFloat();
+
+ public void setArrayFloat(float[] pArrayFloat);
+
+ public double[] getArrayDouble();
+
+ public void setArrayDouble(double[] pArrayDouble);
+
+ public long[] getArrayLong();
+
+ public void setArrayLong(long[] pArrayLong);
+
+ public short[] getArrayShort();
+
+ public void setArrayShort(short[] pArrayShort);
+
+ public boolean[] getArrayBoolean();
+
+ public void setArrayBoolean(boolean[] pArrayBoolean);
+
+ public String[] getArrayString();
+
+ public void setArrayString(String[] pArrayString);
+
+ // ----------------------------------
+ // Primitives
+ // ----------------------------------
+
+ public boolean getBoolean();
+
+ public void setBoolean(boolean pBoolean);
+
+ public short getShort();
+
+ public void setShort(short pShort);
+
+ public int getInt();
+
+ public void setInt(int pInt);
+
+ public long getLong();
+
+ public void setLong(long pLong);
+
+ public double getDouble();
+
+ public void setDouble(double pDouble);
+
+ public float getFloat();
+
+ public void setFloat(float pFloat);
+
+ public char getChar();
+
+ public void setChar(char pChar);
+
+ // ----------------------------------
+ // Object types
+ // ----------------------------------
+
+ public String getString();
+
+ public void setString(String pString);
+
+ public Short getOShort();
+
+ public void setOShort(Short pOShort);
+
+ public Integer getOInteger();
+
+ public void setOInteger(Integer pOInteger);
+
+ public Long getOLong();
+
+ public void setOLong(Long pOLong);
+
+ public Float getOFloat();
+
+ public void setOFloat(Float pOFloat);
+
+ public Double getODouble();
+
+ public void setODouble(Double pODouble);
+
+ public GenericComponent getGenericComponent();
+
+ public void setGenericComponent(GenericComponent pGenericComponent);
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/HelloWorldClient.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/HelloWorldClient.java
new file mode 100644
index 0000000000..1e7ca9f36b
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/HelloWorldClient.java
@@ -0,0 +1,46 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.mock.components;
+
+import org.apache.tuscany.container.java.assembly.mock.HelloWorldService;
+
+/**
+ *
+ *
+ * @version $Rev$ $Date$
+ */
+public class HelloWorldClient implements HelloWorldService{
+
+ private int count;
+
+ public HelloWorldClient() {
+ }
+
+ private HelloWorldService service;
+
+ public void setHelloWorldService(HelloWorldService service){
+ this.service = service;
+ }
+
+ public String hello(String name) {
+ ++count;
+ return service.hello(name);
+ }
+
+ public int count() {
+ return count;
+ }
+
+}
+
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/LocalComponentImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/LocalComponentImpl.java
new file mode 100644
index 0000000000..4b57c7f301
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/LocalComponentImpl.java
@@ -0,0 +1,97 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.mock.components;
+
+import org.osoa.sca.ModuleContext;
+import org.osoa.sca.annotations.ComponentName;
+import org.osoa.sca.annotations.Context;
+import org.osoa.sca.annotations.Property;
+import org.osoa.sca.annotations.Reference;
+
+/**
+ * A test local service
+ *
+ * @version $Rev$ $Date$
+ */
+
+public class LocalComponentImpl {
+
+ @ComponentName
+ protected String name;
+
+ public String getName() {
+ return name;
+ }
+
+ @Context
+ protected ModuleContext moduleCtx;
+
+ public ModuleContext getModuleContext() {
+ return moduleCtx;
+ }
+
+ @Property(name = "fieldSetter", required = true)
+ private String mfieldSetter;
+
+ public String getfieldSetter() {
+ return mfieldSetter;
+ }
+
+ public void setfieldSetter(String pfieldSetter) throws Exception {
+ throw new Exception("Set method instead of field");
+ }
+
+ private String mMethodSetter;
+ boolean mSetByMethod;
+
+ public String getMethodSetter() throws Exception {
+ if (mSetByMethod) {
+ return mMethodSetter;
+ }
+ throw new Exception("Property method setter failed");
+
+ }
+
+ @Property(required = true)
+ public void setMethodSetter(String pMethodSetter) {
+ mSetByMethod = true;
+ mMethodSetter = pMethodSetter;
+ }
+
+ @Reference(name = "requiredDataObject", required = true)
+ private DataObject mRequiredDataObject;
+
+ public DataObject getRequiredDataObject() {
+ return mRequiredDataObject;
+ }
+
+ public void setRequiredDataObject(DataObject pRequiredDataObject) {
+ mRequiredDataObject = pRequiredDataObject;
+ }
+
+ @Reference(name = "optionalDataObject")
+ private DataObject mOptionalDataObject;
+
+ public DataObject getOptionalDataObject() {
+ return mOptionalDataObject;
+ }
+
+ public void setOptionalDataObject(DataObject pOptionalDataObject) {
+ mOptionalDataObject = pOptionalDataObject;
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/ModuleScopeComponent.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/ModuleScopeComponent.java
new file mode 100644
index 0000000000..7787e8cf5b
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/ModuleScopeComponent.java
@@ -0,0 +1,29 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.mock.components;
+
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * @version $Rev$ $Date$
+ */
+@Scope("MODULE")
+public interface ModuleScopeComponent extends GenericComponent {
+
+ //public boolean isInit();
+}
+
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/ModuleScopeComponentImpl.componentType b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/ModuleScopeComponentImpl.componentType
new file mode 100644
index 0000000000..ca4c633e59
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/ModuleScopeComponentImpl.componentType
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
+
+ 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.
+ -->
+<!-- remove this once ImplementationImpl is fixed not to requrie this -->
+<componentType xmlns="http://www.osoa.org/xmlns/sca/0.9">
+
+ <service name="ModuleScopeComponent" scope="module">
+ <interface.java interface="janus.test.component.ModuleScopeComponent"/>
+ </service>
+ <!-- Not supported, not in the spec
+ <property.java name="mInt" class="java.lang.Integer" default="default"/>
+ <property.java name="foo" class="java.lang.String" default="default"/>
+ -->
+ <reference name="mGenericComponent" multiplicity="0..1">
+ <interface.java interface="test.org.apache.tuscany.container.java.components.AbstractGenericComponent"/>
+ </reference>
+
+</componentType>
+
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/ModuleScopeComponentImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/ModuleScopeComponentImpl.java
new file mode 100644
index 0000000000..ca65be4bb0
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/ModuleScopeComponentImpl.java
@@ -0,0 +1,47 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.mock.components;
+
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ModuleScopeComponentImpl extends AbstractGenericComponent implements
+ ModuleScopeComponent {
+
+// private boolean init;
+//
+// @Init(eager=false)
+// public void init(){
+// init= true;
+// }
+//
+// public boolean isInit(){
+// return init;
+// }
+
+
+ private String foo;
+
+ public void setFoo(String foo) {
+ this.foo = foo;
+ }
+
+ public String getFoo() {
+ return foo;
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/ModuleScopeDestroyOnlyComponent.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/ModuleScopeDestroyOnlyComponent.java
new file mode 100644
index 0000000000..76218c2d6c
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/ModuleScopeDestroyOnlyComponent.java
@@ -0,0 +1,34 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.mock.components;
+
+import org.osoa.sca.annotations.Destroy;
+
+public class ModuleScopeDestroyOnlyComponent extends ModuleScopeComponentImpl {
+
+ boolean destroyed = false;
+
+ public boolean isDestroyed() {
+ return destroyed;
+ }
+
+ @Destroy
+ public void destroy() {
+ destroyed = true;
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/ModuleScopeEagerInitComponent.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/ModuleScopeEagerInitComponent.java
new file mode 100644
index 0000000000..56a0421f24
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/ModuleScopeEagerInitComponent.java
@@ -0,0 +1,39 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.mock.components;
+
+import org.osoa.sca.annotations.Init;
+
+public class ModuleScopeEagerInitComponent extends ModuleScopeComponentImpl {
+
+ boolean initialized = false;
+
+ public boolean isInitialized() {
+ return initialized;
+ }
+
+ // this value tests to ensure introspection can find the init() method even
+ // if a field is named the same. Ultimately, this should be in the
+ // introspection tests
+ private boolean init;
+
+ @Init(eager = true)
+ public void init() {
+ initialized = true;
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/ModuleScopeEagerInitDestroyComponent.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/ModuleScopeEagerInitDestroyComponent.java
new file mode 100644
index 0000000000..dae156737a
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/ModuleScopeEagerInitDestroyComponent.java
@@ -0,0 +1,33 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.mock.components;
+
+import org.osoa.sca.annotations.Destroy;
+
+public class ModuleScopeEagerInitDestroyComponent extends ModuleScopeEagerInitComponent {
+
+ boolean destroyed = false;
+
+ public boolean isDestroyed() {
+ return destroyed;
+ }
+
+ @Destroy
+ public void destroy() {
+ destroyed = true;
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/ModuleScopeInitDestroyComponent.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/ModuleScopeInitDestroyComponent.java
new file mode 100644
index 0000000000..d9b1303677
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/ModuleScopeInitDestroyComponent.java
@@ -0,0 +1,34 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.mock.components;
+
+import org.osoa.sca.annotations.Destroy;
+
+public class ModuleScopeInitDestroyComponent extends ModuleScopeInitOnlyComponent {
+
+ boolean destroyed = false;
+
+ public boolean isDestroyed() {
+ return destroyed;
+ }
+
+ @Destroy
+ public void destroy() {
+ destroyed = true;
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/ModuleScopeInitOnlyComponent.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/ModuleScopeInitOnlyComponent.java
new file mode 100644
index 0000000000..a9b465d79e
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/ModuleScopeInitOnlyComponent.java
@@ -0,0 +1,38 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.mock.components;
+
+import org.osoa.sca.annotations.Init;
+
+public class ModuleScopeInitOnlyComponent extends ModuleScopeComponentImpl {
+
+ boolean initialized = false;
+
+ public boolean isInitialized() {
+ return initialized;
+ }
+
+ // this value tests to ensure introspection can find the init() method even
+ // if a field is named the same. Ultimately, this should be in the introspection tests
+ private boolean init;
+
+ @Init
+ public void init() {
+ initialized = true;
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/RemotableService.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/RemotableService.java
new file mode 100644
index 0000000000..645fd7f47c
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/RemotableService.java
@@ -0,0 +1,40 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.mock.components;
+
+import org.osoa.sca.annotations.Remotable;
+
+/**
+ * Used for testing basic remoting operations
+ *
+ * @version $Rev$ $Date$
+ */
+
+@Remotable
+public interface RemotableService {
+
+ public void syncOneWay(String msg);
+
+ public String syncTwoWay(String msg);
+
+ public DataObject syncTwoWayCustomType(DataObject val);
+
+ public String getString();
+
+ public void setString(String string);
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/RemotableServiceImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/RemotableServiceImpl.java
new file mode 100644
index 0000000000..34a4273323
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/RemotableServiceImpl.java
@@ -0,0 +1,61 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.mock.components;
+
+import junit.framework.Assert;
+import org.osoa.sca.annotations.Property;
+
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class RemotableServiceImpl implements RemotableService {
+
+ // ----------------------------------
+ // Properties
+ // ----------------------------------
+
+ @Property(name = "string", required = true)
+ private String mString;
+
+ public String getString() {
+ return mString;
+ }
+
+ public void setString(String string) {
+ mString = string;
+ }
+
+ // ----------------------------------
+ // Methods
+ // ----------------------------------
+
+ public void syncOneWay(String msg) {
+ Assert.assertEquals("hello", msg);
+ }
+
+ public String syncTwoWay(String msg) {
+ return "response";
+ }
+
+ public DataObject syncTwoWayCustomType(DataObject val) {
+ Assert.assertEquals("hello", val.getStringValue());
+ DataObject dto = new DataObject();
+ dto.setStringValue("return");
+ return dto;
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/RequestScopeComponent.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/RequestScopeComponent.java
new file mode 100644
index 0000000000..ac7931bd2c
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/RequestScopeComponent.java
@@ -0,0 +1,28 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.mock.components;
+
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * @version $Rev$ $Date$
+ */
+@Scope("REQUEST")
+public interface RequestScopeComponent extends GenericComponent {
+
+}
+
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/RequestScopeComponentImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/RequestScopeComponentImpl.java
new file mode 100644
index 0000000000..5b20519d90
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/RequestScopeComponentImpl.java
@@ -0,0 +1,25 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.mock.components;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class RequestScopeComponentImpl extends AbstractGenericComponent implements
+ RequestScopeComponent {
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/SessionScopeComponent.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/SessionScopeComponent.java
new file mode 100644
index 0000000000..236e083a2b
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/SessionScopeComponent.java
@@ -0,0 +1,28 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.mock.components;
+
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * @version $Rev$ $Date$
+ */
+@Scope("SESSION")
+public interface SessionScopeComponent extends GenericComponent {
+
+}
+
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/SessionScopeComponentImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/SessionScopeComponentImpl.java
new file mode 100644
index 0000000000..41ffeccdfc
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/SessionScopeComponentImpl.java
@@ -0,0 +1,25 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.mock.components;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class SessionScopeComponentImpl extends AbstractGenericComponent implements
+ SessionScopeComponent {
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/SessionScopeDestroyOnlyComponent.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/SessionScopeDestroyOnlyComponent.java
new file mode 100644
index 0000000000..be20a23d29
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/SessionScopeDestroyOnlyComponent.java
@@ -0,0 +1,34 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.mock.components;
+
+import org.osoa.sca.annotations.Destroy;
+
+public class SessionScopeDestroyOnlyComponent extends SessionScopeComponentImpl {
+
+ boolean destroyed = false;
+
+ public boolean isDestroyed() {
+ return destroyed;
+ }
+
+ @Destroy
+ public void destroy() {
+ destroyed = true;
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/SessionScopeInitDestroyComponent.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/SessionScopeInitDestroyComponent.java
new file mode 100644
index 0000000000..32aa0142a4
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/SessionScopeInitDestroyComponent.java
@@ -0,0 +1,34 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.mock.components;
+
+import org.osoa.sca.annotations.Destroy;
+
+public class SessionScopeInitDestroyComponent extends SessionScopeInitOnlyComponent {
+
+ boolean destroyed = false;
+
+ public boolean isDestroyed() {
+ return destroyed;
+ }
+
+ @Destroy
+ public void destroy() {
+ destroyed = true;
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/SessionScopeInitOnlyComponent.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/SessionScopeInitOnlyComponent.java
new file mode 100644
index 0000000000..a518a9b244
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/SessionScopeInitOnlyComponent.java
@@ -0,0 +1,35 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.mock.components;
+
+import org.osoa.sca.annotations.Init;
+
+public class SessionScopeInitOnlyComponent extends SessionScopeComponentImpl {
+
+ boolean initialized = false;
+
+ public boolean isInitialized() {
+ return initialized;
+ }
+
+ @Init
+ public void init() {
+ initialized = true;
+ }
+
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/StatelessComponent.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/StatelessComponent.java
new file mode 100644
index 0000000000..3fe84dd785
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/StatelessComponent.java
@@ -0,0 +1,28 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.mock.components;
+
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * @version $Rev$ $Date$
+ */
+@Scope("STATELESS")
+public interface StatelessComponent extends GenericComponent {
+
+}
+
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/StatelessComponentImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/StatelessComponentImpl.java
new file mode 100644
index 0000000000..8b806d6a2e
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/StatelessComponentImpl.java
@@ -0,0 +1,25 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.mock.components;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class StatelessComponentImpl extends AbstractGenericComponent implements
+ StatelessComponent {
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/scopes/AggregateScopeTestCase.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/scopes/AggregateScopeTestCase.java
new file mode 100644
index 0000000000..77130f6334
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/scopes/AggregateScopeTestCase.java
@@ -0,0 +1,178 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.scopes;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.container.java.builder.JavaComponentContextBuilder;
+import org.apache.tuscany.container.java.mock.MockFactory;
+import org.apache.tuscany.container.java.mock.components.GenericComponent;
+import org.apache.tuscany.container.java.mock.components.ModuleScopeComponentImpl;
+import org.apache.tuscany.container.java.mock.components.SessionScopeComponentImpl;
+import org.apache.tuscany.core.builder.BuilderException;
+import org.apache.tuscany.core.context.AggregateContext;
+import org.apache.tuscany.core.context.EventContext;
+import org.apache.tuscany.core.context.QualifiedName;
+import org.apache.tuscany.core.context.impl.AggregateContextImpl;
+import org.apache.tuscany.core.context.impl.EventContextImpl;
+import org.apache.tuscany.core.context.scope.AggregateScopeContext;
+import org.apache.tuscany.model.assembly.Extensible;
+import org.apache.tuscany.model.assembly.Scope;
+import org.apache.tuscany.model.assembly.SimpleComponent;
+
+/**
+ * Tests component nesting. This test need to be in the container.java progject since it relies on Java POJOs for scope
+ * testing.
+ *
+ * @version $Rev$ $Date$
+ */
+public class AggregateScopeTestCase extends TestCase {
+
+ /**
+ * Ensures scope events are propagated in an aggregate scope
+ */
+ public void testAggregateScopePropagation() throws Exception {
+ EventContext ctx = new EventContextImpl();
+ AggregateContext moduleComponentCtx = new AggregateContextImpl();
+ moduleComponentCtx.setName("testMC");
+ AggregateScopeContext scopeContainer = new AggregateScopeContext(ctx);
+ scopeContainer.registerConfiguration(MockFactory.createAggregateConfiguration("AggregateComponent", moduleComponentCtx));
+ scopeContainer.start();
+ AggregateContext child = (AggregateContext) scopeContainer.getContext("AggregateComponent");
+ List<Extensible> models = createAssembly(moduleComponentCtx);
+ for (Extensible model : models) {
+ child.registerModelObject(model);
+ }
+
+ scopeContainer.onEvent(EventContext.MODULE_START, null);
+ Object session = new Object();
+ scopeContainer.onEvent(EventContext.REQUEST_START, null);
+ scopeContainer.onEvent(EventContext.SESSION_NOTIFY, session);
+ AggregateContext componentCtx = (AggregateContext) scopeContainer.getContext("AggregateComponent");
+ GenericComponent testService1 = (GenericComponent) componentCtx.locateInstance("TestService1");
+ GenericComponent testService2 = (GenericComponent) componentCtx.locateInstance("TestService2");
+ GenericComponent testService3 = (GenericComponent) componentCtx.locateInstance("TestService3");
+ Assert.assertNotNull(testService1);
+ Assert.assertNotNull(testService2);
+ Assert.assertNotNull(testService3);
+ scopeContainer.onEvent(EventContext.REQUEST_END, null);
+ scopeContainer.onEvent(EventContext.REQUEST_START, null);
+ scopeContainer.onEvent(EventContext.SESSION_NOTIFY, session);
+
+ GenericComponent testService2a = (GenericComponent) componentCtx.locateInstance("TestService2");
+ Assert.assertNotNull(testService2a);
+ GenericComponent testService3a = (GenericComponent) componentCtx.locateInstance("TestService3");
+ Assert.assertNotNull(testService3a);
+ Assert.assertEquals(testService2, testService2a);
+ Assert.assertNotSame(testService3, testService3a);
+ scopeContainer.onEvent(EventContext.REQUEST_END, null);
+ scopeContainer.onEvent(EventContext.SESSION_END, session);
+
+ Object session2 = new Object();
+ scopeContainer.onEvent(EventContext.REQUEST_START, null);
+ scopeContainer.onEvent(EventContext.SESSION_NOTIFY, session2);
+ GenericComponent testService2b = (GenericComponent) componentCtx.locateInstance("TestService2");
+ Assert.assertNotNull(testService2b);
+ Assert.assertNotSame(testService2, testService2b);
+
+ scopeContainer.onEvent(EventContext.REQUEST_END, null);
+ scopeContainer.onEvent(EventContext.SESSION_END, session2);
+
+ }
+
+ /**
+ * Ensures only child entry points (and not components) are accessible from parents
+ */
+ public void testAggregateNoEntryPoint() throws Exception {
+ EventContext ctx = new EventContextImpl();
+ AggregateContext moduleComponentCtx = new AggregateContextImpl();
+ moduleComponentCtx.setName("testMC");
+ AggregateScopeContext scopeContainer = new AggregateScopeContext(ctx);
+ scopeContainer.registerConfiguration(MockFactory.createAggregateConfiguration("AggregateComponent", moduleComponentCtx));
+ scopeContainer.start();
+ AggregateContext child = (AggregateContext) scopeContainer.getContext("AggregateComponent");
+ List<Extensible> parts = createAssembly(moduleComponentCtx);
+ for (Extensible part : parts) {
+ child.registerModelObject(part);
+ }
+
+ // aggregate.onEvent(EventContext.SYSTEM_START, null);
+ scopeContainer.onEvent(EventContext.MODULE_START, null);
+ QualifiedName name = new QualifiedName("AggregateComponent/TestService1");
+ AggregateContext componentCtx = (AggregateContext) scopeContainer.getContext("AggregateComponent");
+ }
+
+ /**
+ * Tests adding a context before its parent has been started
+ */
+ public void testRegisterContextBeforeStart() throws Exception {
+ EventContext ctx = new EventContextImpl();
+ AggregateContext moduleComponentCtx = new AggregateContextImpl();
+ moduleComponentCtx.setName("testMC");
+ AggregateScopeContext scopeContainer = new AggregateScopeContext(ctx);
+ scopeContainer.registerConfiguration(MockFactory.createAggregateConfiguration("AggregateComponent", moduleComponentCtx));
+ scopeContainer.start();
+ scopeContainer.onEvent(EventContext.MODULE_START, null);
+ QualifiedName name = new QualifiedName("AggregateComponent/TestService1");
+ AggregateContext componentCtx = (AggregateContext) scopeContainer.getContext("AggregateComponent");
+ scopeContainer.onEvent(EventContext.MODULE_STOP, null);
+ scopeContainer.stop();
+ }
+
+ /**
+ * Tests adding a context after its parent has been started
+ */
+ public void testRegisterContextAfterStart() throws Exception {
+ EventContext ctx = new EventContextImpl();
+ AggregateContext moduleComponentCtx = new AggregateContextImpl();
+ moduleComponentCtx.setName("testMC");
+ AggregateScopeContext scopeContainer = new AggregateScopeContext(ctx);
+ scopeContainer.start();
+
+ scopeContainer.onEvent(EventContext.MODULE_START, null);
+ scopeContainer.registerConfiguration(MockFactory.createAggregateConfiguration("AggregateComponent", moduleComponentCtx));
+ QualifiedName name = new QualifiedName("AggregateComponent/TestService1");
+ AggregateContext componentCtx = (AggregateContext) scopeContainer.getContext("AggregateComponent");
+ scopeContainer.onEvent(EventContext.MODULE_STOP, null);
+ scopeContainer.stop();
+ }
+
+ /**
+ * Creats an assembly containing a module-scoped component definition, a session-scoped component definition, and a
+ * request-scoped component definition
+ *
+ * @param ctx the parent module context
+ */
+ private List<Extensible> createAssembly(AggregateContext ctx) throws BuilderException {
+ JavaComponentContextBuilder builder = new JavaComponentContextBuilder();
+ SimpleComponent component = MockFactory.createComponent("TestService1", ModuleScopeComponentImpl.class, Scope.MODULE);
+ SimpleComponent sessionComponent = MockFactory.createComponent("TestService2", SessionScopeComponentImpl.class,
+ Scope.SESSION);
+ SimpleComponent requestComponent = MockFactory.createComponent("TestService3", SessionScopeComponentImpl.class,
+ Scope.REQUEST);
+ builder.build(component, ctx);
+ builder.build(sessionComponent, ctx);
+ builder.build(requestComponent, ctx);
+ List<Extensible> configs = new ArrayList();
+ configs.add(component);
+ configs.add(sessionComponent);
+ configs.add(requestComponent);
+ return configs;
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/scopes/BasicHttpSessionScopeTestCase.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/scopes/BasicHttpSessionScopeTestCase.java
new file mode 100644
index 0000000000..a56589c4d1
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/scopes/BasicHttpSessionScopeTestCase.java
@@ -0,0 +1,223 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.scopes;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.container.java.builder.JavaComponentContextBuilder;
+import org.apache.tuscany.container.java.mock.MockFactory;
+import org.apache.tuscany.container.java.mock.components.SessionScopeComponent;
+import org.apache.tuscany.container.java.mock.components.SessionScopeComponentImpl;
+import org.apache.tuscany.container.java.mock.components.SessionScopeInitDestroyComponent;
+import org.apache.tuscany.core.builder.BuilderException;
+import org.apache.tuscany.core.builder.RuntimeConfiguration;
+import org.apache.tuscany.core.context.EventContext;
+import org.apache.tuscany.core.context.InstanceContext;
+import org.apache.tuscany.core.context.impl.EventContextImpl;
+import org.apache.tuscany.core.context.scope.HttpSessionScopeContext;
+import org.apache.tuscany.model.assembly.Scope;
+import org.apache.tuscany.model.assembly.SimpleComponent;
+
+/**
+ * Unit tests for the Http session scope container
+ *
+ * @version $Rev$ $Date$
+ */
+public class BasicHttpSessionScopeTestCase extends TestCase {
+
+ /**
+ * Tests instance identity is properly maintained
+ */
+ public void testInstanceManagement() throws Exception {
+ EventContext ctx = new EventContextImpl();
+ HttpSessionScopeContext scope = new HttpSessionScopeContext(ctx);
+ scope.registerConfigurations(createConfigurations());
+ scope.start();
+ Object session = new Object();
+ Object session2 = new Object();
+ // first request
+ ctx.setIdentifier(EventContext.HTTP_SESSION, session);
+ SessionScopeComponent comp1 = (SessionScopeComponent) scope.getContext("TestService1").getInstance(null);
+ Assert.assertNotNull(comp1);
+ ctx.clearIdentifier(EventContext.HTTP_SESSION);
+
+ // second request
+ ctx.setIdentifier(EventContext.HTTP_SESSION, session);
+ SessionScopeComponent comp2 = (SessionScopeComponent) scope.getContext("TestService1").getInstance(null);
+ Assert.assertNotNull(comp2);
+ Assert.assertSame(comp1, comp2);
+ ctx.clearIdentifier(EventContext.HTTP_SESSION);
+
+ // third request, different session
+ ctx.setIdentifier(EventContext.HTTP_SESSION, session2);
+ SessionScopeComponent comp3 = (SessionScopeComponent) scope.getContext("TestService1").getInstance(null);
+ Assert.assertNotNull(comp3);
+ Assert.assertNotSame(comp1, comp3); // should be different instances
+ ctx.clearIdentifier(EventContext.HTTP_SESSION);
+
+ scope.onEvent(EventContext.SESSION_END, session);
+ scope.onEvent(EventContext.SESSION_END, session2);
+
+ scope.stop();
+ }
+
+ /**
+ * Tests setting no components in the scope
+ */
+ public void testSetNullComponents() throws Exception {
+ EventContext ctx = new EventContextImpl();
+ HttpSessionScopeContext scope = new HttpSessionScopeContext(ctx);
+ scope.registerConfigurations(new ArrayList<RuntimeConfiguration<InstanceContext>>());
+ scope.start();
+ scope.stop();
+ }
+
+ public void testGetContextByKey() throws Exception {
+ EventContext ctx = new EventContextImpl();
+ HttpSessionScopeContext scope = new HttpSessionScopeContext(ctx);
+ scope.registerConfigurations(createConfigurations());
+ scope.start();
+ Object session = new Object();
+ Object session2 = new Object();
+
+ // first request
+ ctx.setIdentifier(EventContext.HTTP_SESSION, session);
+ SessionScopeComponent comp1 = (SessionScopeComponent) scope.getContext("TestService1").getInstance(null);
+ Assert.assertNotNull(comp1);
+ ctx.clearIdentifier(EventContext.HTTP_SESSION);
+
+ // second request, different session
+ ctx.setIdentifier(EventContext.HTTP_SESSION, session2);
+ SessionScopeComponent comp2 = (SessionScopeComponent) scope.getContextByKey("TestService1", session)
+ .getInstance(null);
+ SessionScopeComponent comp3 = (SessionScopeComponent) scope.getContextByKey("TestService1", session)
+ .getInstance(null);
+ Assert.assertNotNull(comp2);
+ scope.onEvent(EventContext.REQUEST_END, session2);
+ Assert.assertSame(comp1, comp2); // should be same instances
+ Assert.assertSame(comp2, comp3); // should not be same instances
+ ctx.clearIdentifier(EventContext.HTTP_SESSION);
+
+ // shutdown sessions
+ scope.onEvent(EventContext.SESSION_END, session);
+ scope.onEvent(EventContext.SESSION_END, session2);
+
+ scope.stop();
+ }
+
+ public void testRegisterContextBeforeSession() throws Exception {
+ EventContext ctx = new EventContextImpl();
+ HttpSessionScopeContext scope = new HttpSessionScopeContext(ctx);
+ scope.registerConfigurations(createConfigurations());
+ scope.start();
+ Object session = new Object();
+ scope.registerConfiguration(createConfiguration("NewTestService"));
+
+ // first request
+ ctx.setIdentifier(EventContext.HTTP_SESSION, session);
+
+ SessionScopeInitDestroyComponent comp2 = (SessionScopeInitDestroyComponent) scope.getContext("NewTestService")
+ .getInstance(null);
+ Assert.assertNotNull(comp2);
+ Assert.assertTrue(comp2.isInitialized());
+ ctx.clearIdentifier(EventContext.HTTP_SESSION);
+
+ // second request different session
+ Object session2 = new Object();
+ ctx.setIdentifier(EventContext.HTTP_SESSION, session2);
+ SessionScopeInitDestroyComponent comp3 = (SessionScopeInitDestroyComponent) scope.getContext("NewTestService")
+ .getInstance(null);
+ Assert.assertNotNull(comp3);
+ Assert.assertNotSame(comp2, comp3);
+ Assert.assertTrue(comp3.isInitialized());
+ ctx.clearIdentifier(EventContext.HTTP_SESSION);
+
+ scope.onEvent(EventContext.SESSION_END, session);
+ Assert.assertTrue(comp2.isDestroyed());
+
+ scope.onEvent(EventContext.SESSION_END, session2);
+ Assert.assertTrue(comp3.isDestroyed());
+ scope.stop();
+ }
+
+ /**
+ * Tests runtime context registration
+ */
+ public void testRegisterContextAfterSession() throws Exception {
+ EventContext ctx = new EventContextImpl();
+ HttpSessionScopeContext scope = new HttpSessionScopeContext(ctx);
+ scope.registerConfigurations(createConfigurations());
+ scope.start();
+ Object session = new Object();
+
+ // first request
+ ctx.setIdentifier(EventContext.HTTP_SESSION, session);
+ SessionScopeComponent comp1 = (SessionScopeComponent) scope.getContext("TestService1").getInstance(null);
+ Assert.assertNotNull(comp1);
+ ctx.clearIdentifier(EventContext.HTTP_SESSION);
+
+ scope.registerConfiguration(createConfiguration("NewTestService"));
+
+ // second request
+ ctx.setIdentifier(EventContext.HTTP_SESSION, session);
+ SessionScopeInitDestroyComponent comp2 = (SessionScopeInitDestroyComponent) scope.getContext("NewTestService")
+ .getInstance(null);
+ Assert.assertNotNull(comp2);
+ Assert.assertTrue(comp2.isInitialized());
+ ctx.clearIdentifier(EventContext.HTTP_SESSION);
+
+ // third request different session
+ Object session2 = new Object();
+ ctx.setIdentifier(EventContext.HTTP_SESSION, session2);
+ SessionScopeInitDestroyComponent comp3 = (SessionScopeInitDestroyComponent) scope.getContext("NewTestService")
+ .getInstance(null);
+ Assert.assertNotNull(comp3);
+ Assert.assertNotSame(comp2, comp3);
+ Assert.assertTrue(comp3.isInitialized());
+ ctx.clearIdentifier(EventContext.HTTP_SESSION);
+
+ scope.onEvent(EventContext.SESSION_END, session);
+ Assert.assertTrue(comp2.isDestroyed());
+
+ scope.onEvent(EventContext.SESSION_END, session2);
+ Assert.assertTrue(comp3.isDestroyed());
+ scope.stop();
+ }
+
+ // ----------------------------------
+ // Private methods
+ // ----------------------------------
+ JavaComponentContextBuilder builder = new JavaComponentContextBuilder();
+
+ private List<RuntimeConfiguration<InstanceContext>> createConfigurations() throws NoSuchMethodException, BuilderException {
+ SimpleComponent component = MockFactory.createComponent("TestService1", SessionScopeComponentImpl.class, Scope.SESSION);
+ builder.build(component, null);
+ List<RuntimeConfiguration<InstanceContext>> configs = new ArrayList();
+ configs.add((RuntimeConfiguration<InstanceContext>) component.getComponentImplementation().getRuntimeConfiguration());
+ return configs;
+ }
+
+ private RuntimeConfiguration<InstanceContext> createConfiguration(String name) throws NoSuchMethodException, BuilderException {
+ SimpleComponent component = MockFactory.createComponent(name, SessionScopeInitDestroyComponent.class, Scope.SESSION);
+ builder.build(component, null);
+ return (RuntimeConfiguration<InstanceContext>) component.getComponentImplementation().getRuntimeConfiguration();
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/scopes/BasicModuleScopeTestCase.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/scopes/BasicModuleScopeTestCase.java
new file mode 100644
index 0000000000..e1dab000ce
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/scopes/BasicModuleScopeTestCase.java
@@ -0,0 +1,126 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.scopes;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.container.java.builder.JavaComponentContextBuilder;
+import org.apache.tuscany.container.java.mock.MockFactory;
+import org.apache.tuscany.container.java.mock.components.ModuleScopeComponentImpl;
+import org.apache.tuscany.container.java.mock.components.ModuleScopeInitDestroyComponent;
+import org.apache.tuscany.core.builder.BuilderException;
+import org.apache.tuscany.core.builder.RuntimeConfiguration;
+import org.apache.tuscany.core.context.EventContext;
+import org.apache.tuscany.core.context.InstanceContext;
+import org.apache.tuscany.core.context.impl.EventContextImpl;
+import org.apache.tuscany.core.context.scope.ModuleScopeContext;
+import org.apache.tuscany.model.assembly.Scope;
+import org.apache.tuscany.model.assembly.SimpleComponent;
+
+/**
+ * Unit tests for the module scope container
+ *
+ * @version $Rev$ $Date$
+ */
+public class BasicModuleScopeTestCase extends TestCase {
+
+ /**
+ * Tests instance identity is properly maintained
+ */
+ public void testInstanceManagement() throws Exception {
+ EventContext ctx = new EventContextImpl();
+ ModuleScopeContext scope = new ModuleScopeContext(ctx);
+ scope.registerConfigurations(createConfigurations());
+ scope.start();
+ // first request
+ scope.onEvent(EventContext.MODULE_START, null);
+ ModuleScopeComponentImpl comp1 = (ModuleScopeComponentImpl) scope.getContext("TestService1").getInstance(null);
+ Assert.assertNotNull(comp1);
+ // second request
+ ModuleScopeComponentImpl comp2 = (ModuleScopeComponentImpl) scope.getContext("TestService1").getInstance(null);
+ Assert.assertNotNull(comp2);
+ Assert.assertSame(comp1, comp2);
+ scope.onEvent(EventContext.MODULE_STOP, null);
+ scope.stop();
+ }
+
+ public void testSetNullComponents() throws Exception {
+ EventContext ctx = new EventContextImpl();
+ ModuleScopeContext scope = new ModuleScopeContext(ctx);
+ scope.registerConfigurations(createConfigurations());
+ scope.start();
+ scope.onEvent(EventContext.MODULE_START, null);
+ scope.onEvent(EventContext.MODULE_STOP, null);
+ scope.stop();
+ }
+
+ public void testRegisterContextBeforeStart() throws Exception {
+ EventContext ctx = new EventContextImpl();
+ ModuleScopeContext scope = new ModuleScopeContext(ctx);
+ scope.registerConfigurations(createConfigurations());
+ scope.start();
+ scope.registerConfiguration(createConfiguration("NewTestService"));
+ scope.onEvent(EventContext.MODULE_START,null);
+ ModuleScopeInitDestroyComponent comp2 = (ModuleScopeInitDestroyComponent) scope.getContext("NewTestService").getInstance(null);
+ Assert.assertNotNull(comp2);
+ Assert.assertTrue(comp2.isInitialized());
+ scope.onEvent(EventContext.MODULE_STOP,null);
+ Assert.assertTrue(comp2.isDestroyed());
+ scope.stop();
+ }
+
+ public void testRegisterContextAfterStart() throws Exception {
+ EventContext ctx = new EventContextImpl();
+ ModuleScopeContext scope = new ModuleScopeContext(ctx);
+ scope.start();
+ scope.registerConfiguration(createConfiguration("NewTestService"));
+ scope.onEvent(EventContext.MODULE_START,null);
+ scope.registerConfigurations(createConfigurations());
+ ModuleScopeInitDestroyComponent comp2 = (ModuleScopeInitDestroyComponent) scope.getContext("NewTestService").getInstance(null);
+ Assert.assertNotNull(comp2);
+ Assert.assertTrue(comp2.isInitialized());
+ scope.onEvent(EventContext.MODULE_STOP,null);
+ Assert.assertTrue(comp2.isDestroyed());
+ scope.stop();
+ }
+
+ // ----------------------------------
+ // Private methods
+ // ----------------------------------
+
+ JavaComponentContextBuilder builder = new JavaComponentContextBuilder();
+
+ private List<RuntimeConfiguration<InstanceContext>> createConfigurations() throws NoSuchMethodException, BuilderException {
+ SimpleComponent component = MockFactory.createComponent("TestService1", ModuleScopeComponentImpl.class, Scope.MODULE);
+ builder.build(component, null);
+ List<RuntimeConfiguration<InstanceContext>> configs = new ArrayList();
+ configs.add((RuntimeConfiguration<InstanceContext>) component.getComponentImplementation().getRuntimeConfiguration());
+ return configs;
+ }
+
+ private RuntimeConfiguration<InstanceContext> createConfiguration(String name)
+ throws NoSuchMethodException, BuilderException {
+ SimpleComponent component = MockFactory.createComponent(name, ModuleScopeInitDestroyComponent.class,
+ Scope.MODULE);
+ builder.build(component, null);
+ return (RuntimeConfiguration<InstanceContext>) component.getComponentImplementation().getRuntimeConfiguration();
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/scopes/BasicRequestScopeTestCase.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/scopes/BasicRequestScopeTestCase.java
new file mode 100644
index 0000000000..b3a6e5f64b
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/scopes/BasicRequestScopeTestCase.java
@@ -0,0 +1,148 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.scopes;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.container.java.builder.JavaComponentContextBuilder;
+import org.apache.tuscany.container.java.mock.MockFactory;
+import org.apache.tuscany.container.java.mock.components.RequestScopeComponent;
+import org.apache.tuscany.container.java.mock.components.RequestScopeComponentImpl;
+import org.apache.tuscany.core.builder.BuilderException;
+import org.apache.tuscany.core.builder.RuntimeConfiguration;
+import org.apache.tuscany.core.context.EventContext;
+import org.apache.tuscany.core.context.InstanceContext;
+import org.apache.tuscany.core.context.impl.EventContextImpl;
+import org.apache.tuscany.core.context.scope.RequestScopeContext;
+import org.apache.tuscany.model.assembly.Scope;
+import org.apache.tuscany.model.assembly.SimpleComponent;
+
+/**
+ * Unit tests for the request scope container
+ *
+ * @version $Rev$ $Date$
+ */
+public class BasicRequestScopeTestCase extends TestCase {
+
+ /**
+ * Tests instance identity is properly maintained
+ */
+ public void testInstanceManagement() throws Exception {
+ EventContext ctx = new EventContextImpl();
+ RequestScopeContext scope = new RequestScopeContext(ctx);
+ scope.registerConfigurations(createConfigurations());
+ scope.start();
+
+ // first request
+ RequestScopeComponentImpl comp1 = (RequestScopeComponentImpl) scope.getContext("TestService1").getInstance(null);
+ Assert.assertNotNull(comp1);
+ scope.onEvent(EventContext.REQUEST_END, null);
+
+ // second request
+ RequestScopeComponentImpl comp2 = (RequestScopeComponentImpl) scope.getContext("TestService1").getInstance(null);
+ Assert.assertNotNull(comp2);
+ Assert.assertNotSame(comp1, comp2);
+ scope.onEvent(EventContext.REQUEST_END, null);
+
+ scope.stop();
+ }
+
+ public void testRegisterContextBeforeRequest() throws Exception {
+ EventContext ctx = new EventContextImpl();
+ RequestScopeContext scope = new RequestScopeContext(ctx);
+ scope.registerConfigurations(createConfigurations());
+ scope.registerConfiguration(createConfiguration("NewTestService"));
+ scope.start();
+ RequestScopeComponent comp1 = (RequestScopeComponent) scope.getContext("TestService1").getInstance(null);
+ Assert.assertNotNull(comp1);
+ RequestScopeComponent comp2 = (RequestScopeComponent) scope.getContext("NewTestService").getInstance(null);
+ Assert.assertNotNull(comp2);
+ scope.onEvent(EventContext.REQUEST_END, null);
+ scope.stop();
+ }
+
+ public void testRegisterContextAfterRequest() throws Exception {
+ EventContext ctx = new EventContextImpl();
+ RequestScopeContext scope = new RequestScopeContext(ctx);
+ scope.registerConfigurations(createConfigurations());
+ scope.start();
+ RequestScopeComponent comp1 = (RequestScopeComponent) scope.getContext("TestService1").getInstance(null);
+ Assert.assertNotNull(comp1);
+ scope.registerConfiguration(createConfiguration("NewTestService"));
+ RequestScopeComponent comp2 = (RequestScopeComponent) scope.getContext("NewTestService").getInstance(null);
+ Assert.assertNotNull(comp2);
+ scope.onEvent(EventContext.REQUEST_END, null);
+ scope.stop();
+ }
+
+ /**
+ * Tests setting no components in the scope
+ */
+ public void testSetNullComponents() throws Exception {
+ EventContext ctx = new EventContextImpl();
+ RequestScopeContext scope = new RequestScopeContext(ctx);
+ scope.registerConfigurations(createConfigurations());
+ scope.start();
+ scope.stop();
+ }
+
+ public void testGetComponentByKey() throws Exception {
+ EventContext ctx = new EventContextImpl();
+ RequestScopeContext scope = new RequestScopeContext(ctx);
+ scope.registerConfigurations(createConfigurations());
+ scope.start();
+
+ RequestScopeComponentImpl comp1 = (RequestScopeComponentImpl) scope.getContext("TestService1").getInstance(null);
+ Assert.assertNotNull(comp1);
+ scope.onEvent(EventContext.REQUEST_END, null);
+
+ // second request
+ // should be null since the other context (thread) expired w/ onEvent(..)
+ Assert.assertNull((RequestScopeComponentImpl) scope.getContextByKey("TestService1", Thread.currentThread()));
+ // Note should test better using concurrent threads to pull the instance
+
+ scope.stop();
+ }
+
+ // ----------------------------------
+ // Private methods
+ // ----------------------------------
+
+ JavaComponentContextBuilder builder = new JavaComponentContextBuilder();
+
+ private List<RuntimeConfiguration<InstanceContext>> createConfigurations() throws NoSuchMethodException, BuilderException {
+ SimpleComponent component = MockFactory.createComponent("TestService1", RequestScopeComponentImpl.class,
+ Scope.REQUEST);
+ builder.build(component, null);
+ List<RuntimeConfiguration<InstanceContext>> configs = new ArrayList();
+ configs.add((RuntimeConfiguration<InstanceContext>) component.getComponentImplementation().getRuntimeConfiguration());
+ return configs;
+ }
+
+ private RuntimeConfiguration<InstanceContext> createConfiguration(String name) throws NoSuchMethodException,
+ BuilderException {
+ SimpleComponent component = MockFactory.createComponent(name, RequestScopeComponentImpl.class,
+ Scope.REQUEST);
+ builder.build(component, null);
+ return (RuntimeConfiguration<InstanceContext>) component.getComponentImplementation().getRuntimeConfiguration();
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/scopes/BasicStatelessScopeTestCase.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/scopes/BasicStatelessScopeTestCase.java
new file mode 100644
index 0000000000..807a0901ce
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/scopes/BasicStatelessScopeTestCase.java
@@ -0,0 +1,125 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.scopes;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.container.java.builder.JavaComponentContextBuilder;
+import org.apache.tuscany.container.java.mock.MockFactory;
+import org.apache.tuscany.container.java.mock.components.StatelessComponent;
+import org.apache.tuscany.container.java.mock.components.StatelessComponentImpl;
+import org.apache.tuscany.core.builder.BuilderException;
+import org.apache.tuscany.core.builder.RuntimeConfiguration;
+import org.apache.tuscany.core.context.EventContext;
+import org.apache.tuscany.core.context.InstanceContext;
+import org.apache.tuscany.core.context.impl.EventContextImpl;
+import org.apache.tuscany.core.context.scope.StatelessScopeContext;
+import org.apache.tuscany.model.assembly.Scope;
+import org.apache.tuscany.model.assembly.SimpleComponent;
+
+/**
+ * Unit tests for the module scope container
+ *
+ * @version $Rev$ $Date$
+ */
+public class BasicStatelessScopeTestCase extends TestCase {
+
+ /**
+ * Tests instance identity is properly maintained
+ */
+ public void testInstanceManagement() throws Exception {
+ EventContext ctx = new EventContextImpl();
+ StatelessScopeContext scope = new StatelessScopeContext(ctx);
+ scope.registerConfigurations(createConfigurations());
+ scope.start();
+ // first request
+ StatelessComponentImpl comp1 = (StatelessComponentImpl) scope.getContext("TestService1").getInstance(null);
+ Assert.assertNotNull(comp1);
+ // second request
+ StatelessComponentImpl comp2 = (StatelessComponentImpl) scope.getContext("TestService1").getInstance(null);
+ Assert.assertNotNull(comp2);
+ Assert.assertNotSame(comp1, comp2);
+ scope.stop();
+ }
+
+ public void testRegisterContextBeforeRequest() throws Exception {
+ EventContext ctx = new EventContextImpl();
+ StatelessScopeContext scope = new StatelessScopeContext(ctx);
+ scope.registerConfigurations(createConfigurations());
+ scope.registerConfiguration(createConfiguration("NewTestService"));
+ scope.start();
+ StatelessComponent comp1 = (StatelessComponent) scope.getContext("TestService1").getInstance(null);
+ Assert.assertNotNull(comp1);
+ StatelessComponent comp2 = (StatelessComponent) scope.getContext("NewTestService").getInstance(null);
+ Assert.assertNotNull(comp2);
+ scope.stop();
+ }
+
+ public void testRegisterContextAfterRequest() throws Exception {
+ EventContext ctx = new EventContextImpl();
+ StatelessScopeContext scope = new StatelessScopeContext(ctx);
+ scope.registerConfigurations(createConfigurations());
+ scope.start();
+ StatelessComponent comp1 = (StatelessComponent) scope.getContext("TestService1").getInstance(null);
+ Assert.assertNotNull(comp1);
+ scope.registerConfiguration(createConfiguration("NewTestService"));
+ StatelessComponent comp2 = (StatelessComponent) scope.getContext("NewTestService").getInstance(null);
+ Assert.assertNotNull(comp2);
+ scope.stop();
+ }
+
+
+ /**
+ * Tests setting no components in the scope
+ */
+ public void testSetNullComponents() throws Exception {
+ EventContext ctx = new EventContextImpl();
+ StatelessScopeContext scope = new StatelessScopeContext(ctx);
+ scope.registerConfigurations(createConfigurations());
+ scope.start();
+ scope.stop();
+ }
+
+ // ----------------------------------
+ // Private methods
+ // ----------------------------------
+
+ JavaComponentContextBuilder builder = new JavaComponentContextBuilder();
+
+ private List<RuntimeConfiguration<InstanceContext>> createConfigurations()
+ throws NoSuchMethodException, BuilderException {
+ SimpleComponent component = MockFactory.createComponent("TestService1", StatelessComponentImpl.class,
+ Scope.INSTANCE);
+ builder.build(component, null);
+ List<RuntimeConfiguration<InstanceContext>> configs = new ArrayList();
+ configs.add((RuntimeConfiguration<InstanceContext>) component.getComponentImplementation().getRuntimeConfiguration());
+ return configs;
+ }
+
+ private RuntimeConfiguration<InstanceContext> createConfiguration(String name)
+ throws NoSuchMethodException, BuilderException {
+ SimpleComponent component = MockFactory.createComponent(name, StatelessComponentImpl.class,
+ Scope.INSTANCE);
+ builder.build(component, null);
+ return (RuntimeConfiguration<InstanceContext>) component.getComponentImplementation().getRuntimeConfiguration();
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/scopes/HttpSessionScopeLifecycleTestCase.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/scopes/HttpSessionScopeLifecycleTestCase.java
new file mode 100644
index 0000000000..1d5780dac4
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/scopes/HttpSessionScopeLifecycleTestCase.java
@@ -0,0 +1,157 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.scopes;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.container.java.builder.JavaComponentContextBuilder;
+import org.apache.tuscany.container.java.mock.MockFactory;
+import org.apache.tuscany.container.java.mock.components.SessionScopeDestroyOnlyComponent;
+import org.apache.tuscany.container.java.mock.components.SessionScopeInitDestroyComponent;
+import org.apache.tuscany.container.java.mock.components.SessionScopeInitOnlyComponent;
+import org.apache.tuscany.core.builder.BuilderException;
+import org.apache.tuscany.core.builder.RuntimeConfiguration;
+import org.apache.tuscany.core.context.EventContext;
+import org.apache.tuscany.core.context.InstanceContext;
+import org.apache.tuscany.core.context.impl.EventContextImpl;
+import org.apache.tuscany.core.context.scope.HttpSessionScopeContext;
+import org.apache.tuscany.model.assembly.Scope;
+import org.apache.tuscany.model.assembly.SimpleComponent;
+
+/**
+ * Lifecycle unit tests for the Http session scope container
+ *
+ * @version $Rev$ $Date$
+ */
+public class HttpSessionScopeLifecycleTestCase extends TestCase {
+
+ /**
+ * Tests instance identity is properly maintained
+ */
+ public void testInitDestroy() throws Exception {
+ EventContext ctx = new EventContextImpl();
+ HttpSessionScopeContext scope = new HttpSessionScopeContext(ctx);
+ scope.registerConfigurations(createComponents());
+ scope.start();
+ Object session = new Object();
+ Object session2 = new Object();
+ // first request, no need to notify scope container since sessions are
+ // evaluated lazily
+ ctx.setIdentifier(EventContext.HTTP_SESSION, session);
+ SessionScopeInitDestroyComponent initDestroy = (SessionScopeInitDestroyComponent) scope.getContext(
+ "TestServiceInitDestroy").getInstance(null);
+ Assert.assertNotNull(initDestroy);
+ SessionScopeInitOnlyComponent initOnly = (SessionScopeInitOnlyComponent) scope.getContext("TestServiceInitOnly")
+ .getInstance(null);
+ Assert.assertNotNull(initOnly);
+ SessionScopeDestroyOnlyComponent destroyOnly = (SessionScopeDestroyOnlyComponent) scope.getContext(
+ "TestServiceDestroyOnly").getInstance(null);
+ Assert.assertNotNull(destroyOnly);
+
+ Assert.assertTrue(initDestroy.isInitialized());
+ Assert.assertTrue(initOnly.isInitialized());
+ Assert.assertFalse(initDestroy.isDestroyed());
+ Assert.assertFalse(destroyOnly.isDestroyed());
+ // end request
+ ctx.clearIdentifier(EventContext.HTTP_SESSION);
+ // expire session
+ scope.onEvent(EventContext.SESSION_END, session);
+ Assert.assertTrue(initDestroy.isDestroyed());
+ Assert.assertTrue(destroyOnly.isDestroyed());
+
+ scope.stop();
+ }
+
+ /**
+ * Test instances destroyed in proper (i.e. reverse) order
+ */
+ public void testDestroyOrder() throws Exception {
+ EventContext ctx = new EventContextImpl();
+ HttpSessionScopeContext scope = new HttpSessionScopeContext(ctx);
+ scope.registerConfigurations(createOrderedInitComponents());
+ scope.start();
+ Object session = new Object();
+ Object session2 = new Object();
+ // request start
+ ctx.setIdentifier(EventContext.HTTP_SESSION, session);
+
+ OrderedInitPojo one = (OrderedInitPojo) scope.getContext("one").getInstance(null);
+ Assert.assertNotNull(one);
+ Assert.assertEquals(1, one.getNumberInstantiated());
+ Assert.assertEquals(1, one.getInitOrder());
+
+ OrderedInitPojo two = (OrderedInitPojo) scope.getContext("two").getInstance(null);
+ Assert.assertNotNull(two);
+ Assert.assertEquals(2, two.getNumberInstantiated());
+ Assert.assertEquals(2, two.getInitOrder());
+
+ OrderedInitPojo three = (OrderedInitPojo) scope.getContext("three").getInstance(null);
+ Assert.assertNotNull(three);
+ Assert.assertEquals(3, three.getNumberInstantiated());
+ Assert.assertEquals(3, three.getInitOrder());
+
+ // end request
+ ctx.clearIdentifier(EventContext.HTTP_SESSION);
+
+ // expire session
+ scope.onEvent(EventContext.SESSION_END, session);
+ Assert.assertEquals(0, one.getNumberInstantiated());
+ scope.stop();
+ }
+
+ // ----------------------------------
+ // Private methods
+ // ----------------------------------
+
+ JavaComponentContextBuilder builder = new JavaComponentContextBuilder();
+
+ private List<RuntimeConfiguration<InstanceContext>> createComponents() throws NoSuchMethodException, BuilderException {
+ SimpleComponent[] ca = new SimpleComponent[3];
+ ca[0] = MockFactory.createComponent("TestServiceInitDestroy", SessionScopeInitDestroyComponent.class,
+ Scope.SESSION);
+ ca[1] = MockFactory.createComponent("TestServiceInitOnly", SessionScopeInitOnlyComponent.class, Scope.SESSION);
+ ca[2] = MockFactory.createComponent("TestServiceDestroyOnly", SessionScopeDestroyOnlyComponent.class,
+ Scope.SESSION);
+ List<RuntimeConfiguration<InstanceContext>> configs = new ArrayList();
+ for (int i = 0; i < ca.length; i++) {
+ builder.build(ca[i], null);
+ configs.add((RuntimeConfiguration<InstanceContext>) ca[i].getComponentImplementation().getRuntimeConfiguration());
+
+ }
+ return configs;
+ }
+
+ private List<RuntimeConfiguration<InstanceContext>> createOrderedInitComponents() throws NoSuchMethodException,
+ BuilderException {
+ SimpleComponent[] ca = new SimpleComponent[3];
+ ca[0] = MockFactory.createComponent("one", OrderedInitPojo.class, Scope.SESSION);
+ ca[1] = MockFactory.createComponent("two", OrderedInitPojo.class, Scope.SESSION);
+ ca[2] = MockFactory.createComponent("three", OrderedInitPojo.class, Scope.SESSION);
+ List<RuntimeConfiguration<InstanceContext>> configs = new ArrayList();
+ for (int i = 0; i < ca.length; i++) {
+ builder.build(ca[i], null);
+ configs.add((RuntimeConfiguration<InstanceContext>) ca[i].getComponentImplementation().getRuntimeConfiguration());
+
+ }
+ return configs;
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/scopes/ModuleScopeLifecycleTestCase.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/scopes/ModuleScopeLifecycleTestCase.java
new file mode 100644
index 0000000000..2c8a79de14
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/scopes/ModuleScopeLifecycleTestCase.java
@@ -0,0 +1,224 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.scopes;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.container.java.builder.JavaComponentContextBuilder;
+import org.apache.tuscany.container.java.mock.MockFactory;
+import org.apache.tuscany.container.java.mock.components.ModuleScopeDestroyOnlyComponent;
+import org.apache.tuscany.container.java.mock.components.ModuleScopeEagerInitComponent;
+import org.apache.tuscany.container.java.mock.components.ModuleScopeEagerInitDestroyComponent;
+import org.apache.tuscany.container.java.mock.components.ModuleScopeInitDestroyComponent;
+import org.apache.tuscany.container.java.mock.components.ModuleScopeInitOnlyComponent;
+import org.apache.tuscany.core.builder.BuilderException;
+import org.apache.tuscany.core.builder.RuntimeConfiguration;
+import org.apache.tuscany.core.context.EventContext;
+import org.apache.tuscany.core.context.InstanceContext;
+import org.apache.tuscany.core.context.impl.EventContextImpl;
+import org.apache.tuscany.core.context.scope.ModuleScopeContext;
+import org.apache.tuscany.model.assembly.Scope;
+import org.apache.tuscany.model.assembly.SimpleComponent;
+
+/**
+ * Lifecycle unit tests for the Http session scope container
+ *
+ * @version $Rev$ $Date$
+ */
+public class ModuleScopeLifecycleTestCase extends TestCase {
+
+ public void testInitDestroy() throws Exception {
+ EventContext ctx = new EventContextImpl();
+ ModuleScopeContext scope = new ModuleScopeContext(ctx);
+ scope.registerConfigurations(createComponents());
+ scope.start();
+ scope.onEvent(EventContext.MODULE_START, null);
+ ModuleScopeInitDestroyComponent initDestroy = (ModuleScopeInitDestroyComponent) scope.getContext(
+ "TestServiceInitDestroy").getInstance(null);
+ Assert.assertNotNull(initDestroy);
+ ModuleScopeInitOnlyComponent initOnly = (ModuleScopeInitOnlyComponent) scope.getContext("TestServiceInitOnly")
+ .getInstance(null);
+ Assert.assertNotNull(initOnly);
+ ModuleScopeDestroyOnlyComponent destroyOnly = (ModuleScopeDestroyOnlyComponent) scope.getContext(
+ "TestServiceDestroyOnly").getInstance(null);
+ Assert.assertNotNull(destroyOnly);
+
+ Assert.assertTrue(initDestroy.isInitialized());
+ Assert.assertTrue(initOnly.isInitialized());
+ Assert.assertFalse(initDestroy.isDestroyed());
+ Assert.assertFalse(destroyOnly.isDestroyed());
+
+ // expire module
+ scope.onEvent(EventContext.MODULE_STOP, null);
+
+ Assert.assertTrue(initDestroy.isDestroyed());
+ Assert.assertTrue(destroyOnly.isDestroyed());
+
+ scope.stop();
+ }
+
+ public void testEagerInit() throws Exception {
+ EventContext ctx = new EventContextImpl();
+ ModuleScopeContext scope = new ModuleScopeContext(ctx);
+ scope.registerConfigurations(createEagerInitComponents());
+ scope.start();
+ scope.onEvent(EventContext.MODULE_START, null);
+ ModuleScopeEagerInitDestroyComponent initDestroy = (ModuleScopeEagerInitDestroyComponent) scope.getContext(
+ "TestServiceEagerInitDestroy").getInstance(null);
+ Assert.assertNotNull(initDestroy);
+ ModuleScopeEagerInitComponent initOnly = (ModuleScopeEagerInitComponent) scope
+ .getContext("TestServiceEagerInit").getInstance(null);
+ Assert.assertNotNull(initOnly);
+
+ Assert.assertTrue(initDestroy.isInitialized());
+ Assert.assertTrue(initOnly.isInitialized());
+ Assert.assertFalse(initDestroy.isDestroyed());
+
+ // expire module
+ scope.onEvent(EventContext.MODULE_STOP, null);
+
+ Assert.assertTrue(initDestroy.isDestroyed());
+
+ scope.stop();
+
+ }
+
+ public void testDestroyOrder() throws Exception {
+ EventContext ctx = new EventContextImpl();
+ ModuleScopeContext scope = new ModuleScopeContext(ctx);
+ scope.registerConfigurations(createOrderedInitComponents());
+ scope.start();
+ scope.onEvent(EventContext.MODULE_START, null);
+ OrderedInitPojo one = (OrderedInitPojo) scope.getContext("one").getInstance(null);
+ Assert.assertNotNull(one);
+ Assert.assertEquals(1, one.getNumberInstantiated());
+ Assert.assertEquals(1, one.getInitOrder());
+
+ OrderedInitPojo two = (OrderedInitPojo) scope.getContext("two").getInstance(null);
+ Assert.assertNotNull(two);
+ Assert.assertEquals(2, two.getNumberInstantiated());
+ Assert.assertEquals(2, two.getInitOrder());
+
+ OrderedInitPojo three = (OrderedInitPojo) scope.getContext("three").getInstance(null);
+ Assert.assertNotNull(three);
+ Assert.assertEquals(3, three.getNumberInstantiated());
+ Assert.assertEquals(3, three.getInitOrder());
+
+ // expire module
+ scope.onEvent(EventContext.MODULE_STOP, null);
+ Assert.assertEquals(0, one.getNumberInstantiated());
+ scope.stop();
+ }
+
+ public void testEagerInitDestroyOrder() throws Exception {
+ EventContext ctx = new EventContextImpl();
+ ModuleScopeContext scope = new ModuleScopeContext(ctx);
+ scope.registerConfigurations(createOrderedEagerInitComponents());
+ scope.start();
+ scope.onEvent(EventContext.MODULE_START, null);
+ OrderedEagerInitPojo one = (OrderedEagerInitPojo) scope.getContext("one").getInstance(null);
+ Assert.assertNotNull(one);
+
+ OrderedEagerInitPojo two = (OrderedEagerInitPojo) scope.getContext("two").getInstance(null);
+ Assert.assertNotNull(two);
+
+ OrderedEagerInitPojo three = (OrderedEagerInitPojo) scope.getContext("three").getInstance(null);
+ Assert.assertNotNull(three);
+
+ // expire module
+ scope.onEvent(EventContext.MODULE_STOP, null);
+ Assert.assertEquals(0, one.getNumberInstantiated());
+ scope.stop();
+ }
+
+ // ----------------------------------
+ // Private methods
+ // ----------------------------------
+
+ JavaComponentContextBuilder builder = new JavaComponentContextBuilder();
+
+ private List<RuntimeConfiguration<InstanceContext>> createComponents() throws NoSuchMethodException, BuilderException {
+ SimpleComponent[] ca = new SimpleComponent[3];
+ ca[0] = MockFactory.createComponent("TestServiceInitDestroy", ModuleScopeInitDestroyComponent.class,
+ Scope.MODULE);
+ ca[1] = MockFactory.createComponent("TestServiceInitOnly", ModuleScopeInitOnlyComponent.class,
+ Scope.MODULE);
+ ca[2] = MockFactory.createComponent("TestServiceDestroyOnly", ModuleScopeDestroyOnlyComponent.class,
+ Scope.MODULE);
+ List<RuntimeConfiguration<InstanceContext>> configs = new ArrayList();
+ for (int i = 0; i < ca.length; i++) {
+ builder.build(ca[i], null);
+ configs.add((RuntimeConfiguration<InstanceContext>) ca[i].getComponentImplementation()
+ .getRuntimeConfiguration());
+
+ }
+ return configs;
+ }
+
+ private List<RuntimeConfiguration<InstanceContext>> createEagerInitComponents() throws NoSuchMethodException,
+ BuilderException {
+ SimpleComponent[] ca = new SimpleComponent[2];
+ ca[0] = MockFactory.createComponent("TestServiceEagerInitDestroy", ModuleScopeEagerInitDestroyComponent.class,
+ Scope.MODULE);
+ ca[1] = MockFactory.createComponent("TestServiceEagerInit", ModuleScopeEagerInitComponent.class,
+ Scope.MODULE);
+ List<RuntimeConfiguration<InstanceContext>> configs = new ArrayList();
+ for (int i = 0; i < ca.length; i++) {
+ builder.build(ca[i], null);
+ configs.add((RuntimeConfiguration<InstanceContext>) ca[i].getComponentImplementation()
+ .getRuntimeConfiguration());
+
+ }
+ return configs;
+ }
+
+ private List<RuntimeConfiguration<InstanceContext>> createOrderedInitComponents() throws NoSuchMethodException,
+ BuilderException {
+ SimpleComponent[] ca = new SimpleComponent[3];
+ ca[0] = MockFactory.createComponent("one", OrderedInitPojo.class, Scope.MODULE);
+ ca[1] = MockFactory.createComponent("two", OrderedInitPojo.class, Scope.MODULE);
+ ca[2] = MockFactory.createComponent("three", OrderedInitPojo.class, Scope.MODULE);
+ List<RuntimeConfiguration<InstanceContext>> configs = new ArrayList();
+ for (int i = 0; i < ca.length; i++) {
+ builder.build(ca[i], null);
+ configs.add((RuntimeConfiguration<InstanceContext>) ca[i].getComponentImplementation()
+ .getRuntimeConfiguration());
+
+ }
+ return configs;
+ }
+
+ private List<RuntimeConfiguration<InstanceContext>> createOrderedEagerInitComponents() throws NoSuchMethodException,
+ BuilderException {
+ SimpleComponent[] ca = new SimpleComponent[3];
+ ca[0] = MockFactory.createComponent("one", OrderedEagerInitPojo.class, Scope.MODULE);
+ ca[1] = MockFactory.createComponent("two", OrderedEagerInitPojo.class, Scope.MODULE);
+ ca[2] = MockFactory.createComponent("three", OrderedEagerInitPojo.class, Scope.MODULE);
+ List<RuntimeConfiguration<InstanceContext>> configs = new ArrayList();
+ for (int i = 0; i < ca.length; i++) {
+ builder.build(ca[i], null);
+ configs.add((RuntimeConfiguration<InstanceContext>) ca[i].getComponentImplementation()
+ .getRuntimeConfiguration());
+
+ }
+ return configs;
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/scopes/OrderException.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/scopes/OrderException.java
new file mode 100644
index 0000000000..fc5f7c8c58
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/scopes/OrderException.java
@@ -0,0 +1,38 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.scopes;
+
+public class OrderException extends Exception {
+
+ public OrderException() {
+ super();
+ }
+
+ public OrderException(String message) {
+ super(message);
+ }
+
+ public OrderException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public OrderException(Throwable cause) {
+ super(cause);
+ }
+
+}
+
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/scopes/OrderedEagerInitPojo.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/scopes/OrderedEagerInitPojo.java
new file mode 100644
index 0000000000..d439159550
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/scopes/OrderedEagerInitPojo.java
@@ -0,0 +1,54 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.scopes;
+
+import org.osoa.sca.annotations.Destroy;
+import org.osoa.sca.annotations.Init;
+
+public class OrderedEagerInitPojo {
+
+ private static Object lock = new Object();
+ private static int numberInstantied;
+ private int initOrder;
+
+ @Init(eager = true)
+ public void init() {
+ synchronized (lock) {
+ ++numberInstantied;
+ initOrder = numberInstantied;
+ }
+ }
+
+ @Destroy
+ public void destroy() throws OrderException {
+ synchronized (lock) {
+ if (initOrder != numberInstantied) {
+ throw new OrderException("Instance shutdown done out of order");
+ }
+ --numberInstantied;
+ }
+ }
+
+ public int getNumberInstantiated() {
+ return numberInstantied;
+ }
+
+ public int getInitOrder() {
+ return initOrder;
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/scopes/OrderedInitPojo.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/scopes/OrderedInitPojo.java
new file mode 100644
index 0000000000..ee5c5145c2
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/scopes/OrderedInitPojo.java
@@ -0,0 +1,54 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.scopes;
+
+import org.osoa.sca.annotations.Destroy;
+import org.osoa.sca.annotations.Init;
+
+public class OrderedInitPojo {
+
+ private static Object lock = new Object();
+ private static int numberInstantied;
+ private int initOrder;
+
+ @Init
+ public void init() {
+ synchronized (lock) {
+ ++numberInstantied;
+ initOrder = numberInstantied;
+ }
+ }
+
+ @Destroy
+ public void destroy() throws OrderException {
+ synchronized (lock) {
+ if (initOrder != numberInstantied) {
+ throw new OrderException("Instance shutdown done out of order");
+ }
+ --numberInstantied;
+ }
+ }
+
+ public int getNumberInstantiated() {
+ return numberInstantied;
+ }
+
+ public int getInitOrder() {
+ return initOrder;
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/scopes/RequestScopeLifecycleTestCase.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/scopes/RequestScopeLifecycleTestCase.java
new file mode 100644
index 0000000000..1979d9b25c
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/java/org/apache/tuscany/container/java/scopes/RequestScopeLifecycleTestCase.java
@@ -0,0 +1,146 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.java.scopes;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.container.java.builder.JavaComponentContextBuilder;
+import org.apache.tuscany.container.java.mock.MockFactory;
+import org.apache.tuscany.container.java.mock.components.SessionScopeDestroyOnlyComponent;
+import org.apache.tuscany.container.java.mock.components.SessionScopeInitDestroyComponent;
+import org.apache.tuscany.container.java.mock.components.SessionScopeInitOnlyComponent;
+import org.apache.tuscany.core.builder.BuilderException;
+import org.apache.tuscany.core.builder.RuntimeConfiguration;
+import org.apache.tuscany.core.context.EventContext;
+import org.apache.tuscany.core.context.InstanceContext;
+import org.apache.tuscany.core.context.impl.EventContextImpl;
+import org.apache.tuscany.core.context.scope.RequestScopeContext;
+import org.apache.tuscany.model.assembly.Scope;
+import org.apache.tuscany.model.assembly.SimpleComponent;
+
+/**
+ * Lifecycle unit tests for the Http session scope container
+ *
+ * @version $Rev$ $Date$
+ */
+public class RequestScopeLifecycleTestCase extends TestCase {
+
+ /**
+ * Tests instance identity is properly maintained
+ */
+ public void testInitDestroy() throws Exception {
+ EventContext ctx = new EventContextImpl();
+ RequestScopeContext scope = new RequestScopeContext(ctx);
+ scope.registerConfigurations(createComponents());
+ scope.start();
+ SessionScopeInitDestroyComponent initDestroy = (SessionScopeInitDestroyComponent) scope.getContext(
+ "TestServiceInitDestroy").getInstance(null);
+ Assert.assertNotNull(initDestroy);
+ SessionScopeInitOnlyComponent initOnly = (SessionScopeInitOnlyComponent) scope.getContext("TestServiceInitOnly")
+ .getInstance(null);
+ Assert.assertNotNull(initOnly);
+ SessionScopeDestroyOnlyComponent destroyOnly = (SessionScopeDestroyOnlyComponent) scope.getContext(
+ "TestServiceDestroyOnly").getInstance(null);
+ Assert.assertNotNull(destroyOnly);
+
+ Assert.assertTrue(initDestroy.isInitialized());
+ Assert.assertTrue(initOnly.isInitialized());
+ Assert.assertFalse(initDestroy.isDestroyed());
+ Assert.assertFalse(destroyOnly.isDestroyed());
+
+ // end request
+ scope.onEvent(EventContext.REQUEST_END, null);
+ Assert.assertTrue(initDestroy.isDestroyed());
+ Assert.assertTrue(destroyOnly.isDestroyed());
+
+ scope.stop();
+ }
+
+ /**
+ * Test instances destroyed in proper (i.e. reverse) order
+ */
+ public void testDestroyOrder() throws Exception {
+ EventContext ctx = new EventContextImpl();
+ RequestScopeContext scope = new RequestScopeContext(ctx);
+ scope.registerConfigurations(createOrderedInitComponents());
+ scope.start();
+ // request start
+ OrderedInitPojo one = (OrderedInitPojo) scope.getContext("one").getInstance(null);
+ Assert.assertNotNull(one);
+ Assert.assertEquals(1, one.getNumberInstantiated());
+ Assert.assertEquals(1, one.getInitOrder());
+
+ OrderedInitPojo two = (OrderedInitPojo) scope.getContext("two").getInstance(null);
+ Assert.assertNotNull(two);
+ Assert.assertEquals(2, two.getNumberInstantiated());
+ Assert.assertEquals(2, two.getInitOrder());
+
+ OrderedInitPojo three = (OrderedInitPojo) scope.getContext("three").getInstance(null);
+ Assert.assertNotNull(three);
+ Assert.assertEquals(3, three.getNumberInstantiated());
+ Assert.assertEquals(3, three.getInitOrder());
+
+ // end request
+ scope.onEvent(EventContext.REQUEST_END, null);
+
+ Assert.assertEquals(0, one.getNumberInstantiated());
+ scope.stop();
+ }
+
+ // ----------------------------------
+ // Private methods
+ // ----------------------------------
+
+ JavaComponentContextBuilder builder = new JavaComponentContextBuilder();
+
+ private List<RuntimeConfiguration<InstanceContext>> createComponents() throws NoSuchMethodException, BuilderException {
+ SimpleComponent[] ca = new SimpleComponent[3];
+ ca[0] = MockFactory.createComponent("TestServiceInitDestroy", SessionScopeInitDestroyComponent.class,
+ Scope.REQUEST);
+ ca[1] = MockFactory.createComponent("TestServiceInitOnly", SessionScopeInitOnlyComponent.class,
+ Scope.REQUEST);
+ ca[2] = MockFactory.createComponent("TestServiceDestroyOnly", SessionScopeDestroyOnlyComponent.class,
+ Scope.REQUEST);
+ List<RuntimeConfiguration<InstanceContext>> configs = new ArrayList();
+ for (int i = 0; i < ca.length; i++) {
+ builder.build(ca[i], null);
+ configs.add((RuntimeConfiguration<InstanceContext>) ca[i].getComponentImplementation().getRuntimeConfiguration());
+
+ }
+ return configs;
+ }
+
+ private List<RuntimeConfiguration<InstanceContext>> createOrderedInitComponents() throws NoSuchMethodException,
+ BuilderException {
+ SimpleComponent[] ca = new SimpleComponent[3];
+ ca[0] = MockFactory.createComponent("one", OrderedInitPojo.class, Scope.REQUEST);
+ ca[1] = MockFactory.createComponent("two", OrderedInitPojo.class, Scope.REQUEST);
+ ca[2] = MockFactory.createComponent("three", OrderedInitPojo.class, Scope.REQUEST);
+ List<RuntimeConfiguration<InstanceContext>> configs = new ArrayList();
+ for (int i = 0; i < ca.length; i++) {
+ builder.build(ca[i], null);
+ configs.add((RuntimeConfiguration<InstanceContext>) ca[i].getComponentImplementation().getRuntimeConfiguration());
+
+ }
+ return configs;
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/resources/org/apache/tuscany/container/java/assembly/tests/sca.module b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/resources/org/apache/tuscany/container/java/assembly/tests/sca.module
new file mode 100644
index 0000000000..d1eda8b8dd
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/resources/org/apache/tuscany/container/java/assembly/tests/sca.module
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
+
+ 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.
+ -->
+<module xmlns="http://www.osoa.org/xmlns/sca/0.9" xmlns:v="http://www.osoa.org/xmlns/sca/values/0.9"
+
+ name="tuscany.container.java.assembly.tests.bigbank.account">
+
+ <entryPoint name="AccountService">
+ <interface.java interface="org.apache.tuscany.container.java.assembly.tests.bigbank.account.services.account.AccountService"/>
+ <binding.ws port="http://www.bigbank.com/AccountService#AccountServiceSOAP"/>
+ <reference>AccountServiceComponent</reference>
+ </entryPoint>
+
+ <component name="AccountServiceComponent">
+ <implementation.java class="org.apache.tuscany.container.java.assembly.tests.bigbank.account.services.account.AccountServiceImpl"/>
+ <properties>
+ <v:currency overridable="may">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.tuscany.container.java.assembly.tests.bigbank.account.services.accountdata.AccountDataServiceImpl"/>
+ </component>
+
+ <component name="StockQuoteService">
+ <implementation.java class="org.apache.tuscany.container.java.assembly.tests.bigbank.account.services.stockquote.StockQuoteServiceImpl"/>
+ </component>
+
+ <!--
+ <externalService name="StockQuoteService">
+ <interface.java interface="org.apache.tuscany.container.java.assembly.tests.bigbank.account.services.stockquote"/>
+ <binding.ws port="http://www.quickstockquote.com/StockQuoteService#StockQuoteServiceSOAP"/>
+ </externalService>
+ -->
+
+</module>
+
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/resources/org/apache/tuscany/container/java/config/ModuleComponentLoaderTest1.module b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/resources/org/apache/tuscany/container/java/config/ModuleComponentLoaderTest1.module
new file mode 100644
index 0000000000..46169aa304
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.java/src/test/resources/org/apache/tuscany/container/java/config/ModuleComponentLoaderTest1.module
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
+
+ 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.
+ -->
+<module xmlns="http://www.osoa.org/xmlns/sca/0.9"
+ xmlns:v="http://www.osoa.org/xmlns/sca/values/0.9"
+ name="ModuleComponentLoaderTest1">
+
+ <component name="HelloWorldServiceComponent">
+ <implementation.java class="org.apache.tuscany.container.java.assembly.mock.HelloWorldImpl"/>
+ </component>
+</module>
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/LICENSE.txt b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/LICENSE.txt
new file mode 100644
index 0000000000..d645695673
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/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/sca-java-1.x/tags/java-stable-20060304/sca/container.js/pom.xml b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/pom.xml
new file mode 100644
index 0000000000..aa90b1dc4d
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/pom.xml
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Copyright (c) 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.
+ -->
+<project>
+ <parent>
+ <groupId>org.apache.tuscany</groupId>
+ <artifactId>tuscany-sca</artifactId>
+ <version>SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>tuscany-container-js</artifactId>
+ <name>Tuscany JavaScript Component Implementation Type</name>
+ <description>Tuscany JavaScript Component Implementation Type.</description>
+ <version>SNAPSHOT</version>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany</groupId>
+ <artifactId>tuscany-core</artifactId>
+ <version>${pom.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>rhino</groupId>
+ <artifactId>js</artifactId>
+ <version>1.6R2</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.tuscany</groupId>
+ <artifactId>tuscany-sdo-plugin</artifactId>
+ <executions>
+ <execution>
+ <configuration>
+ <schemaFile>${basedir}/src/main/resources/model/sca-implementation-js.xsd</schemaFile>
+ <generateLoader>true</generateLoader>
+ <generateSwitch>true</generateSwitch>
+ <noNotification>true</noNotification>
+ <noUnsettable>true</noUnsettable>
+ </configuration>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/main/java/org/apache/tuscany/container/js/assembly/JavaScriptAssemblyFactory.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/main/java/org/apache/tuscany/container/js/assembly/JavaScriptAssemblyFactory.java
new file mode 100644
index 0000000000..0072bcdaa1
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/main/java/org/apache/tuscany/container/js/assembly/JavaScriptAssemblyFactory.java
@@ -0,0 +1,28 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.js.assembly;
+
+import org.apache.tuscany.model.assembly.AssemblyFactory;
+
+public interface JavaScriptAssemblyFactory extends AssemblyFactory {
+
+ /**
+ * Returns a new object of class '<em>JavaScript Implementation</em>'.
+ */
+ JavaScriptImplementation createJavaScriptImplementation();
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/main/java/org/apache/tuscany/container/js/assembly/JavaScriptImplementation.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/main/java/org/apache/tuscany/container/js/assembly/JavaScriptImplementation.java
new file mode 100644
index 0000000000..6edaf2b60a
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/main/java/org/apache/tuscany/container/js/assembly/JavaScriptImplementation.java
@@ -0,0 +1,34 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.js.assembly;
+
+import org.apache.tuscany.common.resource.ResourceLoader;
+import org.apache.tuscany.model.assembly.ComponentImplementation;
+
+/**
+ * A representation of a JavaScript component implementation type
+ *
+ * @version $Rev$ $Date$
+ */
+public interface JavaScriptImplementation extends ComponentImplementation {
+
+ public ResourceLoader getResourceLoader();
+
+ public String getScriptFile();
+
+ public void setScriptFile(String fn);
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/main/java/org/apache/tuscany/container/js/assembly/impl/JavaScriptAssemblyFactoryImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/main/java/org/apache/tuscany/container/js/assembly/impl/JavaScriptAssemblyFactoryImpl.java
new file mode 100644
index 0000000000..21930d22ec
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/main/java/org/apache/tuscany/container/js/assembly/impl/JavaScriptAssemblyFactoryImpl.java
@@ -0,0 +1,33 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.js.assembly.impl;
+
+import org.apache.tuscany.container.js.assembly.JavaScriptAssemblyFactory;
+import org.apache.tuscany.container.js.assembly.JavaScriptImplementation;
+import org.apache.tuscany.model.assembly.impl.AssemblyFactoryImpl;
+
+public class JavaScriptAssemblyFactoryImpl extends AssemblyFactoryImpl implements JavaScriptAssemblyFactory {
+
+ public JavaScriptAssemblyFactoryImpl() {
+ super();
+ }
+
+ public JavaScriptImplementation createJavaScriptImplementation() {
+ return new JavaScriptImplementationImpl();
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/main/java/org/apache/tuscany/container/js/assembly/impl/JavaScriptImplementationImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/main/java/org/apache/tuscany/container/js/assembly/impl/JavaScriptImplementationImpl.java
new file mode 100644
index 0000000000..c6b58a25c6
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/main/java/org/apache/tuscany/container/js/assembly/impl/JavaScriptImplementationImpl.java
@@ -0,0 +1,116 @@
+package org.apache.tuscany.container.js.assembly.impl;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+import org.apache.tuscany.common.resource.ResourceLoader;
+import org.apache.tuscany.container.js.assembly.JavaScriptImplementation;
+import org.apache.tuscany.model.assembly.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.ComponentType;
+import org.apache.tuscany.model.assembly.ModelInitException;
+import org.apache.tuscany.model.assembly.impl.ComponentImplementationImpl;
+
+/**
+ * Default implementation of a JavScript component implementation type
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaScriptImplementationImpl extends ComponentImplementationImpl implements JavaScriptImplementation {
+
+ private ResourceLoader resourceLoader;
+
+ public JavaScriptImplementationImpl() {
+ super();
+ }
+
+ public ResourceLoader getResourceLoader() {
+ return null;
+ }
+
+ public void initialize(AssemblyModelContext modelContext) throws ModelInitException {
+ if (isInitialized()) {
+ return;
+ }
+ this.resourceLoader = modelContext.getApplicationResourceLoader();
+ if(resourceLoader == null){
+ throw new ModelInitException("No resource loader set on model context");
+ }
+ getScriptFile();
+
+ // Initialize the component type
+ ComponentType componentType = getComponentType();
+ if (componentType == null) {
+ try {
+ componentType = createComponentType(modelContext);
+ } catch (IOException e) {
+ throw new ModelInitException("Error retrieving component type file",e);
+ }
+ setComponentType(componentType);
+ }
+
+ super.initialize(modelContext);
+
+ }
+
+ String script;
+
+ public String getScriptFile() {
+ return script;
+ }
+
+ public void setScriptFile(String fn) {
+ script = fn;
+ }
+
+ private String scriptCode;
+
+ public String getScript() throws ModelInitException {
+ if (scriptCode != null) {
+ return scriptCode;
+ }
+ try {
+ URL url = resourceLoader.getResource(getScriptFile());
+ if (url == null) {
+ ModelInitException ce = new ModelInitException("Script not found");
+ ce.setIdentifier(getScriptFile());
+ throw ce;
+ }
+ InputStream inputStream = url.openStream();
+ try {
+ StringBuffer sb = new StringBuffer();
+ int n = 0;
+ while ((n = inputStream.read()) != -1) {
+ sb.append((char) n);
+ }
+ scriptCode = sb.toString();
+ return scriptCode;
+ } finally {
+ inputStream.close();
+ }
+ } catch (IOException e) {
+ ModelInitException ce = new ModelInitException("Error reading script file",e);
+ ce.setIdentifier(getScriptFile());
+ throw ce;
+ }
+ }
+
+ /**
+ * Create the component type
+ *
+ * @param modelContext
+ * @param implementationClass
+ */
+ private ComponentType createComponentType(AssemblyModelContext modelContext) throws IOException{
+ String prefix = script.substring(0,script.lastIndexOf('.'));
+ URL componentTypeFile = resourceLoader.getResource(prefix + ".componentType");
+ if (componentTypeFile != null) {
+ return modelContext.getAssemblyLoader().loadComponentType(componentTypeFile.toString());
+ } else {
+ // TODO we could introspect the JavaScript source
+ return modelContext.getAssemblyFactory().createComponentType();
+ }
+ }
+
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/main/java/org/apache/tuscany/container/js/builder/JavaScriptComponentContextBuilder.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/main/java/org/apache/tuscany/container/js/builder/JavaScriptComponentContextBuilder.java
new file mode 100644
index 0000000000..37ec68942a
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/main/java/org/apache/tuscany/container/js/builder/JavaScriptComponentContextBuilder.java
@@ -0,0 +1,217 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.js.builder;
+
+import java.lang.reflect.Method;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.container.js.assembly.JavaScriptImplementation;
+import org.apache.tuscany.container.js.assembly.impl.JavaScriptImplementationImpl;
+import org.apache.tuscany.container.js.config.JavaScriptComponentRuntimeConfiguration;
+import org.apache.tuscany.container.js.rhino.RhinoScript;
+import org.apache.tuscany.core.builder.BuilderConfigException;
+import org.apache.tuscany.core.builder.BuilderException;
+import org.apache.tuscany.core.builder.RuntimeConfigurationBuilder;
+import org.apache.tuscany.core.context.AggregateContext;
+import org.apache.tuscany.core.context.QualifiedName;
+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.ComponentImplementation;
+import org.apache.tuscany.model.assembly.ConfiguredReference;
+import org.apache.tuscany.model.assembly.ConfiguredService;
+import org.apache.tuscany.model.assembly.ModelInitException;
+import org.apache.tuscany.model.assembly.Scope;
+import org.apache.tuscany.model.assembly.Service;
+import org.apache.tuscany.model.assembly.ServiceContract;
+import org.apache.tuscany.model.assembly.SimpleComponent;
+import org.osoa.sca.annotations.Init;
+
+/**
+ * Builds {@link org.apache.tuscany.container.js.config.JavaScriptComponentRuntimeConfiguration}s from a JavaScript
+ * component type
+ *
+ * @version $Rev$ $Date$
+ */
+@org.osoa.sca.annotations.Scope("MODULE")
+public class JavaScriptComponentContextBuilder implements RuntimeConfigurationBuilder<AggregateContext> {
+
+ private ProxyFactoryFactory factory;
+ private MessageFactory msgFactory;
+ private RuntimeConfigurationBuilder referenceBuilder;
+ private RuntimeContext runtimeContext;
+
+ // ----------------------------------
+ // Constructors
+ // ----------------------------------
+
+ public JavaScriptComponentContextBuilder() {
+ }
+
+ // ----------------------------------
+ // Methods
+ // ----------------------------------
+
+ @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.factory = factory;
+ }
+
+ /**
+ * Sets the factory used to construct invocation messages
+ */
+ @Autowire
+ public void setMessageFactory(MessageFactory msgFactory) {
+ this.msgFactory = 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 setReferenceBuilder(RuntimeConfigurationBuilder builder) {
+ this.referenceBuilder = builder;
+ }
+
+ public void build(AssemblyModelObject modelObject, AggregateContext context) throws BuilderException {
+ if (modelObject instanceof SimpleComponent) {
+ SimpleComponent component = (SimpleComponent) modelObject;
+ ComponentImplementation impl = component.getComponentImplementation();
+ if (impl instanceof JavaScriptImplementation) {
+ Scope scope = ((JavaScriptImplementation) impl).getComponentType().getServices().get(0).getServiceContract()
+ .getScope();
+ Map<String, Class> services = new HashMap();
+ for (Service service : ((JavaScriptImplementation) impl).getComponentType().getServices()) {
+ services.put(service.getName(), service.getServiceContract().getInterface());
+ }
+ Map<String, Object> properties = new HashMap();
+ // TODO support properties
+ String script = null;
+ if (impl instanceof JavaScriptImplementationImpl) { // fixme
+ try {
+ script = ((JavaScriptImplementationImpl) impl).getScript();
+ } catch (ModelInitException e) {
+ throw new BuilderConfigException(e);
+ }
+ }
+
+ RhinoScript invoker = createRhinoInvoker(component.getName(), script, properties);
+ JavaScriptComponentRuntimeConfiguration config = new JavaScriptComponentRuntimeConfiguration(component.getName(),
+ scope, services, properties, invoker);
+
+ // create target-side invocation chains for each service offered by the implementation
+ for (ConfiguredService configuredService : component.getConfiguredServices()) {
+ Service service = configuredService.getService();
+ ServiceContract contract = service.getServiceContract();
+ Map<Method, InvocationConfiguration> iConfigMap = new MethodHashMap();
+ ProxyFactory proxyFactory = factory.createProxyFactory();
+ for (Method method : contract.getInterface().getMethods()) {
+ InvocationConfiguration iConfig = new InvocationConfiguration(method);
+ iConfigMap.put(method, iConfig);
+ }
+ QualifiedName qName = new QualifiedName(component.getName() + QualifiedName.NAME_SEPARATOR + service.getName());
+ ProxyConfiguration pConfiguration = new ProxyConfiguration(qName, iConfigMap, contract.getInterface().getClassLoader(), msgFactory);
+ proxyFactory.setBusinessInterface(contract.getInterface());
+ proxyFactory.setProxyConfiguration(pConfiguration);
+ configuredService.setProxyFactory(proxyFactory);
+ if (referenceBuilder != null) {
+ // invoke the reference builder to handle target-side metadata
+ referenceBuilder.build(configuredService, context);
+ }
+ // add tail interceptor
+ for (InvocationConfiguration iConfig : (Collection<InvocationConfiguration>) iConfigMap.values()) {
+ iConfig.addTargetInterceptor(new InvokerInterceptor());
+ }
+ config.addTargetProxyFactory(service.getName(), proxyFactory);
+ }
+
+ // handle references
+ List<ConfiguredReference> configuredReferences = component.getConfiguredReferences();
+ if (configuredReferences != null) {
+ for (ConfiguredReference reference : configuredReferences) {
+ ProxyFactory proxyFactory = factory.createProxyFactory();
+ ServiceContract interfaze = reference.getReference().getServiceContract();
+ Map<Method, InvocationConfiguration> iConfigMap = new MethodHashMap();
+ for (Method method : interfaze.getInterface().getMethods()) {
+ InvocationConfiguration iConfig = new InvocationConfiguration(method);
+ iConfigMap.put(method, iConfig);
+ }
+ String targetCompName = reference.getTargetConfiguredServices().get(0).getAggregatePart().getName();
+ String targetSerivceName = reference.getTargetConfiguredServices().get(0).getService().getName();
+
+ QualifiedName qName = new QualifiedName(targetCompName + "/" + targetSerivceName);
+
+ // QualifiedName qName = new QualifiedName(reference.getPart().getName() + "/"
+ // + reference.getPort().getName());
+ ProxyConfiguration pConfiguration = new ProxyConfiguration(qName, iConfigMap, interfaze.getInterface().getClassLoader(), msgFactory);
+ proxyFactory.setBusinessInterface(interfaze.getInterface());
+ proxyFactory.setProxyConfiguration(pConfiguration);
+ reference.setProxyFactory(proxyFactory);
+ if (referenceBuilder != null) {
+ // invoke the reference builder to handle metadata associated with the reference
+ referenceBuilder.build(reference, context);
+ }
+ config.addSourceProxyFactory(reference.getReference().getName(), proxyFactory);
+ }
+ }
+ component.getComponentImplementation().setRuntimeConfiguration(config);
+ }
+ }
+ }
+
+ /**
+ * Creates a representation of the JavaScript implementation script that is used to perform invocations
+ *
+ * @param name
+ * @param script the Script source
+ * @param properties configured properties for the component
+ * @return
+ */
+ private RhinoScript createRhinoInvoker(String name, String script, Map properties) {
+ RhinoScript ri = new RhinoScript(name, script, properties);
+ return ri;
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/main/java/org/apache/tuscany/container/js/builder/JavaScriptTargetWireBuilder.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/main/java/org/apache/tuscany/container/js/builder/JavaScriptTargetWireBuilder.java
new file mode 100644
index 0000000000..74433db823
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/main/java/org/apache/tuscany/container/js/builder/JavaScriptTargetWireBuilder.java
@@ -0,0 +1,75 @@
+package org.apache.tuscany.container.js.builder;
+
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.container.js.config.JavaScriptComponentRuntimeConfiguration;
+import org.apache.tuscany.container.js.rhino.RhinoTargetInvoker;
+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;
+
+/**
+ * Responsible for bridging source- and target-side invocations chains when the target type is a JavaScript
+ * implementation
+ *
+ * @version $Rev$ $Date$
+ */
+@Scope("MODULE")
+public class JavaScriptTargetWireBuilder implements WireBuilder {
+
+ private RuntimeContext runtimeContext;
+
+ @Autowire
+ public void setRuntimeContext(RuntimeContext context) {
+ runtimeContext = context;
+ }
+
+ public JavaScriptTargetWireBuilder() {
+ }
+
+ @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 (!(JavaScriptComponentRuntimeConfiguration.class.isAssignableFrom(targetType))) {
+ return;
+ }
+ for (InvocationConfiguration sourceInvocationConfig : sourceFactory.getProxyConfiguration().getInvocationConfigurations()
+ .values()) {
+ Method method = sourceInvocationConfig.getMethod();
+ RhinoTargetInvoker invoker = new RhinoTargetInvoker(sourceFactory.getProxyConfiguration().getTargetName()
+ .getPartName(), method.getName(), targetScopeContext);
+ if (downScope) {
+ // the source scope is shorter than the target, so the invoker can cache the target instance
+ // invoker.setCacheable(true);
+ } else {
+ // invoker.setCacheable(false);
+ }
+ sourceInvocationConfig.setTargetInvoker(invoker);
+ }
+ }
+
+ public void completeTargetChain(ProxyFactory targetFactory, Class targetType, ScopeContext targetScopeContext)
+ throws BuilderConfigException {
+ if (!(JavaScriptComponentRuntimeConfiguration.class.isAssignableFrom(targetType))) {
+ return;
+ }
+ for (InvocationConfiguration targetInvocationConfig : targetFactory.getProxyConfiguration().getInvocationConfigurations()
+ .values()) {
+ Method method = targetInvocationConfig.getMethod();
+ RhinoTargetInvoker invoker = new RhinoTargetInvoker(targetFactory.getProxyConfiguration().getTargetName()
+ .getPartName(), method.getName(), targetScopeContext);
+ targetInvocationConfig.setTargetInvoker(invoker);
+ }
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/main/java/org/apache/tuscany/container/js/config/JavaScriptComponentRuntimeConfiguration.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/main/java/org/apache/tuscany/container/js/config/JavaScriptComponentRuntimeConfiguration.java
new file mode 100644
index 0000000000..b24f98f32a
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/main/java/org/apache/tuscany/container/js/config/JavaScriptComponentRuntimeConfiguration.java
@@ -0,0 +1,101 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.js.config;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.container.js.context.JavaScriptComponentContext;
+import org.apache.tuscany.container.js.rhino.RhinoScript;
+import org.apache.tuscany.core.builder.ContextCreationException;
+import org.apache.tuscany.core.builder.RuntimeConfiguration;
+import org.apache.tuscany.core.context.SimpleComponentContext;
+import org.apache.tuscany.core.invocation.spi.ProxyFactory;
+import org.apache.tuscany.model.assembly.Scope;
+
+/**
+ * Creates instance contexts for JavaScript component types
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaScriptComponentRuntimeConfiguration implements RuntimeConfiguration<SimpleComponentContext> {
+
+ private Scope scope;
+
+ private String name;
+
+ private Map<String, Class> services;
+
+ private Map<String, Object> properties;
+
+ private RhinoScript invoker;
+
+ public JavaScriptComponentRuntimeConfiguration(String name, Scope scope, Map<String, Class> services,
+ Map<String, Object> properties, RhinoScript invoker) {
+ this.name = name;
+ this.scope = scope;
+ this.services = services;
+ this.properties = properties;
+ this.invoker = invoker;
+ }
+
+ public SimpleComponentContext createInstanceContext() throws ContextCreationException {
+ return new JavaScriptComponentContext(name, services, properties, sourceProxyFactories, targetProxyFactories, invoker
+ .copy());
+ }
+
+ public Scope getScope() {
+ return scope;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ private Map<String, ProxyFactory> targetProxyFactories = new HashMap<String, ProxyFactory>();
+
+ public void addTargetProxyFactory(String serviceName, ProxyFactory factory) {
+ targetProxyFactories.put(serviceName, factory);
+ }
+
+ public ProxyFactory getTargetProxyFactory(String serviceName) {
+ return targetProxyFactories.get(serviceName);
+ }
+
+ public Map<String, ProxyFactory> getTargetProxyFactories() {
+ return targetProxyFactories;
+ }
+
+ private Map<String, ProxyFactory> sourceProxyFactories = new HashMap<String, ProxyFactory>();
+
+ public void addSourceProxyFactory(String referenceName, ProxyFactory factory) {
+ sourceProxyFactories.put(referenceName, factory);
+ }
+
+ public ProxyFactory getSourceProxyFactory(String referenceName) {
+ return sourceProxyFactories.get(referenceName);
+ }
+
+ public Map<String, ProxyFactory> getSourceProxyFactories() {
+ return sourceProxyFactories;
+ }
+
+ public void prepare() {
+
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/main/java/org/apache/tuscany/container/js/context/JavaScriptComponentContext.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/main/java/org/apache/tuscany/container/js/context/JavaScriptComponentContext.java
new file mode 100644
index 0000000000..8a4db7eb44
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/main/java/org/apache/tuscany/container/js/context/JavaScriptComponentContext.java
@@ -0,0 +1,161 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.js.context;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.tuscany.container.js.rhino.RhinoScript;
+import org.apache.tuscany.core.context.AbstractContext;
+import org.apache.tuscany.core.context.CoreRuntimeException;
+import org.apache.tuscany.core.context.LifecycleEventListener;
+import org.apache.tuscany.core.context.QualifiedName;
+import org.apache.tuscany.core.context.SimpleComponentContext;
+import org.apache.tuscany.core.context.TargetException;
+import org.apache.tuscany.core.invocation.spi.ProxyCreationException;
+import org.apache.tuscany.core.invocation.spi.ProxyFactory;
+
+public class JavaScriptComponentContext extends AbstractContext implements SimpleComponentContext {
+
+ private Map<String, Class> services;
+
+ private RhinoScript rhinoInvoker;
+
+ private Map<String, Object> properties;
+
+ private Map<String, ProxyFactory> sourceProxyFactories;
+
+ private Map<String, ProxyFactory> targetProxyFactories;
+
+ private Object instance;
+
+ public JavaScriptComponentContext(String name, Map<String, Class> services, Map<String, Object> properties,
+ Map<String, ProxyFactory> sourceProxyFactories, Map<String, ProxyFactory> targetProxyFactories, RhinoScript invoker) {
+ super(name);
+ assert (services != null) : "No service interface mapping specified";
+ assert (properties != null) : "No properties specified";
+ this.services = services;
+ this.properties = properties;
+ this.rhinoInvoker = invoker;
+ this.sourceProxyFactories = sourceProxyFactories;
+ this.targetProxyFactories = targetProxyFactories;
+ }
+
+ public Object getInstance(QualifiedName qName) throws TargetException {
+ return getInstance(qName, true);
+ }
+
+ public synchronized Object getInstance(QualifiedName qName, boolean notify) throws TargetException {
+ String portName=qName.getPortName();
+ ProxyFactory targetFactory;
+ if (portName!=null) {
+ targetFactory = targetProxyFactories.get(portName);
+ } else {
+ //FIXME The port name is null here, either locateService needs more information (the expected interface) to
+ // select the correct port, or we need to return a factory that matches the whole set of services exposed by
+ // the component.
+ targetFactory = targetProxyFactories.values().iterator().next();
+ }
+ if (targetFactory == null) {
+ TargetException e = new TargetException("Target service not found");
+ e.setIdentifier(qName.getPortName());
+ e.addContextName(getName());
+ throw e;
+ }
+ try {
+ Object proxy = targetFactory.createProxy(); //createProxy(new Class[] { iface });
+ notifyListeners(notify);
+ return proxy;
+ } catch (ProxyCreationException e) {
+ TargetException te = new TargetException("Error returning target", e);
+ e.setIdentifier(qName.getPortName());
+ e.addContextName(getName());
+ throw te;
+ }
+ }
+
+ public Object getImplementationInstance() throws TargetException {
+ return getImplementationInstance(true);
+ }
+
+ public Object getImplementationInstance(boolean notify) throws TargetException {
+ rhinoInvoker.updateScriptScope(properties); // create prop values
+ return rhinoInvoker;
+ }
+
+// private Object createProxy(Class[] ifaces) throws ProxyCreationException {
+// // final RhinoInvoker rhinoInvoker = implementation.getRhinoInvoker().copy();
+// rhinoInvoker.updateScriptScope(properties); // create prop values
+// final Map refs = createInvocationContext();
+// InvocationHandler ih = new InvocationHandler() {
+// public Object invoke(Object proxy, Method method, Object[] args) {
+// return rhinoInvoker.invoke(method.getName(), args, method.getReturnType(), refs);
+// // return rhinoInvoker.invoke(method.getName(), args, method.getReturnType(),createInvocationContext());
+// }
+// };
+// return Proxy.newProxyInstance(ifaces[0].getClassLoader(), ifaces, ih);
+// }
+
+ private void notifyListeners(boolean notify) {
+ if (notify) {
+ for (Iterator iter = contextListener.iterator(); iter.hasNext();) {
+ LifecycleEventListener listener = (LifecycleEventListener) iter.next();
+ listener.onInstanceCreate(this);
+ }
+ }
+ }
+
+ /**
+ * Creates a map containing any properties and their values
+ */
+ // private Map createPropertyValues() {
+ // Map<String,Object> context = new HashMap<String,Object>();
+ // List<ConfiguredProperty> configuredProperties = component.getConfiguredProperties();
+ // if (configuredProperties != null) {
+ // for (ConfiguredProperty property : configuredProperties) {
+ // context.put(property.getProperty().getName(), property.getValue());
+ // }
+ // }
+ // return context;
+ // }
+ /**
+ * Creates a map containing any ServiceReferences
+ */
+ private Map createInvocationContext() throws ProxyCreationException {
+ Map<String, Object> context = new HashMap<String, Object>();
+ for (Map.Entry<String, ProxyFactory> entry : sourceProxyFactories.entrySet()) {
+ context.put(entry.getKey(), entry.getValue().createProxy());
+ }
+ return context;
+ }
+
+ public boolean isEagerInit() {
+ return false;
+ }
+
+ public boolean isDestroyable() {
+ return false;
+ }
+
+ public void start() throws CoreRuntimeException {
+ }
+
+ public void stop() throws CoreRuntimeException {
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/main/java/org/apache/tuscany/container/js/loader/JavaScriptSCDLModelLoader.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/main/java/org/apache/tuscany/container/js/loader/JavaScriptSCDLModelLoader.java
new file mode 100644
index 0000000000..ed7d267c89
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/main/java/org/apache/tuscany/container/js/loader/JavaScriptSCDLModelLoader.java
@@ -0,0 +1,77 @@
+package org.apache.tuscany.container.js.loader;
+
+import org.apache.tuscany.container.js.assembly.JavaScriptAssemblyFactory;
+import org.apache.tuscany.container.js.assembly.JavaScriptImplementation;
+import org.apache.tuscany.container.js.assembly.impl.JavaScriptAssemblyFactoryImpl;
+import org.apache.tuscany.container.js.scdl.ScdlFactory;
+import org.apache.tuscany.container.js.scdl.impl.ScdlPackageImpl;
+import org.apache.tuscany.core.runtime.RuntimeContext;
+import org.apache.tuscany.core.system.annotation.Autowire;
+import org.apache.tuscany.core.loader.SCDLModelLoaderRegistry;
+import org.apache.tuscany.model.assembly.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.AssemblyModelObject;
+import org.apache.tuscany.model.scdl.loader.SCDLModelLoader;
+import org.apache.tuscany.sdo.util.SDOUtil;
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Destroy;
+import org.osoa.sca.annotations.Reference;
+
+/**
+ * Populates the assembly model from an SCDL model
+ */
+@org.osoa.sca.annotations.Scope("MODULE")
+public class JavaScriptSCDLModelLoader implements SCDLModelLoader {
+
+ private RuntimeContext runtimeContext;
+ private SCDLModelLoaderRegistry loaderRegistry;
+ private JavaScriptAssemblyFactory jsFactory;
+
+ static {
+ // Register the JavaScript SCDL model
+ SDOUtil.registerStaticTypes(ScdlFactory.class);
+ }
+
+ /**
+ * @param runtimeContext The runtimeContext to set.
+ */
+ @Autowire
+ public void setRuntimeContext(RuntimeContext runtimeContext) {
+ this.runtimeContext = runtimeContext;
+ }
+
+// @Reference
+ public void setLoaderRegistry(SCDLModelLoaderRegistry registry) {
+ this.loaderRegistry = registry;
+ }
+
+ @Init(eager=true)
+ public void init() {
+ runtimeContext.addLoader(this);
+// loaderRegistry.registerLoader(this);
+ }
+
+ @Destroy
+ public void destroy() {
+// loaderRegistry.unregisterLoader(this);
+ }
+
+ /**
+ * Constructs a new JavaSCDLModelLoader.
+ */
+ public JavaScriptSCDLModelLoader() {
+ this.jsFactory=new JavaScriptAssemblyFactoryImpl();
+ }
+
+ /**
+ * @see org.apache.tuscany.model.scdl.loader.SCDLModelLoader#load(org.apache.tuscany.model.assembly.AssemblyModelContext, java.lang.Object)
+ */
+ public AssemblyModelObject load(AssemblyModelContext modelContext, Object object) {
+ if (object instanceof org.apache.tuscany.container.js.scdl.JavaScriptImplementation) {
+ org.apache.tuscany.container.js.scdl.JavaScriptImplementation scdlImplementation=(org.apache.tuscany.container.js.scdl.JavaScriptImplementation)object;
+ JavaScriptImplementation implementation=jsFactory.createJavaScriptImplementation();
+ implementation.setScriptFile(scdlImplementation.getScriptFile());
+ return implementation;
+ } else
+ return null;
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/main/java/org/apache/tuscany/container/js/rhino/RhinoScript.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/main/java/org/apache/tuscany/container/js/rhino/RhinoScript.java
new file mode 100644
index 0000000000..4ddee12fe4
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/main/java/org/apache/tuscany/container/js/rhino/RhinoScript.java
@@ -0,0 +1,298 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.js.rhino;
+
+import java.util.Iterator;
+import java.util.Map;
+
+import org.mozilla.javascript.Context;
+import org.mozilla.javascript.ContextFactory;
+import org.mozilla.javascript.Function;
+import org.mozilla.javascript.Script;
+import org.mozilla.javascript.Scriptable;
+import org.mozilla.javascript.Wrapper;
+
+/**
+ * Represents, and is responsible for dispatching to, a JavaScript artifact in Rhino
+ */
+public class RhinoScript {
+
+ private String scriptName;
+
+ private String script;
+
+ private Scriptable scriptScope;
+
+ private Scriptable sharedScope;
+
+ /*
+ * Enable dynamic scopes so a script can be used concurrently with a global shared scope and individual execution
+ * scopes. See http://www.mozilla.org/rhino/scopes.html TODO: need to review how ths fits in with Tuscany scopes
+ */
+ private static class MyFactory extends ContextFactory {
+ protected boolean hasFeature(Context cx, int featureIndex) {
+ if (featureIndex == Context.FEATURE_DYNAMIC_SCOPE) {
+ return true;
+ }
+ return super.hasFeature(cx, featureIndex);
+ }
+ }
+
+ static {
+ ContextFactory.initGlobal(new MyFactory());
+ }
+
+ /**
+ * Create a new RhinoInvoker.
+ *
+ * @param scriptName the name of the script. Can be anything, only used in messages to identify the script
+ * @param script the complete script
+ */
+ public RhinoScript(String scriptName, String script) {
+ this(scriptName, script, (Map) null);
+ }
+
+ /**
+ * Create a new RhinoInvoker.
+ *
+ * @param scriptName the name of the script. Can be anything, only used in messages to identify the script
+ * @param script the complete script
+ * @param context name-value pairs that are added in to the scope where the script is compiled. May be null. The
+ * value objects are made available to the script by using a variable with the name.
+ */
+ public RhinoScript(String scriptName, String script, Map context) {
+ this.scriptName = scriptName;
+ this.script = script;
+ initScriptScope(scriptName, script, context);
+ initSharedScope();
+ }
+
+ /**
+ * Construct a RhinoInvoker from another RhinoInvoker object. This uses the original script scope so the script
+ * doesn't need to be recompiled.
+ */
+ protected RhinoScript(String scriptName, String script, Scriptable scriptScope) {
+ this.scriptName = scriptName;
+ this.script = script;
+ this.scriptScope = scriptScope;
+ initSharedScope();
+ }
+
+ /**
+ * Invoke a script function
+ *
+ * @param functionName the name of the function to invoke.
+ * @param arg arguments to the function, may be a single object or an array of objects.
+ * @return the function return value.
+ */
+ public Object invoke(String functionName, Object args) {
+ return invoke(functionName, args, null, null);
+ }
+
+ /**
+ * Invoke a script function
+ *
+ * @param functionName the name of the function to invoke.
+ * @param arg arguments to the function, may be a single object or an array of objects.
+ * @param contexts a Map of name-value pairs which are added to the invocation Scope to enable the script to access
+ * the values by using the variable in name.
+ * @return the function return value.
+ */
+ public Object invoke(String functionName, Object args, Map contexts) {
+ return invoke(functionName, args, null, contexts);
+ }
+
+ /**
+ * Invoke a script function
+ *
+ * @param functionName the name of the function to invoke.
+ * @param arg arguments to the function, may be a single object or an array of objects.
+ * @param responseClass the desired class of the response object.
+ * @param contexts a Map of name-value pairs which are added to the invocation Scope to enable the script to access
+ * the values by using the variable in name.
+ * @return the function return value.
+ */
+ public Object invoke(String functionName, Object arg, Class responseClass, Map contexts) {
+ Context cx = Context.enter();
+ try {
+ Function function = getFunction(scriptScope, functionName);
+ Scriptable invocationScope = getInvocationScope(cx, contexts);
+ Object[] args = processArgs(arg, invocationScope);
+ Object jsResponse = function.call(cx, invocationScope, invocationScope, args);
+ Object response = processResponse(jsResponse, responseClass);
+ return response;
+ } finally {
+ Context.exit();
+ }
+ }
+
+ /**
+ * Turn args to JS objects and convert any OMElement to E4X XML
+ */
+ protected Object[] processArgs(Object arg, Scriptable scope) {
+ // TODO: implement pluggable way to transform objects (eg SDO or AXIOM) to E4X XML objects
+ // if (arg instanceof OMElement) {
+ // try {
+ // arg = E4XAXIOMUtils.toScriptableObject((OMElement) arg, scope);
+ // } catch (XmlException e) {
+ // throw new RuntimeException(e);
+ // }
+ // } else if (arg instanceof MessageContext) {
+ // arg = new E4XMessageContext((MessageContext) arg, scope);
+ // }
+ Object[] args;
+ if (arg == null) {
+ args = new Object[] { null };
+ } else if (arg.getClass().isArray()) {
+ args = (Object[]) arg;
+ for (int i = 0; i < args.length; i++) {
+ args[i] = Context.toObject(args[i], scope);
+ }
+ } else {
+ args = new Object[] { Context.toObject(arg, scope) };
+ }
+ return args;
+ }
+
+ /**
+ * Unwrap and convert response
+ */
+ protected Object processResponse(Object response, Class responseClass) {
+ // TODO: implement pluggable way to transform E4X XML into specific objects (eg SDO or AXIOM)
+ // } else if (response instanceof XMLObject) {
+ // response = E4XAXIOMUtils.toOMElement((XMLObject) response);
+ if (Context.getUndefinedValue().equals(response)) {
+ response = null;
+ } else if (response instanceof Wrapper) {
+ response = ((Wrapper) response).unwrap();
+ } else {
+ if (responseClass != null) {
+ response = Context.toType(response, responseClass);
+ } else {
+ response = Context.toType(response, String.class);
+ }
+ }
+ return response;
+ }
+
+ /**
+ * Create a Rhino scope and compile the script into it
+ */
+ protected void initScriptScope(String fileName, String scriptCode, Map context) {
+ Context cx = Context.enter();
+ try {
+
+ this.scriptScope = cx.initStandardObjects(null, true);
+ Script compiledScript = cx.compileString(scriptCode, fileName, 1, null);
+ compiledScript.exec(cx, scriptScope);
+ addContexts(scriptScope, context);
+
+ } finally {
+ Context.exit();
+ }
+ }
+
+ /**
+ * Initializes the shared scope
+ */
+ protected void initSharedScope() {
+ Context cx = Context.enter();
+ try {
+
+ this.sharedScope = cx.newObject(scriptScope);
+ sharedScope.setPrototype(scriptScope);
+ sharedScope.setParentScope(null);
+
+ } finally {
+ Context.exit();
+ }
+ }
+
+ /**
+ * Get a Rhino scope for the function invocation. If the invocation has no context objects then this will use the
+ * shared scope otherwise a new scope is created to hold the context objects. Any new variables the executing script
+ * might define will go in the sharedScope. This new scope is just to hold the invocation specific context objects.
+ */
+ protected Scriptable getInvocationScope(Context cx, Map contexts) {
+
+ Scriptable scope;
+ if (contexts == null || contexts.size() == 0) {
+ scope = sharedScope;
+ } else {
+ scope = cx.newObject(sharedScope);
+ scope.setPrototype(sharedScope);
+ scope.setParentScope(null);
+ addContexts(scope, contexts);
+ }
+
+ return scope;
+ }
+
+ /**
+ * Add the context to the scope. This will make the objects available to a script by using the name it was added
+ * with.
+ */
+ protected void addContexts(Scriptable scope, Map contexts) {
+ if (contexts != null) {
+ for (Iterator i = contexts.keySet().iterator(); i.hasNext();) {
+ String name = (String) i.next();
+ Object value = contexts.get(name);
+ if (value != null) {
+ scope.put(name, scope, Context.toObject(value, scope));
+ }
+ }
+ }
+ }
+
+ /**
+ * Get the Rhino Function object for the named script function
+ */
+ protected Function getFunction(Scriptable scope, String functionName) {
+
+ Object handleObj = scope.get(functionName, scope);
+
+ if (!(handleObj instanceof Function)) {
+ throw new RuntimeException("script function '" + functionName + "' is undefined or not a function in script "
+ + scriptName);
+ }
+
+ return (Function) handleObj;
+ }
+
+ /**
+ * Make a copy of this RhinoScript object. This shares the script scope to avoid the overhead of recompiling the
+ * script, and to allow any initialization done by the script to be shared.
+ */
+ public RhinoScript copy() {
+ return new RhinoScript(scriptName, script, scriptScope);
+ }
+
+ /**
+ * Update the scope where the script is complied with new context values
+ *
+ * @param properties
+ */
+ public void updateScriptScope(Map context) {
+ Context.enter();
+ try {
+ addContexts(scriptScope, context);
+ } finally {
+ Context.exit();
+ }
+ }
+
+} \ No newline at end of file
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/main/java/org/apache/tuscany/container/js/rhino/RhinoTargetInvoker.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/main/java/org/apache/tuscany/container/js/rhino/RhinoTargetInvoker.java
new file mode 100644
index 0000000000..62cf40f333
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/main/java/org/apache/tuscany/container/js/rhino/RhinoTargetInvoker.java
@@ -0,0 +1,81 @@
+package org.apache.tuscany.container.js.rhino;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.apache.tuscany.core.context.QualifiedName;
+import org.apache.tuscany.core.context.ScopeContext;
+import org.apache.tuscany.core.invocation.Interceptor;
+import org.apache.tuscany.core.invocation.TargetInvoker;
+import org.apache.tuscany.core.message.Message;
+
+public class RhinoTargetInvoker implements TargetInvoker {
+
+ private ScopeContext container;
+
+ private QualifiedName name;
+
+ private String operation;
+
+ private RhinoScript target;
+
+ public RhinoTargetInvoker(String serviceName, String operation, ScopeContext container) {
+ assert (serviceName != null) : "No service name specified";
+ assert (container != null) : "No scope container specified";
+ assert (operation != null) : "No operation specified";
+ this.name = new QualifiedName(serviceName);
+ this.container = container;
+ this.operation = operation;
+ }
+
+ public Object invokeTarget(Object payload) throws InvocationTargetException {
+ if (cacheable) {
+ if (target == null) {
+ target = (RhinoScript) container.getContext(name.getPartName()).getImplementationInstance();
+ }
+ return target.invoke(operation, payload);
+ } else {
+ return ((RhinoScript) container.getContext(name.getPartName()).getImplementationInstance())
+ .invoke(operation, payload);
+ }
+ }
+
+ private boolean cacheable;
+
+ public boolean isCacheable() {
+ return cacheable;
+ }
+
+ public void setCacheable(boolean val) {
+ cacheable = val;
+ }
+
+ 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 IllegalStateException("This interceptor must be the last interceptor in an interceptor chain");
+ }
+
+ public Object clone() {
+ try {
+ RhinoTargetInvoker invoker = (RhinoTargetInvoker) super.clone();
+ invoker.container = this.container;
+ invoker.cacheable = this.cacheable;
+ invoker.name = this.name;
+ invoker.operation = this.operation;
+ invoker.target = null;
+ return invoker;
+ } catch (CloneNotSupportedException e) {
+ return null; // will not happen
+ }
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/main/resources/model/sca-implementation-js.xsd b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/main/resources/model/sca-implementation-js.xsd
new file mode 100644
index 0000000000..c68161d7bd
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/main/resources/model/sca-implementation-js.xsd
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
+
+ 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.
+ -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:js="http://org.apache.tuscany/xmlns/js/0.9"
+ xmlns:sca="http://www.osoa.org/xmlns/sca/0.9"
+ elementFormDefault="qualified"
+ xmlns:sdojava="commonj.sdo/java"
+ sdojava:package="org.apache.tuscany.container.js.scdl"
+ targetNamespace="http://org.apache.tuscany/xmlns/js/0.9">
+
+ <import namespace="http://www.osoa.org/xmlns/sca/0.9" schemaLocation="../../../../../model/src/main/resources/model/sca-core.xsd"/>
+
+ <element name="implementation.js" substitutionGroup="sca:implementation" type="js:JavaScriptImplementation"/>
+
+ <complexType name="JavaScriptImplementation">
+ <complexContent>
+ <extension base="sca:Implementation">
+ <sequence>
+ <any maxOccurs="unbounded" minOccurs="0" namespace="##other" processContents="lax"/>
+ </sequence>
+ <attribute name="scriptFile" type="NCName" use="required"/>
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+</schema>
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/main/resources/org/apache/tuscany/container/js/handler/JavaScriptComponentConfigurationHandler.componentType b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/main/resources/org/apache/tuscany/container/js/handler/JavaScriptComponentConfigurationHandler.componentType
new file mode 100644
index 0000000000..c737a08a0b
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/main/resources/org/apache/tuscany/container/js/handler/JavaScriptComponentConfigurationHandler.componentType
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
+
+ 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.
+ -->
+<componentType xmlns="http://www.osoa.org/xmlns/sca/0.9">
+
+ <service name="handler">
+ <interface.js interface="org.apache.tuscany.core.message.handler.MessageHandler"/>
+ </service>
+
+</componentType>
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/main/resources/system.fragment b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/main/resources/system.fragment
new file mode 100644
index 0000000000..4c17a7ac1c
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/main/resources/system.fragment
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
+
+ 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.
+ -->
+<moduleFragment xmlns="http://www.osoa.org/xmlns/sca/0.9" xmlns:v="http://www.osoa.org/xmlns/sca/values/0.9"
+ xmlns:system="http://org.apache.tuscany/xmlns/system/0.9"
+ name="org.apache.tuscany.container.js">
+
+ <component name="org.apache.tuscany.container.js.builder.JavaScriptComponentContextBuilder">
+ <system:implementation.system class="org.apache.tuscany.container.js.builder.JavaScriptComponentContextBuilder"/>
+ </component>
+
+ <component name="org.apache.tuscany.container.js.loader.JavaScriptSCDLModelLoader">
+ <system:implementation.system class="org.apache.tuscany.container.js.loader.JavaScriptSCDLModelLoader"/>
+ </component>
+
+ <component name="org.apache.tuscany.container.js.builder.JavaScriptTargetWireBuilder">
+ <system:implementation.system class="org.apache.tuscany.container.js.builder.JavaScriptTargetWireBuilder"/>
+ </component>
+
+</moduleFragment>
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/samples/java/org/apache/tuscany/container/js/sample/helloworld/HelloWorld.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/samples/java/org/apache/tuscany/container/js/sample/helloworld/HelloWorld.java
new file mode 100644
index 0000000000..ed03753557
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/samples/java/org/apache/tuscany/container/js/sample/helloworld/HelloWorld.java
@@ -0,0 +1,7 @@
+package org.apache.tuscany.container.js.sample.helloworld;
+
+public interface HelloWorld {
+
+ public String getGreeting(String s);
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/samples/java/org/apache/tuscany/container/js/sample/helloworld/HelloWorldImpl.componentType b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/samples/java/org/apache/tuscany/container/js/sample/helloworld/HelloWorldImpl.componentType
new file mode 100644
index 0000000000..cce77fab00
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/samples/java/org/apache/tuscany/container/js/sample/helloworld/HelloWorldImpl.componentType
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="ASCII"?>
+
+<componentType xmlns="http://www.osoa.org/xmlns/sca/0.9" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <service name="HelloWorldService">
+ <interface.java interface="org.apache.tuscany.container.js.sample.helloworld.HelloWorld"/>
+ </service>
+
+</componentType> \ No newline at end of file
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/samples/java/org/apache/tuscany/container/js/sample/helloworld/HelloWorldImpl.js b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/samples/java/org/apache/tuscany/container/js/sample/helloworld/HelloWorldImpl.js
new file mode 100644
index 0000000000..cb63914377
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/samples/java/org/apache/tuscany/container/js/sample/helloworld/HelloWorldImpl.js
@@ -0,0 +1,4 @@
+
+function getGreeting(s) {
+ return "jsHello " + s;
+} \ No newline at end of file
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/samples/java/org/apache/tuscany/container/js/sample/helloworld/Main.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/samples/java/org/apache/tuscany/container/js/sample/helloworld/Main.java
new file mode 100644
index 0000000000..2e63a5a21e
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/samples/java/org/apache/tuscany/container/js/sample/helloworld/Main.java
@@ -0,0 +1,25 @@
+package org.apache.tuscany.container.js.sample.helloworld;
+
+import org.apache.tuscany.core.client.TuscanyRuntime;
+import org.osoa.sca.CurrentModuleContext;
+import org.osoa.sca.ModuleContext;
+
+public class Main {
+
+ public static final void main(String[] args) throws Exception {
+
+ TuscanyRuntime tuscany = new TuscanyRuntime("jsHello", null);
+ tuscany.start();
+ ModuleContext moduleContext = CurrentModuleContext.getContext();
+
+ HelloWorld s =
+ (HelloWorld) moduleContext.locateService("HelloWorldJSComponent");
+
+ String value = s.getGreeting("Petra");
+
+ System.out.println(value);
+
+ tuscany.stop();
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/samples/java/sca.module b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/samples/java/sca.module
new file mode 100644
index 0000000000..25c35fa6d0
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/samples/java/sca.module
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2005 BEA Sytems Inc.
+ Copyright (c) 2005 International Business Machines
+
+ 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.
+ -->
+<module xmlns="http://www.osoa.org/xmlns/sca/0.9" xmlns:v="http://www.osoa.org/xmlns/sca/values/0.9"
+ name="sampleHelloworld">
+
+ <component name="HelloWorldJSComponent">
+ <implementation.js scriptFile="org/apache/tuscany/container/js/sample/helloworld/HelloWorldImpl.js"/>
+ </component>
+
+</module>
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/impl/JavaScriptImplementationTestCase.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/impl/JavaScriptImplementationTestCase.java
new file mode 100644
index 0000000000..c751b0a2ef
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/impl/JavaScriptImplementationTestCase.java
@@ -0,0 +1,75 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.js.assembly.impl;
+
+import junit.framework.TestCase;
+
+/**
+ * FIXME commented out until SCDL loading works
+ *
+ * @version $Rev: 368822 $ $Date: 2006-01-13 18:54:38 +0000 (Fri, 13 Jan 2006) $
+ */
+public class JavaScriptImplementationTestCase extends TestCase {
+
+ private JavaScriptImplementationImpl impl = (JavaScriptImplementationImpl) new JavaScriptAssemblyFactoryImpl()
+ .createJavaScriptImplementation();
+
+ public void testDummy(){} // remove when tests added back
+
+// public void testNoImplementationClass() {
+// impl.setScriptFile("no.such.script.js");
+// try {
+// impl.initialize(new AssemblyModelContextImpl(null, null));
+// impl.getComponentType();
+// fail("Expected IllegalArgumentException");
+// } catch (IllegalArgumentException e) {
+// // ok
+// }
+// }
+
+// public void testHelloWorldWithSidefile() {
+// impl.setScriptFile("org/apache/tuscany/container/js/assembly/mock/HelloWorldImpl.js");
+// impl.initialize(new AssemblyModelContextImpl(new AssemblyLoaderImpl(), ResourceLoaderFactory.getResourceLoader(Thread
+// .currentThread().getContextClassLoader())));
+// ComponentType type = impl.getComponentType();
+// Assert.assertNotNull(type);
+// List<Property> props = type.getProperties();
+// Assert.assertEquals(1, props.size());
+// Assert.assertTrue(props.get(0).getName().equals("text"));
+//
+// Assert.assertTrue(type.getReferences().isEmpty());
+//
+// List<Service> services = type.getServices();
+// Assert.assertEquals(1, services.size());
+// Assert.assertTrue(services.get(0).getName().equals("HelloWorldService"));
+// }
+
+ // static {
+ // // bootstrap this somehow
+ // AssemblyPackage.eINSTANCE.getClass();
+ // }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ Thread.currentThread().setContextClassLoader(JavaScriptImplementationTestCase.class.getClassLoader());
+ }
+
+ protected void tearDown() throws Exception {
+ Thread.currentThread().setContextClassLoader(null);
+ super.tearDown();
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/mock/HelloWorldService.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/mock/HelloWorldService.java
new file mode 100644
index 0000000000..8edb27a473
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/mock/HelloWorldService.java
@@ -0,0 +1,24 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.js.assembly.mock;
+
+/**
+ * @version $Rev: 368822 $ $Date: 2006-01-13 18:54:38 +0000 (Fri, 13 Jan 2006) $
+ */
+public interface HelloWorldService {
+ String hello(String name);
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/JavaScriptAssemblyLoaderTestCase.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/JavaScriptAssemblyLoaderTestCase.java
new file mode 100644
index 0000000000..91ce8a73eb
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/JavaScriptAssemblyLoaderTestCase.java
@@ -0,0 +1,76 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.js.assembly.tests;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.model.assembly.AssemblyFactory;
+import org.apache.tuscany.model.assembly.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.impl.AssemblyFactoryImpl;
+import org.apache.tuscany.model.assembly.impl.AssemblyModelContextImpl;
+
+/**
+ */
+public class JavaScriptAssemblyLoaderTestCase extends TestCase {
+
+ private AssemblyModelContext modelContext;
+
+ /**
+ *
+ */
+ public JavaScriptAssemblyLoaderTestCase() {
+ super();
+ }
+
+ public void testLoader() {
+/*
+
+ AssemblyLoader loader = modelContext.getAssemblyLoader();
+ Module module = loader.getModule(getClass().getResource("sca.module").toString());
+ module.initialize(modelContext);
+
+ Assert.assertTrue(module.getName().equals("tuscany.container.js.assembly.tests.bigbank.account"));
+
+ Component component = module.getComponent("AccountServiceComponent");
+ Assert.assertTrue(component != null);
+
+ EntryPoint entryPoint = module.getEntryPoint("AccountService");
+ Assert.assertTrue(entryPoint != null);
+
+ Object value = component.getConfiguredProperty("currency").getValue();
+ Assert.assertTrue(value.equals("EURO"));
+
+ ConfiguredService configuredService = component.getConfiguredReference("accountDataService").getConfiguredServices().get(0);
+ Assert.assertTrue(configuredService.getPart().getName().equals("AccountDataServiceComponent"));
+
+ InterfaceType interfaceType = configuredService.getService().getInterfaceContract().getInterfaceType();
+ OperationType operationType = interfaceType.getOperationType("getCheckingAccount");
+ Type type = operationType.getInputType();
+ Property arg = (Property) type.getProperties().get(0);
+ Assert.assertTrue(arg.getType().getInstanceClass() == String.class);
+*/
+
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
+ modelContext = new AssemblyModelContextImpl(null,null);
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/account/AccountReport.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/account/AccountReport.java
new file mode 100644
index 0000000000..90c47d400c
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/account/AccountReport.java
@@ -0,0 +1,32 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.js.assembly.tests.bigbank.account.services.account;
+
+import java.util.List;
+
+/**
+ * @model
+ */
+
+public interface AccountReport {
+
+ /**
+ * @model type="services.account.AccountSummary"
+ */
+
+ List getAccountSummaries();
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/account/AccountService.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/account/AccountService.java
new file mode 100644
index 0000000000..ff555e178f
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/account/AccountService.java
@@ -0,0 +1,25 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.js.assembly.tests.bigbank.account.services.account;
+
+import org.osoa.sca.annotations.Remotable;
+
+@Remotable
+public interface AccountService {
+
+ public AccountReport getAccountReport(String customerID);
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/account/AccountSummary.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/account/AccountSummary.java
new file mode 100644
index 0000000000..ad3b4ad737
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/account/AccountSummary.java
@@ -0,0 +1,46 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.js.assembly.tests.bigbank.account.services.account;
+
+/**
+ * @model
+ */
+
+public interface AccountSummary {
+
+ /**
+ * @model
+ */
+ String getAccountNumber();
+
+ void setAccountNumber(String accountNumber);
+
+ /**
+ * @model
+ */
+ String getAccountType();
+
+ void setAccountType(String accountType);
+
+ /**
+ * @model
+ */
+ float getBalance();
+
+ void setBalance(float balance);
+}
+
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/accountdata/AccountDataService.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/accountdata/AccountDataService.java
new file mode 100644
index 0000000000..42d8994392
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/accountdata/AccountDataService.java
@@ -0,0 +1,26 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.js.assembly.tests.bigbank.account.services.accountdata;
+
+public interface AccountDataService {
+
+ CheckingAccount getCheckingAccount(String customerID);
+
+ SavingsAccount getSavingsAccount(String customerID);
+
+ StockAccount getStockAccount(String customerID);
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/accountdata/AccountDataServiceImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/accountdata/AccountDataServiceImpl.java
new file mode 100644
index 0000000000..24b91020f7
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/accountdata/AccountDataServiceImpl.java
@@ -0,0 +1,48 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.js.assembly.tests.bigbank.account.services.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/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/accountdata/CheckingAccount.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/accountdata/CheckingAccount.java
new file mode 100644
index 0000000000..43b755e0fb
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/accountdata/CheckingAccount.java
@@ -0,0 +1,39 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.js.assembly.tests.bigbank.account.services.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/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/accountdata/SavingsAccount.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/accountdata/SavingsAccount.java
new file mode 100644
index 0000000000..3f8cb65ad7
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/accountdata/SavingsAccount.java
@@ -0,0 +1,39 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.js.assembly.tests.bigbank.account.services.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/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/accountdata/StockAccount.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/accountdata/StockAccount.java
new file mode 100644
index 0000000000..ae6cdd6ff6
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/accountdata/StockAccount.java
@@ -0,0 +1,48 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.js.assembly.tests.bigbank.account.services.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/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/stockquote/StockQuoteService.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/stockquote/StockQuoteService.java
new file mode 100644
index 0000000000..8720bcdaf6
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/stockquote/StockQuoteService.java
@@ -0,0 +1,24 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.js.assembly.tests.bigbank.account.services.stockquote;
+
+public interface StockQuoteService {
+
+ public float getQuote(String symbol);
+}
+
+ \ No newline at end of file
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/stockquote/StockQuoteServiceImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/stockquote/StockQuoteServiceImpl.java
new file mode 100644
index 0000000000..9765b67c2f
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/stockquote/StockQuoteServiceImpl.java
@@ -0,0 +1,28 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.js.assembly.tests.bigbank.account.services.stockquote;
+
+/* Dummy'd up StockQuoteService, override webservice for now */
+
+public class StockQuoteServiceImpl implements StockQuoteService {
+
+ public float getQuote(String symbol) {
+ // Just hardcode for now
+ return 83.00f;
+ }
+
+} \ No newline at end of file
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/stockquote/StockQuoteWebService.wsdl b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/stockquote/StockQuoteWebService.wsdl
new file mode 100644
index 0000000000..01df4ef054
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/stockquote/StockQuoteWebService.wsdl
@@ -0,0 +1,98 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
+
+ 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.
+ -->
+<wsdl:definitions targetNamespace="http://webservice.stockquote" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://webservice.stockquote" xmlns:intf="http://webservice.stockquote" xmlns:tns1="http://stockquote" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="">
+ <!--WSDL created by Apache Axis version: 1.2.1
+Built on Jun 14, 2005 (09:15:57 EDT)-->
+ <wsdl:types>
+ <schema elementFormDefault="qualified" targetNamespace="http://stockquote" xmlns="http://www.w3.org/2001/XMLSchema">
+ <complexType name="GetQuoteRequest">
+ <sequence>
+ <element name="symbol" nillable="true" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ <complexType name="GetQuoteResponse">
+ <sequence>
+ <element name="price" type="xsd:float"/>
+ </sequence>
+ </complexType>
+ </schema>
+ <schema elementFormDefault="qualified" targetNamespace="http://webservice.stockquote" xmlns="http://www.w3.org/2001/XMLSchema">
+ <import namespace="http://stockquote"/>
+ <element name="request" type="tns1:GetQuoteRequest"/>
+ <element name="getQuoteReturn" type="tns1:GetQuoteResponse"/>
+ </schema>
+ </wsdl:types>
+
+ <wsdl:message name="getQuoteResponse">
+
+ <wsdl:part element="impl:getQuoteReturn" name="getQuoteReturn"/>
+
+ </wsdl:message>
+
+ <wsdl:message name="getQuoteRequest">
+
+ <wsdl:part element="impl:request" name="request"/>
+
+ </wsdl:message>
+
+ <wsdl:portType name="StockQuoteWebService">
+
+ <wsdl:operation name="getQuote" parameterOrder="request">
+
+ <wsdl:input message="impl:getQuoteRequest" name="getQuoteRequest"/>
+
+ <wsdl:output message="impl:getQuoteResponse" name="getQuoteResponse"/>
+
+ </wsdl:operation>
+
+ </wsdl:portType>
+
+ <wsdl:binding name="StockQuoteWebServiceSoapBinding" type="impl:StockQuoteWebService">
+
+ <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+
+ <wsdl:operation name="getQuote">
+
+ <wsdlsoap:operation soapAction=""/>
+
+ <wsdl:input name="getQuoteRequest">
+
+ <wsdlsoap:body use="literal"/>
+
+ </wsdl:input>
+
+ <wsdl:output name="getQuoteResponse">
+
+ <wsdlsoap:body use="literal"/>
+
+ </wsdl:output>
+
+ </wsdl:operation>
+
+ </wsdl:binding>
+
+ <wsdl:service name="StockQuoteWebServiceService">
+
+ <wsdl:port binding="impl:StockQuoteWebServiceSoapBinding" name="StockQuoteWebService">
+
+ <wsdlsoap:address location="http://localhost:8123/StockQuoteWebService/services/StockQuoteWebService"/>
+
+ </wsdl:port>
+
+ </wsdl:service>
+
+</wsdl:definitions>
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/builder/JSComponentContextBuilderTestCase.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/builder/JSComponentContextBuilderTestCase.java
new file mode 100644
index 0000000000..d21c17636a
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/builder/JSComponentContextBuilderTestCase.java
@@ -0,0 +1,51 @@
+package org.apache.tuscany.container.js.builder;
+
+import java.util.Collection;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.common.resource.impl.ResourceLoaderImpl;
+import org.apache.tuscany.container.js.assembly.mock.HelloWorldService;
+import org.apache.tuscany.container.js.config.JavaScriptComponentRuntimeConfiguration;
+import org.apache.tuscany.container.js.mock.MockAssemblyFactory;
+import org.apache.tuscany.core.builder.RuntimeConfiguration;
+import org.apache.tuscany.core.context.EventContext;
+import org.apache.tuscany.core.context.InstanceContext;
+import org.apache.tuscany.core.context.QualifiedName;
+import org.apache.tuscany.core.context.impl.EventContextImpl;
+import org.apache.tuscany.core.context.scope.ModuleScopeContext;
+import org.apache.tuscany.core.invocation.jdk.JDKProxyFactoryFactory;
+import org.apache.tuscany.core.invocation.spi.ProxyFactory;
+import org.apache.tuscany.model.assembly.Scope;
+import org.apache.tuscany.model.assembly.SimpleComponent;
+import org.apache.tuscany.model.assembly.impl.AssemblyFactoryImpl;
+import org.apache.tuscany.model.assembly.impl.AssemblyModelContextImpl;
+import org.apache.tuscany.model.scdl.loader.impl.SCDLAssemblyModelLoaderImpl;
+
+public class JSComponentContextBuilderTestCase extends TestCase {
+
+ public void testBasicInvocation() throws Exception {
+ JavaScriptComponentContextBuilder jsBuilder = new JavaScriptComponentContextBuilder();
+ jsBuilder.setProxyFactoryFactory(new JDKProxyFactoryFactory());
+ JavaScriptTargetWireBuilder jsWireBuilder = new JavaScriptTargetWireBuilder();
+ SimpleComponent component = MockAssemblyFactory.createComponent("foo",
+ "org/apache/tuscany/container/js/assembly/mock/HelloWorldImpl.js", HelloWorldService.class, Scope.MODULE);
+ component.initialize(new AssemblyModelContextImpl(new AssemblyFactoryImpl(), new SCDLAssemblyModelLoaderImpl(null), new ResourceLoaderImpl(Thread.currentThread().getContextClassLoader())));
+ jsBuilder.build(component, null);
+ ModuleScopeContext context = new ModuleScopeContext(new EventContextImpl());
+ RuntimeConfiguration<InstanceContext> config = (RuntimeConfiguration) component.getComponentImplementation()
+ .getRuntimeConfiguration();
+ context.registerConfiguration(config);
+ context.start();
+ context.onEvent(EventContext.MODULE_START, null);
+ for (ProxyFactory proxyFactory : (Collection<ProxyFactory>) config.getTargetProxyFactories().values()) {
+ jsWireBuilder.completeTargetChain(proxyFactory, JavaScriptComponentRuntimeConfiguration.class, context);
+ proxyFactory.initialize();
+ }
+ InstanceContext ctx = config.createInstanceContext();
+ HelloWorldService hello = (HelloWorldService) ctx.getInstance(new QualifiedName("foo/HelloWorldService"));
+ Assert.assertNotNull(hello);
+ Assert.assertEquals("Hello foo", hello.hello("foo"));
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/builder/MockHandlerBuilder.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/builder/MockHandlerBuilder.java
new file mode 100644
index 0000000000..5f5e8d769a
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/builder/MockHandlerBuilder.java
@@ -0,0 +1,86 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.js.builder;
+
+import org.apache.tuscany.core.builder.BuilderException;
+import org.apache.tuscany.core.builder.RuntimeConfigurationBuilder;
+import org.apache.tuscany.core.context.Context;
+import org.apache.tuscany.core.invocation.InvocationConfiguration;
+import org.apache.tuscany.core.invocation.MessageHandler;
+import org.apache.tuscany.core.invocation.spi.ProxyFactory;
+import org.apache.tuscany.model.assembly.AssemblyModelObject;
+import org.apache.tuscany.model.assembly.ConfiguredReference;
+import org.apache.tuscany.model.assembly.ConfiguredService;
+
+/**
+ * Adds a handler to a source or target proxy configuration
+ *
+ * @version $Rev$ $Date$
+ */
+public class MockHandlerBuilder implements RuntimeConfigurationBuilder {
+
+ private MessageHandler handler;
+
+ private boolean source;
+
+ private boolean request;
+
+ /**
+ * Creates the builder.
+ *
+ * @param handler the handler to add to the source or target proxy configuration
+ * @param source true if the handler should be added on the source side; false if the handler should be added to the
+ * target side
+ * @param request true if the handler is a request handler; false if the handler is a response handler
+ */
+ public MockHandlerBuilder(MessageHandler handler, boolean source, boolean request) {
+ this.handler = handler;
+ this.source = source;
+ this.request = request;
+ }
+
+ public void build(AssemblyModelObject modelObject, Context context) throws BuilderException {
+ if (source) {
+ if (!(modelObject instanceof ConfiguredReference)) {
+ return;
+ } else {
+ ConfiguredReference cref = (ConfiguredReference) modelObject;
+ ProxyFactory pFactory = (ProxyFactory) cref.getProxyFactory();
+ for (InvocationConfiguration config : pFactory.getProxyConfiguration().getInvocationConfigurations().values()) {
+ if (request) {
+ config.addRequestHandler(handler);
+ } else {
+ config.addResponseHandler(handler);
+ }
+ }
+ }
+ } else {
+ if (!(modelObject instanceof ConfiguredService)) {
+ return;
+ } else {
+ ConfiguredService cservice = (ConfiguredService) modelObject;
+ ProxyFactory pFactory = (ProxyFactory) cservice.getProxyFactory();
+ for (InvocationConfiguration config : pFactory.getProxyConfiguration().getInvocationConfigurations().values()) {
+ if (request) {
+ config.addRequestHandler(handler);
+ } else {
+ config.addResponseHandler(handler);
+ }
+ }
+ }
+
+ }
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/builder/MockInterceptorBuilder.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/builder/MockInterceptorBuilder.java
new file mode 100644
index 0000000000..0ed27101dd
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/builder/MockInterceptorBuilder.java
@@ -0,0 +1,74 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.js.builder;
+
+import org.apache.tuscany.core.builder.BuilderException;
+import org.apache.tuscany.core.builder.RuntimeConfigurationBuilder;
+import org.apache.tuscany.core.context.Context;
+import org.apache.tuscany.core.invocation.Interceptor;
+import org.apache.tuscany.core.invocation.InvocationConfiguration;
+import org.apache.tuscany.core.invocation.spi.ProxyFactory;
+import org.apache.tuscany.model.assembly.AssemblyModelObject;
+import org.apache.tuscany.model.assembly.ConfiguredReference;
+import org.apache.tuscany.model.assembly.ConfiguredService;
+
+/**
+ * Adds an interceptor to a source or target proxy configuration
+ *
+ * @version $Rev$ $Date$
+ */
+public class MockInterceptorBuilder implements RuntimeConfigurationBuilder {
+
+ private Interceptor interceptor;
+
+ private boolean source;
+
+ /**
+ * Creates the builder
+ *
+ * @param interceptor the interceptor ot add
+ * @param source true if the interceptor should be added to the source side; false if the interceptor should be
+ * added to the target side
+ */
+ public MockInterceptorBuilder(Interceptor interceptor, boolean source) {
+ this.interceptor = interceptor;
+ this.source = source;
+ }
+
+ public void build(AssemblyModelObject modelObject, Context context) throws BuilderException {
+ if (source) {
+ if (!(modelObject instanceof ConfiguredReference)) {
+ return;
+ } else {
+ ConfiguredReference cref = (ConfiguredReference) modelObject;
+ ProxyFactory pFactory = (ProxyFactory) cref.getProxyFactory();
+ for (InvocationConfiguration config : pFactory.getProxyConfiguration().getInvocationConfigurations().values()) {
+ config.addSourceInterceptor(interceptor);
+ }
+ }
+ } else {
+ if (!(modelObject instanceof ConfiguredService)) {
+ return;
+ } else {
+ ConfiguredService cservice = (ConfiguredService) modelObject;
+ ProxyFactory pFactory = (ProxyFactory) cservice.getProxyFactory();
+ for (InvocationConfiguration config : pFactory.getProxyConfiguration().getInvocationConfigurations().values()) {
+ config.addTargetInterceptor(interceptor);
+ }
+ }
+
+ }
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/config/ModuleComponentConfigurationLoaderTestCase.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/config/ModuleComponentConfigurationLoaderTestCase.java
new file mode 100644
index 0000000000..4f9ba1ab49
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/config/ModuleComponentConfigurationLoaderTestCase.java
@@ -0,0 +1,78 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.js.config;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.common.resource.impl.ResourceLoaderImpl;
+import org.apache.tuscany.container.js.assembly.impl.JavaScriptImplementationImpl;
+import org.apache.tuscany.container.js.loader.JavaScriptSCDLModelLoader;
+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.model.assembly.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.Component;
+import org.apache.tuscany.model.assembly.ComponentImplementation;
+import org.apache.tuscany.model.assembly.Module;
+import org.apache.tuscany.model.assembly.ModuleComponent;
+import org.apache.tuscany.model.assembly.impl.AssemblyFactoryImpl;
+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;
+
+/**
+ * @version $Rev: 368822 $ $Date: 2006-01-13 18:54:38 +0000 (Fri, 13 Jan 2006) $
+ */
+public class ModuleComponentConfigurationLoaderTestCase extends TestCase {
+ private ModuleComponentConfigurationLoader loader;
+
+ public void testFoo() throws ConfigurationException {
+ URL xml = ModuleComponentConfigurationLoaderTestCase.class.getResource("ModuleComponentLoaderTest1.module");
+ ModuleComponent moduleComponent = loader.loadModuleComponent("test", "test", xml.toString());
+ Assert.assertEquals("test", moduleComponent.getName());
+ Module module = moduleComponent.getModuleImplementation();
+ Assert.assertEquals("ModuleComponentLoaderTest1", module.getName());
+ List<Component> components = module.getComponents();
+ Assert.assertEquals(1, components.size());
+ Component component = components.get(0);
+ Assert.assertEquals("HelloWorldServiceComponent", component.getName());
+
+ component = module.getComponent("HelloWorldServiceComponent");
+ Assert.assertEquals("HelloWorldServiceComponent", component.getName());
+
+ ComponentImplementation implementation = component.getComponentImplementation();
+ Assert.assertTrue(implementation instanceof JavaScriptImplementationImpl);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
+ List<SCDLModelLoader> scdlLoaders=new ArrayList<SCDLModelLoader>();
+ JavaScriptSCDLModelLoader jsLoader=new JavaScriptSCDLModelLoader();
+ scdlLoaders.add(jsLoader);
+ AssemblyModelLoader modelLoader=new SCDLAssemblyModelLoaderImpl(scdlLoaders);
+ AssemblyModelContext modelContext=new AssemblyModelContextImpl(
+ new AssemblyFactoryImpl(), modelLoader,new ResourceLoaderImpl(this.getClass().getClassLoader()));
+ loader = new ModuleComponentConfigurationLoaderImpl(modelContext);
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/integration/JSComponentContextTestCase.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/integration/JSComponentContextTestCase.java
new file mode 100644
index 0000000000..cd29f59327
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/integration/JSComponentContextTestCase.java
@@ -0,0 +1,91 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.js.integration;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.container.js.assembly.mock.HelloWorldService;
+import org.apache.tuscany.container.js.builder.JavaScriptComponentContextBuilder;
+import org.apache.tuscany.container.js.builder.JavaScriptTargetWireBuilder;
+import org.apache.tuscany.container.js.builder.MockInterceptorBuilder;
+import org.apache.tuscany.container.js.invocation.mock.MockSyncInterceptor;
+import org.apache.tuscany.container.js.mock.MockAssemblyFactory;
+import org.apache.tuscany.container.js.mock.MockModuleFactory;
+import org.apache.tuscany.core.builder.RuntimeConfigurationBuilder;
+import org.apache.tuscany.core.builder.impl.DefaultWireBuilder;
+import org.apache.tuscany.core.builder.impl.HierarchicalBuilder;
+import org.apache.tuscany.core.context.AggregateContext;
+import org.apache.tuscany.core.context.EventContext;
+import org.apache.tuscany.core.context.impl.AggregateContextImpl;
+import org.apache.tuscany.core.invocation.jdk.JDKProxyFactoryFactory;
+import org.apache.tuscany.core.message.MessageFactory;
+import org.apache.tuscany.core.message.impl.MessageFactoryImpl;
+import org.apache.tuscany.core.runtime.RuntimeContext;
+import org.apache.tuscany.core.runtime.RuntimeContextImpl;
+import org.apache.tuscany.core.system.builder.SystemComponentContextBuilder;
+import org.apache.tuscany.core.system.builder.SystemEntryPointBuilder;
+import org.apache.tuscany.core.system.builder.SystemExternalServiceBuilder;
+import org.apache.tuscany.model.assembly.Scope;
+
+/**
+ * Integration tests for JavaScript components and aggregate contexts
+ *
+ * @version $Rev$ $Date$
+ */
+public class JSComponentContextTestCase extends TestCase {
+
+ public void testBasicInvocation() throws Exception {
+ MessageFactory msgFactory = new MessageFactoryImpl();
+
+ List<RuntimeConfigurationBuilder> builders = new ArrayList();
+ builders.add((new SystemComponentContextBuilder()));
+ builders.add(new SystemEntryPointBuilder());
+ builders.add(new SystemExternalServiceBuilder());
+
+ JavaScriptComponentContextBuilder javaBuilder = new JavaScriptComponentContextBuilder();
+ javaBuilder.setMessageFactory(msgFactory);
+ javaBuilder.setProxyFactoryFactory(new JDKProxyFactoryFactory());
+
+ MockSyncInterceptor mockInterceptor = new MockSyncInterceptor();
+ MockInterceptorBuilder interceptorBuilder = new MockInterceptorBuilder(mockInterceptor, true);
+ HierarchicalBuilder refBuilder = new HierarchicalBuilder();
+ refBuilder.addBuilder(interceptorBuilder);
+ javaBuilder.setReferenceBuilder(refBuilder);
+ builders.add(javaBuilder);
+
+ DefaultWireBuilder defaultWireBuilder = new DefaultWireBuilder();
+
+ RuntimeContext runtime = new RuntimeContextImpl(null, null, builders, defaultWireBuilder);
+ runtime.addBuilder(new JavaScriptTargetWireBuilder());
+ runtime.start();
+ runtime.getRootContext().registerModelObject(
+ MockAssemblyFactory.createSystemComponent("test.module", AggregateContextImpl.class.getName(),
+ Scope.AGGREGATE));
+ AggregateContext child = (AggregateContext) runtime.getRootContext().getContext("test.module");
+ child.registerModelObject(MockModuleFactory.createModule());
+ child.fireEvent(EventContext.MODULE_START, null);
+ HelloWorldService source = (HelloWorldService) child.locateInstance("source/HelloWorldService");
+ Assert.assertNotNull(source);
+ Assert.assertEquals("Hello foo",source.hello("foo"));
+ //Assert.assertEquals(1, mockInterceptor.getCount());
+ child.fireEvent(EventContext.MODULE_STOP, null);
+ runtime.stop();
+ }
+
+}
+
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/invocation/mock/MockHandler.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/invocation/mock/MockHandler.java
new file mode 100644
index 0000000000..7064ec5d65
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/invocation/mock/MockHandler.java
@@ -0,0 +1,27 @@
+/**
+ *
+ */
+package org.apache.tuscany.container.js.invocation.mock;
+
+import org.apache.tuscany.core.invocation.MessageHandler;
+import org.apache.tuscany.core.message.Message;
+
+/**
+ * A test handler
+ *
+ * @version $Rev$ $Date$
+ */
+public class MockHandler implements MessageHandler {
+
+ private int count =0;
+
+ public boolean processMessage(Message message) {
+ //System.out.println("Invoking handler");
+ count++;
+ return true;
+ }
+
+ public int getCount(){
+ return count;
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/invocation/mock/MockSyncInterceptor.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/invocation/mock/MockSyncInterceptor.java
new file mode 100644
index 0000000000..caab4b3756
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/invocation/mock/MockSyncInterceptor.java
@@ -0,0 +1,50 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.js.invocation.mock;
+
+import org.apache.tuscany.core.invocation.Interceptor;
+import org.apache.tuscany.core.message.Message;
+
+/**
+ * A test interceptor
+ *
+ * @version $Rev$ $Date$
+ */
+public class MockSyncInterceptor implements Interceptor {
+
+ private int count;
+
+ private Interceptor next;
+
+ public MockSyncInterceptor() {
+ }
+
+ public Message invoke(Message msg) {
+ ++count;
+ //System.out.println("Invoking interceptor");
+ return next.invoke(msg);
+ }
+
+ public int getCount() {
+ return count;
+ }
+
+ public void setNext(Interceptor next) {
+ this.next=next;
+ }
+}
+
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/mock/MockAssemblyFactory.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/mock/MockAssemblyFactory.java
new file mode 100644
index 0000000000..5cb80b29aa
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/mock/MockAssemblyFactory.java
@@ -0,0 +1,156 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.js.mock;
+
+import org.apache.tuscany.container.js.assembly.JavaScriptAssemblyFactory;
+import org.apache.tuscany.container.js.assembly.JavaScriptImplementation;
+import org.apache.tuscany.container.js.assembly.impl.JavaScriptAssemblyFactoryImpl;
+import org.apache.tuscany.core.config.JavaIntrospectionHelper;
+import org.apache.tuscany.core.context.AggregateContext;
+import org.apache.tuscany.core.system.assembly.SystemAssemblyFactory;
+import org.apache.tuscany.core.system.assembly.SystemImplementation;
+import org.apache.tuscany.core.system.assembly.impl.SystemAssemblyFactoryImpl;
+import org.apache.tuscany.model.assembly.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.Component;
+import org.apache.tuscany.model.assembly.ConfiguredService;
+import org.apache.tuscany.model.assembly.Scope;
+import org.apache.tuscany.model.assembly.Service;
+import org.apache.tuscany.model.assembly.SimpleComponent;
+import org.apache.tuscany.model.assembly.impl.AssemblyModelContextImpl;
+import org.apache.tuscany.model.types.java.JavaServiceContract;
+
+/**
+ * Generates test components and module assemblies
+ *
+ * @version $Rev: 377775 $ $Date: 2006-02-14 09:18:31 -0800 (Tue, 14 Feb 2006) $
+ */
+public class MockAssemblyFactory {
+
+ private static JavaScriptAssemblyFactory factory = new JavaScriptAssemblyFactoryImpl();
+
+ private static SystemAssemblyFactory systemFactory = new SystemAssemblyFactoryImpl();
+
+ public static SimpleComponent createComponent(String name, String scriptFile, Class type, Scope scope) {
+ SimpleComponent sc = factory.createSimpleComponent();
+ JavaScriptImplementation impl = factory.createJavaScriptImplementation();
+ impl.setComponentType(factory.createComponentType());
+ impl.setScriptFile(scriptFile);
+ sc.setComponentImplementation(impl);
+ Service s = factory.createService();
+ String serviceName = type.getName().substring(type.getName().lastIndexOf('.')+1);
+ s.setName(serviceName);
+ JavaServiceContract contract = factory.createJavaServiceContract();
+ s.setServiceContract(contract);
+ contract.setScope(scope);
+ contract.setInterface(type);
+ impl.getComponentType().getServices().add(s);
+ ConfiguredService cService = factory.createConfiguredService();
+ cService.setService(s);
+ cService.initialize(new AssemblyModelContextImpl(null,null));
+ sc.getConfiguredServices().add(cService);
+ sc.setName(name);
+ sc.setComponentImplementation(impl);
+ return sc;
+ }
+
+ public static Component createSystemComponent(String name, String type, Scope scope) throws NoSuchMethodException,
+ ClassNotFoundException {
+ Class claz = JavaIntrospectionHelper.loadClass(type);
+ Component sc = null;
+ if (AggregateContext.class.isAssignableFrom(claz)) {
+ sc = systemFactory.createModuleComponent();
+ } else {
+ sc = systemFactory.createSimpleComponent();
+ }
+ SystemImplementation impl = systemFactory.createSystemImplementation();
+ impl.setImplementationClass(claz);
+ sc.setComponentImplementation(impl);
+ Service s = systemFactory.createService();
+ JavaServiceContract ji = systemFactory.createJavaServiceContract();
+ s.setServiceContract(ji);
+ ji.setScope(scope);
+ impl.setComponentType(systemFactory.createComponentType());
+ impl.getComponentType().getServices().add(s);
+ sc.setName(name);
+ sc.setComponentImplementation(impl);
+ return sc;
+ }
+
+ // public static SimpleComponent createComponent(String name, String scriptFile, String serviceName, ScopeEnum
+ // scope)
+ // throws NoSuchMethodException, ClassNotFoundException {
+ // SimpleComponent sc = new PojoSimpleComponent();
+ // PojoJavaScriptImplementation impl = new PojoJavaScriptImplementation();
+ // impl.setScriptFile(scriptFile);
+ // impl.initialize(new AssemblyModelContextImpl());
+ //
+ // sc.setComponentImplementation(impl);
+ // Service s = new PojoService();
+ // s.setName(serviceName.substring(serviceName.lastIndexOf('.') + 1));
+ // PojoJavaInterface ji = new PojoJavaInterface();
+ // ji.setInterface(serviceName);
+ // Class claz = JavaIntrospectionHelper.loadClass(serviceName);
+ // PojoInterfaceType iType = new PojoInterfaceType();
+ // iType.setInstanceClass(claz);
+ // for (Method m : claz.getMethods()) {
+ // // assume no method overloading
+ // PojoOperationType type = new PojoOperationType();
+ // type.setName(m.getName());
+ // for (Class inputType : m.getParameterTypes()) {
+ // type.setOutputType(new SDOType(null,null,inputType,Collections.EMPTY_LIST));
+ // }
+ // iType.addOperationType(type);
+ // }
+ // ji.setInterfaceType(iType);
+ //
+ //
+ // s.setInterfaceContract(ji);
+ // ji.setScope(scope);
+ // impl.getServices().add(s);
+ // sc.setName(name);
+ // sc.setComponentImplementation(impl);
+ // PojoConfiguredService cService = new PojoConfiguredService();
+ // cService.setService(s);
+ // sc.getConfiguredServices().add(cService);
+ // return sc;
+ // }
+ //
+ // public static Component createSystemComponent(String name, String type, ScopeEnum scope) throws
+ // NoSuchMethodException,
+ // ClassNotFoundException {
+ //
+ // Class claz = JavaIntrospectionHelper.loadClass(type);
+ // PojoComponent sc = null;
+ // if (AggregateContext.class.isAssignableFrom(claz)) {
+ // sc = new PojoAggregateComponent();
+ // } else {
+ // sc = new PojoSimpleComponent();
+ // }
+ // SystemImplementation impl = new PojoSystemImplementation();
+ // impl.setClass(type);
+ // sc.setComponentImplementation(impl);
+ // Service s = new PojoService();
+ // JavaInterface ji = new PojoJavaInterface();
+ // s.setInterfaceContract(ji);
+ // ji.setScope(scope);
+ // impl.getServices().add(s);
+ // sc.setName(name);
+ // sc.setComponentImplementation(impl);
+ // return sc;
+ // }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/mock/MockModuleFactory.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/mock/MockModuleFactory.java
new file mode 100644
index 0000000000..fe66104000
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/mock/MockModuleFactory.java
@@ -0,0 +1,115 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.container.js.mock;
+
+import org.apache.tuscany.common.resource.impl.ResourceLoaderImpl;
+import org.apache.tuscany.container.js.assembly.mock.HelloWorldService;
+import org.apache.tuscany.model.assembly.AssemblyFactory;
+import org.apache.tuscany.model.assembly.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.Component;
+import org.apache.tuscany.model.assembly.ConfiguredReference;
+import org.apache.tuscany.model.assembly.ConfiguredService;
+import org.apache.tuscany.model.assembly.Module;
+import org.apache.tuscany.model.assembly.Reference;
+import org.apache.tuscany.model.assembly.Scope;
+import org.apache.tuscany.model.assembly.Service;
+import org.apache.tuscany.model.assembly.impl.AssemblyFactoryImpl;
+import org.apache.tuscany.model.assembly.impl.AssemblyModelContextImpl;
+import org.apache.tuscany.model.scdl.loader.impl.SCDLAssemblyModelLoaderImpl;
+import org.apache.tuscany.model.types.java.JavaServiceContract;
+
+/**
+ * Generates mock modules
+ *
+ * @version $Rev$ $Date$
+ */
+public class MockModuleFactory {
+
+ private static AssemblyFactory factory = new AssemblyFactoryImpl();
+
+ private static AssemblyModelContext assemblyContext = new AssemblyModelContextImpl(new AssemblyFactoryImpl(),
+ new SCDLAssemblyModelLoaderImpl(null), new ResourceLoaderImpl(Thread.currentThread().getContextClassLoader()));
+
+ private MockModuleFactory() {
+ }
+
+ public static Module createModule() throws Exception {
+ Component sourceComponent = MockAssemblyFactory.createComponent("source",
+ "org/apache/tuscany/container/js/assembly/mock/HelloWorldImpl.js", HelloWorldService.class, Scope.MODULE);
+ Component targetComponent = MockAssemblyFactory.createComponent("target",
+ "org/apache/tuscany/container/js/assembly/mock/HelloWorldImpl.js", HelloWorldService.class, Scope.MODULE);
+
+ Service targetService = factory.createService();
+ JavaServiceContract targetContract = factory.createJavaServiceContract();
+ targetContract.setInterface(HelloWorldService.class);
+ targetService.setServiceContract(targetContract);
+ targetService.setName("GenericComponent");
+ ConfiguredService cTargetService = factory.createConfiguredService();
+ cTargetService.setService(targetService);
+ cTargetService.initialize(assemblyContext);
+ targetComponent.getConfiguredServices().add(cTargetService);
+ targetComponent.initialize(assemblyContext);
+
+ Reference ref = factory.createReference();
+ ConfiguredReference cref = factory.createConfiguredReference();
+ ref.setName("setGenericComponent");
+ JavaServiceContract inter = factory.createJavaServiceContract();
+ inter.setInterface(HelloWorldService.class);
+ ref.setServiceContract(inter);
+ cref.setReference(ref);
+ cref.getTargetConfiguredServices().add(cTargetService);
+ cref.initialize(assemblyContext);
+ sourceComponent.getConfiguredReferences().add(cref);
+ sourceComponent.initialize(assemblyContext);
+
+ Module module = factory.createModule();
+ module.setName("test.module");
+ module.getComponents().add(sourceComponent);
+ module.getComponents().add(targetComponent);
+ module.initialize(assemblyContext);
+ return module;
+ }
+
+ // public static Module createModule() throws Exception {
+ // Component sourceComponent =
+ // MockAssemblyFactory.createComponent("source","org/apache/tuscany/container/js/assembly/mock/HelloWorldImpl.js",HelloWorldService.class.getCanonicalName(),ScopeEnum.MODULE_LITERAL);
+ // Component targetComponent =
+ // MockAssemblyFactory.createComponent("target","org/apache/tuscany/container/js/assembly/mock/HelloWorldImpl.js",HelloWorldService.class.getCanonicalName(),ScopeEnum.MODULE_LITERAL);
+ // PojoReference ref = new PojoReference();
+ // PojoConfiguredReference cref = new PojoConfiguredReference();
+ // ref.setName("helloWorld");
+ // PojoInterface inter = new PojoJavaInterface();
+ // PojoInterfaceType type = new PojoInterfaceType();
+ // type.setInstanceClass(HelloWorldService.class);
+ // PojoOperationType oType = new PojoOperationType();
+ // oType.setName("hello");
+ // SDOType inputType = new SDOType("String","",String.class,null);
+ // oType.setInputType(inputType);
+ // type.addOperationType(oType);
+ // inter.setInterfaceType(type);
+ // ref.setInterfaceContract(inter);
+ // cref.setReference(ref);
+ // cref.setPart(targetComponent);
+ // PojoPort port = new PojoPort();
+ // port.setName("HelloWorldService");
+ // cref.setPort(port);
+ // sourceComponent.getConfiguredReferences().add(cref);
+ // PojoModule module = new PojoModule();
+ // module.setName("test.module");
+ // module.addComponent(sourceComponent);
+ // module.addComponent(targetComponent);
+ // return module;
+ // }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/rhino/RhinoInvokerTestCase.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/rhino/RhinoInvokerTestCase.java
new file mode 100644
index 0000000000..9269c1cf7e
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/rhino/RhinoInvokerTestCase.java
@@ -0,0 +1,184 @@
+/*
+ * Copyright 2004,2005 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.container.js.rhino;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.mozilla.javascript.EcmaError;
+
+/**
+ * Tests for the RhinoInvoker
+ */
+public class RhinoInvokerTestCase extends TestCase {
+
+ private static final String scriptName = "RhinoInvokerTestCase.js";
+ private String script;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ this.script = readResource(scriptName);
+ }
+
+ public void testSimpleInvocation() {
+ RhinoScript ri = new RhinoScript(scriptName, script);
+ Object x = ri.invoke("echo", "petra", null);
+ assertEquals("petra", x);
+ }
+
+ public void testCopy() {
+ RhinoScript ri = new RhinoScript(scriptName, script);
+ Object x = ri.invoke("echo", "petra", null);
+ assertEquals("petra", x);
+
+ ri = ri.copy();
+ x = ri.invoke("echo", "sue", null);
+ assertEquals("sue", x);
+
+ }
+
+ public void testContexts1() {
+ RhinoScript ri = new RhinoScript(scriptName, script);
+ Map<String, Object> contexts = new HashMap<String, Object>();
+ contexts.put("a", "petra");
+ Object x = ri.invoke("getA", null, contexts);
+ assertEquals("petra", x);
+ }
+
+ /**
+ * Tests context not accessable across invocations
+ */
+ public void testContexts2() {
+ RhinoScript ri = new RhinoScript(scriptName, script);
+ Map<String, Object> contexts = new HashMap<String, Object>();
+ contexts.put("a", "petra");
+ Object x = ri.invoke("getA", null, contexts);
+ assertEquals("petra", x);
+
+ try {
+ x = ri.invoke("getA", null, null);
+ assertTrue("expected ReferenceError", false);
+ } catch (EcmaError e) {
+ assertEquals("ReferenceError", e.getName());
+ }
+ }
+
+ /**
+ * Tests shared scope is accessable across invocations
+ */
+ public void testScopes1() {
+ RhinoScript ri = new RhinoScript(scriptName, script);
+ ri.invoke("setGlobalVarY", "petra", null);
+
+ Object x = ri.invoke("getGlobalVarY", null, null);
+ assertEquals("petra", x);
+ }
+
+ /**
+ * Tests local vars are NOT accessable across invocations
+ */
+ public void testScopes2() {
+ RhinoScript ri = new RhinoScript(scriptName, script);
+ ri.invoke("setLocalVarY", "petra", null);
+
+ try {
+ ri.invoke("getGlobalVarY", null, null);
+ assertTrue("expected ReferenceError", false);
+ } catch (EcmaError e) {
+ assertEquals("ReferenceError", e.getName());
+ }
+ }
+
+ /**
+ * Tests shared scope is accessable when using contexts (ie an invocation scope)
+ */
+ public void testScopes3() {
+ RhinoScript ri = new RhinoScript(scriptName, script);
+ ri.invoke("setGlobalVarY", "petra", null);
+
+ Map<String, Object> contexts = new HashMap<String, Object>();
+ contexts.put("a", "sue");
+ Object x = ri.invoke("getGlobalVarY", null, contexts);
+ assertEquals("petra", x);
+
+ x = ri.invoke("getA", null, contexts);
+ assertEquals("sue", x);
+
+ }
+
+ /**
+ * Tests a copy only retains the script scope not the shared scope
+ */
+ public void testScopes4() {
+ RhinoScript ri = new RhinoScript(scriptName, script);
+ ri.invoke("setGlobalVarY", "petra", null);
+
+ ri = ri.copy();
+ try {
+ ri.invoke("getGlobalVarY", null, null);
+ assertTrue("expected ReferenceError", false);
+ } catch (EcmaError e) {
+ assertEquals("ReferenceError", e.getName());
+ }
+ try {
+ ri.invoke("getA", null, null);
+ assertTrue("expected ReferenceError", false);
+ } catch (EcmaError e) {
+ assertEquals("ReferenceError", e.getName());
+ }
+
+ }
+
+ public void testGetInt() {
+ RhinoScript ri = new RhinoScript(scriptName, script);
+ Object x = ri.invoke("getInt", null, Integer.TYPE, null);
+ assertEquals(Integer.class, x.getClass());
+ }
+
+ /**
+ * Read a resource into a String
+ */
+ private String readResource(String name) {
+ try {
+ URL url = getClass().getResource(name);
+ if (url == null) {
+ throw new RuntimeException("resource not found: " + name);
+ }
+ InputStream inputStream = url.openStream();
+
+ StringBuffer resource = new StringBuffer();
+ int n = 0;
+
+ while ((n = inputStream.read()) != -1) {
+ resource.append((char) n);
+ }
+
+ inputStream.close();
+
+ String s = resource.toString();
+ return s;
+
+ } catch (IOException e) {
+ throw new RuntimeException("IOException reading resource " + name, e);
+ }
+ }
+
+} \ No newline at end of file
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/resources/org/apache/tuscany/container/js/assembly/mock/HelloWorldImpl.componentType b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/resources/org/apache/tuscany/container/js/assembly/mock/HelloWorldImpl.componentType
new file mode 100644
index 0000000000..3e9bb5bc28
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/resources/org/apache/tuscany/container/js/assembly/mock/HelloWorldImpl.componentType
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
+
+ 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.
+ -->
+<componentType xmlns="http://www.osoa.org/xmlns/sca/0.9"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <service name="HelloWorldService">
+ <interface.java interface="org.apache.tuscany.container.js.assembly.mock.HelloWorldService" remoteable="true"/>
+ </service>
+ <property name="text" type="xsd:string"/>
+</componentType> \ No newline at end of file
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/resources/org/apache/tuscany/container/js/assembly/mock/HelloWorldImpl.js b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/resources/org/apache/tuscany/container/js/assembly/mock/HelloWorldImpl.js
new file mode 100644
index 0000000000..6c5f697040
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/resources/org/apache/tuscany/container/js/assembly/mock/HelloWorldImpl.js
@@ -0,0 +1,4 @@
+
+function hello(name) {
+ return "Hello " + name;
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/resources/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/AccountService.wsdl b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/resources/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/AccountService.wsdl
new file mode 100644
index 0000000000..ecd07d3934
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/resources/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/AccountService.wsdl
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
+
+ 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.
+ -->
+<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:tns="http://www.bigbank.com/AccountService/"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://www.bigbank.com/AccountService/"
+
+ name="AccountService">
+
+ <wsdl:types>
+ <xsd:schema targetNamespace="http://www.bigbank.com/AccountService/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <xsd:element name="customerID" type="xsd:string"/>
+ <xsd:element name="getAccountReportResponse" type="tns:AccountReport"/>
+
+ <xsd:complexType name="AccountReport">
+ <xsd:sequence>
+ <xsd:element name="accountSummary" type="tns:AccountSummary" maxOccurs="unbounded"/>
+ </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:customerID" 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="AccountServiceSOAP" type="tns:AccountService">
+ <soap:binding style="document"
+ transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="getAccountReport">
+ <soap:operation
+ soapAction="http://www.bigbank.com/AccountService/getAccountReport"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="AccountService">
+ <wsdl:port binding="tns:AccountServiceSOAP"
+ name="AccountServiceSOAP">
+ <soap:address location=""/>
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/resources/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/AccountServiceImpl.componentType b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/resources/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/AccountServiceImpl.componentType
new file mode 100644
index 0000000000..9f75ba9134
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/resources/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/AccountServiceImpl.componentType
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="ASCII"?>
+
+<componentType xmlns="http://www.osoa.org/xmlns/sca/0.9" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <service name="test1MediatorService">
+ <interface.java interface="org.apache.tuscany.container.js.assembly.tests.bigbank.account.services.account.AccountService"/>
+ </service>
+
+ <reference name="accountDataService">
+ <interface.java interface="org.apache.tuscany.container.js.assembly.tests.bigbank.account.services.accountdata.AccountDataService"/>
+ </reference>
+
+ <reference name="stockQuoteService">
+ <interface.java interface="org.apache.tuscany.container.js.assembly.tests.bigbank.account.services.stockquote.StockQuoteService"/>
+ </reference>
+
+ <property name="currency" type="xsd:string" default="USD"/>
+
+</componentType> \ No newline at end of file
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/resources/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/account/AccountService.wsdl b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/resources/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/account/AccountService.wsdl
new file mode 100644
index 0000000000..ecd07d3934
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/resources/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/account/AccountService.wsdl
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
+
+ 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.
+ -->
+<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:tns="http://www.bigbank.com/AccountService/"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://www.bigbank.com/AccountService/"
+
+ name="AccountService">
+
+ <wsdl:types>
+ <xsd:schema targetNamespace="http://www.bigbank.com/AccountService/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <xsd:element name="customerID" type="xsd:string"/>
+ <xsd:element name="getAccountReportResponse" type="tns:AccountReport"/>
+
+ <xsd:complexType name="AccountReport">
+ <xsd:sequence>
+ <xsd:element name="accountSummary" type="tns:AccountSummary" maxOccurs="unbounded"/>
+ </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:customerID" 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="AccountServiceSOAP" type="tns:AccountService">
+ <soap:binding style="document"
+ transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="getAccountReport">
+ <soap:operation
+ soapAction="http://www.bigbank.com/AccountService/getAccountReport"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="AccountService">
+ <wsdl:port binding="tns:AccountServiceSOAP"
+ name="AccountServiceSOAP">
+ <soap:address location=""/>
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/resources/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/account/AccountServiceImpl.componentType b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/resources/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/account/AccountServiceImpl.componentType
new file mode 100644
index 0000000000..9f75ba9134
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/resources/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/account/AccountServiceImpl.componentType
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="ASCII"?>
+
+<componentType xmlns="http://www.osoa.org/xmlns/sca/0.9" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <service name="test1MediatorService">
+ <interface.java interface="org.apache.tuscany.container.js.assembly.tests.bigbank.account.services.account.AccountService"/>
+ </service>
+
+ <reference name="accountDataService">
+ <interface.java interface="org.apache.tuscany.container.js.assembly.tests.bigbank.account.services.accountdata.AccountDataService"/>
+ </reference>
+
+ <reference name="stockQuoteService">
+ <interface.java interface="org.apache.tuscany.container.js.assembly.tests.bigbank.account.services.stockquote.StockQuoteService"/>
+ </reference>
+
+ <property name="currency" type="xsd:string" default="USD"/>
+
+</componentType> \ No newline at end of file
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/resources/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/accountdata/AccountDataServiceImpl.componentType b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/resources/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/accountdata/AccountDataServiceImpl.componentType
new file mode 100644
index 0000000000..0217420bea
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/resources/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/accountdata/AccountDataServiceImpl.componentType
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="ASCII"?>
+
+<componentType xmlns="http://www.osoa.org/xmlns/sca/0.9" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <service name="AccountDataService">
+ <interface.java interface="org.apache.tuscany.container.js.assembly.tests.bigbank.account.services.accountdata.AccountDataService"/>
+ </service>
+
+</componentType> \ No newline at end of file
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/resources/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/stockquote/StockQuoteServiceImpl.componentType b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/resources/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/stockquote/StockQuoteServiceImpl.componentType
new file mode 100644
index 0000000000..e67876ba35
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/resources/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/stockquote/StockQuoteServiceImpl.componentType
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="ASCII"?>
+
+<componentType xmlns="http://www.osoa.org/xmlns/sca/0.9" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <service name="StockQuoteService">
+ <interface.java interface="org.apache.tuscany.container.js.assembly.tests.bigbank.account.services.stockquote.StockQuoteService"/>
+ </service>
+
+</componentType> \ No newline at end of file
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/resources/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/stockquote/StockQuoteWebService.wsdl b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/resources/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/stockquote/StockQuoteWebService.wsdl
new file mode 100644
index 0000000000..01df4ef054
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/resources/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/stockquote/StockQuoteWebService.wsdl
@@ -0,0 +1,98 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
+
+ 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.
+ -->
+<wsdl:definitions targetNamespace="http://webservice.stockquote" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://webservice.stockquote" xmlns:intf="http://webservice.stockquote" xmlns:tns1="http://stockquote" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="">
+ <!--WSDL created by Apache Axis version: 1.2.1
+Built on Jun 14, 2005 (09:15:57 EDT)-->
+ <wsdl:types>
+ <schema elementFormDefault="qualified" targetNamespace="http://stockquote" xmlns="http://www.w3.org/2001/XMLSchema">
+ <complexType name="GetQuoteRequest">
+ <sequence>
+ <element name="symbol" nillable="true" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ <complexType name="GetQuoteResponse">
+ <sequence>
+ <element name="price" type="xsd:float"/>
+ </sequence>
+ </complexType>
+ </schema>
+ <schema elementFormDefault="qualified" targetNamespace="http://webservice.stockquote" xmlns="http://www.w3.org/2001/XMLSchema">
+ <import namespace="http://stockquote"/>
+ <element name="request" type="tns1:GetQuoteRequest"/>
+ <element name="getQuoteReturn" type="tns1:GetQuoteResponse"/>
+ </schema>
+ </wsdl:types>
+
+ <wsdl:message name="getQuoteResponse">
+
+ <wsdl:part element="impl:getQuoteReturn" name="getQuoteReturn"/>
+
+ </wsdl:message>
+
+ <wsdl:message name="getQuoteRequest">
+
+ <wsdl:part element="impl:request" name="request"/>
+
+ </wsdl:message>
+
+ <wsdl:portType name="StockQuoteWebService">
+
+ <wsdl:operation name="getQuote" parameterOrder="request">
+
+ <wsdl:input message="impl:getQuoteRequest" name="getQuoteRequest"/>
+
+ <wsdl:output message="impl:getQuoteResponse" name="getQuoteResponse"/>
+
+ </wsdl:operation>
+
+ </wsdl:portType>
+
+ <wsdl:binding name="StockQuoteWebServiceSoapBinding" type="impl:StockQuoteWebService">
+
+ <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+
+ <wsdl:operation name="getQuote">
+
+ <wsdlsoap:operation soapAction=""/>
+
+ <wsdl:input name="getQuoteRequest">
+
+ <wsdlsoap:body use="literal"/>
+
+ </wsdl:input>
+
+ <wsdl:output name="getQuoteResponse">
+
+ <wsdlsoap:body use="literal"/>
+
+ </wsdl:output>
+
+ </wsdl:operation>
+
+ </wsdl:binding>
+
+ <wsdl:service name="StockQuoteWebServiceService">
+
+ <wsdl:port binding="impl:StockQuoteWebServiceSoapBinding" name="StockQuoteWebService">
+
+ <wsdlsoap:address location="http://localhost:8123/StockQuoteWebService/services/StockQuoteWebService"/>
+
+ </wsdl:port>
+
+ </wsdl:service>
+
+</wsdl:definitions>
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/resources/org/apache/tuscany/container/js/assembly/tests/sca.module b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/resources/org/apache/tuscany/container/js/assembly/tests/sca.module
new file mode 100644
index 0000000000..86f516c128
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/resources/org/apache/tuscany/container/js/assembly/tests/sca.module
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
+
+ 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.
+ -->
+<module xmlns="http://www.osoa.org/xmlns/sca/0.9" xmlns:v="http://www.osoa.org/xmlns/sca/values/0.9"
+ xmlns:js="http://org.apache.tuscany/xmlns/js/0.9"
+ name="tuscany.container.js.assembly.tests.bigbank.account">
+
+ <entryPoint name="AccountService">
+ <interface.java interface="org.apache.tuscany.container.js.assembly.tests.bigbank.account.services.account.AccountService"/>
+ <binding.ws port="http://www.bigbank.com/AccountService#AccountServiceSOAP"/>
+ <reference>AccountServiceComponent</reference>
+ </entryPoint>
+
+ <component name="AccountServiceComponent">
+ <js:implementation.js scriptFile="org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/account/AccountServiceImpl.js"/>
+ <properties>
+ <v:currency>EURO</v:currency>
+ </properties>
+ <references>
+ <v:accountDataService>AccountDataServiceComponent</v:accountDataService>
+ <v:stockQuoteService>StockQuoteService</v:stockQuoteService>
+ </references>
+ </component>
+
+ <component name="AccountDataServiceComponent">
+ <js:implementation.js scriptFile="org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/accountdata/AccountDataServiceImpl.js"/>
+ </component>
+
+ <component name="StockQuoteService">
+ <js:implementation.js scriptFile="org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/stockquote/StockQuoteServiceImpl.js"/>
+ </component>
+
+ <!--
+ <externalService name="StockQuoteService">
+ <interface.java interface="org.apache.tuscany.container.js.assembly.tests.bigbank.account.services.stockquote"/>
+ <binding.ws port="http://www.quickstockquote.com/StockQuoteService#StockQuoteServiceSOAP"/>
+ </externalService>
+ -->
+
+</module>
+
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/resources/org/apache/tuscany/container/js/config/ModuleComponentLoaderTest1.module b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/resources/org/apache/tuscany/container/js/config/ModuleComponentLoaderTest1.module
new file mode 100644
index 0000000000..d8e2c425ea
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/resources/org/apache/tuscany/container/js/config/ModuleComponentLoaderTest1.module
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
+
+ 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.
+ -->
+<module xmlns="http://www.osoa.org/xmlns/sca/0.9"
+ xmlns:v="http://www.osoa.org/xmlns/sca/values/0.9"
+ xmlns:js="http://org.apache.tuscany/xmlns/js/0.9"
+ name="ModuleComponentLoaderTest1">
+
+ <component name="HelloWorldServiceComponent">
+ <js:implementation.js scriptFile="org.apache.tuscany.container.js.assembly.mock.HelloWorldImpl.js"/>
+ </component>
+</module>
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/resources/org/apache/tuscany/container/js/rhino/RhinoInvokerTestCase.js b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/resources/org/apache/tuscany/container/js/rhino/RhinoInvokerTestCase.js
new file mode 100644
index 0000000000..2de740d5f8
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/resources/org/apache/tuscany/container/js/rhino/RhinoInvokerTestCase.js
@@ -0,0 +1,22 @@
+
+function echo(x) {
+ return x;
+}
+
+function getA(x) {
+ return a;
+}
+
+function setGlobalVarY(x) {
+ y = x;
+}
+function setLocalVarY(x) {
+ var y = x;
+}
+function getGlobalVarY(x) {
+ return y;
+}
+
+function getInt(x) {
+ return 42;
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/LICENSE.txt b/sca-java-1.x/tags/java-stable-20060304/sca/core/LICENSE.txt
new file mode 100644
index 0000000000..d645695673
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/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/sca-java-1.x/tags/java-stable-20060304/sca/core/pom.xml b/sca-java-1.x/tags/java-stable-20060304/sca/core/pom.xml
new file mode 100644
index 0000000000..2a4f7d89a1
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/pom.xml
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Copyright (c) 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.
+ -->
+<project>
+ <parent>
+ <groupId>org.apache.tuscany</groupId>
+ <artifactId>tuscany-sca</artifactId>
+ <version>SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>tuscany-core</artifactId>
+ <name>Tuscany Core</name>
+ <description>Core Tuscany runtime.</description>
+ <version>SNAPSHOT</version>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany</groupId>
+ <artifactId>tuscany-model</artifactId>
+ <version>${pom.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>tomcat</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>5.0.18</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.tuscany</groupId>
+ <artifactId>tuscany-sdo-plugin</artifactId>
+ <executions>
+ <execution>
+ <configuration>
+ <schemaFile>${basedir}/src/main/resources/model/tuscany-system.xsd</schemaFile>
+ <generateLoader>true</generateLoader>
+ <generateSwitch>true</generateSwitch>
+ <noNotification>true</noNotification>
+ <noUnsettable>true</noUnsettable>
+ </configuration>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/addressing/AddressingConstants.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/addressing/AddressingConstants.java
new file mode 100644
index 0000000000..8154ad4709
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/addressing/AddressingConstants.java
@@ -0,0 +1,33 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.addressing;
+
+/**
+ */
+public interface AddressingConstants {
+
+ String NS_URI = "http://schemas.xmlsoap.org/ws/2004/08/addressing";
+ String TO_HEADER_NAME = NS_URI + "#To";
+ String FROM_HEADER_NAME = NS_URI + "#From";
+ String MESSAGE_ID_HEADER_NAME = NS_URI + "#MessageID";
+ String ACTION_HEADER_NAME = NS_URI + "#Action";
+ String REPLY_TO_HEADER_NAME = NS_URI + "#ReplyTo";
+ String RELATES_TO_HEADER_NAME = NS_URI + "#RelatesTo";
+ String FAULT_TO_HEADER_NAME = NS_URI + "#FaultTo";
+ String ENDPOINT_REFERENCE_HEADER_NAME = NS_URI + "#EndpointReference";
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/addressing/AddressingFactory.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/addressing/AddressingFactory.java
new file mode 100644
index 0000000000..878322bc6e
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/addressing/AddressingFactory.java
@@ -0,0 +1,37 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.addressing;
+
+
+/**
+ * The <b>Factory</b> for the model.
+ */
+public interface AddressingFactory {
+
+ /**
+ * Returns a new object of class '<em>Endpoint Reference</em>'.
+ */
+ EndpointReference createEndpointReference();
+
+ /**
+ * Create a new message ID
+ *
+ * @return
+ */
+ String createMessageID();
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/addressing/EndpointReference.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/addressing/EndpointReference.java
new file mode 100644
index 0000000000..f8ecd34354
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/addressing/EndpointReference.java
@@ -0,0 +1,120 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.addressing;
+
+import java.util.Map;
+
+import org.apache.tuscany.core.invocation.MessageHandler;
+import org.apache.tuscany.model.assembly.ConfiguredPort;
+
+/**
+ * A representation of the model object '<em><b>Endpoint Reference</b></em>'.
+ */
+public interface EndpointReference extends org.osoa.sca.ServiceReference, MessageHandler {
+
+ /**
+ * Returns the endpoint address.
+ *
+ * @return The address.
+ */
+ String getAddress();
+
+ /**
+ * Sets the endpoint address.
+ *
+ * @param address The address.
+ */
+ void setAddress(String address);
+
+ /**
+ * Returns the QName of the WSDL portType associated with this endpoint reference.
+ *
+ * @return The QName of the portType.
+ */
+ String getPortTypeName();
+
+ /**
+ * Sets the QName of the WSDL portType associated with this endpoint reference.
+ *
+ * @param qname The QName of the portType.
+ */
+ void setPortTypeName(String qname);
+
+ /**
+ * Returns the QName of the WSDL service associated with this endpoint reference.
+ *
+ * @return The QName of the service.
+ */
+ String getServiceName();
+
+ /**
+ * Sets the QName of the WSDL service associated with this endpoint reference.
+ *
+ * @param qname The QName of the service.
+ */
+ void setServiceName(String qname);
+
+ /**
+ * Returns the name of the WSDL port associated with this endpoint reference.
+ *
+ * @return The name of the port.
+ */
+ String getPortName();
+
+ /**
+ * Sets the name of the WSDL port associated with this endpoint reference.
+ *
+ * @param name The name of the port.
+ */
+ void setPortName(String name);
+
+ /**
+ * Returns the endpoint reference parameters..
+ *
+ * @return The collection of reference parameters.
+ */
+ Map<String, Object> getReferenceParameters();
+
+ /**
+ * Returns the configured port corresponding to this endpoint reference.
+ *
+ * @return
+ */
+ ConfiguredPort getConfiguredPort();
+
+ /**
+ * Returns the configured port corresponding to this endpoint reference.
+ *
+ * @return
+ */
+ void setConfiguredPort(ConfiguredPort configuredPort);
+
+ /**
+ * Returns the message handler associated with this endpoint reference
+ *
+ * @return
+ */
+ MessageHandler getMessageHandler();
+
+ /**
+ * Sets the message handler associated with this endpoint reference
+ *
+ * @param messageHandler
+ */
+ void setMessageHandler(MessageHandler messageHandler);
+
+} // EndpointReference
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/addressing/impl/AddressingFactoryImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/addressing/impl/AddressingFactoryImpl.java
new file mode 100644
index 0000000000..882e3157c2
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/addressing/impl/AddressingFactoryImpl.java
@@ -0,0 +1,50 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.addressing.impl;
+
+import org.eclipse.emf.ecore.util.EcoreUtil;
+
+import org.apache.tuscany.core.addressing.AddressingFactory;
+import org.apache.tuscany.core.addressing.EndpointReference;
+
+/**
+ * A factory for endpoint references.
+ *
+ */
+public class AddressingFactoryImpl implements AddressingFactory {
+
+ /**
+ * Constructor
+ */
+ public AddressingFactoryImpl() {
+ super();
+ }
+
+ /**
+ * @see org.apache.tuscany.core.addressing.AddressingFactory#createEndpointReference()
+ */
+ public EndpointReference createEndpointReference() {
+ return new EndpointReferenceImpl();
+ }
+
+ /**
+ * @see org.apache.tuscany.core.addressing.AddressingFactory#createMessageID()
+ */
+ public String createMessageID() {
+ return EcoreUtil.generateUUID();
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/addressing/impl/EndpointReferenceImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/addressing/impl/EndpointReferenceImpl.java
new file mode 100644
index 0000000000..f4fbd2036b
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/addressing/impl/EndpointReferenceImpl.java
@@ -0,0 +1,182 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.addressing.impl;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.core.addressing.EndpointReference;
+import org.apache.tuscany.core.invocation.MessageHandler;
+import org.apache.tuscany.core.message.Message;
+import org.apache.tuscany.model.assembly.ConfiguredPort;
+
+/**
+ * An implementation of EndpointReference.
+ */
+public class EndpointReferenceImpl implements EndpointReference {
+
+ private ConfiguredPort configuredPort;
+ private MessageHandler messageHandler;
+ private String address;
+ private String portTypeName;
+ private String portName;
+ private String serviceName;
+ private Map<String, Object> referenceParameters;
+
+ /**
+ * @see org.apache.tuscany.core.addressing.EndpointReference#getAddress()
+ */
+ public String getAddress() {
+ return address;
+ }
+
+ /**
+ * @see org.apache.tuscany.core.addressing.EndpointReference#setAddress(java.lang.String)
+ */
+ public void setAddress(String value) {
+ this.address=value;
+ }
+
+ /**
+ * @see org.apache.tuscany.core.addressing.EndpointReference#getPortTypeName()
+ */
+ public String getPortTypeName() {
+ return portTypeName;
+ }
+
+ /**
+ * @see org.apache.tuscany.core.addressing.EndpointReference#setPortTypeName(java.lang.String)
+ */
+ public void setPortTypeName(String value) {
+ this.portTypeName=value;
+ }
+
+ /**
+ * @see org.apache.tuscany.core.addressing.EndpointReference#getServiceName()
+ */
+ public String getServiceName() {
+ return serviceName;
+ }
+
+ /**
+ * @see org.apache.tuscany.core.addressing.EndpointReference#getPortName()
+ */
+ public String getPortName() {
+ return portName;
+ }
+
+ /**
+ * @see org.apache.tuscany.core.addressing.EndpointReference#setServiceName(java.lang.String)
+ */
+ public void setServiceName(String value) {
+ this.serviceName=value;
+ }
+
+ /**
+ * @see org.apache.tuscany.core.addressing.EndpointReference#setPortName(java.lang.String)
+ */
+ public void setPortName(String portName) {
+ this.portName=portName;
+ }
+
+ /**
+ * @see org.apache.tuscany.core.addressing.EndpointReference#getReferenceParameters()
+ */
+ public Map<String, Object> getReferenceParameters() {
+ if (referenceParameters==null)
+ referenceParameters=new HashMap<String, Object>();
+ return referenceParameters;
+ }
+
+ /**
+ * @see org.apache.tuscany.core.addressing.EndpointReference#getConfiguredPort()
+ */
+ public ConfiguredPort getConfiguredPort() {
+ return configuredPort;
+ }
+
+ /**
+ * @see org.apache.tuscany.core.addressing.EndpointReference#setConfiguredPort(org.apache.tuscany.model.assembly.ConfiguredPort)
+ */
+ public void setConfiguredPort(ConfiguredPort configuredPort) {
+ this.configuredPort = configuredPort;
+ }
+
+ /**
+ * @see org.apache.tuscany.core.addressing.EndpointReference#getMessageHandler()
+ */
+ public MessageHandler getMessageHandler() {
+ return messageHandler;
+ }
+
+ /**
+ * @see org.apache.tuscany.core.addressing.EndpointReference#setMessageHandler(org.apache.tuscany.core.invocation.MessageHandler)
+ */
+ public void setMessageHandler(MessageHandler messageHandler) {
+ this.messageHandler = messageHandler;
+ }
+
+ /**
+ * @see org.osoa.sca.ServiceReference#getSessionID()
+ */
+ public Object getSessionID() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * @see org.osoa.sca.ServiceReference#endSession()
+ */
+ public void endSession() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * @see org.osoa.sca.ServiceReference#getCallbackID()
+ */
+ public Object getCallbackID() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * @see org.osoa.sca.ServiceReference#setCallbackID(java.lang.Object)
+ */
+ public void setCallbackID(Object callbackID) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * @see org.osoa.sca.ServiceReference#getCallback()
+ */
+ public Object getCallback() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * @see org.osoa.sca.ServiceReference#setCallback(java.lang.Object)
+ */
+ public void setCallback(Object callback) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * @see org.apache.tuscany.core.invocation.MessageHandler#processMessage(org.apache.tuscany.core.message.Message)
+ */
+ public boolean processMessage(Message message) {
+ return messageHandler.processMessage(message);
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/BuilderConfigException.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/BuilderConfigException.java
new file mode 100644
index 0000000000..04b7b69cf5
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/BuilderConfigException.java
@@ -0,0 +1,26 @@
+package org.apache.tuscany.core.builder;
+
+/**
+ * Represents an error processing a logical configuration model
+ *
+ * @version $Rev$ $Date$
+ */
+public class BuilderConfigException extends BuilderException {
+
+ public BuilderConfigException() {
+ super();
+ }
+
+ public BuilderConfigException(String message) {
+ super(message);
+ }
+
+ public BuilderConfigException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public BuilderConfigException(Throwable cause) {
+ super(cause);
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/BuilderException.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/BuilderException.java
new file mode 100644
index 0000000000..246f188988
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/BuilderException.java
@@ -0,0 +1,41 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.builder;
+
+import org.apache.tuscany.core.context.CoreRuntimeException;
+
+/**
+ * The root exception for the builder package. Builder exceptions denote a non-recoverable failure.
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class BuilderException extends CoreRuntimeException {
+
+ public BuilderException() {
+ super();
+ }
+
+ public BuilderException(String message) {
+ super(message);
+ }
+
+ public BuilderException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public BuilderException(Throwable cause) {
+ super(cause);
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/BuilderInitException.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/BuilderInitException.java
new file mode 100644
index 0000000000..cd57eaf7ab
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/BuilderInitException.java
@@ -0,0 +1,39 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.builder;
+
+/**
+ * Denotes an exception initializing a builder
+ *
+ * @version $Rev$ $Date$
+ */
+public class BuilderInitException extends BuilderException {
+
+ public BuilderInitException() {
+ super();
+ }
+
+ public BuilderInitException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public BuilderInitException(String message) {
+ super(message);
+ }
+
+ public BuilderInitException(Throwable cause) {
+ super(cause);
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/ConfigurationException.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/ConfigurationException.java
new file mode 100644
index 0000000000..70a31c34c6
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/ConfigurationException.java
@@ -0,0 +1,26 @@
+package org.apache.tuscany.core.builder;
+
+/**
+ * Represents an error processing a logical configuration model
+ *
+ * @version $Rev$ $Date$
+ */
+public class ConfigurationException extends BuilderException {
+
+ public ConfigurationException() {
+ super();
+ }
+
+ public ConfigurationException(String message) {
+ super(message);
+ }
+
+ public ConfigurationException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public ConfigurationException(Throwable cause) {
+ super(cause);
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/ContextCreationException.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/ContextCreationException.java
new file mode 100644
index 0000000000..24b526371d
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/ContextCreationException.java
@@ -0,0 +1,41 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.builder;
+
+
+/**
+ * Denotes an exception creating an instance context
+ *
+ * @version $Rev$ $Date$
+ */
+public class ContextCreationException extends BuilderException {
+
+ public ContextCreationException() {
+ super();
+ }
+
+ public ContextCreationException(String message) {
+ super(message);
+ }
+
+ public ContextCreationException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public ContextCreationException(Throwable cause) {
+ super(cause);
+ }
+
+}
+
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/HierarchicalWireBuilder.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/HierarchicalWireBuilder.java
new file mode 100644
index 0000000000..ace34a1ad5
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/HierarchicalWireBuilder.java
@@ -0,0 +1,29 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.builder;
+
+/**
+ * A wire builder that delegates to child wire builders
+ *
+ * @version $Rev$ $Date$
+ */
+public interface HierarchicalWireBuilder extends WireBuilder{
+
+ /**
+ * Registers a child wire builder
+ */
+ public void addWireBuilder(WireBuilder builder);
+
+}
+
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/NoAccessorException.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/NoAccessorException.java
new file mode 100644
index 0000000000..34b6294638
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/NoAccessorException.java
@@ -0,0 +1,39 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.builder;
+
+/**
+ * Denotes an attempt to access a non-existent field or method
+ *
+ * @version $Rev$ $Date$
+ */
+public class NoAccessorException extends BuilderException {
+
+ public NoAccessorException() {
+ super();
+ }
+
+ public NoAccessorException(String message) {
+ super(message);
+ }
+
+ public NoAccessorException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public NoAccessorException(Throwable cause) {
+ super(cause);
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/ObjectFactory.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/ObjectFactory.java
new file mode 100644
index 0000000000..7d27df4ebd
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/ObjectFactory.java
@@ -0,0 +1,19 @@
+package org.apache.tuscany.core.builder;
+
+import org.apache.tuscany.core.injection.ObjectCreationException;
+
+/**
+ * Implementations create new instances of a particular type
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ObjectFactory<T> {
+
+ /**
+ * Return a instance of the type that this factory creates.
+ *
+ * @return a instance from this factory
+ */
+ T getInstance() throws ObjectCreationException;
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/RuntimeConfiguration.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/RuntimeConfiguration.java
new file mode 100644
index 0000000000..79396e6052
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/RuntimeConfiguration.java
@@ -0,0 +1,69 @@
+package org.apache.tuscany.core.builder;
+
+import java.util.Map;
+
+import org.apache.tuscany.core.context.Context;
+import org.apache.tuscany.core.invocation.spi.ProxyFactory;
+import org.apache.tuscany.model.assembly.Scope;
+
+/**
+ * Implementations create instances of {@link org.apache.tuscany.core.context.Context} based on a compiled
+ * configuration, such as a logical assembly model. For example, implementations of
+ * {@link org.apache.tuscany.core.builder.RuntimeConfigurationBuilder} analyze an
+ * {@link org.apache.tuscany.model.assembly.AssemblyModelObject} to create implementations of
+ * <tt>RuntimeConfiguration</tt>.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface RuntimeConfiguration<T extends Context> {
+
+ /**
+ * Creates an instance context based on the current runtime configuration
+ *
+ * @return a new instance context
+ * @throws ContextCreationException if an error occurs creating the context
+ */
+ public T createInstanceContext() throws ContextCreationException;
+
+ /**
+ * Returns the scope identifier associated with the type of contexts produced by the current configuration
+ */
+ public Scope getScope();
+
+ /**
+ * Returns the name of the contexts produced by the current configuration
+ */
+ public String getName();
+
+ public void prepare();
+
+ /**
+ * Adds a target-side proxy factory for the given service name to the configuration. Target-side proxy factories
+ * contain the invocation chains associated with the destination service of a wire and are responsible for
+ * generating proxies
+ */
+ public void addTargetProxyFactory(String serviceName, ProxyFactory factory);
+
+ /**
+ * Returns the target-side proxy factory associated with the given service name
+ */
+ public ProxyFactory getTargetProxyFactory(String serviceName);
+
+ /**
+ * Returns a collection of target-side proxy factories for the configuration keyed by service name
+ */
+ public Map<String, ProxyFactory> getTargetProxyFactories();
+
+ /**
+ * Adds a source-side proxy factory for the given reference. Source-side proxy factories contain the invocation
+ * chains for a reference in the component implementation associated with the instance context created by this
+ * configuration. Source-side proxy factories also produce proxies that are injected on a reference in a component
+ * implementation.
+ */
+ public void addSourceProxyFactory(String referenceName, ProxyFactory factory);
+
+ public ProxyFactory getSourceProxyFactory(String referenceName);
+
+ public Map<String, ProxyFactory> getSourceProxyFactories();
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/RuntimeConfigurationBuilder.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/RuntimeConfigurationBuilder.java
new file mode 100644
index 0000000000..d797253520
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/RuntimeConfigurationBuilder.java
@@ -0,0 +1,24 @@
+package org.apache.tuscany.core.builder;
+
+import org.apache.tuscany.core.context.Context;
+import org.apache.tuscany.model.assembly.AssemblyModelObject;
+
+/**
+ * Implementations are responsible for generating a runtime configuration model from a logical configuration model. The
+ * logical configuration model (LCM) is decorated with the runtime configuration model (RCM).
+ *
+ * @version $Rev$ $Date$
+ * @see RuntimeConfiguration
+ */
+public interface RuntimeConfigurationBuilder<Y extends Context> {
+
+ /**
+ * Builds a runtime configuration for the supplied model object for registration under the supplied context.
+ *
+ * @param object the logical configuration model node
+ * @param context the context that will be the parent of the built context
+ * @throws BuilderException
+ */
+ public void build(AssemblyModelObject object, Y context) throws BuilderException;
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/UnknownTypeException.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/UnknownTypeException.java
new file mode 100644
index 0000000000..015b0ba342
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/UnknownTypeException.java
@@ -0,0 +1,26 @@
+package org.apache.tuscany.core.builder;
+
+/**
+ * Denotes an unknown configuration parameter type
+ *
+ * @version $Rev$ $Date$
+ */
+public class UnknownTypeException extends BuilderException {
+
+ public UnknownTypeException() {
+ super();
+ }
+
+ public UnknownTypeException(String message) {
+ super(message);
+ }
+
+ public UnknownTypeException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public UnknownTypeException(Throwable cause) {
+ super(cause);
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/WireBuilder.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/WireBuilder.java
new file mode 100644
index 0000000000..6f0cf9ce14
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/WireBuilder.java
@@ -0,0 +1,60 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.builder;
+
+import org.apache.tuscany.core.context.ScopeContext;
+import org.apache.tuscany.core.invocation.spi.ProxyFactory;
+
+/**
+ * Responsible for finalizing target-side proxy factories and bridging
+ * {@link org.apache.tuscany.core.invocation.InvocationConfiguration}s held by source- and target-side proxy factories.
+ * <p>
+ * Wire builders may optimize the invocation chains based on certain characteristics of th wire, such as source and
+ * target scopes.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface WireBuilder {
+
+ /**
+ * Connects invocation configurations of the source proxy factory to corresponding ones in the target proxy to
+ * factory
+ *
+ * @param sourceFactory the proxy factory used in constructing the source side of the invocation chain
+ * @param targetFactory the proxy factory used in constructing the target side of the invocation chain
+ * @param targetType the context type of the target. Used to determine if a paricular wire builder should construct
+ * the wire
+ * @param downScope true if the component containing the reference (source side) is of a lesser scope than the
+ * target service
+ * @param targetScopeContext the scope context responsible for managing intance contexts of the target component
+ * type
+ * @throws BuilderConfigException if an error occurs during the wire build process
+ */
+ public void connect(ProxyFactory sourceFactory, ProxyFactory targetFactory, Class targetType, boolean downScope,
+ ScopeContext targetScopeContext) throws BuilderConfigException;
+
+ /**
+ * Finishes processing the target side invocation chain. For example, a
+ * {@link org.apache.tuscany.core.invocation.TargetInvoker} used by target-side proxies is usually set during this
+ * phase.
+ *
+ * @param targetFactory the target-side proxy factory
+ * @param targetType the target context type
+ * @param targetScopeContext the target scope
+ * @throws BuilderConfigException if an error occurs during the wire build process
+ */
+ public void completeTargetChain(ProxyFactory targetFactory, Class targetType, ScopeContext targetScopeContext)
+ throws BuilderConfigException;
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/impl/AssemblyVisitor.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/impl/AssemblyVisitor.java
new file mode 100644
index 0000000000..20e9143537
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/impl/AssemblyVisitor.java
@@ -0,0 +1,62 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.builder.impl;
+
+import java.util.List;
+
+import org.apache.tuscany.core.builder.RuntimeConfigurationBuilder;
+import org.apache.tuscany.core.context.AggregateContext;
+import org.apache.tuscany.model.assembly.AssemblyModelObject;
+import org.apache.tuscany.model.assembly.AssemblyModelVisitor;
+
+/**
+ * Decorates an assembly object graph with runtime configurations using a set of builders
+ *
+ * @version $Rev$ $Date$
+ */
+public class AssemblyVisitor implements AssemblyModelVisitor {
+
+ private AggregateContext parent;
+
+ List<RuntimeConfigurationBuilder> builders;
+
+ /**
+ * Constructs a visitor
+ *
+ * @param parent the parent context for the object graph
+ * @param builders the collection of builders for creating runtime configurations
+ */
+ public AssemblyVisitor(AggregateContext parent, List<RuntimeConfigurationBuilder> builders) {
+ this.parent = parent;
+ this.builders = builders;
+ }
+
+ /**
+ * Initiate walking the object graph
+ */
+ public boolean start(AssemblyModelObject modelObject) {
+ return modelObject.accept(this);
+ }
+
+ /**
+ * Callback when walking the graph
+ */
+ public boolean visit(AssemblyModelObject modelObject) {
+ for (RuntimeConfigurationBuilder builder : builders) {
+ builder.build(modelObject, parent);
+ }
+ return true;
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/impl/BaseExternalServiceRuntimeConfiguration.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/impl/BaseExternalServiceRuntimeConfiguration.java
new file mode 100644
index 0000000000..ce092a7d34
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/impl/BaseExternalServiceRuntimeConfiguration.java
@@ -0,0 +1,106 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.builder.impl;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.core.builder.ContextCreationException;
+import org.apache.tuscany.core.builder.ObjectFactory;
+import org.apache.tuscany.core.builder.RuntimeConfiguration;
+import org.apache.tuscany.core.context.ExternalServiceContext;
+import org.apache.tuscany.core.context.impl.ExternalServiceContextImpl;
+import org.apache.tuscany.core.invocation.spi.ProxyFactory;
+import org.apache.tuscany.model.assembly.Scope;
+
+/**
+ * A template implementation that creates instances of {@link org.apache.tuscany.core.context.ExternalServiceContext}
+ * configured with the appropriate invocation chains and bindings. This class is intended to be subclassed when
+ * contributing new bindings to the runtime. The subclass serves as a marker so the binding {@link WireBuilder}
+ * responsible for setting the proper {@link org.apache.tuscany.core.invocation.TargetInvoker} on the invocation chains
+ * can be notified.
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class BaseExternalServiceRuntimeConfiguration implements RuntimeConfiguration<ExternalServiceContext> {
+
+ private String name;
+
+ private ProxyFactory proxyFactory;
+
+ private ObjectFactory objectFactory;
+
+ private String targetServiceName;
+
+ private Map<String,ProxyFactory> targetProxyFactories;
+
+ public BaseExternalServiceRuntimeConfiguration(String name, ObjectFactory objectFactory) {
+ assert (name != null) : "Name was null";
+ assert (objectFactory != null) : "Object factory was null";
+ this.name = name;
+ this.objectFactory = objectFactory;
+ }
+
+ public ExternalServiceContext createInstanceContext() throws ContextCreationException {
+ return new ExternalServiceContextImpl(name, proxyFactory, objectFactory);
+ }
+
+ public Scope getScope() {
+ return Scope.MODULE;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void prepare() {
+ }
+
+ public void addTargetProxyFactory(String serviceName, ProxyFactory factory) {
+ assert (serviceName != null) : "No service name specified";
+ assert (factory != null) : "Proxy factory was null";
+ this.targetServiceName = serviceName; // external services are configured with only one service
+ this.proxyFactory = factory;
+ }
+
+ public ProxyFactory getTargetProxyFactory(String serviceName) {
+ if (this.targetServiceName.equals(serviceName)) {
+ return proxyFactory;
+ } else {
+ return null;
+ }
+ }
+
+ public Map<String,ProxyFactory> getTargetProxyFactories() {
+ if (targetProxyFactories == null) {
+ targetProxyFactories = new HashMap(1);
+ targetProxyFactories.put(targetServiceName, proxyFactory);
+ }
+ return targetProxyFactories;
+ }
+
+ public void addSourceProxyFactory(String referenceName, ProxyFactory factory) {
+ // no wires inside an aggregate from an external service
+ }
+
+ public ProxyFactory getSourceProxyFactory(String referenceName) {
+ return null;
+ }
+
+ public Map getSourceProxyFactories() {
+ return Collections.EMPTY_MAP;
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/impl/DefaultWireBuilder.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/impl/DefaultWireBuilder.java
new file mode 100644
index 0000000000..6ed5472a64
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/impl/DefaultWireBuilder.java
@@ -0,0 +1,110 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.builder.impl;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.core.builder.BuilderConfigException;
+import org.apache.tuscany.core.builder.HierarchicalWireBuilder;
+import org.apache.tuscany.core.builder.WireBuilder;
+import org.apache.tuscany.core.context.QualifiedName;
+import org.apache.tuscany.core.context.ScopeContext;
+import org.apache.tuscany.core.invocation.InvocationConfiguration;
+import org.apache.tuscany.core.invocation.impl.InvokerInterceptor;
+import org.apache.tuscany.core.invocation.impl.MessageChannelImpl;
+import org.apache.tuscany.core.invocation.spi.ProxyFactory;
+
+/**
+ * The top-most wire builder configured in a runtime. Responsible for constructing wires from source and target chains,
+ * this implementation first bridges the chains and then delegates to any other wire builders.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefaultWireBuilder implements HierarchicalWireBuilder {
+
+ // collection configured wire builders
+ private List<WireBuilder> builders = new ArrayList();
+
+ public DefaultWireBuilder() {
+ }
+
+ /**
+ * Adds a wire builder to delegate to
+ */
+ public void addWireBuilder(WireBuilder builder) {
+ builders.add(builder);
+ }
+
+ public void setWireBuilders(List<WireBuilder> builders) {
+ builders.addAll(builders);
+ }
+
+ public void connect(ProxyFactory sourceFactory, ProxyFactory targetFactory, Class targetType, boolean downScope,
+ ScopeContext targetScopeContext) {
+ QualifiedName targetName = sourceFactory.getProxyConfiguration().getTargetName();
+ // get the proxy chain for the target
+ if (targetFactory != null) {
+ // if null, the target side has no interceptors or handlers
+ Map<Method, InvocationConfiguration> targetInvocationConfigs = targetFactory.getProxyConfiguration()
+ .getInvocationConfigurations();
+ for (InvocationConfiguration sourceInvocationConfig : sourceFactory.getProxyConfiguration()
+ .getInvocationConfigurations().values()) {
+ // match invocation chains
+ InvocationConfiguration targetInvocationConfig = targetInvocationConfigs.get(sourceInvocationConfig.getMethod());
+ // if handler is configured, add that
+ if (targetInvocationConfig.getRequestHandlers() != null) {
+ sourceInvocationConfig.setTargetRequestChannel(new MessageChannelImpl(targetInvocationConfig
+ .getRequestHandlers()));
+ sourceInvocationConfig.setTargetResponseChannel(new MessageChannelImpl(targetInvocationConfig
+ .getResponseHandlers()));
+ } else {
+ // no handlers, just connect interceptors
+ if (targetInvocationConfig.getTargetInterceptor() == null) {
+ BuilderConfigException e = new BuilderConfigException("No target handler or interceptor for operation");
+ e.setIdentifier(targetInvocationConfig.getMethod().getName());
+ throw e;
+ }
+ if (!(sourceInvocationConfig.getLastTargetInterceptor() instanceof InvokerInterceptor && targetInvocationConfig
+ .getTargetInterceptor() instanceof InvokerInterceptor)) {
+ // check that we do not have the case where the only interceptors are invokers since we just need one
+ sourceInvocationConfig.addTargetInterceptor(targetInvocationConfig.getTargetInterceptor());
+ }
+ }
+ }
+ }
+ // delegate to other wire builders
+ for (WireBuilder builder : builders) {
+ builder.connect(sourceFactory, targetFactory, targetType, downScope, targetScopeContext);
+ }
+ // signal that wire build process is complete
+ boolean optimizable = true;
+ for (InvocationConfiguration sourceInvocationConfig : sourceFactory.getProxyConfiguration().getInvocationConfigurations()
+ .values()) {
+ sourceInvocationConfig.build();
+ // TODO optimize if no proxy needed using NullProxyFactory
+ }
+ }
+
+ public void completeTargetChain(ProxyFactory targetFactory, Class targetType, ScopeContext targetScopeContext)
+ throws BuilderConfigException {
+ // delegate to other wire builders
+ for (WireBuilder builder : builders) {
+ builder.completeTargetChain(targetFactory, targetType, targetScopeContext);
+ }
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/impl/EntryPointRuntimeConfiguration.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/impl/EntryPointRuntimeConfiguration.java
new file mode 100644
index 0000000000..108cc2d366
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/impl/EntryPointRuntimeConfiguration.java
@@ -0,0 +1,104 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.builder.impl;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.core.builder.ContextCreationException;
+import org.apache.tuscany.core.builder.RuntimeConfiguration;
+import org.apache.tuscany.core.context.EntryPointContext;
+import org.apache.tuscany.core.context.impl.EntryPointContextImpl;
+import org.apache.tuscany.core.invocation.spi.ProxyFactory;
+import org.apache.tuscany.core.message.MessageFactory;
+import org.apache.tuscany.model.assembly.Scope;
+
+/**
+ * Produces entry point contexts
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class EntryPointRuntimeConfiguration implements RuntimeConfiguration<EntryPointContext> {
+
+ private String name;
+
+ private ProxyFactory proxyFactory;
+
+ private String referenceName;
+
+ private MessageFactory msgFactory;
+
+ private Map<String, ProxyFactory> sourceProxyFactories;
+
+ public EntryPointRuntimeConfiguration(String name, String referenceName, MessageFactory msgFactory) {
+ assert (name != null) : "Entry point name was null";
+ assert (msgFactory != null) : "Message factory was null";
+ this.name = name;
+ this.referenceName = referenceName;
+ this.msgFactory = msgFactory;
+ }
+
+ public EntryPointContext createInstanceContext() throws ContextCreationException {
+ return new EntryPointContextImpl(name, proxyFactory, msgFactory);
+ }
+
+ public Scope getScope() {
+ return Scope.MODULE;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void prepare() {
+ }
+
+ public void addTargetProxyFactory(String serviceName, ProxyFactory factory) {
+ // no wires to an entry point from with an aggregate
+ }
+
+ public ProxyFactory getTargetProxyFactory(String serviceName) {
+ // no wires to an entry point from with an aggregate
+ return null;
+ }
+
+ public Map<String, ProxyFactory> getTargetProxyFactories() {
+ // no wires to an entry point from with an aggregate
+ return Collections.EMPTY_MAP;
+ }
+
+ public void addSourceProxyFactory(String refName, ProxyFactory factory) {
+ assert (refName != null) : "No reference name specified";
+ assert (factory != null) : "Proxy factory was null";
+ this.referenceName = refName; // entry points are configured with only one reference
+ this.proxyFactory = factory;
+ }
+
+ public ProxyFactory getSourceProxyFactory(String refName) {
+ if (this.referenceName.equals(refName)) {
+ return proxyFactory;
+ } else {
+ return null;
+ }
+ }
+
+ public Map<String, ProxyFactory> getSourceProxyFactories() {
+ if (sourceProxyFactories == null) {
+ sourceProxyFactories = new HashMap(1);
+ sourceProxyFactories.put(referenceName, proxyFactory);
+ }
+ return sourceProxyFactories;
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/impl/HierarchicalBuilder.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/impl/HierarchicalBuilder.java
new file mode 100644
index 0000000000..41f56c1bf0
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/impl/HierarchicalBuilder.java
@@ -0,0 +1,58 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.builder.impl;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import org.apache.tuscany.core.builder.BuilderException;
+import org.apache.tuscany.core.builder.RuntimeConfigurationBuilder;
+import org.apache.tuscany.core.context.Context;
+import org.apache.tuscany.model.assembly.AssemblyModelObject;
+
+/**
+ * A builder that contains nested builders. Used for synchronizing parts of the build process, such as references.
+ *
+ * @version $Rev$ $Date$
+ */
+public class HierarchicalBuilder implements RuntimeConfigurationBuilder {
+ private List<RuntimeConfigurationBuilder> builders = new CopyOnWriteArrayList();
+
+ private List<RuntimeConfigurationBuilder> readOnlyBuilders = Collections.unmodifiableList(builders);
+
+ public HierarchicalBuilder() {
+ }
+
+ public void addBuilder(RuntimeConfigurationBuilder builder) {
+ builders.add(builder);
+ }
+
+ public void removeBuilder(RuntimeConfigurationBuilder builder){
+ builders.remove(builder);
+ }
+
+ public List getBuilders(){
+ return readOnlyBuilders;
+ }
+
+ public void build(AssemblyModelObject object, Context context) throws BuilderException {
+ for (RuntimeConfigurationBuilder builder : builders) {
+ builder.build(object, context);
+ }
+
+ }
+
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/impl/ProxyObjectFactory.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/impl/ProxyObjectFactory.java
new file mode 100644
index 0000000000..c5d3b56034
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/impl/ProxyObjectFactory.java
@@ -0,0 +1,42 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.builder.impl;
+
+import org.apache.tuscany.core.builder.ObjectFactory;
+import org.apache.tuscany.core.injection.ObjectCreationException;
+import org.apache.tuscany.core.invocation.spi.ProxyCreationException;
+import org.apache.tuscany.core.invocation.spi.ProxyFactory;
+
+/**
+ * Uses a proxy factory to return an object instance
+ *
+ * @version $Rev$ $Date$
+ */
+public class ProxyObjectFactory implements ObjectFactory {
+
+ private ProxyFactory factory;
+
+ public ProxyObjectFactory(ProxyFactory factory) {
+ this.factory = factory;
+ }
+
+ public Object getInstance() throws ObjectCreationException {
+ try {
+ return factory.createProxy();
+ } catch (ProxyCreationException e) {
+ throw new ObjectCreationException(e);
+ }
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/client/TuscanyRuntime.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/client/TuscanyRuntime.java
new file mode 100644
index 0000000000..629f3ac0c2
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/client/TuscanyRuntime.java
@@ -0,0 +1,204 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.client;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.common.monitor.MonitorFactory;
+import org.apache.tuscany.common.monitor.impl.NullMonitorFactory;
+import org.apache.tuscany.common.resource.ResourceLoader;
+import org.apache.tuscany.common.resource.impl.ResourceLoaderImpl;
+import org.apache.tuscany.core.builder.RuntimeConfigurationBuilder;
+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.config.impl.ModuleComponentConfigurationLoaderImpl;
+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.runtime.RuntimeContext;
+import org.apache.tuscany.core.runtime.RuntimeContextImpl;
+import org.apache.tuscany.core.system.builder.SystemComponentContextBuilder;
+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.AssemblyFactoryImpl;
+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;
+import org.osoa.sca.ModuleContext;
+import org.osoa.sca.SCA;
+import org.osoa.sca.ServiceRuntimeException;
+
+/**
+ * Create and initialize a Tuscany SCA runtime environment.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TuscanyRuntime extends SCA {
+ private final Monitor monitor;
+ private final Object sessionKey = new Object();
+
+ private final RuntimeContext runtimeContext;
+ private AggregateContext systemModuleComponentContext;
+ private AggregateContext moduleContext;
+
+ private final static 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, 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 monitorFactory the MonitorFactory for this runtime
+ * @throws ConfigurationException if there was a problem loading the SCA configuration
+ */
+ public TuscanyRuntime(String name, String uri, MonitorFactory monitorFactory) throws ConfigurationException {
+ this.monitor = monitorFactory.getMonitor(Monitor.class);
+
+ // Create a resource loader from the current classloader
+ ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+ ResourceLoader resourceLoader = new ResourceLoaderImpl(classLoader);
+
+ // Create an assembly model factory
+ AssemblyFactory modelFactory=new AssemblyFactoryImpl();
+
+ // Create an assembly model loader
+ List<SCDLModelLoader> scdlLoaders=new ArrayList<SCDLModelLoader>();
+ scdlLoaders.add(new SystemSCDLModelLoader());
+ AssemblyModelLoader modelLoader=new SCDLAssemblyModelLoaderImpl(scdlLoaders);
+
+ // Create an assembly model context
+ AssemblyModelContext modelContext = new AssemblyModelContextImpl(modelFactory, modelLoader, resourceLoader);
+
+ // Create system configuration builders
+ List<RuntimeConfigurationBuilder> configBuilders = new ArrayList();
+ configBuilders.add((new SystemComponentContextBuilder()));
+ configBuilders.add(new SystemEntryPointBuilder());
+ configBuilders.add(new SystemExternalServiceBuilder());
+
+ // Create a runtime context and start it
+ runtimeContext = new RuntimeContextImpl(monitorFactory, scdlLoaders, configBuilders,new DefaultWireBuilder());
+ runtimeContext.start();
+ monitor.started(runtimeContext);
+
+ // Get the system context
+ AggregateContext systemContext = runtimeContext.getSystemContext();
+
+ // Load the system module component
+ ModuleComponentConfigurationLoader loader = new ModuleComponentConfigurationLoaderImpl(modelContext);
+ ModuleComponent systemModuleComponent = loader.loadSystemModuleComponent(SYSTEM_MODULE_COMPONENT, SYSTEM_MODULE_COMPONENT);
+
+ // Register it with the system context
+ systemContext.registerModelObject(systemModuleComponent);
+
+ // Get the aggregate context representing the system module component
+ systemModuleComponentContext = (AggregateContext) systemContext.getContext(SYSTEM_MODULE_COMPONENT);
+ systemModuleComponentContext.registerModelObject(systemModuleComponent.getComponentImplementation());
+ systemModuleComponentContext.fireEvent(EventContext.MODULE_START, null);
+
+ // Load the SCDL configuration of the application module
+ ModuleComponent moduleComponent = loader.loadModuleComponent(name, uri);
+
+ // Register it under the root application context
+ runtimeContext.getRootContext().registerModelObject(moduleComponent);
+ moduleContext=(AggregateContext)runtimeContext.getContext(moduleComponent.getName());
+ moduleContext.registerModelObject(moduleComponent.getComponentImplementation());
+
+ }
+
+ /**
+ * 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);
+ runtimeContext.stop();
+ monitor.stopped(runtimeContext);
+ }
+
+ /**
+ * 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/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/config/ComponentTypeIntrospector.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/config/ComponentTypeIntrospector.java
new file mode 100644
index 0000000000..c80a8f31ba
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/config/ComponentTypeIntrospector.java
@@ -0,0 +1,37 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.config;
+
+import org.apache.tuscany.model.assembly.ComponentType;
+
+/**
+ * Interface for implementations that are able create SCA definitions
+ * by inspecting Java classes.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ComponentTypeIntrospector {
+ /**
+ * Create a componentType definition by introspecting a Java Class.
+ *
+ * @param implClass the class to inspect
+ * @return a componentType definition
+ * @throws ConfigurationException if the Class does not define a valid component type
+ */
+ ComponentType introspect(Class<?> implClass) throws ConfigurationException;
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/config/ConfigurationException.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/config/ConfigurationException.java
new file mode 100644
index 0000000000..96365311f2
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/config/ConfigurationException.java
@@ -0,0 +1,42 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.config;
+
+import org.apache.tuscany.common.TuscanyException;
+
+
+/**
+ * Base class for exceptions that pertain to configuration.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ConfigurationException extends TuscanyException {
+ public ConfigurationException() {
+ }
+
+ public ConfigurationException(String message) {
+ super(message);
+ }
+
+ public ConfigurationException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public ConfigurationException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/config/ConfigurationLoadException.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/config/ConfigurationLoadException.java
new file mode 100644
index 0000000000..3055dc2fd2
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/config/ConfigurationLoadException.java
@@ -0,0 +1,47 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.config;
+
+import java.io.IOException;
+
+/**
+ * Exception indicating that there was a problem loading a configuration resource.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ConfigurationLoadException extends ConfigurationException {
+
+ /**
+ * Constructor specifying the resource that was being loaded and the IOException that resulted.
+ * These are returned as the message and cause respectively.
+ *
+ * @param resource the resource being loaded
+ * @param cause the IOException that occurred
+ */
+ public ConfigurationLoadException(String resource, IOException cause) {
+ super(resource, cause);
+ }
+
+ /**
+ * Constructor specifying the resource that was being loaded.
+ *
+ * @param resource the resource being loaded
+ */
+ public ConfigurationLoadException(String resource) {
+ super(resource);
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/config/ImplementationCache.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/config/ImplementationCache.java
new file mode 100644
index 0000000000..595f499797
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/config/ImplementationCache.java
@@ -0,0 +1,46 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.config;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.model.assembly.ComponentImplementation;
+
+/**
+ * Cache of introspected implementations.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ImplementationCache {
+ /**
+ * Return an implementation from a given namespace.
+ *
+ * @param type the namespace that defines the type of implementation
+ * @param name the name of an implementation in that namespace
+ * @return the implementation or null if it is not present in the cache
+ */
+ ComponentImplementation get(QName type, String name);
+
+ /**
+ * Add an implementation to the cache
+ *
+ * @param type the namespace that defines the type of implementation
+ * @param name the name of an implementation in that namespace
+ * @param implementation the introspected implementation
+ */
+ void put(QName type, String name, ComponentImplementation implementation);
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/config/InvalidRootElementException.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/config/InvalidRootElementException.java
new file mode 100644
index 0000000000..19df4784cd
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/config/InvalidRootElementException.java
@@ -0,0 +1,51 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.config;
+
+/**
+ * Configuration exception that indicates the root element in an XML file was not the one expected.
+ *
+ * @version $Rev$ $Date$
+ */
+public class InvalidRootElementException extends ConfigurationException {
+ private final String resource;
+ private final String element;
+
+ /**
+ * Constructor specifying the location of the resource and the element that was expected.
+ *
+ * @param resource the resource
+ * @param element the expected root element
+ */
+ public InvalidRootElementException(String resource, String element) {
+ super();
+ this.resource = resource;
+ this.element = element;
+ }
+
+ public String getMessage() {
+ return "XML document element in resource " + resource + " is not a " + element;
+ }
+
+ public String getResource() {
+ return resource;
+ }
+
+ public String getElement() {
+ return element;
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/config/JavaIntrospectionHelper.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/config/JavaIntrospectionHelper.java
new file mode 100644
index 0000000000..c10ff82310
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/config/JavaIntrospectionHelper.java
@@ -0,0 +1,349 @@
+package org.apache.tuscany.core.config;
+
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * Implements various reflection-related operations
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaIntrospectionHelper {
+
+ private static final Class[] EMPTY_CLASS_ARRY = new Class[0];
+
+ // ----------------------------------
+ // Constructors
+ // ----------------------------------
+
+ /**
+ * Hide the constructor
+ */
+ private JavaIntrospectionHelper() {
+ }
+
+ // ----------------------------------
+ // Methods
+ // ----------------------------------
+
+ /**
+ * Returns a collection of public, private, protected, or default fields declared by a class or one of its
+ * supertypes
+ */
+ public static Set<Field> getAllFields(Class pClass) {
+ return getAllFields(pClass, new HashSet<Field>());
+ }
+
+ /**
+ * Recursively evaluates the type hierachy to return all fields on a given type
+ *
+ * @spec This raises an interesting issue - do we allow injection on private supertype fields in a subtype even if
+ * they are annotated?
+ */
+ private static Set<Field> getAllFields(Class pClass, Set<Field> fields) {
+ if (pClass == null || pClass.isArray() || Object.class.equals(pClass)) {
+ return fields;
+ }
+ fields = getAllFields(pClass.getSuperclass(), fields);
+ Field[] declaredFields = pClass.getDeclaredFields();
+ for (int i = 0; i < declaredFields.length; i++) {
+ declaredFields[i].setAccessible(true); // ignore Java accessibility
+ fields.add(declaredFields[i]);
+ }
+ return fields;
+ }
+
+ /**
+ * Returns a collection of public, private, protected, or default methods declared by a class or one of its
+ * supertypes. Note that overriden methods will not be returned in the collection (i.e. only the method override
+ * will be). <p/> This method can potentially be expensive as reflection information is not cached. It is assumed
+ * that this method will be used during a configuration phase.
+ */
+ public static Set<Method> getAllUniqueMethods(Class pClass) {
+ return getAllUniqueMethods(pClass, new HashSet<Method>());
+ }
+
+ /**
+ * Recursively evaluates the type hierarchy to return all unique methods
+ */
+ private static Set<Method> getAllUniqueMethods(Class pClass, Set<Method> methods) {
+ if (pClass == null || pClass.isArray() || Object.class.equals(pClass)) {
+ return methods;
+ }
+ // we first evaluate methods of the subclass and then move to the parent
+ Method[] declaredMethods = pClass.getDeclaredMethods();
+ for (int i = 0; i < declaredMethods.length; i++) {
+ if (methods.size() == 0) {
+ methods.add(declaredMethods[i]);
+ } else {
+ List temp = new ArrayList();
+ boolean matched = false;
+ for (Method method : methods) {
+ // only add if not already in the set from a supclass (i.e. the
+ // method is not overrided)
+ if (exactMethodMatch(declaredMethods[i], method)) {
+ matched = true;
+ break;
+ }
+ }
+ if (!matched) {
+ // TODO ignore Java accessibility
+ declaredMethods[i].setAccessible(true);
+ temp.add(declaredMethods[i]);
+
+ }
+ methods.addAll(temp);
+ temp.clear();
+ }
+ }
+ // evaluate class hierarchy - this is done last to track inherited methods
+ methods = getAllUniqueMethods(pClass.getSuperclass(), methods);
+ return methods;
+ }
+
+ /**
+ * Finds the closest matching field with the given name, that is, a field of the exact specified type or,
+ * alternately, of a supertype.
+ *
+ * @param name the name of the field
+ * @param type the field type
+ * @param fields the collection of fields to search
+ * @return the matching field or null if not found
+ * @throws NoSuchFieldException if no field found
+ */
+ public static Field findClosestMatchingField(String name, Class type, Set<Field> fields) {
+ Field candidate = null;
+ for (Field field : fields) {
+ if (field.getName().equals(name)) {
+ if (field.getType().equals(type)) {
+ return field; // exact match
+ } else if (field.getType().isAssignableFrom(type)
+ || (field.getType().isPrimitive() && primitiveAssignable(field.getType(), type))) {
+ // We could have the situation where a field parameter is a primitive and the demarshalled value is
+ // an object counterpart (e.g. Integer and int)
+ // @spec issue
+ // either an interface or super class, so keep a reference until
+ // we know there are no closer types
+ candidate = field;
+ }
+ }
+ }
+ if (candidate != null) {
+ return candidate;
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Finds the closest matching method with the given name, that is, a method taking the exact parameter types or,
+ * alternately, parameter supertypes.
+ *
+ * @param name the name of the method
+ * @param types the method parameter types
+ * @param methods the collection of methods to search
+ * @return the matching method or null if not found
+ * @throws NoSuchFieldException if no field found
+ */
+ public static Method findClosestMatchingMethod(String name, Class[] types, Set<Method> methods) {
+ if (types == null) {
+ types = EMPTY_CLASS_ARRY;
+ }
+ Method candidate = null;
+ for (Method method : methods) {
+ if (method.getName().equals(name) && method.getParameterTypes().length == types.length) {
+ Class[] params = method.getParameterTypes();
+ boolean disqualify = false;
+ boolean exactMatch = true;
+ for (int i = 0; i < params.length; i++) {
+ if (!params[i].equals(types[i]) && !params[i].isAssignableFrom(types[i])) {
+ // no match
+ disqualify = true;
+ exactMatch = false;
+ break;
+ } else if (!params[i].equals(types[i]) && params[i].isAssignableFrom(types[i])) {
+ // not exact match
+ exactMatch = false;
+ }
+ }
+ if (disqualify) {
+ continue;
+ } else if (exactMatch) {
+ return method;
+ } else {
+ candidate = method;
+ }
+ }
+ }
+ if (candidate != null) {
+ return candidate;
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Returns a field or method defined in the given class or its superclasses matching a literal name and parameter
+ * types <p/> This method can potentially be expensive as reflection information is not cached. It is assumed that
+ * this method will be used during a configuration phase.
+ *
+ * @param clazz the class to introspect
+ * @param propertName the literal name of the property (i.e. JavaBean conventions are not applied)
+ * @param paramTypes the parameter types for a method or null for fields or methods with no parameters
+ * @return the field, method or null
+ */
+ public static AccessibleObject getBeanProperty(Class clazz, String propertName, Class[] paramTypes) {
+
+ Set<Method> methods = getAllUniqueMethods(clazz);
+ for (Method method : methods) {
+ if (method.getName().equals(propertName)) {
+ Class[] types = method.getParameterTypes();
+ if (types.length == 0 && paramTypes == null) {
+ return method;
+ } else if (types.length != 0 && paramTypes == null) {
+ break;
+ } else if (types.length == paramTypes.length) {
+ for (int n = 0; n < types.length - 1; n++) {
+ if (!types[n].equals(paramTypes[n]) || !types[n].isAssignableFrom(paramTypes[n])) {
+ break;
+ }
+ }
+ return method;
+ }
+ }
+ }
+
+ Set<Field> fields = getAllFields(clazz);
+ for (Field field : fields) {
+ if (field.getName().equals(propertName)) {
+ return field;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Determines if two methods "match" - that is, they have the same method names and exact parameter types (one is
+ * not a supertype of the other)
+ */
+ public static boolean exactMethodMatch(Method method1, Method method2) {
+ if (!method1.getName().equals(method2.getName())) {
+ return false;
+ }
+ Class[] types1 = method1.getParameterTypes();
+ Class[] types2 = method2.getParameterTypes();
+ if (types1.length == 0 && types2.length == 0) {
+ return true;
+ } else if (types1.length == types2.length) {
+ for (int n = 0; n < types1.length; n++) {
+ if (!types1[n].equals(types2[n])) {
+ return false;
+ }
+ }
+ return true;
+ }
+ return false;
+ }
+
+ public static Constructor getDefaultConstructor(Class clazz) throws NoSuchMethodException {
+ return clazz.getConstructor((Class[]) null);
+ }
+
+ /**
+ * Loads a class corresponding to the class name using the current context class loader.
+ *
+ * @throws ClassNotFoundException if the class was not found on the classpath
+ */
+ public static Class loadClass(String pName) throws ClassNotFoundException {
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ return Class.forName(pName, true, loader);
+ }
+
+ /**
+ * Returns the simple name of a class - i.e. the class name devoid of its package qualifier
+ *
+ * @param implClass
+ * @return
+ */
+ public static String getBaseName(Class<?> implClass) {
+ String baseName = implClass.getName();
+ int lastDot = baseName.lastIndexOf('.');
+ if (lastDot != -1) {
+ baseName = baseName.substring(lastDot + 1);
+ }
+ return baseName;
+ }
+
+ public static boolean isImmutable(Class clazz) {
+ return (String.class == clazz || clazz.isPrimitive() || Number.class.isAssignableFrom(clazz)
+ || Boolean.class.isAssignableFrom(clazz) || Character.class.isAssignableFrom(clazz) || Byte.class
+ .isAssignableFrom(clazz));
+ }
+
+ /**
+ * Takes a property name and converts it to a getter method name according to JavaBean conventions. For example,
+ * property <code>foo<code> is returned as <code>getFoo</code>
+ */
+ public static String toGetter(String name) {
+ return "get" + name.toUpperCase().substring(0, 1) + name.substring(1);
+ }
+
+ /**
+ * Takes a setter or getter method name and converts it to a property name according to JavaBean conventions. For
+ * example, <code>setFoo(var)</code> is returned as property <code>foo<code>
+ */
+ public static String toPropertyName(String name) {
+ return name.substring(3, 4).toLowerCase() + name.substring(4);
+ }
+
+ /**
+ * Takes a property name and converts it to a setter method name according to JavaBean conventions. For example, the
+ * property <code>foo<code> is returned as <code>setFoo(var)</code>
+ */
+ public static String toSetter(String name) {
+ return "set" + name.toUpperCase().substring(0, 1) + name.substring(1);
+ }
+
+ /**
+ * Compares a two types, assuming one is a primitive, to dtermine if the other is its object counterpart
+ */
+ private static boolean primitiveAssignable(Class memberType, Class param) {
+ if (memberType == Integer.class) {
+ return (param == Integer.TYPE);
+ } else if (memberType == Double.class) {
+ return (param == Double.TYPE);
+ } else if (memberType == Float.class) {
+ return (param == Float.TYPE);
+ } else if (memberType == Short.class) {
+ return (param == Short.TYPE);
+ } else if (memberType == Character.class) {
+ return (param == Character.TYPE);
+ } else if (memberType == Boolean.class) {
+ return (param == Boolean.TYPE);
+ } else if (memberType == Byte.class) {
+ return (param == Byte.TYPE);
+ } else if (param == Integer.class) {
+ return (memberType == Integer.TYPE);
+ } else if (param == Double.class) {
+ return (memberType == Double.TYPE);
+ } else if (param == Float.class) {
+ return (memberType == Float.TYPE);
+ } else if (param == Short.class) {
+ return (memberType == Short.TYPE);
+ } else if (param == Character.class) {
+ return (memberType == Character.TYPE);
+ } else if (param == Boolean.class) {
+ return (memberType == Boolean.TYPE);
+ } else if (param == Byte.class) {
+ return (memberType == Byte.TYPE);
+ } else {
+ return false;
+ }
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/config/MissingResourceException.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/config/MissingResourceException.java
new file mode 100644
index 0000000000..7b40ccbefa
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/config/MissingResourceException.java
@@ -0,0 +1,43 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.config;
+
+/**
+ * Exception that indicates an expected resource could not be found.
+ *
+ * @version $Rev$ $Date$
+ */
+public class MissingResourceException extends ConfigurationException {
+ /**
+ * Constructor that indicates which resource could not be found.
+ * The supplied parameter is also returned as the message.
+ *
+ * @param resource the resource that could not be found
+ */
+ public MissingResourceException(String resource) {
+ super(resource);
+ }
+
+ /**
+ * Return the name of the expected resource.
+ *
+ * @return the name of the expected resource
+ */
+ public String getResource() {
+ return getMessage();
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/config/ModuleComponentConfigurationLoader.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/config/ModuleComponentConfigurationLoader.java
new file mode 100644
index 0000000000..a8e2718222
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/config/ModuleComponentConfigurationLoader.java
@@ -0,0 +1,74 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.config;
+
+import java.util.Collection;
+
+import org.apache.tuscany.model.assembly.ModuleComponent;
+
+/**
+ * Interface for loading configuration information from some external
+ * form into a Tuscany logical model.
+ *
+ * @version $Rev: 368822 $ $Date: 2006-01-13 10:54:38 -0800 (Fri, 13 Jan 2006) $
+ */
+public interface ModuleComponentConfigurationLoader {
+
+ /**
+ * Load a SCDL module component.
+ *
+ * @param name the name of the module component
+ * @param uri
+ * @return a new module component definition
+ * @throws ConfigurationException if there was a problem loading the module component.
+ */
+ ModuleComponent loadModuleComponent(String name, String uri) throws ConfigurationLoadException;
+
+ /**
+ * Load a System SCDL module component.
+ *
+ * @param name the name of the module component
+ * @param uri
+ * @return a new module component definition
+ * @throws ConfigurationException if there was a problem loading the module component.
+ */
+ ModuleComponent loadSystemModuleComponent(String name, String uri) throws ConfigurationLoadException;
+
+ /**
+ * Load a SCDL module component.
+ *
+ * @param name the name of the module component
+ * @param uri
+ * @param url
+ * @return a new module component definition
+ * @throws ConfigurationException if there was a problem loading the module component.
+ */
+ ModuleComponent loadModuleComponent(String name, String uri, String url) throws ConfigurationLoadException;
+
+ /**
+ * Load a SCDL module component.
+ *
+ * @param name the name of the module component
+ * @param uri
+ * @param url
+ * @param urls
+ * @return a new module component definition
+ * @throws ConfigurationException if there was a problem loading the module component.
+ */
+ ModuleComponent loadModuleComponent(String name, String uri, String url, Collection<String> urls) throws ConfigurationLoadException;
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/config/impl/Java5ComponentTypeIntrospector.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/config/impl/Java5ComponentTypeIntrospector.java
new file mode 100644
index 0000000000..8799969028
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/config/impl/Java5ComponentTypeIntrospector.java
@@ -0,0 +1,423 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.config.impl;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import org.osoa.sca.annotations.Callback;
+import org.osoa.sca.annotations.Remotable;
+
+import org.apache.tuscany.core.config.ComponentTypeIntrospector;
+import org.apache.tuscany.core.config.ConfigurationException;
+import org.apache.tuscany.core.config.JavaIntrospectionHelper;
+import org.apache.tuscany.model.assembly.AssemblyFactory;
+import org.apache.tuscany.model.assembly.ComponentType;
+import org.apache.tuscany.model.assembly.Multiplicity;
+import org.apache.tuscany.model.assembly.Property;
+import org.apache.tuscany.model.assembly.Reference;
+import org.apache.tuscany.model.assembly.Scope;
+import org.apache.tuscany.model.assembly.Service;
+import org.apache.tuscany.model.assembly.ServiceContract;
+import org.apache.tuscany.model.types.java.JavaServiceContract;
+
+/**
+ * Introspects Java annotation-based metata data
+ *
+ * @version $Rev$ $Date$
+ */
+public class Java5ComponentTypeIntrospector implements ComponentTypeIntrospector {
+ private final AssemblyFactory factory;
+
+ public Java5ComponentTypeIntrospector(AssemblyFactory factory) {
+ this.factory = factory;
+ }
+
+ /**
+ * Returns a component type for the given class
+ *
+ * @throws ConfigurationException
+ */
+ public ComponentType introspect(Class<?> implClass) throws ConfigurationException {
+ ComponentType compType = factory.createComponentType();
+ introspectServices(compType, implClass);
+ introspectAnnotatedMembers(compType, implClass);
+
+ // if implementation is not annotated and no annotated members were found, add public fields and setters
+ if (!implClass.isAnnotationPresent(org.osoa.sca.annotations.Service.class) && compType.getProperties().isEmpty()
+ && compType.getReferences().isEmpty()) {
+ introspectMembers(compType, implClass);
+ }
+
+ // FIXME scopes should be handled at the interface level
+ if (compType != null) {
+ Scope scope = getScope(implClass);
+ for (Iterator<Service> i = compType.getServices().iterator(); i.hasNext();) {
+ ServiceContract intf = i.next().getServiceContract();
+ if (intf != null)
+ intf.setScope(scope);
+ }
+ }
+
+ return compType;
+ }
+
+ /**
+ * Returns the scope for a given class
+ *
+ */
+ private static Scope getScope(Class<?> implClass) {
+ org.osoa.sca.annotations.Scope scope = implClass.getAnnotation(org.osoa.sca.annotations.Scope.class);
+ if (scope == null) {
+ // scope was not defined on the implementation class, look for annotated interfaces
+ Class<?>[] interfaces = implClass.getInterfaces();
+ for (int i = 0; i < interfaces.length; i++) {
+ scope = interfaces[i].getAnnotation(org.osoa.sca.annotations.Scope.class);
+ }
+ }
+ if (scope == null) {
+ return Scope.INSTANCE;
+ }
+
+ if ("MODULE".equalsIgnoreCase(scope.value())) {
+ return (Scope.MODULE);
+ } else if ("SESSION".equalsIgnoreCase(scope.value())) {
+ return (Scope.SESSION);
+ } else if ("REQUEST".equalsIgnoreCase(scope.value())) {
+ return (Scope.REQUEST);
+ } else {
+ return (Scope.INSTANCE);
+ }
+ }
+
+ /**
+ * Adds the supported services for a component implementation type to its component type
+ *
+ * @param compType the component type being generated
+ * @param implClass the component implementation type class
+ * @throws ConfigurationException
+ */
+ protected void introspectServices(ComponentType compType, Class<?> implClass) throws ConfigurationException {
+ List<Service> services = compType.getServices();
+ assert services.isEmpty() : "componentType already has services defined";
+
+ // add services defined in an @Service annotation
+ org.osoa.sca.annotations.Service serviceAnnotation = implClass.getAnnotation(org.osoa.sca.annotations.Service.class);
+ if (serviceAnnotation != null) {
+ Class<?>[] interfaces = serviceAnnotation.interfaces();
+ Class<?> value = serviceAnnotation.value();
+ if (interfaces.length > 0) {
+ if (!Void.class.equals(value)) {
+ throw new IllegalArgumentException("Both interfaces and value specified in @Service on "
+ + implClass.getName());
+ }
+ for (int i = 0; i < interfaces.length; i++) {
+ Class<?> intf = interfaces[i];
+ addService(services, intf);
+ }
+ return;
+ } else if (!Void.class.equals(value)) {
+ addService(services, value);
+ return;
+ }
+ }
+
+ // no @Service annotation, add all implemented interfaces with an @Remotable annotation
+ Class[] interfaces = implClass.getInterfaces();
+ for (int i = 0; i < interfaces.length; i++) {
+ Class<?> intf = interfaces[i];
+ if (intf.isAnnotationPresent(Remotable.class)) {
+ addService(services, intf);
+ }
+ }
+
+ // if no Remotable interfaces were specified, the class itself is the service
+ if (services.isEmpty()) {
+ addService(services, implClass);
+ }
+ }
+
+ /**
+ * Recursively adds supported services to a component type by walking the class hierarchy
+ *
+ * @throws ConfigurationException
+ */
+ protected void addService(List<Service> services, Class<?> serviceClass) throws ConfigurationException {
+ JavaServiceContract javaInterface = factory.createJavaServiceContract();
+ javaInterface.setInterface(serviceClass);
+ Callback callback = serviceClass.getAnnotation(Callback.class);
+ if (callback != null && !Void.class.equals(callback.value())) {
+ javaInterface.setCallbackInterface(callback.value());
+ }
+
+ String name = JavaIntrospectionHelper.getBaseName(serviceClass);
+ Service service = factory.createService();
+ service.setName(name);
+ service.setServiceContract(javaInterface);
+ services.add(service);
+ }
+
+ /**
+ * Root method for determining public field and method metadata
+ *
+ * @throws ConfigurationException
+ */
+ protected void introspectAnnotatedMembers(ComponentType compType, Class<?> implClass) throws ConfigurationException {
+
+ introspectPublicFields(compType, implClass);
+ introspectPrivateFields(compType, implClass);
+
+ introspectPublicMethods(compType, implClass);
+ introspectPrivateMethods(compType, implClass);
+ }
+
+ /**
+ * Introspects metdata for all public fields and methods for a class hierarchy
+ *
+ * @throws ConfigurationException
+ */
+ protected void introspectMembers(ComponentType compType, Class<?> implClass) throws ConfigurationException {
+ List<Property> properties = compType.getProperties();
+ List<Reference> references = compType.getReferences();
+
+ // inspect public fields from class and all superclasses
+ Field[] fields = implClass.getFields();
+ for (int i = 0; i < fields.length; i++) {
+ Field field = fields[i];
+ if (field.getType().isAnnotationPresent(Remotable.class)) {
+ addReference(references, field);
+ } else {
+ addProperty(properties, field);
+ }
+ }
+
+ // add public methods from class and all superclasses
+ Method[] methods = implClass.getMethods();
+ for (int i = 0; i < methods.length; i++) {
+ Method method = methods[i];
+ if (Void.class.equals(method.getReturnType()) && method.getName().startsWith("set")
+ && method.getParameterTypes().length == 1
+ && !method.getParameterTypes()[0].isAnnotationPresent(Remotable.class)) {
+ String name = method.getName();
+ name = Character.toLowerCase(name.charAt(3)) + name.substring(4);
+ Class<?> type = method.getParameterTypes()[0];
+ if (type.isAnnotationPresent(Remotable.class)) {
+ addReference(references, name, type, false);
+ } else {
+ addProperty(properties, name, type, false);
+ }
+ }
+ }
+ }
+
+ private void introspectPublicFields(ComponentType compType, Class<?> implClass) throws ConfigurationException {
+ List<Property> properties = compType.getProperties();
+ List<Reference> references = compType.getReferences();
+
+ // inspect public fields from class and all superclasses
+ Field[] fields = implClass.getFields();
+ for (int i = 0; i < fields.length; i++) {
+ Field field = fields[i];
+ if (field.isAnnotationPresent(org.osoa.sca.annotations.Property.class)) {
+ addProperty(properties, field);
+ } else if (field.isAnnotationPresent(org.osoa.sca.annotations.Reference.class)) {
+ addReference(references, field);
+ }
+ }
+ }
+
+ private void introspectPrivateFields(ComponentType compType, Class<?> implClass) throws ConfigurationException {
+ List<Property> properties = compType.getProperties();
+ List<Reference> references = compType.getReferences();
+
+ // inspect private fields declared in class
+ Field[] fields = implClass.getDeclaredFields();
+ for (int i = 0; i < fields.length; i++) {
+ Field field = fields[i];
+ if (!Modifier.isPrivate(field.getModifiers())) {
+ continue;
+ }
+ if (field.isAnnotationPresent(org.osoa.sca.annotations.Property.class)) {
+ addProperty(properties, field);
+ } else if (field.isAnnotationPresent(org.osoa.sca.annotations.Reference.class)) {
+ addReference(references, field);
+ }
+ }
+ }
+
+ private void introspectPublicMethods(ComponentType compType, Class<?> implClass) throws ConfigurationException {
+ List<Property> properties = compType.getProperties();
+ List<Reference> references = compType.getReferences();
+
+ // add public methods from class and all superclasses
+ Method[] methods = implClass.getMethods();
+ for (int i = 0; i < methods.length; i++) {
+ Method method = methods[i];
+ if (method.isAnnotationPresent(org.osoa.sca.annotations.Property.class)) {
+ addProperty(properties, method);
+ } else if (method.isAnnotationPresent(org.osoa.sca.annotations.Reference.class)) {
+ addReference(references, method);
+ }
+ }
+ }
+
+ private void introspectPrivateMethods(ComponentType compType, Class<?> implClass) throws ConfigurationException {
+ List<Property> properties = compType.getProperties();
+ List<Reference> references = compType.getReferences();
+
+ // add private methods declared on class
+ Method[] methods = implClass.getDeclaredMethods();
+ for (int i = 0; i < methods.length; i++) {
+ Method method = methods[i];
+ if (!Modifier.isPrivate(method.getModifiers())) {
+ continue;
+ }
+ if (method.isAnnotationPresent(org.osoa.sca.annotations.Property.class)) {
+ addProperty(properties, method);
+ } else if (method.isAnnotationPresent(org.osoa.sca.annotations.Reference.class)) {
+ addReference(references, method);
+ }
+ }
+ }
+
+ protected void addProperty(List<Property> properties, Field field) throws ConfigurationException {
+ String name;
+ boolean required;
+ org.osoa.sca.annotations.Property annotation = field.getAnnotation(org.osoa.sca.annotations.Property.class);
+ if (annotation != null) {
+ name = annotation.name();
+ if (name.length() == 0) {
+ name = field.getName();
+ }
+ required = annotation.required();
+ } else {
+ name = field.getName();
+ required = false;
+ }
+ addProperty(properties, name, field.getType(), required);
+ }
+
+ protected void addProperty(List<Property> properties, Method method) throws ConfigurationException {
+ if (!Void.class.equals(method.getReturnType())) {
+ throw new ConfigurationException("Property setter method does not return void: " + method.toString());
+ }
+ Class<?>[] params = method.getParameterTypes();
+ if (params.length != 1) {
+ throw new ConfigurationException("Property setter method does not have 1 parameter: " + method.toString());
+ }
+
+ String name;
+ boolean required;
+ org.osoa.sca.annotations.Property annotation = method.getAnnotation(org.osoa.sca.annotations.Property.class);
+ if (annotation != null) {
+ name = annotation.name();
+ required = annotation.required();
+ } else {
+ name = "";
+ required = false;
+ }
+ if (name.length() == 0) {
+ name = method.getName();
+ if (name.length() > 3 && name.startsWith("set")) {
+ name = Character.toLowerCase(name.charAt(3)) + name.substring(4);
+ }
+ }
+ addProperty(properties, name, params[0], required);
+ }
+
+ protected void addProperty(List<Property> properties, String name, Class<?> type, boolean required)
+ throws ConfigurationException {
+ Property prop = factory.createProperty();
+ prop.setName(name);
+ prop.setType(type);
+ prop.setRequired(required);
+
+ // a java.util.Map is not a "many"
+ prop.setMany(type.isArray() || Collection.class.isAssignableFrom(type));
+
+ // todo how is the default specified using annotations?
+ prop.setDefaultValue(null);
+
+ properties.add(prop);
+ }
+
+ protected void addReference(List<Reference> references, Field field) throws ConfigurationException {
+ String name;
+ boolean required;
+ org.osoa.sca.annotations.Reference annotation = field.getAnnotation(org.osoa.sca.annotations.Reference.class);
+ if (annotation != null) {
+ name = annotation.name();
+ if (name.length() == 0) {
+ name = field.getName();
+ }
+ required = annotation.required();
+ } else {
+ name = field.getName();
+ required = false;
+ }
+ addReference(references, name, field.getType(), required);
+ }
+
+ protected void addReference(List<Reference> references, Method method) throws ConfigurationException {
+ if (!Void.TYPE.equals(method.getReturnType())) {
+ throw new ConfigurationException("Reference setter method does not return void: " + method.toString());
+ }
+ Class<?>[] params = method.getParameterTypes();
+ if (params.length != 1) {
+ throw new ConfigurationException("Reference setter method does not have 1 parameter: " + method.toString());
+ }
+
+ String name;
+ boolean required;
+ org.osoa.sca.annotations.Reference annotation = method.getAnnotation(org.osoa.sca.annotations.Reference.class);
+ if (annotation != null) {
+ name = annotation.name();
+ required = annotation.required();
+ } else {
+ name = "";
+ required = false;
+ }
+ if (name.length() == 0) {
+ name = method.getName();
+ if (name.length() > 3 && name.startsWith("set")) {
+ name = Character.toLowerCase(name.charAt(3)) + name.substring(4);
+ }
+ }
+ addReference(references, name, params[0], required);
+ }
+
+ protected void addReference(List<Reference> references, String name, Class<?> type, boolean required)
+ throws ConfigurationException {
+ Reference ref = factory.createReference();
+ ref.setName(name);
+ boolean many = type.isArray() || Collection.class.isAssignableFrom(type);
+ Multiplicity multiplicity;
+ if (required)
+ multiplicity = many ? Multiplicity.ONE_N : Multiplicity.ONE_ONE;
+ else
+ multiplicity = many ? Multiplicity.ZERO_N : Multiplicity.ZERO_ONE;
+ ref.setMultiplicity(multiplicity);
+ ServiceContract javaInterface = factory.createJavaServiceContract();
+ javaInterface.setInterface(type);
+ ref.setServiceContract(javaInterface);
+ references.add(ref);
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/config/impl/ModuleComponentConfigurationLoaderImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/config/impl/ModuleComponentConfigurationLoaderImpl.java
new file mode 100644
index 0000000000..bed4b0ac40
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/config/impl/ModuleComponentConfigurationLoaderImpl.java
@@ -0,0 +1,142 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.config.impl;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.tuscany.common.resource.ResourceLoader;
+import org.apache.tuscany.core.config.ConfigurationLoadException;
+import org.apache.tuscany.core.config.ModuleComponentConfigurationLoader;
+import org.apache.tuscany.model.assembly.AssemblyFactory;
+import org.apache.tuscany.model.assembly.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.Module;
+import org.apache.tuscany.model.assembly.ModuleComponent;
+import org.apache.tuscany.model.assembly.ModuleFragment;
+import org.apache.tuscany.model.assembly.loader.AssemblyModelLoader;
+
+/**
+ */
+public class ModuleComponentConfigurationLoaderImpl implements ModuleComponentConfigurationLoader {
+
+ private static final String SCA_MODULE_FILE_NAME = "sca.module";
+ //FIXME can fragments have a variable prefix name?
+ private static final String SCA_FRAGMENT_FILE_NAME = "sca.fragment";
+ private static final String SYSTEM_MODULE_FILE_NAME = "system.module";
+ //FIXME can fragments have a variable prefix name?
+ private static final String SYSTEM_FRAGMENT_FILE_NAME = "system.fragment";
+
+ private AssemblyModelContext modelContext;
+ private ResourceLoader resourceLoader;
+ private AssemblyFactory assemblyFactory;
+ private AssemblyModelLoader modelLoader;
+
+ /**
+ * Constructor
+ */
+ public ModuleComponentConfigurationLoaderImpl(AssemblyModelContext modelContext) {
+ this.modelContext=modelContext;
+ this.modelLoader=this.modelContext.getAssemblyLoader();
+ this.assemblyFactory=this.modelContext.getAssemblyFactory();
+ this.resourceLoader=this.modelContext.getApplicationResourceLoader();
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.loader.AssemblyModelLoader#loadModuleComponent(java.lang.String, java.lang.String)
+ */
+ public ModuleComponent loadSystemModuleComponent(String name, String uri) throws ConfigurationLoadException {
+ return loadModuleComponent(SYSTEM_MODULE_FILE_NAME, SYSTEM_FRAGMENT_FILE_NAME, name, uri);
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.loader.AssemblyModelLoader#loadModuleComponent(java.lang.String, java.lang.String)
+ */
+ public ModuleComponent loadModuleComponent(String name, String uri) throws ConfigurationLoadException {
+ return loadModuleComponent(SCA_MODULE_FILE_NAME, SCA_FRAGMENT_FILE_NAME, name, uri);
+ }
+
+ /**
+ * Load a module component.
+ */
+ private ModuleComponent loadModuleComponent(String moduleFileName, String fragmentFileName, String name, String uri) throws ConfigurationLoadException {
+
+ // Load the sca.module file
+ URL moduleUrl;
+ try {
+ moduleUrl = resourceLoader.getResource(moduleFileName);
+ } catch (IOException e) {
+ throw new ConfigurationLoadException(moduleFileName, e);
+ }
+ if (moduleUrl == null) {
+ throw new ConfigurationLoadException(moduleFileName);
+ }
+ String moduleUri=moduleUrl.toString();
+
+ // Load the sca.fragment files
+ Iterator<URL> i;
+ try {
+ i = resourceLoader.getAllResources(fragmentFileName);
+ } catch (IOException e) {
+ throw new ConfigurationLoadException(fragmentFileName, e);
+ }
+ List<String> moduleFragmentUris=new ArrayList<String>();
+ for (; i.hasNext(); ) {
+ URL url=i.next();
+ moduleFragmentUris.add(url.toString());
+ }
+
+ return loadModuleComponent(name, uri, moduleUri, moduleFragmentUris);
+ }
+
+ /**
+ * @see org.apache.tuscany.core.config.ModuleComponentConfigurationLoader#loadModuleComponent(java.lang.String, java.lang.String, java.lang.String)
+ */
+ public ModuleComponent loadModuleComponent(String name, String uri, String url) throws ConfigurationLoadException {
+ return loadModuleComponent( name, uri, url, (Collection)null);
+ }
+
+ /**
+ * @see org.apache.tuscany.core.config.ModuleComponentConfigurationLoader#loadModuleComponent(java.lang.String, java.lang.String, java.lang.String, java.util.Collection)
+ */
+ public ModuleComponent loadModuleComponent(String name, String uri, String moduleUri, Collection<String> moduleFragmentUris) throws ConfigurationLoadException {
+
+ // Load the module file
+ Module module=modelLoader.loadModule(moduleUri);
+
+ // Load the sca.fragment files
+ if (moduleFragmentUris!=null) {
+ for (String moduleFragmentUri : moduleFragmentUris) {
+ ModuleFragment moduleFragment=modelLoader.loadModuleFragment(moduleFragmentUri);
+ module.getModuleFragments().add(moduleFragment);
+ }
+ }
+
+ // Create the module component
+ ModuleComponent moduleComponent=assemblyFactory.createModuleComponent();
+ moduleComponent.setName(name);
+ moduleComponent.setURI(uri);
+ moduleComponent.setComponentImplementation(module);
+ moduleComponent.initialize(modelContext);
+
+ return moduleComponent;
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/AbstractContext.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/AbstractContext.java
new file mode 100644
index 0000000000..c1abcb3c03
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/AbstractContext.java
@@ -0,0 +1,89 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.context;
+
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+/**
+ * Functionality common to all <code>Context<code> implementations
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class AbstractContext implements Context {
+
+ public AbstractContext() {
+ }
+
+ public AbstractContext(String name) {
+ this.name = name;
+ }
+
+ protected String name;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ protected int lifecycleState = UNINITIALIZED;
+
+ public int getLifecycleState() {
+ return lifecycleState;
+ }
+
+ public void setLifecycleState(int state) {
+ lifecycleState = state;
+ }
+
+ protected List<LifecycleEventListener> contextListener = new CopyOnWriteArrayList();
+
+ public void addContextListener(LifecycleEventListener listener) {
+ contextListener.add(listener);
+ }
+
+ public void removeContextListener(LifecycleEventListener listener) {
+ contextListener.remove(listener);
+ }
+
+ public String toString() {
+ switch (lifecycleState) {
+ case (CONFIG_ERROR):
+ return "Context [" + name + "] in state [CONFIG_ERROR]";
+ case (ERROR):
+ return "Context [" + name + "] in state [ERROR]";
+ case (INITIALIZING):
+ return "Context [" + name + "] in state [INITIALIZING]";
+ case (INITIALIZED):
+ return "Context [" + name + "] in state [INITIALIZED]";
+ case (RUNNING):
+ return "Context [" + name + "] in state [RUNNING]";
+ case (STOPPING):
+ return "Context [" + name + "] in state [STOPPING]";
+ case (STOPPED):
+ return "Context [" + name + "] in state [STOPPED]";
+ case (UNINITIALIZED):
+ return "Context [" + name + "] in state [UNINITIALIZED]";
+ default:
+ return "Context [" + name + "] in state [UNKNOWN]";
+ }
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/AggregateContext.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/AggregateContext.java
new file mode 100644
index 0000000000..0fab87358f
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/AggregateContext.java
@@ -0,0 +1,85 @@
+package org.apache.tuscany.core.context;
+
+import java.util.List;
+
+import org.apache.tuscany.core.config.ConfigurationException;
+import org.apache.tuscany.model.assembly.Aggregate;
+import org.apache.tuscany.model.assembly.Extensible;
+import org.apache.tuscany.model.assembly.AggregatePart;
+
+/**
+ * A context which contains child component contexts.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface AggregateContext extends InstanceContext {
+
+ /**
+ * Propagates an event to registered listeners. All lifecycle events will be propagated to children in the order
+ * that they were registered. Listeners are expected to be well-behaved and if an exception is thrown the
+ * notification process will be aborted.
+ *
+ * @param pEventType the type of event. Basic types are defined in {@link EventContext}
+ * @param pMessage the message associated with the event or null
+ * @throws EventException if an error occurs while sending the event
+ */
+ public void fireEvent(int pEventType, Object pMessage) throws EventException;
+
+ /**
+ * Registers a listener to receive notifications for the context
+ *
+ * @throws ContextRuntimeException if an error occurs during registration
+ */
+ public void registerListener(RuntimeEventListener listener) throws ContextRuntimeException;
+
+ /**
+ * Adds runtime artifacts represented by the set of model objects to the aggregate context by merging them with
+ * existing artifacts. Implementing classes may support only a subset of {@link AggregatePart} types.
+ *
+ * @see org.apache.tuscany.model.assembly.Component
+ * @see org.apache.tuscany.model.assembly.ModuleComponent
+ * @see org.apache.tuscany.model.assembly.SimpleComponent
+ * @see org.apache.tuscany.model.assembly.EntryPoint
+ * @see org.apache.tuscany.model.assembly.ExternalService
+ */
+ public void registerModelObjects(List<Extensible> models) throws ConfigurationException;
+
+ /**
+ * Adds a runtime artifact represented by the model object to the aggregate context by merging it with existing
+ * artifacts. Implementing classes may support only a subset of {@link AggregatePart} types.
+ *
+ * @see org.apache.tuscany.model.assembly.Component
+ * @see org.apache.tuscany.model.assembly.ModuleComponent
+ * @see org.apache.tuscany.model.assembly.SimpleComponent
+ * @see org.apache.tuscany.model.assembly.EntryPoint
+ * @see org.apache.tuscany.model.assembly.ExternalService
+ */
+ public void registerModelObject(Extensible model) throws ConfigurationException;
+
+ /**
+ * Returns the child context associated with a given name
+ */
+ public InstanceContext getContext(String name);
+
+ /**
+ * Returns the parent context, or null if the context does not have one
+ */
+ public AggregateContext getParent();
+
+ /**
+ * Intended for internal use by the runtime, returns an implementation instance for the given context name, which
+ * may be a compound component/service form. Unlike {@link InstanceContext#getInstance(QualifiedName)}, which for aggregate contexts only returns
+ * entry point proxies, this method will return any type of contained implementation instance.
+ *
+ * @throws TargetException if there was an error returning the instance
+ */
+ public Object locateInstance(String name) throws TargetException;
+
+ /**
+ * Returns the aggregate managed by this aggregate context
+ * @return
+ */
+ @Deprecated
+ public Aggregate getAggregate();
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/AutowireContext.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/AutowireContext.java
new file mode 100644
index 0000000000..5f3973f358
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/AutowireContext.java
@@ -0,0 +1,35 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.context;
+
+/**
+ * A specialization of an AggregateContext that is able to automatically resolve references
+ * for its children using EntryPoint or Service interfaces exposed by it or, recursively, any
+ * of it parents.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface AutowireContext extends AggregateContext {
+
+ /**
+ * Returns an reference to the requested service.
+ *
+ * @param instanceInterface the type of service being requested
+ * @return a reference to the requested service or null if none can be found
+ * @throws AutowireResolutionException if an error occurs attempting to resolve an autowire
+ */
+ <T> T resolveInstance(Class<T> instanceInterface) throws AutowireResolutionException;
+
+ // todo add additional methods that allow other qualifications to be supplied
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/AutowireResolutionException.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/AutowireResolutionException.java
new file mode 100644
index 0000000000..4da4206a94
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/AutowireResolutionException.java
@@ -0,0 +1,40 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.context;
+
+/**
+ * Denotes an exception while resolving an automatic wire
+ *
+ * @version $Rev$ $Date$
+ */
+public class AutowireResolutionException extends TargetException {
+
+ public AutowireResolutionException() {
+ super();
+ }
+
+ public AutowireResolutionException(String message) {
+ super(message);
+ }
+
+ public AutowireResolutionException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public AutowireResolutionException(Throwable cause) {
+ super(cause);
+ }
+
+}
+
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/ConfigurationContext.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/ConfigurationContext.java
new file mode 100644
index 0000000000..a57ed03ffd
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/ConfigurationContext.java
@@ -0,0 +1,66 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.context;
+
+import org.apache.tuscany.core.builder.BuilderConfigException;
+import org.apache.tuscany.core.config.ConfigurationException;
+import org.apache.tuscany.core.invocation.spi.ProxyFactory;
+import org.apache.tuscany.model.assembly.Extensible;
+
+/**
+ * Offers configuration services in the runtime. A ConfigurationContext is able to configure a model and then build the
+ * runtime representation corresponding to that model in the live system. <p/> Configuration contexts will typically be
+ * hierarchical, delegating to their parent <b>after</b> performing an operation. The parent ConfigurationContext will
+ * typically be injected into an implementation of this interface during registration.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ConfigurationContext {
+
+ /**
+ * Adds additional configuration information to a model object.
+ *
+ * @param model the model object to be configured
+ * @throws ConfigurationException
+ */
+ public void configure(Extensible model) throws ConfigurationException;
+
+ /**
+ * Decorates the supplied model object with a {@link org.apache.tuscany.core.builder.RuntimeConfiguration} that can
+ * be used to create the runtime context corresponding to the model.
+ *
+ * @param parent an AggregrateContext that will ultimately become the parent of the runtime context
+ * @param model the model object that defines the configuration to be built
+ * @throws BuilderConfigException
+ * @see org.apache.tuscany.core.builder.RuntimeConfiguration
+ */
+ public void build(AggregateContext parent, Extensible model) throws BuilderConfigException;
+
+ /**
+ * Constructs a wire from a source proxy factory to a corresponding target, potentially performing optimizations
+ *
+ * @param sourceFactory the proxy factory that will be used to create the injected proxy for a reference
+ * @param targetFactory the proxy factory that contains the invocation chains for the target side of the wire
+ * @param targetType the {@link org.apache.tuscany.core.builder.RuntimeConfiguration} implementation type for the
+ * wire target
+ * @param downScope whether the source is a shorter lived scope than the target. Used in optimization.
+ * @param targetScopeContext the scope context of the target service
+ * @throws BuilderConfigException
+ */
+ public void wire(ProxyFactory sourceFactory, ProxyFactory targetFactory, Class targetType, boolean downScope,
+ ScopeContext targetScopeContext) throws BuilderConfigException;
+
+ public void wire(ProxyFactory targetFactory, Class targetType, ScopeContext targetScopeContext) throws BuilderConfigException;
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/Context.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/Context.java
new file mode 100644
index 0000000000..2eb70e8711
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/Context.java
@@ -0,0 +1,106 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.context;
+
+/**
+ * An entity that provides an execution context for a runtime artifact
+ *
+ * @version $Rev$ $Date$
+ */
+public interface Context {
+
+ /* A configuration error state */
+ public static final int CONFIG_ERROR = -1;
+
+ /* Has not been initialized */
+ public static final int UNINITIALIZED = 0;
+
+ /* In the process of being configured and initialized */
+ public static final int INITIALIZING = 1;
+
+ /* Instantiated and configured */
+ public static final int INITIALIZED = 2;
+
+ /* Configured and initialized */
+ public static final int RUNNING = 4;
+
+ /* In the process of being shutdown */
+ public static final int STOPPING = 5;
+
+ /* Has been shutdown and removed from the module */
+ public static final int STOPPED = 6;
+
+ /* In an error state */
+ public static final int ERROR = 7;
+
+ /**
+ * Returns the name of the context
+ */
+ public String getName();
+
+ /**
+ * Sets the name of the context
+ */
+ public void setName(String name);
+
+ /**
+ * Returns the lifecycle state
+ *
+ * @see #UNINITIALIZED
+ * @see #INITIALIZING
+ * @see #INITIALIZED
+ * @see #RUNNING
+ * @see #STOPPING
+ * @see #STOPPED
+ */
+ public int getLifecycleState();
+
+ /**
+ * Sets the lifecycle state
+ *
+ * @see #UNINITIALIZED
+ * @see #INITIALIZING
+ * @see #INITIALIZED
+ * @see #RUNNING
+ * @see #STOPPING
+ * @see #STOPPED
+ */
+ public void setLifecycleState(int state);
+
+ /**
+ * Starts the container
+ *
+ * @throws CoreRuntimeException
+ */
+ public void start() throws CoreRuntimeException;
+
+ /**
+ * Stops the container
+ *
+ * @throws CoreRuntimeException
+ */
+ public void stop() throws CoreRuntimeException;
+
+ /**
+ * Registers a listener for context events
+ */
+ public void addContextListener(LifecycleEventListener listener);
+
+ /**
+ * Deregisters a context event listener
+ */
+ public void removeContextListener(LifecycleEventListener listener);
+
+}
+
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/ContextInitException.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/ContextInitException.java
new file mode 100644
index 0000000000..e024a98b0e
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/ContextInitException.java
@@ -0,0 +1,43 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.context;
+
+/**
+ * Denotes an error encountered while initializing an instance context
+ *
+ * @version $Rev$ $Date$
+ */
+public class ContextInitException extends ContextRuntimeException {
+
+ public ContextInitException() {
+ super();
+ }
+
+ public ContextInitException(String message) {
+ super(message);
+ }
+
+ public ContextInitException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public ContextInitException(Throwable cause) {
+ super(cause);
+ }
+
+}
+
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/ContextRuntimeException.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/ContextRuntimeException.java
new file mode 100644
index 0000000000..0d35f145dc
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/ContextRuntimeException.java
@@ -0,0 +1,39 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.context;
+
+/**
+ * An unchecked exception encountered by an {@link org.apache.tuscany.core.context.Context}
+ *
+ * @version $Rev$ $Date$
+ */
+public class ContextRuntimeException extends CoreRuntimeException {
+
+ public ContextRuntimeException() {
+ super();
+ }
+
+ public ContextRuntimeException(String message) {
+ super(message);
+ }
+
+ public ContextRuntimeException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public ContextRuntimeException(Throwable cause) {
+ super(cause);
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/CoreRuntimeException.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/CoreRuntimeException.java
new file mode 100644
index 0000000000..a46d35c22c
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/CoreRuntimeException.java
@@ -0,0 +1,27 @@
+package org.apache.tuscany.core.context;
+
+import org.apache.tuscany.common.TuscanyRuntimeException;
+
+/**
+ * The root exception for the runtime package. Exceptions occurring in the runtime are generally non-recoverable
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class CoreRuntimeException extends TuscanyRuntimeException {
+
+ public CoreRuntimeException() {
+ super();
+ }
+
+ public CoreRuntimeException(String message) {
+ super(message);
+ }
+
+ public CoreRuntimeException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public CoreRuntimeException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/DuplicateNameException.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/DuplicateNameException.java
new file mode 100644
index 0000000000..81a334d3c8
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/DuplicateNameException.java
@@ -0,0 +1,39 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.context;
+
+/**
+ * Denotes an attempt to add a context with a name equal to an existing context
+ *
+ * @version $Rev$ $Date$
+ */
+public class DuplicateNameException extends ContextRuntimeException {
+
+ public DuplicateNameException() {
+ super();
+ }
+
+ public DuplicateNameException(String message) {
+ super(message);
+ }
+
+ public DuplicateNameException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public DuplicateNameException(Throwable cause) {
+ super(cause);
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/EntryPointContext.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/EntryPointContext.java
new file mode 100644
index 0000000000..aef2840f9a
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/EntryPointContext.java
@@ -0,0 +1,57 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.context;
+
+/**
+ * The runtime artifact representing an entry point, <code>EntryPointContext</code> manages invocation handler
+ * instances that expose service operations offered by a component in the parent aggregate. The invocation handler
+ * instance is responsible for dispatching the request down an invocation chain to the target instance. The invocation
+ * chain may contain {@link org.apache.tuscany.core.invocation.Interceptor}s and
+ * {@link org.apache.tuscany.core.invocation.MessageHandler}s that implement policies or perform mediations on the
+ * invocation.
+ * <p>
+ * Entry point contexts are used by transport binding artifacts to invoke an operation on a service. The transport
+ * binding uses an {@link java.lang.reflect.InvocationHandler} instance obtained from the <code>EntryPointContext</code>
+ * to perform the invocation as in:
+ *
+ * <pre>
+ * AggregateContext aggregateContext = ...
+ * EntryPointContext ctx = (EntryPointContext) aggregateContext.getContext(&quot;source&quot;);
+ * Assert.assertNotNull(ctx);
+ * InvocationHandler handler = (InvocationHandler) ctx.getImplementationInstance();
+ * Object response = handler.invoke(null, operation, new Object[] { param });
+ * </pre>
+ *
+ * The <code>Proxy</code> instance passed to <code>InvocationHandler</code> may be null as the client is invoking
+ * directly on the handler.
+ * <p>
+ * Alternatively, the following will return a proxy implementing the service interface exposed by the entry point:
+ *
+ * <pre>
+ * AggregateContext aggregateContext = ...
+ * EntryPointContext ctx = (EntryPointContext) aggregateContext.getContext(&quot;source&quot;);
+ * Assert.assertNotNull(ctx);
+ * HelloWorld proxy = (Helloworld) ctx.getInstance(null); // service name not necessary
+ * </pre>
+ *
+ * The proxy returned will be backed by the entry point invocation chain.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface EntryPointContext extends InstanceContext {
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/EventContext.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/EventContext.java
new file mode 100644
index 0000000000..9f7c98200a
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/EventContext.java
@@ -0,0 +1,66 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.context;
+
+/**
+ * Implementations are responsible for tracking scope keys associated with the current request.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface EventContext {
+
+ /* An event type fired when a request is first serviced in the runtime */
+ public static final int REQUEST_START = 1;
+
+ /* An event type fired when the runtime finishes servicing a request */
+ public static final int REQUEST_END = 2;
+
+ /* An event type fired when a session is set for the current context */
+ public static final int SESSION_NOTIFY = 3;
+
+ /* An event type fired when a session is invalidated in the runtime */
+ public static final int SESSION_END = 4;
+
+ /* An event type fired when the current deployment unit is initialized */
+ public static final int MODULE_START = 5;
+
+ /* An event type fired when the current deployment unit is quiesced */
+ public static final int MODULE_STOP = 6;
+
+ public static final int SYSTEM_START = 7;
+
+ public static final int SYSTEM_STOP = 8;
+
+ /* An identifier type associated with an HTTP session */
+ public static final Object HTTP_SESSION = new Object();
+
+ /**
+ * Returns the unique key for the given identifier, e.g a session
+ */
+ public Object getIdentifier(Object type);
+
+ /**
+ * Sets the unique key for the given identifier, e.g a session
+ */
+ public void setIdentifier(Object type, Object identifier);
+
+ /**
+ * Clears the unique key for the given identifier, e.g a session
+ */
+ public void clearIdentifier(Object type);
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/EventException.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/EventException.java
new file mode 100644
index 0000000000..aaf26aee69
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/EventException.java
@@ -0,0 +1,43 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.context;
+
+/**
+ * Denotes an error encountered while firing a module event
+ *
+ * @version $Rev$ $Date$
+ */
+public class EventException extends CoreRuntimeException {
+
+ public EventException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public EventException(String message) {
+ super(message);
+ }
+
+ public EventException(Throwable cause) {
+ super(cause);
+ }
+
+ public EventException() {
+ super();
+ }
+
+}
+
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/ExternalServiceContext.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/ExternalServiceContext.java
new file mode 100644
index 0000000000..298246dc81
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/ExternalServiceContext.java
@@ -0,0 +1,24 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.context;
+
+/**
+ * Manages an external service
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ExternalServiceContext extends InstanceContext {
+
+}
+
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/InstanceContext.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/InstanceContext.java
new file mode 100644
index 0000000000..473762b6b0
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/InstanceContext.java
@@ -0,0 +1,75 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.context;
+
+/**
+ * Manages instances of a runtime artifact. An <code>InstanceContext</code> may contain child contexts which
+ * themselves manage implementation instances or it may be a leaf context.
+ *
+ * @see org.apache.tuscany.core.context.SimpleComponentContext
+ * @see org.apache.tuscany.core.context.AggregateContext
+ * @see org.apache.tuscany.core.context.EntryPointContext
+ * @see org.apache.tuscany.core.context.ExternalServiceContext
+ *
+ * @version $Rev$ $Date$
+ */
+public interface InstanceContext extends Context {
+
+ /**
+ * Returns the instance associated with the requested name, which may be in a simple or compound form. Simple (i.e.
+ * leaf) contexts will return an instance associated with the service name part of the compound name, which may be
+ * null.
+ * <p>
+ * Aggregate contexts will return an instance (likely a proxy) of a contained entry point context. In this case, the
+ * port name on the qualified name will correspond to the aggregate context name and the part name will be used to
+ * retrieve the contained entry point context. The latter may be null. If the contained context is not an entry
+ * point context, an exception will be thrown.
+ *
+ * @param qName a qualified name of the requested instance
+ * @return the implementation instance or a proxy to it
+ * @throws TargetException if an error occurs retrieving the instance or the requested component is not an entry
+ * point.
+ *
+ * @see AggregateContext
+ * @see org.apache.tuscany.model.assembly.EntryPoint
+ */
+ public Object getInstance(QualifiedName qName) throws TargetException;
+
+ /**
+ * Returns an instance associated with the requested name without notifying <code>ContextEventListener</code>s
+ * that may be registered with this context on instance creation. Note that {@link #getInstance(QualifiedName)}
+ * should generally be called and this method is only provided as an optimization for particular circumstances.
+ *
+ * @param qName a qualified name of the requested instance
+ * @param notify whether to notify <code>ContextEventListener</code>s
+ * @return the instance or a proxy to it
+ * @throws TargetException if an error occurs retrieving the instance or proxy
+ * @see LifecycleEventListener
+ */
+ public Object getInstance(QualifiedName qName, boolean notify) throws TargetException;
+
+ /**
+ * Returns the implementation instance associated witht he component. An implementation instance does not
+ * have a proxy invocation chainXXX
+ * @return
+ * @throws TargetException
+ */
+ public Object getImplementationInstance() throws TargetException;
+
+ public Object getImplementationInstance(boolean notify) throws TargetException;
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/InvalidNameException.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/InvalidNameException.java
new file mode 100644
index 0000000000..65c709e569
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/InvalidNameException.java
@@ -0,0 +1,43 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.context;
+
+/**
+ * Denotes an invalid name
+ *
+ * @version $Rev$ $Date$
+ */
+public class InvalidNameException extends ContextRuntimeException {
+
+ public InvalidNameException() {
+ super();
+ }
+
+ public InvalidNameException(String message) {
+ super(message);
+ }
+
+ public InvalidNameException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public InvalidNameException(Throwable cause) {
+ super(cause);
+ }
+
+}
+
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/LifecycleEventListener.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/LifecycleEventListener.java
new file mode 100644
index 0000000000..78962b53b4
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/LifecycleEventListener.java
@@ -0,0 +1,32 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.context;
+
+import java.util.EventListener;
+
+/**
+ * Callback interface for receiving instance context lifecycle events
+ *
+ * @version $Rev$ $Date$
+ */
+public interface LifecycleEventListener extends EventListener {
+
+ /**
+ * Notifies the listener that a new component context was created
+ */
+ public void onInstanceCreate(Context component);
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/QualifiedName.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/QualifiedName.java
new file mode 100644
index 0000000000..ad71721b75
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/QualifiedName.java
@@ -0,0 +1,83 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.context;
+
+/**
+ * An evaluated name consisting of a part/port pair. In the runtime, a part generally 'contains' or 'provides' ports
+ * such as a module component/entry point or a component/service pair.
+ *
+ * @version $Rev$ $Date$
+ */
+public class QualifiedName {
+
+ private String qName;
+
+ private String partName;
+
+ private String portName;
+
+ public static final String NAME_SEPARATOR = "/";
+
+ /**
+ * Constructs a new qualified name
+ *
+ * @throws InvalidNameException if the name is in an invalid format
+ */
+ public QualifiedName(String qualifiedName) throws InvalidNameException {
+ assert (qualifiedName != null) : "Name was null";
+ int pos = qualifiedName.indexOf(QualifiedName.NAME_SEPARATOR);
+ switch (pos) {
+ case -1:
+ partName = qualifiedName;
+ break;
+ case 0:
+ throw new InvalidNameException(qualifiedName);
+ default:
+ partName = qualifiedName.substring(0, pos);
+ portName = qualifiedName.substring(pos + 1);
+ break;
+ }
+ qName = qualifiedName;
+ }
+
+ /**
+ * Returns the parsed part name
+ */
+ public String getPartName() {
+ return partName;
+ }
+
+ /**
+ * Returns the parsed port name if the original is of the compound for part/port
+ */
+ public String getPortName() {
+ return portName;
+ }
+
+ /**
+ * Returns the full part/port name pair
+ *
+ * @return
+ */
+ public String getQualifiedName() {
+ return qName;
+ }
+
+ public String toString() {
+ return qName;
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/RuntimeEventListener.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/RuntimeEventListener.java
new file mode 100644
index 0000000000..e90f30b9cc
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/RuntimeEventListener.java
@@ -0,0 +1,36 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.context;
+
+import java.util.EventListener;
+
+/**
+ * Listeners observe events fired in the SCA runtime.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface RuntimeEventListener extends EventListener {
+
+ /**
+ * A method called when an event for which the <tt>Listener</tt> class is registered to observe is fired in the runtime
+ *
+ * @param type the event type identifier
+ * @param message the event message
+ * @throws EventException if an error occurs processing the event
+ */
+ public void onEvent(int type, Object message) throws EventException;
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/ScopeAwareContext.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/ScopeAwareContext.java
new file mode 100644
index 0000000000..565d7b49a6
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/ScopeAwareContext.java
@@ -0,0 +1,31 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.context;
+
+import java.util.Map;
+
+import org.apache.tuscany.model.assembly.Scope;
+
+/**
+ * Denotes an aggregate context that supports scopes
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ScopeAwareContext extends AggregateContext {
+
+ /**
+ * Returns an immutable collection of scopes keyed by type for the aggregate context
+ */
+ public Map<Scope, ScopeContext> getScopeContexts();
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/ScopeContext.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/ScopeContext.java
new file mode 100644
index 0000000000..abda942c88
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/ScopeContext.java
@@ -0,0 +1,72 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.context;
+
+import java.util.List;
+
+import org.apache.tuscany.core.builder.RuntimeConfiguration;
+
+/**
+ * Manages the lifecycle and visibility of <code>InstanceContext</code>s.
+ *
+ * @see org.apache.tuscany.core.context.InstanceContext
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ScopeContext extends InstanceContext, RuntimeEventListener {
+
+ /**
+ * Returns whether implementation instances may be held for the duration of an invocation
+ */
+ public boolean isCacheable();
+
+ /**
+ * Registers the runtime configurations used to construct instance contexts for the scope
+ */
+ public void registerConfigurations(List<RuntimeConfiguration<InstanceContext>> configurations);
+
+ /**
+ * Adds a runtime configuration to the scope
+ */
+ public void registerConfiguration(RuntimeConfiguration<InstanceContext> configuration);
+
+ /**
+ * Returns a context bound to the given name or null if the component does not exist. The returned context is bound
+ * to a key determined from the thread context.
+ */
+ public InstanceContext getContext(String name);
+
+ /**
+ * Returns a context bound to the given name and scoped to the given key or null if the context does not exist
+ */
+ public InstanceContext getContextByKey(String name, Object key);
+
+ /**
+ * Removes a context with the given name, determining the scope key from the thread context
+ *
+ * @throws ScopeRuntimeException
+ */
+ public void removeContext(String name) throws ScopeRuntimeException;
+
+ /**
+ * Removes a context bound to the given name and scope key
+ *
+ * @throws ScopeRuntimeException
+ */
+ public void removeContextByKey(String name, Object key) throws ScopeRuntimeException;
+
+} \ No newline at end of file
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/ScopeIdentifier.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/ScopeIdentifier.java
new file mode 100644
index 0000000000..38a847295c
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/ScopeIdentifier.java
@@ -0,0 +1,33 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.context;
+
+/**
+ * Implementations enable lazy retrieval of a scope id associated with a request, i.e. an id (and presumably a context) do not
+ * have to be generated if the scope is never accessed. Identifiers are associated with the current request thread and keyed on
+ * scope type.
+ *
+ * @version $Rev$ $Date$
+ * @see org.apache.tuscany.container.module.EventContext
+ */
+public interface ScopeIdentifier {
+
+ /**
+ * Returns the scope id for the request.
+ */
+ public Object getIdentifier();
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/ScopeInitializationException.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/ScopeInitializationException.java
new file mode 100644
index 0000000000..6ef5bfe9dd
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/ScopeInitializationException.java
@@ -0,0 +1,42 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.context;
+
+/**
+ * Denotes an initialization exception thrown by a scope container
+ *
+ * @version $Rev$ $Date$
+ */
+public class ScopeInitializationException extends ScopeRuntimeException {
+
+ public ScopeInitializationException() {
+ super();
+ }
+
+ public ScopeInitializationException(String message) {
+ super(message);
+ }
+
+ public ScopeInitializationException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public ScopeInitializationException(Throwable cause) {
+ super(cause);
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/ScopeRuntimeException.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/ScopeRuntimeException.java
new file mode 100644
index 0000000000..5022f7589d
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/ScopeRuntimeException.java
@@ -0,0 +1,43 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.context;
+
+/**
+ * Denotes a general runtime exception encountered by a scope container
+ *
+ * @version $Rev$ $Date$
+ */
+public class ScopeRuntimeException extends CoreRuntimeException {
+
+ public ScopeRuntimeException() {
+ super();
+ }
+
+ public ScopeRuntimeException(String message) {
+ super(message);
+ }
+
+ public ScopeRuntimeException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public ScopeRuntimeException(Throwable cause) {
+ super(cause);
+ }
+
+}
+
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/ScopeStrategy.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/ScopeStrategy.java
new file mode 100644
index 0000000000..b648fc2dcc
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/ScopeStrategy.java
@@ -0,0 +1,43 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.context;
+
+import java.util.Map;
+
+import org.apache.tuscany.model.assembly.Scope;
+
+/**
+ * Implementations provide scope container creation facilities and scope semantics to the runtime
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ScopeStrategy {
+
+ /* Denotes an undefined scope */
+ public static final int SCOPE_NOT_FOUND = -3;
+
+ /**
+ * Creates and returns new instances of configured scope containers
+ */
+ public Map<Scope, ScopeContext> createScopes(EventContext eventContext);
+
+ /**
+ * Determines whether a wire proceeds from a source of higher scope to a target of lesser scope
+ */
+ public boolean downScopeReference(Scope sourceScope, Scope targetScope);
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/ServiceNotFoundException.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/ServiceNotFoundException.java
new file mode 100644
index 0000000000..253909d7fa
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/ServiceNotFoundException.java
@@ -0,0 +1,42 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.context;
+
+import org.osoa.sca.ServiceUnavailableException;
+
+/**
+ * Denotes the specific case where a service was not found at runtime
+ *
+ * @version $Rev$ $Date$
+ */
+public class ServiceNotFoundException extends ServiceUnavailableException {
+
+ public ServiceNotFoundException() {
+ super();
+ }
+
+ public ServiceNotFoundException(String message) {
+ super(message);
+ }
+
+ public ServiceNotFoundException(Throwable cause) {
+ super(cause);
+ }
+
+ public ServiceNotFoundException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+}
+
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/SimpleComponentContext.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/SimpleComponentContext.java
new file mode 100644
index 0000000000..d35a3712a0
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/SimpleComponentContext.java
@@ -0,0 +1,36 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.context;
+
+/**
+ * A runtime entity that manages a non-aggregate (i.e. leaf-type) instance.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface SimpleComponentContext extends InstanceContext {
+
+ /**
+ * Returns whether a the context should be eagerly initialized
+ */
+ public boolean isEagerInit();
+
+ /**
+ * Returns whether a the context should be called back when its scope ends
+ */
+ public boolean isDestroyable();
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/SystemAggregateContext.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/SystemAggregateContext.java
new file mode 100644
index 0000000000..afb8499104
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/SystemAggregateContext.java
@@ -0,0 +1,36 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.context;
+
+import org.apache.tuscany.core.config.ConfigurationException;
+
+/**
+ * Marker type for system aggregate contexts
+ *
+ * @version $Rev$ $Date$
+ */
+public interface SystemAggregateContext extends AutowireContext, ScopeAwareContext, ConfigurationContext {
+
+ /**
+ * Register a simple Java Object as a system component.
+ * This is primarily intended for use by bootstrap code to create the initial
+ * configuration components.
+ *
+ * @param name the name of the resulting component
+ * @param instance the Object that will become the component's implementation
+ * @throws ConfigurationException
+ */
+ void registerJavaObject(String name, Object instance) throws ConfigurationException;
+}
+
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/TargetException.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/TargetException.java
new file mode 100644
index 0000000000..dd39d06aa1
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/TargetException.java
@@ -0,0 +1,42 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.context;
+
+/**
+ * Denotes an error while performing an operation on a target component implementation instance or proxy
+ *
+ * @version $Rev$ $Date$
+ */
+public class TargetException extends CoreRuntimeException {
+
+ public TargetException() {
+ super();
+ }
+
+ public TargetException(String message) {
+ super(message);
+ }
+
+ public TargetException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public TargetException(Throwable cause) {
+ super(cause);
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/impl/AbstractAggregateContext.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/impl/AbstractAggregateContext.java
new file mode 100644
index 0000000000..9ee1878625
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/impl/AbstractAggregateContext.java
@@ -0,0 +1,652 @@
+package org.apache.tuscany.core.context.impl;
+
+import static org.apache.tuscany.core.context.EventContext.HTTP_SESSION;
+import static org.apache.tuscany.core.context.EventContext.REQUEST_END;
+import static org.apache.tuscany.core.context.EventContext.SESSION_NOTIFY;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+import javax.wsdl.Part;
+
+import org.apache.tuscany.common.monitor.MonitorFactory;
+import org.apache.tuscany.core.builder.BuilderConfigException;
+import org.apache.tuscany.core.builder.RuntimeConfiguration;
+import org.apache.tuscany.core.config.ConfigurationException;
+import org.apache.tuscany.core.context.AbstractContext;
+import org.apache.tuscany.core.context.AggregateContext;
+import org.apache.tuscany.core.context.AutowireContext;
+import org.apache.tuscany.core.context.ConfigurationContext;
+import org.apache.tuscany.core.context.ContextInitException;
+import org.apache.tuscany.core.context.CoreRuntimeException;
+import org.apache.tuscany.core.context.DuplicateNameException;
+import org.apache.tuscany.core.context.EntryPointContext;
+import org.apache.tuscany.core.context.EventContext;
+import org.apache.tuscany.core.context.EventException;
+import org.apache.tuscany.core.context.InstanceContext;
+import org.apache.tuscany.core.context.QualifiedName;
+import org.apache.tuscany.core.context.RuntimeEventListener;
+import org.apache.tuscany.core.context.ScopeAwareContext;
+import org.apache.tuscany.core.context.ScopeContext;
+import org.apache.tuscany.core.context.ScopeRuntimeException;
+import org.apache.tuscany.core.context.ScopeStrategy;
+import org.apache.tuscany.core.context.SimpleComponentContext;
+import org.apache.tuscany.core.context.TargetException;
+import org.apache.tuscany.core.context.scope.DefaultScopeStrategy;
+import org.apache.tuscany.core.invocation.InvocationConfiguration;
+import org.apache.tuscany.core.invocation.spi.ProxyFactory;
+import org.apache.tuscany.core.invocation.spi.ProxyInitializationException;
+import org.apache.tuscany.core.system.annotation.Autowire;
+import org.apache.tuscany.core.system.annotation.ParentContext;
+import org.apache.tuscany.model.assembly.Aggregate;
+import org.apache.tuscany.model.assembly.Component;
+import org.apache.tuscany.model.assembly.EntryPoint;
+import org.apache.tuscany.model.assembly.Extensible;
+import org.apache.tuscany.model.assembly.ExternalService;
+import org.apache.tuscany.model.assembly.Module;
+import org.apache.tuscany.model.assembly.Scope;
+import org.apache.tuscany.model.assembly.ComponentImplementation;
+import org.apache.tuscany.model.assembly.impl.AssemblyFactoryImpl;
+
+/**
+ * The base implementation of an aggregate context
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class AbstractAggregateContext extends AbstractContext implements AutowireContext, ScopeAwareContext {
+
+ public static final int DEFAULT_WAIT = 1000 * 60;
+
+ // ----------------------------------
+ // Fields
+ // ----------------------------------
+
+ // The parent context, if one exists
+ @ParentContext
+ protected AggregateContext parentContext;
+
+ // The parent configuration context, if one exists
+ @Autowire(required = false)
+ protected ConfigurationContext configurationContext;
+
+ // The system monitor factory
+ @Autowire(required = false)
+ protected MonitorFactory monitorFactory;
+
+ // The logical model representing the module assembly
+ // protected ModuleComponent moduleComponent;
+ protected Module module;
+
+ protected Map<String, RuntimeConfiguration<InstanceContext>> configurations = new HashMap();
+
+ // Factory for scope contexts
+ @Autowire(required = false)
+ protected ScopeStrategy scopeStrategy;
+
+ // The event context for associating context events to threads
+ protected EventContext eventContext;
+
+ // The scopes for this context
+ protected Map<Scope, ScopeContext> scopeContexts;
+
+ protected Map<Scope, ScopeContext> immutableScopeContexts;
+
+ // A component context name to scope context index
+ protected Map<String, ScopeContext> scopeIndex;
+
+ // Listeners for context events
+ protected List<RuntimeEventListener> listeners = new CopyOnWriteArrayList();
+
+ // Blocking latch to ensure the module is initialized exactly once prior to servicing requests
+ protected CountDownLatch initializeLatch = new CountDownLatch(1);
+
+ // Indicates whether the module context has been initialized
+ protected boolean initialized;
+
+ // ----------------------------------
+ // Constructors
+ // ----------------------------------
+
+ public AbstractAggregateContext() {
+ scopeIndex = new ConcurrentHashMap();
+ // FIXME the factory should be injected
+ module = new AssemblyFactoryImpl().createModule();
+ }
+
+ public AbstractAggregateContext(String name, AggregateContext parent, ScopeStrategy strategy, EventContext ctx,
+ ConfigurationContext configCtx, MonitorFactory factory) {
+ super(name);
+ this.scopeStrategy = strategy;
+ this.eventContext = ctx;
+ this.configurationContext = configCtx;
+ this.monitorFactory = factory;
+ scopeIndex = new ConcurrentHashMap();
+ parentContext = parent;
+ // FIXME the factory should be injected
+ module = new AssemblyFactoryImpl().createModule();
+ }
+
+ // ----------------------------------
+ // Lifecycle methods
+ // ----------------------------------
+
+ public void start() {
+ synchronized (initializeLatch) {
+ try {
+ if (lifecycleState != UNINITIALIZED && lifecycleState != STOPPED) {
+ throw new IllegalStateException("Context not in UNINITIALIZED state");
+ }
+ lifecycleState = INITIALIZING;
+ initializeScopes();
+
+ Map<Scope, List<RuntimeConfiguration<SimpleComponentContext>>> configurationsByScope = new HashMap();
+ if (configurations != null) {
+ for (RuntimeConfiguration source : configurations.values()) {
+ // FIXME scopes are defined at the interface level
+ Scope sourceScope = source.getScope();
+ wireSource(source);
+ buildTarget(source);
+ scopeIndex.put(source.getName(), scopeContexts.get(sourceScope));
+ List<RuntimeConfiguration<SimpleComponentContext>> list = configurationsByScope.get(sourceScope);
+ if (list == null) {
+ list = new ArrayList();
+ configurationsByScope.put(sourceScope, list);
+ }
+ list.add(source);
+ }
+ }
+ for (EntryPoint ep : module.getEntryPoints()) {
+ registerAutowire(ep);
+ }
+ for (Component component : module.getComponents()) {
+ registerAutowire(component);
+ }
+ for (ExternalService es : module.getExternalServices()) {
+ registerAutowire(es);
+ }
+ for (Map.Entry entries : configurationsByScope.entrySet()) {
+ // register configurations with scope contexts
+ ScopeContext scope = scopeContexts.get(entries.getKey());
+ scope.registerConfigurations((List<RuntimeConfiguration<InstanceContext>>) entries.getValue());
+ }
+ initializeProxies();
+ for (ScopeContext scope : scopeContexts.values()) {
+ // register scope contexts as a listeners for events in the aggregate context
+ registerListener(scope);
+ scope.start();
+ }
+ lifecycleState = RUNNING;
+ } catch (ProxyInitializationException e) {
+ lifecycleState = ERROR;
+ ContextInitException cie = new ContextInitException(e);
+ cie.addContextName(getName());
+ throw cie;
+ } catch (ConfigurationException e) {
+ lifecycleState = ERROR;
+ throw new ContextInitException(e);
+ } catch (CoreRuntimeException e) {
+ lifecycleState = ERROR;
+ e.addContextName(getName());
+ throw e;
+ } finally {
+ initialized = true;
+ // release the latch and allow requests to be processed
+ initializeLatch.countDown();
+ }
+ }
+ }
+
+ public void stop() {
+ if (lifecycleState == STOPPED) {
+ return;
+ }
+ // need to block a start until reset is complete
+ initializeLatch = new CountDownLatch(2);
+ lifecycleState = STOPPING;
+ initialized = false;
+ if (scopeContexts != null) {
+ for (ScopeContext scope : scopeContexts.values()) {
+ try {
+ if (scope.getLifecycleState() == ScopeContext.RUNNING) {
+ scope.stop();
+ }
+ } catch (ScopeRuntimeException e) {
+ // log.error("Error stopping scope container [" + scopeContainers[i].getName() + "]", e);
+ }
+ }
+ }
+ scopeContexts = null;
+ scopeIndex.clear();
+ // allow initialized to be called
+ initializeLatch.countDown();
+ lifecycleState = STOPPED;
+ }
+
+ // ----------------------------------
+ // Methods
+ // ----------------------------------
+
+ public void setModule(Module module) {
+ assert (module != null) : "Module cannot be null";
+ name = module.getName();
+ this.module = module;
+ }
+
+ public void setScopeStrategy(ScopeStrategy scopeStrategy) {
+ this.scopeStrategy = scopeStrategy;
+ }
+
+ public void setEventContext(EventContext eventContext) {
+ this.eventContext = eventContext;
+ }
+
+ public void setMonitorFactory(MonitorFactory factory) {
+ this.monitorFactory = factory;
+ }
+
+ public AggregateContext getParent() {
+ return parentContext;
+ }
+
+ public void registerModelObjects(List<Extensible> models) throws ConfigurationException {
+ assert (models != null) : "Model object collection was null";
+ for (Extensible model : models) {
+ registerModelObject(model);
+ }
+ }
+
+ public void registerModelObject(Extensible model) throws ConfigurationException {
+ assert (model != null) : "Model object was null";
+ initializeScopes();
+ if (configurationContext != null) {
+ try {
+ configurationContext.configure(model);
+ configurationContext.build(this, model);
+ } catch (ConfigurationException e) {
+ e.addContextName(getName());
+ throw e;
+ } catch (BuilderConfigException e) {
+ e.addContextName(getName());
+ throw e;
+ }
+ }
+ RuntimeConfiguration<InstanceContext> configuration = null;
+ if (model instanceof Module) {
+ // merge new module definition with the existing one
+ Module oldModule = module;
+ Module newModule = (Module) model;
+ module = newModule;
+ for (Component component : newModule.getComponents()) {
+ ComponentImplementation componentImplementation = component.getComponentImplementation();
+ if (componentImplementation == null) {
+ ConfigurationException e = new ConfigurationException("Component implementation not set");
+ e.addContextName(component.getName());
+ e.addContextName(getName());
+ throw e;
+ }
+ configuration = (RuntimeConfiguration<InstanceContext>) componentImplementation.getRuntimeConfiguration();
+ if (configuration == null) {
+ ConfigurationException e = new ConfigurationException("Runtime configuration not set");
+ e.addContextName(component.getName());
+ e.addContextName(getName());
+ throw e;
+ }
+ registerConfiguration(configuration);
+ registerAutowire(component);
+ }
+ for (EntryPoint ep : newModule.getEntryPoints()) {
+ configuration = (RuntimeConfiguration<InstanceContext>) ep.getConfiguredReference().getRuntimeConfiguration();
+ if (configuration == null) {
+ ConfigurationException e = new ConfigurationException("Runtime configuration not set");
+ e.setIdentifier(ep.getName());
+ e.addContextName(getName());
+ throw e;
+ }
+ registerConfiguration(configuration);
+ registerAutowire(ep);
+ }
+ for (ExternalService service : newModule.getExternalServices()) {
+ configuration = (RuntimeConfiguration<InstanceContext>) service.getConfiguredService().getRuntimeConfiguration();
+ if (configuration == null) {
+ ConfigurationException e = new ConfigurationException("Runtime configuration not set");
+ e.setIdentifier(service.getName());
+ e.addContextName(getName());
+ throw e;
+ }
+ registerConfiguration(configuration);
+ registerAutowire(service);
+ }
+ if (lifecycleState == RUNNING) {
+ for (Component component : newModule.getComponents()) {
+ RuntimeConfiguration<InstanceContext> config = (RuntimeConfiguration<InstanceContext>) component
+ .getComponentImplementation().getRuntimeConfiguration();
+ wireSource(config);
+ buildTarget(config);
+ try {
+ if (config.getSourceProxyFactories() != null) {
+ for (ProxyFactory sourceProxyFactory : (Collection<ProxyFactory>) config.getSourceProxyFactories()
+ .values()) {
+ sourceProxyFactory.initialize();
+ }
+ }
+ if (config.getTargetProxyFactories() != null) {
+ for (ProxyFactory targetProxyFactory : (Collection<ProxyFactory>) config.getTargetProxyFactories()
+ .values()) {
+ targetProxyFactory.initialize();
+ }
+ }
+ } catch (ProxyInitializationException e) {
+ throw new ConfigurationException(e);
+ }
+
+ }
+ for (EntryPoint ep : newModule.getEntryPoints()) {
+ RuntimeConfiguration<InstanceContext> config = (RuntimeConfiguration<InstanceContext>) ep
+ .getConfiguredReference().getRuntimeConfiguration();
+ wireSource(config);
+ buildTarget(config);
+ try {
+ if (config.getSourceProxyFactories() != null) {
+ for (ProxyFactory sourceProxyFactory : (Collection<ProxyFactory>) config.getSourceProxyFactories()
+ .values()) {
+ sourceProxyFactory.initialize();
+ }
+ }
+ if (config.getTargetProxyFactories() != null) {
+ for (ProxyFactory targetProxyFactory : (Collection<ProxyFactory>) config.getTargetProxyFactories()
+ .values()) {
+ targetProxyFactory.initialize();
+ }
+ }
+ } catch (ProxyInitializationException e) {
+ throw new ConfigurationException(e);
+ }
+
+ }
+ for (ExternalService es : newModule.getExternalServices()) {
+ RuntimeConfiguration<InstanceContext> config = (RuntimeConfiguration<InstanceContext>) es
+ .getConfiguredService().getRuntimeConfiguration();
+ buildTarget(config);
+ try {
+ if (config.getSourceProxyFactories() != null) {
+ for (ProxyFactory sourceProxyFactory : (Collection<ProxyFactory>) config.getSourceProxyFactories()
+ .values()) {
+ sourceProxyFactory.initialize();
+ }
+ }
+ if (config.getTargetProxyFactories() != null) {
+ for (ProxyFactory targetProxyFactory : (Collection<ProxyFactory>) config.getTargetProxyFactories()
+ .values()) {
+ targetProxyFactory.initialize();
+ }
+ }
+ } catch (ProxyInitializationException e) {
+ throw new ConfigurationException(e);
+ }
+
+ }
+
+ }
+ // merge existing module component assets
+ module.getComponents().addAll(oldModule.getComponents());
+ module.getEntryPoints().addAll(oldModule.getEntryPoints());
+ module.getExternalServices().addAll(oldModule.getExternalServices());
+ } else {
+ if (model instanceof Component) {
+ Component component = (Component) model;
+ module.getComponents().add(component);
+ configuration = (RuntimeConfiguration<InstanceContext>) component.getComponentImplementation()
+ .getRuntimeConfiguration();
+ } else if (model instanceof EntryPoint) {
+ EntryPoint ep = (EntryPoint) model;
+ module.getEntryPoints().add(ep);
+ configuration = (RuntimeConfiguration<InstanceContext>) ep.getConfiguredReference().getRuntimeConfiguration();
+ } else if (model instanceof ExternalService) {
+ ExternalService service = (ExternalService) model;
+ module.getExternalServices().add(service);
+ configuration = (RuntimeConfiguration<InstanceContext>) service.getConfiguredService().getRuntimeConfiguration();
+ } else {
+ BuilderConfigException e = new BuilderConfigException("Unknown model type");
+ e.setIdentifier(model.getClass().getName());
+ e.addContextName(getName());
+ throw e;
+ }
+ if (configuration == null) {
+ ConfigurationException e = new ConfigurationException("Runtime configuration not set");
+ if (model instanceof Part) {
+ e.setIdentifier(((Part) model).getName());
+ }
+ e.addContextName(getName());
+ throw e;
+ }
+ registerConfiguration(configuration);
+ registerAutowire(model);
+ }
+ }
+
+ protected void registerConfiguration(RuntimeConfiguration<InstanceContext> configuration) throws ConfigurationException {
+ if (lifecycleState == RUNNING) {
+ if (scopeIndex.get(configuration.getName()) != null) {
+ throw new DuplicateNameException(configuration.getName());
+ }
+ ScopeContext scope = scopeContexts.get(configuration.getScope());
+ if (scope == null) {
+ ConfigurationException e = new ConfigurationException("Component has an unknown scope");
+ e.addContextName(configuration.getName());
+ e.addContextName(getName());
+ throw e;
+ }
+ scope.registerConfiguration(configuration);
+ scopeIndex.put(configuration.getName(), scope);
+ configurations.put(configuration.getName(), configuration); // xcv
+ } else {
+ if (configurations.get(configuration.getName()) != null) {
+ throw new DuplicateNameException(configuration.getName());
+ }
+ configurations.put(configuration.getName(), configuration);
+ }
+
+ }
+
+ public void registerListener(RuntimeEventListener listener) {
+ assert (listener != null) : "Listener cannot be null";
+ listeners.add(listener);
+ }
+
+ public void fireEvent(int eventType, Object message) throws EventException {
+ checkInit();
+ if (eventType == SESSION_NOTIFY) {
+ // update context
+ eventContext.setIdentifier(HTTP_SESSION, message);
+ } else if (eventType == REQUEST_END) {
+ // be very careful with pooled threads, ensuring threadlocals are cleaned up
+ eventContext.clearIdentifier(HTTP_SESSION);
+ }
+ for (RuntimeEventListener listener : listeners) {
+ listener.onEvent(eventType, message);
+ }
+ }
+
+ public InstanceContext getContext(String componentName) {
+ checkInit();
+ assert (componentName != null) : "Name was null";
+ ScopeContext scope = scopeIndex.get(componentName);
+ if (scope == null) {
+ return null;
+ }
+ return scope.getContext(componentName);
+
+ }
+
+ public Object getInstance(QualifiedName qName) throws TargetException {
+ return getInstance(qName, true);
+ }
+
+ public Object getInstance(QualifiedName qName, boolean notify) throws TargetException {
+ assert (qName != null) : "Name was null ";
+ // use the port name to get the context since entry points ports
+ ScopeContext scope = scopeIndex.get(qName.getPortName());
+ if (scope == null) {
+ return null;
+ }
+ InstanceContext ctx = scope.getContext(qName.getPortName());
+ if (!(ctx instanceof EntryPointContext)) {
+ TargetException e = new TargetException("Target not an entry point");
+ e.setIdentifier(qName.getQualifiedName());
+ e.addContextName(name);
+ throw e;
+ }
+ return ctx.getInstance(null, notify);
+ }
+
+ public Object locateInstance(String qualifiedName) throws TargetException {
+ checkInit();
+ QualifiedName qName = new QualifiedName(qualifiedName);
+ ScopeContext scope = scopeIndex.get(qName.getPartName());
+ if (scope == null) {
+ TargetException e = new TargetException("Component not found");
+ e.setIdentifier(qualifiedName);
+ e.addContextName(getName());
+ throw e;
+ }
+ InstanceContext ctx = scope.getContext(qName.getPartName());
+ try {
+ return ctx.getInstance(qName, true);
+ } catch (TargetException e) {
+ e.addContextName(getName());
+ throw e;
+ }
+ }
+
+ public Map<Scope, ScopeContext> getScopeContexts() {
+ initializeScopes();
+ return immutableScopeContexts;
+ }
+
+ // ----------------------------------
+ // Abstract methods
+ // ----------------------------------
+
+ /**
+ * Registers a model object as autowirable
+ *
+ * @throws ContextInitException
+ */
+ protected abstract void registerAutowire(Extensible model) throws ConfigurationException;
+
+ // ----------------------------------
+ // Protected methods
+ // ----------------------------------
+
+ /**
+ * Blocks until the module context has been initialized
+ */
+ protected void checkInit() {
+ if (!initialized) {
+ try {
+ /* block until the module has initialized */
+ boolean success = initializeLatch.await(DEFAULT_WAIT, TimeUnit.MILLISECONDS);
+ if (!success) {
+ throw new ContextInitException("Timeout waiting for module context to initialize");
+ }
+ } catch (InterruptedException e) { // should not happen
+ }
+ }
+
+ }
+
+ protected void initializeScopes() {
+ if (scopeContexts == null) {
+ if (scopeStrategy == null) {
+ scopeStrategy = new DefaultScopeStrategy();
+ }
+ scopeContexts = scopeStrategy.createScopes(eventContext);
+ immutableScopeContexts = Collections.unmodifiableMap(scopeContexts);
+ }
+ }
+
+ /**
+ * Iterates through references and delegates to the configuration context to wire them to their targets
+ */
+ protected void wireSource(RuntimeConfiguration source) {
+ Scope sourceScope = source.getScope();
+ if (source.getSourceProxyFactories() != null) {
+ for (ProxyFactory sourceFactory : ((Map<String, ProxyFactory>) source.getSourceProxyFactories()).values()) {
+ QualifiedName targetName = sourceFactory.getProxyConfiguration().getTargetName();
+ RuntimeConfiguration target = configurations.get(targetName.getPartName());
+ if (target == null) {
+ ContextInitException e = new ContextInitException("Target not found");
+ e.setIdentifier(targetName.getPartName());
+ e.addContextName(source.getName());
+ e.addContextName(name);
+ throw e;
+ }
+ // get the proxy chain for the target
+ ProxyFactory targetFactory = target.getTargetProxyFactory(sourceFactory.getProxyConfiguration().getTargetName()
+ .getPortName());
+ if (targetFactory == null) {
+ ContextInitException e = new ContextInitException("No proxy factory found for service");
+ e.setIdentifier(sourceFactory.getProxyConfiguration().getTargetName().getPortName());
+ e.addContextName(target.getName());
+ e.addContextName(source.getName());
+ e.addContextName(name);
+ throw e;
+ }
+ boolean downScope = scopeStrategy.downScopeReference(sourceScope, target.getScope());
+ configurationContext.wire(sourceFactory, targetFactory, target.getClass(), downScope, scopeContexts.get(target
+ .getScope()));
+ }
+ }
+ // wire invokers when the proxy only contains the target chain
+ if (source.getTargetProxyFactories() != null) {
+ for (ProxyFactory targetFactory : ((Map<String, ProxyFactory>) source.getTargetProxyFactories()).values()) {
+ configurationContext.wire(targetFactory, source.getClass(), scopeContexts.get(sourceScope));
+ }
+ }
+ source.prepare();
+ }
+
+ /**
+ * Signals to target side of reference configurations to initialize
+ */
+ protected void buildTarget(RuntimeConfiguration target) {
+ if (target.getTargetProxyFactories() != null) {
+ for (ProxyFactory targetFactory : ((Map<String, ProxyFactory>) target.getTargetProxyFactories()).values()) {
+ for (InvocationConfiguration iConfig : (Collection<InvocationConfiguration>) targetFactory
+ .getProxyConfiguration().getInvocationConfigurations().values()) {
+ iConfig.build();
+ }
+ }
+ }
+ }
+
+ protected void initializeProxies() throws ProxyInitializationException {
+ for (RuntimeConfiguration config : configurations.values()) {
+ if (config.getSourceProxyFactories() != null) {
+ for (ProxyFactory sourceProxyFactory : (Collection<ProxyFactory>) config.getSourceProxyFactories().values()) {
+ sourceProxyFactory.initialize();
+ }
+ }
+ if (config.getSourceProxyFactories() != null) {
+ for (ProxyFactory targetProxyFactory : (Collection<ProxyFactory>) config.getTargetProxyFactories().values()) {
+ targetProxyFactory.initialize();
+ }
+ }
+ }
+ }
+
+ /**
+ * @see org.apache.tuscany.core.context.AggregateContext#getAggregate()
+ */
+ public Aggregate getAggregate() {
+ return module;
+ }
+} \ No newline at end of file
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/impl/AggregateContextImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/impl/AggregateContextImpl.java
new file mode 100644
index 0000000000..69e0b8edfc
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/impl/AggregateContextImpl.java
@@ -0,0 +1,222 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.context.impl;
+
+import org.apache.tuscany.common.monitor.MonitorFactory;
+import org.apache.tuscany.core.builder.BuilderConfigException;
+import org.apache.tuscany.core.config.ConfigurationException;
+import org.apache.tuscany.core.context.AggregateContext;
+import org.apache.tuscany.core.context.AutowireContext;
+import org.apache.tuscany.core.context.AutowireResolutionException;
+import org.apache.tuscany.core.context.ConfigurationContext;
+import org.apache.tuscany.core.context.EventContext;
+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.ScopeStrategy;
+import org.apache.tuscany.core.context.ServiceNotFoundException;
+import org.apache.tuscany.core.context.TargetException;
+import org.apache.tuscany.core.invocation.spi.ProxyFactory;
+import org.apache.tuscany.core.system.annotation.Autowire;
+import org.apache.tuscany.model.assembly.Extensible;
+import org.osoa.sca.ModuleContext;
+import org.osoa.sca.RequestContext;
+import org.osoa.sca.ServiceReference;
+import org.osoa.sca.ServiceUnavailableException;
+
+/**
+ * The standard implementation of an aggregate context. Autowiring is performed by delegating to the parent context.
+ *
+ * @version $Rev$ $Date$
+ */
+public class AggregateContextImpl extends AbstractAggregateContext implements ConfigurationContext, ModuleContext {
+
+ // ----------------------------------
+ // Fields
+ // ----------------------------------
+
+ @Autowire(required = false)
+ private AutowireContext autowireContext;
+
+ // ----------------------------------
+ // Constructors
+ // ----------------------------------
+
+ public AggregateContextImpl() {
+ super();
+ eventContext = new EventContextImpl();
+ }
+
+ public AggregateContextImpl(String name, AggregateContext parent, ScopeStrategy strategy, EventContext ctx,
+ ConfigurationContext configCtx, MonitorFactory factory) {
+ super(name, parent, strategy, ctx, configCtx, factory);
+ }
+
+ public AggregateContextImpl(String name, AggregateContext parent, AutowireContext autowireContext, ScopeStrategy strategy,
+ EventContext ctx, ConfigurationContext configCtx, MonitorFactory factory) {
+ super(name, parent, strategy, ctx, configCtx, factory);
+ this.autowireContext = autowireContext;
+ }
+
+ // ----------------------------------
+ // ModuleContext methods
+ // ----------------------------------
+
+ private String uri;
+
+ public String getURI() {
+ return uri;
+ }
+
+ public void setURI(String uri) {
+ this.uri = uri;
+ }
+
+ public Object locateService(String qualifiedName) throws ServiceUnavailableException {
+ checkInit();
+ QualifiedName qName = new QualifiedName(qualifiedName);
+ ScopeContext scope = scopeIndex.get(qName.getPartName());
+ if (scope == null) {
+ throw new ServiceNotFoundException(qualifiedName);
+ }
+ InstanceContext ctx = scope.getContext(qName.getPartName());
+ try {
+ Object o = ctx.getInstance(qName, true);
+ if (o == null) {
+ throw new ServiceUnavailableException(qualifiedName);
+ }
+ return o;
+ } catch (TargetException e) {
+ e.addContextName(getName());
+ throw new ServiceUnavailableException(e);
+ }
+ }
+
+ public ServiceReference createServiceReference(String serviceName) {
+ throw new UnsupportedOperationException();
+ }
+
+ public RequestContext getRequestContext() {
+ throw new UnsupportedOperationException();
+ }
+
+ public ServiceReference createServiceReferenceForSession(Object self) {
+ throw new UnsupportedOperationException();
+ }
+
+ public ServiceReference createServiceReferenceForSession(Object self, String serviceName) {
+ throw new UnsupportedOperationException();
+ }
+
+ public ServiceReference newSession(String serviceName) {
+ throw new UnsupportedOperationException();
+ }
+
+ public ServiceReference newSession(String serviceName, Object sessionId) {
+ throw new UnsupportedOperationException();
+ }
+
+ // ----------------------------------
+ // AutowireContext methods
+ // ----------------------------------
+
+ public <T> T resolveInstance(Class<T> instanceInterface) throws AutowireResolutionException {
+ if (MonitorFactory.class.equals(instanceInterface)) {
+ return instanceInterface.cast(monitorFactory);
+ } else if (ConfigurationContext.class.equals(instanceInterface)) {
+ return instanceInterface.cast(this);
+ } else if (AutowireContext.class.equals(instanceInterface)) {
+ return instanceInterface.cast(this);
+ }
+ if (autowireContext != null) {
+ try {
+ return autowireContext.resolveInstance(instanceInterface);
+ } catch (AutowireResolutionException e) {
+ e.addContextName(getName());
+ throw e;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ protected void registerAutowire(Extensible model) {
+ // this context only delegates autowiring
+ }
+
+ // ----------------------------------
+ // ConfigurationContext methods
+ // ----------------------------------
+
+ public void configure(Extensible model) throws ConfigurationException {
+ if (configurationContext != null) {
+ try {
+ configurationContext.configure(model);
+ } catch (ConfigurationException e) {
+ e.addContextName(getName());
+ throw e;
+ }
+ }
+ }
+
+ public void build(AggregateContext parent, Extensible model) throws BuilderConfigException {
+ if (configurationContext != null) {
+ try {
+ configurationContext.build(parent, model);
+ } catch (BuilderConfigException e) {
+ e.addContextName(getName());
+ throw e;
+ }
+ }
+ }
+
+ public void wire(ProxyFactory sourceFactory, ProxyFactory targetFactory, Class targetType, boolean downScope,
+ ScopeContext targetScopeContext) throws BuilderConfigException {
+ if (configurationContext != null) {
+ try {
+ configurationContext.wire(sourceFactory, targetFactory, targetType, downScope, targetScopeContext);
+ } catch (BuilderConfigException e) {
+ e.addContextName(getName());
+ throw e;
+ }
+ }
+ }
+
+ public void wire(ProxyFactory targetFactory, Class targetType, ScopeContext targetScopeContext) throws BuilderConfigException {
+ if (configurationContext != null) {
+ try {
+ configurationContext.wire(targetFactory, targetType, targetScopeContext);
+ } catch (BuilderConfigException e) {
+ e.addContextName(getName());
+ throw e;
+ }
+ }
+ }
+
+ // ----------------------------------
+ // InstanceContext methods
+ // ----------------------------------
+
+ public Object getImplementationInstance() throws TargetException {
+ return this;
+ }
+
+ public Object getImplementationInstance(boolean notify) throws TargetException {
+ return this;
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/impl/EntryPointContextImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/impl/EntryPointContextImpl.java
new file mode 100644
index 0000000000..791ce6b8a5
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/impl/EntryPointContextImpl.java
@@ -0,0 +1,112 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.context.impl;
+
+import java.lang.reflect.InvocationHandler;
+
+import org.apache.tuscany.core.context.AbstractContext;
+import org.apache.tuscany.core.context.ContextInitException;
+import org.apache.tuscany.core.context.CoreRuntimeException;
+import org.apache.tuscany.core.context.EntryPointContext;
+import org.apache.tuscany.core.context.QualifiedName;
+import org.apache.tuscany.core.context.TargetException;
+import org.apache.tuscany.core.invocation.jdk.JDKInvocationHandler;
+import org.apache.tuscany.core.invocation.spi.ProxyCreationException;
+import org.apache.tuscany.core.invocation.spi.ProxyFactory;
+import org.apache.tuscany.core.message.MessageFactory;
+
+/**
+ * The default implementation of an entry point context
+ *
+ * @version $Rev$ $Date$
+ */
+public class EntryPointContextImpl extends AbstractContext implements EntryPointContext {
+
+ private MessageFactory messageFactory;
+
+ private ProxyFactory proxyFactory;
+
+ private Object target;
+
+ private InvocationHandler invocationHandler;
+
+ // a proxy implementing the service exposed by the entry point backed by the invocation handler
+ private Object proxy;
+
+ // ----------------------------------
+ // Constructors
+ // ----------------------------------
+
+ /**
+ * Creates a new entry point
+ *
+ * @param name the entry point name
+ * @param proxyFactory the proxy factory containing the invocation chains for the entry point
+ * @param parentContext the containing aggregate of the entry point
+ * @param messageFactory a factory for generating invocation messages
+ * @throws ContextInitException if an error occurs creating the entry point
+ */
+ public EntryPointContextImpl(String name, ProxyFactory proxyFactory, MessageFactory messageFactory)
+ throws ContextInitException {
+ super(name);
+ assert (proxyFactory != null) : "Proxy factory was null";
+ assert (messageFactory != null) : "Message factory was null";
+ this.proxyFactory = proxyFactory;
+ this.messageFactory = messageFactory;
+ invocationHandler = new JDKInvocationHandler(messageFactory, proxyFactory.getProxyConfiguration()
+ .getInvocationConfigurations());
+ }
+
+ // ----------------------------------
+ // Methods
+ // ----------------------------------
+
+ public Object getInstance(QualifiedName qName) throws TargetException {
+ if (proxy == null) {
+ try {
+ proxy = proxyFactory.createProxy();
+ } catch (ProxyCreationException e) {
+ TargetException te = new TargetException(e);
+ te.addContextName(getName());
+ throw te;
+ }
+ }
+ return proxy;
+ }
+
+ public Object getInstance(QualifiedName qName, boolean notify) throws TargetException {
+ return getInstance(qName);
+ }
+
+ public void start() throws ContextInitException {
+ lifecycleState = RUNNING;
+ }
+
+ public void stop() throws CoreRuntimeException {
+ lifecycleState = STOPPED;
+ }
+
+ // ----------------------------------
+ // InstanceContext methods
+ // ----------------------------------
+
+ public Object getImplementationInstance() throws TargetException {
+ return invocationHandler;
+ }
+
+ public Object getImplementationInstance(boolean notify) throws TargetException {
+ return getImplementationInstance();
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/impl/EventContextImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/impl/EventContextImpl.java
new file mode 100644
index 0000000000..accf6b3030
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/impl/EventContextImpl.java
@@ -0,0 +1,77 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.context.impl;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.core.context.EventContext;
+import org.apache.tuscany.core.context.ScopeIdentifier;
+
+/**
+ * An implementation of an {@link org.apache.tuscany.core.context.EventContext} that handles event-to-thread associations using an
+ * <code>InheritableThreadLocal</code>
+ *
+ * @version $Rev$ $Date$
+ */
+public class EventContextImpl implements EventContext {
+
+ // @TODO design a proper propagation strategy for creating new threads
+ /*
+ * a map ( associated with the current thread) of scope identifiers keyed on the event context id type. the scope identifier
+ * may be a {@link ScopeIdentifier} or an opaque id
+ */
+ private ThreadLocal<Map> eventContext = new InheritableThreadLocal();
+
+ public Object getIdentifier(Object type) {
+ Map map = eventContext.get();
+ if (map == null) {
+ return null;
+ }
+ Object currentId = map.get(type);
+ if (currentId instanceof ScopeIdentifier) {
+ currentId = ((ScopeIdentifier) currentId).getIdentifier();
+ // once we have accessed the id, replace the lazy wrapper
+ map.put(type, currentId);
+ }
+ return currentId;
+ }
+
+ public void setIdentifier(Object type, Object identifier) {
+ Map map = eventContext.get();
+ if (map == null) {
+ map = new HashMap();
+ eventContext.set(map);
+ }
+ map.put(type, identifier);
+ }
+
+ public void clearIdentifier(Object type) {
+ if (type == null) {
+ return;
+ }
+ Map map = eventContext.get();
+ if (map != null) {
+ map.remove(type);
+ }
+ }
+
+ public EventContextImpl() {
+ super();
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/impl/ExternalServiceContextImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/impl/ExternalServiceContextImpl.java
new file mode 100644
index 0000000000..a73081ef66
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/impl/ExternalServiceContextImpl.java
@@ -0,0 +1,92 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.context.impl;
+
+import org.apache.tuscany.core.builder.ObjectFactory;
+import org.apache.tuscany.core.context.AbstractContext;
+import org.apache.tuscany.core.context.CoreRuntimeException;
+import org.apache.tuscany.core.context.ExternalServiceContext;
+import org.apache.tuscany.core.context.QualifiedName;
+import org.apache.tuscany.core.context.TargetException;
+import org.apache.tuscany.core.invocation.spi.ProxyCreationException;
+import org.apache.tuscany.core.invocation.spi.ProxyFactory;
+
+/**
+ * The default implementation of an external service context
+ *
+ * @version $Rev$ $Date$
+ */
+public class ExternalServiceContextImpl extends AbstractContext implements ExternalServiceContext {
+
+ private ProxyFactory targetProxyFactory;
+
+ private ObjectFactory targetInstanceFactory;
+
+ // ----------------------------------
+ // Constructors
+ // ----------------------------------
+
+ /**
+ * Creates an external service context
+ *
+ * @param name the name of the external service
+ * @param targetProxyFactory the factory which creates proxies implementing the configured service interface for the
+ * external service. There is always only one proxy factory as an external service is configured with one
+ * service
+ * @param targetInstanceFactory the object factory that creates an artifact capabile of communicating over the
+ * binding transport configured on the external service. The object factory may implement a caching strategy.
+ */
+ public ExternalServiceContextImpl(String name, ProxyFactory targetProxyFactory, ObjectFactory targetInstanceFactory) {
+ super(name);
+ assert (targetProxyFactory != null) : "Target proxy factory was null";
+ assert (targetInstanceFactory != null) : "Target instance factory was null";
+ this.targetProxyFactory = targetProxyFactory;
+ this.targetInstanceFactory = targetInstanceFactory;
+ }
+
+ // ----------------------------------
+ // Methods
+ // ----------------------------------
+
+ public Object getInstance(QualifiedName qName) throws TargetException {
+ try {
+ return targetProxyFactory.createProxy();
+ // TODO do we cache the proxy, (assumes stateful capabilities will be provided in an interceptor)
+ } catch (ProxyCreationException e) {
+ TargetException te = new TargetException(e);
+ te.addContextName(getName());
+ throw te;
+ }
+ }
+
+ public Object getInstance(QualifiedName qName, boolean notify) throws TargetException {
+ return getInstance(qName);
+ }
+
+ public void start() throws CoreRuntimeException {
+ lifecycleState = RUNNING;
+ }
+
+ public void stop() throws CoreRuntimeException {
+ lifecycleState = STOPPED;
+ }
+
+ public Object getImplementationInstance() throws TargetException {
+ return targetInstanceFactory.getInstance();
+ }
+
+ public Object getImplementationInstance(boolean notify) throws TargetException {
+ return getImplementationInstance();
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/scope/AbstractScopeContext.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/scope/AbstractScopeContext.java
new file mode 100644
index 0000000000..449af4bdf8
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/scope/AbstractScopeContext.java
@@ -0,0 +1,158 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.context.scope;
+
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.apache.tuscany.core.builder.RuntimeConfiguration;
+import org.apache.tuscany.core.context.AbstractContext;
+import org.apache.tuscany.core.context.InstanceContext;
+import org.apache.tuscany.core.context.QualifiedName;
+import org.apache.tuscany.core.context.EventContext;
+import org.apache.tuscany.core.context.Context;
+import org.apache.tuscany.core.context.ScopeContext;
+import org.apache.tuscany.core.context.TargetException;
+
+/**
+ * Implements functionality common to scope contexts.
+ * <p>
+ * <b>NB: </b>Minimal synchronization is performed, particularly for initializing and destroying scopes, and it is
+ * assumed the scope container will block requests until these operations have completed.
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class AbstractScopeContext extends AbstractContext implements ScopeContext{
+ // ----------------------------------
+ // Fields
+ // ----------------------------------
+
+ // The collection of runtime configurations for the scope
+ protected Map<String, RuntimeConfiguration<InstanceContext>> runtimeConfigurations = new ConcurrentHashMap();
+
+ // The event context the scope container is associated with
+ protected EventContext eventContext;
+
+ // ----------------------------------
+ // Constructors
+ // ----------------------------------
+
+ public AbstractScopeContext(EventContext eventContext) {
+ assert (eventContext != null) : "Event context was null";
+ this.eventContext = eventContext;
+ }
+
+ // ----------------------------------
+ // Lifecycle methods
+ // --------------------------_--------
+
+ public synchronized void start() {
+ }
+
+ public synchronized void stop() {
+ }
+
+
+ // ----------------------------------
+ // Scope methods
+ // ----------------------------------
+
+ public void registerConfigurations(List<RuntimeConfiguration<InstanceContext>> configurations) {
+ for (RuntimeConfiguration<InstanceContext> configuration : configurations) {
+ runtimeConfigurations.put(configuration.getName(), configuration);
+ }
+ }
+
+ public Object getInstance(QualifiedName qName) throws TargetException {
+ Object instance = null;
+ InstanceContext context = getContext(qName.getPartName());
+ if (context == null) {
+ TargetException e = new TargetException("Target not found");
+ e.setIdentifier(qName.getQualifiedName());
+ throw e;
+ }
+ return context.getInstance(qName);
+ }
+
+ public Object getInstance(QualifiedName qName, boolean notify) throws TargetException {
+ return getInstance(qName);
+ }
+
+ //----------------------------------
+ // InstanceContext methods
+ //----------------------------------
+
+ public Object getImplementationInstance() throws TargetException{
+ return this;
+ }
+
+ public Object getImplementationInstance(boolean notify) throws TargetException{
+ return this;
+ }
+
+ // ----------------------------------
+ // Protected methods
+ // ----------------------------------
+
+ protected EventContext getEventContext() {
+ return eventContext;
+ }
+
+ /**
+ * Notfies instances that are associated with a context and configured to receive callbacks that the context is
+ * being destroyed in reverse order
+ *
+ * @param key the context key
+ */
+ protected void notifyInstanceShutdown(Object key) {
+ InstanceContext[] contexts = getShutdownContexts(key);
+ if ((contexts == null) || (contexts.length < 1)) {
+ return;
+ }
+ // shutdown destroyable instances in reverse instantiation order
+ for (int i = contexts.length - 1; i >= 0; i--) {
+ InstanceContext context = contexts[i];
+
+ if (context.getLifecycleState() == Context.RUNNING) {
+ synchronized (context) {
+ context.setLifecycleState(Context.STOPPING);
+ removeContextByKey(context.getName(), key);
+ try {
+ context.stop();
+ } catch (TargetException e) {
+ // TODO send a monitoring event
+ // log.error("Error releasing instance [" + context.getName() + "]",e);
+ }
+ }
+ }
+ }
+ }
+
+ protected void checkInit() {
+ if (lifecycleState != RUNNING) {
+ throw new IllegalStateException("Scope not running [" + lifecycleState + "]");
+ }
+ }
+
+ /**
+ * Returns an array of contexts that need to be notified of scope shutdown. The array must be in the order in which
+ * component contexts were created
+ */
+ protected abstract InstanceContext[] getShutdownContexts(Object key);
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/scope/AbstractScopeStrategy.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/scope/AbstractScopeStrategy.java
new file mode 100644
index 0000000000..f89d09196d
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/scope/AbstractScopeStrategy.java
@@ -0,0 +1,67 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.context.scope;
+
+import org.apache.tuscany.core.context.ScopeStrategy;
+import org.apache.tuscany.model.assembly.Scope;
+
+/**
+ * Implements basic scope strategy functionality
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class AbstractScopeStrategy implements ScopeStrategy {
+
+ public AbstractScopeStrategy() {
+ }
+
+ /**
+ * Determines legal scope references according to standard SCA scope rules
+ *
+ * @param pReferrer the scope of the component making the reference
+ * @param pReferee the scope of the component being referred to
+ */
+ public boolean downScopeReference(Scope pReferrer, Scope pReferee) {
+ if (pReferrer == Scope.UNDEFINED || pReferee == Scope.UNDEFINED) {
+ return false;
+ }
+ if (pReferee == pReferrer){
+ return false;
+ }else if(pReferrer == Scope.INSTANCE){
+ return false;
+ }else if(pReferee == Scope.INSTANCE){
+ return true;
+ }else if (pReferrer == Scope.REQUEST && pReferee == Scope.SESSION){
+ return false;
+ }else if (pReferrer == Scope.REQUEST && pReferee == Scope.MODULE){
+ return false;
+// }else if (pReferrer == Scope.SESSION && pReferee == Scope.REQUEST){
+// return true;
+ }else if (pReferrer == Scope.SESSION && pReferee == Scope.MODULE){
+ return false;
+// }else if (pReferrer == Scope.MODULE){
+// return true;
+ }else{
+ return true;
+ }
+ //FIXME Jim this does not work with enumerations, what does it mean to have a scope <0?
+// } else if ((pReferrer < 0) || (pReferee < 0)) {
+// return false;
+// }
+//
+// return (pReferrer > pReferee);
+// return pReferrer != pReferee;
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/scope/AggregateScopeContext.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/scope/AggregateScopeContext.java
new file mode 100644
index 0000000000..19f554a625
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/scope/AggregateScopeContext.java
@@ -0,0 +1,184 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.context.scope;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.apache.tuscany.core.builder.RuntimeConfiguration;
+import org.apache.tuscany.core.context.AbstractContext;
+import org.apache.tuscany.core.context.AggregateContext;
+import org.apache.tuscany.core.context.EventContext;
+import org.apache.tuscany.core.context.EventException;
+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.ScopeInitializationException;
+import org.apache.tuscany.core.context.ScopeRuntimeException;
+import org.apache.tuscany.core.context.TargetException;
+
+/**
+ * Manages the lifecycle of aggregate component contexts, i.e. contexts which contain child contexts
+ *
+ * @see org.apache.tuscany.core.context.AggregateContext
+ * @version $Rev$ $Date$
+ */
+public class AggregateScopeContext extends AbstractContext implements ScopeContext {
+
+ // ----------------------------------
+ // Fields
+ // ----------------------------------
+
+ private EventContext eventContext;
+
+ private List<RuntimeConfiguration<InstanceContext>> configs = new ArrayList();
+
+ // Aggregate component contexts in this scope keyed by name
+ private Map<String, AggregateContext> contexts = new ConcurrentHashMap();
+
+ // indicates if a module start event has been previously propagated so child contexts added after can be notified
+ private boolean moduleScopeStarted;
+
+ // ----------------------------------
+ // Constructors
+ // ----------------------------------
+
+ public AggregateScopeContext(EventContext eventContext) {
+ assert (eventContext != null) : "Event context was null";
+ this.eventContext = eventContext;
+ name = "Aggregate Scope";
+ }
+
+ // ----------------------------------
+ // Lifecycle methods
+ // ----------------------------------
+
+ public void start() throws ScopeInitializationException {
+ for (RuntimeConfiguration<InstanceContext> configuration : configs) {
+ InstanceContext context = configuration.createInstanceContext();
+ if (!(context instanceof AggregateContext)) {
+ ScopeInitializationException e = new ScopeInitializationException("Context not an aggregate type");
+ e.addContextName(context.getName());
+ throw e;
+ }
+ AggregateContext aggregateCtx = (AggregateContext) context;
+ aggregateCtx.start();
+ contexts.put(aggregateCtx.getName(), aggregateCtx);
+ }
+ lifecycleState = RUNNING;
+ }
+
+ public void stop() throws ScopeRuntimeException {
+ for (AggregateContext context : contexts.values()) {
+ context.stop();
+ }
+ }
+
+ // ----------------------------------
+ // Methods
+ // ----------------------------------
+
+ public void registerConfigurations(List<RuntimeConfiguration<InstanceContext>> configurations) {
+ this.configs = configurations;
+ }
+
+ public void registerConfiguration(RuntimeConfiguration<InstanceContext> configuration) {
+ assert (configuration != null) : "Configuration was null";
+ configs.add(configuration);
+ if (lifecycleState == RUNNING) {
+ InstanceContext context = configuration.createInstanceContext();
+ if (!(context instanceof AggregateContext)) {
+ ScopeInitializationException e = new ScopeInitializationException("Context not an aggregate type");
+ e.setIdentifier(context.getName());
+ throw e;
+ }
+ AggregateContext aggregateCtx = (AggregateContext) context;
+ aggregateCtx.start();
+ if (moduleScopeStarted) {
+ aggregateCtx.fireEvent(EventContext.MODULE_START, null);
+ }
+ contexts.put(aggregateCtx.getName(), aggregateCtx);
+ }
+ }
+
+ public boolean isCacheable() {
+ return false;
+ }
+
+ public Object getInstance(QualifiedName qName) throws TargetException {
+ Object instance = null;
+ InstanceContext context = getContext(qName.getPartName());
+ if (context == null) {
+ TargetException e = new TargetException("Component not found");
+ e.setIdentifier(qName.getQualifiedName());
+ throw e;
+ }
+ return context.getInstance(qName);
+ }
+
+ public Object getInstance(QualifiedName qName, boolean notify) throws TargetException {
+ return getInstance(qName);
+ }
+
+ public InstanceContext getContext(String ctxName) {
+ checkInit();
+ return contexts.get(ctxName);
+ }
+
+ public InstanceContext getContextByKey(String ctxName, Object key) {
+ return getContext(ctxName);
+ }
+
+ public void removeContext(String ctxName) throws ScopeRuntimeException {
+ InstanceContext context = contexts.remove(ctxName);
+ if (context != null) {
+ context.stop();
+ }
+ }
+
+ public void removeContextByKey(String ctxName, Object key) throws ScopeRuntimeException {
+ }
+
+ public void onEvent(int type, Object message) throws EventException {
+ if (type == EventContext.MODULE_START) {
+ // track module starting so that aggregate contexts registered after the event are notified properly
+ moduleScopeStarted = true;
+ } else if (type == EventContext.MODULE_STOP) {
+ moduleScopeStarted = false;
+ }
+ // propagate events to child contexts
+ for (AggregateContext context : contexts.values()) {
+ context.fireEvent(type, message);
+ }
+ }
+
+ public Object getImplementationInstance() throws TargetException{
+ return this;
+ }
+
+ public Object getImplementationInstance(boolean notify) throws TargetException{
+ return this;
+ }
+
+ private void checkInit() {
+ if (lifecycleState != RUNNING) {
+ throw new IllegalStateException("Scope not running [" + lifecycleState + "]");
+ }
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/scope/DefaultScopeStrategy.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/scope/DefaultScopeStrategy.java
new file mode 100644
index 0000000000..509eb7941f
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/scope/DefaultScopeStrategy.java
@@ -0,0 +1,52 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.context.scope;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.core.context.EventContext;
+import org.apache.tuscany.core.context.ScopeContext;
+import org.apache.tuscany.model.assembly.Scope;
+
+/**
+ * Implements a {@link org.apache.tuscany.core.context.ScopeStrategy} for the default module scopes: stateless, request, session,
+ * and module.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefaultScopeStrategy extends AbstractScopeStrategy {
+
+ public DefaultScopeStrategy() {
+ }
+
+ public Map<Scope,ScopeContext> createScopes(EventContext eventContext) {
+ ScopeContext moduleScope = new ModuleScopeContext(eventContext);
+ ScopeContext sessionScope = new HttpSessionScopeContext(eventContext);
+ ScopeContext requestScope = new RequestScopeContext(eventContext);
+ ScopeContext statelessScope = new StatelessScopeContext(eventContext);
+ ScopeContext aggregrateScope = new AggregateScopeContext(eventContext);
+ Map<Scope,ScopeContext> scopes = new HashMap();
+ scopes.put(Scope.MODULE,moduleScope);
+ scopes.put(Scope.SESSION,sessionScope);
+ scopes.put(Scope.REQUEST,requestScope);
+ scopes.put(Scope.INSTANCE,statelessScope);
+ scopes.put(Scope.AGGREGATE,aggregrateScope);
+ return scopes;
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/scope/HttpSessionScopeContext.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/scope/HttpSessionScopeContext.java
new file mode 100644
index 0000000000..e1fcc4ab70
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/scope/HttpSessionScopeContext.java
@@ -0,0 +1,254 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.context.scope;
+
+import java.util.Map;
+import java.util.Queue;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentLinkedQueue;
+
+import org.apache.tuscany.core.builder.RuntimeConfiguration;
+import org.apache.tuscany.core.context.Context;
+import org.apache.tuscany.core.context.CoreRuntimeException;
+import org.apache.tuscany.core.context.EventContext;
+import org.apache.tuscany.core.context.InstanceContext;
+import org.apache.tuscany.core.context.LifecycleEventListener;
+import org.apache.tuscany.core.context.RuntimeEventListener;
+import org.apache.tuscany.core.context.ScopeRuntimeException;
+import org.apache.tuscany.core.context.SimpleComponentContext;
+
+/**
+ * An implementation of an HTTP session-scoped component container where each HTTP session is mapped to a context in the scope
+ *
+ * @version $Rev$ $Date$
+ */
+public class HttpSessionScopeContext extends AbstractScopeContext implements RuntimeEventListener, LifecycleEventListener {
+
+ // The collection of service component contexts keyed by session
+ private Map<Object, Map<String, InstanceContext>> contexts;
+
+ // Stores ordered lists of contexts to shutdown keyed by session
+ private Map<Object, Queue<InstanceContext>> destroyableContexts;
+
+ // ----------------------------------
+ // Constructors
+ // ----------------------------------
+
+ public HttpSessionScopeContext(EventContext eventContext) {
+ super(eventContext);
+ setName("Http Session Scope");
+ }
+
+ // ----------------------------------
+ // Lifecycle methods
+ // ----------------------------------
+
+ public synchronized void start() {
+ if (lifecycleState != UNINITIALIZED) {
+ throw new IllegalStateException("Scope container must be in UNINITIALIZED state");
+ }
+ super.start();
+ contexts = new ConcurrentHashMap();
+ destroyableContexts = new ConcurrentHashMap();
+ lifecycleState = RUNNING;
+ }
+
+ public synchronized void stop() {
+ if (lifecycleState != RUNNING) {
+ throw new IllegalStateException("Scope container in wrong state");
+ }
+ super.stop();
+ contexts = null;
+ contexts = null;
+ destroyableContexts = null;
+ lifecycleState = STOPPED;
+ }
+
+ // ----------------------------------
+ // Listener methods
+ // ----------------------------------
+
+ public void onEvent(int type, Object key) {
+ checkInit();
+ if (key == null) {
+ return;
+ }
+ if (type == EventContext.SESSION_END) {
+ notifyInstanceShutdown(key);
+ destroyComponentContext(key);
+ }
+ }
+
+ // ----------------------------------
+ // Scope methods
+ // ----------------------------------
+
+ public boolean isCacheable() {
+ return true;
+ }
+
+ public void registerConfiguration(RuntimeConfiguration<InstanceContext> configuration) {
+ runtimeConfigurations.put(configuration.getName(), configuration);
+ }
+
+ public InstanceContext getContext(String ctxName) {
+ checkInit();
+ if (ctxName == null) {
+ return null;
+ }
+ // try{
+ Map<String, InstanceContext> ctxs = getSessionContext();
+ if (ctxs == null) {
+ return null;
+ }
+ InstanceContext ctx = ctxs.get(ctxName);
+ if (ctx == null) {
+ // the configuration was added after the session had started, so create a context now and start it
+ RuntimeConfiguration<InstanceContext> configuration = runtimeConfigurations.get(ctxName);
+ if (configuration != null) {
+ ctx = configuration.createInstanceContext();
+ ctx.addContextListener(this);
+ ctx.start();
+ ctxs.put(ctx.getName(), ctx);
+ }
+ }
+ return ctx;
+ }
+
+ public InstanceContext getContextByKey(String ctxName, Object key) {
+ checkInit();
+ if (key == null && ctxName == null) {
+ return null;
+ }
+ Map components = (Map) contexts.get(key);
+ if (components == null) {
+ return null;
+ }
+ return (InstanceContext) components.get(ctxName);
+ }
+
+ public void removeContext(String ctxName) {
+ checkInit();
+ Object key = getEventContext().getIdentifier(EventContext.HTTP_SESSION);
+ removeContextByKey(ctxName, key);
+ }
+
+ public void removeContextByKey(String ctxName, Object key) {
+ checkInit();
+ if (key == null || ctxName == null) {
+ return;
+ }
+ Map components = (Map) contexts.get(key);
+ if (components == null) {
+ return;
+ }
+ components.remove(ctxName);
+ Map definitions = contexts.get(key);
+ InstanceContext meta = (InstanceContext) definitions.get(ctxName);
+ destroyableContexts.get(key).remove(meta);
+ definitions.remove(ctxName);
+ }
+
+ public void onInstanceCreate(Context context) throws ScopeRuntimeException {
+ checkInit();
+ if (context instanceof SimpleComponentContext) {
+ // if destroyable, queue the context to have its component implementation instance released
+ if (((SimpleComponentContext) context).isDestroyable()) {
+ Object key = getEventContext().getIdentifier(EventContext.HTTP_SESSION);
+ Queue comps = destroyableContexts.get(key);
+ if (comps == null) {
+ ScopeRuntimeException e = new ScopeRuntimeException("Shutdown queue not found for key");
+ e.setIdentifier(key.toString());
+ throw e;
+ }
+ comps.add(context);
+ }
+ }
+ }
+
+ /**
+ * Returns an array of {@link SimpleComponentContext}s representing components that need to be notified of scope shutdown or
+ * null if none found.
+ */
+ protected InstanceContext[] getShutdownContexts(Object key) {
+ /*
+ * This method will be called from the Listener which is associated with a different thread than the request. So, just
+ * grab the key directly
+ */
+ Queue queue = destroyableContexts.get(key);
+ if (queue != null) {
+ // create 0-length array since Queue.size() has O(n) traversal
+ return (InstanceContext[]) queue.toArray(new InstanceContext[0]);
+ } else {
+ return null;
+ }
+ }
+
+ // ----------------------------------
+ // Private methods
+ // ----------------------------------
+
+ /**
+ * Returns and, if necessary, creates a context for the current sesion
+ */
+ private Map<String, InstanceContext> getSessionContext() throws CoreRuntimeException {
+ Object key = getEventContext().getIdentifier(EventContext.HTTP_SESSION);
+ if (key == null) {
+ throw new ScopeRuntimeException("Session key not set in request context");
+ }
+ Map m = contexts.get(key);
+ if (m != null) {
+ return m; // already created, return
+ }
+ Map<String, InstanceContext> sessionContext = new ConcurrentHashMap(runtimeConfigurations.size());
+ for (RuntimeConfiguration<InstanceContext> config : runtimeConfigurations.values()) {
+ InstanceContext context = null;
+ context = config.createInstanceContext();
+ context.addContextListener(this);
+ context.start();
+ sessionContext.put(context.getName(), context);
+ }
+
+ Queue shutdownQueue = new ConcurrentLinkedQueue();
+ contexts.put(key, sessionContext);
+ destroyableContexts.put(key, shutdownQueue);
+ // initialize eager components. Note this cannot be done when we initially create each context since a component may
+ // contain a forward reference to a component which has not been instantiated
+ for (InstanceContext context : sessionContext.values()) {
+ if (context instanceof SimpleComponentContext) {
+ SimpleComponentContext simpleCtx = (SimpleComponentContext) context;
+ if (simpleCtx.isEagerInit()) {
+ // Get the instance and perform manual shutdown registration to avoid a map lookup
+ context.getInstance(null, false);
+ if (simpleCtx.isDestroyable()) {
+ shutdownQueue.add(context);
+ }
+ }
+ }
+ }
+ return sessionContext;
+ }
+
+ /**
+ * Removes the components associated with an expiring context
+ */
+ private void destroyComponentContext(Object key) {
+ contexts.remove(key);
+ destroyableContexts.remove(key);
+ }
+
+} \ No newline at end of file
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/scope/ModuleScopeContext.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/scope/ModuleScopeContext.java
new file mode 100644
index 0000000000..00f2747fae
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/scope/ModuleScopeContext.java
@@ -0,0 +1,182 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.context.scope;
+
+import java.util.Map;
+import java.util.Queue;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentLinkedQueue;
+
+import org.apache.tuscany.core.builder.RuntimeConfiguration;
+import org.apache.tuscany.core.context.Context;
+import org.apache.tuscany.core.context.CoreRuntimeException;
+import org.apache.tuscany.core.context.EventContext;
+import org.apache.tuscany.core.context.InstanceContext;
+import org.apache.tuscany.core.context.LifecycleEventListener;
+import org.apache.tuscany.core.context.RuntimeEventListener;
+import org.apache.tuscany.core.context.SimpleComponentContext;
+
+/**
+ * Manages component contexts whose implementations are module scoped
+ *
+ * @version $Rev$ $Date$
+ */
+public class ModuleScopeContext extends AbstractScopeContext implements RuntimeEventListener, LifecycleEventListener {
+
+ // ----------------------------------
+ // Fields
+ // ----------------------------------
+
+ // Component contexts in this scope keyed by name
+ private Map<String, InstanceContext> componentContexts;
+
+ private Queue<SimpleComponentContext> destroyableContexts;
+
+ // ----------------------------------
+ // Constructor
+ // ----------------------------------
+
+ public ModuleScopeContext(EventContext eventContext) {
+ super(eventContext);
+ setName("Module Scope");
+ }
+
+ // ----------------------------------
+ // Listener methods
+ // ----------------------------------
+
+ public void onEvent(int type, Object key) {
+ if (type == EventContext.MODULE_START) {
+ lifecycleState = RUNNING;
+ initComponentContexts();
+ } else if (type == EventContext.MODULE_STOP) {
+ notifyInstanceShutdown(key);
+ }
+ }
+
+ // ----------------------------------
+ // Lifecycle methods
+ // ----------------------------------
+
+ public synchronized void start() {
+ if (lifecycleState != UNINITIALIZED) {
+ throw new IllegalStateException("Scope must be in UNINITIALIZED state [" + lifecycleState + "]");
+ }
+ }
+
+ public synchronized void stop() {
+ if (lifecycleState != RUNNING) {
+ throw new IllegalStateException("Scope in wrong state [" + lifecycleState + "]");
+ }
+ super.stop();
+ componentContexts = null;
+ destroyableContexts = null;
+ lifecycleState = STOPPED;
+ }
+
+ // ----------------------------------
+ // Methods
+ // ----------------------------------
+
+ public boolean isCacheable() {
+ return true;
+ }
+
+ public void registerConfiguration(RuntimeConfiguration<InstanceContext> configuration) {
+ runtimeConfigurations.put(configuration.getName(), configuration);
+ if (lifecycleState == RUNNING) {
+ componentContexts.put(configuration.getName(), configuration.createInstanceContext());
+ }
+ }
+
+ public InstanceContext getContext(String ctxName) {
+ checkInit();
+ return componentContexts.get(ctxName);
+ }
+
+ public InstanceContext getContextByKey(String ctxName, Object key) {
+ checkInit();
+ return componentContexts.get(ctxName);
+ }
+
+ public void removeContext(String ctxName) {
+ checkInit();
+ Object component = componentContexts.remove(ctxName);
+ if (component != null) {
+ destroyableContexts.remove(component);
+ }
+ }
+
+ public void removeContextByKey(String ctxName, Object key) {
+ checkInit();
+ removeContext(ctxName);
+ }
+
+ public void onInstanceCreate(Context context) {
+ checkInit();
+ if (context instanceof SimpleComponentContext) {
+ SimpleComponentContext serviceContext = (SimpleComponentContext) context;
+ // Queue the context to have its implementation instance released if destroyable
+ if (serviceContext.isDestroyable()) {
+ destroyableContexts.add(serviceContext);
+ }
+ }
+ }
+
+ /**
+ * Returns an array of {@link SimpleComponentContext}s representing components that need to be notified of scope shutdown.
+ */
+ protected InstanceContext[] getShutdownContexts(Object key) {
+ if (destroyableContexts != null) {
+ // create 0-length array since Queue.size() has O(n) traversal
+ return (InstanceContext[]) destroyableContexts.toArray(new InstanceContext[0]);
+ } else {
+ return null;
+ }
+ }
+
+ // ----------------------------------
+ // Private methods
+ // ----------------------------------
+
+ private synchronized void initComponentContexts() throws CoreRuntimeException {
+ if (componentContexts == null) {
+ componentContexts = new ConcurrentHashMap();
+ destroyableContexts = new ConcurrentLinkedQueue();
+ for (RuntimeConfiguration<InstanceContext> config : runtimeConfigurations.values()) {
+ InstanceContext context = config.createInstanceContext();
+ context.addContextListener(this);
+ context.start();
+ componentContexts.put(context.getName(), context);
+ }
+ // Initialize eager contexts. Note this cannot be done when we initially create each context since a component may
+ // contain a forward reference to a component which has not been instantiated
+ for (InstanceContext context : componentContexts.values()) {
+ if (context instanceof SimpleComponentContext) {
+ SimpleComponentContext simpleCtx = (SimpleComponentContext) context;
+ if (simpleCtx.isEagerInit()) {
+ // perform silent creation and manual shutdown registration
+ simpleCtx.getInstance(null, false);
+ if (simpleCtx.isDestroyable()) {
+ destroyableContexts.add(simpleCtx);
+ }
+ }
+ }
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/scope/RequestScopeContext.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/scope/RequestScopeContext.java
new file mode 100644
index 0000000000..deed3e2dee
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/scope/RequestScopeContext.java
@@ -0,0 +1,224 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.context.scope;
+
+import java.util.Map;
+import java.util.Queue;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentLinkedQueue;
+
+import org.apache.tuscany.core.builder.RuntimeConfiguration;
+import org.apache.tuscany.core.context.InstanceContext;
+import org.apache.tuscany.core.context.Context;
+import org.apache.tuscany.core.context.LifecycleEventListener;
+import org.apache.tuscany.core.context.CoreRuntimeException;
+import org.apache.tuscany.core.context.EventContext;
+import org.apache.tuscany.core.context.RuntimeEventListener;
+import org.apache.tuscany.core.context.SimpleComponentContext;
+
+/**
+ * An implementation of a request-scoped component container.
+ *
+ * @version $Rev$ $Date$
+ */
+public class RequestScopeContext extends AbstractScopeContext implements RuntimeEventListener, LifecycleEventListener {
+
+ // ----------------------------------
+ // Fields
+ // ----------------------------------
+
+ // A collection of service component contexts keyed by thread. Note this could have been implemented with a ThreadLocal but
+ // using a Map allows finer-grained concurrency.
+ private Map<Object, Map<String, InstanceContext>> contextMap;
+
+ // stores ordered lists of contexts to shutdown for each thread.
+ private Map<Object, Queue> destroyComponents;
+
+ // ----------------------------------
+ // Constructor
+ // ----------------------------------
+
+ public RequestScopeContext(EventContext eventContext) {
+ super(eventContext);
+ setName("Request Scope");
+ }
+
+ // ----------------------------------
+ // Listener methods
+ // ----------------------------------
+
+ public void onEvent(int type, Object key) {
+ checkInit();
+ /* clean up current context for pooled threads */
+ if (type == EventContext.REQUEST_END) {
+ getEventContext().clearIdentifier(EventContext.HTTP_SESSION);
+ notifyInstanceShutdown(Thread.currentThread());
+ destroyContext();
+ }
+ }
+
+ // ----------------------------------
+ // Lifecycle methods
+ // ----------------------------------
+
+ public synchronized void start() {
+ if (lifecycleState != UNINITIALIZED) {
+ throw new IllegalStateException("Scope must be in UNINITIALIZED state [" + lifecycleState + "]");
+ }
+ super.start();
+ contextMap = new ConcurrentHashMap();
+ destroyComponents = new ConcurrentHashMap();
+ lifecycleState = RUNNING;
+
+ }
+
+ public synchronized void stop() {
+ if (lifecycleState != RUNNING) {
+ throw new IllegalStateException("Scope in wrong state [" + lifecycleState + "]");
+ }
+ super.stop();
+ contextMap = null;
+ destroyComponents = null;
+ lifecycleState = STOPPED;
+ }
+
+ // ----------------------------------
+ // Methods
+ // ----------------------------------
+
+ public boolean isCacheable() {
+ return true;
+ }
+
+ public void registerConfiguration(RuntimeConfiguration<InstanceContext> configuration) {
+ runtimeConfigurations.put(configuration.getName(), configuration);
+ }
+
+ public InstanceContext getContext(String ctxName) {
+ checkInit();
+ Map<String, InstanceContext> contexts = getComponentContexts();
+ InstanceContext ctx = contexts.get(ctxName);
+ if (ctx == null){
+ // check to see if the configuration was added after the request was started
+ RuntimeConfiguration<InstanceContext> configuration = runtimeConfigurations.get(ctxName);
+ if (configuration != null) {
+ ctx = configuration.createInstanceContext();
+ ctx.addContextListener(this);
+ ctx.start();
+ contexts.put(ctx.getName(), ctx);
+ }
+ }
+ return ctx;
+ }
+
+ public InstanceContext getContextByKey(String ctxName, Object key) {
+ checkInit();
+ if (key == null) {
+ return null;
+ }
+ Map<String, InstanceContext> components = (Map) contextMap.get(key);
+ if (components == null) {
+ return null;
+ }
+ return components.get(ctxName);
+ }
+
+ public void removeContext(String ctxName) {
+ checkInit();
+ removeContextByKey(ctxName, Thread.currentThread());
+ }
+
+ public void removeContextByKey(String ctxName, Object key) {
+ checkInit();
+ if (key == null || ctxName == null) {
+ return;
+ }
+ Map components = (Map) contextMap.get(key);
+ if (components == null) {
+ return;
+ }
+ components.remove(ctxName);
+ Map<String, InstanceContext> contexts = (Map) contextMap.get(key);
+ // no synchronization for the following two operations since the request
+ // context will not be shutdown before the second call is processed
+ InstanceContext context = contexts.get(ctxName);
+ destroyComponents.get(key).remove(context);
+ }
+
+ public void onInstanceCreate(Context context) {
+ checkInit();
+ if (context instanceof SimpleComponentContext) {
+ // Queue the context to have its implementation instance released if destroyable
+ if (((SimpleComponentContext) context).isDestroyable()) {
+ Queue collection = destroyComponents.get(Thread.currentThread());
+ collection.add(context);
+ }
+ }
+ }
+
+ /**
+ * Returns an array of {@link SimpleComponentContext}s representing components that need to be notified of scope shutdown.
+ */
+ protected InstanceContext[] getShutdownContexts(Object key) {
+ checkInit();
+ Queue queue = destroyComponents.get(Thread.currentThread());
+ if (queue != null) {
+ // create 0-length array since Queue.size() has O(n) traversal
+ return (InstanceContext[]) queue.toArray(new InstanceContext[0]);
+ } else {
+ return null;
+ }
+ }
+
+ // ----------------------------------
+ // Private methods
+ // ----------------------------------
+
+ private void destroyContext() {
+ // TODO uninitialize all request-scoped components
+ contextMap.remove(Thread.currentThread());
+ destroyComponents.remove(Thread.currentThread());
+ }
+
+ /**
+ * Initializes ServiceComponentContexts for the current request.
+ * <p>
+ * TODO This eagerly creates all component contexts, even if the component is never accessed during the request. This method
+ * should be profiled to determine if lazy initialization is more performant
+ * <p>
+ * TODO Eager initialization is not performed for request-scoped components
+ */
+
+ private Map<String, InstanceContext> getComponentContexts() throws CoreRuntimeException {
+ Map contexts = (Map) contextMap.get(Thread.currentThread());
+ if (contexts == null) {
+ contexts = new ConcurrentHashMap();
+ Queue shutdownQueue = new ConcurrentLinkedQueue();
+ for (RuntimeConfiguration<InstanceContext> config : runtimeConfigurations.values()) {
+ InstanceContext context = null;
+ context = config.createInstanceContext();
+ context.addContextListener(this);
+ context.start();
+ contexts.put(context.getName(), context);
+ }
+ contextMap.put(Thread.currentThread(), contexts);
+ destroyComponents.put(Thread.currentThread(), shutdownQueue);
+ }
+ return contexts;
+ }
+
+} \ No newline at end of file
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/scope/StatelessScopeContext.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/scope/StatelessScopeContext.java
new file mode 100644
index 0000000000..8b12f8b183
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/scope/StatelessScopeContext.java
@@ -0,0 +1,145 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.context.scope;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.apache.tuscany.core.builder.RuntimeConfiguration;
+import org.apache.tuscany.core.context.InstanceContext;
+import org.apache.tuscany.core.context.Context;
+import org.apache.tuscany.core.context.LifecycleEventListener;
+import org.apache.tuscany.core.context.CoreRuntimeException;
+import org.apache.tuscany.core.context.EventContext;
+import org.apache.tuscany.core.context.RuntimeEventListener;
+
+/**
+ * A container that manages stateless components.
+ *
+ * @version $Rev$ $Date$
+ */
+public class StatelessScopeContext extends AbstractScopeContext implements RuntimeEventListener, LifecycleEventListener {
+
+ // ----------------------------------
+ // Fields
+ // ----------------------------------
+
+ // Component contexts keyed by name
+ private Map<String, InstanceContext> contextMap;
+
+ // ----------------------------------
+ // Constructor
+ // ----------------------------------
+
+ public StatelessScopeContext(EventContext eventContext) {
+ super(eventContext);
+ setName("Stateless Scope");
+ }
+
+ // ----------------------------------
+ // Lifecycle methods
+ // ----------------------------------
+
+ public synchronized void start() {
+ if (lifecycleState != UNINITIALIZED) {
+ throw new IllegalStateException("Scope must be in UNINITIALIZED state [" + lifecycleState + "]");
+ }
+ super.start();
+ lifecycleState = RUNNING;
+ prepare();
+ }
+
+ public synchronized void stop() {
+ if (lifecycleState != RUNNING) {
+ throw new IllegalStateException("Scope in wrong state [" + lifecycleState + "]");
+ }
+ super.stop();
+ contextMap = null;
+ lifecycleState = STOPPED;
+ }
+
+ // ----------------------------------
+ // Methods
+ // ----------------------------------
+
+ public void registerConfiguration(RuntimeConfiguration<InstanceContext> configuration) {
+ runtimeConfigurations.put(configuration.getName(), configuration);
+ if (lifecycleState == RUNNING) {
+ contextMap.put(configuration.getName(), configuration.createInstanceContext());
+ }
+
+ }
+
+ public void onEvent(int type, Object key) {
+ // do nothing
+ }
+
+ public boolean isCacheable() {
+ return true;
+ }
+
+ public InstanceContext getContext(String ctxName) {
+ return contextMap.get(ctxName);
+ }
+
+ public InstanceContext getContextByKey(String ctxName, Object key) {
+ return getContext(ctxName);
+ }
+
+ public void removeContext(String ctxName) {
+ removeContextByKey(ctxName, null);
+ }
+
+ public void removeContextByKey(String ctxName, Object key) {
+ contextMap.remove(ctxName);
+ }
+
+ /**
+ * Always returns null since stateless components cannot be shutdown
+ */
+ protected InstanceContext[] getShutdownContexts(Object key) {
+ return null;
+ }
+
+ // ----------------------------------
+ // Private methods
+ // ----------------------------------
+
+ public void onInstanceCreate(Context component) {
+ // do nothing
+ }
+
+ private void prepare() throws CoreRuntimeException {
+ if (lifecycleState != RUNNING) {
+ throw new IllegalStateException("Scope not in INITIALIZED state [" + lifecycleState + "]");
+ }
+ if (contextMap == null) {
+ contextMap = new ConcurrentHashMap();
+ for (RuntimeConfiguration<InstanceContext> config : runtimeConfigurations.values()) {
+ for (int i = 0; i < runtimeConfigurations.size(); i++) {
+ InstanceContext context = null;
+ context = config.createInstanceContext();
+ context.addContextListener(this);
+ context.start();
+ contextMap.put(context.getName(), context);
+ }
+
+ }
+ }
+ }
+
+} \ No newline at end of file
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/webapp/HTTPSessionExpirationListener.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/webapp/HTTPSessionExpirationListener.java
new file mode 100644
index 0000000000..923b9fb941
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/webapp/HTTPSessionExpirationListener.java
@@ -0,0 +1,62 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.context.webapp;
+
+import javax.servlet.http.HttpSessionEvent;
+import javax.servlet.http.HttpSessionListener;
+
+import org.apache.tuscany.core.context.AggregateContext;
+import org.apache.tuscany.core.context.EventContext;
+
+/**
+ * Cleans up resources used by expired sessions
+ *
+ * @version $Rev$ $Date$
+ */
+public class HTTPSessionExpirationListener implements HttpSessionListener {
+ // ----------------------------------
+ // Constructors
+ // ----------------------------------
+
+ public HTTPSessionExpirationListener() {
+ }
+
+ // ----------------------------------
+ // Methods
+ // ----------------------------------
+
+ public void sessionCreated(HttpSessionEvent event) {
+ // do nothing since sessions are lazily created in {@link
+ // org.apache.tuscany.tomcat.webapp.listener.RequestFilter}
+ }
+
+ public void sessionDestroyed(HttpSessionEvent event) {
+ TuscanyWebAppRuntime tuscanyRuntime = null;
+ try {
+ tuscanyRuntime = (TuscanyWebAppRuntime) event.getSession().getServletContext().getAttribute(
+ TuscanyWebAppRuntime.class.getName());
+ tuscanyRuntime.start();
+
+ // End the session
+ AggregateContext context = tuscanyRuntime.getModuleComponentContext();
+ context.fireEvent(EventContext.SESSION_END, event.getSession());
+ } finally {
+ if (tuscanyRuntime != null)
+ tuscanyRuntime.stop();
+ }
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/webapp/LazyHTTPSessionId.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/webapp/LazyHTTPSessionId.java
new file mode 100644
index 0000000000..186f35df14
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/webapp/LazyHTTPSessionId.java
@@ -0,0 +1,56 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.context.webapp;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.tuscany.core.context.ScopeIdentifier;
+
+/**
+ * Implements a <code>ScopeIdentifier</code> for a Servlet-based transport.
+ * Wraps an <code>HttpServletRequest</code> so that the session id associated
+ * with the current request may be lazily retrieved by the module context - i.e.
+ * if a session context or session-scoped component is not accessed, no session
+ * is created.
+ *
+ * @version $Rev$ $Date$
+ */
+public class LazyHTTPSessionId implements ScopeIdentifier {
+
+ private HttpServletRequest request;
+
+ //----------------------------------
+ // Constructors
+ //----------------------------------
+
+ public LazyHTTPSessionId(HttpServletRequest request) {
+ this.request = request;
+ }
+
+ //----------------------------------
+ // Methods
+ //----------------------------------
+
+ /**
+ * Returns the session identifier
+ *
+ * @see org.apache.tuscany.core.context.ScopeIdentifier#getIdentifier()
+ */
+ public Object getIdentifier() {
+ return request.getSession(true);
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/webapp/TuscanyRequestFilter.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/webapp/TuscanyRequestFilter.java
new file mode 100644
index 0000000000..8e92c9ebd4
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/webapp/TuscanyRequestFilter.java
@@ -0,0 +1,107 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.context.webapp;
+
+import java.io.IOException;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.tuscany.core.context.AggregateContext;
+import org.apache.tuscany.core.context.EventContext;
+
+/**
+ * Notifies the {@link org.apache.tuscany.core.context.AggregateContext} of web request start and end events as well as setting up the
+ * current session context. The latter is done using lazy Servlet-based session retrieval. The filter fires a session
+ * start event, passing a <tt>LazyServletSessionId</tt> as the session id. The <tt>LazyServletSessionId</tt> is a
+ * wrapper for the servlet request which may be called by the <tt>ModuleContext</tt> to retrieve the session id
+ * lazily.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TuscanyRequestFilter implements Filter {
+ private TuscanyWebAppRuntime tuscanyRuntime;
+
+ // ----------------------------------
+ // Constructors
+ // ----------------------------------
+
+ public TuscanyRequestFilter() {
+ }
+
+ // ----------------------------------
+ // Methods
+ // ----------------------------------
+
+ public void init(FilterConfig filterConfig) throws ServletException {
+
+ // Get the Tuscany runtime from the servlet context
+ tuscanyRuntime = (TuscanyWebAppRuntime) filterConfig.getServletContext().getAttribute(
+ TuscanyWebAppRuntime.class.getName());
+ }
+
+ public void destroy() {
+ }
+
+ public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws ServletException,
+ IOException {
+ // Get the module component context from the tuscany runtime
+ AggregateContext context = tuscanyRuntime.getModuleComponentContext();
+ try {
+
+ // Start the SCA implementation
+ tuscanyRuntime.start();
+
+ // Handle a request
+ if (request instanceof HttpServletRequest) {
+ if (((HttpServletRequest) request).getSession(false) != null) {
+
+ // A session is already active
+ context.fireEvent(EventContext.SESSION_NOTIFY, ((HttpServletRequest) request).getSession(true));
+ } else {
+ // Create a lazy wrapper since a session is not yet active
+ context.fireEvent(EventContext.SESSION_NOTIFY, new LazyHTTPSessionId((HttpServletRequest) request));
+ }
+ } else {
+ context.fireEvent(EventContext.SESSION_NOTIFY, request);
+ }
+ // Start processing the request
+ context.fireEvent(EventContext.REQUEST_START, request);
+ // Dispatch to the next filter
+ filterChain.doFilter(request, response);
+ } catch (Exception e) {
+ throw new ServletException(e);
+
+ } finally {
+ try {
+ // End processing the request
+ context.fireEvent(EventContext.REQUEST_END, request);
+ // Stop the SCA implementation
+ tuscanyRuntime.stop();
+ } catch (Exception e) {
+ throw new ServletException(e);
+ }
+ }
+
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/webapp/TuscanyWebAppRuntime.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/webapp/TuscanyWebAppRuntime.java
new file mode 100644
index 0000000000..3b9801a811
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/context/webapp/TuscanyWebAppRuntime.java
@@ -0,0 +1,59 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.context.webapp;
+
+import org.apache.tuscany.core.context.AggregateContext;
+import org.osoa.sca.ModuleContext;
+import org.osoa.sca.SCA;
+
+/**
+ * An implementation of the SCA runtime for use in a Web app
+ *
+ * @version $Rev$ $Date$
+ */
+public class TuscanyWebAppRuntime extends SCA {
+ private AggregateContext moduleComponentContext;
+
+ // ----------------------------------
+ // Constructors
+ // ----------------------------------
+
+ public TuscanyWebAppRuntime(AggregateContext moduleComponentContext) {
+ this.moduleComponentContext = moduleComponentContext;
+ }
+
+ // ----------------------------------
+ // Methods
+ // ----------------------------------
+
+ /**
+ * Returns the module component context associated with this runtime
+ */
+ public AggregateContext getModuleComponentContext() {
+ return moduleComponentContext;
+ }
+
+ public void start() {
+ // Associate it with the current thread
+ setModuleContext((ModuleContext) moduleComponentContext);
+ }
+
+ public void stop() {
+ setModuleContext(null);
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/injection/EventInvoker.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/injection/EventInvoker.java
new file mode 100644
index 0000000000..d2b95ae70e
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/injection/EventInvoker.java
@@ -0,0 +1,17 @@
+package org.apache.tuscany.core.injection;
+
+/**
+ * Performs an invocation on an instance
+ *
+ * @version $Rev$ $Date$
+ * @see MethodEventInvoker
+ */
+public interface EventInvoker<T> {
+
+ /**
+ * Performs the invocation on a given instance
+ *
+ * @throws ObjectCallbackException
+ */
+ void invokeEvent(T instance) throws ObjectCallbackException;
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/injection/FactoryInitException.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/injection/FactoryInitException.java
new file mode 100644
index 0000000000..e9573d4a4e
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/injection/FactoryInitException.java
@@ -0,0 +1,27 @@
+package org.apache.tuscany.core.injection;
+
+/**
+ * Denotes an exception initializing an object factory
+ *
+ * @version $Rev$ $Date$
+ */
+public class FactoryInitException extends InjectionRuntimeException {
+
+ public FactoryInitException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public FactoryInitException(String message) {
+ super(message);
+ }
+
+ public FactoryInitException(Throwable cause) {
+ super(cause);
+ }
+
+ public FactoryInitException() {
+ super();
+ }
+
+}
+
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/injection/FieldInjector.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/injection/FieldInjector.java
new file mode 100644
index 0000000000..c48f620a3f
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/injection/FieldInjector.java
@@ -0,0 +1,45 @@
+package org.apache.tuscany.core.injection;
+
+import java.lang.reflect.Field;
+
+import org.apache.tuscany.core.builder.ObjectFactory;
+
+/**
+ * Injects a value created by an {@link ObjectFactory} on a given field
+ *
+ * @version $Rev$ $Date$
+ */
+public class FieldInjector<T> implements Injector<T> {
+
+ private final Field field;
+
+ private final ObjectFactory<?> objectFactory;
+
+ // //----------------------------------
+ // Constructors
+ // ----------------------------------
+
+ /**
+ * Create an injector and have it use the given <code>ObjectFactory</code>
+ * to inject a value on the instance using the reflected <code>Field</code>
+ */
+ public FieldInjector(Field field, ObjectFactory<?> objectFactory) {
+ this.field = field;
+ this.objectFactory = objectFactory;
+ }
+
+ // ----------------------------------
+ // Methods
+ // ----------------------------------
+
+ /**
+ * Inject a new value on the given isntance
+ */
+ public void inject(T instance) throws ObjectCreationException {
+ try {
+ field.set(instance, objectFactory.getInstance());
+ } catch (IllegalAccessException e) {
+ throw new AssertionError("Field is not accessible [" + field + "]");
+ }
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/injection/InjectionRuntimeException.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/injection/InjectionRuntimeException.java
new file mode 100644
index 0000000000..ac8b09eab2
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/injection/InjectionRuntimeException.java
@@ -0,0 +1,29 @@
+package org.apache.tuscany.core.injection;
+
+import org.apache.tuscany.common.TuscanyRuntimeException;
+
+/**
+ * Root unchecked exception for the injection package
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class InjectionRuntimeException extends TuscanyRuntimeException {
+
+ public InjectionRuntimeException() {
+ super();
+ }
+
+ public InjectionRuntimeException(String message) {
+ super(message);
+ }
+
+ public InjectionRuntimeException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public InjectionRuntimeException(Throwable cause) {
+ super(cause);
+ }
+
+}
+
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/injection/Injector.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/injection/Injector.java
new file mode 100644
index 0000000000..013b1c5874
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/injection/Injector.java
@@ -0,0 +1,17 @@
+package org.apache.tuscany.core.injection;
+
+/**
+ * Implementations inject a pre-configured value on an instance
+ *
+ * @version $Rev$ $Date$
+ * @see MethodInjector
+ * @see FieldInjector
+ */
+public interface Injector<T> {
+
+ /**
+ * Inject a value on the given instance
+ */
+ void inject(T instance) throws ObjectCreationException;
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/injection/MethodEventInvoker.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/injection/MethodEventInvoker.java
new file mode 100644
index 0000000000..08dd4cd124
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/injection/MethodEventInvoker.java
@@ -0,0 +1,39 @@
+package org.apache.tuscany.core.injection;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+/**
+ * Performs an invocation on a method of a given instance
+ *
+ * @version $Rev$ $Date$
+ */
+public class MethodEventInvoker<T> implements EventInvoker<T> {
+ private final Method method;
+
+ //----------------------------------
+ // Constructors
+ //----------------------------------
+
+ /**
+ * Intantiates an invoker for the given method
+ */
+ public MethodEventInvoker(Method method) {
+ this.method = method;
+ }
+
+ //----------------------------------
+ // Methods
+ //----------------------------------
+
+ public void invokeEvent(T instance) throws ObjectCallbackException {
+ try {
+ method.invoke(instance, (Object[]) null);
+ } catch (IllegalAccessException e) {
+ throw new AssertionError("Method is not accessible [" + method + "]");
+ } catch (InvocationTargetException e) {
+ throw new ObjectCallbackException("Exception thrown by callback method [" + method + "]", e);
+ }
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/injection/MethodInjector.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/injection/MethodInjector.java
new file mode 100644
index 0000000000..55ea7bae5f
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/injection/MethodInjector.java
@@ -0,0 +1,30 @@
+package org.apache.tuscany.core.injection;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.core.builder.ObjectFactory;
+
+/**
+ * Injects a value created by an {@link ObjectFactory} using a given method
+ * @version $Rev$ $Date$
+ */
+public class MethodInjector<T> implements Injector<T> {
+ private final Method method;
+ private final ObjectFactory<?> objectFactory;
+
+ public MethodInjector(Method method, ObjectFactory<?> objectFactory) {
+ this.method = method;
+ this.objectFactory = objectFactory;
+ }
+
+ public void inject(T instance) throws ObjectCreationException {
+ try {
+ method.invoke(instance, new Object[]{objectFactory.getInstance()});
+ } catch (IllegalAccessException e) {
+ throw new AssertionError("Method is not accessible [" + method + "]");
+ } catch (InvocationTargetException e) {
+ throw new ObjectCreationException("Exception thrown by setter [" + method + "]", e);
+ }
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/injection/NullEventInvoker.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/injection/NullEventInvoker.java
new file mode 100644
index 0000000000..23599bae0e
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/injection/NullEventInvoker.java
@@ -0,0 +1,14 @@
+package org.apache.tuscany.core.injection;
+
+/**
+ * A no-op invoker
+ *
+ * @version $Rev$ $Date$
+ */
+public final class NullEventInvoker<T> implements EventInvoker<T> {
+ public static final EventInvoker<?> NULL_INVOKER = new NullEventInvoker();
+
+ public void invokeEvent(T instance) {
+ // does nothing
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/injection/ObjectCallbackException.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/injection/ObjectCallbackException.java
new file mode 100644
index 0000000000..b428c31f4f
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/injection/ObjectCallbackException.java
@@ -0,0 +1,26 @@
+package org.apache.tuscany.core.injection;
+
+/**
+ * Denotes an error when invoking on an object
+ *
+ * @version $Rev$ $Date$
+ */
+public class ObjectCallbackException extends InjectionRuntimeException {
+
+ public ObjectCallbackException() {
+ super();
+ }
+
+ public ObjectCallbackException(String message) {
+ super(message);
+ }
+
+ public ObjectCallbackException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public ObjectCallbackException(Throwable cause) {
+ super(cause);
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/injection/ObjectCreationException.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/injection/ObjectCreationException.java
new file mode 100644
index 0000000000..338b841c49
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/injection/ObjectCreationException.java
@@ -0,0 +1,27 @@
+package org.apache.tuscany.core.injection;
+
+/**
+ * Denotes an error creating a new object instance
+ *
+ * @version $Rev$ $Date$
+ */
+public class ObjectCreationException extends InjectionRuntimeException {
+
+ public ObjectCreationException() {
+ super();
+ }
+
+ public ObjectCreationException(String message) {
+ super(message);
+ }
+
+ public ObjectCreationException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public ObjectCreationException(Throwable cause) {
+ super(cause);
+ }
+
+}
+
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/injection/PojoObjectFactory.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/injection/PojoObjectFactory.java
new file mode 100644
index 0000000000..e3e1874b1e
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/injection/PojoObjectFactory.java
@@ -0,0 +1,75 @@
+package org.apache.tuscany.core.injection;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.tuscany.core.builder.ObjectFactory;
+
+/**
+ * Creates new instances of a Java class, calling a given set of injectors to configure the instance
+ *
+ * @version $Rev$ $Date$
+ * @see Injector
+ */
+public class PojoObjectFactory<T> implements ObjectFactory<T> {
+
+ // ----------------------------------
+ // Constants
+ // ----------------------------------
+
+ private static final ObjectFactory[] NO_INIT_PARAM = {};
+
+ private static final List<Injector> NO_SETTER_PARAM = Collections.EMPTY_LIST;
+
+ // ----------------------------------
+ // Fields
+ // ----------------------------------
+
+ private final Constructor<T> ctr;
+
+ private final ObjectFactory<?>[] initParamsArray;
+
+ private final List<Injector> setters;
+
+ // ----------------------------------
+ // Constructors
+ // ----------------------------------
+
+ public PojoObjectFactory(Constructor<T> ctr, List<ObjectFactory> initParams, List<Injector> setters) {
+ this.ctr = ctr;
+ if (initParams != null && initParams.size() > 0) {
+ initParamsArray = initParams.toArray(new ObjectFactory[initParams.size()]);
+ } else {
+ initParamsArray = NO_INIT_PARAM;
+ }
+ this.setters = setters != null ? setters : NO_SETTER_PARAM;
+ } // ----------------------------------
+
+ // Methods
+ // ----------------------------------
+
+ public T getInstance() throws ObjectCreationException {
+ Object[] initargs = new Object[initParamsArray.length];
+ // create the constructor arg array
+ for (int i = 0; i < initParamsArray.length; i++) {
+ ObjectFactory<?> objectFactory = initParamsArray[i];
+ initargs[i] = objectFactory.getInstance();
+ }
+ try {
+ T instance = ctr.newInstance(initargs);
+ // interate through the injectors and inject the instance
+ for (Injector setter : setters) {
+ setter.inject(instance);
+ }
+ return instance;
+ } catch (InstantiationException e) {
+ throw new AssertionError("Class is not instantiable [" + ctr.getDeclaringClass().getName() + "]");
+ } catch (IllegalAccessException e) {
+ throw new AssertionError("Constructor is not accessible [" + ctr + "]");
+ } catch (InvocationTargetException e) {
+ throw new ObjectCreationException("Exception thrown by constructor [" + ctr + "]", e);
+ }
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/injection/ReferenceTargetFactory.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/injection/ReferenceTargetFactory.java
new file mode 100644
index 0000000000..f84c5b7ed1
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/injection/ReferenceTargetFactory.java
@@ -0,0 +1,133 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.injection;
+
+import org.apache.tuscany.core.builder.ObjectFactory;
+import org.apache.tuscany.core.context.AggregateContext;
+import org.apache.tuscany.core.context.InstanceContext;
+import org.apache.tuscany.core.context.QualifiedName;
+import org.apache.tuscany.core.context.TargetException;
+import org.apache.tuscany.model.assembly.Component;
+import org.apache.tuscany.model.assembly.ConfiguredReference;
+import org.apache.tuscany.model.assembly.ConfiguredService;
+import org.apache.tuscany.model.assembly.EntryPoint;
+import org.apache.tuscany.model.assembly.ExternalService;
+
+/**
+ * Returns a direct reference to a target service, i.e. the factory avoids creating proxies and returns the actual
+ * target instance
+ *
+ * @version $Rev$ $Date$
+ */
+public class ReferenceTargetFactory<T> implements ObjectFactory<T> {
+
+ private AggregateContext parentContext;
+
+ // the SCDL name of the target component/service for this reference
+ private String targetName;
+
+ private QualifiedName targetComponentName;
+
+ // the reference target is in another module
+ private boolean interModule;
+
+ // ----------------------------------
+ // Constructors
+ // ----------------------------------
+
+ /**
+ * Constructs a reference object factory from a configured reference on a type
+ */
+ public ReferenceTargetFactory(ConfiguredReference reference, AggregateContext parentContext)
+ throws FactoryInitException {
+ // FIXME how to handle a reference that is a list - may take different proxy factories for each entry
+ assert (reference != null) : "Reference was null";
+ assert (parentContext != null) : "Parent context was null";
+
+ this.parentContext = parentContext;
+ // targetName = reference.getReference().getName();
+ ConfiguredService targetService = reference.getTargetConfiguredServices().get(0);
+ if (targetService.getAggregatePart() instanceof ExternalService) {
+ targetName = ((ExternalService) targetService.getAggregatePart()).getName();
+ } else if (targetService.getAggregatePart() instanceof Component) {
+ Component targetComponent = (Component) targetService.getAggregatePart();
+ targetName = targetComponent.getName();
+ } else if (targetService.getAggregatePart() instanceof EntryPoint) {
+ targetName = ((EntryPoint) targetService.getAggregatePart()).getName();
+ } else if (targetService.getAggregatePart() == null) {
+ // FIXME not correct
+ if (targetService.getService() == null) {
+ throw new FactoryInitException("No target service specified");
+ }
+ targetName = targetService.getService().getName();
+ } else {
+ FactoryInitException fie = new FactoryInitException("Unknown reference target type");
+ fie.setIdentifier(reference.getReference().getName());
+ throw fie;
+ }
+ }
+
+ /**
+ * Reference source is an external service, target is in another module
+ *
+ * @param service
+ * @param parentContext
+ * @throws FactoryInitException
+ */
+ public ReferenceTargetFactory(String targetName, AggregateContext parentContext) throws FactoryInitException {
+ //assert (service != null) : "Service was null";
+ assert (parentContext != null) : "Parent context was null";
+ interModule = true; // an external service with a reference target in another module
+ this.targetName = targetName;// service.getAggregatePart().getName();
+ targetComponentName = new QualifiedName(targetName);
+ this.parentContext = parentContext;
+ }
+
+ // ----------------------------------
+ // Methods
+ // ----------------------------------
+
+ public T getInstance() throws ObjectCreationException {
+ if (interModule) {
+ // only return entry points since this is an inter-module wire
+ Object o = parentContext.getInstance(targetComponentName);
+ if (o != null) {
+ return (T) o;
+ } else {
+ // walk up the hierarchy of aggregate contexts
+ AggregateContext ctx = parentContext;
+ do {
+ if (ctx == null) {
+ break; // reached top of context hierarchy
+ }
+ InstanceContext compContext = ctx.getContext(targetComponentName.getPartName());
+ if (compContext != null) {
+ o = compContext.getInstance(targetComponentName);
+ if (o != null) {
+ return (T) o;
+ }
+ }
+ ctx = ctx.getParent();
+ } while (ctx != null);
+ TargetException e= new TargetException("Target reference not found");
+ e.setIdentifier(targetName);
+ throw e;
+ }
+ } else {
+ // the target is in the same module, so just locate it
+ return (T) parentContext.locateInstance(targetName);
+ }
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/injection/SDOObjectFactory.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/injection/SDOObjectFactory.java
new file mode 100644
index 0000000000..8147fa0d51
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/injection/SDOObjectFactory.java
@@ -0,0 +1,37 @@
+package org.apache.tuscany.core.injection;
+
+import org.apache.tuscany.core.builder.ObjectFactory;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.helper.CopyHelper;
+
+/**
+ * Creates new instances of an SDO
+ *
+ * @version $Rev$ $Date$
+ */
+public class SDOObjectFactory implements ObjectFactory<DataObject> {
+
+ private DataObject dataObject;
+
+ //----------------------------------
+ // Constructors
+ //----------------------------------
+
+ public SDOObjectFactory(DataObject dataObject) {
+ this.dataObject = dataObject;
+ }
+
+ //----------------------------------
+ // Methods
+ //----------------------------------
+
+ public DataObject getInstance() throws ObjectCreationException {
+ return CopyHelper.INSTANCE.copy(dataObject);
+ }
+
+ public void releaseInstance(DataObject instance) {
+ }
+
+}
+
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/injection/SingletonObjectFactory.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/injection/SingletonObjectFactory.java
new file mode 100644
index 0000000000..9f46357086
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/injection/SingletonObjectFactory.java
@@ -0,0 +1,29 @@
+package org.apache.tuscany.core.injection;
+
+import org.apache.tuscany.core.builder.ObjectFactory;
+
+/**
+ * Implementation of ObjectFactory that returns a single instance, typically an immutable type.
+ *
+ * @version $Rev$ $Date$
+ */
+public class SingletonObjectFactory<T> implements ObjectFactory<T> {
+ private final T instance;
+
+ // ----------------------------------
+ // Constructors
+ // ----------------------------------
+
+ public SingletonObjectFactory(T instance) {
+ this.instance = instance;
+ }
+
+ // ----------------------------------
+ // Methods
+ // ----------------------------------
+
+ public T getInstance() {
+ return instance;
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/Interceptor.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/Interceptor.java
new file mode 100644
index 0000000000..40137f9b10
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/Interceptor.java
@@ -0,0 +1,42 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.invocation;
+
+import org.apache.tuscany.core.message.Message;
+
+/**
+ * Synchronous, around-style mediation associated with a client- or target- side invocation.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface Interceptor {
+
+ /**
+ * Process a synchronous invocation.
+ *
+ * @param msg the request Message for the invocation
+ * @return the response Message from the invocation
+ */
+ Message invoke(Message msg);
+
+ /**
+ * Sets the next interceptor.
+ *
+ * @param next
+ */
+ void setNext(Interceptor next);
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/InvocationConfiguration.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/InvocationConfiguration.java
new file mode 100644
index 0000000000..2c5e61a8a1
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/InvocationConfiguration.java
@@ -0,0 +1,279 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.invocation;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.core.invocation.impl.MessageChannelImpl;
+import org.apache.tuscany.core.invocation.impl.MessageDispatcher;
+import org.apache.tuscany.core.invocation.impl.RequestResponseInterceptor;
+
+/**
+ * Contains a source- or target-side invocation pipeline for a service operation. Source and target invocation pipelines
+ * are "bridged" together by a set of wire builders with the source-side holding references to the target.
+ * <p>
+ * A set of invocation configurations are used by a {@link org.apache.tuscany.core.invocation.spi.ProxyFactory} to
+ * create service proxies.
+ * <p>
+ * Invocation configurations must contain at least one interceptor and may have 0 to N handlers. Handlers process an
+ * invocation request or response in a one-way fashion. A typical invocation sequence where interceptors and handlers
+ * are configured for both the source and target-side will proceed as follows:
+ * <ol>
+ * <li>The first source interceptor will be called with a message, which will in turn invoke the next interceptor in
+ * the chain
+ * <li>The last source interceptor, which must be of type
+ * {@link org.apache.tuscany.core.invocation.impl.RequestResponseInterceptor} if there are handlers present, will be
+ * invoked. The RR interceptor will in turn pass the message to a
+ * {@link org.apache.tuscany.core.invocation.MessageChannel} which will invoke all source-side request handlers.
+ * <li> The RR interceptor will then invoke the target-side request <tt>MessageChannel</tt>.
+ * <li> The last source-side handler, an instance of
+ * {@link org.apache.tuscany.core.invocation.impl.MessageDispatcher}, will invoke the first source-side
+ * interceptor, which in turn will pass the message down the target-side interceptor chain.
+ * <li> If the target is a component instance the last target-side interceptor, an instance of
+ * {@link org.apache.tuscany.core.invocation.impl.InvokerInterceptor} will retrieve the
+ * {@link org.apache.tuscany.core.invocation.TargetInvoker} from the message and call it to invoke the operation on a
+ * target instance. <tt>TargetInvoker</tt>s are help by the source proxy to enable optimizations such as caching of
+ * target instances.
+ * <li> The response is returned up the invocation stack until it reaches the source-side
+ * <tt>RequestResponseInterceptor</tt>, which invokes the target and source-side response channels respectively.
+ * <li> The response is then passed back up the rest of the invocation stack.
+ * </ol>
+ * <p>
+ * The source-to-target bridge may be constructed in any of the following ways:
+ * <ul>
+ * <li>Source handler-to-target handler
+ * <li>Source handler-to-target interceptor
+ * <li>Source interceptor-to-target handler
+ * <li>Source interceptor-to-target interceptor
+ * </ul>
+ * <p>
+ * In some scenarios, a service proxy may only contain target-side invocaton chains, for example, when a service is
+ * resolved through a locate operation by a non-component client. In this case, there will be no source-side invocation
+ * chains and the target invoker will be held by the target-side and passed down the pipeline.
+ *
+ * @see org.apache.tuscany.core.builder.WireBuilder
+ * @see org.apache.tuscany.core.invocation.spi.ProxyFactory
+ * @see org.apache.tuscany.core.invocation.TargetInvoker
+ * @see org.apache.tuscany.core.invocation.impl.MessageDispatcher
+ *
+ * @version $Rev$ $Date$
+ */
+public class InvocationConfiguration {
+
+ // the operation on the target that will utlimately be invoked
+ private Method operation;
+
+ // responsible for invoking a target instance
+ private TargetInvoker targetInvoker;
+
+ private Interceptor sourceInterceptorChainHead;
+
+ private Interceptor sourceInterceptorChainTail;
+
+ private Interceptor targetInterceptorChainHead;
+
+ private Interceptor targetInterceptorChainTail;
+
+ private List<MessageHandler> requestHandlers;
+
+ private List<MessageHandler> responseHandlers;
+
+ // a source-side pointer to target request handlers, if the exist
+ private MessageChannel targetRequestChannel;
+
+ // a source-side pointer to target response handlers, if the exist
+ private MessageChannel targetResponseChannel;
+
+ /**
+ * Creates an new invocation configuration for the given target operation
+ */
+ public InvocationConfiguration(Method operation) {
+ assert (operation != null) : "No operation type specified";
+ this.operation = operation;
+ }
+
+ /**
+ * Returns the target operation for the invocation configuration
+ */
+ public Method getMethod() {
+ return operation;
+ }
+
+ /**
+ * Used by source-side configurations, sets a pointer to the target-side request channel. This may be null when no
+ * target request handlers exist.
+ */
+ public void setTargetRequestChannel(MessageChannel channel) {
+ targetRequestChannel = channel;
+ }
+
+ /**
+ * Used by source-side configurations, sets a pointer to the target-side response channel. This may be null when no
+ * target response handlers exist.
+ */
+ public void setTargetResponseChannel(MessageChannel channel) {
+ targetResponseChannel = channel;
+ }
+
+ /**
+ * Adds an interceptor to the invocation chain for source-side configurations
+ */
+ public void addSourceInterceptor(Interceptor interceptor) {
+ if (sourceInterceptorChainHead == null) {
+ sourceInterceptorChainHead = interceptor;
+ } else {
+ sourceInterceptorChainTail.setNext(interceptor);
+ }
+ sourceInterceptorChainTail = interceptor;
+ }
+
+ /**
+ * Adds an interceptor to the invocation chain for target-side configurations
+ */
+ public void addTargetInterceptor(Interceptor interceptor) {
+ if (targetInterceptorChainHead == null) {
+ targetInterceptorChainHead = interceptor;
+ } else {
+ targetInterceptorChainTail.setNext(interceptor);
+ }
+ targetInterceptorChainTail = interceptor;
+ }
+
+ /**
+ * Adds an request handler to the invocation chain for either a source- or target-side configuration
+ */
+ public void addRequestHandler(MessageHandler handler) {
+ if (requestHandlers == null) {
+ requestHandlers = new ArrayList<MessageHandler>();
+ }
+ requestHandlers.add(handler);
+ }
+
+ /**
+ * Adds an response handler to the invocation chain for either a source- or target-side configuration
+ */
+ public void addResponseHandler(MessageHandler handler) {
+ if (responseHandlers == null) {
+ responseHandlers = new ArrayList<MessageHandler>();
+ }
+ responseHandlers.add(handler);
+ }
+
+ /**
+ * Returns the request handler chain for either a source- or target-side configuration
+ */
+ public List<MessageHandler> getRequestHandlers() {
+ return requestHandlers;
+ }
+
+ /**
+ * Returns the response handler chain for either a source- or target-side configuration
+ */
+ public List<MessageHandler> getResponseHandlers() {
+ return responseHandlers;
+ }
+
+ /**
+ * Returns the head source-side interceptor. This will be null for target-side configurations
+ */
+ public Interceptor getSourceInterceptor() {
+ return sourceInterceptorChainHead;
+ }
+
+ /**
+ * Returns the head target-side interceptor. On source-side configurations, this will be the head interceptor of the
+ * "bridged" target configuration.
+ */
+ public Interceptor getTargetInterceptor() {
+ return targetInterceptorChainHead;
+ }
+
+
+ public Interceptor getLastTargetInterceptor() {
+ return targetInterceptorChainTail;
+ }
+
+ /**
+ * Sets the target invoker to pass down the invocation pipeline. When a service proxy represents a wire,
+ * the target invoker is set on the source-side.
+ */
+ public void setTargetInvoker(TargetInvoker invoker) {
+ this.targetInvoker = invoker;
+ }
+
+ /**
+ * Returns the target invoker that is passed down the invocation pipeline. When a service proxy represents a wire,
+ * the target invoker is cached on the source-side.
+ */
+ public TargetInvoker getTargetInvoker() {
+ return targetInvoker;
+ }
+
+ /**
+ * Prepares the configuration by linking interceptors and handlers
+ */
+ public void build() {
+
+ if (requestHandlers != null && targetInterceptorChainHead != null) {
+ // on target-side, connect existing handlers and interceptors
+ MessageHandler messageDispatcher = new MessageDispatcher(targetInterceptorChainHead);
+ requestHandlers.add(messageDispatcher);
+ }
+
+ if (requestHandlers != null) {
+ MessageChannel requestChannel = new MessageChannelImpl(requestHandlers);
+ MessageChannel responseChannel = new MessageChannelImpl(responseHandlers);
+ Interceptor channelInterceptor = new RequestResponseInterceptor(requestChannel, targetRequestChannel,
+ responseChannel, targetResponseChannel);
+
+ if (sourceInterceptorChainHead != null) {
+ sourceInterceptorChainTail.setNext(channelInterceptor);
+ } else {
+ sourceInterceptorChainHead = channelInterceptor;
+ }
+
+ } else {
+ // no request handlers
+ if (sourceInterceptorChainHead != null) {
+ if (targetInterceptorChainHead != null) {
+ // Connect source interceptor chain directly to target interceptor chain
+ sourceInterceptorChainTail.setNext(targetInterceptorChainHead);
+ // sourceInterceptorChainTail = targetInterceptorChainHead;
+ } else {
+ // Connect source interceptor chain to the target request channel
+ Interceptor channelInterceptor = new RequestResponseInterceptor(null, targetRequestChannel, null,
+ targetResponseChannel);
+ sourceInterceptorChainTail.setNext(channelInterceptor);
+ }
+ } else {
+ // no source interceptor chain or source handlers, conntect to target interceptor chain or channel
+ if (targetInterceptorChainHead != null) {
+ sourceInterceptorChainHead = targetInterceptorChainHead;
+ sourceInterceptorChainTail = targetInterceptorChainHead;
+ } else {
+ Interceptor channelInterceptor = new RequestResponseInterceptor(null, targetRequestChannel, null,
+ targetResponseChannel);
+ sourceInterceptorChainHead = channelInterceptor;
+ sourceInterceptorChainTail = channelInterceptor;
+ }
+ }
+ }
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/InvocationException.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/InvocationException.java
new file mode 100644
index 0000000000..d089b45d76
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/InvocationException.java
@@ -0,0 +1,29 @@
+package org.apache.tuscany.core.invocation;
+
+import org.apache.tuscany.common.TuscanyException;
+
+/**
+ * The root checked exception for the invocation framework
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class InvocationException extends TuscanyException {
+
+ public InvocationException() {
+ super();
+ }
+
+ public InvocationException(String message) {
+ super(message);
+ }
+
+ public InvocationException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public InvocationException(Throwable cause) {
+ super(cause);
+ }
+
+}
+
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/InvocationRuntimeException.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/InvocationRuntimeException.java
new file mode 100644
index 0000000000..ddb7b5f74b
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/InvocationRuntimeException.java
@@ -0,0 +1,44 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.invocation;
+
+import org.osoa.sca.ServiceRuntimeException;
+
+/**
+ * Denotes an exception thrown during invocation processing
+ *
+ * @version $Rev$ $Date$
+ */
+public class InvocationRuntimeException extends ServiceRuntimeException {
+
+ public InvocationRuntimeException() {
+ super();
+ }
+
+ public InvocationRuntimeException(String message) {
+ super(message);
+ }
+
+ public InvocationRuntimeException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public InvocationRuntimeException(Throwable cause) {
+ super(cause);
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/MessageChannel.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/MessageChannel.java
new file mode 100644
index 0000000000..4a5e8a1f87
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/MessageChannel.java
@@ -0,0 +1,33 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.invocation;
+
+import org.apache.tuscany.core.message.Message;
+
+/**
+ * Represents a one-way pipeline through which messages are sent during an invocation
+ *
+ * @see org.apache.tuscany.core.message.Message
+ */
+public interface MessageChannel {
+
+ /**
+ * Sends a message
+ */
+ void send(Message message);
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/MessageHandler.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/MessageHandler.java
new file mode 100644
index 0000000000..4719fbae81
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/MessageHandler.java
@@ -0,0 +1,34 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.invocation;
+
+import org.apache.tuscany.core.message.Message;
+
+
+/**
+ * Performs a uni-directional mediation on a message
+ *
+ * @see org.apache.tuscany.core.message.Message
+ */
+public interface MessageHandler {
+
+ /**
+ * Process a message.
+ */
+ boolean processMessage(Message message);
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/MethodHashMap.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/MethodHashMap.java
new file mode 100644
index 0000000000..183cb5ecbb
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/MethodHashMap.java
@@ -0,0 +1,53 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.invocation;
+
+import java.lang.reflect.Method;
+import java.util.HashMap;
+
+import org.apache.tuscany.core.config.JavaIntrospectionHelper;
+
+/**
+ * A HashMap keyed by method
+ */
+public class MethodHashMap extends HashMap {
+
+ /**
+ * Constructs a new MethodHashMap.
+ */
+ public MethodHashMap() {
+ super();
+ }
+
+ /**
+ * Constructs a new MethodHashMap.
+ */
+ public MethodHashMap(int size) {
+ super(size);
+ }
+
+ /**
+ * @see java.util.HashMap#get(java.lang.Object)
+ */
+ public Object get(Object key) {
+ Method method=(Method)key;
+ //FIXME find a more efficient way to find a matching method
+ Method closestMethod=JavaIntrospectionHelper.findClosestMatchingMethod(method.getName(), method.getParameterTypes(), super.keySet());
+ return super.get(closestMethod);
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/ProxyConfiguration.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/ProxyConfiguration.java
new file mode 100644
index 0000000000..11fc4768f3
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/ProxyConfiguration.java
@@ -0,0 +1,101 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.invocation;
+
+import java.lang.reflect.Method;
+import java.util.Map;
+
+import org.apache.tuscany.core.context.QualifiedName;
+import org.apache.tuscany.core.message.MessageFactory;
+
+/**
+ * Represents configuration information for creating a service proxy. When a client component implementation is injected
+ * with a service proxy representing a wire, source- and target-side proxy configurations are "bridged" together. This
+ * concatenated configuration may then be used to generate a proxy implemented a particular business interface required
+ * by the client.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ProxyConfiguration {
+
+ private Map<Method, InvocationConfiguration> configurations;
+
+ private ClassLoader proxyClassLoader;
+
+ private MessageFactory messageFactory;
+
+ private QualifiedName serviceName;
+
+ // ----------------------------------
+ // Constructors
+ // ----------------------------------
+
+ /**
+ * Creates a configuration used to generate proxies representing a service.
+ *
+ * @param serviceName the qualified name of the service represented by this configuration
+ * @param invocationConfigs a collection of operation-to-invocation configuration mappings for the service
+ * @param proxyClassLoader the classloader to use when creating a proxy
+ * @param messageFactory the factory used to create invocation messages
+ */
+ public ProxyConfiguration(QualifiedName serviceName, Map<Method, InvocationConfiguration> invocationConfigs,
+ ClassLoader proxyClassLoader, MessageFactory messageFactory) {
+ assert (invocationConfigs != null) : "No invocation configuration map specified";
+ this.serviceName = serviceName;
+ configurations = invocationConfigs;
+ this.messageFactory = messageFactory;
+ if (proxyClassLoader == null) {
+ this.proxyClassLoader = Thread.currentThread().getContextClassLoader();
+ } else {
+ this.proxyClassLoader = proxyClassLoader;
+ }
+ }
+
+ // ----------------------------------
+ // Methods
+ // ----------------------------------
+
+ /**
+ * Returns the qualified service name the configuration is associated with
+ */
+ public QualifiedName getTargetName() {
+ return serviceName;
+ }
+
+ /**
+ * Returns a collection of operation types to {@link InvocationConfiguration} mappings that represent the specific
+ * proxy configuration information for particular operations
+ */
+ public Map<Method, InvocationConfiguration> getInvocationConfigurations() {
+ return configurations;
+ }
+
+ /**
+ * Returns the classloader to use in creating proxies
+ */
+ public ClassLoader getProxyClassLoader() {
+ return proxyClassLoader;
+ }
+
+ /**
+ * Returns the factory used to create invocation messages
+ */
+ public MessageFactory getMessageFactory() {
+ return messageFactory;
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/TargetInvoker.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/TargetInvoker.java
new file mode 100644
index 0000000000..e0a85d0b6e
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/TargetInvoker.java
@@ -0,0 +1,44 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.invocation;
+
+import java.lang.reflect.InvocationTargetException;
+
+/**
+ * Implementations are responsible for resolving a target and performing the actual invocation on it, for example, a
+ * service component implementation instance or an external service client.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface TargetInvoker extends Interceptor, Cloneable{
+
+ /**
+ * Responsible for invoking an operation on a target with the given payload
+ *
+ * @param payload the parameters of the target operation or null
+ * @throws InvocationTargetException if the target operation itself throws an exception. The root cause will be set
+ * to that exception
+ */
+ public Object invokeTarget(Object payload) throws InvocationTargetException;
+
+ /**
+ * Determines whether the proxy can be cached on the client/source side
+ */
+ public boolean isCacheable();
+
+ public Object clone();
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/impl/InvokerInterceptor.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/impl/InvokerInterceptor.java
new file mode 100644
index 0000000000..7b9dc1c86f
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/impl/InvokerInterceptor.java
@@ -0,0 +1,46 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.invocation.impl;
+
+import org.apache.tuscany.core.invocation.Interceptor;
+import org.apache.tuscany.core.invocation.InvocationRuntimeException;
+import org.apache.tuscany.core.invocation.TargetInvoker;
+import org.apache.tuscany.core.message.Message;
+
+/**
+ * Serves as a tail interceptor on a target invocation chain. This implementation dispatches to the target invoker
+ * passed inside the invocation message. Target invokers are passed from the source in order to allow for caching of
+ * target instances.
+ *
+ * @see org.apache.tuscany.core.invocation.TargetInvoker
+ * @version $Rev$ $Date$
+ */
+public class InvokerInterceptor implements Interceptor {
+
+ public InvokerInterceptor() {
+ }
+
+ 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) {
+ throw new IllegalStateException("This interceptor must be the last one in an target interceptor chain");
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/impl/MessageChannelImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/impl/MessageChannelImpl.java
new file mode 100644
index 0000000000..6c0b15a823
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/impl/MessageChannelImpl.java
@@ -0,0 +1,68 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.invocation.impl;
+
+import java.util.List;
+
+import org.apache.tuscany.core.invocation.MessageChannel;
+import org.apache.tuscany.core.invocation.MessageHandler;
+import org.apache.tuscany.core.message.Message;
+
+/**
+ * A channel comprising an ordered collection of message handlers.
+ *
+ *@see org.apache.tuscany.core.message.Message
+ * @version $Rev$ $Date$
+ */
+public class MessageChannelImpl implements MessageChannel {
+
+ private final List<MessageHandler> pipeline;
+
+ //----------------------------------
+ // Constructors
+ //----------------------------------
+
+ /**
+ * Construct a new channel comprising the supplied list of handlers.
+ *
+ * @param pipeline the Handlers in the channel
+ */
+ public MessageChannelImpl(List<MessageHandler> pipeline) {
+ this.pipeline = pipeline;
+ }
+
+ //----------------------------------
+ // Methods
+ //----------------------------------
+
+ /**
+ * Send a message down the channel. The message will be processed by all handlers
+ * in order until one returns false to indicate processing is complete or all
+ * handlers have been called.
+ *
+ * @param msg a Message to send down the channel
+ */
+ public void send(Message msg) {
+ if (pipeline!=null) {
+ for (MessageHandler handler : pipeline) {
+ if (!handler.processMessage(msg)) {
+ break;
+ }
+ }
+ }
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/impl/MessageDispatcher.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/impl/MessageDispatcher.java
new file mode 100644
index 0000000000..a162962717
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/impl/MessageDispatcher.java
@@ -0,0 +1,46 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.invocation.impl;
+
+import org.apache.tuscany.core.invocation.Interceptor;
+import org.apache.tuscany.core.invocation.MessageHandler;
+import org.apache.tuscany.core.message.Message;
+
+/**
+ * A message handler that dispatches the message through an interceptor stack and the uses the response channel to
+ * return the invocation result.
+ *
+ * @version $Rev$ $Date$
+ */
+public class MessageDispatcher implements MessageHandler {
+ private final Interceptor head;
+
+ /**
+ * Construct a handler that dispatches messages to an Interceptor stack.
+ *
+ * @param head the interceptor at the head of the stack
+ */
+ public MessageDispatcher(Interceptor head) {
+ this.head = head;
+ }
+
+ public boolean processMessage(Message msg) {
+ Message resp = head.invoke(msg);
+ msg.getCallbackChannel().send(resp);
+ return false;
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/impl/NullProxyFactory.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/impl/NullProxyFactory.java
new file mode 100644
index 0000000000..fa4297ef00
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/impl/NullProxyFactory.java
@@ -0,0 +1,57 @@
+package org.apache.tuscany.core.invocation.impl;
+
+import org.apache.tuscany.core.context.AggregateContext;
+import org.apache.tuscany.core.invocation.ProxyConfiguration;
+import org.apache.tuscany.core.invocation.spi.ProxyCreationException;
+import org.apache.tuscany.core.invocation.spi.ProxyFactory;
+import org.apache.tuscany.core.invocation.spi.ProxyInitializationException;
+
+/**
+ * Returns an actual implementation instance as opposed to a proxy. Used in cases where proxying may be optimized away.
+ *
+ * @version $Rev: 379957 $ $Date: 2006-02-22 14:58:24 -0800 (Wed, 22 Feb 2006) $
+ */
+public class NullProxyFactory implements ProxyFactory {
+
+ private AggregateContext parentContext;
+
+ private String targetName;
+
+ public NullProxyFactory(String componentName, AggregateContext parentContext) {
+ assert (parentContext != null) : "Parent context was null";
+ this.targetName = componentName;
+ this.parentContext = parentContext;
+ }
+
+ public void initialize(Class businessInterface, ProxyConfiguration config) throws ProxyInitializationException {
+ }
+
+ public Object createProxy() throws ProxyCreationException {
+ return parentContext.getContext(targetName);
+ }
+
+ public void initialize() throws ProxyInitializationException {
+ }
+
+ public ProxyConfiguration getProxyConfiguration() {
+ return null;
+ }
+
+ public void setProxyConfiguration(ProxyConfiguration config) {
+ }
+
+ public void setBusinessInterface(Class interfaze) {
+ }
+
+ public Class getBusinessInterface() {
+ return null;
+ }
+
+ public void addInterface(Class claz) {
+ }
+
+ public Class[] getImplementatedInterfaces() {
+ return null;
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/impl/OneWayInterceptor.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/impl/OneWayInterceptor.java
new file mode 100644
index 0000000000..71d324e032
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/impl/OneWayInterceptor.java
@@ -0,0 +1,48 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.invocation.impl;
+
+import org.apache.tuscany.core.invocation.Interceptor;
+import org.apache.tuscany.core.invocation.MessageChannel;
+import org.apache.tuscany.core.message.Message;
+
+/**
+ * An interceptor that sends the invocation Message down its request channel and does not expect a response.
+ *
+ * @version $Rev$ $Date$
+ */
+public class OneWayInterceptor implements Interceptor {
+ private MessageChannel requestChannel;
+
+ /**
+ * Construct an interceptor that sends messages down the supplied channel.
+ *
+ * @param requestChannel the channel to send messages down
+ */
+ public OneWayInterceptor(MessageChannel requestChannel) {
+ this.requestChannel = requestChannel;
+ }
+
+ public Message invoke(Message message) {
+ requestChannel.send(message);
+ return null;
+ }
+
+ public void setNext(Interceptor next) {
+ throw new IllegalStateException("This interceptor must be the last one in an interceptor chain");
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/impl/RequestResponseInterceptor.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/impl/RequestResponseInterceptor.java
new file mode 100644
index 0000000000..03122f0992
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/impl/RequestResponseInterceptor.java
@@ -0,0 +1,73 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.invocation.impl;
+
+import org.apache.tuscany.core.invocation.Interceptor;
+import org.apache.tuscany.core.invocation.MessageChannel;
+import org.apache.tuscany.core.message.Message;
+
+/**
+ * An interceptor that first sends the invocation Message down its request channel then extracts the response from the
+ * message and sends it down the response channel before returning it up the interceptor stack.
+ *
+ * @version $Rev$ $Date$
+ */
+public class RequestResponseInterceptor implements Interceptor {
+
+ private MessageChannel sourceRequestChannel;
+
+ private MessageChannel sourceResponseChannel;
+
+ private MessageChannel targetRequestChannel;
+
+ private MessageChannel targetResponseChannel;
+
+ /**
+ * Construct an interceptor that sends messages down the supplied channels.
+ *
+ * @param targetRequestChannel the channel to send request messages down
+ * @param targetResponseChannel the channel to sent response messages down
+ */
+ public RequestResponseInterceptor(MessageChannel sourceRequestChannel, MessageChannel targetRequestChannel,
+ MessageChannel sourceResponseChannel, MessageChannel targetResponseChannel) {
+ this.sourceRequestChannel = sourceRequestChannel;
+ this.sourceResponseChannel = sourceResponseChannel;
+ this.targetRequestChannel = targetRequestChannel;
+ this.targetResponseChannel = targetResponseChannel;
+ }
+
+ public Message invoke(Message requestMessage) {
+ if (sourceRequestChannel != null) {
+ sourceRequestChannel.send(requestMessage);
+ }
+ if (targetRequestChannel != null) {
+ targetRequestChannel.send(requestMessage);
+ }
+ Message responseMessage = requestMessage.getRelatedCallbackMessage();
+ if (targetResponseChannel != null) {
+ targetResponseChannel.send(responseMessage);
+ }
+ if (sourceResponseChannel != null) {
+ sourceResponseChannel.send(responseMessage);
+ }
+ return responseMessage;
+ }
+
+ public void setNext(Interceptor next) {
+ throw new IllegalStateException("This interceptor must be the last one in an interceptor chain");
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/jdk/JDKInvocationHandler.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/jdk/JDKInvocationHandler.java
new file mode 100644
index 0000000000..2f27698d6b
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/jdk/JDKInvocationHandler.java
@@ -0,0 +1,143 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.invocation.jdk;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.core.context.TargetException;
+import org.apache.tuscany.core.invocation.Interceptor;
+import org.apache.tuscany.core.invocation.InvocationConfiguration;
+import org.apache.tuscany.core.invocation.TargetInvoker;
+import org.apache.tuscany.core.message.Message;
+import org.apache.tuscany.core.message.MessageFactory;
+
+/**
+ * Receives a request from a JDK proxy and dispatches it to a target invoker or source interceptor stack
+ *
+ * @version $Rev$ $Date$
+ */
+public class JDKInvocationHandler implements InvocationHandler {
+
+ private MessageFactory messageFactory;
+
+ /*
+ * an association of an operation to configuration holder. The holder contains the master invocation configuration
+ * and a locale clone of the master TargetInvoker. TargetInvokers will be cloned by the handler and placed in the
+ * holder if they are cacheable. This allows optimizations such as avoiding target resolution when a source refers
+ * to a target of greater scope since the target reference can be maintained by the invoker. When a target invoker
+ * is not cacheable, the master associated with the invocation configuration will be used.
+ */
+ private Map<Method, ConfigHolder> configuration;
+
+ // ----------------------------------
+ // Constructors
+ // ----------------------------------
+
+ public JDKInvocationHandler(MessageFactory messageFactory, Map<Method, InvocationConfiguration> configuration) {
+ assert (configuration != null) : "Configuration not specified";
+ this.configuration = new HashMap(configuration.size());
+ for (Map.Entry<Method, InvocationConfiguration> entry : configuration.entrySet()) {
+ this.configuration.put(entry.getKey(), new ConfigHolder(entry.getValue()));
+ }
+ // this.configuration = configuration;
+ this.messageFactory = messageFactory;
+ }
+
+ // ----------------------------------
+ // Methods
+ // ----------------------------------
+
+ /**
+ * Dispatches a client request made on a proxy
+ */
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+ Interceptor headInterceptor = null;
+ ConfigHolder holder = configuration.get(method);
+ if (holder == null) {
+ TargetException e = new TargetException("Operation not configured");
+ e.setIdentifier(method.getName());
+ throw e;
+ }
+ InvocationConfiguration config = holder.config;
+ if (config != null) {
+ headInterceptor = config.getSourceInterceptor();
+ }
+
+ TargetInvoker invoker = null;
+
+ if (holder.cachedInvoker == null) {
+ if(config.getTargetInvoker() == null){
+ TargetException e= new TargetException("No target invoker configured for operation");
+ e.setIdentifier(config.getMethod().getName());
+ throw e;
+ }
+ if (config.getTargetInvoker().isCacheable()) {
+ // clone and store the invoker locally
+ holder.cachedInvoker = (TargetInvoker) config.getTargetInvoker().clone();
+ invoker = holder.cachedInvoker;
+ } else {
+ invoker = config.getTargetInvoker();
+ }
+ } else {
+ invoker = config.getTargetInvoker();
+ }
+ if (headInterceptor == null) {
+ try {
+ // short-circuit the dispatch and invoke the target directly
+ if (config.getTargetInvoker() == null) {
+ throw new AssertionError("No target invoker [" + method.getName() + "]");
+ }
+ return config.getTargetInvoker().invokeTarget(args);
+ } catch (InvocationTargetException e) {
+ // the cause was thrown by the target so throw it
+ throw e.getCause();
+ }
+ } else {
+ Message msg = messageFactory.createMessage();
+ msg.setTargetInvoker(invoker);// config.getTargetInvoker());
+ msg.setBody(args);
+ // dispatch the invocation down the chain and get the response
+ Message resp = headInterceptor.invoke(msg);
+
+ Object body = resp.getBody();
+ if (body instanceof Throwable) {
+ throw (Throwable) body;
+ }
+ return body;
+ }
+ }
+
+ /**
+ * A holder used to associate an invocation configuration with a local copy of a target invoker that was previously
+ * cloned from the configuration master
+ */
+ private class ConfigHolder {
+
+ public ConfigHolder(InvocationConfiguration config) {
+ this.config = config;
+ }
+
+ InvocationConfiguration config;
+
+ TargetInvoker cachedInvoker;
+ }
+
+} \ No newline at end of file
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/jdk/JDKProxyFactory.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/jdk/JDKProxyFactory.java
new file mode 100644
index 0000000000..75137ffa36
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/jdk/JDKProxyFactory.java
@@ -0,0 +1,96 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.invocation.jdk;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.util.Map;
+
+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.spi.ProxyFactory;
+import org.apache.tuscany.core.invocation.spi.ProxyInitializationException;
+
+/**
+ * Creates proxies for handling invocations using JDK dynamic proxies
+ *
+ * @version $Rev$ $Date$
+ */
+public class JDKProxyFactory implements ProxyFactory {
+
+ private static final int UNINITIALIZED = 0;
+
+ private static final int INITIALIZED = 1;
+
+ private static final int ERROR = -1;
+
+ private int state = UNINITIALIZED;
+
+ private Class[] businessInterfaceArray;
+
+ private Map<Method, InvocationConfiguration> methodToInvocationConfig;
+
+ private ProxyConfiguration configuration;
+
+ public void initialize() throws ProxyInitializationException {
+ if (state != UNINITIALIZED) {
+ throw new IllegalStateException("Proxy factory in wrong state [" + state + "]");
+ }
+ Map<Method, InvocationConfiguration> invocationConfigs = configuration.getInvocationConfigurations();
+ methodToInvocationConfig = new MethodHashMap(invocationConfigs.size());
+ for (Map.Entry entry : invocationConfigs.entrySet()) {
+ Method method = (Method) entry.getKey();
+ methodToInvocationConfig.put(method, (InvocationConfiguration) entry.getValue());
+ }
+ state = INITIALIZED;
+ }
+
+ public Object createProxy() {
+ if (state != INITIALIZED) {
+ throw new IllegalStateException("Proxy factory not INITIALIZED [" + state + "]");
+ }
+ InvocationHandler handler = new JDKInvocationHandler(configuration.getMessageFactory(), methodToInvocationConfig);
+ return Proxy.newProxyInstance(configuration.getProxyClassLoader(), businessInterfaceArray, handler);
+ }
+
+ public ProxyConfiguration getProxyConfiguration() {
+ return configuration;
+ }
+
+ public void setProxyConfiguration(ProxyConfiguration config) {
+ configuration = config;
+ }
+
+ public void setBusinessInterface(Class interfaze) {
+ businessInterfaceArray = new Class[] { interfaze };
+ }
+
+ public Class getBusinessInterface() {
+ return businessInterfaceArray[0];
+ }
+
+ public void addInterface(Class claz) {
+ throw new UnsupportedOperationException("Additional proxy interfaces not yet supported");
+ }
+
+ public Class[] getImplementatedInterfaces() {
+ return businessInterfaceArray;
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/jdk/JDKProxyFactoryFactory.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/jdk/JDKProxyFactoryFactory.java
new file mode 100644
index 0000000000..81458e4178
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/jdk/JDKProxyFactoryFactory.java
@@ -0,0 +1,52 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.invocation.jdk;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Proxy;
+
+import org.apache.tuscany.core.invocation.spi.ProxyFactory;
+import org.apache.tuscany.core.invocation.spi.ProxyFactoryFactory;
+
+/**
+ * Creates JDK Dynamic Proxy-based proxy factories
+ *
+ * @version $Rev$ $Date$
+ */
+public class JDKProxyFactoryFactory implements ProxyFactoryFactory {
+
+ public JDKProxyFactoryFactory() {
+ }
+
+ public ProxyFactory createProxyFactory() {
+ return new JDKProxyFactory();
+ }
+
+ public boolean isProxy(Object object) {
+ if (object == null) {
+ return false;
+ } else {
+ return Proxy.isProxyClass(object.getClass());
+ }
+ }
+
+ public InvocationHandler getHandler(Object proxy) {
+ if (proxy == null) {
+ return null;
+ } else {
+ return Proxy.getInvocationHandler(proxy);
+ }
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/spi/ProxyCreationException.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/spi/ProxyCreationException.java
new file mode 100644
index 0000000000..2a97975bf9
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/spi/ProxyCreationException.java
@@ -0,0 +1,43 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.invocation.spi;
+
+/**
+ * Denotes an error creating a proxy instance
+ *
+ * @version $Rev$ $Date$
+ */
+public class ProxyCreationException extends ProxyException {
+
+ public ProxyCreationException() {
+ super();
+ }
+
+ public ProxyCreationException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public ProxyCreationException(String message) {
+ super(message);
+ }
+
+ public ProxyCreationException(Throwable cause) {
+ super(cause);
+ }
+
+}
+
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/spi/ProxyException.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/spi/ProxyException.java
new file mode 100644
index 0000000000..843a90d341
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/spi/ProxyException.java
@@ -0,0 +1,40 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.invocation.spi;
+
+import org.apache.tuscany.core.invocation.InvocationException;
+
+public class ProxyException extends InvocationException {
+
+ public ProxyException() {
+ super();
+ }
+
+ public ProxyException(String message) {
+ super(message);
+ }
+
+ public ProxyException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public ProxyException(Throwable cause) {
+ super(cause);
+ }
+
+}
+
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/spi/ProxyFactory.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/spi/ProxyFactory.java
new file mode 100644
index 0000000000..aef98a0b4c
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/spi/ProxyFactory.java
@@ -0,0 +1,79 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.invocation.spi;
+
+import org.apache.tuscany.core.invocation.ProxyConfiguration;
+
+/**
+ * Implementations are responsible for creating service proxies using a particular proxy strategy. Service proxies may
+ * represent a wire between two components or a reference to a service resolved through a locate operation. When
+ * representing a wire, a proxy is injected on reference in a component implementation. In this case the proxy will
+ * implement the interface required by the reference and pass invocation messages down source- and target-side
+ * invocation chains for processing. These source- and target-side invocation chains will be derived from metadata
+ * decorating the source reference and target service definition and implementation respectively.
+ * <p>
+ * The second type of proxy will be generated when non-component client code (such as a JSP) locates a service. In this
+ * case, the proxy will implement the requested service interface but will only contain a target-side invocation chain.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ProxyFactory<T> {
+
+ /**
+ * Prepares the factory for generating the proxy of a particular reference type. This will typically be called when
+ * construction of the proxy configuration is complete, including linking of source and target invocation chains.
+ *
+ * @throws ProxyInitializationException if an error is encountered during initialization
+ */
+ public void initialize() throws ProxyInitializationException;
+
+ /**
+ * Returns a proxy for a service reference
+ */
+ public T createProxy() throws ProxyCreationException;
+
+ /**
+ * Returns the configuration information used to create a proxy
+ */
+ public ProxyConfiguration getProxyConfiguration();
+
+ /**
+ * Sets the configuration information used to create a proxy
+ */
+ public void setProxyConfiguration(ProxyConfiguration config);
+
+ /**
+ * Sets the primary interface type generated proxies should implement
+ */
+ public void setBusinessInterface(Class interfaze);
+
+ /**
+ * Returns the primary interface type implemented by generated proxies
+ */
+ public Class getBusinessInterface();
+
+ /**
+ * Adds an interface type generated proxies should implement
+ */
+ public void addInterface(Class claz);
+
+ /**
+ * Returns an array of all interfaces implemented by generated proxies
+ */
+ public Class[] getImplementatedInterfaces();
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/spi/ProxyFactoryFactory.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/spi/ProxyFactoryFactory.java
new file mode 100644
index 0000000000..8e4c2ee589
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/spi/ProxyFactoryFactory.java
@@ -0,0 +1,42 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.invocation.spi;
+
+import java.lang.reflect.InvocationHandler;
+
+/**
+ * Creates proxy factories which may be subsequently configured to generate proxies
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ProxyFactoryFactory {
+
+ /**
+ * Returns a new proxy factory
+ */
+ public ProxyFactory createProxyFactory();
+
+ /**
+ * Determines whether the given object is a proxy
+ */
+ public boolean isProxy(Object object);
+
+ /**
+ * Returns an invocation handler fronting the invocation chains used by the proxy. Note that should SCA define a
+ * DII, this could return such an interface.
+ *
+ * @throws IllegalArgumentException if the class is not a proxy
+ */
+ public InvocationHandler getHandler(Object proxy) throws IllegalArgumentException;
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/spi/ProxyInitializationException.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/spi/ProxyInitializationException.java
new file mode 100644
index 0000000000..d8c8e64614
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/invocation/spi/ProxyInitializationException.java
@@ -0,0 +1,43 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.invocation.spi;
+
+/**
+ * Denotes an error initializing a proxy factory
+ *
+ * @version $Rev$ $Date$
+ */
+public class ProxyInitializationException extends ProxyException {
+
+ public ProxyInitializationException() {
+ super();
+ }
+
+ public ProxyInitializationException(String message) {
+ super(message);
+ }
+
+ public ProxyInitializationException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public ProxyInitializationException(Throwable cause) {
+ super(cause);
+ }
+
+}
+
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/loader/SCDLModelLoaderRegistry.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/loader/SCDLModelLoaderRegistry.java
new file mode 100644
index 0000000000..0205c1350e
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/loader/SCDLModelLoaderRegistry.java
@@ -0,0 +1,51 @@
+/**
+ *
+ * Copyright 2005 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.core.loader;
+
+import java.util.List;
+
+import org.apache.tuscany.model.scdl.loader.SCDLModelLoader;
+
+/**
+ * A ModelLoaderRegistry maintains a list of SCDLModelLoaders that have been contributed
+ * to the system by various extension components (such as implementations or bindings).
+ *
+ *
+ * @version $Rev$ $Date$
+ */
+public interface SCDLModelLoaderRegistry {
+ /**
+ * Returns the list of registered model loaders.
+ *
+ * @return the list of registered model loaders
+ */
+ List<SCDLModelLoader> getLoaders();
+
+ /**
+ * Register a model loader.
+ *
+ * @param loader the loader being contributed by the extension component
+ */
+ void registerLoader(SCDLModelLoader loader);
+
+ /**
+ * Unregister a model loader.
+ *
+ * @param loader the loader previously contributed by the extension component
+ */
+ void unregisterLoader(SCDLModelLoader loader);
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/loader/impl/SCDLModelLoaderRegistryImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/loader/impl/SCDLModelLoaderRegistryImpl.java
new file mode 100644
index 0000000000..2f0ba73252
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/loader/impl/SCDLModelLoaderRegistryImpl.java
@@ -0,0 +1,49 @@
+/**
+ *
+ * Copyright 2005 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.core.loader.impl;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Collections;
+
+import org.apache.tuscany.core.loader.SCDLModelLoaderRegistry;
+import org.apache.tuscany.model.scdl.loader.SCDLModelLoader;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class SCDLModelLoaderRegistryImpl implements SCDLModelLoaderRegistry {
+ private final List<SCDLModelLoader> loaders;
+ private final List<SCDLModelLoader> registry;
+
+ public SCDLModelLoaderRegistryImpl() {
+ registry = new ArrayList<SCDLModelLoader>();
+ loaders = Collections.unmodifiableList(registry);
+ }
+
+ public List<SCDLModelLoader> getLoaders() {
+ return loaders;
+ }
+
+ public void registerLoader(SCDLModelLoader loader) {
+ registry.add(loader);
+ }
+
+ public void unregisterLoader(SCDLModelLoader loader) {
+ registry.remove(loader);
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/message/Message.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/message/Message.java
new file mode 100644
index 0000000000..e316050511
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/message/Message.java
@@ -0,0 +1,182 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.message;
+
+import java.util.Map;
+
+import org.apache.tuscany.core.addressing.EndpointReference;
+import org.apache.tuscany.core.invocation.MessageChannel;
+import org.apache.tuscany.core.invocation.TargetInvoker;
+
+/**
+ * Represents a request, response, or exception for an invocation
+ */
+public interface Message {
+
+ /**
+ * Return any message headers associated with the invocation.
+ */
+ Map<String, Object> getHeaders();
+
+ /**
+ * Returns the body of the message, which will be the payload or parameters
+ * associated with the invocation
+ * FIXME what is different w/ getPayload()?
+ */
+ Object getBody();
+
+ /**
+ * Sets the body of the message.
+ */
+ void setBody(Object body);
+
+ /**
+ * Returns true if the message is a request message
+ * FIXME is this still used?
+ */
+ boolean isRequest();
+
+ /**
+ * Returns true if the message is an inbound message
+ * FIXME is this still used?
+ */
+ boolean isResponse();
+
+ /**
+ * Sets the To header
+ * FIXME Javadoc
+ */
+ void setTo(EndpointReference to);
+
+ /**
+ * Returns the To header
+ * FIXME Javadoc
+ */
+ EndpointReference getTo();
+
+ /**
+ * Sets the From header
+ * FIXME Javadoc
+ */
+ void setFrom(EndpointReference from);
+
+ /**
+ * Returns the From header
+ * FIXME Javadoc
+ */
+ EndpointReference getFrom();
+
+ /**
+ * Sets the message ID
+ */
+ void setMessageID(String messageID);
+
+ /**
+ * Returns the message ID
+ */
+ String getMessageID();
+
+ /**
+ * Sets the Action header
+ * FIXME Javadoc
+ */
+ void setAction(String action);
+
+ /**
+ * Returns the Action header
+ * FIXME Javadoc
+ */
+ String getAction();
+
+ /**
+ * Sets the ReplyTo header
+ * FIXME Javadoc
+ */
+ void setReplyTo(EndpointReference replyTo);
+
+ /**
+ * Returns the ReplyTo header
+ * FIXME Javadoc
+ */
+ EndpointReference getReplyTo();
+
+ /**
+ * Sets the RelatesTo header
+ * FIXME Javadoc
+ */
+ void setRelatesTo(String relatesTo);
+
+ /**
+ * Returns the RelatesTo header
+ * FIXME Javadoc
+ */
+ String getRelatesTo();
+
+ /**
+ * Sets the FaultTo header
+ * FIXME Javadoc
+ */
+ void setFaultTo(EndpointReference faultTo);
+
+ /**
+ * Returns the FaultTo header
+ * FIXME Javadoc
+ */
+ EndpointReference getFaultTo();
+
+ /**
+ * Sets the EndpointReference header
+ * FIXME Javadoc
+ */
+ void setEndpointReference(EndpointReference endpointReference);
+
+ /**
+ * Returns the EndpointReference header
+ * FIXME Javadoc
+ */
+ EndpointReference getEndpointReference();
+
+ /**
+ * Sets the operation name
+ * FIXME Javadoc
+ */
+ void setOperationName(String operationName);
+
+ /**
+ * Returns the operation name
+ * FIXME Javadoc
+ */
+ String getOperationName();
+
+ /**
+ * Returns the callback channel
+ * FIXME Javadoc
+ */
+ MessageChannel getCallbackChannel();
+
+ /**
+ * Returns the related callback message
+ * FIXME Javadoc
+ */
+ Message getRelatedCallbackMessage();
+
+ //ADDED
+ public void setTargetInvoker(TargetInvoker invoker);
+
+ public TargetInvoker getTargetInvoker();
+
+} // Message
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/message/MessageFactory.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/message/MessageFactory.java
new file mode 100644
index 0000000000..74b0e85848
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/message/MessageFactory.java
@@ -0,0 +1,31 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.message;
+
+/**
+ * The <b>Factory</b> for messages
+ *
+ * @see org.apache.tuscany.core.message.Message
+ */
+public interface MessageFactory {
+
+ /**
+ * Returns a new message.
+ */
+ Message createMessage();
+
+} // MessageFactory
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/message/impl/MessageFactoryImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/message/impl/MessageFactoryImpl.java
new file mode 100644
index 0000000000..43787bbe67
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/message/impl/MessageFactoryImpl.java
@@ -0,0 +1,40 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.message.impl;
+
+import org.apache.tuscany.core.message.Message;
+import org.apache.tuscany.core.message.MessageFactory;
+
+/**
+ * The default message factory
+ *
+ * @version $Rev$ $Date$
+ */
+public class MessageFactoryImpl implements MessageFactory {
+
+ /**
+ * Constructor
+ */
+ public MessageFactoryImpl() {
+ super();
+ }
+
+ public Message createMessage() {
+ return new MessageImpl();
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/message/impl/MessageImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/message/impl/MessageImpl.java
new file mode 100644
index 0000000000..b67c7e227e
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/message/impl/MessageImpl.java
@@ -0,0 +1,249 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.message.impl;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.core.addressing.EndpointReference;
+import org.apache.tuscany.core.invocation.MessageChannel;
+import org.apache.tuscany.core.invocation.TargetInvoker;
+import org.apache.tuscany.core.message.Message;
+
+/**
+ */
+public class MessageImpl implements Message, MessageChannel {
+
+ private String action;
+ private Object body;
+ private EndpointReference endpointReference;
+ private EndpointReference faultTo;
+ private EndpointReference from;
+ private Map<String, Object> headers;
+ private String messageID;
+ private String operationName;
+ private Message relatedCallbackMessage;
+ private String relatesTo;
+ private EndpointReference replyTo;
+ private TargetInvoker invoker;
+ private EndpointReference to;
+
+ /**
+ * Constructor
+ */
+ protected MessageImpl() {
+ super();
+ }
+
+ /**
+ * @see org.apache.tuscany.core.message.Message#getAction()
+ */
+ public String getAction() {
+ return action;
+ }
+
+ /**
+ * @see org.apache.tuscany.core.message.Message#getBody()
+ */
+ public Object getBody() {
+ return body;
+ }
+
+ /**
+ * @see org.apache.tuscany.core.message.Message#getEndpointReference()
+ */
+ public EndpointReference getEndpointReference() {
+ return endpointReference;
+ }
+
+ /**
+ * @see org.apache.tuscany.core.message.Message#getFaultTo()
+ */
+ public EndpointReference getFaultTo() {
+ return faultTo;
+ }
+
+ /**
+ * @see org.apache.tuscany.core.message.Message#getFrom()
+ */
+ public EndpointReference getFrom() {
+ return from;
+ }
+
+ /**
+ * @see org.apache.tuscany.core.message.Message#getHeaders()
+ */
+ public Map<String, Object> getHeaders() {
+ if (headers==null)
+ headers=new HashMap<String, Object>();
+ return headers;
+ }
+
+ /**
+ * @see org.apache.tuscany.core.message.Message#getMessageID()
+ */
+ public String getMessageID() {
+ return messageID;
+ }
+
+ /**
+ * @see org.apache.tuscany.core.message.Message#getOperationName()
+ */
+ public String getOperationName() {
+ return operationName;
+ }
+
+ /**
+ * @see org.apache.tuscany.core.message.Message#getRelatesTo()
+ */
+ public String getRelatesTo() {
+ return relatesTo;
+ }
+
+ /**
+ * @see org.apache.tuscany.core.message.Message#getReplyTo()
+ */
+ public EndpointReference getReplyTo() {
+ return replyTo;
+ }
+
+ /**
+ * @see org.apache.tuscany.core.message.Message#getTo()
+ */
+ public EndpointReference getTo() {
+ return to;
+ }
+
+ /**
+ * @see org.apache.tuscany.core.message.Message#isRequest()
+ */
+ public boolean isRequest() {
+ return relatesTo==null;
+ }
+
+ /**
+ * @see org.apache.tuscany.core.message.Message#isResponse()
+ */
+ public boolean isResponse() {
+ return relatesTo!=null;
+ }
+
+ /**
+ * @see org.apache.tuscany.core.message.Message#setAction(java.lang.String)
+ */
+ public void setAction(String action) {
+ this.action=action;
+ }
+
+ /**
+ * @see org.apache.tuscany.core.message.Message#setBody(java.lang.Object)
+ */
+ public void setBody(Object body) {
+ this.body=body;
+ }
+
+ /**
+ * @see org.apache.tuscany.core.message.Message#setEndpointReference(org.apache.tuscany.core.client.runtime.addressing.sdo.EndpointReference)
+ */
+ public void setEndpointReference(EndpointReference endpointReference) {
+ this.endpointReference=endpointReference;
+ }
+
+ /**
+ * @see org.apache.tuscany.core.message.Message#setFaultTo(org.apache.tuscany.core.client.runtime.addressing.sdo.EndpointReference)
+ */
+ public void setFaultTo(EndpointReference faultTo) {
+ this.faultTo=faultTo;
+ }
+
+ /**
+ * @see org.apache.tuscany.core.message.Message#setFrom(org.apache.tuscany.core.client.runtime.addressing.sdo.EndpointReference)
+ */
+ public void setFrom(EndpointReference from) {
+ this.from=from;
+ }
+
+ /**
+ * @see org.apache.tuscany.core.message.Message#setMessageID(java.lang.String)
+ */
+ public void setMessageID(String messageID) {
+ this.messageID=messageID;
+ }
+
+ /**
+ * @see org.apache.tuscany.core.message.Message#setOperationName(java.lang.String)
+ */
+ public void setOperationName(String operationName) {
+ this.operationName=operationName;
+ }
+
+ /**
+ * @see org.apache.tuscany.core.message.Message#setRelatesTo(java.lang.String)
+ */
+ public void setRelatesTo(String relatesTo) {
+ this.relatesTo=relatesTo;
+ }
+
+ /**
+ * @see org.apache.tuscany.core.message.Message#setReplyTo(org.apache.tuscany.core.client.runtime.addressing.sdo.EndpointReference)
+ */
+ public void setReplyTo(EndpointReference replyTo) {
+ this.replyTo=replyTo;
+ }
+
+ /**
+ * @see org.apache.tuscany.core.message.Message#setTo(org.apache.tuscany.core.client.runtime.addressing.sdo.EndpointReference)
+ */
+ public void setTo(EndpointReference to) {
+ this.to=to;
+ }
+
+ /**
+ * @see org.apache.tuscany.core.message.Message#getCallbackChannel()
+ */
+ public MessageChannel getCallbackChannel() {
+ return this;
+ }
+
+ /**
+ * @see org.apache.tuscany.core.invocation.MessageChannel#send(org.apache.tuscany.core.message.Message)
+ */
+ public void send(Message message) {
+ relatedCallbackMessage = message;
+ }
+
+ /**
+ * @see org.apache.tuscany.core.message.Message#getRelatedCallbackMessage()
+ */
+ public Message getRelatedCallbackMessage() {
+ return relatedCallbackMessage;
+ }
+
+ /**
+ * @see org.apache.tuscany.core.message.Message#setTargetInvoker(org.apache.tuscany.core.invocation.TargetInvoker)
+ */
+ public void setTargetInvoker(TargetInvoker invoker){
+ this.invoker = invoker;
+ }
+
+ /**
+ * @see org.apache.tuscany.core.message.Message#getTargetInvoker()
+ */
+ public TargetInvoker getTargetInvoker(){
+ return invoker;
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/runtime/RuntimeContext.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/runtime/RuntimeContext.java
new file mode 100644
index 0000000000..5bf71a09f9
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/runtime/RuntimeContext.java
@@ -0,0 +1,83 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.runtime;
+
+import org.apache.tuscany.common.monitor.MonitorFactory;
+import org.apache.tuscany.core.builder.RuntimeConfigurationBuilder;
+import org.apache.tuscany.core.builder.WireBuilder;
+import org.apache.tuscany.core.context.AggregateContext;
+import org.apache.tuscany.core.context.AutowireContext;
+import org.apache.tuscany.core.context.ConfigurationContext;
+import org.apache.tuscany.core.context.SystemAggregateContext;
+import org.apache.tuscany.model.scdl.loader.SCDLModelLoader;
+
+/**
+ * Represents a top-level component context in the runtime, that is the bootstrap context.
+ * This context serves as the ultimate root of the context hierarchy. Under it are two
+ * separate trees: the rootContext for user components and the systemContext for
+ * system components (those that comprise the runtime itself).
+ *
+ * @version $Rev$ $Date$
+ */
+public interface RuntimeContext extends AutowireContext, ConfigurationContext {
+
+ /* the symbolic name of the runtime bootstrap context */
+ public static final String RUNTIME = "tuscany.runtime";
+
+ /* the symbolic name of the aggregate context containing all system components in the runtime */
+ public static final String SYSTEM = "tuscany.system";
+
+ /* the symbolic name of the aggregate context containing all user components in the runtime */
+ public static final String ROOT = "tuscany.root";
+
+ /**
+ * Returns the context that forms the root of the user component tree.
+ * All user components will managed by contexts that are children of this root.
+ * @return the root of the user component tree
+ */
+ public AggregateContext getRootContext();
+
+ /**
+ * Returns the context that forms the root of the system component tree.
+ * All system components, components that provide system services needed by the
+ * Tuscany runtime itself, will be managed by contexts that are children of this root.
+ * @return the root of the system component tree
+ */
+ public SystemAggregateContext getSystemContext();
+
+ /**
+ * Adds a configuration builder to the runtime
+ */
+ @Deprecated
+ public void addBuilder(RuntimeConfigurationBuilder builder);
+
+ /**
+ * Adds a wire builder to the runtime
+ */
+ @Deprecated
+ public void addBuilder(WireBuilder builder);
+
+ /**
+ * Adds an SCDL model loader to the runtime
+ */
+ @Deprecated
+ public void addLoader(SCDLModelLoader loader);
+
+ /**
+ * Returns the monitor factory in use by the runtime
+ */
+ @Deprecated
+ public MonitorFactory getMonitorFactory();
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/runtime/RuntimeContextImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/runtime/RuntimeContextImpl.java
new file mode 100644
index 0000000000..044958b9bf
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/runtime/RuntimeContextImpl.java
@@ -0,0 +1,286 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.runtime;
+
+import java.util.ArrayList;
+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.BuilderConfigException;
+import org.apache.tuscany.core.builder.HierarchicalWireBuilder;
+import org.apache.tuscany.core.builder.RuntimeConfigurationBuilder;
+import org.apache.tuscany.core.builder.WireBuilder;
+import org.apache.tuscany.core.builder.impl.AssemblyVisitor;
+import org.apache.tuscany.core.builder.impl.DefaultWireBuilder;
+import org.apache.tuscany.core.config.ConfigurationException;
+import org.apache.tuscany.core.context.AbstractContext;
+import org.apache.tuscany.core.context.AggregateContext;
+import org.apache.tuscany.core.context.AutowireContext;
+import org.apache.tuscany.core.context.AutowireResolutionException;
+import org.apache.tuscany.core.context.ConfigurationContext;
+import org.apache.tuscany.core.context.CoreRuntimeException;
+import org.apache.tuscany.core.context.EventException;
+import org.apache.tuscany.core.context.QualifiedName;
+import org.apache.tuscany.core.context.RuntimeEventListener;
+import org.apache.tuscany.core.context.ScopeContext;
+import org.apache.tuscany.core.context.SystemAggregateContext;
+import org.apache.tuscany.core.context.TargetException;
+import org.apache.tuscany.core.context.impl.AggregateContextImpl;
+import org.apache.tuscany.core.context.impl.EventContextImpl;
+import org.apache.tuscany.core.invocation.spi.ProxyFactory;
+import org.apache.tuscany.core.system.context.SystemAggregateContextImpl;
+import org.apache.tuscany.core.system.context.SystemScopeStrategy;
+import org.apache.tuscany.model.assembly.Aggregate;
+import org.apache.tuscany.model.assembly.Extensible;
+import org.apache.tuscany.model.scdl.loader.SCDLModelLoader;
+
+/**
+ * Implementation of a RuntimeContext that forms the foundation for a Tuscany environment.
+ *
+ * @version $Rev$ $Date$
+ */
+public class RuntimeContextImpl extends AbstractContext implements RuntimeContext {
+
+ private final List<RuntimeConfigurationBuilder> builders;
+
+ private final List<SCDLModelLoader> loaders;
+
+ // the top-level wire builder in the runtime
+ private final HierarchicalWireBuilder wireBuilder;
+
+ private final List<RuntimeEventListener> listeners = new ArrayList(1);
+
+ private final AggregateContext rootContext;
+
+ private final SystemAggregateContext systemContext;
+
+ private final MonitorFactory monitorFactory;
+
+ /**
+ * Default constructor that creates a runtime with a NullMonitorFactory and no builders.
+ */
+ public RuntimeContextImpl() {
+ this(new NullMonitorFactory(), null, null, null);
+ }
+
+ /**
+ * Constructor for creating a runtime with a specified MonitorFactory and pre-defined builders.
+ *
+ * @param monitorFactory the default {@link MonitorFactory} for this runtime
+ * @param builders a list of builders automatically made available; may be null
+ * @param wireBuilder the top-level hierarchical wire builder for the runtime; if not specified, a default
+ * implementation will be used
+ */
+ public RuntimeContextImpl(MonitorFactory monitorFactory, List<SCDLModelLoader> loaders,
+ List<RuntimeConfigurationBuilder> builders, HierarchicalWireBuilder wireBuilder) {
+ super(RUNTIME);
+ this.monitorFactory = monitorFactory;
+ this.builders = (builders == null) ? new ArrayList(1) : builders;
+ this.loaders = (loaders == null) ? new ArrayList(1) : loaders;
+ this.wireBuilder = (wireBuilder == null) ? new DefaultWireBuilder() : wireBuilder;
+
+ rootContext = new AggregateContextImpl(ROOT, this, this, new RuntimeScopeStrategy(), new EventContextImpl(), this, monitorFactory);
+ systemContext = new SystemAggregateContextImpl(SYSTEM, this, this, new SystemScopeStrategy(), new EventContextImpl(), this, monitorFactory);
+ }
+
+ /**
+ * Specialized constructor that allows the default implementations of the root and system contexts to be
+ * overridden.
+ *
+ * @param monitorFactory the default {@link MonitorFactory} for this runtime
+ * @param rootContext the context to use for the root of the user context tree
+ * @param systemContext the context to use for the root of the system context tree
+ * @param builders a list of builders automatically made available; may be null
+ * @param wireBuilder the top-level hierarchical wire builder for the runtime; if not specified, a default
+ * implementation will be used
+ */
+ public RuntimeContextImpl(MonitorFactory monitorFactory, AggregateContext rootContext, SystemAggregateContext systemContext,
+ List<SCDLModelLoader> loaders, List<RuntimeConfigurationBuilder> builders, HierarchicalWireBuilder wireBuilder) {
+ super(RUNTIME);
+ this.rootContext = rootContext;
+ this.systemContext = systemContext;
+ this.monitorFactory = monitorFactory;
+ this.loaders = (loaders == null) ? new ArrayList(1) : loaders;
+ this.builders = (builders == null) ? new ArrayList(1) : builders;
+ this.wireBuilder = (wireBuilder == null) ? new DefaultWireBuilder() : wireBuilder;
+ }
+
+ public void start() throws CoreRuntimeException {
+ if (lifecycleState == RUNNING) {
+ return;
+ }
+ systemContext.start();
+ rootContext.start();
+ lifecycleState = RUNNING;
+ }
+
+ public void stop() throws CoreRuntimeException {
+ if (lifecycleState == STOPPED) {
+ return;
+ }
+ rootContext.stop();
+ systemContext.stop();
+ lifecycleState = STOPPED;
+ }
+
+ public void addBuilder(RuntimeConfigurationBuilder builder) {
+ assert (builder != null) : "Builder was null";
+ builders.add(builder);
+ }
+
+ public void addBuilder(WireBuilder builder) {
+ assert (builder != null) : "Builder was null";
+ wireBuilder.addWireBuilder(builder);
+ }
+
+ public void addLoader(SCDLModelLoader loader) {
+ assert (loader != null) : "Loader was null";
+ loaders.add(loader);
+ }
+
+ public AggregateContext getContext(String ctxName) {
+ checkRunning();
+ if (ROOT.equals(ctxName)) {
+ return rootContext;
+ } else if (SYSTEM.equals(ctxName)) {
+ return systemContext;
+ }
+ return (AggregateContext) rootContext.getContext(ctxName);
+ }
+
+ public AggregateContext getRootContext() {
+ checkRunning();
+ return rootContext;
+ }
+
+ public SystemAggregateContext getSystemContext() {
+ checkRunning();
+ return systemContext;
+ }
+
+ public MonitorFactory getMonitorFactory() {
+ return monitorFactory;
+ }
+
+ public void registerModelObject(Extensible model) throws ConfigurationException {
+ assert (model != null) : "Model was null";
+ // note do not configure or build model object since the root context will perform a call back
+ rootContext.registerModelObject(model);
+ }
+
+ public void registerModelObjects(List<Extensible> models) throws ConfigurationException {
+ for (Extensible model : models) {
+ registerModelObject(model);
+ }
+ }
+
+ public void registerListener(RuntimeEventListener listener) {
+ assert (listener != null) : "Listener cannot be null";
+ listeners.add(listener);
+ }
+
+ public void fireEvent(int eventType, Object message) throws EventException {
+ checkRunning();
+ for (RuntimeEventListener listener : listeners) {
+ listener.onEvent(eventType, message);
+ }
+ }
+
+ public AggregateContext getParent() {
+ return null; // there is no parent
+ }
+
+ public Object locateService(String serviceName) {
+ return null;
+ }
+
+ public Object locateInstance(String serviceName) {
+ return null;
+ }
+
+ public Object getInstance(QualifiedName qName) throws TargetException {
+ return getSystemContext().getInstance(qName);
+ }
+
+ public Object getInstance(QualifiedName qName, boolean notify) throws TargetException {
+ return getInstance(qName);
+ }
+
+ // ----------------------------------
+ // ConfigurationContext methods
+ // ----------------------------------
+
+ public synchronized void build(AggregateContext parent, Extensible model) throws BuilderConfigException {
+ AssemblyVisitor visitor = new AssemblyVisitor(parent, builders);
+ visitor.start(model);
+ }
+
+ public void configure(Extensible model) throws ConfigurationException {
+ }
+
+ public void wire(ProxyFactory sourceFactory, ProxyFactory targetFactory, Class targetType, boolean downScope,
+ ScopeContext targetScopeContext) throws BuilderConfigException {
+ wireBuilder.connect(sourceFactory, targetFactory, targetType, downScope, targetScopeContext);
+ }
+
+ public void wire(ProxyFactory targetFactory, Class targetType, ScopeContext targetScopeContext) throws BuilderConfigException {
+ wireBuilder.completeTargetChain(targetFactory, targetType, targetScopeContext);
+ }
+
+ // ----------------------------------
+ // AutowireContext methods
+ // ----------------------------------
+
+ public <T> T resolveInstance(Class<T> instanceInterface) throws AutowireResolutionException {
+ if (MonitorFactory.class.equals(instanceInterface)) {
+ return instanceInterface.cast(monitorFactory);
+ } else if (ConfigurationContext.class.equals(instanceInterface)) {
+ return instanceInterface.cast(this);
+ } else if (AutowireContext.class.equals(instanceInterface)) {
+ return instanceInterface.cast(this);
+ } else if (RuntimeContext.class.equals(instanceInterface)) {
+ return instanceInterface.cast(this);
+ } else {
+ // autowire to system components
+ return instanceInterface.cast(getSystemContext().resolveInstance(instanceInterface));
+ }
+ }
+
+ // ----------------------------------
+ // InstanceContext methods
+ // ----------------------------------
+
+ public Object getImplementationInstance() throws TargetException {
+ return this;
+ }
+
+ public Object getImplementationInstance(boolean notify) throws TargetException {
+ return this;
+ }
+
+ public Aggregate getAggregate() {
+ return systemContext.getAggregate();
+ }
+
+ // ----------------------------------
+ // Private methods
+ // ----------------------------------
+
+ private void checkRunning() {
+ if (lifecycleState != RUNNING) {
+ throw new IllegalStateException("Context must be in RUNNING state");
+ }
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/runtime/RuntimeMonitor.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/runtime/RuntimeMonitor.java
new file mode 100644
index 0000000000..c1b87d6a13
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/runtime/RuntimeMonitor.java
@@ -0,0 +1,32 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.runtime;
+
+import org.apache.tuscany.common.TuscanyException;
+import org.apache.tuscany.common.TuscanyRuntimeException;
+
+
+/**
+ * Serves as a top-level error logging monitor
+ *
+ * @version $Rev$ $Date$
+ */
+public interface RuntimeMonitor {
+
+ public void log(TuscanyRuntimeException e);
+
+ public void log(TuscanyException e);
+
+}
+
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/runtime/RuntimeScopeStrategy.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/runtime/RuntimeScopeStrategy.java
new file mode 100644
index 0000000000..77ddd78d15
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/runtime/RuntimeScopeStrategy.java
@@ -0,0 +1,46 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.runtime;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.core.context.EventContext;
+import org.apache.tuscany.core.context.ScopeContext;
+import org.apache.tuscany.core.context.scope.AbstractScopeStrategy;
+import org.apache.tuscany.core.context.scope.AggregateScopeContext;
+import org.apache.tuscany.model.assembly.Scope;
+
+/**
+ * Implements a {@link org.apache.tuscany.core.context.ScopeStrategy} for a runtime context. Specifically, a runtime
+ * context has only one scope, {@link org.apache.tuscany.model.assembly.Scope#AGGREGATE}
+ *
+ * @version $Rev$ $Date$
+ */
+public class RuntimeScopeStrategy extends AbstractScopeStrategy {
+
+ public RuntimeScopeStrategy() {
+ }
+
+ public Map<Scope, ScopeContext> createScopes(EventContext eventContext) {
+ ScopeContext aggregrateScope = new AggregateScopeContext(eventContext);
+ Map<Scope, ScopeContext> scopes = new HashMap();
+ scopes.put(Scope.AGGREGATE, aggregrateScope);
+ return scopes;
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/annotation/Autowire.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/annotation/Autowire.java
new file mode 100644
index 0000000000..bcb06812e8
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/annotation/Autowire.java
@@ -0,0 +1,21 @@
+package org.apache.tuscany.core.system.annotation;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ * A system annotation to inject an autowired instance
+ *
+ * @version $Rev$ $Date$
+ */
+@Target( { METHOD, FIELD })
+@Retention(RUNTIME)
+public @interface Autowire {
+
+ public boolean required() default true;
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/annotation/ParentContext.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/annotation/ParentContext.java
new file mode 100644
index 0000000000..f3d2c0216b
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/annotation/ParentContext.java
@@ -0,0 +1,33 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.system.annotation;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ * A system annotation to inject the parent context
+ *
+ * @version $Rev$ $Date$
+ */
+
+@Target( { METHOD, FIELD })
+@Retention(RUNTIME)
+public @interface ParentContext {
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/assembly/SystemAssemblyFactory.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/assembly/SystemAssemblyFactory.java
new file mode 100644
index 0000000000..d230df8dd7
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/assembly/SystemAssemblyFactory.java
@@ -0,0 +1,38 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.system.assembly;
+
+import org.apache.tuscany.model.assembly.AssemblyFactory;
+
+/**
+ * A factory for building system assembly model artifacts
+ *
+ * @version $Rev$ $Date$
+ */
+public interface SystemAssemblyFactory extends AssemblyFactory {
+
+ /**
+ * Returns an assembly model artifact representing a system component implementation
+ */
+ SystemImplementation createSystemImplementation();
+
+ /**
+ * Returns an assembly model artifact representing a system binding
+ */
+ SystemBinding createSystemBinding();
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/assembly/SystemBinding.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/assembly/SystemBinding.java
new file mode 100644
index 0000000000..edc7c87c85
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/assembly/SystemBinding.java
@@ -0,0 +1,37 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.system.assembly;
+
+import org.apache.tuscany.model.assembly.Binding;
+
+/**
+ * Represents a system binding
+ *
+ * @version $Rev$ $Date$
+ */
+public interface SystemBinding extends Binding {
+
+ /**
+ * Returns the qualified name of the wire target the binding is associated with in component/service form
+ */
+ public String getTargetName();
+
+ /**
+ * Sets the qualified name of the wire target the binding is associated with in component/service form
+ */
+ public void setTargetName(String name);
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/assembly/SystemImplementation.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/assembly/SystemImplementation.java
new file mode 100644
index 0000000000..7fae0ebad3
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/assembly/SystemImplementation.java
@@ -0,0 +1,38 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.system.assembly;
+
+import org.apache.tuscany.model.assembly.ComponentImplementation;
+
+/**
+ * Represents a system component implementation
+ *
+ * @version $Rev$ $Date$
+ */
+public interface SystemImplementation extends ComponentImplementation {
+
+ /**
+ * Returns the implementation class of the system component
+ */
+ Class getImplementationClass();
+
+ /**
+ * Sets the implementation class of the system component
+ */
+ void setImplementationClass(Class value);
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/assembly/impl/SystemAssemblyFactoryImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/assembly/impl/SystemAssemblyFactoryImpl.java
new file mode 100644
index 0000000000..668b7dd8b1
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/assembly/impl/SystemAssemblyFactoryImpl.java
@@ -0,0 +1,41 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.system.assembly.impl;
+
+import org.apache.tuscany.core.system.assembly.SystemAssemblyFactory;
+import org.apache.tuscany.core.system.assembly.SystemBinding;
+import org.apache.tuscany.core.system.assembly.SystemImplementation;
+import org.apache.tuscany.model.assembly.impl.AssemblyFactoryImpl;
+
+/**
+ * The default implementation of the system assembly factory
+ *
+ * @version $Rev$ $Date$
+ */
+public class SystemAssemblyFactoryImpl extends AssemblyFactoryImpl implements SystemAssemblyFactory {
+
+ public SystemAssemblyFactoryImpl() {
+ }
+
+ public SystemImplementation createSystemImplementation() {
+ return new SystemImplementationImpl();
+ }
+
+ public SystemBinding createSystemBinding() {
+ return new SystemBindingImpl();
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/assembly/impl/SystemBindingImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/assembly/impl/SystemBindingImpl.java
new file mode 100644
index 0000000000..a9996065e2
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/assembly/impl/SystemBindingImpl.java
@@ -0,0 +1,41 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.system.assembly.impl;
+
+import org.apache.tuscany.core.system.assembly.SystemBinding;
+import org.apache.tuscany.model.assembly.impl.BindingImpl;
+
+/**
+ * The default implementation of the system binding assembly artifact
+ *
+ * @version $Rev$ $Date$
+ */
+public class SystemBindingImpl extends BindingImpl implements SystemBinding {
+
+ protected SystemBindingImpl() {
+ }
+
+ private String name;
+
+ public String getTargetName() {
+ return name;
+ }
+
+ public void setTargetName(String name) {
+ this.name = name;
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/assembly/impl/SystemImplementationImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/assembly/impl/SystemImplementationImpl.java
new file mode 100644
index 0000000000..5d54132464
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/assembly/impl/SystemImplementationImpl.java
@@ -0,0 +1,94 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.system.assembly.impl;
+
+import java.net.URL;
+
+import org.apache.tuscany.core.config.ComponentTypeIntrospector;
+import org.apache.tuscany.core.config.ConfigurationException;
+import org.apache.tuscany.core.config.JavaIntrospectionHelper;
+import org.apache.tuscany.core.config.impl.Java5ComponentTypeIntrospector;
+import org.apache.tuscany.core.system.assembly.SystemImplementation;
+import org.apache.tuscany.model.assembly.AssemblyFactory;
+import org.apache.tuscany.model.assembly.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.ComponentType;
+import org.apache.tuscany.model.assembly.Scope;
+import org.apache.tuscany.model.assembly.Service;
+import org.apache.tuscany.model.assembly.impl.AssemblyFactoryImpl;
+import org.apache.tuscany.model.assembly.impl.ComponentImplementationImpl;
+
+/**
+ * The default implementation of the system implementation assembly artifact
+ *
+ * @version $Rev$ $Date$
+ */
+public class SystemImplementationImpl extends ComponentImplementationImpl implements SystemImplementation {
+
+ private Class<?> implementationClass;
+
+ private AssemblyModelContext modelContext;
+
+ protected SystemImplementationImpl() {
+ }
+
+ public Class getImplementationClass() {
+ return implementationClass;
+ }
+
+ public void setImplementationClass(Class value) {
+ checkNotFrozen();
+ implementationClass = value;
+ }
+
+ public void initialize(AssemblyModelContext context) {
+ if (isInitialized())
+ return;
+ this.modelContext = context;
+ // Initialize the component type
+ ComponentType componentType = getComponentType();
+ if (componentType == null) {
+ componentType = createComponentType(implementationClass);
+ setComponentType(componentType);
+ }
+ super.initialize(modelContext);
+ }
+
+ /**
+ * Creates the component type
+ */
+ private ComponentType createComponentType(Class<?> implClass) {
+ ComponentType componentType;
+ String baseName = JavaIntrospectionHelper.getBaseName(implClass);
+ URL componentTypeFile = implClass.getResource(baseName + ".componentType");
+ if (componentTypeFile != null) {
+ componentType = modelContext.getAssemblyLoader().loadComponentType(componentTypeFile.toString());
+ // FIXME workaround for TUSCANY-46 where the scope is not read - default system implementations to MODULE scope
+ for (Service service : componentType.getServices()) {
+ service.getServiceContract().setScope(Scope.MODULE);
+ }
+ } else {
+ AssemblyFactory factory = new AssemblyFactoryImpl();
+ ComponentTypeIntrospector introspector = new Java5ComponentTypeIntrospector(factory);
+ try {
+ componentType = introspector.introspect(implClass);
+ } catch (ConfigurationException e) {
+ throw new IllegalArgumentException("Unable to introspect implementation class: " + implClass.getName(), e);
+ }
+ }
+ return componentType;
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/builder/SystemComponentContextBuilder.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/builder/SystemComponentContextBuilder.java
new file mode 100644
index 0000000000..ac65a3de49
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/builder/SystemComponentContextBuilder.java
@@ -0,0 +1,383 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.system.builder;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.tuscany.common.monitor.MonitorFactory;
+import org.apache.tuscany.core.builder.BuilderConfigException;
+import org.apache.tuscany.core.builder.BuilderException;
+import org.apache.tuscany.core.builder.NoAccessorException;
+import org.apache.tuscany.core.builder.RuntimeConfigurationBuilder;
+import org.apache.tuscany.core.builder.UnknownTypeException;
+import org.apache.tuscany.core.config.JavaIntrospectionHelper;
+import org.apache.tuscany.core.context.AggregateContext;
+import org.apache.tuscany.core.context.AutowireContext;
+import org.apache.tuscany.core.context.ConfigurationContext;
+import org.apache.tuscany.core.context.SystemAggregateContext;
+import org.apache.tuscany.core.context.impl.AggregateContextImpl;
+import org.apache.tuscany.core.injection.EventInvoker;
+import org.apache.tuscany.core.injection.FieldInjector;
+import org.apache.tuscany.core.injection.Injector;
+import org.apache.tuscany.core.injection.MethodEventInvoker;
+import org.apache.tuscany.core.injection.MethodInjector;
+import org.apache.tuscany.core.injection.ObjectCreationException;
+import org.apache.tuscany.core.injection.ReferenceTargetFactory;
+import org.apache.tuscany.core.injection.SDOObjectFactory;
+import org.apache.tuscany.core.injection.SingletonObjectFactory;
+import org.apache.tuscany.core.runtime.RuntimeContext;
+import org.apache.tuscany.core.system.annotation.Autowire;
+import org.apache.tuscany.core.system.annotation.ParentContext;
+import org.apache.tuscany.core.system.assembly.SystemImplementation;
+import org.apache.tuscany.core.system.config.SystemComponentRuntimeConfiguration;
+import org.apache.tuscany.core.system.context.SystemAggregateContextImpl;
+import org.apache.tuscany.model.assembly.AssemblyModelObject;
+import org.apache.tuscany.model.assembly.Component;
+import org.apache.tuscany.model.assembly.ComponentImplementation;
+import org.apache.tuscany.model.assembly.ConfiguredProperty;
+import org.apache.tuscany.model.assembly.ConfiguredReference;
+import org.apache.tuscany.model.assembly.ConfiguredService;
+import org.apache.tuscany.model.assembly.Module;
+import org.apache.tuscany.model.assembly.Scope;
+import org.osoa.sca.annotations.ComponentName;
+import org.osoa.sca.annotations.Context;
+import org.osoa.sca.annotations.Destroy;
+import org.osoa.sca.annotations.Init;
+
+import commonj.sdo.DataObject;
+
+/**
+ * Decorates components whose implementation type is a
+ * {@link org.apache.tuscany.core.system.assembly.SystemImplementation} with the appropriate runtime configuration.
+ * System components are not proxied.
+ *
+ * @version $Rev$ $Date$
+ */
+public class SystemComponentContextBuilder implements RuntimeConfigurationBuilder<AggregateContext> {
+ // ----------------------------------
+ // Constructors
+ // ----------------------------------
+
+ public SystemComponentContextBuilder() {
+ }
+
+ // ----------------------------------
+ // Methods
+ // ----------------------------------
+
+ public void build(AssemblyModelObject modelObject, AggregateContext parentContext) throws BuilderException {
+ if (!(modelObject instanceof Component)) {
+ return;
+ }
+ Component component = (Component) modelObject;
+
+ Class implClass = null;
+ Scope scope = null;
+
+ // Get the component implementation
+ ComponentImplementation componentImplementation = component.getComponentImplementation();
+ if (componentImplementation instanceof SystemImplementation
+ && componentImplementation.getRuntimeConfiguration() == null) {
+
+ // The component is a system component, implemented by a Java class
+ SystemImplementation javaImpl = (SystemImplementation) componentImplementation;
+ scope = componentImplementation.getComponentType().getServices().get(0).getServiceContract().getScope();
+ implClass = javaImpl.getImplementationClass();
+
+ } else if (componentImplementation instanceof Module) {
+ if (((Module)componentImplementation).getName().startsWith("org.apache.tuscany.core.system")) {
+
+ // The component is a system module component, fix the implementation class to our implementation
+ // of system module component context
+ implClass=SystemAggregateContextImpl.class;
+ scope = Scope.AGGREGATE;
+
+ } else {
+
+ // The component is an app module component, fix the implementation class to our implementation
+ // of app module component context
+ implClass=AggregateContextImpl.class;
+ scope = Scope.AGGREGATE;
+
+ }
+
+ } else {
+ return;
+ }
+
+ // FIXME scope
+ Set<Field> fields;
+ Set<Method> methods;
+ try {
+ fields = JavaIntrospectionHelper.getAllFields(implClass);
+ methods = JavaIntrospectionHelper.getAllUniqueMethods(implClass);
+ String name = component.getName();
+ Constructor ctr = implClass.getConstructor((Class[]) null);
+
+ List<Injector> injectors = new ArrayList();
+
+ // handle properties
+ List<ConfiguredProperty> configuredProperties = component.getConfiguredProperties();
+ if (configuredProperties != null) {
+ for (ConfiguredProperty property : configuredProperties) {
+ Injector injector = createPropertyInjector(property, fields, methods);
+ injectors.add(injector);
+ }
+ }
+
+ //FIXME do not inject references on an application module yet
+ if (implClass!=AggregateContextImpl.class) {
+ // handle references
+ List<ConfiguredReference> configuredReferences = component.getConfiguredReferences();
+ if (configuredReferences != null) {
+ for (ConfiguredReference reference : configuredReferences) {
+ Injector injector = createReferenceInjector(parentContext.getName(), component.getName(), parentContext,
+ reference, fields, methods);
+ injectors.add(injector);
+ }
+ }
+ }
+
+ // create factory for the component implementation type
+ EventInvoker initInvoker = null;
+ boolean eagerInit = false;
+ EventInvoker destroyInvoker = null;
+ for (Field field : fields) {
+ ComponentName compName = field.getAnnotation(ComponentName.class);
+ if (compName != null) {
+ Injector injector = new FieldInjector(field, new SingletonObjectFactory(name));
+ injectors.add(injector);
+ }
+ Context context = field.getAnnotation(Context.class);
+ if (context != null) {
+ Injector injector = new FieldInjector(field, new SingletonObjectFactory(parentContext));
+ injectors.add(injector);
+ }
+ ParentContext parentField = field.getAnnotation(ParentContext.class);
+ if (parentField != null) {
+ if (!(parentContext instanceof AggregateContext)) {
+ BuilderConfigException e = new BuilderConfigException("Component must be a child of");
+ e.setIdentifier(AggregateContext.class.getName());
+ throw e;
+ }
+ Injector injector = new FieldInjector(field, new SingletonObjectFactory((parentContext)));
+ injectors.add(injector);
+ }
+ Autowire autowire = field.getAnnotation(Autowire.class);
+ if (autowire != null) {
+ if (!(parentContext instanceof AutowireContext)) {
+ BuilderConfigException e = new BuilderConfigException("Parent context must implement");
+ e.setIdentifier(AutowireContext.class.getName());
+ throw e;
+ }
+ AutowireContext ctx = (AutowireContext) parentContext;
+ // for system aggregate context types, only allow autowire of certain types, otherwise we have a
+ // chicken-and-egg problem
+ if (SystemAggregateContext.class.isAssignableFrom(implClass)
+ && !(field.getType().equals(ConfigurationContext.class)
+ || field.getType().equals(MonitorFactory.class)
+ || field.getType().equals(RuntimeContext.class) || field.getType().equals(
+ AutowireContext.class))) {
+ BuilderConfigException e = new BuilderConfigException("Illegal autowire type for system context");
+ e.setIdentifier(field.getType().getName());
+ throw e;
+ }
+
+ Object o = ctx.resolveInstance(field.getType());
+ if (autowire.required() && o == null) {
+ BuilderConfigException e = new BuilderConfigException("No autowire found for field");
+ e.setIdentifier(field.getName());
+ throw e;
+ }
+ Injector injector = new FieldInjector(field, new SingletonObjectFactory(o));
+ injectors.add(injector);
+ }
+ }
+ for (Method method : methods) {
+ Init init = method.getAnnotation(Init.class);
+ if (init != null && initInvoker == null) {
+ initInvoker = new MethodEventInvoker(method);
+ eagerInit = init.eager();
+ continue;
+ }
+ Destroy destroy = method.getAnnotation(Destroy.class);
+ if (destroy != null && destroyInvoker == null) {
+ destroyInvoker = new MethodEventInvoker(method);
+ continue;
+ }
+ ComponentName compName = method.getAnnotation(ComponentName.class);
+ if (compName != null) {
+ Injector injector = new MethodInjector(method, new SingletonObjectFactory(name));
+ injectors.add(injector);
+ }
+ Context context = method.getAnnotation(Context.class);
+ if (context != null) {
+ Injector injector = new MethodInjector(method, new SingletonObjectFactory(parentContext));
+ injectors.add(injector);
+ }
+ ParentContext parentMethod = method.getAnnotation(ParentContext.class);
+ if (parentMethod != null) {
+ if (!(parentContext instanceof AggregateContext)) {
+ BuilderConfigException e = new BuilderConfigException("Component must be a child of ");
+ e.setIdentifier(AggregateContext.class.getName());
+ throw e;
+ }
+ Injector injector = new MethodInjector(method, new SingletonObjectFactory((parentContext)));
+ injectors.add(injector);
+ }
+ Autowire autowire = method.getAnnotation(Autowire.class);
+ if (autowire != null) {
+ if (!(parentContext instanceof AutowireContext)) {
+ BuilderConfigException e = new BuilderConfigException("Parent context must implement)");
+ e.setIdentifier(AutowireContext.class.getName());
+ throw e;
+ }
+ if (method.getParameterTypes() == null || method.getParameterTypes().length != 1) {
+ BuilderConfigException e = new BuilderConfigException(
+ "Autowire setter methods must take one parameter");
+ e.setIdentifier(method.getName());
+ throw e;
+ }
+ AutowireContext ctx = (AutowireContext) parentContext;
+ Class paramType = method.getParameterTypes()[0];
+ // for system aggregate context types, only allow autowire of certain types, otherwise we have a
+ // chicken-and-egg problem
+ if (SystemAggregateContext.class.isAssignableFrom(implClass)
+ && !(paramType.equals(ConfigurationContext.class) || paramType.equals(MonitorFactory.class)
+ || paramType.equals(RuntimeContext.class) || paramType.equals(AutowireContext.class))) {
+ BuilderConfigException e = new BuilderConfigException("Illegal autowire type for system context");
+ e.setIdentifier(paramType.getName());
+ throw e;
+ }
+ Object o = ctx.resolveInstance(paramType);
+ if (autowire.required() && o == null) {
+ BuilderConfigException e = new BuilderConfigException("No autowire found for method ");
+ e.setIdentifier(method.getName());
+ throw e;
+ }
+
+ Injector injector = new MethodInjector(method, new SingletonObjectFactory(o));
+ injectors.add(injector);
+ }
+ }
+ // decorate the logical model
+ SystemComponentRuntimeConfiguration config = new SystemComponentRuntimeConfiguration(name,
+ JavaIntrospectionHelper.getDefaultConstructor(implClass), injectors, eagerInit, initInvoker,
+ destroyInvoker, scope);
+ componentImplementation.setRuntimeConfiguration(config);
+ } catch (BuilderConfigException e) {
+ e.addContextName(component.getName());
+ e.addContextName(parentContext.getName());
+ throw e;
+ } catch (NoSuchMethodException e) {
+ BuilderConfigException ce = new BuilderConfigException("Class does not have a no-arg constructor", e);
+ ce.setIdentifier(implClass.getName());
+ throw ce;
+ }
+ }
+
+ // ----------------------------------
+ // Private methods
+ // ----------------------------------
+
+ /**
+ * Creates an <code>Injector</code> for component properties
+ */
+ private Injector createPropertyInjector(ConfiguredProperty property, Set<Field> fields, Set<Method> methods)
+ throws NoAccessorException {
+ Object value = property.getValue();
+ String propName = property.getProperty().getName();
+ // @FIXME is this how to get property type of object
+ Class type = value.getClass();
+
+ // There is no efficient way to do this
+ Method method = null;
+ Field field = JavaIntrospectionHelper.findClosestMatchingField(propName, type, fields);
+ if (field == null) {
+ method = JavaIntrospectionHelper.findClosestMatchingMethod(propName, new Class[] { type }, methods);
+ if (method == null) {
+ throw new NoAccessorException(propName);
+ }
+ }
+ Injector injector = null;
+ // FIXME support types other than String
+ if (value instanceof DataObject) {
+ if (field != null) {
+ injector = new FieldInjector(field, new SDOObjectFactory((DataObject) value));
+ } else {
+ injector = new MethodInjector(method, new SDOObjectFactory((DataObject) value));
+ }
+ } else if (JavaIntrospectionHelper.isImmutable(type)) {
+ if (field != null) {
+ injector = new FieldInjector(field, new SingletonObjectFactory(value));
+ } else {
+ injector = new MethodInjector(method, new SingletonObjectFactory(value));
+ }
+ } else {
+ if (field != null) {
+ throw new UnknownTypeException(field.getName());
+ } else {
+ throw new UnknownTypeException(method.getName());
+ }
+ }
+ return injector;
+
+ }
+
+ /**
+ * Creates an <code>Injector</code> for service references
+ */
+ private Injector createReferenceInjector(String moduleName, String componentName, AggregateContext parentContext,
+ ConfiguredReference reference, Set<Field> fields, Set<Method> methods) throws NoAccessorException,
+ BuilderConfigException {
+ String refName = reference.getReference().getName();
+ List<ConfiguredService> services = reference.getTargetConfiguredServices();
+ Class type;
+ if (services.size() == 1) {
+ // get the interface
+ type = reference.getReference().getServiceContract().getInterface();
+ } else {
+ // FIXME do we support arrays?
+ type = List.class;
+ }
+ Method method = null;
+ Field field = JavaIntrospectionHelper.findClosestMatchingField(refName, type, fields);
+ if (field == null) {
+ method = JavaIntrospectionHelper.findClosestMatchingMethod(refName, new Class[] { type }, methods);
+ if (method == null) {
+ throw new NoAccessorException(refName);
+ }
+ }
+ Injector injector;
+ try {
+ if (field != null) {
+ injector = new FieldInjector(field, new ReferenceTargetFactory(reference, parentContext));
+ } else {
+ injector = new MethodInjector(method, new ReferenceTargetFactory(reference, parentContext));
+ }
+ } catch (ObjectCreationException e) {
+ BuilderConfigException ce = new BuilderConfigException("Error configuring reference", e);
+ ce.setIdentifier(refName);
+ throw ce;
+ }
+ return injector;
+
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/builder/SystemEntryPointBuilder.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/builder/SystemEntryPointBuilder.java
new file mode 100644
index 0000000000..6520fc0557
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/builder/SystemEntryPointBuilder.java
@@ -0,0 +1,63 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.system.builder;
+
+import org.apache.tuscany.core.builder.BuilderException;
+import org.apache.tuscany.core.builder.RuntimeConfigurationBuilder;
+import org.apache.tuscany.core.context.AggregateContext;
+import org.apache.tuscany.core.injection.FactoryInitException;
+import org.apache.tuscany.core.injection.ReferenceTargetFactory;
+import org.apache.tuscany.core.system.assembly.SystemBinding;
+import org.apache.tuscany.core.system.config.SystemEntryPointRuntimeConfiguration;
+import org.apache.tuscany.model.assembly.AssemblyModelObject;
+import org.apache.tuscany.model.assembly.EntryPoint;
+
+/**
+ * Decorates the logical model with entry point context configuration builders
+ *
+ * @version $Rev$ $Date$
+ */
+public class SystemEntryPointBuilder implements RuntimeConfigurationBuilder<AggregateContext> {
+
+ // ----------------------------------
+ // Constructors
+ // ----------------------------------
+
+ public SystemEntryPointBuilder() {
+ }
+
+ // ----------------------------------
+ // Methods
+ // ----------------------------------
+
+ public void build(AssemblyModelObject modelObject, AggregateContext context) throws BuilderException {
+ if (!(modelObject instanceof EntryPoint)) {
+ return;
+ }
+ EntryPoint entryPoint = (EntryPoint) modelObject;
+ if (!(entryPoint.getBindings().get(0) instanceof SystemBinding)
+ || entryPoint.getConfiguredReference().getRuntimeConfiguration() != null) {
+ return;
+ }
+ try {
+ SystemEntryPointRuntimeConfiguration config = new SystemEntryPointRuntimeConfiguration(entryPoint.getName(),
+ new ReferenceTargetFactory(entryPoint.getConfiguredReference(), context));
+ entryPoint.getConfiguredReference().setRuntimeConfiguration(config);
+ } catch (FactoryInitException e) {
+ e.addContextName(entryPoint.getName());
+ e.addContextName(context.getName());
+ throw e;
+ }
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/builder/SystemExternalServiceBuilder.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/builder/SystemExternalServiceBuilder.java
new file mode 100644
index 0000000000..dc00e6505f
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/builder/SystemExternalServiceBuilder.java
@@ -0,0 +1,77 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.system.builder;
+
+import org.apache.tuscany.core.builder.BuilderConfigException;
+import org.apache.tuscany.core.builder.BuilderException;
+import org.apache.tuscany.core.builder.RuntimeConfigurationBuilder;
+import org.apache.tuscany.core.context.AggregateContext;
+import org.apache.tuscany.core.context.AutowireContext;
+import org.apache.tuscany.core.injection.ReferenceTargetFactory;
+import org.apache.tuscany.core.system.assembly.SystemBinding;
+import org.apache.tuscany.core.system.config.SystemExternalServiceRuntimeConfiguration;
+import org.apache.tuscany.core.system.injection.AutowireFactory;
+import org.apache.tuscany.model.assembly.AssemblyModelObject;
+import org.apache.tuscany.model.assembly.ExternalService;
+
+/**
+ * Creates runtime configurations for system type external services
+ *
+ * @version $Rev$ $Date$
+ */
+public class SystemExternalServiceBuilder implements RuntimeConfigurationBuilder<AggregateContext> {
+ // ----------------------------------
+ // Constructors
+ // ----------------------------------
+
+ public SystemExternalServiceBuilder() {
+ }
+
+ // ----------------------------------
+ // Methods
+ // ----------------------------------
+
+ public void build(AssemblyModelObject modelObject, AggregateContext context) throws BuilderException {
+ if (!(modelObject instanceof ExternalService)) {
+ return;
+ }
+ ExternalService externalService = (ExternalService) modelObject;
+ if (externalService.getConfiguredService() != null
+ && externalService.getConfiguredService().getRuntimeConfiguration() != null) {
+ return;
+ } else if (externalService.getBindings() == null || externalService.getBindings().size() < 1
+ || !(externalService.getBindings().get(0) instanceof SystemBinding)) {
+ return;
+ }
+ SystemBinding binding = (SystemBinding)externalService.getBindings().get(0);
+ if (binding.getTargetName() != null) {
+ SystemExternalServiceRuntimeConfiguration config = new SystemExternalServiceRuntimeConfiguration(externalService
+ .getName(), new ReferenceTargetFactory(binding.getTargetName(), context));
+ externalService.getConfiguredService().setRuntimeConfiguration(config);
+ } else if (externalService.getConfiguredService().getService().getServiceContract().getInterface() != null) {
+ // autowire
+ Class<?> claz = externalService.getConfiguredService().getService().getServiceContract().getInterface();
+ if (claz == null) {
+ BuilderException e = new BuilderConfigException("Interface type not specified");
+ e.setIdentifier(externalService.getName());
+ e.addContextName(externalService.getName());
+ e.addContextName(context.getName());
+ throw e;
+ }
+ SystemExternalServiceRuntimeConfiguration config = new SystemExternalServiceRuntimeConfiguration(externalService
+ .getName(), new AutowireFactory(claz, (AutowireContext) context));
+ externalService.getConfiguredService().setRuntimeConfiguration(config);
+ }
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/config/SystemComponentRuntimeConfiguration.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/config/SystemComponentRuntimeConfiguration.java
new file mode 100644
index 0000000000..cf05059b90
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/config/SystemComponentRuntimeConfiguration.java
@@ -0,0 +1,140 @@
+package org.apache.tuscany.core.system.config;
+
+import java.lang.reflect.Constructor;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.core.builder.ContextCreationException;
+import org.apache.tuscany.core.builder.RuntimeConfiguration;
+import org.apache.tuscany.core.context.AggregateContext;
+import org.apache.tuscany.core.context.InstanceContext;
+import org.apache.tuscany.core.injection.EventInvoker;
+import org.apache.tuscany.core.injection.Injector;
+import org.apache.tuscany.core.injection.PojoObjectFactory;
+import org.apache.tuscany.core.invocation.spi.ProxyFactory;
+import org.apache.tuscany.core.system.context.SystemComponentContext;
+import org.apache.tuscany.model.assembly.Scope;
+
+/**
+ * A RuntimeConfiguration that handles system component implementation types
+ *
+ * @version $Rev$ $Date$
+ */
+public class SystemComponentRuntimeConfiguration implements RuntimeConfiguration<InstanceContext> {
+
+ // the component name as configured in the hosting module
+ private String name;
+
+ // the implementation type constructor
+ private Constructor ctr;
+
+ // injectors for properties, references and other metadata values such as @Context
+ private List<Injector> setters;
+
+ // an invoker for a method decorated with @Init
+ private EventInvoker init;
+
+ // whether the component should be eagerly initialized when its scope starts
+ private boolean eagerInit;
+
+ // an invoker for a method decorated with @Destroy
+ private EventInvoker destroy;
+
+ // the scope of the implementation instance
+ private Scope scope;
+
+ // if the component implementation scope is stateless
+ private boolean stateless;
+
+ // if the component implementation is an aggregate context
+ private boolean isAggregate;
+
+ // ----------------------------------
+ // Constructors
+ // ----------------------------------
+
+ /**
+ * Creates the runtime configuration
+ *
+ * @param name the SCDL name of the component the context refers to
+ * @param ctr the implementation type constructor
+ * @param setters a collection of <code>Injectors</code> used to configure properties, references and other meta
+ * data values on implementation instances
+ * @param eagerInit whether the component should be eagerly initialized
+ * @param init an <code>Invoker</code> pointing to a method on the implementation type decorated with
+ * <code>@Init</code>
+ * @param destroy an <code>Invoker</code> pointing to a method on the implementation type decorated with
+ * <code>@Destroy</code>
+ * @param scope the scope of the component implementation type
+ */
+ public SystemComponentRuntimeConfiguration(String name, Constructor ctr, List<Injector> setters, boolean eagerInit,
+ EventInvoker init, EventInvoker destroy, Scope scope) {
+ assert (name != null) : "Name was null";
+ assert (ctr != null) : "Constructor was null";
+ assert (setters != null) : "Setters were null";
+ this.name = name;
+ this.ctr = ctr;
+ this.isAggregate = AggregateContext.class.isAssignableFrom(ctr.getDeclaringClass());
+ this.setters = setters;
+ this.eagerInit = eagerInit;
+ this.init = init;
+ this.destroy = destroy;
+ this.scope = scope;
+ stateless = (scope == Scope.INSTANCE);
+ }
+
+ // ----------------------------------
+ // Methods
+ // ----------------------------------
+
+ public String getName() {
+ return name;
+ }
+
+ public Scope getScope() {
+ return scope;
+ }
+
+ public InstanceContext createInstanceContext() throws ContextCreationException {
+ if (isAggregate) {
+ // aggregate context types are themselves an instance context
+ PojoObjectFactory objectFactory = new PojoObjectFactory(ctr, null, setters);
+ AggregateContext ctx = (AggregateContext) objectFactory.getInstance();
+ ctx.setName(name);
+ return ctx;
+ } else {
+ PojoObjectFactory objectFactory = new PojoObjectFactory(ctr, null, setters);
+ return new SystemComponentContext(name, objectFactory, eagerInit, init, destroy, stateless);
+ }
+ }
+
+ // -- Proxy
+
+ public void prepare() {
+ }
+
+ public void addTargetProxyFactory(String serviceName, ProxyFactory factory) {
+ throw new UnsupportedOperationException();
+ }
+
+ public ProxyFactory getTargetProxyFactory(String serviceName) {
+ return null;
+ }
+
+ public Map<String, ProxyFactory> getTargetProxyFactories() {
+ return null;
+ }
+
+ public void addSourceProxyFactory(String referenceName, ProxyFactory factory) {
+ throw new UnsupportedOperationException();
+ }
+
+ public ProxyFactory getSourceProxyFactory(String referenceName) {
+ return null;
+ }
+
+ public Map<String, ProxyFactory> getSourceProxyFactories() {
+ return null;
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/config/SystemEntryPointRuntimeConfiguration.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/config/SystemEntryPointRuntimeConfiguration.java
new file mode 100644
index 0000000000..f6c25e9b86
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/config/SystemEntryPointRuntimeConfiguration.java
@@ -0,0 +1,92 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.system.config;
+
+import java.util.Map;
+
+import org.apache.tuscany.core.builder.ContextCreationException;
+import org.apache.tuscany.core.builder.ObjectFactory;
+import org.apache.tuscany.core.builder.RuntimeConfiguration;
+import org.apache.tuscany.core.context.EntryPointContext;
+import org.apache.tuscany.core.invocation.spi.ProxyFactory;
+import org.apache.tuscany.core.system.context.SystemEntryPointContext;
+import org.apache.tuscany.model.assembly.Scope;
+
+/**
+ * Creates {@link SystemEntryPointContext} instances based on an entry point configuration in an assembly model
+ *
+ * @version $Rev$ $Date$
+ */
+public class SystemEntryPointRuntimeConfiguration implements RuntimeConfiguration<EntryPointContext> {
+
+ // the name of the entry point
+ private String name;
+
+ // the factory for returning a reference to the implementation instance of the component exposed by the entry point
+ private ObjectFactory factory;
+
+ // ----------------------------------
+ // Constructors
+ // ----------------------------------
+
+ public SystemEntryPointRuntimeConfiguration(String name, ObjectFactory factory) {
+ this.name = name;
+ this.factory = factory;
+ }
+
+ // ----------------------------------
+ // Methods
+ // ----------------------------------
+
+ public EntryPointContext createInstanceContext() throws ContextCreationException {
+ return new SystemEntryPointContext(name, factory);
+ }
+
+ public Scope getScope() {
+ return Scope.MODULE;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ // -- Proxy
+ public void prepare() {
+ }
+
+ public void addTargetProxyFactory(String serviceName, ProxyFactory pFactory) {
+ throw new UnsupportedOperationException();
+ }
+
+ public ProxyFactory getTargetProxyFactory(String serviceName) {
+ return null;
+ }
+
+ public Map<String, ProxyFactory> getTargetProxyFactories() {
+ return null;
+ }
+
+ public void addSourceProxyFactory(String referenceName, ProxyFactory pFactory) {
+ throw new UnsupportedOperationException();
+ }
+
+ public ProxyFactory getSourceProxyFactory(String referenceName) {
+ return null;
+ }
+
+ public Map<String, ProxyFactory> getSourceProxyFactories() {
+ return null;
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/config/SystemExternalServiceRuntimeConfiguration.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/config/SystemExternalServiceRuntimeConfiguration.java
new file mode 100644
index 0000000000..789982bdcf
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/config/SystemExternalServiceRuntimeConfiguration.java
@@ -0,0 +1,97 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.system.config;
+
+import java.util.Map;
+
+import org.apache.tuscany.core.builder.ContextCreationException;
+import org.apache.tuscany.core.builder.ObjectFactory;
+import org.apache.tuscany.core.builder.RuntimeConfiguration;
+import org.apache.tuscany.core.context.ExternalServiceContext;
+import org.apache.tuscany.core.invocation.spi.ProxyFactory;
+import org.apache.tuscany.core.system.context.SystemExternalServiceContext;
+import org.apache.tuscany.model.assembly.Scope;
+
+/**
+ * Creates system type external service contexts
+ *
+ * @see org.apache.tuscany.core.context.ExternalServiceContext
+ * @see org.apache.tuscany.core.system.context.SystemExternalServiceContext
+ *
+ * @version $Rev$ $Date$
+ */
+public class SystemExternalServiceRuntimeConfiguration implements RuntimeConfiguration<ExternalServiceContext> {
+
+ // the name of the external service
+ private String name;
+
+ // the factory for returning a reference to the implementation instance of the component represented by the external service
+ private ObjectFactory factory;
+
+ // ----------------------------------
+ // Constructors
+ // ----------------------------------
+
+ public SystemExternalServiceRuntimeConfiguration(String name, ObjectFactory factory) {
+ assert (name != null) : "Name was null";
+ assert (factory != null) : "Object factory was null";
+ this.name = name;
+ this.factory = factory;
+ }
+
+ // ----------------------------------
+ // Methods
+ // ----------------------------------
+
+ public Scope getScope() {
+ return Scope.MODULE;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public ExternalServiceContext createInstanceContext() throws ContextCreationException {
+ return new SystemExternalServiceContext(name, factory);
+ }
+
+ // -- Proxy
+ public void prepare() {
+ }
+
+ public void addTargetProxyFactory(String serviceName, ProxyFactory pFactory) {
+ throw new UnsupportedOperationException();
+ }
+
+ public ProxyFactory getTargetProxyFactory(String serviceName) {
+ return null;
+ }
+
+ public Map<String, ProxyFactory> getTargetProxyFactories() {
+ return null;
+ }
+
+ public void addSourceProxyFactory(String referenceName, ProxyFactory pFactory) {
+ throw new UnsupportedOperationException();
+ }
+
+ public ProxyFactory getSourceProxyFactory(String referenceName) {
+ return null;
+ }
+
+ public Map<String, ProxyFactory> getSourceProxyFactories() {
+ return null;
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/config/SystemObjectRuntimeConfiguration.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/config/SystemObjectRuntimeConfiguration.java
new file mode 100644
index 0000000000..06acb12deb
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/config/SystemObjectRuntimeConfiguration.java
@@ -0,0 +1,92 @@
+/**
+ *
+ * Copyright 2005 BEA Systems Inc.
+ * Copyright 2005 International Business Machines Corporation
+ *
+ * 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.core.system.config;
+
+import java.util.Map;
+
+import org.apache.tuscany.core.builder.ContextCreationException;
+import org.apache.tuscany.core.builder.ObjectFactory;
+import org.apache.tuscany.core.builder.RuntimeConfiguration;
+import org.apache.tuscany.core.context.Context;
+import org.apache.tuscany.core.injection.SingletonObjectFactory;
+import org.apache.tuscany.core.invocation.spi.ProxyFactory;
+import org.apache.tuscany.core.system.context.SystemComponentContext;
+import org.apache.tuscany.model.assembly.Scope;
+
+/**
+ * A RuntimeConfiguration that contains the configuration needed to convert a simple
+ * Java Object into a component. The object is assumed to be fully initialized and
+ * will always be added with MODULE scope.
+ *
+ * @version $Rev$ $Date$
+ */
+public class SystemObjectRuntimeConfiguration implements RuntimeConfiguration {
+ private final String name;
+ private final ObjectFactory<?> objectFactory;
+
+ /**
+ * Construct a RuntimeConfiguration for the supplied Java Object.
+ *
+ * @param name the name to be assigned to the resulting component
+ * @param instance the Java Object that provides the implementation
+ */
+ public SystemObjectRuntimeConfiguration(String name, Object instance) {
+ this.name = name;
+ objectFactory = new SingletonObjectFactory(instance);
+ }
+
+ public Context createInstanceContext() throws ContextCreationException {
+ return new SystemComponentContext(name, objectFactory, false, null, null, false);
+ }
+
+ public Scope getScope() {
+ return Scope.MODULE;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void prepare() {
+ throw new UnsupportedOperationException();
+ }
+
+ public void addTargetProxyFactory(String serviceName, ProxyFactory factory) {
+ throw new UnsupportedOperationException();
+ }
+
+ public ProxyFactory getTargetProxyFactory(String serviceName) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Map getTargetProxyFactories() {
+ throw new UnsupportedOperationException();
+ }
+
+ public void addSourceProxyFactory(String referenceName, ProxyFactory factory) {
+ throw new UnsupportedOperationException();
+ }
+
+ public ProxyFactory getSourceProxyFactory(String referenceName) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Map getSourceProxyFactories() {
+ throw new UnsupportedOperationException();
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/context/SystemAggregateContextImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/context/SystemAggregateContextImpl.java
new file mode 100644
index 0000000000..a2efc35ac1
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/context/SystemAggregateContextImpl.java
@@ -0,0 +1,666 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.system.context;
+
+import static org.apache.tuscany.core.context.EventContext.HTTP_SESSION;
+import static org.apache.tuscany.core.context.EventContext.REQUEST_END;
+import static org.apache.tuscany.core.context.EventContext.SESSION_NOTIFY;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.tuscany.common.monitor.MonitorFactory;
+import org.apache.tuscany.core.builder.BuilderConfigException;
+import org.apache.tuscany.core.builder.RuntimeConfiguration;
+import org.apache.tuscany.core.config.ConfigurationException;
+import org.apache.tuscany.core.context.AbstractContext;
+import org.apache.tuscany.core.context.AggregateContext;
+import org.apache.tuscany.core.context.AutowireContext;
+import org.apache.tuscany.core.context.AutowireResolutionException;
+import org.apache.tuscany.core.context.ConfigurationContext;
+import org.apache.tuscany.core.context.ContextInitException;
+import org.apache.tuscany.core.context.CoreRuntimeException;
+import org.apache.tuscany.core.context.DuplicateNameException;
+import org.apache.tuscany.core.context.EntryPointContext;
+import org.apache.tuscany.core.context.EventContext;
+import org.apache.tuscany.core.context.EventException;
+import org.apache.tuscany.core.context.InstanceContext;
+import org.apache.tuscany.core.context.LifecycleEventListener;
+import org.apache.tuscany.core.context.QualifiedName;
+import org.apache.tuscany.core.context.RuntimeEventListener;
+import org.apache.tuscany.core.context.ScopeContext;
+import org.apache.tuscany.core.context.ScopeRuntimeException;
+import org.apache.tuscany.core.context.ScopeStrategy;
+import org.apache.tuscany.core.context.SimpleComponentContext;
+import org.apache.tuscany.core.context.SystemAggregateContext;
+import org.apache.tuscany.core.context.TargetException;
+import org.apache.tuscany.core.context.impl.EventContextImpl;
+import org.apache.tuscany.core.invocation.jdk.JDKProxyFactoryFactory;
+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.message.impl.MessageFactoryImpl;
+import org.apache.tuscany.core.runtime.RuntimeContext;
+import org.apache.tuscany.core.system.annotation.Autowire;
+import org.apache.tuscany.core.system.annotation.ParentContext;
+import org.apache.tuscany.core.system.assembly.SystemBinding;
+import org.apache.tuscany.core.system.config.SystemObjectRuntimeConfiguration;
+import org.apache.tuscany.model.assembly.Aggregate;
+import org.apache.tuscany.model.assembly.Component;
+import org.apache.tuscany.model.assembly.EntryPoint;
+import org.apache.tuscany.model.assembly.Extensible;
+import org.apache.tuscany.model.assembly.ExternalService;
+import org.apache.tuscany.model.assembly.Module;
+import org.apache.tuscany.model.assembly.AggregatePart;
+import org.apache.tuscany.model.assembly.Scope;
+import org.apache.tuscany.model.assembly.impl.AssemblyFactoryImpl;
+
+/**
+ * Implements an aggregate context for system components. By default a system context uses the scopes specified by
+ * {@link org.apache.tuscany.core.system.context.SystemScopeStrategy}. In addition, it implements an autowire policy
+ * where entry points configured with a {@link org.apache.tuscany.core.system.assembly.SystemBinding} are matched
+ * according to their exposed interface. A system context may contain child aggregate contexts but an entry point in a
+ * child context will only be outwardly accessible if there is an entry point that exposes it configured in the
+ * top-level system context.
+ *
+ * @version $Rev$ $Date$
+ */
+public class SystemAggregateContextImpl extends AbstractContext implements SystemAggregateContext {
+
+ public static final int DEFAULT_WAIT = 1000 * 60;
+
+ // ----------------------------------
+ // Fields
+ // ----------------------------------
+
+ // The parent context, if one exists
+ @ParentContext
+ protected AggregateContext parentContext;
+
+ // The parent configuration context, if one exists
+ @Autowire(required = false)
+ protected ConfigurationContext configurationContext;
+
+ // The system monitor factory
+ @Autowire(required = false)
+ protected MonitorFactory monitorFactory;
+
+ // The logical model representing the module assembly
+ // protected ModuleComponent moduleComponent;
+ protected Module module;
+
+ protected List<RuntimeConfiguration<InstanceContext>> configurations = new ArrayList();
+
+ protected ScopeStrategy scopeStrategy;
+
+ // The event context for associating context events to threads
+ protected EventContext eventContext;
+
+ // The scopes for this context
+ protected Map<Scope, ScopeContext> scopeContexts;
+
+ protected Map<Scope, ScopeContext> immutableScopeContexts;
+
+ // A component context name to scope context index
+ protected Map<String, ScopeContext> scopeIndex;
+
+ // Listeners for context events
+ protected List<RuntimeEventListener> listeners = new CopyOnWriteArrayList();
+
+ // Blocking latch to ensure the module is initialized exactly once prior to servicing requests
+ protected CountDownLatch initializeLatch = new CountDownLatch(1);
+
+ // Indicates whether the module context has been initialized
+ protected boolean initialized;
+
+ // a mapping of service type to component name
+ private Map<Class, NameToScope> autowireIndex = new ConcurrentHashMap();
+
+ @Autowire(required = false)
+ private AutowireContext autowireContext;
+
+ // ----------------------------------
+ // Constructors
+ // ----------------------------------
+
+ public SystemAggregateContextImpl() {
+ super();
+ scopeIndex = new ConcurrentHashMap();
+ // FIXME the assembly factory should be injected here
+ module = new AssemblyFactoryImpl().createModule();
+ eventContext = new EventContextImpl();
+ scopeStrategy = new SystemScopeStrategy();
+ }
+
+ public SystemAggregateContextImpl(String name, AggregateContext parent, AutowireContext autowire, ScopeStrategy strategy,
+ EventContext ctx, ConfigurationContext configCtx, MonitorFactory factory) {
+ super(name);
+ this.parentContext = parent;
+ this.autowireContext = autowire;
+ this.scopeStrategy = strategy;
+ this.eventContext = ctx;
+ this.configurationContext = configCtx;
+ this.monitorFactory = factory;
+ scopeIndex = new ConcurrentHashMap();
+ // FIXME the assembly factory should be injected here
+ module = new AssemblyFactoryImpl().createModule();
+ }
+
+ // ----------------------------------
+ // Lifecycle methods
+ // ----------------------------------
+
+ public void start() {
+ synchronized (initializeLatch) {
+ try {
+ if (lifecycleState != UNINITIALIZED && lifecycleState != STOPPED) {
+ throw new IllegalStateException("Context not in UNINITIALIZED state");
+ }
+
+ lifecycleState = INITIALIZING;
+ initializeScopes();
+
+ Map<Scope, List<RuntimeConfiguration<SimpleComponentContext>>> configurationsByScope = new HashMap();
+ if (configurations != null) {
+ for (RuntimeConfiguration config : configurations) {
+ // FIXME scopes are defined at the interface level
+ Scope scope = config.getScope();
+ // ensure duplicate names were not added before the context was started
+ if (scopeIndex.get(config.getName()) != null) {
+ throw new DuplicateNameException(config.getName());
+ }
+ scopeIndex.put(config.getName(), scopeContexts.get(scope));
+ List<RuntimeConfiguration<SimpleComponentContext>> list = configurationsByScope.get(scope);
+ if (list == null) {
+ list = new ArrayList();
+ configurationsByScope.put(scope, list);
+ }
+ list.add(config);
+ }
+ }
+ for (EntryPoint ep : module.getEntryPoints()) {
+ registerAutowire(ep);
+ }
+ for (Component component : module.getComponents()) {
+ registerAutowire(component);
+ }
+ for (ExternalService es : module.getExternalServices()) {
+ registerAutowire(es);
+ }
+ for (Map.Entry entries : configurationsByScope.entrySet()) {
+ // register configurations with scope contexts
+ ScopeContext scope = scopeContexts.get(entries.getKey());
+ scope.registerConfigurations((List<RuntimeConfiguration<InstanceContext>>) entries.getValue());
+ }
+ for (ScopeContext scope : scopeContexts.values()) {
+ // register scope contexts as a listeners for events in the aggregate context
+ registerListener(scope);
+ scope.start();
+ }
+ lifecycleState = RUNNING;
+ } catch (ConfigurationException e) {
+ lifecycleState = ERROR;
+ throw new ContextInitException(e);
+ } catch (CoreRuntimeException e) {
+ lifecycleState = ERROR;
+ e.addContextName(getName());
+ throw e;
+ } finally {
+ initialized = true;
+ // release the latch and allow requests to be processed
+ initializeLatch.countDown();
+ }
+ }
+ }
+
+ public void stop() {
+ if (lifecycleState == STOPPED) {
+ return;
+ }
+ // need to block a start until reset is complete
+ initializeLatch = new CountDownLatch(2);
+ lifecycleState = STOPPING;
+ initialized = false;
+ if (scopeContexts != null) {
+ for (ScopeContext scope : scopeContexts.values()) {
+ try {
+ if (scope.getLifecycleState() == ScopeContext.RUNNING) {
+ scope.stop();
+ }
+ } catch (ScopeRuntimeException e) {
+ // log.error("Error stopping scope container [" + scopeContainers[i].getName() + "]", e);
+ }
+ }
+ }
+ scopeContexts = null;
+ scopeIndex.clear();
+ // allow initialized to be called
+ initializeLatch.countDown();
+ lifecycleState = STOPPED;
+ }
+
+ // ----------------------------------
+ // Methods
+ // ----------------------------------
+
+ public void setModule(Module module) {
+ assert (module != null) : "Module cannot be null";
+ name = module.getName();
+ this.module = module;
+ }
+
+ public void addContextListener(LifecycleEventListener listener) {
+ super.addContextListener(listener);
+ }
+
+ public void setEventContext(EventContext eventContext) {
+ this.eventContext = eventContext;
+ }
+
+ public void setMonitorFactory(MonitorFactory factory) {
+ this.monitorFactory = factory;
+ }
+
+ public AggregateContext getParent() {
+ return parentContext;
+ }
+
+ public void registerModelObjects(List<Extensible> models) throws ConfigurationException {
+ assert (models != null) : "Model object collection was null";
+ for (Extensible model : models) {
+ registerModelObject(model);
+ }
+ }
+
+ public void registerModelObject(Extensible model) throws ConfigurationException {
+ assert (model != null) : "Model object was null";
+ initializeScopes();
+ if (configurationContext != null) {
+ try {
+ configurationContext.configure(model);
+ configurationContext.build(this, model);
+ } catch (ConfigurationException e) {
+ e.addContextName(getName());
+ throw e;
+ } catch (BuilderConfigException e) {
+ e.addContextName(getName());
+ throw e;
+ }
+ }
+ RuntimeConfiguration<InstanceContext> configuration = null;
+ if (model instanceof Module) {
+ // merge new module definition with the existing one
+ Module oldModule = module;
+ Module newModule = (Module) model;
+ module = newModule;
+ for (Component component : newModule.getComponents()) {
+ configuration = (RuntimeConfiguration<InstanceContext>) component.getComponentImplementation()
+ .getRuntimeConfiguration();
+ if (configuration == null) {
+ ConfigurationException e = new ConfigurationException("Runtime configuration not set");
+ e.addContextName(component.getName());
+ e.addContextName(getName());
+ throw e;
+ }
+ registerConfiguration(configuration);
+ registerAutowire(component);
+ }
+ for (EntryPoint ep : newModule.getEntryPoints()) {
+ configuration = (RuntimeConfiguration<InstanceContext>) ep.getConfiguredReference().getRuntimeConfiguration();
+ if (configuration == null) {
+ ConfigurationException e = new ConfigurationException("Runtime configuration not set");
+ e.setIdentifier(ep.getName());
+ e.addContextName(getName());
+ throw e;
+ }
+ registerConfiguration(configuration);
+ registerAutowire(ep);
+ }
+ for (ExternalService service : newModule.getExternalServices()) {
+ configuration = (RuntimeConfiguration<InstanceContext>) service.getConfiguredService().getRuntimeConfiguration();
+ if (configuration == null) {
+ ConfigurationException e = new ConfigurationException("Runtime configuration not set");
+ e.setIdentifier(service.getName());
+ e.addContextName(getName());
+ throw e;
+ }
+ registerConfiguration(configuration);
+ registerAutowire(service);
+ }
+ // merge existing module component assets
+ module.getComponents().addAll(oldModule.getComponents());
+ module.getEntryPoints().addAll(oldModule.getEntryPoints());
+ module.getExternalServices().addAll(oldModule.getExternalServices());
+ } else {
+ if (model instanceof Component) {
+ Component component = (Component) model;
+ module.getComponents().add(component);
+ configuration = (RuntimeConfiguration<InstanceContext>) component.getComponentImplementation()
+ .getRuntimeConfiguration();
+ } else if (model instanceof EntryPoint) {
+ EntryPoint ep = (EntryPoint) model;
+ module.getEntryPoints().add(ep);
+ configuration = (RuntimeConfiguration<InstanceContext>) ep.getConfiguredReference().getRuntimeConfiguration();
+ } else if (model instanceof ExternalService) {
+ ExternalService service = (ExternalService) model;
+ module.getExternalServices().add(service);
+ configuration = (RuntimeConfiguration<InstanceContext>) service.getConfiguredService().getRuntimeConfiguration();
+ } else {
+ BuilderConfigException e = new BuilderConfigException("Unknown model type");
+ e.setIdentifier(model.getClass().getName());
+ e.addContextName(getName());
+ throw e;
+ }
+ if (configuration == null) {
+ ConfigurationException e = new ConfigurationException(
+ "Runtime configuration not set. Ensure a runtime configuration builder is registered for the component implementation type");
+ if (model instanceof AggregatePart) {
+ e.setIdentifier(((AggregatePart) model).getName());
+ }
+ e.addContextName(getName());
+ throw e;
+ }
+ registerConfiguration(configuration);
+ registerAutowire(model);
+ }
+ }
+
+ public void registerJavaObject(String componentName, Object instance) throws ConfigurationException {
+ registerConfiguration(new SystemObjectRuntimeConfiguration(componentName, instance));
+ }
+
+ protected void registerConfiguration(RuntimeConfiguration<InstanceContext> configuration) throws ConfigurationException {
+ if (lifecycleState == RUNNING) {
+ if (scopeIndex.get(configuration.getName()) != null) {
+ throw new DuplicateNameException(configuration.getName());
+ }
+ ScopeContext scope = scopeContexts.get(configuration.getScope());
+ if (scope == null) {
+ ConfigurationException e = new ConfigurationException("Component has an unknown scope");
+ e.addContextName(configuration.getName());
+ e.addContextName(getName());
+ throw e;
+ }
+ scope.registerConfiguration(configuration);
+ scopeIndex.put(configuration.getName(), scope);
+ } else {
+ configurations.add(configuration);
+ }
+
+ }
+
+ public void registerListener(RuntimeEventListener listener) {
+ assert (listener != null) : "Listener cannot be null";
+ listeners.add(listener);
+ }
+
+ public void fireEvent(int eventType, Object message) throws EventException {
+ checkInit();
+ if (eventType == SESSION_NOTIFY) {
+ // update context
+ eventContext.setIdentifier(HTTP_SESSION, message);
+ } else if (eventType == REQUEST_END) {
+ // be very careful with pooled threads, ensuring threadlocals are cleaned up
+ eventContext.clearIdentifier(HTTP_SESSION);
+ }
+ for (RuntimeEventListener listener : listeners) {
+ listener.onEvent(eventType, message);
+ }
+ }
+
+ public InstanceContext getContext(String componentName) {
+ checkInit();
+ assert (componentName != null) : "Name was null";
+ ScopeContext scope = scopeIndex.get(componentName);
+ if (scope == null) {
+ return null;
+ }
+ return scope.getContext(componentName);
+
+ }
+
+ /**
+ * @see org.apache.tuscany.core.context.AggregateContext#getAggregate()
+ */
+ public Aggregate getAggregate() {
+ return module;
+ }
+
+ public Object getInstance(QualifiedName qName) throws TargetException {
+ return getInstance(qName, true);
+ }
+
+ public Object getInstance(QualifiedName qName, boolean notify) throws TargetException {
+ assert (qName != null) : "Name was null ";
+ // use the port name to get the context since entry points ports
+ ScopeContext scope = scopeIndex.get(qName.getPortName());
+ if (scope == null) {
+ return null;
+ }
+ InstanceContext ctx = scope.getContext(qName.getPortName());
+ if (!(ctx instanceof EntryPointContext)) {
+ TargetException e = new TargetException("Target not an entry point");
+ e.setIdentifier(qName.getQualifiedName());
+ e.addContextName(name);
+ throw e;
+ }
+ return ctx.getInstance(null, notify);
+ }
+
+ public Object locateInstance(String qualifiedName) throws TargetException {
+ checkInit();
+ QualifiedName qName = new QualifiedName(qualifiedName);
+ ScopeContext scope = scopeIndex.get(qName.getPartName());
+ if (scope == null) {
+ TargetException e = new TargetException("Component not found");
+ e.setIdentifier(qualifiedName);
+ e.addContextName(getName());
+ throw e;
+ }
+ InstanceContext ctx = scope.getContext(qName.getPartName());
+ try {
+ return ctx.getInstance(qName, true);
+ } catch (TargetException e) {
+ e.addContextName(getName());
+ throw e;
+ }
+ }
+
+ // ----------------------------------
+ // InstanceContext methods
+ // ----------------------------------
+
+ public Object getImplementationInstance() throws TargetException {
+ return this;
+ }
+
+ public Object getImplementationInstance(boolean notify) throws TargetException {
+ return this;
+ }
+
+ public Map<Scope, ScopeContext> getScopeContexts() {
+ initializeScopes();
+ return immutableScopeContexts;
+ }
+
+ // ----------------------------------
+ // Protected methods
+ // ----------------------------------
+
+ /**
+ * Blocks until the module context has been initialized
+ */
+ protected void checkInit() {
+ if (!initialized) {
+ try {
+ /* block until the module has initialized */
+ boolean success = initializeLatch.await(DEFAULT_WAIT, TimeUnit.MILLISECONDS);
+ if (!success) {
+ throw new ContextInitException("Timeout waiting for module context to initialize");
+ }
+ } catch (InterruptedException e) { // should not happen
+ }
+ }
+
+ }
+
+ protected void initializeScopes() {
+ if (scopeContexts == null) {
+ scopeContexts = scopeStrategy.createScopes(eventContext);
+ immutableScopeContexts = Collections.unmodifiableMap(scopeContexts);
+ }
+ }
+
+ // ////////////////////////////
+
+ // ----------------------------------
+ // AutowireContext methods
+ // ----------------------------------
+
+ // FIXME These should be removed and configured
+ private static final MessageFactory messageFactory = new MessageFactoryImpl();
+
+ private static final ProxyFactoryFactory proxyFactoryFactory = new JDKProxyFactoryFactory();
+
+ public <T> T resolveInstance(Class<T> instanceInterface) throws AutowireResolutionException {
+ if (RuntimeContext.class.equals(instanceInterface)) {
+ return autowireContext.resolveInstance(instanceInterface);
+ } else if (MonitorFactory.class.equals(instanceInterface)) {
+ return instanceInterface.cast(monitorFactory);
+ } else if (ConfigurationContext.class.equals(instanceInterface)) {
+ return instanceInterface.cast(this);
+ } else if (AggregateContext.class.equals(instanceInterface)) {
+ return instanceInterface.cast(this);
+ } else if (AutowireContext.class.equals(instanceInterface)) {
+ return instanceInterface.cast(this);
+ } else if (MessageFactory.class.equals(instanceInterface)) {
+ return instanceInterface.cast(messageFactory);
+ } else if (ProxyFactoryFactory.class.equals(instanceInterface)) {
+ return instanceInterface.cast(proxyFactoryFactory);
+ }
+
+ NameToScope mapping = autowireIndex.get(instanceInterface);
+ if (mapping != null) {
+ try {
+ return instanceInterface.cast(mapping.getScopeContext().getInstance(mapping.getName()));
+ } catch (TargetException e) {
+ AutowireResolutionException ae = new AutowireResolutionException("Autowire instance not found", e);
+ ae.addContextName(getName());
+ throw ae;
+ }
+ }
+ return null;
+ }
+
+ private void registerAutowire(Extensible model) throws ConfigurationException {
+ if (lifecycleState == INITIALIZING || lifecycleState == INITIALIZED || lifecycleState == RUNNING) {
+ // only autowire entry points with system bindings
+ if (model instanceof EntryPoint) {
+ EntryPoint ep = (EntryPoint) model;
+ if (ep.getBindings() != null) {
+ if (ep.getBindings().get(0) instanceof SystemBinding) {
+ ScopeContext scope = scopeContexts.get(((RuntimeConfiguration) ep.getConfiguredReference()
+ .getRuntimeConfiguration()).getScope());
+ if (scope == null) {
+ ConfigurationException ce = new ConfigurationException("Scope not found for entry point");
+ ce.setIdentifier(ep.getName());
+ ce.addContextName(getName());
+ throw ce;
+ }
+ NameToScope mapping = new NameToScope(new QualifiedName(ep.getName()), scope);
+ autowireIndex.put(ep.getConfiguredService().getService().getServiceContract().getInterface(), mapping);
+ }
+ }
+ }
+ }
+ }
+
+ // ----------------------------------
+ // ConfigurationContext methods
+ // ----------------------------------
+
+ public void configure(Extensible model) throws ConfigurationException {
+ if (configurationContext != null) {
+ configurationContext.configure(model);
+ }
+ }
+
+ public void build(AggregateContext parent, Extensible model) throws BuilderConfigException {
+ if (configurationContext != null) {
+ configurationContext.build(parent, model);
+ }
+ }
+
+ public void wire(ProxyFactory sourceFactory, ProxyFactory targetFactory, Class targetType, boolean downScope,
+ ScopeContext targetScopeContext) throws BuilderConfigException {
+ if (configurationContext != null) {
+ try {
+ configurationContext.wire(sourceFactory, targetFactory, targetType, downScope, targetScopeContext);
+ } catch (BuilderConfigException e) {
+ e.addContextName(getName());
+ throw e;
+ }
+ }
+ }
+
+ public void wire(ProxyFactory targetFactory, Class targetType, ScopeContext targetScopeContext) throws BuilderConfigException {
+ if (configurationContext != null) {
+ try {
+ configurationContext.wire(targetFactory, targetType, targetScopeContext);
+ } catch (BuilderConfigException e) {
+ e.addContextName(getName());
+ throw e;
+ }
+ }
+ }
+
+ // ----------------------------------
+ // Inner classes
+ // ----------------------------------
+
+ /**
+ * Maps a context name to a scope
+ */
+ private class NameToScope {
+
+ private QualifiedName epName;
+
+ private ScopeContext scope;
+
+ public NameToScope(QualifiedName epName, ScopeContext scope) {
+ this.epName = epName;
+ this.scope = scope;
+ }
+
+ public QualifiedName getName() {
+ return epName;
+ }
+
+ public ScopeContext getScopeContext() {
+ return scope;
+ }
+
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/context/SystemComponentContext.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/context/SystemComponentContext.java
new file mode 100644
index 0000000000..4418f52e19
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/context/SystemComponentContext.java
@@ -0,0 +1,198 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.system.context;
+
+import java.util.Iterator;
+
+import org.apache.tuscany.core.builder.ObjectFactory;
+import org.apache.tuscany.core.context.AbstractContext;
+import org.apache.tuscany.core.context.Context;
+import org.apache.tuscany.core.context.ContextInitException;
+import org.apache.tuscany.core.context.LifecycleEventListener;
+import org.apache.tuscany.core.context.QualifiedName;
+import org.apache.tuscany.core.context.SimpleComponentContext;
+import org.apache.tuscany.core.context.TargetException;
+import org.apache.tuscany.core.injection.EventInvoker;
+import org.apache.tuscany.core.injection.Injector;
+import org.apache.tuscany.core.injection.ObjectCallbackException;
+import org.apache.tuscany.core.injection.ObjectCreationException;
+
+/**
+ * Manages system component implementation instances
+ *
+ * @version $Rev$ $Date$
+ */
+public class SystemComponentContext extends AbstractContext implements SimpleComponentContext {
+
+ private boolean eagerInit;
+
+ private EventInvoker initInvoker;
+
+ private EventInvoker destroyInvoker;
+
+ private Injector componentName;
+
+ private Injector moduleContext;
+
+ private boolean stateless;
+
+ // the cached target instance
+ private Object cachedTargetInstance;
+
+ // responsible for creating a new implementation instance with injected references and properties
+ private ObjectFactory objectFactory;
+
+ // ----------------------------------
+ // Constructors
+ // ----------------------------------
+
+ public SystemComponentContext(String name, ObjectFactory objectFactory, boolean eagerInit, EventInvoker initInvoker,
+ EventInvoker destroyInvoker, boolean stateless) {
+ super(name);
+ assert (objectFactory != null) : "Object factory was null";
+ if (eagerInit == true && initInvoker == null) {
+ throw new AssertionError("No intialization method found for eager init implementation");
+ }
+ this.objectFactory = objectFactory;
+
+ this.eagerInit = eagerInit;
+ this.initInvoker = initInvoker;
+ this.destroyInvoker = destroyInvoker;
+ this.stateless = stateless;
+ }
+
+ // ----------------------------------
+ // Methods
+ // ----------------------------------
+
+ public void setName(String name) {
+ super.setName(name);
+ }
+
+ protected int type;
+
+ public int getType() {
+ return type;
+ }
+
+ public void setType(int type) {
+ this.type = type;
+ }
+
+ public synchronized Object getInstance(QualifiedName qName) throws TargetException {
+ return getInstance(qName, true);
+ }
+
+ public synchronized Object getInstance(QualifiedName qName, boolean notify) throws TargetException {
+ if (cachedTargetInstance != null) {
+ return cachedTargetInstance; // already cached, just return
+ }
+
+ if (getLifecycleState() == ERROR || getLifecycleState() == CONFIG_ERROR) {
+ return null;
+ }
+ synchronized (this) {
+ try {
+ Object instance = objectFactory.getInstance();
+ startInstance(instance);
+ if (notify) {
+ for (Iterator iter = contextListener.iterator(); iter.hasNext();) {
+ LifecycleEventListener listener = (LifecycleEventListener) iter.next();
+ listener.onInstanceCreate(this);
+ }
+ }
+ setLifecycleState(RUNNING);
+ if (stateless) {
+ return instance;
+ } else {
+ // cache the actual instance
+ cachedTargetInstance = instance;
+ return cachedTargetInstance;
+ }
+ } catch (ObjectCreationException e) {
+ setLifecycleState(Context.ERROR);
+ TargetException te = new TargetException("Error creating instance for component", e);
+ te.setIdentifier(getName());
+ throw te;
+ }
+ }
+
+ }
+
+ public Object getImplementationInstance() throws TargetException {
+ return getInstance(null);
+ }
+
+ public Object getImplementationInstance(boolean notify) throws TargetException {
+ return getInstance(null, notify);
+ }
+
+ public boolean isEagerInit() {
+ return eagerInit;
+ }
+
+ public boolean isDestroyable() {
+ return (destroyInvoker != null);
+ }
+
+ // ----------------------------------
+ // Lifecycle methods
+ // ----------------------------------
+
+ public void start() throws ContextInitException {
+ if (getLifecycleState() != UNINITIALIZED && getLifecycleState() != STOPPED) {
+ throw new IllegalStateException("Component must be in UNINITIALIZED state [" + getLifecycleState() + "]");
+ }
+ if (objectFactory == null) {
+ setLifecycleState(ERROR);
+ ContextInitException e = new ContextInitException("Object factory not found ");
+ e.setIdentifier(getName());
+ throw e;
+ }
+ setLifecycleState(INITIALIZED);
+ }
+
+ public void stop() {
+ if (cachedTargetInstance != null) {
+ if (destroyInvoker != null) {
+ try {
+ destroyInvoker.invokeEvent(cachedTargetInstance);
+ } catch (ObjectCallbackException e) {
+ throw new TargetException(e.getCause());
+ }
+ }
+ }
+ setLifecycleState(STOPPED);
+ }
+
+ // ----------------------------------
+ // Private methods
+ // ----------------------------------
+ private void startInstance(Object instance) throws TargetException {
+ try {
+ // handle @Init
+ if (initInvoker != null) {
+ initInvoker.invokeEvent(instance);
+ }
+ } catch (ObjectCallbackException e) {
+ TargetException te = new TargetException("Error initializing instance", e);
+ te.setIdentifier(getName());
+ throw te;
+ }
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/context/SystemEntryPointContext.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/context/SystemEntryPointContext.java
new file mode 100644
index 0000000000..5533424334
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/context/SystemEntryPointContext.java
@@ -0,0 +1,82 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.system.context;
+
+import org.apache.tuscany.core.builder.ObjectFactory;
+import org.apache.tuscany.core.context.AbstractContext;
+import org.apache.tuscany.core.context.QualifiedName;
+import org.apache.tuscany.core.context.CoreRuntimeException;
+import org.apache.tuscany.core.context.EntryPointContext;
+import org.apache.tuscany.core.context.TargetException;
+
+/**
+ * Manages an entry point into a system module. System entry points cache a direct (i.e. non-proxied) reference to a
+ * component instance.
+ *
+ * @version $Rev$ $Date$
+ */
+public class SystemEntryPointContext extends AbstractContext implements EntryPointContext {
+
+ // responsible for resolving the component implementation instance exposed by the entry point
+ private ObjectFactory factory;
+
+ // a reference to the component's implementation instance exposed by the entry point
+ private Object cachedInstance;
+
+ // ----------------------------------
+ // Constructors
+ // ----------------------------------
+
+ public SystemEntryPointContext(String name, ObjectFactory factory) {
+ super(name);
+ assert (factory != null) : "Object factory was null";
+ this.factory = factory;
+ }
+
+ // ----------------------------------
+ // Methods
+ // ----------------------------------
+
+ public Object getInstance(QualifiedName qName) throws TargetException {
+ return getInstance(qName, true);
+ }
+
+ public Object getInstance(QualifiedName qName, boolean notify) throws TargetException {
+ try {
+ if (cachedInstance == null) {
+ cachedInstance = factory.getInstance();
+ }
+ return cachedInstance;
+ } catch (TargetException e) {
+ e.addContextName(getName());
+ throw e;
+ }
+ }
+
+ public void start() throws CoreRuntimeException {
+ lifecycleState = RUNNING;
+ }
+
+ public void stop() throws CoreRuntimeException {
+ lifecycleState = STOPPED;
+ }
+
+ public Object getImplementationInstance() throws TargetException{
+ return getInstance(null);
+ }
+
+ public Object getImplementationInstance(boolean notify) throws TargetException{
+ return getInstance(null,notify);
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/context/SystemExternalServiceContext.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/context/SystemExternalServiceContext.java
new file mode 100644
index 0000000000..9b09cea082
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/context/SystemExternalServiceContext.java
@@ -0,0 +1,82 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.system.context;
+
+import org.apache.tuscany.core.builder.ObjectFactory;
+import org.apache.tuscany.core.context.AbstractContext;
+import org.apache.tuscany.core.context.ExternalServiceContext;
+import org.apache.tuscany.core.context.QualifiedName;
+import org.apache.tuscany.core.context.TargetException;
+
+/**
+ * An implementation of an external service for system wiring. As system components are not proxied and the system
+ * binding is by-reference, the implementation caches a reference to its configured target.
+ *
+ * @version $Rev$ $Date$
+ */
+public class SystemExternalServiceContext extends AbstractContext implements ExternalServiceContext {
+
+ // a factory for retrieving the target of the external service wire
+ private ObjectFactory factory;
+
+ // the cached target
+ private Object cachedInstance;
+
+ // ----------------------------------
+ // Constructors
+ // ----------------------------------
+
+ public SystemExternalServiceContext(String name, ObjectFactory factory) {
+ super(name);
+ assert (factory != null) : "Object factory was null";
+ this.factory = factory;
+ }
+
+ // ----------------------------------
+ // Methods
+ // ----------------------------------
+
+ public Object getInstance(QualifiedName qName) throws TargetException {
+ return getInstance(qName, false);
+ }
+
+ public Object getInstance(QualifiedName qName, boolean notify) throws TargetException {
+ try {
+ if (cachedInstance == null) {
+ cachedInstance = factory.getInstance();
+ }
+ return cachedInstance;
+ } catch (TargetException e) {
+ e.addContextName(getName());
+ throw e;
+ }
+
+ }
+
+ public void start() {
+ lifecycleState = RUNNING;
+ }
+
+ public void stop() {
+ lifecycleState = STOPPED;
+ }
+
+ public Object getImplementationInstance() throws TargetException {
+ return this;
+ }
+
+ public Object getImplementationInstance(boolean notify) throws TargetException {
+ return this;
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/context/SystemScopeStrategy.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/context/SystemScopeStrategy.java
new file mode 100644
index 0000000000..0dbd75da19
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/context/SystemScopeStrategy.java
@@ -0,0 +1,56 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.system.context;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.core.context.EventContext;
+import org.apache.tuscany.core.context.ScopeContext;
+import org.apache.tuscany.core.context.scope.AbstractScopeStrategy;
+import org.apache.tuscany.core.context.scope.AggregateScopeContext;
+import org.apache.tuscany.core.context.scope.ModuleScopeContext;
+import org.apache.tuscany.core.context.scope.StatelessScopeContext;
+import org.apache.tuscany.model.assembly.Scope;
+
+/**
+ * Implements a {@link org.apache.tuscany.core.context.ScopeStrategy} for a system aggregate context with the following scopes:
+ * <ul>
+ * <li>{@link org.apache.tuscany.model.assembly.Scope#AGGREGATE</li>
+ * <li>{@link org.apache.tuscany.model.assembly.Scope#MODULE</li>
+ * <li>{@link org.apache.tuscany.model.assembly.Scope#INSTANCE</li>
+ * </ul>
+ *
+ * @version $Rev$ $Date$
+ */
+public class SystemScopeStrategy extends AbstractScopeStrategy {
+
+ public SystemScopeStrategy() {
+ }
+
+ public Map<Scope, ScopeContext> createScopes(EventContext eventContext) {
+ ScopeContext aggregrateScope = new AggregateScopeContext(eventContext);
+ ScopeContext moduleScoper = new ModuleScopeContext(eventContext);
+ ScopeContext statelessScope = new StatelessScopeContext(eventContext);
+ Map<Scope, ScopeContext> scopes = new HashMap();
+ scopes.put(Scope.AGGREGATE, aggregrateScope);
+ scopes.put(Scope.MODULE, moduleScoper);
+ scopes.put(Scope.INSTANCE, statelessScope);
+ return scopes;
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/injection/AutowireFactory.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/injection/AutowireFactory.java
new file mode 100644
index 0000000000..3bde49dbbe
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/injection/AutowireFactory.java
@@ -0,0 +1,50 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.system.injection;
+
+import org.apache.tuscany.core.builder.ObjectFactory;
+import org.apache.tuscany.core.context.AggregateContext;
+import org.apache.tuscany.core.context.AutowireContext;
+import org.apache.tuscany.core.injection.FactoryInitException;
+import org.apache.tuscany.core.injection.ObjectCreationException;
+
+/**
+ * Implementation of ObjectFactory that returns an instance by resolving against an AutowireContext.
+ *
+ * @version $Rev$ $Date$
+ */
+public class AutowireFactory<T> implements ObjectFactory<T> {
+
+ private AutowireContext autoWireContext;
+
+ private Class<T> implementationType;
+
+ /**
+ * Constructor specifying the context to wire against and the type of service required.
+ *
+ * @param implementationType the type of service required
+ * @param autoWireContext the context to wire against
+ */
+ public AutowireFactory(Class<T> implementationType, AutowireContext autoWireContext) {
+ assert (implementationType != null) : "Implementation type was null";
+ assert (autoWireContext != null) : "Autowire context was null";
+ this.implementationType = implementationType;
+ this.autoWireContext = autoWireContext;
+ }
+
+ public T getInstance() throws ObjectCreationException {
+ // todo what about required? should this just return null?
+ return autoWireContext.resolveInstance(implementationType);
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/loader/SystemSCDLModelLoader.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/loader/SystemSCDLModelLoader.java
new file mode 100644
index 0000000000..f49efe3ebc
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/loader/SystemSCDLModelLoader.java
@@ -0,0 +1,49 @@
+package org.apache.tuscany.core.system.loader;
+
+import org.apache.tuscany.core.system.assembly.SystemAssemblyFactory;
+import org.apache.tuscany.core.system.assembly.impl.SystemAssemblyFactoryImpl;
+import org.apache.tuscany.core.system.scdl.ScdlFactory;
+import org.apache.tuscany.core.system.scdl.SystemImplementation;
+import org.apache.tuscany.model.assembly.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.AssemblyModelObject;
+import org.apache.tuscany.model.scdl.loader.SCDLModelLoader;
+import org.apache.tuscany.sdo.util.SDOUtil;
+
+/**
+ * Populates the assembly model from an SCDL model
+ */
+public class SystemSCDLModelLoader implements SCDLModelLoader {
+
+ private SystemAssemblyFactory systemFactory;
+
+ static {
+ // Register the system SCDL model
+ SDOUtil.registerStaticTypes(ScdlFactory.class);
+ }
+
+ /**
+ * Constructs a new JavaSCDLModelLoader.
+ */
+ public SystemSCDLModelLoader() {
+ this.systemFactory=new SystemAssemblyFactoryImpl();
+ }
+
+ /**
+ * @see org.apache.tuscany.model.scdl.loader.SCDLModelLoader#load(org.apache.tuscany.model.assembly.AssemblyModelContext, java.lang.Object)
+ */
+ public AssemblyModelObject load(AssemblyModelContext modelContext, Object object) {
+ if (object instanceof SystemImplementation) {
+ SystemImplementation scdlImplementation=(SystemImplementation)object;
+ org.apache.tuscany.core.system.assembly.SystemImplementation implementation=systemFactory.createSystemImplementation();
+ Class implementationClass;
+ try {
+ implementationClass=modelContext.getSystemResourceLoader().loadClass(scdlImplementation.getClass_());
+ } catch (ClassNotFoundException e) {
+ throw new IllegalArgumentException(e);
+ }
+ implementation.setImplementationClass(implementationClass);
+ return implementation;
+ } else
+ return null;
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/webapp/ContextBinder.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/webapp/ContextBinder.java
new file mode 100644
index 0000000000..690d03ac36
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/webapp/ContextBinder.java
@@ -0,0 +1,39 @@
+/**
+ *
+ * Copyright 2005 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.core.webapp;
+
+import org.osoa.sca.SCA;
+import org.osoa.sca.ModuleContext;
+
+/**
+ * @version $Rev$ $Date$
+ */
+class ContextBinder extends SCA {
+ static final ContextBinder BINDER = new ContextBinder();
+
+ public void setContext(ModuleContext context) {
+ setModuleContext(context);
+ }
+
+ public void start() {
+ throw new AssertionError();
+ }
+
+ public void stop() {
+ throw new AssertionError();
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/webapp/TuscanyRequestFilter.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/webapp/TuscanyRequestFilter.java
new file mode 100644
index 0000000000..b72c546bf6
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/webapp/TuscanyRequestFilter.java
@@ -0,0 +1,97 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.webapp;
+
+import java.io.IOException;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+
+import org.osoa.sca.ModuleContext;
+import org.osoa.sca.CurrentModuleContext;
+
+import org.apache.tuscany.core.context.AggregateContext;
+import org.apache.tuscany.core.context.EventContext;
+import org.apache.tuscany.core.context.webapp.LazyHTTPSessionId;
+
+/**
+ * Notifies the {@link org.apache.tuscany.core.context.AggregateContext} of web request start and end events as well as setting up the
+ * current session context. The latter is done using lazy Servlet-based session retrieval. The filter fires a session
+ * start event, passing a <tt>LazyServletSessionId</tt> as the session id. The <tt>LazyServletSessionId</tt> is a
+ * wrapper for the servlet request which may be called by the <tt>ModuleContext</tt> to retrieve the session id
+ * lazily.
+ *
+ * @version $Rev: 379957 $ $Date: 2006-02-22 14:58:24 -0800 (Wed, 22 Feb 2006) $
+ */
+public class TuscanyRequestFilter implements Filter {
+ private AggregateContext moduleContext;
+
+ public TuscanyRequestFilter() {
+ }
+
+ public void init(FilterConfig filterConfig) throws ServletException {
+ ServletContext servletContext = filterConfig.getServletContext();
+ moduleContext = (AggregateContext) servletContext.getAttribute(TuscanyServletListener.MODULE_COMPONENT_NAME);
+ }
+
+ public void destroy() {
+ }
+
+ public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws ServletException, IOException {
+ ModuleContext oldContext = CurrentModuleContext.getContext();
+ try {
+ // Set the current module context
+ ContextBinder.BINDER.setContext((ModuleContext) moduleContext);
+
+ // Handle a request
+ if (request instanceof HttpServletRequest) {
+ if (((HttpServletRequest) request).getSession(false) != null) {
+
+ // A session is already active
+ moduleContext.fireEvent(EventContext.SESSION_NOTIFY, ((HttpServletRequest) request).getSession(true));
+ } else {
+ // Create a lazy wrapper since a session is not yet active
+ moduleContext.fireEvent(EventContext.SESSION_NOTIFY, new LazyHTTPSessionId((HttpServletRequest) request));
+ }
+ } else {
+ moduleContext.fireEvent(EventContext.SESSION_NOTIFY, request);
+ }
+ // Start processing the request
+ moduleContext.fireEvent(EventContext.REQUEST_START, request);
+ // Dispatch to the next filter
+ filterChain.doFilter(request, response);
+ } catch (Exception e) {
+ throw new ServletException(e);
+
+ } finally {
+ try {
+ // End processing the request
+ moduleContext.fireEvent(EventContext.REQUEST_END, request);
+ } catch (Exception e) {
+ throw new ServletException(e);
+ }
+ ContextBinder.BINDER.setContext(oldContext);
+ }
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/webapp/TuscanyServletListener.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/webapp/TuscanyServletListener.java
new file mode 100644
index 0000000000..56b4b52495
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/webapp/TuscanyServletListener.java
@@ -0,0 +1,168 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.webapp;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+import javax.servlet.http.HttpSessionEvent;
+import javax.servlet.http.HttpSessionListener;
+
+import org.osoa.sca.CurrentModuleContext;
+import org.osoa.sca.ModuleContext;
+
+import org.apache.tuscany.common.monitor.MonitorFactory;
+import org.apache.tuscany.common.monitor.impl.NullMonitorFactory;
+import org.apache.tuscany.common.resource.ResourceLoader;
+import org.apache.tuscany.common.resource.impl.ResourceLoaderImpl;
+import org.apache.tuscany.core.builder.RuntimeConfigurationBuilder;
+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.config.impl.ModuleComponentConfigurationLoaderImpl;
+import org.apache.tuscany.core.context.AggregateContext;
+import org.apache.tuscany.core.context.EventContext;
+import org.apache.tuscany.core.runtime.RuntimeContext;
+import org.apache.tuscany.core.runtime.RuntimeContextImpl;
+import org.apache.tuscany.core.system.builder.SystemComponentContextBuilder;
+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.AssemblyFactoryImpl;
+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;
+
+/**
+ * ServletContextListener that can be added to a standard web application to boot
+ * a Tuscany runtime inside that application. All implementation classes should
+ * be located in the web application itself.
+ *
+ * @version $Rev: 380792 $ $Date: 2006-02-24 11:25:11 -0800 (Fri, 24 Feb 2006) $
+ */
+public class TuscanyServletListener implements ServletContextListener, HttpSessionListener {
+ public static final String SCA_COMPONENT_NAME = "org.apache.tuscany.core.webapp.ModuleComponentName";
+ public static final String MODULE_COMPONENT_NAME = "org.apache.tuscany.core.webapp.ModuleComponentContext";
+ public static final String TUSCANY_RUNTIME_NAME = RuntimeContext.class.getName();
+
+ private final Object sessionKey = new Object();
+
+ private RuntimeContext runtimeContext;
+ private AggregateContext systemModuleComponentContext;
+ private AggregateContext moduleContext;
+
+ private static final String SYSTEM_MODULE_COMPONENT = "org.apache.tuscany.core.system";
+
+ public void contextInitialized(ServletContextEvent servletContextEvent) {
+ ServletContext servletContext = servletContextEvent.getServletContext();
+ String name = servletContext.getInitParameter(SCA_COMPONENT_NAME);
+ String uri = name; // todo get from context path
+ MonitorFactory monitorFactory = new NullMonitorFactory(); // todo have one that writes to the servlet log
+
+ try {
+ bootRuntime(name, uri, monitorFactory);
+ } catch (ConfigurationException e) {
+ throw new RuntimeException(e.getMessage(), e);
+ }
+
+ servletContext.setAttribute(TUSCANY_RUNTIME_NAME, runtimeContext);
+ servletContext.setAttribute(MODULE_COMPONENT_NAME, moduleContext);
+ }
+
+ public void contextDestroyed(ServletContextEvent servletContextEvent) {
+ moduleContext.fireEvent(EventContext.MODULE_STOP, null);
+ moduleContext.stop();
+ systemModuleComponentContext.fireEvent(EventContext.MODULE_STOP, null);
+ systemModuleComponentContext.stop();
+ runtimeContext.stop();
+ servletContextEvent.getServletContext().removeAttribute(MODULE_COMPONENT_NAME);
+ servletContextEvent.getServletContext().removeAttribute(TUSCANY_RUNTIME_NAME);
+ }
+
+ public void sessionCreated(HttpSessionEvent event) {
+ // do nothing since sessions are lazily created in {@link TuscanyRequestFilter}
+ }
+
+ public void sessionDestroyed(HttpSessionEvent event) {
+ // todo do we actually need to bind the module context to the thread to fire this event?
+ ModuleContext oldContext = CurrentModuleContext.getContext();
+ try {
+ ContextBinder.BINDER.setContext((ModuleContext) moduleContext);
+ moduleContext.fireEvent(EventContext.SESSION_END, event.getSession());
+ } finally{
+ ContextBinder.BINDER.setContext(oldContext);
+ }
+ }
+
+ private void bootRuntime(String name, String uri, MonitorFactory monitorFactory) throws ConfigurationException {
+ // Create a resource loader from the current classloader
+ ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+ ResourceLoader resourceLoader = new ResourceLoaderImpl(classLoader);
+
+ // Create an assembly model factory
+ AssemblyFactory modelFactory=new AssemblyFactoryImpl();
+
+ // Create an assembly model loader
+ List<SCDLModelLoader> scdlLoaders=new ArrayList<SCDLModelLoader>();
+ scdlLoaders.add(new SystemSCDLModelLoader());
+ AssemblyModelLoader modelLoader=new SCDLAssemblyModelLoaderImpl(scdlLoaders);
+
+ // Create an assembly model context
+ AssemblyModelContext modelContext = new AssemblyModelContextImpl(modelFactory, modelLoader, resourceLoader);
+
+ // Create system configuration builders
+ List<RuntimeConfigurationBuilder> configBuilders = new ArrayList();
+ configBuilders.add((new SystemComponentContextBuilder()));
+ configBuilders.add(new SystemEntryPointBuilder());
+ configBuilders.add(new SystemExternalServiceBuilder());
+
+ // Create a runtime context and start it
+ runtimeContext = new RuntimeContextImpl(monitorFactory, scdlLoaders, configBuilders,new DefaultWireBuilder());
+ runtimeContext.start();
+
+ // Get the system context
+ AggregateContext systemContext = runtimeContext.getSystemContext();
+
+ // Load the system module component
+ ModuleComponentConfigurationLoader loader = new ModuleComponentConfigurationLoaderImpl(modelContext);
+ ModuleComponent systemModuleComponent = loader.loadSystemModuleComponent(SYSTEM_MODULE_COMPONENT, SYSTEM_MODULE_COMPONENT);
+
+ // Register it with the system context
+ systemContext.registerModelObject(systemModuleComponent);
+
+ // Get the aggregate context representing the system module component
+ systemModuleComponentContext = (AggregateContext) systemContext.getContext(SYSTEM_MODULE_COMPONENT);
+ systemModuleComponentContext.registerModelObject(systemModuleComponent.getComponentImplementation());
+ systemModuleComponentContext.fireEvent(EventContext.MODULE_START, null);
+
+ // Load the SCDL configuration of the application module
+ ModuleComponent moduleComponent = loader.loadModuleComponent(name, uri);
+
+ // Register it under the root application context
+ runtimeContext.getRootContext().registerModelObject(moduleComponent);
+ moduleContext=(AggregateContext)runtimeContext.getContext(moduleComponent.getName());
+ moduleContext.registerModelObject(moduleComponent.getComponentImplementation());
+
+ moduleContext.fireEvent(EventContext.MODULE_START, null);
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/resources/META-INF/services/org.apache.tuscany.core.runtime.proxy.ServiceProxyFactory b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/resources/META-INF/services/org.apache.tuscany.core.runtime.proxy.ServiceProxyFactory
new file mode 100644
index 0000000000..9b2d05d734
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/resources/META-INF/services/org.apache.tuscany.core.runtime.proxy.ServiceProxyFactory
@@ -0,0 +1 @@
+org.apache.tuscany.core.runtime.proxy.impl.ServiceProxyFactoryImpl \ No newline at end of file
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/resources/model/anyobject.xsd b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/resources/model/anyobject.xsd
new file mode 100644
index 0000000000..47f45d61d7
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/resources/model/anyobject.xsd
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
+
+ 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.
+ -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:obj="http://org.apache.tuscany/xmlns/anyobject/v0.0.1/"
+ targetNamespace="http://org.apache.tuscany/xmlns/anyobject/v0.0.1/"
+ xmlns:codegen="http://www.eclipse.org/emf/2002/Ecore"
+ codegen:nsPrefix="obj"
+ codegen:package="org.apache.tuscany.message.object">
+
+ <element name="anyObject" type="obj:AnyObject"/>
+ <complexType name="AnyObject">
+ <sequence>
+ <element name="object" type="obj:Object"/>
+ </sequence>
+ </complexType>
+
+ <simpleType name="Object" codegen:instanceClass="java.lang.Object">
+ <restriction base="base64Binary"/>
+ </simpleType>
+
+</schema>
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/resources/model/tuscany-system.xsd b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/resources/model/tuscany-system.xsd
new file mode 100644
index 0000000000..7bd45320b9
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/resources/model/tuscany-system.xsd
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
+
+ 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.
+ -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://org.apache.tuscany/xmlns/system/0.9"
+ xmlns:sca="http://www.osoa.org/xmlns/sca/0.9"
+ xmlns:system="http://org.apache.tuscany/xmlns/system/0.9"
+ xmlns:sdojava="commonj.sdo/java"
+ elementFormDefault="qualified"
+ sdojava:package="org.apache.tuscany.core.system.scdl">
+
+ <import namespace="http://www.osoa.org/xmlns/sca/0.9" schemaLocation="../../../../../model/src/main/resources/model/sca-core.xsd"/>
+
+ <element name="implementation.system" type="system:SystemImplementation" substitutionGroup="sca:implementation"/>
+ <complexType name="SystemImplementation">
+ <complexContent>
+ <extension base="sca:Implementation">
+ <sequence>
+ <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="class" type="NCName" use="required"/>
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <element name="binding.system" type="system:SystemBinding" substitutionGroup="sca:binding"/>
+ <complexType name="SystemBinding">
+ <complexContent>
+ <extension base="sca:Binding">
+ <sequence>
+ <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+</schema> \ No newline at end of file
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/resources/org/apache/tuscany/core/Messages.properties b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/resources/org/apache/tuscany/core/Messages.properties
new file mode 100644
index 0000000000..4581e44bff
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/resources/org/apache/tuscany/core/Messages.properties
@@ -0,0 +1,25 @@
+# Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
+#
+# 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.
+# ====================================================================
+# To code developer:
+# Do NOT change the properties between this line and the
+# "%%% END OF TRANSLATED PROPERTIES %%%" line.
+# Make a new property name, append to the end of the file and change
+# the code to use the new property.
+# ====================================================================
+
+# =====================================================================
+# %%% END OF TRANSLATED PROPERTIES %%%
+# =====================================================================
+# NLS_MESSAGEFORMAT_ALL
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/resources/system.module b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/resources/system.module
new file mode 100644
index 0000000000..65ed9da82c
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/resources/system.module
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
+
+ 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.
+ -->
+<module xmlns="http://www.osoa.org/xmlns/sca/0.9"
+ xmlns:v="http://www.osoa.org/xmlns/sca/values/0.9"
+ xmlns:system="http://org.apache.tuscany/xmlns/system/0.9"
+ name="org.apache.tuscany.core.system">
+
+ <component name="org.apache.tuscany.core.loader.SCDLModelLoaderRegistry">
+ <system:implementation.system class="org.apache.tuscany.core.loader.impl.SCDLModelLoaderRegistryImpl"/>
+ </component>
+
+</module>
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/builder/impl/DefaultWireBuilderTestCase.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/builder/impl/DefaultWireBuilderTestCase.java
new file mode 100644
index 0000000000..6eaac60eaa
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/builder/impl/DefaultWireBuilderTestCase.java
@@ -0,0 +1,447 @@
+package org.apache.tuscany.core.builder.impl;
+
+import java.lang.reflect.Method;
+import java.util.Map;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.core.context.QualifiedName;
+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.jdk.JDKProxyFactory;
+import org.apache.tuscany.core.invocation.mock.MockHandler;
+import org.apache.tuscany.core.invocation.mock.MockStaticInvoker;
+import org.apache.tuscany.core.invocation.mock.MockSyncInterceptor;
+import org.apache.tuscany.core.invocation.mock.SimpleTarget;
+import org.apache.tuscany.core.invocation.mock.SimpleTargetImpl;
+import org.apache.tuscany.core.invocation.spi.ProxyFactory;
+import org.apache.tuscany.core.message.Message;
+import org.apache.tuscany.core.message.MessageFactory;
+import org.apache.tuscany.core.message.impl.MessageFactoryImpl;
+
+public class DefaultWireBuilderTestCase extends TestCase {
+
+ private Method hello;
+
+ private Method goodbye;
+
+ public DefaultWireBuilderTestCase() {
+ super();
+ }
+
+ public DefaultWireBuilderTestCase(String arg0) {
+ super(arg0);
+ }
+
+ public void setUp() throws Exception {
+ hello = SimpleTarget.class.getMethod("hello", new Class[] { String.class });
+ goodbye = SimpleTarget.class.getMethod("goodbye", new Class[] { String.class });
+ }
+
+ public void testWireWithInterceptorsAndHandlers() throws Exception {
+ MessageFactory msgFactory = new MessageFactoryImpl();
+
+ InvocationConfiguration source = new InvocationConfiguration(hello);
+ MockHandler sourceRequestHandler = new MockHandler();
+ MockHandler sourceResponseHandler = new MockHandler();
+ MockSyncInterceptor sourceInterceptor = new MockSyncInterceptor();
+ source.addRequestHandler(sourceRequestHandler);
+ source.addResponseHandler(sourceResponseHandler);
+ source.addSourceInterceptor(sourceInterceptor);
+
+ ProxyFactory sourceFactory = new JDKProxyFactory();
+ Map<Method, InvocationConfiguration> sourceInvocationConfigs = new MethodHashMap();
+ sourceInvocationConfigs.put(hello, source);
+ ProxyConfiguration sourceConfig = new ProxyConfiguration(new QualifiedName("target/SimpleTarget"),
+ sourceInvocationConfigs, Thread.currentThread().getContextClassLoader(), msgFactory);
+ sourceFactory.setProxyConfiguration(sourceConfig);
+ sourceFactory.setBusinessInterface(SimpleTarget.class);
+
+ InvocationConfiguration target = new InvocationConfiguration(hello);
+ MockHandler targetRequestHandler = new MockHandler();
+ MockHandler targetResponseHandler = new MockHandler();
+ MockSyncInterceptor targetInterceptor = new MockSyncInterceptor();
+ target.addRequestHandler(targetRequestHandler);
+ target.addResponseHandler(targetResponseHandler);
+ target.addTargetInterceptor(targetInterceptor);
+ target.addTargetInterceptor(new InvokerInterceptor());
+
+ ProxyFactory targetFactory = new JDKProxyFactory();
+ Map<Method, InvocationConfiguration> targetInvocationConfigs = new MethodHashMap();
+ targetInvocationConfigs.put(hello, target);
+ ProxyConfiguration targetConfig = new ProxyConfiguration(new QualifiedName("target/SimpleTarget"),
+ targetInvocationConfigs, Thread.currentThread().getContextClassLoader(), msgFactory);
+ targetFactory.setProxyConfiguration(targetConfig);
+ targetFactory.setBusinessInterface(SimpleTarget.class);
+
+ // connect the source to the target
+ DefaultWireBuilder builder = new DefaultWireBuilder();
+ // no need for scopes since we use a static invoker
+ builder.connect(sourceFactory, targetFactory, null, true, null);
+ // source.build();
+ target.build();
+ // set a static invoker
+ MockStaticInvoker invoker = new MockStaticInvoker(hello, new SimpleTargetImpl());
+ source.setTargetInvoker(invoker);
+
+ Message msg = msgFactory.createMessage();
+ msg.setBody("foo");
+ msg.setTargetInvoker(invoker);
+ Message response = (Message) source.getSourceInterceptor().invoke(msg);
+ Assert.assertEquals("foo", response.getBody());
+ Assert.assertEquals(1, sourceRequestHandler.getCount());
+ Assert.assertEquals(1, sourceResponseHandler.getCount());
+ Assert.assertEquals(1, sourceInterceptor.getCount());
+ Assert.assertEquals(1, targetRequestHandler.getCount());
+ Assert.assertEquals(1, targetResponseHandler.getCount());
+ Assert.assertEquals(1, targetInterceptor.getCount());
+ }
+
+ public void testWireWithSourceInterceptorTargetHandlersAndTargetInterceptor() throws Exception {
+ MessageFactory msgFactory = new MessageFactoryImpl();
+
+ InvocationConfiguration source = new InvocationConfiguration(hello);
+ MockSyncInterceptor sourceInterceptor = new MockSyncInterceptor();
+ source.addSourceInterceptor(sourceInterceptor);
+
+ ProxyFactory sourceFactory = new JDKProxyFactory();
+ Map<Method, InvocationConfiguration> sourceInvocationConfigs = new MethodHashMap();
+ sourceInvocationConfigs.put(hello, source);
+ ProxyConfiguration sourceConfig = new ProxyConfiguration(new QualifiedName("target/SimpleTarget"),
+ sourceInvocationConfigs, Thread.currentThread().getContextClassLoader(), msgFactory);
+ sourceFactory.setProxyConfiguration(sourceConfig);
+ sourceFactory.setBusinessInterface(SimpleTarget.class);
+
+ InvocationConfiguration target = new InvocationConfiguration(hello);
+ MockHandler targetRequestHandler = new MockHandler();
+ MockHandler targetResponseHandler = new MockHandler();
+ MockSyncInterceptor targetInterceptor = new MockSyncInterceptor();
+ target.addRequestHandler(targetRequestHandler);
+ target.addResponseHandler(targetResponseHandler);
+ target.addTargetInterceptor(targetInterceptor);
+ target.addTargetInterceptor(new InvokerInterceptor());
+
+ ProxyFactory targetFactory = new JDKProxyFactory();
+ Map<Method, InvocationConfiguration> targetInvocationConfigs = new MethodHashMap();
+ targetInvocationConfigs.put(hello, target);
+ ProxyConfiguration targetConfig = new ProxyConfiguration(new QualifiedName("target/SimpleTarget"),
+ targetInvocationConfigs, Thread.currentThread().getContextClassLoader(), msgFactory);
+ targetFactory.setProxyConfiguration(targetConfig);
+ targetFactory.setBusinessInterface(SimpleTarget.class);
+
+ // connect the source to the target
+ DefaultWireBuilder builder = new DefaultWireBuilder();
+ // no need for scopes since we use a static invoker
+ builder.connect(sourceFactory, targetFactory, null, true, null);
+ // source.build();
+ target.build();
+ // set a static invoker
+ MockStaticInvoker invoker = new MockStaticInvoker(hello, new SimpleTargetImpl());
+ source.setTargetInvoker(invoker);
+
+ Message msg = msgFactory.createMessage();
+ msg.setBody("foo");
+ msg.setTargetInvoker(invoker);
+ Message response = (Message) source.getSourceInterceptor().invoke(msg);
+ Assert.assertEquals("foo", response.getBody());
+ Assert.assertEquals(1, sourceInterceptor.getCount());
+ Assert.assertEquals(1, targetRequestHandler.getCount());
+ Assert.assertEquals(1, targetResponseHandler.getCount());
+ Assert.assertEquals(1, targetInterceptor.getCount());
+ }
+
+ public void testWireWithInterceptorsAndRequestHandlers() throws Exception {
+ MessageFactory msgFactory = new MessageFactoryImpl();
+
+ InvocationConfiguration source = new InvocationConfiguration(hello);
+ MockHandler sourceRequestHandler = new MockHandler();
+ MockSyncInterceptor sourceInterceptor = new MockSyncInterceptor();
+ source.addRequestHandler(sourceRequestHandler);
+ source.addSourceInterceptor(sourceInterceptor);
+
+ ProxyFactory sourceFactory = new JDKProxyFactory();
+ Map<Method, InvocationConfiguration> sourceInvocationConfigs = new MethodHashMap();
+ sourceInvocationConfigs.put(hello, source);
+ ProxyConfiguration sourceConfig = new ProxyConfiguration(new QualifiedName("target/SimpleTarget"),
+ sourceInvocationConfigs, Thread.currentThread().getContextClassLoader(), msgFactory);
+ sourceFactory.setProxyConfiguration(sourceConfig);
+ sourceFactory.setBusinessInterface(SimpleTarget.class);
+
+ InvocationConfiguration target = new InvocationConfiguration(hello);
+ MockHandler targetRequestHandler = new MockHandler();
+ MockSyncInterceptor targetInterceptor = new MockSyncInterceptor();
+ target.addRequestHandler(targetRequestHandler);
+ target.addTargetInterceptor(targetInterceptor);
+ target.addTargetInterceptor(new InvokerInterceptor());
+
+ ProxyFactory targetFactory = new JDKProxyFactory();
+ Map<Method, InvocationConfiguration> targetInvocationConfigs = new MethodHashMap();
+ targetInvocationConfigs.put(hello, target);
+ ProxyConfiguration targetConfig = new ProxyConfiguration(new QualifiedName("target/SimpleTarget"),
+ targetInvocationConfigs, Thread.currentThread().getContextClassLoader(), msgFactory);
+ targetFactory.setProxyConfiguration(targetConfig);
+ targetFactory.setBusinessInterface(SimpleTarget.class);
+
+ // connect the source to the target
+ DefaultWireBuilder builder = new DefaultWireBuilder();
+ // no need for scopes since we use a static invoker
+ builder.connect(sourceFactory, targetFactory, null, true, null);
+ // source.build();
+ target.build();
+ // set a static invoker
+ MockStaticInvoker invoker = new MockStaticInvoker(hello, new SimpleTargetImpl());
+ source.setTargetInvoker(invoker);
+
+ Message msg = msgFactory.createMessage();
+ msg.setBody("foo");
+ msg.setTargetInvoker(invoker);
+ Message response = (Message) source.getSourceInterceptor().invoke(msg);
+ Assert.assertEquals("foo", response.getBody());
+ Assert.assertEquals(1, sourceRequestHandler.getCount());
+ Assert.assertEquals(1, sourceInterceptor.getCount());
+ Assert.assertEquals(1, targetRequestHandler.getCount());
+ Assert.assertEquals(1, targetInterceptor.getCount());
+ }
+
+ public void testWireWithSourceAndTargetInterceptors() throws Exception {
+ MessageFactory msgFactory = new MessageFactoryImpl();
+
+ InvocationConfiguration source = new InvocationConfiguration(hello);
+ MockSyncInterceptor sourceInterceptor = new MockSyncInterceptor();
+ source.addSourceInterceptor(sourceInterceptor);
+
+ ProxyFactory sourceFactory = new JDKProxyFactory();
+ Map<Method, InvocationConfiguration> sourceInvocationConfigs = new MethodHashMap();
+ sourceInvocationConfigs.put(hello, source);
+ ProxyConfiguration sourceConfig = new ProxyConfiguration(new QualifiedName("target/SimpleTarget"),
+ sourceInvocationConfigs, Thread.currentThread().getContextClassLoader(), msgFactory);
+ sourceFactory.setProxyConfiguration(sourceConfig);
+ sourceFactory.setBusinessInterface(SimpleTarget.class);
+
+ InvocationConfiguration target = new InvocationConfiguration(hello);
+ MockSyncInterceptor targetInterceptor = new MockSyncInterceptor();
+ target.addTargetInterceptor(targetInterceptor);
+ target.addTargetInterceptor(new InvokerInterceptor());
+
+ ProxyFactory targetFactory = new JDKProxyFactory();
+ Map<Method, InvocationConfiguration> targetInvocationConfigs = new MethodHashMap();
+ targetInvocationConfigs.put(hello, target);
+ ProxyConfiguration targetConfig = new ProxyConfiguration(new QualifiedName("target/SimpleTarget"),
+ targetInvocationConfigs, Thread.currentThread().getContextClassLoader(), msgFactory);
+ targetFactory.setProxyConfiguration(targetConfig);
+ targetFactory.setBusinessInterface(SimpleTarget.class);
+
+ // connect the source to the target
+ DefaultWireBuilder builder = new DefaultWireBuilder();
+ // no need for scopes since we use a static invoker
+ builder.connect(sourceFactory, targetFactory, null, true, null);
+ // source.build();
+ target.build();
+ // set a static invoker
+ MockStaticInvoker invoker = new MockStaticInvoker(hello, new SimpleTargetImpl());
+ source.setTargetInvoker(invoker);
+
+ Message msg = msgFactory.createMessage();
+ msg.setBody("foo");
+ msg.setTargetInvoker(invoker);
+ Message response = (Message) source.getSourceInterceptor().invoke(msg);
+ Assert.assertEquals("foo", response.getBody());
+ Assert.assertEquals(1, sourceInterceptor.getCount());
+ Assert.assertEquals(1, targetInterceptor.getCount());
+ }
+
+ public void testWireWithSourceInterceptorSourceHandlersAndTargetInterceptor() throws Exception {
+ MessageFactory msgFactory = new MessageFactoryImpl();
+
+ InvocationConfiguration source = new InvocationConfiguration(hello);
+ MockHandler sourceRequestHandler = new MockHandler();
+ MockHandler sourceResponseHandler = new MockHandler();
+ MockSyncInterceptor sourceInterceptor = new MockSyncInterceptor();
+ source.addRequestHandler(sourceRequestHandler);
+ source.addResponseHandler(sourceResponseHandler);
+ source.addSourceInterceptor(sourceInterceptor);
+
+ ProxyFactory sourceFactory = new JDKProxyFactory();
+ Map<Method, InvocationConfiguration> sourceInvocationConfigs = new MethodHashMap();
+ sourceInvocationConfigs.put(hello, source);
+ ProxyConfiguration sourceConfig = new ProxyConfiguration(new QualifiedName("target/SimpleTarget"),
+ sourceInvocationConfigs, Thread.currentThread().getContextClassLoader(), msgFactory);
+ sourceFactory.setProxyConfiguration(sourceConfig);
+ sourceFactory.setBusinessInterface(SimpleTarget.class);
+
+ InvocationConfiguration target = new InvocationConfiguration(hello);
+ MockSyncInterceptor targetInterceptor = new MockSyncInterceptor();
+ target.addTargetInterceptor(targetInterceptor);
+ target.addTargetInterceptor(new InvokerInterceptor());
+
+ ProxyFactory targetFactory = new JDKProxyFactory();
+ Map<Method, InvocationConfiguration> targetInvocationConfigs = new MethodHashMap();
+ targetInvocationConfigs.put(hello, target);
+ ProxyConfiguration targetConfig = new ProxyConfiguration(new QualifiedName("target/SimpleTarget"),
+ targetInvocationConfigs, Thread.currentThread().getContextClassLoader(), msgFactory);
+ targetFactory.setProxyConfiguration(targetConfig);
+ targetFactory.setBusinessInterface(SimpleTarget.class);
+
+ // connect the source to the target
+ DefaultWireBuilder builder = new DefaultWireBuilder();
+ // no need for scopes since we use a static invoker
+ builder.connect(sourceFactory, targetFactory, null, true, null);
+ // source.build();
+ target.build();
+ // set a static invoker
+ MockStaticInvoker invoker = new MockStaticInvoker(hello, new SimpleTargetImpl());
+ source.setTargetInvoker(invoker);
+
+ Message msg = msgFactory.createMessage();
+ msg.setBody("foo");
+ msg.setTargetInvoker(invoker);
+ Message response = (Message) source.getSourceInterceptor().invoke(msg);
+ Assert.assertEquals("foo", response.getBody());
+ Assert.assertEquals(1, sourceRequestHandler.getCount());
+ Assert.assertEquals(1, sourceResponseHandler.getCount());
+ Assert.assertEquals(1, sourceInterceptor.getCount());
+ Assert.assertEquals(1, targetInterceptor.getCount());
+ }
+
+ public void testWireWithTargetInterceptorAndTargetHandlers() throws Exception {
+ MessageFactory msgFactory = new MessageFactoryImpl();
+
+ InvocationConfiguration source = new InvocationConfiguration(hello);
+
+ ProxyFactory sourceFactory = new JDKProxyFactory();
+ Map<Method, InvocationConfiguration> sourceInvocationConfigs = new MethodHashMap();
+ sourceInvocationConfigs.put(hello, source);
+ ProxyConfiguration sourceConfig = new ProxyConfiguration(new QualifiedName("target/SimpleTarget"),
+ sourceInvocationConfigs, Thread.currentThread().getContextClassLoader(), msgFactory);
+ sourceFactory.setProxyConfiguration(sourceConfig);
+ sourceFactory.setBusinessInterface(SimpleTarget.class);
+
+ InvocationConfiguration target = new InvocationConfiguration(hello);
+ MockHandler targetRequestHandler = new MockHandler();
+ MockHandler targetResponseHandler = new MockHandler();
+ MockSyncInterceptor targetInterceptor = new MockSyncInterceptor();
+ target.addRequestHandler(targetRequestHandler);
+ target.addResponseHandler(targetResponseHandler);
+ target.addTargetInterceptor(targetInterceptor);
+ target.addTargetInterceptor(new InvokerInterceptor());
+
+ ProxyFactory targetFactory = new JDKProxyFactory();
+ Map<Method, InvocationConfiguration> targetInvocationConfigs = new MethodHashMap();
+ targetInvocationConfigs.put(hello, target);
+ ProxyConfiguration targetConfig = new ProxyConfiguration(new QualifiedName("target/SimpleTarget"),
+ targetInvocationConfigs, Thread.currentThread().getContextClassLoader(), msgFactory);
+ targetFactory.setProxyConfiguration(targetConfig);
+ targetFactory.setBusinessInterface(SimpleTarget.class);
+
+ // connect the source to the target
+ DefaultWireBuilder builder = new DefaultWireBuilder();
+ // no need for scopes since we use a static invoker
+ builder.connect(sourceFactory, targetFactory, null, true, null);
+ // source.build();
+ target.build();
+ // set a static invoker
+ MockStaticInvoker invoker = new MockStaticInvoker(hello, new SimpleTargetImpl());
+ source.setTargetInvoker(invoker);
+
+ Message msg = msgFactory.createMessage();
+ msg.setBody("foo");
+ msg.setTargetInvoker(invoker);
+ Message response = (Message) source.getSourceInterceptor().invoke(msg);
+ Assert.assertEquals("foo", response.getBody());
+ Assert.assertEquals(1, targetRequestHandler.getCount());
+ Assert.assertEquals(1, targetResponseHandler.getCount());
+ Assert.assertEquals(1, targetInterceptor.getCount());
+ }
+
+ public void testWireWithTargetInterceptor() throws Exception {
+ MessageFactory msgFactory = new MessageFactoryImpl();
+
+ InvocationConfiguration source = new InvocationConfiguration(hello);
+
+ ProxyFactory sourceFactory = new JDKProxyFactory();
+ Map<Method, InvocationConfiguration> sourceInvocationConfigs = new MethodHashMap();
+ sourceInvocationConfigs.put(hello, source);
+ ProxyConfiguration sourceConfig = new ProxyConfiguration(new QualifiedName("target/SimpleTarget"),
+ sourceInvocationConfigs, Thread.currentThread().getContextClassLoader(), msgFactory);
+ sourceFactory.setProxyConfiguration(sourceConfig);
+ sourceFactory.setBusinessInterface(SimpleTarget.class);
+
+ InvocationConfiguration target = new InvocationConfiguration(hello);
+ MockSyncInterceptor targetInterceptor = new MockSyncInterceptor();
+ target.addTargetInterceptor(targetInterceptor);
+ target.addTargetInterceptor(new InvokerInterceptor());
+
+ ProxyFactory targetFactory = new JDKProxyFactory();
+ Map<Method, InvocationConfiguration> targetInvocationConfigs = new MethodHashMap();
+ targetInvocationConfigs.put(hello, target);
+ ProxyConfiguration targetConfig = new ProxyConfiguration(new QualifiedName("target/SimpleTarget"),
+ targetInvocationConfigs, Thread.currentThread().getContextClassLoader(), msgFactory);
+ targetFactory.setProxyConfiguration(targetConfig);
+ targetFactory.setBusinessInterface(SimpleTarget.class);
+
+ // connect the source to the target
+ DefaultWireBuilder builder = new DefaultWireBuilder();
+ // no need for scopes since we use a static invoker
+ builder.connect(sourceFactory, targetFactory, null, true, null);
+ target.build();
+ // set a static invoker
+ MockStaticInvoker invoker = new MockStaticInvoker(hello, new SimpleTargetImpl());
+ source.setTargetInvoker(invoker);
+
+ Message msg = msgFactory.createMessage();
+ msg.setBody("foo");
+ msg.setTargetInvoker(invoker);
+ Message response = (Message) source.getSourceInterceptor().invoke(msg);
+ Assert.assertEquals("foo", response.getBody());
+ Assert.assertEquals(1, targetInterceptor.getCount());
+ }
+
+ /**
+ * When there are only {@link InvokerInterceptor}s in the source and target chain, we need to bypass one during
+ * wire up so they are not chained together
+ */
+ public void testWireWithOnlyInvokerInterceptors() throws Exception {
+ MessageFactory msgFactory = new MessageFactoryImpl();
+
+ InvocationConfiguration source = new InvocationConfiguration(hello);
+ source.addTargetInterceptor(new InvokerInterceptor());
+
+ ProxyFactory sourceFactory = new JDKProxyFactory();
+ Map<Method, InvocationConfiguration> sourceInvocationConfigs = new MethodHashMap();
+ sourceInvocationConfigs.put(hello, source);
+ ProxyConfiguration sourceConfig = new ProxyConfiguration(new QualifiedName("target/SimpleTarget"),
+ sourceInvocationConfigs, Thread.currentThread().getContextClassLoader(), msgFactory);
+ sourceFactory.setProxyConfiguration(sourceConfig);
+ sourceFactory.setBusinessInterface(SimpleTarget.class);
+
+ InvocationConfiguration target = new InvocationConfiguration(hello);
+ target.addTargetInterceptor(new InvokerInterceptor());
+
+ ProxyFactory targetFactory = new JDKProxyFactory();
+ Map<Method, InvocationConfiguration> targetInvocationConfigs = new MethodHashMap();
+ targetInvocationConfigs.put(hello, target);
+ ProxyConfiguration targetConfig = new ProxyConfiguration(new QualifiedName("target/SimpleTarget"),
+ targetInvocationConfigs, Thread.currentThread().getContextClassLoader(), msgFactory);
+ targetFactory.setProxyConfiguration(targetConfig);
+ targetFactory.setBusinessInterface(SimpleTarget.class);
+
+ // connect the source to the target
+ DefaultWireBuilder builder = new DefaultWireBuilder();
+ // no need for scopes since we use a static invoker
+ builder.connect(sourceFactory, targetFactory, null, true, null);
+ target.build();
+ // set a static invoker
+ MockStaticInvoker invoker = new MockStaticInvoker(hello, new SimpleTargetImpl());
+ source.setTargetInvoker(invoker);
+
+ Message msg = msgFactory.createMessage();
+ msg.setBody("foo");
+ msg.setTargetInvoker(invoker);
+ Message response = (Message) source.getSourceInterceptor().invoke(msg);
+ Assert.assertEquals("foo", response.getBody());
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/builder/impl/NegativeDefaultWireBuilderTestCase.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/builder/impl/NegativeDefaultWireBuilderTestCase.java
new file mode 100644
index 0000000000..bf83bca5cb
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/builder/impl/NegativeDefaultWireBuilderTestCase.java
@@ -0,0 +1,71 @@
+package org.apache.tuscany.core.builder.impl;
+
+import java.lang.reflect.Method;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.core.builder.BuilderConfigException;
+import org.apache.tuscany.core.context.QualifiedName;
+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.jdk.JDKProxyFactory;
+import org.apache.tuscany.core.invocation.mock.SimpleTarget;
+import org.apache.tuscany.core.invocation.spi.ProxyFactory;
+import org.apache.tuscany.core.message.MessageFactory;
+import org.apache.tuscany.core.message.impl.MessageFactoryImpl;
+
+public class NegativeDefaultWireBuilderTestCase extends TestCase {
+
+ private Method hello;
+
+ private Method goodbye;
+
+ public NegativeDefaultWireBuilderTestCase() {
+ super();
+ }
+
+ public NegativeDefaultWireBuilderTestCase(String arg0) {
+ super(arg0);
+ }
+
+ public void setUp() throws Exception {
+ hello = SimpleTarget.class.getMethod("hello", new Class[] { String.class });
+ goodbye = SimpleTarget.class.getMethod("goodbye", new Class[] { String.class });
+ }
+
+ public void testNoTargetInterceptorOrHandler() throws Exception {
+ MessageFactory msgFactory = new MessageFactoryImpl();
+
+ InvocationConfiguration source = new InvocationConfiguration(hello);
+
+ ProxyFactory sourceFactory = new JDKProxyFactory();
+ Map<Method, InvocationConfiguration> sourceInvocationConfigs = new MethodHashMap();
+ sourceInvocationConfigs.put(hello, source);
+ ProxyConfiguration sourceConfig = new ProxyConfiguration(new QualifiedName("target/SimpleTarget"),
+ sourceInvocationConfigs, Thread.currentThread().getContextClassLoader(), msgFactory);
+ sourceFactory.setProxyConfiguration(sourceConfig);
+ sourceFactory.setBusinessInterface(SimpleTarget.class);
+
+ InvocationConfiguration target = new InvocationConfiguration(hello);
+
+ ProxyFactory targetFactory = new JDKProxyFactory();
+ Map<Method, InvocationConfiguration> targetInvocationConfigs = new MethodHashMap();
+ targetInvocationConfigs.put(hello, target);
+ ProxyConfiguration targetConfig = new ProxyConfiguration(new QualifiedName("target/SimpleTarget"),
+ targetInvocationConfigs, Thread.currentThread().getContextClassLoader(), msgFactory);
+ targetFactory.setProxyConfiguration(targetConfig);
+ targetFactory.setBusinessInterface(SimpleTarget.class);
+
+ // connect the source to the target
+ DefaultWireBuilder builder = new DefaultWireBuilder();
+ try {
+ builder.connect(sourceFactory, targetFactory, null, true, null);
+ fail("Expected " + BuilderConfigException.class.getName());
+ } catch (BuilderConfigException e) {
+ // success
+ }
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/config/JavaIntrospectionHelperTestCase.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/config/JavaIntrospectionHelperTestCase.java
new file mode 100644
index 0000000000..9cd7a40e59
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/config/JavaIntrospectionHelperTestCase.java
@@ -0,0 +1,37 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.config;
+
+import java.lang.reflect.Constructor;
+
+import org.apache.tuscany.core.config.JavaIntrospectionHelper;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JavaIntrospectionHelperTestCase extends TestCase {
+ public void testDefaultConstructor() throws Exception {
+ Constructor ctr = JavaIntrospectionHelper.getDefaultConstructor(SomeClass.class);
+ assertEquals(ctr, SomeClass.class.getConstructor(new Class[]{}));
+ assertTrue(SomeClass.class == ctr.newInstance((Object[]) null).getClass());
+ }
+
+ public static class SomeClass {
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/config/ModuleComponentConfigurationLoaderTestCase.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/config/ModuleComponentConfigurationLoaderTestCase.java
new file mode 100644
index 0000000000..df4cace0f9
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/config/ModuleComponentConfigurationLoaderTestCase.java
@@ -0,0 +1,68 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.config;
+
+import java.net.URL;
+import java.util.List;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.common.resource.impl.ResourceLoaderImpl;
+import org.apache.tuscany.core.config.impl.ModuleComponentConfigurationLoaderImpl;
+import org.apache.tuscany.model.assembly.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.Component;
+import org.apache.tuscany.model.assembly.ComponentImplementation;
+import org.apache.tuscany.model.assembly.Module;
+import org.apache.tuscany.model.assembly.ModuleComponent;
+import org.apache.tuscany.model.assembly.impl.AssemblyFactoryImpl;
+import org.apache.tuscany.model.assembly.impl.AssemblyModelContextImpl;
+import org.apache.tuscany.model.scdl.loader.impl.SCDLAssemblyModelLoaderImpl;
+
+/**
+ * @version $Rev: 379641 $ $Date: 2006-02-21 16:50:58 -0800 (Tue, 21 Feb 2006) $
+ */
+public class ModuleComponentConfigurationLoaderTestCase extends TestCase {
+ private ModuleComponentConfigurationLoader loader;
+
+ public void testFoo() throws ConfigurationException {
+ URL xml = ModuleComponentConfigurationLoaderTestCase.class.getResource("ModuleComponentLoaderTest1.module");
+ ModuleComponent moduleComponent = loader.loadModuleComponent("test", "test", xml.toString());
+ Assert.assertEquals("test", moduleComponent.getName());
+ Module module = moduleComponent.getModuleImplementation();
+ Assert.assertEquals("ModuleComponentLoaderTest1", module.getName());
+ List<Component> components = module.getComponents();
+ Assert.assertEquals(1,components.size());
+ Component component = components.get(0);
+ Assert.assertEquals("HelloWorldServiceComponent", component.getName());
+
+ component = module.getComponent("HelloWorldServiceComponent");
+ Assert.assertEquals("HelloWorldServiceComponent", component.getName());
+
+ ComponentImplementation implementation = component.getComponentImplementation();
+ Assert.assertNull(implementation);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
+ AssemblyModelContext modelContext=new AssemblyModelContextImpl(
+ new AssemblyFactoryImpl(), new SCDLAssemblyModelLoaderImpl(null),
+ new ResourceLoaderImpl(this.getClass().getClassLoader()));
+ loader = new ModuleComponentConfigurationLoaderImpl(modelContext);
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/context/AbstractAggregateHierarchyTests.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/context/AbstractAggregateHierarchyTests.java
new file mode 100644
index 0000000000..87e8d091ce
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/context/AbstractAggregateHierarchyTests.java
@@ -0,0 +1,107 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.context;
+
+import java.util.List;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.common.monitor.impl.NullMonitorFactory;
+import org.apache.tuscany.core.builder.RuntimeConfigurationBuilder;
+import org.apache.tuscany.core.context.impl.AggregateContextImpl;
+import org.apache.tuscany.core.context.impl.EventContextImpl;
+import org.apache.tuscany.core.context.scope.DefaultScopeStrategy;
+import org.apache.tuscany.core.mock.MockConfigContext;
+import org.apache.tuscany.core.mock.MockFactory;
+import org.apache.tuscany.core.mock.component.ModuleScopeSystemComponent;
+import org.apache.tuscany.core.mock.component.ModuleScopeSystemComponentImpl;
+import org.apache.tuscany.model.assembly.Component;
+import org.apache.tuscany.model.assembly.EntryPoint;
+import org.apache.tuscany.model.assembly.Scope;
+import org.osoa.sca.ModuleContext;
+
+/**
+ * Performs testing of various hierarchical scenarios
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class AbstractAggregateHierarchyTests extends TestCase {
+ protected List<RuntimeConfigurationBuilder> builders;
+
+ public void testParentContextIsolation() throws Exception {
+ AggregateContext parent = createContextHierachy();
+ AggregateContext child = (AggregateContext) parent.getContext("test.child");
+ Component component = MockFactory.createSystemComponent("TestService1", ModuleScopeSystemComponentImpl.class,
+ Scope.MODULE);
+ parent.registerModelObject(component);
+ EntryPoint ep = MockFactory.createEPSystemBinding("TestService1EP", ModuleScopeSystemComponent.class, "TestService1",
+ component);
+ parent.registerModelObject(ep);
+ parent.fireEvent(EventContext.MODULE_START, null);
+ child.fireEvent(EventContext.MODULE_START, null);
+ Assert.assertNotNull(parent.locateInstance("TestService1EP"));
+ try {
+ ((ModuleContext) child).locateService("TestService1EP");
+ fail("Expexcted " + ServiceNotFoundException.class.getName());
+ } catch (ServiceNotFoundException e) {
+ // expect exception to be thrown
+ }
+ parent.fireEvent(EventContext.MODULE_STOP, null);
+ child.fireEvent(EventContext.MODULE_STOP, null);
+ parent.stop();
+
+ }
+
+ /**
+ * Checks that registration of duplicate named model objects before context start throws an exception
+ */
+ public void testRegisterSameName() throws Exception {
+ AggregateContext parent = new AggregateContextImpl("test.parent", null, new DefaultScopeStrategy(),
+ new EventContextImpl(), new MockConfigContext(builders), new NullMonitorFactory());
+ parent.registerModelObject(MockFactory.createSystemAggregateComponent("test.child"));
+ try {
+ parent.registerModelObject(MockFactory.createSystemAggregateComponent("test.child"));
+ parent.start();
+ fail("Expected " + DuplicateNameException.class.getName());
+ } catch (DuplicateNameException e) {
+ // expected
+ }
+ }
+
+ /**
+ * Checks that registration of duplicate named model objects after context start throws an exception
+ */
+ public void testRegisterSameNameAfterStart() throws Exception {
+ AggregateContext parent = new AggregateContextImpl("test.parent", null, new DefaultScopeStrategy(),
+ new EventContextImpl(), new MockConfigContext(builders), new NullMonitorFactory());
+ parent.registerModelObject(MockFactory.createSystemAggregateComponent("test.child"));
+ parent.start();
+ AggregateContext child = (AggregateContext) parent.getContext("test.child");
+ Assert.assertNotNull(child);
+ try {
+ parent.registerModelObject(MockFactory.createSystemAggregateComponent("test.child"));
+ fail("Expected " + DuplicateNameException.class.getName());
+ } catch (DuplicateNameException e) {
+ // expected
+ }
+ }
+
+ protected abstract AggregateContext createContextHierachy() throws Exception;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ builders = MockFactory.createSystemBuilders();
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/context/AggregateComponentContextRegisterTestCase.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/context/AggregateComponentContextRegisterTestCase.java
new file mode 100644
index 0000000000..924ce57939
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/context/AggregateComponentContextRegisterTestCase.java
@@ -0,0 +1,130 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.context;
+
+import java.util.List;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.common.monitor.impl.NullMonitorFactory;
+import org.apache.tuscany.core.builder.RuntimeConfigurationBuilder;
+import org.apache.tuscany.core.context.impl.AggregateContextImpl;
+import org.apache.tuscany.core.context.impl.EventContextImpl;
+import org.apache.tuscany.core.context.scope.DefaultScopeStrategy;
+import org.apache.tuscany.core.mock.MockConfigContext;
+import org.apache.tuscany.core.mock.MockFactory;
+import org.apache.tuscany.core.mock.component.GenericSystemComponent;
+import org.apache.tuscany.core.mock.component.ModuleScopeSystemComponent;
+import org.apache.tuscany.core.mock.component.ModuleScopeSystemComponentImpl;
+import org.apache.tuscany.model.assembly.Component;
+import org.apache.tuscany.model.assembly.EntryPoint;
+import org.apache.tuscany.model.assembly.Module;
+import org.apache.tuscany.model.assembly.Scope;
+
+/**
+ * Tests registration of model objects for an aggregate context
+ *
+ * @version $Rev$ $Date$
+ */
+public class AggregateComponentContextRegisterTestCase extends TestCase {
+
+ public void testModuleRegistration() throws Exception {
+ AggregateContext moduleContext = createContext();
+ Module module = MockFactory.createSystemModule();
+ moduleContext.registerModelObject(module);
+ moduleContext.start();
+ moduleContext.fireEvent(EventContext.MODULE_START, null);
+ GenericSystemComponent component = (GenericSystemComponent) moduleContext.locateInstance("TestService1");
+ Assert.assertNotNull(component);
+ GenericSystemComponent ep = (GenericSystemComponent) moduleContext.locateInstance("TestService1EP");
+ Assert.assertNotNull(ep);
+ moduleContext.fireEvent(EventContext.MODULE_STOP, null);
+ moduleContext.stop();
+ }
+
+ public void testModuleRegistrationAfterStart() throws Exception {
+ AggregateContext moduleContext = createContext();
+ moduleContext.start();
+ Module module = MockFactory.createSystemModule();
+ moduleContext.registerModelObject(module);
+ moduleContext.fireEvent(EventContext.MODULE_START, null);
+ GenericSystemComponent component = (GenericSystemComponent) moduleContext.locateInstance("TestService1");
+ Assert.assertNotNull(component);
+ GenericSystemComponent ep = (GenericSystemComponent) moduleContext.locateInstance("TestService1EP");
+ Assert.assertNotNull(ep);
+ moduleContext.fireEvent(EventContext.MODULE_STOP, null);
+ moduleContext.stop();
+ }
+
+ public void testRegistration() throws Exception {
+ AggregateContext moduleContext = createContext();
+ Component component = MockFactory.createSystemComponent("TestService1", ModuleScopeSystemComponentImpl.class,
+ Scope.MODULE);
+ moduleContext.registerModelObject(component);
+ EntryPoint ep = MockFactory.createEPSystemBinding("TestService1EP", ModuleScopeSystemComponent.class, "TestService1",
+ component);
+ moduleContext.registerModelObject(ep);
+ moduleContext.start();
+ moduleContext.fireEvent(EventContext.MODULE_START, null);
+ GenericSystemComponent test = (GenericSystemComponent) moduleContext.locateInstance("TestService1");
+ Assert.assertNotNull(test);
+ GenericSystemComponent testEP = (GenericSystemComponent) moduleContext.locateInstance("TestService1EP");
+ Assert.assertNotNull(testEP);
+ moduleContext.fireEvent(EventContext.MODULE_STOP, null);
+ moduleContext.stop();
+ }
+
+ public void testRegistrationAfterStart() throws Exception {
+ AggregateContext moduleContext = createContext();
+ Component component = MockFactory.createSystemComponent("TestService1", ModuleScopeSystemComponentImpl.class,
+ Scope.MODULE);
+ moduleContext.start();
+ moduleContext.registerModelObject(component);
+ EntryPoint ep = MockFactory.createEPSystemBinding("TestService1EP", ModuleScopeSystemComponent.class, "TestService1",
+ component);
+ moduleContext.registerModelObject(ep);
+ moduleContext.fireEvent(EventContext.MODULE_START, null);
+ GenericSystemComponent test = (GenericSystemComponent) moduleContext.locateInstance("TestService1");
+ Assert.assertNotNull(test);
+ GenericSystemComponent testEP = (GenericSystemComponent) moduleContext.locateInstance("TestService1EP");
+ Assert.assertNotNull(testEP);
+ moduleContext.fireEvent(EventContext.MODULE_STOP, null);
+ moduleContext.stop();
+ }
+
+ public void testEPRegistrationAfterModuleStart() throws Exception {
+ AggregateContext moduleContext = createContext();
+ Component component = MockFactory.createSystemComponent("TestService1", ModuleScopeSystemComponentImpl.class,
+ Scope.MODULE);
+ moduleContext.start();
+ moduleContext.registerModelObject(component);
+ moduleContext.fireEvent(EventContext.MODULE_START, null);
+ GenericSystemComponent test = (GenericSystemComponent) moduleContext.locateInstance("TestService1");
+ Assert.assertNotNull(test);
+ EntryPoint ep = MockFactory.createEPSystemBinding("TestService1EP", ModuleScopeSystemComponent.class, "TestService1",
+ component);
+ moduleContext.registerModelObject(ep);
+ GenericSystemComponent testEP = (GenericSystemComponent) moduleContext.locateInstance("TestService1EP");
+ Assert.assertNotNull(testEP);
+ moduleContext.fireEvent(EventContext.MODULE_STOP, null);
+ moduleContext.stop();
+ }
+
+ protected AggregateContext createContext() {
+ List<RuntimeConfigurationBuilder> builders = MockFactory.createSystemBuilders();
+ return new AggregateContextImpl("test.context", null, new DefaultScopeStrategy(), new EventContextImpl(),
+ new MockConfigContext(builders), new NullMonitorFactory());
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/context/AggregateHierarchyTestCase.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/context/AggregateHierarchyTestCase.java
new file mode 100644
index 0000000000..51d315e1cf
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/context/AggregateHierarchyTestCase.java
@@ -0,0 +1,96 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.context;
+
+import java.util.List;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.common.monitor.impl.NullMonitorFactory;
+import org.apache.tuscany.core.builder.RuntimeConfigurationBuilder;
+import org.apache.tuscany.core.context.impl.AggregateContextImpl;
+import org.apache.tuscany.core.context.impl.EventContextImpl;
+import org.apache.tuscany.core.context.scope.DefaultScopeStrategy;
+import org.apache.tuscany.core.mock.MockConfigContext;
+import org.apache.tuscany.core.mock.MockFactory;
+import org.apache.tuscany.core.mock.component.ModuleScopeSystemComponent;
+import org.apache.tuscany.core.mock.component.ModuleScopeSystemComponentImpl;
+import org.apache.tuscany.model.assembly.Component;
+import org.apache.tuscany.model.assembly.EntryPoint;
+import org.apache.tuscany.model.assembly.Scope;
+import org.osoa.sca.ModuleContext;
+import org.osoa.sca.ServiceUnavailableException;
+
+/**
+ * Performs testing of various hierarchical scenarios
+ *
+ * @version $Rev$ $Date$
+ */
+public class AggregateHierarchyTestCase extends AbstractAggregateHierarchyTests {
+
+ /**
+ * FIXME model Tests adding a component, accessing it and then exposing it as an entry point after the first access
+ *
+ * @throws Exception
+ */
+ public void testChildContextIsolation() throws Exception {
+ AggregateContext parent = createContextHierachy();
+ AggregateContext child = (AggregateContext) parent.getContext("test.child");
+ Component component = MockFactory.createSystemInitializedComponent("TestService1", ModuleScopeSystemComponentImpl.class,
+ Scope.MODULE);
+ child.registerModelObject(component);
+ parent.fireEvent(EventContext.MODULE_START, null);
+ child.fireEvent(EventContext.MODULE_START, null);
+ Assert.assertNotNull(child.locateInstance("TestService1"));
+ try {
+ ((ModuleContext) parent).locateService("test.child/TestService1");
+ fail("Expected " + ServiceUnavailableException.class.getName()
+ + " since [test.child/TestService1] is not an entry point");
+ } catch (ServiceUnavailableException e) {
+ // should throw an exception since it is not an entry point
+ }
+
+ // now expose the service as an entry point
+ // FIXME hack to get around initialization of component - just create another one ;-)
+ component = MockFactory.createSystemComponent("TestService1", ModuleScopeSystemComponentImpl.class, Scope.MODULE);
+ EntryPoint ep = MockFactory.createEPSystemBinding("TestService1EP", ModuleScopeSystemComponent.class, "TestService1",
+ component);
+ child.registerModelObject(ep);
+ Assert.assertNotNull(child.locateInstance("TestService1EP"));
+ Assert.assertNotNull(parent.locateInstance("test.child/TestService1EP"));
+
+ // now expose the child entry point from the parent context
+ EntryPoint parentEp = MockFactory.createEntryPointWithStringRef("TestService1EP", ModuleScopeSystemComponent.class,
+ "TestService1", "test.child/TestService1EP");
+ parent.registerModelObject(parentEp);
+ Assert.assertNotNull(parent.locateInstance("TestService1EP"));
+
+ parent.fireEvent(EventContext.MODULE_STOP, null);
+ child.fireEvent(EventContext.MODULE_STOP, null);
+ parent.stop();
+ }
+
+ protected AggregateContext createContextHierachy() throws Exception {
+ List<RuntimeConfigurationBuilder> systemBuilders = MockFactory.createSystemBuilders();
+ AggregateContext parent = new AggregateContextImpl("test.parent", null, new DefaultScopeStrategy(),
+ new EventContextImpl(), new MockConfigContext(systemBuilders), new NullMonitorFactory());
+ Component component = MockFactory.createAggregateComponent("test.child");
+ parent.registerModelObject(component);
+ parent.start();
+ AggregateContext child = (AggregateContext) parent.getContext("test.child");
+ Assert.assertNotNull(child);
+ return parent;
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/context/QualifiedNameTestCase.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/context/QualifiedNameTestCase.java
new file mode 100644
index 0000000000..4f86d1aed5
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/context/QualifiedNameTestCase.java
@@ -0,0 +1,52 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.context;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests parsing of naming patters
+ *
+ * @version $Rev$ $Date$
+ */
+public class QualifiedNameTestCase extends TestCase {
+
+ public void testSimpleName() throws Exception {
+ QualifiedName name = new QualifiedName("Foo");
+ assertEquals("Foo", name.getPartName());
+ assertEquals(null, name.getPortName());
+ }
+
+ public void testCompoundName() throws Exception {
+ QualifiedName name = new QualifiedName("Foo/Bar");
+ assertEquals("Foo", name.getPartName());
+ assertEquals("Bar", name.getPortName());
+ }
+
+ public void testCompoundMultiName() throws Exception {
+ QualifiedName name = new QualifiedName("Foo/Bar/Baz");
+ assertEquals("Foo", name.getPartName());
+ assertEquals("Bar/Baz", name.getPortName());
+ }
+
+ public void testInvalidName() throws Exception {
+ try {
+ QualifiedName name = new QualifiedName("/Foo/Bar");
+ fail("Invalid name exception not thrown");
+ } catch (InvalidNameException e) {
+
+ }
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/context/scope/DefaultScopeStrategyTestCase.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/context/scope/DefaultScopeStrategyTestCase.java
new file mode 100644
index 0000000000..2460d32793
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/context/scope/DefaultScopeStrategyTestCase.java
@@ -0,0 +1,52 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.context.scope;
+
+import org.apache.tuscany.model.assembly.Scope;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+/**
+ * Basic scope strategy tests, including downscope referencing
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefaultScopeStrategyTestCase extends TestCase {
+
+ public void testDownScopeReferences() throws Exception{
+ DefaultScopeStrategy strategy = new DefaultScopeStrategy();
+
+ Assert.assertTrue(!strategy.downScopeReference(Scope.MODULE,Scope.MODULE));
+ Assert.assertTrue(strategy.downScopeReference(Scope.MODULE,Scope.SESSION));
+ Assert.assertTrue(strategy.downScopeReference(Scope.MODULE,Scope.REQUEST));
+ Assert.assertTrue(strategy.downScopeReference(Scope.MODULE,Scope.INSTANCE));
+
+ Assert.assertTrue(!strategy.downScopeReference(Scope.SESSION,Scope.MODULE));
+ Assert.assertTrue(!strategy.downScopeReference(Scope.SESSION,Scope.SESSION));
+ Assert.assertTrue(strategy.downScopeReference(Scope.SESSION,Scope.REQUEST));
+ Assert.assertTrue(strategy.downScopeReference(Scope.SESSION,Scope.INSTANCE));
+
+ Assert.assertTrue(!strategy.downScopeReference(Scope.REQUEST,Scope.MODULE));
+ Assert.assertTrue(!strategy.downScopeReference(Scope.REQUEST,Scope.SESSION));
+ Assert.assertTrue(!strategy.downScopeReference(Scope.REQUEST,Scope.REQUEST));
+ Assert.assertTrue(strategy.downScopeReference(Scope.REQUEST,Scope.INSTANCE));
+
+ Assert.assertTrue(!strategy.downScopeReference(Scope.REQUEST,Scope.MODULE));
+ Assert.assertTrue(!strategy.downScopeReference(Scope.REQUEST,Scope.SESSION));
+ Assert.assertTrue(!strategy.downScopeReference(Scope.REQUEST,Scope.REQUEST));
+ Assert.assertTrue(!strategy.downScopeReference(Scope.INSTANCE,Scope.INSTANCE));
+ }
+}
+
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/injection/Bean1.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/injection/Bean1.java
new file mode 100644
index 0000000000..b9bc3a1660
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/injection/Bean1.java
@@ -0,0 +1,26 @@
+package org.apache.tuscany.core.injection;
+
+
+public class Bean1 extends SuperBean {
+
+ public static final int ALL_BEAN1_FIELDS = 3 + ALL_SUPER_FIELDS;
+
+ public static final int ALL__BEAN1_METHODS = 4 + ALL_SUPER_METHODS - 1;
+
+ private String field1;
+
+ public void setMethod1(String param) {
+ }
+
+ public void setMethod1(int param) {
+ }
+
+ public void override(String param) throws Exception {
+ }
+
+
+ public void noOverride(String param) throws Exception {
+ }
+
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/injection/ReflectionHelperTestCase.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/injection/ReflectionHelperTestCase.java
new file mode 100644
index 0000000000..ca1f2012a5
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/injection/ReflectionHelperTestCase.java
@@ -0,0 +1,74 @@
+package org.apache.tuscany.core.injection;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.Set;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.core.config.JavaIntrospectionHelper;
+
+public class ReflectionHelperTestCase extends TestCase {
+
+ public ReflectionHelperTestCase() {
+ super();
+ }
+
+ public ReflectionHelperTestCase(String arg0) {
+ super(arg0);
+ }
+
+ public void testGetSuperAllFields() throws Exception {
+ Set<Field> superBeanFields = JavaIntrospectionHelper.getAllFields(SuperBean.class);
+ Assert.assertEquals(SuperBean.ALL_SUPER_FIELDS, superBeanFields.size());
+ }
+
+ public void testBean1AllFields() throws Exception {
+ Set<Field> beanFields = JavaIntrospectionHelper.getAllFields(Bean1.class);
+ Assert.assertEquals(Bean1.ALL_BEAN1_FIELDS, beanFields.size());
+ }
+
+ public void testGetSuperAllMethods() throws Exception {
+ Set<Method> superBeanMethods = JavaIntrospectionHelper.getAllUniqueMethods(SuperBean.class);
+ Assert.assertEquals(SuperBean.ALL_SUPER_METHODS, superBeanMethods.size());
+ }
+
+ public void testGetBean1AllMethods() throws Exception {
+ Set<Method> beanMethods = JavaIntrospectionHelper.getAllUniqueMethods(Bean1.class);
+ Assert.assertEquals(Bean1.ALL__BEAN1_METHODS, beanMethods.size());
+ }
+
+ public void testOverrideMethod() throws Exception {
+ Set<Method> beanFields = JavaIntrospectionHelper.getAllUniqueMethods(Bean1.class);
+ boolean invoked = false;
+ for (Method method : beanFields) {
+ if (method.getName().equals("override")) {
+ method.invoke(new Bean1(), new Object[]{"foo"});
+ invoked = true;
+ }
+ }
+ if (!invoked) {
+ throw new Exception("Override never invoked");
+ }
+ }
+
+ public void testNoOverrideMethod() throws Exception {
+ Set<Method> beanFields = JavaIntrospectionHelper.getAllUniqueMethods(Bean1.class);
+ boolean found = false;
+ for (Method method : beanFields) {
+ if (method.getName().equals("noOverride") && method.getParameterTypes().length == 0) {
+ found = true;
+ }
+ }
+ if (!found) {
+ throw new Exception("No override not found");
+ }
+ }
+
+ public void testGetBean1AllFields() throws Exception {
+ Set<Field> bean1 = JavaIntrospectionHelper.getAllFields(Bean1.class);
+ Assert.assertEquals(Bean1.ALL_BEAN1_FIELDS, bean1.size());
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/injection/SuperBean.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/injection/SuperBean.java
new file mode 100644
index 0000000000..5d88aeb1a8
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/injection/SuperBean.java
@@ -0,0 +1,27 @@
+package org.apache.tuscany.core.injection;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class SuperBean {
+
+ public static final int ALL_SUPER_FIELDS = 3;
+
+ public static final int ALL_SUPER_METHODS = 4;
+
+ private String superField1;
+
+ public void setSuperMethod1(String param) {
+ }
+
+ public void setSuperMethod1(int param) {
+ }
+
+ public void override(String param) throws Exception {
+ throw new Exception("Override not handled");
+ }
+
+ public void noOverride() throws Exception {
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/InvocationConfigurationErrorTestCase.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/InvocationConfigurationErrorTestCase.java
new file mode 100644
index 0000000000..3d2fe482f1
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/InvocationConfigurationErrorTestCase.java
@@ -0,0 +1,158 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.invocation;
+
+import java.lang.reflect.Method;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.core.invocation.impl.InvokerInterceptor;
+import org.apache.tuscany.core.invocation.impl.MessageChannelImpl;
+import org.apache.tuscany.core.invocation.mock.MockHandler;
+import org.apache.tuscany.core.invocation.mock.MockStaticInvoker;
+import org.apache.tuscany.core.invocation.mock.MockSyncInterceptor;
+import org.apache.tuscany.core.invocation.mock.SimpleTarget;
+import org.apache.tuscany.core.invocation.mock.SimpleTargetImpl;
+import org.apache.tuscany.core.message.Message;
+import org.apache.tuscany.core.message.MessageFactory;
+import org.apache.tuscany.core.message.impl.MessageFactoryImpl;
+
+/**
+ * Tests error propagation through an innvocation
+ *
+ * @version $Rev$ $Date$
+ */
+public class InvocationConfigurationErrorTestCase extends TestCase {
+
+
+ private Method hello;
+ private Method goodbye;
+
+ private MessageFactory factory = new MessageFactoryImpl();
+
+ public InvocationConfigurationErrorTestCase() {
+ super();
+ }
+
+ public InvocationConfigurationErrorTestCase(String arg0) {
+ super(arg0);
+ }
+
+ public void setUp() throws Exception {
+ hello = SimpleTarget.class.getMethod("hello", new Class[]{String.class});
+ goodbye = SimpleTarget.class.getMethod("goodbye", new Class[]{String.class});
+ }
+
+ public void testInvokeWithHandlers() throws Exception{
+ InvocationConfiguration source = new InvocationConfiguration(hello);
+ MockHandler sourceRequestHandler = new MockHandler();
+ MockHandler sourceResponseHandler = new MockHandler();
+ MockSyncInterceptor sourceInterceptor = new MockSyncInterceptor();
+ source.addRequestHandler(sourceRequestHandler);
+ source.addResponseHandler(sourceResponseHandler);
+ source.addSourceInterceptor(sourceInterceptor);
+
+ InvocationConfiguration target = new InvocationConfiguration(hello);
+ MockHandler targetRequestHandler = new MockHandler();
+ MockHandler targetResponseHandler = new MockHandler();
+ MockSyncInterceptor targetInterceptor = new MockSyncInterceptor();
+ target.addRequestHandler(targetRequestHandler);
+ target.addResponseHandler(targetResponseHandler);
+ target.addTargetInterceptor(targetInterceptor);
+ target.addTargetInterceptor(new InvokerInterceptor());
+
+ // connect the source to the target
+ source.setTargetRequestChannel(new MessageChannelImpl(target.getRequestHandlers()));
+ source.setTargetResponseChannel(new MessageChannelImpl(target.getResponseHandlers()));
+ source.build();
+ target.build();
+ MockStaticInvoker invoker = new MockStaticInvoker(hello, new SimpleTargetImpl());
+ source.setTargetInvoker(invoker);
+
+ Message msg = factory.createMessage();
+ msg.setTargetInvoker(invoker);
+ Message response = (Message) source.getSourceInterceptor().invoke(msg);
+ Assert.assertTrue(response.getBody() instanceof IllegalArgumentException);
+ Assert.assertEquals(1,sourceRequestHandler.getCount());
+ Assert.assertEquals(1,sourceResponseHandler.getCount());
+ Assert.assertEquals(1,sourceInterceptor.getCount());
+ Assert.assertEquals(1,targetRequestHandler.getCount());
+ Assert.assertEquals(1,targetResponseHandler.getCount());
+ Assert.assertEquals(1,targetInterceptor.getCount());
+ }
+
+ public void testInvokeWithRequestHandlers() throws Exception{
+ InvocationConfiguration source = new InvocationConfiguration(hello);
+ MockHandler sourceRequestHandler = new MockHandler();
+ MockSyncInterceptor sourceInterceptor = new MockSyncInterceptor();
+ source.addRequestHandler(sourceRequestHandler);
+ source.addSourceInterceptor(sourceInterceptor);
+
+ InvocationConfiguration target = new InvocationConfiguration(hello);
+ MockHandler targetRequestHandler = new MockHandler();
+ MockSyncInterceptor targetInterceptor = new MockSyncInterceptor();
+ target.addRequestHandler(targetRequestHandler);
+ target.addTargetInterceptor(targetInterceptor);
+ target.addTargetInterceptor(new InvokerInterceptor());
+
+ // connect the source to the target
+ source.setTargetRequestChannel(new MessageChannelImpl(target.getRequestHandlers()));
+ source.setTargetResponseChannel(new MessageChannelImpl(target.getResponseHandlers()));
+ source.build();
+ target.build();
+ MockStaticInvoker invoker = new MockStaticInvoker(hello, new SimpleTargetImpl());
+ source.setTargetInvoker(invoker);
+
+ Message msg = factory.createMessage();
+ msg.setTargetInvoker(invoker);
+ Message response = (Message) source.getSourceInterceptor().invoke(msg);
+ Assert.assertTrue(response.getBody() instanceof IllegalArgumentException);
+ Assert.assertEquals(1,sourceRequestHandler.getCount());
+ Assert.assertEquals(1,sourceInterceptor.getCount());
+ Assert.assertEquals(1,targetRequestHandler.getCount());
+ Assert.assertEquals(1,targetInterceptor.getCount());
+ }
+
+ /**
+ * Tests basic wiring of a source to a target, including handlers and interceptors
+ */
+ public void testInvokeWithInterceptorsOnly() throws Exception{
+ InvocationConfiguration source = new InvocationConfiguration(hello);
+ MockSyncInterceptor sourceInterceptor = new MockSyncInterceptor();
+ source.addSourceInterceptor(sourceInterceptor);
+
+ InvocationConfiguration target = new InvocationConfiguration(hello);
+ MockSyncInterceptor targetInterceptor = new MockSyncInterceptor();
+ target.addTargetInterceptor(targetInterceptor);
+ target.addTargetInterceptor(new InvokerInterceptor());
+
+ // connect the source to the target
+ source.addTargetInterceptor(target.getTargetInterceptor());
+ source.build();
+ target.build();
+ MockStaticInvoker invoker = new MockStaticInvoker(hello, new SimpleTargetImpl());
+ source.setTargetInvoker(invoker);
+
+ Message msg = factory.createMessage();
+ msg.setTargetInvoker(invoker);
+ Message response = (Message) source.getSourceInterceptor().invoke(msg);
+ Assert.assertTrue(response.getBody() instanceof IllegalArgumentException);
+ Assert.assertEquals(1,sourceInterceptor.getCount());
+ Assert.assertEquals(1,targetInterceptor.getCount());
+
+ }
+
+}
+
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/InvocationConfigurationTestCase.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/InvocationConfigurationTestCase.java
new file mode 100644
index 0000000000..9e5fb80cad
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/InvocationConfigurationTestCase.java
@@ -0,0 +1,156 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.invocation;
+
+import java.lang.reflect.Method;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.core.invocation.impl.InvokerInterceptor;
+import org.apache.tuscany.core.invocation.impl.MessageChannelImpl;
+import org.apache.tuscany.core.invocation.mock.MockHandler;
+import org.apache.tuscany.core.invocation.mock.MockStaticInvoker;
+import org.apache.tuscany.core.invocation.mock.MockSyncInterceptor;
+import org.apache.tuscany.core.invocation.mock.SimpleTarget;
+import org.apache.tuscany.core.invocation.mock.SimpleTargetImpl;
+import org.apache.tuscany.core.message.Message;
+import org.apache.tuscany.core.message.MessageFactory;
+import org.apache.tuscany.core.message.impl.MessageFactoryImpl;
+
+public class InvocationConfigurationTestCase extends TestCase {
+
+ private Method hello;
+
+ private Method goodbye;
+
+ private MessageFactory factory = new MessageFactoryImpl();
+
+ public InvocationConfigurationTestCase() {
+ super();
+ }
+
+ public InvocationConfigurationTestCase(String arg0) {
+ super(arg0);
+ }
+
+ public void setUp() throws Exception {
+ hello = SimpleTarget.class.getMethod("hello", new Class[] { String.class });
+ goodbye = SimpleTarget.class.getMethod("goodbye", new Class[] { String.class });
+ }
+
+ /**
+ * Tests basic wiring of a source to a target, including handlers and interceptors
+ */
+ public void testInvokeWithHandlers() throws Exception {
+ InvocationConfiguration source = new InvocationConfiguration(hello);
+ MockHandler sourceRequestHandler = new MockHandler();
+ MockHandler sourceResponseHandler = new MockHandler();
+ MockSyncInterceptor sourceInterceptor = new MockSyncInterceptor();
+ source.addRequestHandler(sourceRequestHandler);
+ source.addResponseHandler(sourceResponseHandler);
+ source.addSourceInterceptor(sourceInterceptor);
+
+ InvocationConfiguration target = new InvocationConfiguration(hello);
+ MockHandler targetRequestHandler = new MockHandler();
+ MockHandler targetResponseHandler = new MockHandler();
+ MockSyncInterceptor targetInterceptor = new MockSyncInterceptor();
+ target.addRequestHandler(targetRequestHandler);
+ target.addResponseHandler(targetResponseHandler);
+ target.addTargetInterceptor(targetInterceptor);
+ target.addTargetInterceptor(new InvokerInterceptor());
+
+ // connect the source to the target
+ source.setTargetRequestChannel(new MessageChannelImpl(target.getRequestHandlers()));
+ source.setTargetResponseChannel(new MessageChannelImpl(target.getResponseHandlers()));
+ source.build();
+ target.build();
+ MockStaticInvoker invoker = new MockStaticInvoker(hello, new SimpleTargetImpl());
+ source.setTargetInvoker(invoker);
+
+ Message msg = factory.createMessage();
+ msg.setBody("foo");
+ msg.setTargetInvoker(invoker);
+ Message response = (Message) source.getSourceInterceptor().invoke(msg);
+ Assert.assertEquals("foo", response.getBody());
+ Assert.assertEquals(1, sourceRequestHandler.getCount());
+ Assert.assertEquals(1, sourceResponseHandler.getCount());
+ Assert.assertEquals(1, sourceInterceptor.getCount());
+ Assert.assertEquals(1, targetRequestHandler.getCount());
+ Assert.assertEquals(1, targetResponseHandler.getCount());
+ Assert.assertEquals(1, targetInterceptor.getCount());
+ }
+
+ public void testInvokeWithRequestHandlers() throws Exception {
+ InvocationConfiguration source = new InvocationConfiguration(hello);
+ MockHandler sourceRequestHandler = new MockHandler();
+ MockSyncInterceptor sourceInterceptor = new MockSyncInterceptor();
+ source.addRequestHandler(sourceRequestHandler);
+ source.addSourceInterceptor(sourceInterceptor);
+
+ InvocationConfiguration target = new InvocationConfiguration(hello);
+ MockHandler targetRequestHandler = new MockHandler();
+ MockSyncInterceptor targetInterceptor = new MockSyncInterceptor();
+ target.addRequestHandler(targetRequestHandler);
+ target.addTargetInterceptor(targetInterceptor);
+ target.addTargetInterceptor(new InvokerInterceptor());
+
+ // connect the source to the target
+ source.setTargetRequestChannel(new MessageChannelImpl(target.getRequestHandlers()));
+ source.setTargetResponseChannel(new MessageChannelImpl(target.getResponseHandlers()));
+ source.build();
+ target.build();
+ MockStaticInvoker invoker = new MockStaticInvoker(hello, new SimpleTargetImpl());
+ source.setTargetInvoker(invoker);
+
+ Message msg = factory.createMessage();
+ msg.setBody("foo");
+ msg.setTargetInvoker(invoker);
+ Message response = (Message) source.getSourceInterceptor().invoke(msg);
+ Assert.assertEquals("foo", response.getBody());
+ Assert.assertEquals(1, sourceRequestHandler.getCount());
+ Assert.assertEquals(1, sourceInterceptor.getCount());
+ Assert.assertEquals(1, targetRequestHandler.getCount());
+ Assert.assertEquals(1, targetInterceptor.getCount());
+ }
+
+ /**
+ * Tests basic wiring of a source to a target, including handlers and interceptors
+ */
+ public void testInvokeWithInterceptorsOnly() throws Exception {
+ InvocationConfiguration source = new InvocationConfiguration(hello);
+ MockSyncInterceptor sourceInterceptor = new MockSyncInterceptor();
+ source.addSourceInterceptor(sourceInterceptor);
+
+ InvocationConfiguration target = new InvocationConfiguration(hello);
+ MockSyncInterceptor targetInterceptor = new MockSyncInterceptor();
+ target.addTargetInterceptor(targetInterceptor);
+ target.addTargetInterceptor(new InvokerInterceptor());
+
+ // connect the source to the target
+ source.addTargetInterceptor(target.getTargetInterceptor());
+ source.build();
+ target.build();
+ MockStaticInvoker invoker = new MockStaticInvoker(hello, new SimpleTargetImpl());
+ source.setTargetInvoker(invoker);
+
+ Message msg = factory.createMessage();
+ msg.setBody("foo");
+ msg.setTargetInvoker(invoker);
+ Message response = (Message) source.getSourceInterceptor().invoke(msg);
+ Assert.assertEquals("foo", response.getBody());
+ Assert.assertEquals(1, sourceInterceptor.getCount());
+ Assert.assertEquals(1, targetInterceptor.getCount());
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/InvocationErrorTestCase.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/InvocationErrorTestCase.java
new file mode 100644
index 0000000000..02929c9193
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/InvocationErrorTestCase.java
@@ -0,0 +1,124 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.invocation;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.core.invocation.impl.InvokerInterceptor;
+import org.apache.tuscany.core.invocation.jdk.JDKInvocationHandler;
+import org.apache.tuscany.core.invocation.mock.MockHandler;
+import org.apache.tuscany.core.invocation.mock.MockStaticInvoker;
+import org.apache.tuscany.core.invocation.mock.MockSyncInterceptor;
+import org.apache.tuscany.core.message.impl.MessageFactoryImpl;
+
+/**
+ * Tests handling of exceptions thrown during an invocation
+ *
+ * @version $Rev: 377006 $ $Date: 2006-02-11 09:41:59 -0800 (Sat, 11 Feb 2006) $
+ */
+public class InvocationErrorTestCase extends TestCase {
+
+ private Method checkedMethod;
+ private Method runtimeMethod;
+
+ public InvocationErrorTestCase() {
+ super();
+ }
+
+ public InvocationErrorTestCase(String arg0) {
+ super(arg0);
+ }
+
+ public void setUp() throws Exception {
+ checkedMethod = TestBean.class.getDeclaredMethod("checkedException", (Class[]) null);
+ runtimeMethod = TestBean.class.getDeclaredMethod("runtimeException", (Class[]) null);
+ Assert.assertNotNull(checkedMethod);
+ Assert.assertNotNull(runtimeMethod);
+ }
+
+ public void testCheckedException() throws Exception {
+ Map<Method, InvocationConfiguration> config = new MethodHashMap();
+ config.put(checkedMethod, getConfiguration(checkedMethod));
+ InvocationHandler handler = new JDKInvocationHandler(new MessageFactoryImpl(), config);
+ try {
+ TestBean proxy = (TestBean) Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(),
+ new Class[]{TestBean.class}, handler);
+ proxy.checkedException();
+ } catch (TestException e) {
+ return;
+ }
+ Assert.fail(TestException.class.getName() + " should have been thrown");
+ }
+
+ public void testRuntimeException() throws Exception {
+ Map<Method, InvocationConfiguration> config = new MethodHashMap();
+ config.put(runtimeMethod, getConfiguration(runtimeMethod));
+ InvocationHandler handler = new JDKInvocationHandler(new MessageFactoryImpl(), config);
+ try {
+ TestBean proxy = (TestBean) Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(),
+ new Class[]{TestBean.class}, handler);
+ proxy.runtimeException();
+ } catch (TestRuntimeException e) {
+ return;
+ }
+ Assert.fail(TestException.class.getName() + " should have been thrown");
+ }
+
+ private InvocationConfiguration getConfiguration(Method m) {
+ MockStaticInvoker invoker = new MockStaticInvoker(m, new TestBeanImpl());
+ InvocationConfiguration invocationConfiguration=new InvocationConfiguration(m);
+ invocationConfiguration.addSourceInterceptor(new MockSyncInterceptor());
+ invocationConfiguration.addRequestHandler(new MockHandler());
+ invocationConfiguration.setTargetInvoker(invoker);
+ invocationConfiguration.addTargetInterceptor(new InvokerInterceptor());
+ invocationConfiguration.build();
+ return invocationConfiguration;
+ }
+
+ public interface TestBean {
+
+ public void checkedException() throws TestException;
+
+ public void runtimeException() throws TestRuntimeException;
+
+ }
+
+ public class TestBeanImpl implements TestBean {
+
+ public void checkedException() throws TestException {
+ throw new TestException();
+ }
+
+ public void runtimeException() throws TestRuntimeException {
+ throw new TestRuntimeException();
+ }
+ }
+
+ public class TestException extends Exception {
+ }
+
+ public class TestRuntimeException extends RuntimeException {
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/jdk/JDKInvocationHandlerTestCase.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/jdk/JDKInvocationHandlerTestCase.java
new file mode 100644
index 0000000000..758134fbba
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/jdk/JDKInvocationHandlerTestCase.java
@@ -0,0 +1,112 @@
+package org.apache.tuscany.core.invocation.jdk;
+
+import java.lang.reflect.Method;
+import java.util.Map;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.core.invocation.InvocationConfiguration;
+import org.apache.tuscany.core.invocation.MethodHashMap;
+import org.apache.tuscany.core.invocation.impl.InvokerInterceptor;
+import org.apache.tuscany.core.invocation.impl.MessageChannelImpl;
+import org.apache.tuscany.core.invocation.mock.MockHandler;
+import org.apache.tuscany.core.invocation.mock.MockStaticInvoker;
+import org.apache.tuscany.core.invocation.mock.MockSyncInterceptor;
+import org.apache.tuscany.core.invocation.mock.SimpleTarget;
+import org.apache.tuscany.core.invocation.mock.SimpleTargetImpl;
+import org.apache.tuscany.core.message.impl.MessageFactoryImpl;
+
+public class JDKInvocationHandlerTestCase extends TestCase {
+
+ private Method hello;
+
+ private Method goodbye;
+
+ public JDKInvocationHandlerTestCase() {
+ super();
+ }
+
+ public JDKInvocationHandlerTestCase(String arg0) {
+ super(arg0);
+ }
+
+ public void setUp() throws Exception {
+ hello = SimpleTarget.class.getMethod("hello", new Class[] { String.class });
+ goodbye = SimpleTarget.class.getMethod("goodbye", new Class[] { String.class });
+ }
+
+ public void testBasicInvoke() throws Throwable {
+ Map<Method, InvocationConfiguration> configs = new MethodHashMap();
+ configs.put(hello, getInvocationHandler(hello));
+ JDKInvocationHandler handler = new JDKInvocationHandler(new MessageFactoryImpl(), configs);
+ Assert.assertEquals("foo", handler.invoke(null, hello, new Object[] { "foo" }));
+ }
+
+ public void testErrorInvoke() throws Throwable {
+ Map<Method, InvocationConfiguration> configs = new MethodHashMap();
+ configs.put(hello, getInvocationHandler(hello));
+ JDKInvocationHandler handler = new JDKInvocationHandler(new MessageFactoryImpl(), configs);
+ try {
+ Assert.assertEquals("foo", handler.invoke(null, hello, new Object[] {}));
+ fail("Expected " + IllegalArgumentException.class.getName());
+ } catch (IllegalArgumentException e) {
+ // should throw
+ }
+ }
+
+ public void testDirectErrorInvoke() throws Throwable {
+ InvocationConfiguration source = new InvocationConfiguration(hello);
+ MockStaticInvoker invoker = new MockStaticInvoker(hello, new SimpleTargetImpl());
+ source.setTargetInvoker(invoker);
+
+ Map<Method, InvocationConfiguration> configs = new MethodHashMap();
+ configs.put(hello, source);
+ JDKInvocationHandler handler = new JDKInvocationHandler(new MessageFactoryImpl(), configs);
+ try {
+ Assert.assertEquals("foo", handler.invoke(null, hello, new Object[] {}));
+ fail("Expected " + IllegalArgumentException.class.getName());
+ } catch (IllegalArgumentException e) {
+ // should throw
+ }
+ }
+
+ public void testDirectInvoke() throws Throwable {
+ InvocationConfiguration source = new InvocationConfiguration(hello);
+ MockStaticInvoker invoker = new MockStaticInvoker(hello, new SimpleTargetImpl());
+ source.setTargetInvoker(invoker);
+
+ Map<Method, InvocationConfiguration> configs = new MethodHashMap();
+ configs.put(hello, source);
+ JDKInvocationHandler handler = new JDKInvocationHandler(new MessageFactoryImpl(), configs);
+ Assert.assertEquals("foo", handler.invoke(null, hello, new Object[] { "foo" }));
+ }
+
+ private InvocationConfiguration getInvocationHandler(Method m) {
+ InvocationConfiguration source = new InvocationConfiguration(m);
+ MockHandler sourceRequestHandler = new MockHandler();
+ MockHandler sourceResponseHandler = new MockHandler();
+ MockSyncInterceptor sourceInterceptor = new MockSyncInterceptor();
+ source.addRequestHandler(sourceRequestHandler);
+ source.addResponseHandler(sourceResponseHandler);
+ source.addSourceInterceptor(sourceInterceptor);
+
+ InvocationConfiguration target = new InvocationConfiguration(m);
+ MockHandler targetRequestHandler = new MockHandler();
+ MockHandler targetResponseHandler = new MockHandler();
+ MockSyncInterceptor targetInterceptor = new MockSyncInterceptor();
+ target.addRequestHandler(targetRequestHandler);
+ target.addResponseHandler(targetResponseHandler);
+ target.addTargetInterceptor(targetInterceptor);
+ target.addTargetInterceptor(new InvokerInterceptor());
+
+ // connect the source to the target
+ source.setTargetRequestChannel(new MessageChannelImpl(target.getRequestHandlers()));
+ source.setTargetResponseChannel(new MessageChannelImpl(target.getResponseHandlers()));
+ source.build();
+ target.build();
+ MockStaticInvoker invoker = new MockStaticInvoker(m, new SimpleTargetImpl());
+ source.setTargetInvoker(invoker);
+ return source;
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/jdk/JDKProxyFactoryTestCase.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/jdk/JDKProxyFactoryTestCase.java
new file mode 100644
index 0000000000..98853a1469
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/jdk/JDKProxyFactoryTestCase.java
@@ -0,0 +1,66 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.invocation.jdk;
+
+import java.lang.reflect.Method;
+import java.util.Map;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.core.context.QualifiedName;
+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.mock.MockStaticInvoker;
+import org.apache.tuscany.core.invocation.mock.MockSyncInterceptor;
+import org.apache.tuscany.core.invocation.mock.SimpleTarget;
+import org.apache.tuscany.core.invocation.mock.SimpleTargetImpl;
+import org.apache.tuscany.core.message.impl.MessageFactoryImpl;
+
+public class JDKProxyFactoryTestCase extends TestCase {
+
+ private Method hello;
+
+ private Method goodbye;
+
+ public JDKProxyFactoryTestCase(String arg0) {
+ super(arg0);
+ }
+
+ public void setUp() throws Exception {
+ hello = SimpleTarget.class.getMethod("hello", new Class[] { String.class });
+ goodbye = SimpleTarget.class.getMethod("goodbye", new Class[] { String.class });
+ }
+
+ public void testProxyFactory() throws Exception {
+ InvocationConfiguration source = new InvocationConfiguration(hello);
+ MockSyncInterceptor sourceInterceptor = new MockSyncInterceptor();
+ source.addSourceInterceptor(sourceInterceptor);
+ source.addTargetInterceptor(new InvokerInterceptor());
+ source.setTargetInvoker(new MockStaticInvoker(hello, new SimpleTargetImpl()));
+ source.build();
+ Map<Method, InvocationConfiguration> configs = new MethodHashMap();
+ configs.put(hello, source);
+ ProxyConfiguration config = new ProxyConfiguration(new QualifiedName("foo"), configs, Thread.currentThread()
+ .getContextClassLoader(), new MessageFactoryImpl());
+ JDKProxyFactory factory = new JDKProxyFactory();
+ factory.setProxyConfiguration(config);
+ factory.setBusinessInterface(SimpleTarget.class);
+ factory.initialize();
+ SimpleTarget instance = (SimpleTarget) factory.createProxy();
+ Assert.assertEquals("foo",instance.hello("foo"));
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/mock/MockHandler.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/mock/MockHandler.java
new file mode 100644
index 0000000000..ec52bee002
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/mock/MockHandler.java
@@ -0,0 +1,25 @@
+/**
+ *
+ */
+package org.apache.tuscany.core.invocation.mock;
+
+import org.apache.tuscany.core.invocation.MessageHandler;
+import org.apache.tuscany.core.message.Message;
+
+/**
+ *
+ */
+public class MockHandler implements MessageHandler {
+
+ private int count =0;
+
+ public boolean processMessage(Message message) {
+ //System.out.println("Invoking handler");
+ count++;
+ return true;
+ }
+
+ public int getCount(){
+ return count;
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/mock/MockScopeContext.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/mock/MockScopeContext.java
new file mode 100644
index 0000000000..ec8a95d4be
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/mock/MockScopeContext.java
@@ -0,0 +1,136 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.invocation.mock;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.core.builder.RuntimeConfiguration;
+import org.apache.tuscany.core.context.InstanceContext;
+import org.apache.tuscany.core.context.EventException;
+import org.apache.tuscany.core.context.QualifiedName;
+import org.apache.tuscany.core.context.LifecycleEventListener;
+import org.apache.tuscany.core.context.ScopeContext;
+import org.apache.tuscany.core.context.ScopeRuntimeException;
+import org.apache.tuscany.core.context.SimpleComponentContext;
+import org.apache.tuscany.core.context.TargetException;
+import org.apache.tuscany.model.assembly.SimpleComponent;
+
+public class MockScopeContext implements ScopeContext {
+
+ Map<String, Object> components;
+
+ public MockScopeContext() {
+ components = new HashMap();
+ components.put("foo", new SimpleTargetImpl());
+ components.put("bar", new SimpleTargetImpl());
+ }
+
+ public MockScopeContext(Map<String,Object> instances) {
+ components = instances;
+ }
+
+
+ public void start() {
+ }
+
+ public void stop() {
+ }
+
+ public String getName() {
+ return "Mock Scope Container";
+ }
+
+ public boolean isCacheable() {
+ return false;
+ }
+
+ public int[] getEventTypes() {
+ return null;
+ }
+
+ public SimpleComponentContext getContext(String name) {
+ return null;
+ }
+
+ public Object getInstance(QualifiedName name) throws ScopeRuntimeException {
+ return components.get(name.getPartName());
+ }
+
+ public Object getInstance(QualifiedName componentName, boolean notify) throws TargetException {
+ return getInstance(componentName);
+ }
+
+ public SimpleComponentContext getContextByKey(String name, Object key) {
+ return null;
+ }
+
+ public void setComponent(SimpleComponent component) throws ScopeRuntimeException {
+ }
+
+ public void removeContext(String name) throws ScopeRuntimeException {
+ }
+
+ public void removeContextByKey(String name, Object key) throws ScopeRuntimeException {
+ }
+
+ public SimpleComponent[] getComponents() {
+ return null;
+ }
+
+ public void onEvent(int type, Object message) throws EventException {
+ }
+
+
+ public void registerConfigurations(List<RuntimeConfiguration<InstanceContext>> configurations) {
+ }
+
+ public void registerConfiguration(RuntimeConfiguration<InstanceContext> configuration) {
+ }
+
+ public int getLifecycleState(){
+ return RUNNING;
+ }
+
+
+ public void setLifecycleState(int state) {
+ }
+
+
+ public void setName(String name) {
+ }
+
+
+ public void addContextListener(LifecycleEventListener listener) {
+ }
+
+
+ public void removeContextListener(LifecycleEventListener listener) {
+ }
+
+ public Object getImplementationInstance() throws TargetException{
+ return this;
+ }
+
+ public Object getImplementationInstance(boolean notify) throws TargetException{
+ return this;
+ }
+
+
+}
+
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/mock/MockStaticInvoker.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/mock/MockStaticInvoker.java
new file mode 100644
index 0000000000..27b3594ab7
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/mock/MockStaticInvoker.java
@@ -0,0 +1,70 @@
+package org.apache.tuscany.core.invocation.mock;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.core.invocation.Interceptor;
+import org.apache.tuscany.core.invocation.InvocationRuntimeException;
+import org.apache.tuscany.core.invocation.TargetInvoker;
+import org.apache.tuscany.core.message.Message;
+
+/**
+ * Caches component instances that do not need to be resolved for every invocation, e.g. an invocation originating from
+ * a lesser scope intended for a target with a wider scope
+ *
+ * @version $Rev: 377006 $ $Date: 2006-02-11 09:41:59 -0800 (Sat, 11 Feb 2006) $
+ */
+public class MockStaticInvoker implements TargetInvoker {
+
+ private Object instance;
+
+ private Method operation;
+
+ public MockStaticInvoker(Method operation, Object instance) {
+ this.operation = operation;
+ this.instance = instance;
+ }
+
+ public boolean isCacheable() {
+ return true;
+ }
+
+ public Object invokeTarget(Object payload) throws InvocationTargetException {
+ try {
+ if (payload != null && !payload.getClass().isArray()) {
+ return operation.invoke(instance, payload);
+ } else {
+ return operation.invoke(instance, (Object[]) payload);
+ }
+ } catch (IllegalAccessException e) {
+ throw new InvocationRuntimeException(e);
+ }
+ }
+
+ 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 IllegalStateException("This interceptor must be the last interceptor in an interceptor chain");
+ }
+
+ public Object clone() {
+ try {
+ MockStaticInvoker invoker = (MockStaticInvoker) super.clone();
+ invoker.instance = this.instance;
+ invoker.operation = this.operation;
+ return invoker;
+ } catch (CloneNotSupportedException e) {
+ return null; // will not happen
+ }
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/mock/MockSyncInterceptor.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/mock/MockSyncInterceptor.java
new file mode 100644
index 0000000000..120b7654cd
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/mock/MockSyncInterceptor.java
@@ -0,0 +1,45 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.invocation.mock;
+
+import org.apache.tuscany.core.invocation.Interceptor;
+import org.apache.tuscany.core.message.Message;
+
+public class MockSyncInterceptor implements Interceptor {
+
+ private int count;
+
+ private Interceptor next;
+
+ public MockSyncInterceptor() {
+ }
+
+ public Message invoke(Message msg) {
+ ++count;
+ //System.out.println("Invoking interceptor");
+ return next.invoke(msg);
+ }
+
+ public int getCount() {
+ return count;
+ }
+
+ public void setNext(Interceptor next) {
+ this.next=next;
+ }
+}
+
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/mock/SimpleSource.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/mock/SimpleSource.java
new file mode 100644
index 0000000000..5a68024f2a
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/mock/SimpleSource.java
@@ -0,0 +1,25 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.invocation.mock;
+
+public interface SimpleSource {
+
+ public void invokeHello() throws Exception;
+
+ public void invokeGoodbye() throws Exception;
+}
+
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/mock/SimpleSourceImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/mock/SimpleSourceImpl.java
new file mode 100644
index 0000000000..51025ba3a0
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/mock/SimpleSourceImpl.java
@@ -0,0 +1,36 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.invocation.mock;
+
+public class SimpleSourceImpl implements SimpleSource {
+
+ private SimpleTarget proxy;
+
+ public SimpleSourceImpl(SimpleTarget proxy) {
+ this.proxy = proxy;
+ }
+
+ public void invokeHello() throws Exception {
+ proxy.hello("hello");
+ }
+
+ public void invokeGoodbye() throws Exception {
+ proxy.goodbye("hello");
+ }
+
+}
+
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/mock/SimpleTarget.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/mock/SimpleTarget.java
new file mode 100644
index 0000000000..e4aabd72a2
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/mock/SimpleTarget.java
@@ -0,0 +1,28 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.invocation.mock;
+
+public interface SimpleTarget {
+
+ public String hello(String message) throws Exception;
+
+ public String goodbye(String message) throws Exception;
+
+ public String echo(String message) throws Exception;
+
+}
+
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/mock/SimpleTargetImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/mock/SimpleTargetImpl.java
new file mode 100644
index 0000000000..16f70c020f
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/mock/SimpleTargetImpl.java
@@ -0,0 +1,39 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.invocation.mock;
+
+public class SimpleTargetImpl implements SimpleTarget {
+
+ public SimpleTargetImpl() {
+ super();
+ }
+
+ public String hello(String message) throws Exception {
+ return message;
+ }
+
+ public String goodbye(String message) throws Exception {
+ return message;
+ }
+
+ public String echo(String message) throws Exception {
+ return message;
+ }
+
+
+}
+
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/mock/MockConfigContext.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/mock/MockConfigContext.java
new file mode 100644
index 0000000000..f7ed7654d6
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/mock/MockConfigContext.java
@@ -0,0 +1,56 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.mock;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.core.builder.BuilderConfigException;
+import org.apache.tuscany.core.builder.RuntimeConfigurationBuilder;
+import org.apache.tuscany.core.builder.impl.AssemblyVisitor;
+import org.apache.tuscany.core.config.ConfigurationException;
+import org.apache.tuscany.core.context.AggregateContext;
+import org.apache.tuscany.core.context.ConfigurationContext;
+import org.apache.tuscany.core.context.ScopeContext;
+import org.apache.tuscany.core.invocation.spi.ProxyFactory;
+import org.apache.tuscany.model.assembly.Extensible;
+
+/**
+ * A mock configuration context
+ *
+ * @version $Rev$ $Date$
+ */
+public class MockConfigContext implements ConfigurationContext {
+
+ private List<RuntimeConfigurationBuilder> builders = new ArrayList();
+
+ public MockConfigContext(List<RuntimeConfigurationBuilder> builders) {
+ this.builders=builders;
+ }
+
+ public void configure(Extensible model) throws ConfigurationException {
+ }
+
+ public void build(AggregateContext parent, Extensible model) throws BuilderConfigException {
+ AssemblyVisitor visitor = new AssemblyVisitor(parent, builders);
+ visitor.start(model);
+ }
+
+ public void wire(ProxyFactory sourceFactory, ProxyFactory targetFactory, Class targetType, boolean downScope, ScopeContext targetScopeContext) throws BuilderConfigException {
+ }
+
+ public void wire(ProxyFactory targetFactory, Class targetType, ScopeContext targetScopeContext) throws BuilderConfigException {
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/mock/MockFactory.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/mock/MockFactory.java
new file mode 100644
index 0000000000..dca6e337f1
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/mock/MockFactory.java
@@ -0,0 +1,329 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.mock;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.core.builder.RuntimeConfigurationBuilder;
+import org.apache.tuscany.core.context.AggregateContext;
+import org.apache.tuscany.core.context.impl.AggregateContextImpl;
+import org.apache.tuscany.core.mock.component.ModuleScopeSystemComponent;
+import org.apache.tuscany.core.mock.component.ModuleScopeSystemComponentImpl;
+import org.apache.tuscany.core.system.assembly.SystemAssemblyFactory;
+import org.apache.tuscany.core.system.assembly.SystemBinding;
+import org.apache.tuscany.core.system.assembly.SystemImplementation;
+import org.apache.tuscany.core.system.assembly.impl.SystemAssemblyFactoryImpl;
+import org.apache.tuscany.core.system.builder.SystemComponentContextBuilder;
+import org.apache.tuscany.core.system.builder.SystemEntryPointBuilder;
+import org.apache.tuscany.core.system.builder.SystemExternalServiceBuilder;
+import org.apache.tuscany.core.system.context.SystemAggregateContextImpl;
+import org.apache.tuscany.model.assembly.AggregatePart;
+import org.apache.tuscany.model.assembly.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.Component;
+import org.apache.tuscany.model.assembly.ConfiguredReference;
+import org.apache.tuscany.model.assembly.ConfiguredService;
+import org.apache.tuscany.model.assembly.EntryPoint;
+import org.apache.tuscany.model.assembly.ExternalService;
+import org.apache.tuscany.model.assembly.Module;
+import org.apache.tuscany.model.assembly.Reference;
+import org.apache.tuscany.model.assembly.Scope;
+import org.apache.tuscany.model.assembly.Service;
+import org.apache.tuscany.model.assembly.SimpleComponent;
+import org.apache.tuscany.model.assembly.impl.AssemblyModelContextImpl;
+import org.apache.tuscany.model.types.java.JavaServiceContract;
+
+/**
+ * Generates test components, modules, and runtime artifacts
+ *
+ * @version $Rev$ $Date$
+ */
+public class MockFactory {
+
+ private static SystemAssemblyFactory systemFactory = new SystemAssemblyFactoryImpl();
+
+ private static AssemblyModelContext assemblyContext = new AssemblyModelContextImpl(systemFactory, null, null);
+
+ private MockFactory() {
+ }
+
+
+ /**
+ * Creates a system component of the given type with the given name and scope
+ */
+ public static Component createSystemComponent(String name, Class type, Scope scope) {
+
+ Component sc = null;
+ if (AggregateContext.class.isAssignableFrom(type)) {
+ sc = systemFactory.createModuleComponent();
+ } else {
+ sc = systemFactory.createSimpleComponent();
+ }
+ SystemImplementation impl = systemFactory.createSystemImplementation();
+ impl.setImplementationClass(type);
+ sc.setComponentImplementation(impl);
+ Service s = systemFactory.createService();
+ JavaServiceContract ji = systemFactory.createJavaServiceContract();
+ s.setServiceContract(ji);
+ ji.setScope(scope);
+ impl.setComponentType(systemFactory.createComponentType());
+ impl.getComponentType().getServices().add(s);
+ sc.setName(name);
+ sc.setComponentImplementation(impl);
+ return sc;
+ }
+
+ /**
+ * Creates an aggregate component with the given name
+ */
+ public static Component createAggregateComponent(String name) {
+ Component sc = sc = systemFactory.createModuleComponent();
+ SystemImplementation impl = systemFactory.createSystemImplementation();
+ impl.setImplementationClass(AggregateContextImpl.class);
+ sc.setComponentImplementation(impl);
+ Service s = systemFactory.createService();
+ JavaServiceContract ji = systemFactory.createJavaServiceContract();
+ s.setServiceContract(ji);
+ ji.setScope(Scope.AGGREGATE);
+ impl.setComponentType(systemFactory.createComponentType());
+ impl.getComponentType().getServices().add(s);
+ sc.setName(name);
+ sc.setComponentImplementation(impl);
+ return sc;
+ }
+
+ /**
+ * Creates an aggregate component with the given name
+ */
+ public static Component createSystemAggregateComponent(String name) {
+ Component sc = sc = systemFactory.createModuleComponent();
+ SystemImplementation impl = systemFactory.createSystemImplementation();
+ impl.setImplementationClass(SystemAggregateContextImpl.class);
+ sc.setComponentImplementation(impl);
+ Service s = systemFactory.createService();
+ JavaServiceContract ji = systemFactory.createJavaServiceContract();
+ s.setServiceContract(ji);
+ ji.setScope(Scope.AGGREGATE);
+ impl.setComponentType(systemFactory.createComponentType());
+ impl.getComponentType().getServices().add(s);
+ sc.setName(name);
+ sc.setComponentImplementation(impl);
+ return sc;
+ }
+
+ /**
+ * Creates and initializes a system component of the given type with the given name and scope
+ */
+ public static Component createSystemInitializedComponent(String name, Class type, Scope scope) {
+ Component sc = createSystemComponent(name,type,scope);
+ sc.initialize(assemblyContext);
+ return sc;
+ }
+
+ /**
+ * Creates a basic entry point with no configured reference using the system binding
+ *
+ * @param name the name of the entry point
+ * @param interfaz the inteface exposed by the entry point
+ * @param refName the name of the entry point reference
+ */
+ public static EntryPoint createEPSystemBinding(String name, Class interfaz, String refName) {
+ return createEPSystemBinding(name, interfaz, refName, null);
+ }
+
+ /**
+ * Creates an entry point wired to the given target (e.g. component, external service) using the system binding
+ *
+ * @param name the name of the entry point
+ * @param interfaz the inteface exposed by the entry point
+ * @param refName the name of the entry point reference
+ * @param target the target the entry point is wired to
+ */
+ public static EntryPoint createEPSystemBinding(String name, Class interfaz, String refName, AggregatePart target) {
+ JavaServiceContract contract = systemFactory.createJavaServiceContract();
+ contract.setInterface(interfaz);
+
+ EntryPoint ep = systemFactory.createEntryPoint();
+ ep.setName(name);
+
+ Reference ref = systemFactory.createReference();
+ ref.setName(refName);
+ ref.setServiceContract(contract);
+ ConfiguredReference configuredReference = systemFactory.createConfiguredReference();
+ configuredReference.setReference(ref);
+ Service service = systemFactory.createService();
+ service.setServiceContract(contract);
+
+ ConfiguredService cService = systemFactory.createConfiguredService();
+ cService.setService(service);
+ cService.initialize(assemblyContext);
+
+ configuredReference.getTargetConfiguredServices().add(cService);
+ ep.setConfiguredReference(configuredReference);
+
+ Service epService = systemFactory.createService();
+ epService.setServiceContract(contract);
+
+ ConfiguredService epCService = systemFactory.createConfiguredService();
+ epCService.initialize(assemblyContext);
+ epCService.setService(epService);
+
+ ep.setConfiguredService(epCService);
+ SystemBinding binding = systemFactory.createSystemBinding();
+ ep.getBindings().add(binding);
+ if (target != null) {
+ if (target instanceof Component) {
+ ((Component) target).getConfiguredServices().add(cService);
+ // cService.
+ } else if (target instanceof ExternalService) {
+ ((ExternalService) target).setConfiguredService(cService);
+ }
+ target.initialize(assemblyContext);
+ }
+ ep.initialize(null);
+ return ep;
+ }
+
+ /**
+ * Creates an entry point that should be wired to the given target (e.g. component, external service) using the
+ * system binding. The system assembly process should resolve the target name to an actual target configuration.
+ *
+ * @param name the name of the entry point
+ * @param interfaz the inteface exposed by the entry point
+ * @param refName the name of the entry point reference
+ * @param componentName the name of the target to resolve
+ */
+ public static EntryPoint createEntryPointWithStringRef(String name, Class interfaz, String refName, String componentName) {
+ EntryPoint ep = createEPSystemBinding(name, interfaz, refName, null);
+ ConfiguredReference cRef = systemFactory.createConfiguredReference();
+ Reference ref = systemFactory.createReference();
+ cRef.setReference(ref);
+ Service service = systemFactory.createService();
+ service.setName(componentName);
+ ConfiguredService cService = systemFactory.createConfiguredService();
+ cService.setService(service);
+ cRef.getTargetConfiguredServices().add(cService);
+ cRef.initialize(assemblyContext);
+ cService.initialize(assemblyContext);
+ ep.setConfiguredReference(cRef);
+ ep.initialize(assemblyContext);
+ return ep;
+ }
+
+ /**
+ * Creates an external service configured with a {@link SystemBinding}
+ */
+ public static ExternalService createESSystemBinding(String name, String refName) {
+ ExternalService es = systemFactory.createExternalService();
+ es.setName(name);
+ ConfiguredService configuredService = systemFactory.createConfiguredService();
+ es.setConfiguredService(configuredService);
+ SystemBinding binding = systemFactory.createSystemBinding();
+ binding.setTargetName(refName);
+ es.getBindings().add(binding);
+ es.initialize(null);
+ return es;
+ }
+
+ /**
+ * Creates an external service that specifies an autowire of the given type
+ */
+ public static ExternalService createAutowirableExternalService(String name, Class type) {
+ ExternalService es = systemFactory.createExternalService();
+ es.setName(name);
+ JavaServiceContract inter = systemFactory.createJavaServiceContract();
+ inter.setInterface(type);
+ Service service = systemFactory.createService();
+ service.setServiceContract(inter);
+ ConfiguredService cService = systemFactory.createConfiguredService();
+ cService.setService(service);
+ cService.initialize(assemblyContext);
+ es.setConfiguredService(cService);
+ es.getBindings().add(systemFactory.createSystemBinding());
+ es.initialize(null);
+ return es;
+ }
+
+ /**
+ * Creates a test system module component with a module-scoped component and entry point
+ */
+ public static Module createSystemModule(){
+ Module module = systemFactory.createModule();
+ module.setName("system.module");
+
+ // create test component
+ SimpleComponent component = systemFactory.createSimpleComponent();
+ component.setName("TestService1");
+ SystemImplementation impl = systemFactory.createSystemImplementation();
+ impl.setComponentType(systemFactory.createComponentType());
+ impl.setImplementationClass(ModuleScopeSystemComponentImpl.class);
+ component.setComponentImplementation(impl);
+ Service s = systemFactory.createService();
+ JavaServiceContract contract = systemFactory.createJavaServiceContract();
+ s.setServiceContract(contract);
+ contract.setScope(Scope.MODULE);
+ impl.getComponentType().getServices().add(s);
+ component.setComponentImplementation(impl);
+
+ // create the entry point
+ EntryPoint ep = createEPSystemBinding("TestService1EP", ModuleScopeSystemComponent.class, "target", component);
+
+ module.getEntryPoints().add(ep);
+ module.getComponents().add(component);
+ module.initialize(assemblyContext);
+ return module;
+ }
+
+ /**
+ * Creates a test system module component with a module-scoped component and entry point
+ */
+ public static Module createSystemChildModule() {
+ Module module = systemFactory.createModule();
+ module.setName("system.test.module");
+
+ // create test component
+ SimpleComponent component = systemFactory.createSimpleComponent();
+ component.setName("TestService2");
+ SystemImplementation impl = systemFactory.createSystemImplementation();
+ impl.setImplementationClass(ModuleScopeSystemComponentImpl.class);
+ component.setComponentImplementation(impl);
+ Service s = systemFactory.createService();
+ JavaServiceContract ji = systemFactory.createJavaServiceContract();
+ s.setServiceContract(ji);
+ ji.setScope(Scope.MODULE);
+ impl.setComponentType(systemFactory.createComponentType());
+ impl.getComponentType().getServices().add(s);
+ component.setComponentImplementation(impl);
+
+ // create the entry point
+ EntryPoint ep = createEPSystemBinding("TestService2EP", ModuleScopeSystemComponent.class, "target", component);
+
+ module.getEntryPoints().add(ep);
+ module.getComponents().add(component);
+ module.initialize(assemblyContext);
+ return module;
+ }
+
+ /**
+ * Returns a collection of bootstrap configuration builders
+ */
+ public static List<RuntimeConfigurationBuilder> createSystemBuilders() {
+ List<RuntimeConfigurationBuilder> builders = new ArrayList();
+ builders.add((new SystemComponentContextBuilder()));
+ builders.add(new SystemEntryPointBuilder());
+ builders.add(new SystemExternalServiceBuilder());
+ return builders;
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/mock/component/GenericSystemComponent.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/mock/component/GenericSystemComponent.java
new file mode 100644
index 0000000000..99aeb1b8f3
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/mock/component/GenericSystemComponent.java
@@ -0,0 +1,6 @@
+package org.apache.tuscany.core.mock.component;
+
+public interface GenericSystemComponent {
+
+}
+
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/mock/component/ModuleScopeSystemComponent.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/mock/component/ModuleScopeSystemComponent.java
new file mode 100644
index 0000000000..dabbd9e4ef
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/mock/component/ModuleScopeSystemComponent.java
@@ -0,0 +1,28 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.mock.component;
+
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * @version $Rev$ $Date$
+ */
+@Scope("MODULE")
+public interface ModuleScopeSystemComponent extends GenericSystemComponent {
+
+}
+
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/mock/component/ModuleScopeSystemComponentImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/mock/component/ModuleScopeSystemComponentImpl.java
new file mode 100644
index 0000000000..58afde9354
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/mock/component/ModuleScopeSystemComponentImpl.java
@@ -0,0 +1,25 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.mock.component;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ModuleScopeSystemComponentImpl implements ModuleScopeSystemComponent {
+
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/runtime/RuntimeBootTestCase.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/runtime/RuntimeBootTestCase.java
new file mode 100644
index 0000000000..a0af27f563
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/runtime/RuntimeBootTestCase.java
@@ -0,0 +1,96 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.runtime;
+
+import java.util.List;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.common.monitor.impl.NullMonitorFactory;
+import org.apache.tuscany.core.builder.RuntimeConfigurationBuilder;
+import org.apache.tuscany.core.context.AggregateContext;
+import org.apache.tuscany.core.context.Context;
+import org.apache.tuscany.core.context.EventContext;
+import org.apache.tuscany.core.mock.MockFactory;
+
+/**
+ * Tests runtime boot scenarios
+ *
+ * @version $Rev$ $Date$
+ */
+public class RuntimeBootTestCase extends TestCase {
+ private RuntimeContext runtime;
+
+ public void testContextParents() {
+ AggregateContext rootContext = runtime.getRootContext();
+ assertNotNull(rootContext);
+ assertEquals("tuscany.root", rootContext.getName());
+ assertSame(runtime, rootContext.getParent());
+ assertSame(rootContext, runtime.getContext("tuscany.root"));
+
+ AggregateContext systemContext = runtime.getSystemContext();
+ assertNotNull(systemContext);
+ assertEquals("tuscany.system", systemContext.getName());
+ assertSame(runtime, systemContext.getParent());
+ assertSame(systemContext, runtime.getContext("tuscany.system"));
+ }
+
+ public void testRuntimeLifecycle() {
+ assertEquals(Context.RUNNING, runtime.getLifecycleState());
+ runtime.stop();
+
+ assertEquals(Context.STOPPED, runtime.getLifecycleState());
+
+ runtime.start();
+ assertEquals(Context.RUNNING, runtime.getLifecycleState());
+ }
+
+ public void testIncrementalBoot() throws Exception{
+
+ List<RuntimeConfigurationBuilder> builders = MockFactory.createSystemBuilders();
+ // start the runtime context
+ RuntimeContext runtimeContext = new RuntimeContextImpl(new NullMonitorFactory(), null, builders, null);
+ runtimeContext.start();
+
+ AggregateContext system = runtimeContext.getSystemContext();
+ Assert.assertNotNull(system);
+ // register system components
+ system.registerModelObject(MockFactory.createSystemModule());
+ // start the module scope
+ system.fireEvent(EventContext.MODULE_START, null);
+ // register the first module
+
+ // register the second module
+
+ // start the modules
+
+ system.fireEvent(EventContext.MODULE_STOP, null);
+ runtimeContext.stop();
+ Assert.assertEquals(Context.STOPPED,system.getLifecycleState());
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ runtime = new RuntimeContextImpl();
+ runtime.start();
+ }
+
+ protected void tearDown() throws Exception {
+ runtime.stop();
+ super.tearDown();
+ }
+}
+
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/runtime/RuntimeContextImplTestCase.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/runtime/RuntimeContextImplTestCase.java
new file mode 100644
index 0000000000..0ea1ad7bb8
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/runtime/RuntimeContextImplTestCase.java
@@ -0,0 +1,305 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.runtime;
+
+import java.util.List;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.common.monitor.impl.NullMonitorFactory;
+import org.apache.tuscany.core.builder.RuntimeConfigurationBuilder;
+import org.apache.tuscany.core.config.ConfigurationException;
+import org.apache.tuscany.core.context.AggregateContext;
+import org.apache.tuscany.core.context.Context;
+import org.apache.tuscany.core.context.EventContext;
+import org.apache.tuscany.core.context.impl.AggregateContextImpl;
+import org.apache.tuscany.core.mock.MockFactory;
+import org.apache.tuscany.core.mock.component.ModuleScopeSystemComponent;
+import org.apache.tuscany.core.mock.component.ModuleScopeSystemComponentImpl;
+import org.apache.tuscany.core.system.assembly.SystemAssemblyFactory;
+import org.apache.tuscany.core.system.assembly.impl.SystemAssemblyFactoryImpl;
+import org.apache.tuscany.core.system.context.TestBuilder;
+import org.apache.tuscany.model.assembly.Component;
+import org.apache.tuscany.model.assembly.ConfiguredService;
+import org.apache.tuscany.model.assembly.EntryPoint;
+import org.apache.tuscany.model.assembly.ExternalService;
+import org.apache.tuscany.model.assembly.Scope;
+import org.apache.tuscany.model.assembly.Service;
+import org.apache.tuscany.model.types.java.JavaServiceContract;
+import org.osoa.sca.ServiceUnavailableException;
+
+/**
+ * Performs basic tests on the runtime context
+ *
+ * @version $Rev$ $Date$
+ */
+public class RuntimeContextImplTestCase extends TestCase {
+
+ private SystemAssemblyFactory systemFactory = new SystemAssemblyFactoryImpl();
+
+ private List<RuntimeConfigurationBuilder> builders;
+
+ /**
+ * Tests explicit wiring of an external service to a system entry point that is wired to a child system module entry
+ * point
+ */
+ public void testSystemExplicitWiring() throws Exception {
+ RuntimeContext runtime = new RuntimeContextImpl(new NullMonitorFactory(), null, builders, null);
+ runtime.start();
+
+ AggregateContext root = runtime.getRootContext();
+ Assert.assertNotNull(root);
+ Assert.assertTrue(root.getLifecycleState() == Context.RUNNING);
+
+ AggregateContext system = runtime.getSystemContext();
+ Assert.assertNotNull(system);
+ system.registerModelObject(MockFactory.createSystemModule());
+
+ // register a child system context
+ system.registerModelObject(MockFactory.createSystemAggregateComponent("system.child"));
+ AggregateContext systemChild = (AggregateContext) system.getContext("system.child");
+ systemChild.registerModelObject(MockFactory.createSystemChildModule());
+
+ // register a top-level system entry point that exposes the child entry point
+ EntryPoint ep = MockFactory.createEPSystemBinding("TestService2EP", ModuleScopeSystemComponent.class, "ref");
+ ep.getBindings().add(systemFactory.createSystemBinding());
+ Service service = systemFactory.createService();
+ service.setName("system.child/TestService2EP");
+ ((ConfiguredService) ep.getConfiguredReference().getTargetConfiguredServices().get(0)).setService(service);
+ JavaServiceContract inter = systemFactory.createJavaServiceContract();
+ inter.setInterface(ModuleScopeSystemComponentImpl.class);
+ service.setServiceContract(inter);
+ system.registerModelObject(ep);
+ system.fireEvent(EventContext.MODULE_START, null);
+ Assert.assertNotNull(system.locateInstance("TestService1"));
+ Assert.assertNotNull(system.locateInstance("TestService2EP"));
+
+ // create a test module and wire an external service to the system entry point
+ Component moduleComponent = MockFactory.createAggregateComponent("test.module");
+ runtime.registerModelObject(moduleComponent);
+ AggregateContextImpl moduleContext = (AggregateContextImpl) runtime.getContext("test.module");
+ Assert.assertNotNull(moduleContext);
+ ExternalService es = MockFactory.createESSystemBinding("TestService2ES", "tuscany.system/TestService2EP");
+ moduleContext.registerModelObject(es);
+ moduleContext.fireEvent(EventContext.MODULE_START, null);
+ Assert.assertNotNull(moduleContext.locateInstance("TestService2ES"));
+
+ moduleContext.fireEvent(EventContext.MODULE_STOP, null);
+ system.fireEvent(EventContext.MODULE_STOP, null);
+ runtime.stop();
+ }
+
+ /**
+ * Tests autowiring an external service to a system entry point
+ */
+ public void testSystemAutoWiring() throws Exception {
+ RuntimeContext runtime = new RuntimeContextImpl(new NullMonitorFactory(), null, builders, null);
+ runtime.start();
+
+ AggregateContext root = runtime.getRootContext();
+ Assert.assertNotNull(root);
+ Assert.assertTrue(root.getLifecycleState() == Context.RUNNING);
+
+ AggregateContext system = runtime.getSystemContext();
+ Assert.assertNotNull(system);
+ system.registerModelObject(MockFactory.createSystemModule());
+
+ // create a test module and wire an external service to the system entry point
+ Component moduleComponent = MockFactory.createAggregateComponent("test.module");
+ runtime.registerModelObject(moduleComponent);
+ AggregateContextImpl moduleContext = (AggregateContextImpl) runtime.getContext("test.module");
+ Assert.assertNotNull(moduleContext);
+ ExternalService es = MockFactory.createAutowirableExternalService("TestService2ES", ModuleScopeSystemComponent.class);
+ moduleContext.registerModelObject(es);
+
+ system.fireEvent(EventContext.MODULE_START, null);
+ moduleContext.fireEvent(EventContext.MODULE_START, null);
+ // test that the autowire was resolved
+ Assert.assertNotNull(moduleContext.locateInstance("TestService2ES"));
+
+ moduleContext.fireEvent(EventContext.MODULE_STOP, null);
+ system.fireEvent(EventContext.MODULE_STOP, null);
+ runtime.stop();
+ }
+
+ public void testServiceNotFound() throws Exception {
+ RuntimeContext runtime = new RuntimeContextImpl(new NullMonitorFactory(), null, builders, null);
+ runtime.start();
+
+ // create a test module
+ Component moduleComponent = MockFactory.createAggregateComponent("module");
+ runtime.registerModelObject(moduleComponent);
+ AggregateContextImpl moduleContext = (AggregateContextImpl) runtime.getContext("module");
+ moduleContext.fireEvent(EventContext.MODULE_START, null);
+ try {
+ moduleContext.locateService("TestService");
+ fail("Expected " + ServiceUnavailableException.class.getName());
+ } catch (ServiceUnavailableException e) {
+ // expected
+ }
+ moduleContext.fireEvent(EventContext.MODULE_STOP, null);
+ runtime.stop();
+ }
+
+ public void testExternalServiceReferenceNotFound() throws Exception {
+ RuntimeContext runtime = new RuntimeContextImpl(new NullMonitorFactory(), null, builders, null);
+ runtime.start();
+ AggregateContext system = runtime.getSystemContext();
+
+ // create a test module
+ Component moduleComponent = MockFactory.createAggregateComponent("module");
+ runtime.registerModelObject(moduleComponent);
+ AggregateContextImpl moduleContext = (AggregateContextImpl) runtime.getContext("module");
+ ExternalService es = MockFactory.createESSystemBinding("TestServiceES", "tuscany.system/TestService1xEP");
+ moduleContext.registerModelObject(es);
+
+ // start the modules and test inter-module system wires
+ system.fireEvent(EventContext.MODULE_START, null);
+ moduleContext.fireEvent(EventContext.MODULE_START, null);
+ try {
+ moduleContext.locateService("TestServiceES");
+ fail("Expected " + ServiceUnavailableException.class.getName());
+ } catch (ServiceUnavailableException e) {
+ // expected
+ }
+ moduleContext.fireEvent(EventContext.MODULE_STOP, null);
+ system.fireEvent(EventContext.MODULE_STOP, null);
+ runtime.stop();
+ }
+
+ public void testEntryPointReferenceNotFound() throws Exception {
+ RuntimeContext runtime = new RuntimeContextImpl(new NullMonitorFactory(), null, builders, null);
+ runtime.start();
+
+ // create a test module
+ Component moduleComponent = MockFactory.createAggregateComponent("module");
+ runtime.registerModelObject(moduleComponent);
+
+ Component component = MockFactory.createSystemComponent("NoService", ModuleScopeSystemComponentImpl.class, Scope.MODULE);
+ // do not register the above component!
+
+ AggregateContextImpl moduleContext = (AggregateContextImpl) runtime.getContext("module");
+ moduleContext.registerModelObject(MockFactory.createEPSystemBinding("TestServiceEP", ModuleScopeSystemComponent.class,
+ "NoReference", component));
+
+ moduleContext.fireEvent(EventContext.MODULE_START, null);
+ try {
+ moduleContext.locateService("TestServiceEP");
+ fail("Expected " + ServiceUnavailableException.class.getName());
+ } catch (ServiceUnavailableException e) {
+ // expected
+ }
+ moduleContext.fireEvent(EventContext.MODULE_STOP, null);
+ runtime.stop();
+ }
+
+ /**
+ * Test two module components that have external services wired to entry points contained in each
+ */
+ public void testCircularWires() throws Exception {
+ RuntimeContext runtime = new RuntimeContextImpl(new NullMonitorFactory(), null, builders, null);
+ runtime.start();
+
+ // create a test modules
+ Component module1 = MockFactory.createAggregateComponent("module1");
+ runtime.registerModelObject(module1);
+ Component module2 = MockFactory.createAggregateComponent("module2");
+ runtime.registerModelObject(module2);
+
+ AggregateContextImpl moduleContext1 = (AggregateContextImpl) runtime.getContext("module1");
+ AggregateContextImpl moduleContext2 = (AggregateContextImpl) runtime.getContext("module2");
+
+ Component component1 = MockFactory.createSystemComponent("Component1", ModuleScopeSystemComponentImpl.class,
+ Scope.MODULE);
+ EntryPoint entryPoint1 = MockFactory.createEPSystemBinding("EntryPoint1", ModuleScopeSystemComponent.class, "Component1",
+ component1);
+ ExternalService externalService1 = MockFactory.createESSystemBinding("ExternalService1", "module2/EntryPoint2");
+ moduleContext1.registerModelObject(component1);
+ moduleContext1.registerModelObject(entryPoint1);
+ moduleContext1.registerModelObject(externalService1);
+
+ Component component2 = MockFactory.createSystemComponent("Component2", ModuleScopeSystemComponentImpl.class,
+ Scope.MODULE);
+ EntryPoint entryPoint2 = MockFactory.createEPSystemBinding("EntryPoint2", ModuleScopeSystemComponent.class, "Component2",
+ component2);
+ ExternalService externalService2 = MockFactory.createESSystemBinding("ExternalService2", "module1/EntryPoint1");
+ moduleContext2.registerModelObject(component2);
+ moduleContext2.registerModelObject(entryPoint2);
+ moduleContext2.registerModelObject(externalService2);
+
+ moduleContext1.fireEvent(EventContext.MODULE_START, null);
+ moduleContext2.fireEvent(EventContext.MODULE_START, null);
+ Assert.assertNotNull(moduleContext2.locateInstance("ExternalService2"));
+ Assert.assertNotNull(moduleContext1.locateInstance("ExternalService1"));
+ runtime.stop();
+ }
+
+ /**
+ * Tests that a circular reference between an external service in one module and an entry point in another is caught
+ * as an error condition FIXME this must be implemented
+ */
+ public void testInterModuleCircularReference() throws Exception {
+ RuntimeContext runtime = new RuntimeContextImpl(new NullMonitorFactory(), null, builders, null);
+ runtime.start();
+
+ // create a test modules
+ Component module1 = MockFactory.createAggregateComponent("module1");
+ runtime.registerModelObject(module1);
+ Component module2 = MockFactory.createAggregateComponent("module2");
+ runtime.registerModelObject(module2);
+
+ AggregateContextImpl moduleContext1 = (AggregateContextImpl) runtime.getContext("module1");
+ AggregateContextImpl moduleContext2 = (AggregateContextImpl) runtime.getContext("module2");
+ ExternalService externalService1 = MockFactory.createESSystemBinding("ExternalService1", "module2/EntryPoint2");
+ EntryPoint entryPoint1 = MockFactory.createEPSystemBinding("EntryPoint1", ModuleScopeSystemComponent.class,
+ "ExternalService1", externalService1);
+ ExternalService externalService2 = MockFactory.createESSystemBinding("ExternalService2", "module1/EntryPoint1");
+ EntryPoint entryPoint2 = MockFactory.createEPSystemBinding("EntryPoint2", ModuleScopeSystemComponent.class,
+ "ExternalService2", externalService2);
+ try {
+ // FIXME this should throw a circular reference exception
+ moduleContext1.registerModelObject(externalService1);
+ moduleContext1.registerModelObject(entryPoint1);
+ moduleContext2.registerModelObject(externalService2);
+ moduleContext2.registerModelObject(entryPoint2);
+ // FIXME implement fail("Expected " + ConfigurationException.class.getName());
+ } catch (ConfigurationException e) {
+ // expected
+ }
+ }
+
+ public void testRuntimeBuilderAutowire() throws Exception {
+
+ RuntimeContext runtime = new RuntimeContextImpl(new NullMonitorFactory(), null, builders, null);
+ runtime.start();
+
+ AggregateContext system = runtime.getSystemContext();
+ Component builder = MockFactory.createSystemComponent("TestBuilder", TestBuilder.class, Scope.MODULE);
+ system.registerModelObject(builder);
+ system.fireEvent(EventContext.MODULE_START, null);
+ Component module1 = MockFactory.createAggregateComponent("module1");
+ runtime.registerModelObject(module1);
+ runtime.getContext("module1");
+ Assert.assertTrue(((TestBuilder) system.locateInstance("TestBuilder")).invoked());
+ system.fireEvent(EventContext.MODULE_STOP, null);
+ runtime.stop();
+
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ builders = MockFactory.createSystemBuilders();
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/system/builder/SystemComponentContextBuilderTestCase.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/system/builder/SystemComponentContextBuilderTestCase.java
new file mode 100644
index 0000000000..c73554a1df
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/system/builder/SystemComponentContextBuilderTestCase.java
@@ -0,0 +1,137 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.system.builder;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.common.monitor.impl.NullMonitorFactory;
+import org.apache.tuscany.core.builder.RuntimeConfiguration;
+import org.apache.tuscany.core.context.AggregateContext;
+import org.apache.tuscany.core.context.InstanceContext;
+import org.apache.tuscany.core.context.impl.AggregateContextImpl;
+import org.apache.tuscany.core.context.impl.EventContextImpl;
+import org.apache.tuscany.core.context.scope.DefaultScopeStrategy;
+import org.apache.tuscany.core.mock.MockConfigContext;
+import org.apache.tuscany.core.mock.MockFactory;
+import org.apache.tuscany.core.system.assembly.SystemAssemblyFactory;
+import org.apache.tuscany.core.system.assembly.impl.SystemAssemblyFactoryImpl;
+import org.apache.tuscany.model.assembly.Component;
+import org.apache.tuscany.model.assembly.ConfiguredProperty;
+import org.apache.tuscany.model.assembly.Property;
+import org.apache.tuscany.model.assembly.Scope;
+
+/**
+ * Tests to that system components are built properly
+ *
+ * @version $Rev$ $Date$
+ */
+public class SystemComponentContextBuilderTestCase extends TestCase {
+
+ private SystemAssemblyFactory factory = new SystemAssemblyFactoryImpl();
+
+ public void testComponentContextBuilder() throws Exception {
+ SystemComponentContextBuilder builder = new SystemComponentContextBuilder();
+ Component component = MockFactory.createSystemComponent("test", SystemComponentImpl.class,
+ Scope.AGGREGATE);
+
+ ConfiguredProperty cProp = factory.createConfiguredProperty();
+ Property prop = factory.createProperty();
+ prop.setName("testInt");
+ cProp.setValue(1);
+ cProp.setProperty(prop);
+ component.getConfiguredProperties().add(cProp);
+
+ cProp = factory.createConfiguredProperty();
+ prop = factory.createProperty();
+ prop.setName("testString");
+ cProp.setValue("test");
+ cProp.setProperty(prop);
+ component.getConfiguredProperties().add(cProp);
+
+ cProp = factory.createConfiguredProperty();
+ prop = factory.createProperty();
+ prop.setName("testDouble");
+ cProp.setValue(1d);
+ cProp.setProperty(prop);
+ component.getConfiguredProperties().add(cProp);
+
+ cProp = factory.createConfiguredProperty();
+ prop = factory.createProperty();
+ prop.setName("testFloat");
+ cProp.setValue(1f);
+ cProp.setProperty(prop);
+ component.getConfiguredProperties().add(cProp);
+
+ cProp = factory.createConfiguredProperty();
+ prop = factory.createProperty();
+ prop.setName("testShort");
+ cProp.setValue((short) 1);
+ cProp.setProperty(prop);
+ component.getConfiguredProperties().add(cProp);
+
+ cProp = factory.createConfiguredProperty();
+ prop = factory.createProperty();
+ prop.setName("testByte");
+ cProp.setValue((byte) 1);
+ cProp.setProperty(prop);
+ component.getConfiguredProperties().add(cProp);
+
+ cProp = factory.createConfiguredProperty();
+ prop = factory.createProperty();
+ prop.setName("testBoolean");
+ cProp.setValue(Boolean.TRUE);
+ cProp.setProperty(prop);
+ component.getConfiguredProperties().add(cProp);
+
+ cProp = factory.createConfiguredProperty();
+ prop = factory.createProperty();
+ prop.setName("testChar");
+ cProp.setValue('1');
+ cProp.setProperty(prop);
+ component.getConfiguredProperties().add(cProp);
+
+ builder.build(component, createContext());
+ RuntimeConfiguration config = (RuntimeConfiguration) component.getComponentImplementation().getRuntimeConfiguration();
+ Assert.assertNotNull(config);
+ InstanceContext ctx = (InstanceContext) config.createInstanceContext();
+
+ ctx.start();
+ SystemComponentImpl instance = (SystemComponentImpl) ctx.getInstance(null);
+ Assert.assertNotNull(instance.getConfigContext());
+ Assert.assertNotNull(instance.getParentContext());
+ Assert.assertNotNull(instance.getAutowireContext());
+ Assert.assertNotNull(instance.getConfigContextSetter());
+ Assert.assertNotNull(instance.getParentContextSetter());
+ Assert.assertNotNull(instance.getAutowireContextSetter());
+ Assert.assertEquals(1, instance.getTestInt());
+ Assert.assertEquals(1d, instance.getTestDouble());
+ Assert.assertEquals(1f, instance.getTestFloat());
+ Assert.assertEquals((short) 1, instance.getTestShort());
+ Assert.assertTrue(instance.getTestBoolean());
+ Assert.assertEquals('1', instance.getTestChar());
+ Assert.assertEquals((byte) 1, instance.getTestByte());
+ Assert.assertEquals("test", instance.getTestString());
+
+ Assert.assertTrue(instance.initialized());
+ ctx.stop();
+ Assert.assertTrue(instance.destroyed());
+ }
+
+ private static AggregateContext createContext() {
+ return new AggregateContextImpl("test.parent", null, new DefaultScopeStrategy(), new EventContextImpl(),
+ new MockConfigContext(null), new NullMonitorFactory());
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/system/builder/SystemComponentImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/system/builder/SystemComponentImpl.java
new file mode 100644
index 0000000000..b86f79e504
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/system/builder/SystemComponentImpl.java
@@ -0,0 +1,165 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.system.builder;
+
+import org.apache.tuscany.core.context.AggregateContext;
+import org.apache.tuscany.core.context.AutowireContext;
+import org.apache.tuscany.core.context.ConfigurationContext;
+import org.apache.tuscany.core.system.annotation.Autowire;
+import org.apache.tuscany.core.system.annotation.ParentContext;
+import org.osoa.sca.annotations.Destroy;
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Property;
+
+/**
+ * A system component used for unit testing
+ *
+ * @version $Rev$ $Date$
+ */
+public class SystemComponentImpl {
+
+ @Autowire
+ private ConfigurationContext ctx;
+
+ @ParentContext
+ private AggregateContext parent;
+
+ @Autowire
+ private AutowireContext autowireCtx;
+
+ private ConfigurationContext ctxSetter;
+
+ private AggregateContext parentSetter;
+
+ private AutowireContext autowireCtxSetter;
+
+ public ConfigurationContext getConfigContext() {
+ return ctx;
+ }
+
+ public AggregateContext getParentContext() {
+ return parent;
+ }
+
+ public AutowireContext getAutowireContext() {
+ return autowireCtx;
+ }
+
+ @Autowire
+ public void setConfigContext(ConfigurationContext configCtx) {
+ ctxSetter = configCtx;
+ }
+
+ public ConfigurationContext getConfigContextSetter() {
+ return ctxSetter;
+ }
+
+ @ParentContext
+ public void setParentContex(AggregateContext ctx) {
+ parentSetter = ctx;
+ }
+
+ public AggregateContext getParentContextSetter() {
+ return parentSetter;
+ }
+
+ @Autowire
+ public void setAutowireContext(AutowireContext ctx) {
+ autowireCtxSetter = ctx;
+ }
+
+ public AutowireContext getAutowireContextSetter() {
+ return autowireCtx;
+ }
+
+ private boolean inited;
+
+ @Init
+ public void init(){
+ inited=true;
+ }
+
+ public boolean initialized(){
+ return (inited == true);
+ }
+
+ private boolean destroyed;
+
+ @Destroy
+ public void destroy(){
+ destroyed=true;
+ }
+
+ public boolean destroyed(){
+ return (destroyed == true);
+ }
+
+ @Property
+ private int testInt;
+
+ public int getTestInt(){
+ return testInt;
+ }
+
+ @Property
+ private double testDouble;
+
+ public double getTestDouble(){
+ return testDouble;
+ }
+
+ @Property
+ private float testFloat;
+
+ public float getTestFloat(){
+ return testFloat;
+ }
+
+ @Property
+ private short testShort;
+
+ public short getTestShort(){
+ return testShort;
+ }
+
+ @Property
+ private boolean testBoolean;
+
+ public boolean getTestBoolean(){
+ return testBoolean;
+ }
+
+ @Property
+ private byte testByte;
+
+ public byte getTestByte(){
+ return testByte;
+ }
+
+ @Property
+ private char testChar;
+
+ public char getTestChar(){
+ return testChar;
+ }
+
+ @Property
+ private String testString;
+
+ public String getTestString(){
+ return testString;
+ }
+
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/system/builder/impl/AssemblyVisitorTestCase.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/system/builder/impl/AssemblyVisitorTestCase.java
new file mode 100644
index 0000000000..fe3d7f222b
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/system/builder/impl/AssemblyVisitorTestCase.java
@@ -0,0 +1,123 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.system.builder.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.common.resource.ResourceLoader;
+import org.apache.tuscany.common.resource.impl.ResourceLoaderImpl;
+import org.apache.tuscany.core.builder.BuilderException;
+import org.apache.tuscany.core.builder.RuntimeConfigurationBuilder;
+import org.apache.tuscany.core.builder.impl.AssemblyVisitor;
+import org.apache.tuscany.core.context.Context;
+import org.apache.tuscany.core.mock.component.ModuleScopeSystemComponent;
+import org.apache.tuscany.core.system.assembly.SystemAssemblyFactory;
+import org.apache.tuscany.core.system.assembly.SystemBinding;
+import org.apache.tuscany.core.system.assembly.SystemImplementation;
+import org.apache.tuscany.core.system.assembly.impl.SystemAssemblyFactoryImpl;
+import org.apache.tuscany.model.assembly.AssemblyFactory;
+import org.apache.tuscany.model.assembly.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.AssemblyModelObject;
+import org.apache.tuscany.model.assembly.Component;
+import org.apache.tuscany.model.assembly.ConfiguredPort;
+import org.apache.tuscany.model.assembly.ConfiguredReference;
+import org.apache.tuscany.model.assembly.ConfiguredService;
+import org.apache.tuscany.model.assembly.EntryPoint;
+import org.apache.tuscany.model.assembly.Module;
+import org.apache.tuscany.model.assembly.Reference;
+import org.apache.tuscany.model.assembly.RuntimeConfigurationHolder;
+import org.apache.tuscany.model.assembly.Service;
+import org.apache.tuscany.model.assembly.impl.AssemblyFactoryImpl;
+import org.apache.tuscany.model.assembly.impl.AssemblyModelContextImpl;
+import org.apache.tuscany.model.assembly.loader.AssemblyModelLoader;
+import org.apache.tuscany.model.scdl.loader.impl.SCDLAssemblyModelLoaderImpl;
+import org.apache.tuscany.model.types.java.JavaServiceContract;
+
+/**
+ * Tests decorating a logical configuration model
+ *
+ * @version $Rev$ $Date$
+ */
+public class AssemblyVisitorTestCase extends TestCase {
+
+ private static final Object MARKER = new Object();
+
+ private SystemAssemblyFactory factory = new SystemAssemblyFactoryImpl();
+ private AssemblyModelContext assemblyContext = new AssemblyModelContextImpl(factory, null, null);
+
+ public void testModelVisit() throws Exception {
+
+ Component component = factory.createSimpleComponent();
+ SystemImplementation impl = factory.createSystemImplementation();
+ impl.setComponentType(factory.createComponentType());
+ component.setComponentImplementation(impl);
+ ConfiguredReference cRef = factory.createConfiguredReference();
+ Reference ref = factory.createReference();
+ cRef.setReference(ref);
+ component.getConfiguredReferences().add(cRef);
+
+ EntryPoint ep = factory.createEntryPoint();
+ JavaServiceContract contract = factory.createJavaServiceContract();
+ contract.setInterface(ModuleScopeSystemComponent.class);
+ Service service = factory.createService();
+ service.setServiceContract(contract);
+ ConfiguredService cService = factory.createConfiguredService();
+ cService.setService(service);
+ cService.initialize(assemblyContext);
+ ep.setConfiguredService(cService);
+ SystemBinding binding = factory.createSystemBinding();
+ ep.getBindings().add(binding);
+ ConfiguredReference cEpRef = factory.createConfiguredReference();
+ Reference epRef = factory.createReference();
+ cEpRef.setReference(epRef);
+ ep.setConfiguredReference(cEpRef);
+
+ ep.initialize(assemblyContext);
+ Module module = factory.createModule();
+ module.getComponents().add(component);
+ module.getEntryPoints().add(ep);
+
+ List<RuntimeConfigurationBuilder> builders = new ArrayList();
+ builders.add(new TestBuilder());
+ AssemblyVisitor visitor = new AssemblyVisitor(null, builders);
+ module.initialize(assemblyContext);
+ visitor.start(module);
+
+ Assert.assertSame(MARKER, impl.getRuntimeConfiguration());
+ Assert.assertSame(MARKER, cRef.getRuntimeConfiguration());
+ Assert.assertSame(MARKER, cRef.getProxyFactory());
+ Assert.assertSame(MARKER, binding.getRuntimeConfiguration());
+ Assert.assertSame(MARKER, cEpRef.getRuntimeConfiguration());
+ Assert.assertSame(MARKER, cEpRef.getProxyFactory());
+ Assert.assertSame(MARKER, module.getRuntimeConfiguration());
+
+ }
+
+ private static class TestBuilder implements RuntimeConfigurationBuilder {
+ public void build(AssemblyModelObject model, Context context) throws BuilderException {
+ if (model instanceof ConfiguredPort) {
+ ((ConfiguredPort) model).setProxyFactory(MARKER);
+ }
+ if (model instanceof RuntimeConfigurationHolder) {
+ ((RuntimeConfigurationHolder) model).setRuntimeConfiguration(MARKER);
+ }
+ }
+
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/system/context/SystemAggregateComponentContextRegisterTestCase.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/system/context/SystemAggregateComponentContextRegisterTestCase.java
new file mode 100644
index 0000000000..40feca3b7c
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/system/context/SystemAggregateComponentContextRegisterTestCase.java
@@ -0,0 +1,40 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.system.context;
+
+import java.util.List;
+
+import org.apache.tuscany.core.builder.RuntimeConfigurationBuilder;
+import org.apache.tuscany.core.context.AggregateComponentContextRegisterTestCase;
+import org.apache.tuscany.core.context.AggregateContext;
+import org.apache.tuscany.core.context.impl.EventContextImpl;
+import org.apache.tuscany.core.context.scope.DefaultScopeStrategy;
+import org.apache.tuscany.core.mock.MockConfigContext;
+import org.apache.tuscany.core.mock.MockFactory;
+import org.apache.tuscany.common.monitor.impl.NullMonitorFactory;
+
+/**
+ * Tests registration of model objects for an system aggregate context
+ *
+ * @version $Rev$ $Date$
+ */
+public class SystemAggregateComponentContextRegisterTestCase extends AggregateComponentContextRegisterTestCase {
+
+ protected AggregateContext createContext() {
+ List<RuntimeConfigurationBuilder> builders = MockFactory.createSystemBuilders();
+ AggregateContext moduleContext = new SystemAggregateContextImpl("test.context", null,
+ null, new DefaultScopeStrategy(), new EventContextImpl(), new MockConfigContext(builders), new NullMonitorFactory());
+ return moduleContext;
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/system/context/SystemAggregateComponentContextTestCase.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/system/context/SystemAggregateComponentContextTestCase.java
new file mode 100644
index 0000000000..55fd6502f0
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/system/context/SystemAggregateComponentContextTestCase.java
@@ -0,0 +1,127 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.system.context;
+
+import java.util.List;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.common.monitor.impl.NullMonitorFactory;
+import org.apache.tuscany.core.builder.RuntimeConfigurationBuilder;
+import org.apache.tuscany.core.context.AggregateContext;
+import org.apache.tuscany.core.context.EventContext;
+import org.apache.tuscany.core.context.impl.EventContextImpl;
+import org.apache.tuscany.core.mock.MockConfigContext;
+import org.apache.tuscany.core.mock.MockFactory;
+import org.apache.tuscany.core.mock.component.ModuleScopeSystemComponent;
+import org.apache.tuscany.core.mock.component.ModuleScopeSystemComponentImpl;
+import org.apache.tuscany.model.assembly.Component;
+import org.apache.tuscany.model.assembly.EntryPoint;
+import org.apache.tuscany.model.assembly.Scope;
+
+/**
+ * Tests the system aggregate context
+ *
+ * @version $Rev$ $Date$
+ */
+public class SystemAggregateComponentContextTestCase extends TestCase {
+
+ public void testChildLocate() throws Exception {
+ List<RuntimeConfigurationBuilder> builders = MockFactory.createSystemBuilders();
+
+ SystemAggregateContextImpl system = new SystemAggregateContextImpl("system", null, null, new SystemScopeStrategy(),
+ new EventContextImpl(), new MockConfigContext(builders), new NullMonitorFactory());
+ system.start();
+
+ Component aggregateComponent = MockFactory.createAggregateComponent("system.child");
+ system.registerModelObject(aggregateComponent);
+ AggregateContext childContext = (AggregateContext) system.getContext("system.child");
+ Assert.assertNotNull(childContext);
+
+ Component component = MockFactory.createSystemComponent("TestService1", ModuleScopeSystemComponentImpl.class,
+ Scope.MODULE);
+ EntryPoint ep = MockFactory.createEPSystemBinding("TestService1EP", ModuleScopeSystemComponent.class, "TestService1",
+ component);
+ childContext.registerModelObject(component);
+ childContext.registerModelObject(ep);
+ childContext.fireEvent(EventContext.MODULE_START, null);
+ Assert.assertNotNull(system.locateInstance("system.child/TestService1EP"));
+ childContext.fireEvent(EventContext.MODULE_STOP, null);
+ system.stop();
+ }
+
+ public void testAutowire() throws Exception {
+ List<RuntimeConfigurationBuilder> builders = MockFactory.createSystemBuilders();
+ SystemAggregateContextImpl system = new SystemAggregateContextImpl("system", null, null, new SystemScopeStrategy(),
+ new EventContextImpl(), new MockConfigContext(builders), new NullMonitorFactory());
+
+ Component component = MockFactory.createSystemComponent("TestService1", ModuleScopeSystemComponentImpl.class,
+ Scope.MODULE);
+ EntryPoint ep = MockFactory.createEPSystemBinding("TestService1EP", ModuleScopeSystemComponent.class, "TestService1",
+ component);
+ system.registerModelObject(component);
+ system.registerModelObject(ep);
+ system.start();
+ system.fireEvent(EventContext.MODULE_START, null);
+ Assert.assertSame(system.locateInstance("TestService1EP"), system.resolveInstance(ModuleScopeSystemComponent.class));
+ system.fireEvent(EventContext.MODULE_STOP, null);
+ system.stop();
+ }
+
+ public void testAutowireRegisterAfterStart() throws Exception {
+ List<RuntimeConfigurationBuilder> builders = MockFactory.createSystemBuilders();
+
+ SystemAggregateContextImpl system = new SystemAggregateContextImpl("system", null, null, new SystemScopeStrategy(),
+ new EventContextImpl(), new MockConfigContext(builders), new NullMonitorFactory());
+
+ Component component = MockFactory.createSystemComponent("TestService1", ModuleScopeSystemComponentImpl.class,
+ Scope.MODULE);
+ system.registerModelObject(component);
+ system.start();
+ system.fireEvent(EventContext.MODULE_START, null);
+ EntryPoint ep = MockFactory.createEPSystemBinding("TestService1EP", ModuleScopeSystemComponent.class, "TestService1",
+ component);
+ system.registerModelObject(ep);
+ Assert.assertSame(system.locateInstance("TestService1EP"), system.resolveInstance(ModuleScopeSystemComponent.class));
+ system.fireEvent(EventContext.MODULE_STOP, null);
+ system.stop();
+ }
+
+ public void testAutowireModuleRegister() throws Exception {
+ List<RuntimeConfigurationBuilder> builders = MockFactory.createSystemBuilders();
+
+ SystemAggregateContextImpl system = new SystemAggregateContextImpl("system", null, null, new SystemScopeStrategy(),
+ new EventContextImpl(), new MockConfigContext(builders), new NullMonitorFactory());
+ system.registerModelObject(MockFactory.createSystemModule());
+ system.start();
+ system.fireEvent(EventContext.MODULE_START, null);
+ Assert.assertSame(system.locateInstance("TestService1EP"), system.resolveInstance(ModuleScopeSystemComponent.class));
+ system.fireEvent(EventContext.MODULE_STOP, null);
+ system.stop();
+ }
+
+ public void testAutowireModuleRegisterAfterStart() throws Exception {
+ List<RuntimeConfigurationBuilder> builders = MockFactory.createSystemBuilders();
+ SystemAggregateContextImpl system = new SystemAggregateContextImpl("system", null, null, new SystemScopeStrategy(),
+ new EventContextImpl(), new MockConfigContext(builders), new NullMonitorFactory());
+ system.start();
+ system.fireEvent(EventContext.MODULE_START, null);
+ system.registerModelObject(MockFactory.createSystemModule());
+ Assert.assertSame(system.locateInstance("TestService1EP"), system.resolveInstance(ModuleScopeSystemComponent.class));
+ system.fireEvent(EventContext.MODULE_STOP, null);
+ system.stop();
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/system/context/SystemAggregateHierarchyTestCase.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/system/context/SystemAggregateHierarchyTestCase.java
new file mode 100644
index 0000000000..39dd0c050a
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/system/context/SystemAggregateHierarchyTestCase.java
@@ -0,0 +1,49 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.system.context;
+
+import java.util.List;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.common.monitor.impl.NullMonitorFactory;
+import org.apache.tuscany.core.builder.RuntimeConfigurationBuilder;
+import org.apache.tuscany.core.context.AbstractAggregateHierarchyTests;
+import org.apache.tuscany.core.context.AggregateContext;
+import org.apache.tuscany.core.context.impl.EventContextImpl;
+import org.apache.tuscany.core.context.scope.DefaultScopeStrategy;
+import org.apache.tuscany.core.mock.MockConfigContext;
+import org.apache.tuscany.core.mock.MockFactory;
+
+/**
+ * Performs testing of various hierarchical scenarios
+ *
+ * @version $Rev$ $Date$
+ */
+public class SystemAggregateHierarchyTestCase extends AbstractAggregateHierarchyTests {
+
+
+
+ protected AggregateContext createContextHierachy() throws Exception {
+ List<RuntimeConfigurationBuilder> mockBuilders = MockFactory.createSystemBuilders();
+ AggregateContext parent = new SystemAggregateContextImpl("test.parent", null, null, new DefaultScopeStrategy(),
+ new EventContextImpl(), new MockConfigContext(mockBuilders), new NullMonitorFactory());
+ parent.registerModelObject(MockFactory.createAggregateComponent("test.child"));
+ parent.start();
+ AggregateContext child = (AggregateContext) parent.getContext("test.child");
+ Assert.assertNotNull(child);
+ return parent;
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/system/context/SystemBootstrapTestCase.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/system/context/SystemBootstrapTestCase.java
new file mode 100644
index 0000000000..62f4b689c3
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/system/context/SystemBootstrapTestCase.java
@@ -0,0 +1,130 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.core.system.context;
+
+import java.util.List;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.common.monitor.impl.NullMonitorFactory;
+import org.apache.tuscany.core.builder.RuntimeConfigurationBuilder;
+import org.apache.tuscany.core.context.AggregateContext;
+import org.apache.tuscany.core.context.AutowireContext;
+import org.apache.tuscany.core.context.EventContext;
+import org.apache.tuscany.core.context.impl.AggregateContextImpl;
+import org.apache.tuscany.core.mock.MockFactory;
+import org.apache.tuscany.core.mock.component.GenericSystemComponent;
+import org.apache.tuscany.core.mock.component.ModuleScopeSystemComponent;
+import org.apache.tuscany.core.mock.component.ModuleScopeSystemComponentImpl;
+import org.apache.tuscany.core.runtime.RuntimeContext;
+import org.apache.tuscany.core.runtime.RuntimeContextImpl;
+import org.apache.tuscany.core.system.assembly.SystemAssemblyFactory;
+import org.apache.tuscany.core.system.assembly.impl.SystemAssemblyFactoryImpl;
+import org.apache.tuscany.model.assembly.Component;
+import org.apache.tuscany.model.assembly.ConfiguredService;
+import org.apache.tuscany.model.assembly.EntryPoint;
+import org.apache.tuscany.model.assembly.ExternalService;
+import org.apache.tuscany.model.assembly.Module;
+import org.apache.tuscany.model.assembly.Service;
+import org.apache.tuscany.model.types.java.JavaServiceContract;
+
+/**
+ * Tests bootstrapping a system module
+ *
+ * @version $Rev$ $Date$
+ */
+public class SystemBootstrapTestCase extends TestCase {
+ private List<RuntimeConfigurationBuilder> builders;
+
+ private SystemAssemblyFactory factory = new SystemAssemblyFactoryImpl();
+
+ /**
+ * Simulates booting a runtime process
+ */
+ public void testBoot() throws Exception {
+ RuntimeContext runtimeContext = new RuntimeContextImpl(new NullMonitorFactory(), null, builders,null);
+ runtimeContext.start();
+
+ AggregateContext systemContext = runtimeContext.getSystemContext();
+ Assert.assertNotNull(systemContext);
+ Module systemModule = MockFactory.createSystemModule();
+ // MockSystemAssemblyFactory.buildModule(systemModule, systemContext);
+ systemContext.registerModelObject(systemModule);
+
+ // create a test module
+ Component moduleComponent = MockFactory.createAggregateComponent("module");
+ runtimeContext.registerModelObject(moduleComponent);
+ AggregateContextImpl moduleContext = (AggregateContextImpl) runtimeContext.getContext("module");
+ Assert.assertNotNull(moduleContext);
+ ExternalService es = MockFactory.createESSystemBinding("TestServiceES", "tuscany.system/TestService1EP");
+ moduleContext.registerModelObject(es);
+
+ // start the modules and test inter-module system wires
+ systemContext.fireEvent(EventContext.MODULE_START, null);
+ moduleContext.fireEvent(EventContext.MODULE_START, null);
+
+ Assert.assertNotNull(systemContext.locateInstance("TestService1EP"));
+ GenericSystemComponent testService = (GenericSystemComponent) systemContext.locateInstance("TestService1");
+ Assert.assertNotNull(testService);
+ GenericSystemComponent testES = (GenericSystemComponent) moduleContext.locateInstance("TestServiceES");
+ Assert.assertNotNull(testES);
+ Assert.assertSame(testService, testES);
+ }
+
+ public void testRuntimeBoot() throws Exception {
+ RuntimeContext runtime = new RuntimeContextImpl(new NullMonitorFactory(), null, builders,null);
+ runtime.start();
+ runtime.getRootContext();
+
+ AggregateContext system = runtime.getSystemContext();
+ system.registerModelObject(MockFactory.createSystemModule());
+ system.registerModelObject(MockFactory.createSystemAggregateComponent("module2"));
+ AggregateContext systemModule2 = (AggregateContext) system.getContext("module2");
+ systemModule2.registerModelObject(MockFactory.createSystemChildModule());
+
+ EntryPoint ep = MockFactory.createEPSystemBinding("TestService2EP", ModuleScopeSystemComponent.class, "ref");
+ ep.getBindings().add(factory.createSystemBinding());
+ Service service = factory.createService();
+ service.setName("module2/TestService2EP");
+ JavaServiceContract inter = factory.createJavaServiceContract();
+ inter.setInterface(ModuleScopeSystemComponentImpl.class);
+ service.setServiceContract(inter);
+ ((ConfiguredService) ep.getConfiguredReference().getTargetConfiguredServices().get(0)).setService(service);
+ system.registerModelObject(ep);
+ system.fireEvent(EventContext.MODULE_START, null);
+ Assert.assertNotNull(system.locateInstance("TestService1"));
+ Assert.assertNotNull(system.locateInstance("TestService2EP"));
+
+ Assert.assertNotNull(((AutowireContext) system).resolveInstance(ModuleScopeSystemComponent.class));
+ // create a test module
+ Component moduleComponent = MockFactory.createAggregateComponent("test.module");
+ runtime.registerModelObject(moduleComponent);
+ AggregateContextImpl moduleContext = (AggregateContextImpl) runtime.getContext("test.module");
+ Assert.assertNotNull(moduleContext);
+ ExternalService es = MockFactory.createESSystemBinding("TestService2ES", "tuscany.system/TestService2EP");
+ moduleContext.registerModelObject(es);
+ moduleContext.fireEvent(EventContext.MODULE_START, null);
+ Assert.assertNotNull(moduleContext.locateInstance("TestService2ES"));
+
+ moduleContext.fireEvent(EventContext.MODULE_STOP, null);
+ system.fireEvent(EventContext.MODULE_STOP, null);
+ runtime.stop();
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ builders = MockFactory.createSystemBuilders();
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/system/context/SystemObjectRegistrationTestCase.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/system/context/SystemObjectRegistrationTestCase.java
new file mode 100644
index 0000000000..3c9aadac45
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/system/context/SystemObjectRegistrationTestCase.java
@@ -0,0 +1,59 @@
+/**
+ *
+ * Copyright 2005 BEA Systems Inc.
+ * Copyright 2005 International Business Machines Corporation
+ *
+ * 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.core.system.context;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.core.runtime.RuntimeContext;
+import org.apache.tuscany.core.runtime.RuntimeContextImpl;
+import org.apache.tuscany.core.context.SystemAggregateContext;
+import org.apache.tuscany.core.context.EventContext;
+import org.apache.tuscany.core.config.ConfigurationException;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class SystemObjectRegistrationTestCase extends TestCase {
+ private RuntimeContext runtime;
+ private SystemAggregateContext systemContext;
+
+ public void testRegistration() throws ConfigurationException {
+ MockComponent instance = new MockComponent();
+ systemContext.registerJavaObject("foo", instance);
+ assertSame(instance, systemContext.locateInstance("foo"));
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ runtime = new RuntimeContextImpl();
+ runtime.start();
+ systemContext = runtime.getSystemContext();
+ systemContext.fireEvent(EventContext.MODULE_START, null);
+ }
+
+ protected void tearDown() throws Exception {
+ runtime.stop();
+ super.tearDown();
+ }
+
+ private static class MockComponent {
+ public String hello(String message) {
+ return message;
+ }
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/system/context/TestBuilder.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/system/context/TestBuilder.java
new file mode 100644
index 0000000000..6bdcd896a1
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/system/context/TestBuilder.java
@@ -0,0 +1,36 @@
+package org.apache.tuscany.core.system.context;
+
+import org.apache.tuscany.core.builder.BuilderException;
+import org.apache.tuscany.core.builder.RuntimeConfigurationBuilder;
+import org.apache.tuscany.core.context.AggregateContext;
+import org.apache.tuscany.core.system.annotation.Autowire;
+import org.apache.tuscany.core.runtime.RuntimeContext;
+import org.apache.tuscany.model.assembly.AssemblyModelObject;
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Scope;
+
+@Scope("MODULE")
+public class TestBuilder implements RuntimeConfigurationBuilder<AggregateContext> {
+
+ @Autowire
+ private RuntimeContext runtime;
+
+ private boolean invoked = false;
+
+ public TestBuilder() {
+ super();
+ }
+
+ @Init(eager = true)
+ public void init() {
+ runtime.addBuilder(this);
+ }
+
+ public void build(AssemblyModelObject object, AggregateContext context) throws BuilderException {
+ invoked = true;
+ }
+
+ public boolean invoked() {
+ return invoked;
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/resources/org/apache/tuscany/core/config/ModuleComponentLoaderTest1.module b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/resources/org/apache/tuscany/core/config/ModuleComponentLoaderTest1.module
new file mode 100644
index 0000000000..b261cbe6c0
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/resources/org/apache/tuscany/core/config/ModuleComponentLoaderTest1.module
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
+
+ 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.
+ -->
+<module xmlns="http://www.osoa.org/xmlns/sca/0.9"
+ xmlns:v="http://www.osoa.org/xmlns/sca/values/0.9"
+ name="ModuleComponentLoaderTest1">
+
+ <component name="HelloWorldServiceComponent">
+ <implementation.java class="org.apache.tuscany.samples.helloworld.HelloWorldServiceComponentImpl"/>
+ </component>
+</module>
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/resources/system.fragment b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/resources/system.fragment
new file mode 100644
index 0000000000..74d04561cd
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/test/resources/system.fragment
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
+
+ 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.
+ -->
+<moduleFragment xmlns="http://www.osoa.org/xmlns/sca/0.9" xmlns:v="http://www.osoa.org/xmlns/sca/values/0.9"
+ xmlns:system="http://org.apache.tuscany/xmlns/system/0.9"
+ name="org.apache.tuscany.container.java">
+
+</moduleFragment>
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/LICENSE.txt b/sca-java-1.x/tags/java-stable-20060304/sca/model/LICENSE.txt
new file mode 100644
index 0000000000..d645695673
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/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/sca-java-1.x/tags/java-stable-20060304/sca/model/pom.xml b/sca-java-1.x/tags/java-stable-20060304/sca/model/pom.xml
new file mode 100644
index 0000000000..91ae36c3a4
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/pom.xml
@@ -0,0 +1,101 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Copyright (c) 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.
+ -->
+<project>
+ <parent>
+ <groupId>org.apache.tuscany</groupId>
+ <artifactId>tuscany-sca</artifactId>
+ <version>SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>tuscany-model</artifactId>
+ <name>Tuscany Assembly Model</name>
+ <description>Data model for the Assembly model defined by the SCA specification.</description>
+ <version>SNAPSHOT</version>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.osoa</groupId>
+ <artifactId>sca-api</artifactId>
+ <version>${pom.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany</groupId>
+ <artifactId>tuscany-common</artifactId>
+ <version>${pom.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>commonj</groupId>
+ <artifactId>sdo-api</artifactId>
+ <version>SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany</groupId>
+ <artifactId>tuscany-sdo-impl</artifactId>
+ <version>SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>axis</groupId>
+ <artifactId>axis-wsdl4j</artifactId>
+ <version>1.2</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>asm</groupId>
+ <artifactId>asm</artifactId>
+ <version>2.2</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.tuscany</groupId>
+ <artifactId>tuscany-sdo-plugin</artifactId>
+ <executions>
+ <execution>
+ <configuration>
+ <schemaFile>${basedir}/src/main/resources/model/sca.xsd</schemaFile>
+ <generateLoader>true</generateLoader>
+ <generateSwitch>true</generateSwitch>
+ <noNotification>true</noNotification>
+ <noUnsettable>true</noUnsettable>
+ </configuration>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/ModelRuntimeException.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/ModelRuntimeException.java
new file mode 100644
index 0000000000..ba361fab89
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/ModelRuntimeException.java
@@ -0,0 +1,41 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model;
+
+import org.apache.tuscany.common.TuscanyRuntimeException;
+
+/**
+ * The root runtime exception for the model.
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class ModelRuntimeException extends TuscanyRuntimeException {
+
+ public ModelRuntimeException() {
+ super();
+ }
+
+ public ModelRuntimeException(String message) {
+ super(message);
+ }
+
+ public ModelRuntimeException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public ModelRuntimeException(Throwable cause) {
+ super(cause);
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Aggregate.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Aggregate.java
new file mode 100644
index 0000000000..d313a087d0
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Aggregate.java
@@ -0,0 +1,117 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.assembly;
+
+import java.util.List;
+
+import javax.wsdl.Import;
+
+/**
+ * A model object that describes a container for other module objects, which must be {@link AggregatePart}s.
+ */
+public interface Aggregate extends Extensible {
+
+ /**
+ * Returns the name of the aggregate.
+ * @return the name of the aggregate
+ */
+ String getName();
+
+ /**
+ * Sets the name of the aggregate.
+ * @param name the name of the aggregate
+ */
+ void setName(String name);
+
+ /**
+ * Returns the AggregatePart objects that are contained in this aggregate.
+ * @return the AggregatePart objects that are contained in this aggregate
+ */
+ List<AggregatePart> getAggregateParts();
+
+ /**
+ * Helper method that returns all entry points contained in this aggregate.
+ * @return a list of all EntryPoint model objects driectly contained in this aggregate
+ */
+ List<EntryPoint> getEntryPoints();
+
+ /**
+ * Returns the named entry point.
+ * @param name
+ * @return
+ */
+ EntryPoint getEntryPoint(String name);
+
+ /**
+ * Helper method that returns all entry points contained in this aggregate.
+ * @return
+ */
+ List<Component> getComponents();
+
+ /**
+ * Returns the named component.
+ * @param name
+ * @return
+ */
+ Component getComponent(String name);
+
+ /**
+ * Returns external services contained in this aggregate.
+ * @return
+ */
+ List<ExternalService> getExternalServices();
+
+ /**
+ * Returns the named external service.
+ * @param name
+ * @return
+ */
+ ExternalService getExternalService(String name);
+
+ /**
+ * Returns the configured service at the given address.
+ * @param address
+ * @return
+ */
+ ConfiguredService getConfiguredService(ServiceURI address);
+
+ /**
+ * Returns the wires.
+ * @return
+ */
+ List<Wire> getWires();
+
+ /**
+ * Returns the WSDL imports.
+ * @return
+ */
+ List<Import> getWSDLImports();
+
+ /**
+ * Returns the WSDL imports for the given namespace.
+ * @param namespace
+ * @return
+ */
+ List<Import> getWSDLImports(String namespace);
+
+ /**
+ * Returns the assembly model context used by this aggregate.
+ * @return
+ */
+ AssemblyModelContext getAssemblyModelContext();
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/AggregatePart.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/AggregatePart.java
new file mode 100644
index 0000000000..f88458eaa8
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/AggregatePart.java
@@ -0,0 +1,40 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.assembly;
+
+/**
+ * A configured object that is contained inside an {@link Aggregate}.
+ */
+public interface AggregatePart extends AssemblyModelObject {
+ /**
+ * Returns the name that uniquely identifies this part within its containing aggregate.
+ * @return the name that uniquely identifies this part within its containing aggregate
+ */
+ String getName();
+
+ /**
+ * Sets the name that uniquely identifies this part within its containing aggregate.
+ * @param value the name that uniquely identifies this part within its containing aggregate
+ */
+ void setName(String value);
+
+ /**
+ * Returns the aggregate that contains this part.
+ * @return the aggregate that contains this part
+ */
+ Aggregate getAggregate();
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/AssemblyFactory.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/AssemblyFactory.java
new file mode 100644
index 0000000000..2f5715bd4e
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/AssemblyFactory.java
@@ -0,0 +1,162 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.assembly;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.model.types.java.JavaServiceContract;
+import org.apache.tuscany.model.types.wsdl.WSDLServiceContract;
+
+/**
+ * The Factory for the assembly model.
+ * Provides a create method for each non-abstract class of the model.
+ */
+public interface AssemblyFactory {
+
+ /**
+ * Returns a new SimpleComponent.
+ * @return
+ */
+ SimpleComponent createSimpleComponent();
+
+ /**
+ * Returns a new ComponentType.
+ * @return
+ */
+ ComponentType createComponentType();
+
+ /**
+ * Returns a new EntryPoint.
+ * @return
+ */
+ EntryPoint createEntryPoint();
+
+ /**
+ * Returns a new ExternalService.
+ * @return
+ */
+ ExternalService createExternalService();
+
+ /**
+ * Returns a new JavaServiceContract.
+ * @return
+ */
+ JavaServiceContract createJavaServiceContract();
+
+ /**
+ * Returns a new Module.
+ * @return
+ */
+ Module createModule();
+
+ /**
+ * Returns a new ModuleComponent.
+ * @return
+ */
+ ModuleComponent createModuleComponent();
+
+ /**
+ * Returns a new ModuleFragment.
+ * @return
+ */
+ ModuleFragment createModuleFragment();
+
+ /**
+ * Returns a new Reference.
+ * @return
+ */
+ Reference createReference();
+
+ /**
+ * Returns a new ConfiguredReference.
+ * @return
+ */
+ ConfiguredReference createConfiguredReference();
+
+ /**
+ * Returns a new Service.
+ * @return
+ */
+ Service createService();
+
+ /**
+ * Returns a new ConfiguredService.
+ * @return
+ */
+ ConfiguredService createConfiguredService();
+
+ /**
+ * Returns a new Subsystem.
+ * @return
+ */
+ Subsystem createSubsystem();
+
+ /**
+ * Returns Property.
+ * @return
+ */
+ Property createProperty();
+
+ /**
+ * Returns a new ConfiguredProperty.
+ * @return
+ */
+ ConfiguredProperty createConfiguredProperty();
+
+ /**
+ * Returns a new WSDLServiceContract.
+ * @return
+ */
+ WSDLServiceContract createWSDLServiceContract();
+
+ /**
+ * Create a new ServiceURI from the given uri string.
+ * @param uri
+ * @return
+ */
+ ServiceURI createServiceURI(String uri);
+
+ /**
+ * Creates a new ServiceURI from a module component and a service name.
+ * @param moduleComponent
+ * @param serviceName
+ * @return
+ */
+ ServiceURI createServiceURI(ModuleComponent moduleComponent, String serviceName);
+
+ /**
+ * Creates a new ServiceURI from a module component and configured port.
+ * @param moduleComponent
+ * @param aggregatePart
+ * @param configuredPort
+ * @return
+ */
+ ServiceURI createServiceURI(ModuleComponent moduleComponent, AggregatePart aggregatePart, ConfiguredPort configuredPort);
+
+ /**
+ * Create a qname from a URI
+ * @param uri
+ * @return
+ */
+ QName createQName(String uri);
+
+ /**
+ * Create a wire
+ * @return
+ */
+ Wire createWire();
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/AssemblyModelContext.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/AssemblyModelContext.java
new file mode 100644
index 0000000000..43e6766b8b
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/AssemblyModelContext.java
@@ -0,0 +1,64 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.assembly;
+
+import org.apache.tuscany.common.resource.ResourceLoader;
+import org.apache.tuscany.model.assembly.loader.AssemblyModelLoader;
+
+import commonj.sdo.helper.TypeHelper;
+
+/**
+ * Context object supplied by visitors that are processing the model.
+ */
+public interface AssemblyModelContext {
+
+ /**
+ * Returns a factory that can be used to create other model objects
+ *
+ * @return a factory for model objects
+ */
+ AssemblyFactory getAssemblyFactory();
+
+ /**
+ * Returns a loader for resources in the system environment
+ *
+ * @return a resource loader
+ */
+ ResourceLoader getSystemResourceLoader();
+
+ /**
+ * Returns a loader for resources in the application environment.
+ *
+ * @return a loader for resources in the system environment
+ */
+ ResourceLoader getApplicationResourceLoader();
+
+ /**
+ * Returns a loader that can be used to load sub-models.
+ *
+ * @return a loader for sub-models
+ */
+ AssemblyModelLoader getAssemblyLoader();
+
+ /**
+ * Returns an SDO type helper.
+ *
+ * @return an SDO type helper
+ */
+ TypeHelper getTypeHelper();
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/AssemblyModelObject.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/AssemblyModelObject.java
new file mode 100644
index 0000000000..e9a32ed4ce
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/AssemblyModelObject.java
@@ -0,0 +1,45 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.assembly;
+
+/**
+ * Base interface for all assembly model objects providing methods for managing the model itself.
+ */
+public interface AssemblyModelObject {
+
+ /**
+ * Initialize this model object.
+ *
+ * @param modelContext context providing access to the environment in which this model is being used
+ * @throws ModelInitException if an error ocurrs initializing the artifact
+ */
+ void initialize(AssemblyModelContext modelContext) throws ModelInitException;
+
+ /**
+ * Freeze this model object preventing any additional changes.
+ */
+ void freeze();
+
+ /**
+ * Accept a visitor
+ *
+ * @param visitor a visitor that is visiting the model
+ * @return true if processing is complete and the visitor should stop traversing the model
+ */
+ boolean accept(AssemblyModelVisitor visitor);
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/AssemblyModelVisitor.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/AssemblyModelVisitor.java
new file mode 100644
index 0000000000..9f3153e953
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/AssemblyModelVisitor.java
@@ -0,0 +1,32 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.assembly;
+
+/**
+ * A visitor that traverses the model performing some operation.
+ */
+public interface AssemblyModelVisitor {
+
+ /**
+ * Visit the given model object.
+ *
+ * @param modelObject the assembly model object to visit
+ * @return true if processing is complete
+ */
+ boolean visit(AssemblyModelObject modelObject);
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Binding.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Binding.java
new file mode 100644
index 0000000000..61207186e3
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Binding.java
@@ -0,0 +1,40 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.assembly;
+
+
+/**
+ * The binding of an entry point or external service to a transport.
+ * This model object will typically by extended by binding implementations to allow
+ * specification of binding/transport specific information.
+ */
+public interface Binding extends AssemblyModelObject, RuntimeConfigurationHolder {
+ /**
+ * Returns the binding URI.
+ * @return the binding uri
+ * todo do we need this?
+ */
+ String getURI();
+
+ /**
+ * Sets binding URI.
+ * @param value the binding uri
+ * todo do we need this?
+ */
+ void setURI(String value);
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Component.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Component.java
new file mode 100644
index 0000000000..86dd1c5f12
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Component.java
@@ -0,0 +1,80 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.assembly;
+
+import java.util.List;
+
+
+/**
+ * A component is a configured instance of a generic {@link ComponentImplementation}.
+ */
+public interface Component extends Extensible, AggregatePart {
+
+ /**
+ * Returns the ComponentImplementation for this configured instance.
+ * @return the ComponentImplementation for this configured instance
+ */
+ ComponentImplementation getComponentImplementation();
+
+ /**
+ * Sets the ComponentImplementation for this configured instance
+ * @param value the ComponentImplementation for this configured instance
+ */
+ void setComponentImplementation(ComponentImplementation value);
+
+ /**
+ * Returns a list of configured property values for this configured instance.
+ * These values will be used to initialize the component when it is activated.
+ * @return a list of ConfiguredProperty values
+ */
+ List<ConfiguredProperty> getConfiguredProperties();
+
+ /**
+ * Returns the ConfiguredProperty value for the specified property.
+ *
+ * @param name the name of the Property
+ * @return the configured property value for the named property
+ */
+ ConfiguredProperty getConfiguredProperty(String name);
+
+ /**
+ * Returns a list of configured reference values for the configured instance.
+ * @return a list of configured reference values for the configured instance
+ */
+ List<ConfiguredReference> getConfiguredReferences();
+
+ /**
+ * Returns the ConfiguredReference value for the specified reference.
+ * @param name the name of the Property
+ * @return the configured reference value for the named reference
+ */
+ ConfiguredReference getConfiguredReference(String name);
+
+ /**
+ * Returns the configured services for the configured instance.
+ * @return the configured services for the configured instance
+ */
+ List<ConfiguredService> getConfiguredServices();
+
+ /**
+ * Returns the ConfiguredService value for the specified property.
+ * @param name the name of the Property
+ * @return the configured service value for the named service
+ */
+ ConfiguredService getConfiguredService(String name);
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ComponentImplementation.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ComponentImplementation.java
new file mode 100644
index 0000000000..9bae24522e
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ComponentImplementation.java
@@ -0,0 +1,40 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.assembly;
+
+
+/**
+ * The implementation for a specific component instance.
+ * This interface will typically be extended by component type implementations to indicate the
+ * specific implementation to be used by a runtime and to allow for additional runtime configuration
+ * properties.
+ */
+public interface ComponentImplementation extends Extensible, RuntimeConfigurationHolder {
+
+ /**
+ * Returns the generic component type corresponding to this implementation.
+ * @return the generic component type corresponding to this implementation
+ */
+ ComponentType getComponentType();
+
+ /**
+ * Sets the generic component type corresponding to this implementation.
+ * @param componentType the generic component type corresponding to this implementation
+ */
+ void setComponentType(ComponentType componentType);
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ComponentType.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ComponentType.java
new file mode 100644
index 0000000000..58ac9bc9de
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ComponentType.java
@@ -0,0 +1,66 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.assembly;
+
+import java.util.List;
+
+
+/**
+ * A logical definition of a type of component separate from any specific implementation.
+ */
+public interface ComponentType extends Extensible {
+
+ /**
+ * Returns a list of services exposed by this component type.
+ * @return a list of services exposed by this component type
+ */
+ List<Service> getServices();
+
+ /**
+ * Returns the specfied service if exposed by this component type.
+ * @param name the name of the service
+ * @return the service identified by the supplied name, or null if there is no service with that name
+ */
+ Service getService(String name);
+
+ /**
+ * Returns the list of references this component type consumes.
+ * @return the list of references this component type consumes
+ */
+ List<Reference> getReferences();
+
+ /**
+ * Returns the specified reference.
+ * @param name the name of the reference
+ * @return the reference identified by the supplied name, or null if there is no reference with that name
+ */
+ Reference getReference(String name);
+
+ /**
+ * Returns the list of properties that can be used to configure components with this component type.
+ * @return the list of properties that can be used to configure components with this component type
+ */
+ List<Property> getProperties();
+
+ /**
+ * Returns the specified property
+ * @param name the name of the property
+ * @return the property with the supplied name, or null if there is no property with that name
+ */
+ Property getProperty(String name);
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ConfiguredPort.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ConfiguredPort.java
new file mode 100644
index 0000000000..d40e852e88
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ConfiguredPort.java
@@ -0,0 +1,57 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.assembly;
+
+
+/**
+ * Represents a configured port (e.g. a configured reference or configured service).
+ */
+public interface ConfiguredPort extends AssemblyModelObject, RuntimeConfigurationHolder {
+
+ /**
+ * Returns the port that is being configured.
+ * @return the port that is being configured
+ */
+ Port getPort();
+
+ /**
+ * Sets the port that is being configured.
+ * @param port the port that is being configured
+ */
+ void setPort(Port port);
+
+ /**
+ * Returns the aggregate part containing this port.
+ * @return the aggregate part that contains this port
+ */
+ AggregatePart getAggregatePart();
+
+ /**
+ * Returns the port's proxy factory
+ * @return the port's proxy factory
+ * todo should this be here or should it be provided in a sub-interface?
+ */
+ Object getProxyFactory();
+
+ /**
+ * Sets the port's proxy factory
+ * @param proxyFactory the port's proxy factory
+ * todo should this be here or should it be provided in a sub-interface?
+ */
+ void setProxyFactory(Object proxyFactory);
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ConfiguredProperty.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ConfiguredProperty.java
new file mode 100644
index 0000000000..0a28c0a7bf
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ConfiguredProperty.java
@@ -0,0 +1,62 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.assembly;
+
+/**
+ * The configured value of a {@link Property}.
+ */
+public interface ConfiguredProperty extends AssemblyModelObject {
+
+ /**
+ * Returns the {@link Property} whose value is being set.
+ * @return the {@link Property} whose value is being set
+ */
+ Property getProperty();
+
+ /**
+ * Sets the {@link Property} whose value is being set.
+ * @param property the {@link Property} whose value is being set
+ */
+ void setProperty(Property property);
+
+ /**
+ * Returns the value being set for this usage of the {@link Property}.
+ * @return the value being set for this usage of the {@link Property}
+ */
+ Object getValue();
+
+ /**
+ * Sets the value being set for this usage of the {@link Property}.
+ * @param value the value being set for this usage of the {@link Property}
+ */
+ void setValue(Object value);
+
+ /**
+ * Returns the override option that determines if any configuration for this property
+ * that is contained in this aggregate can be overridden by configuration supplied from outside.
+ */
+ OverrideOption getOverrideOption();
+
+ /**
+ * Set the override option that determines if any configuration for this property
+ * that is contained in this aggregate can be overridden by configuration supplied from outside.
+ *
+ * @param value the option that determines how property configuration can be overriden
+ */
+ void setOverrideOption(OverrideOption value);
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ConfiguredReference.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ConfiguredReference.java
new file mode 100644
index 0000000000..972c6812d8
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ConfiguredReference.java
@@ -0,0 +1,44 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.assembly;
+
+import java.util.List;
+
+/**
+ * A configured reference associated with a particular usage.
+ */
+public interface ConfiguredReference extends ConfiguredPort {
+
+ /**
+ * Returns the {@link Reference} that is being configured.
+ * @return the {@link Reference} that is being configured
+ */
+ Reference getReference();
+
+ /**
+ * Sets the {@link Reference} that is being configured.
+ * @param reference the {@link Reference} that is being configured
+ */
+ void setReference(Reference reference);
+
+ /**
+ * Returns the list of configured services that are wired to this configured reference.
+ * @return the list of configured services that are wired to this configured reference
+ */
+ List<ConfiguredService> getTargetConfiguredServices();
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ConfiguredService.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ConfiguredService.java
new file mode 100644
index 0000000000..14b1c0abbe
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ConfiguredService.java
@@ -0,0 +1,36 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.assembly;
+
+
+/**
+ * A configured service associated with a particular usage.
+ */
+public interface ConfiguredService extends ConfiguredPort {
+ /**
+ * Returns the {@link Service} that is being configured.
+ * @return the {@link Service} that is being configured
+ */
+ Service getService();
+
+ /**
+ * Sets the {@link Service} that is being configured.
+ * @param service the {@link Service} that is being configured
+ */
+ void setService(Service service);
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/EntryPoint.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/EntryPoint.java
new file mode 100644
index 0000000000..718ae996c5
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/EntryPoint.java
@@ -0,0 +1,64 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.assembly;
+
+import java.util.List;
+
+
+/**
+ * An entry point exposed by its containing {@link Aggregate}.
+ * References from outside the Aggregate can only be connected to its entry points.
+ */
+public interface EntryPoint extends AggregatePart, Extensible {
+
+ /**
+ * Returns the bindings supported by this entry point.
+ * A single entry point may be bound to multiple transports.
+ *
+ * @return a list of bindings supported by this entry point
+ */
+ List<Binding> getBindings();
+
+ /**
+ * Returns the configured service exposed by this entry point.
+ *
+ * @return the configured service exposed by this entry point
+ */
+ ConfiguredService getConfiguredService();
+
+ /**
+ * Sets the configured service exposed by this entry point.
+ *
+ * @param configuredService the configured service exposed by this entry point
+ */
+ void setConfiguredService(ConfiguredService configuredService);
+
+ /**
+ * Returns the configured reference that wires this entry point to the published service inside the aggregate.
+ *
+ * @return the reference that wires this entry point to the published service
+ */
+ ConfiguredReference getConfiguredReference();
+
+ /**
+ * Sets the configured reference that wires this entry point to the published service inside the aggregate.
+ *
+ * @param configuredReference the configured reference that wires this entry point to the published service inside the aggregate
+ */
+ void setConfiguredReference(ConfiguredReference configuredReference);
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Extensible.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Extensible.java
new file mode 100644
index 0000000000..2a5b5878f8
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Extensible.java
@@ -0,0 +1,38 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.assembly;
+
+import java.util.List;
+
+/**
+ * An extensible model object.
+ * TODO do we actually need this given we have the ability to load specializations of individual model objects
+ * TODO is this the bext interface for this?
+ */
+public interface Extensible extends AssemblyModelObject {
+
+ /**
+ * Returns the extensibility elements.
+ */
+ List getExtensibilityElements();
+
+ /**
+ * Returns the extensibility attributes.
+ */
+ List getExtensibilityAttributes();
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ExternalService.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ExternalService.java
new file mode 100644
index 0000000000..a30000f387
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ExternalService.java
@@ -0,0 +1,59 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.assembly;
+
+import java.util.List;
+
+
+/**
+ * An external service consumed by its containing {@link Aggregate}.
+ * All references used by the aggregate are specified as external services.
+ */
+public interface ExternalService extends AggregatePart, Extensible {
+
+ /**
+ * Returns the bindings that can be used by operations on this external service.
+ * A single external service may be bound to multiple transports.
+ */
+ List<Binding> getBindings();
+
+ /**
+ * Returns the override option that determines if any wiring for this external service
+ * that is contained in this aggregate can be overridden by wired supplied from outside.
+ */
+ OverrideOption getOverrideOption();
+
+ /**
+ * Set the override option that determines if any wiring for this external service
+ * that is contained in this aggregate can be overridden by wired supplied from outside.
+ *
+ * @param value the option that determines how wires can be overriden
+ */
+ void setOverrideOption(OverrideOption value);
+
+ /**
+ * Returns the configured service that this external service provides to other parts of the containing aggregate.
+ * @return the configured service that this external service provides to other parts of the containing aggregate
+ */
+ ConfiguredService getConfiguredService();
+
+ /**
+ * Sets the configured service that this external service provides to other parts of the containing aggregate
+ * @param configuredService the configured service that this external service provides to other parts of the containing aggregate
+ */
+ void setConfiguredService(ConfiguredService configuredService);
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ModelInitException.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ModelInitException.java
new file mode 100644
index 0000000000..4af3737a5d
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ModelInitException.java
@@ -0,0 +1,43 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.assembly;
+
+import org.apache.tuscany.model.ModelRuntimeException;
+
+/**
+ * Denotes an exception initializing an assembly model artifact
+ *
+ * @version $Rev$ $Date$
+ */
+public class ModelInitException extends ModelRuntimeException {
+ // todo serialuid
+
+ public ModelInitException() {
+ super();
+ }
+
+ public ModelInitException(String message) {
+ super(message);
+ }
+
+ public ModelInitException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public ModelInitException(Throwable cause) {
+ super(cause);
+ }
+
+}
+
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Module.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Module.java
new file mode 100644
index 0000000000..90f9fbf9b2
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Module.java
@@ -0,0 +1,39 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.assembly;
+
+import java.util.List;
+
+/**
+ * A specialized {@link ComponentImplementation} that defines a modular unit of assembly.
+ * A Module denotes the extent of assembly in which pass-by-reference semantics are supported.
+ */
+public interface Module extends Aggregate, ComponentImplementation {
+ /**
+ * Returns a list of assembly fragments that combine to form a single module.
+ * @return a list of assembly fragments that combine to form a single module
+ */
+ List<ModuleFragment> getModuleFragments();
+
+ /**
+ * Returns the specified assembly fragment.
+ * @param name the name of the fragment
+ * @return the fragment with the specified name, or null if there is no fragment with that name
+ */
+ ModuleFragment getModuleFragment(String name);
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ModuleComponent.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ModuleComponent.java
new file mode 100644
index 0000000000..13125076ea
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ModuleComponent.java
@@ -0,0 +1,47 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.assembly;
+
+/**
+ * Specialization of Component that represents a configured {@link Module}.
+ */
+public interface ModuleComponent extends Component {
+ // todo do we need this or can we just override getComponentImplementation() ?
+ /**
+ * Returns the module implementing this module component.
+ * @return the module implementing this module component
+ */
+ Module getModuleImplementation();
+
+ /**
+ * Set the module implementing this module component.
+ * @param module the module implementing this module component
+ */
+ void setModuleImplementation(Module module);
+
+ /**
+ * Returns the uri that uniquely identifies this module component.
+ * @return the uri that uniquely identifies this module component
+ */
+ String getURI();
+
+ /**
+ * Sets the uri that uniquely identifies this module component.
+ * @param uri the uri that uniquely identifies this module component
+ */
+ void setURI(String uri);
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ModuleFragment.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ModuleFragment.java
new file mode 100644
index 0000000000..f268524c3f
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ModuleFragment.java
@@ -0,0 +1,25 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.assembly;
+
+/**
+ * A fragment of assembly configuration within a module.
+ * To support flexibility and reuse, modules can be defined in multiple fragments that are
+ * then combined by the runtime to form the complete module definition.
+ */
+public interface ModuleFragment extends Aggregate {
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Multiplicity.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Multiplicity.java
new file mode 100644
index 0000000000..78ff6ede2f
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Multiplicity.java
@@ -0,0 +1,47 @@
+/**
+ *
+ * Copyright 2005 BEA Systems Inc.
+ * Copyright 2005 International Business Machines Corporation
+ *
+ * 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.model.assembly;
+
+/**
+ * Enumeration for multiplicity.
+ */
+public enum Multiplicity {
+ /**
+ * Indicates a relationship that is optionally connected to the requestor and which, if supplied,
+ * must be connected to exactly one provider.
+ */
+ ZERO_ONE,
+
+ /**
+ * Indicates a relationship that must be connected between exactly one requestor and
+ * exactly one provider.
+ */
+ ONE_ONE,
+
+ /**
+ * Indicates a relationship that is optionally connects the requestor to zero to unbounded providers.
+ */
+ ZERO_N,
+
+ /**
+ * Indicates a relationship that must be connected at the requestor and which connects it to
+ * zero to unbounded providers.
+ */
+ ONE_N
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/OverrideOption.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/OverrideOption.java
new file mode 100644
index 0000000000..62c7b3fb7a
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/OverrideOption.java
@@ -0,0 +1,40 @@
+/**
+ *
+ * Copyright 2005 BEA Systems Inc.
+ * Copyright 2005 International Business Machines Corporation
+ *
+ * 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.model.assembly;
+
+/**
+ * Enumeration for override options that are used to control whether configuration information
+ * can be overridden by larger grained definitions.
+ */
+public enum OverrideOption {
+ /**
+ * Indicates that the supplied configuration cannot be overridden.
+ */
+ NO,
+
+ /**
+ * Indicates that the supplied configuration may be overriden.
+ */
+ MAY,
+
+ /**
+ * Indicates that the supplied configuration must be overriden.
+ */
+ MUST
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Port.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Port.java
new file mode 100644
index 0000000000..5dadfa0d63
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Port.java
@@ -0,0 +1,47 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.assembly;
+
+/**
+ * Abstraction for the association of a service contract with a requestor or provider.
+ */
+public interface Port extends AssemblyModelObject {
+ /**
+ * Returns the contract for invocations of a service using this port.
+ * @return the oontract for invocations of a service using this port
+ */
+ ServiceContract getServiceContract();
+
+ /**
+ * Set the contract for invocations of a service using this port.
+ * @param contract the contract for invocations of a service using this port
+ */
+ void setServiceContract(ServiceContract contract);
+
+ /**
+ * Returns the name of the port where it is associated with a requestor or provider.
+ * @return the name of the port
+ */
+ String getName();
+
+ /**
+ * Sets the name of the port where it is associated with a requestor or provider.
+ * @param name the name of the port where it is associated with a requestor or provider
+ */
+ void setName(String name);
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Property.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Property.java
new file mode 100644
index 0000000000..cd6a918686
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Property.java
@@ -0,0 +1,91 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.assembly;
+
+
+
+/**
+ * A description of a property that can be used to configure a component.
+ */
+public interface Property extends Extensible {
+ // todo should we decalre this as Property<T> where T would be the type of this Property?
+
+ /**
+ * Returns the property name.
+ * @return the property name
+ */
+ String getName();
+
+ /**
+ * Sets the property name.
+ * @param name the property name
+ */
+ void setName(String name);
+
+ /**
+ * Returns the default value of the property.
+ * @return the default value of ths property
+ */
+ Object getDefaultValue();
+
+ /**
+ * Sets the default value of the property.
+ * @param value the default value of ths property
+ */
+ void setDefaultValue(Object value);
+
+ /**
+ * Returns true if the property allows multiple values.
+ * @return true if the property allows multiple values
+ */
+ boolean isMany();
+
+ /**
+ * Sets whether or not the property allows multiple values.
+ * @param value true if the property should allow multiple values
+ */
+ void setMany(boolean value);
+
+ /**
+ * Returns true if a value must be supplied for the property.
+ * @return true is a value must be supplied for the property
+ */
+ boolean isRequired();
+
+ /**
+ * Sets whether a value must be supplied for the property.
+ * For ease of use, it is recommended that a meaningful default value should
+ * be supplied for all properties; users should only be required to specify
+ * a value if there is no reasonable default.
+ *
+ * @param value set to true to require that a value be supplied for uses of this property
+ */
+ void setRequired(boolean value);
+
+ /**
+ * Returns the type of this property as used by the runtime.
+ * @return the type of this property as used by the runtime
+ */
+ Class getType();
+
+ /**
+ * Sets the type of this property as used by the runtime
+ * @param value the type of this property as used by the runtime
+ */
+ void setType(Class value);
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Reference.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Reference.java
new file mode 100644
index 0000000000..8cc13e98ec
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Reference.java
@@ -0,0 +1,36 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.assembly;
+
+
+/**
+ * The association of a port with a requestor.
+ */
+public interface Reference extends Port {
+ /**
+ * Returns the multiplicity allowed for wires connected to this reference.
+ * @return the multiplicity allowed for wires connected to this reference
+ */
+ Multiplicity getMultiplicity();
+
+ /**
+ * Sets the multiplicity allowed for wires connected to this reference.
+ * @param multiplicity the multiplicity allowed for wires connected to this reference
+ */
+ void setMultiplicity(Multiplicity multiplicity);
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/RuntimeConfigurationHolder.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/RuntimeConfigurationHolder.java
new file mode 100644
index 0000000000..7b20f2db21
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/RuntimeConfigurationHolder.java
@@ -0,0 +1,36 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.assembly;
+
+/**
+ * A model object that can hold a runtime configuration object.
+ */
+public interface RuntimeConfigurationHolder {
+
+ /**
+ * Sets the runtime configuration object.
+ * @param configuration the runtime configuration object
+ */
+ void setRuntimeConfiguration(Object configuration);
+
+ /**
+ * Returns the runtime configuration object.
+ * @return the runtime configuration object
+ */
+ Object getRuntimeConfiguration();
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Scope.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Scope.java
new file mode 100644
index 0000000000..e5209d05b5
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Scope.java
@@ -0,0 +1,32 @@
+/**
+ *
+ * Copyright 2005 BEA Systems Inc.
+ * Copyright 2005 International Business Machines Corporation
+ *
+ * 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.model.assembly;
+
+/**
+ * The types of scope supported by assemblies.
+ */
+public enum Scope {
+ // todo define what these are
+ INSTANCE,
+ REQUEST,
+ SESSION,
+ MODULE,
+ AGGREGATE,
+ UNDEFINED
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Service.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Service.java
new file mode 100644
index 0000000000..c73002efba
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Service.java
@@ -0,0 +1,24 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.assembly;
+
+
+/**
+ * The association of a port with a provider.
+ */
+public interface Service extends Port {
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ServiceContract.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ServiceContract.java
new file mode 100644
index 0000000000..3284755ddb
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ServiceContract.java
@@ -0,0 +1,62 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.assembly;
+
+/**
+ * The contract specified by a requestor or provider for invocations across a port.
+ */
+public interface ServiceContract extends Extensible {
+
+ /**
+ * Returns the interface for invocations from the requestor to the provider.
+ * @return the interface for invocations from the requestor to the provider
+ */
+ Class getInterface();
+
+ /**
+ * Sets the interface for invocations from the requestor to the provider.
+ * @param value the interface for invocations from the requestor to the provider
+ */
+ void setInterface(Class value);
+
+ /**
+ * Returns the callback interface for invocation from the provider back to its requestor.
+ * @return the callback interface for invocation from the provider back to its requestor
+ */
+ Class getCallbackInterface();
+
+ /**
+ * Sets the callback interface for invocation from the provider back to its requestor.
+ * @param value the callback interface for invocation from the provider back to its requestor
+ */
+ void setCallbackInterface(Class value);
+
+ /**
+ * Returns the scope of this service contract.
+ * @return
+ * todo missing javadoc
+ */
+ Scope getScope();
+
+ /**
+ * Sets the scope.
+ * @param scope of this service contract.
+ * todo missing javadoc
+ */
+ void setScope(Scope scope);
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ServiceURI.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ServiceURI.java
new file mode 100644
index 0000000000..3b9c1ec2a7
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ServiceURI.java
@@ -0,0 +1,53 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.assembly;
+
+/**
+ * Represents a service URI.
+ */
+public interface ServiceURI {
+
+ /**
+ * Returns true if the address scheme is sca
+ * @return
+ */
+ public boolean isSCAScheme();
+
+ /**
+ * @return Returns the address.
+ */
+ public String getAddress();
+
+ /**
+ * Returns the module component name
+ * @return
+ */
+ public String getModuleComponentName();
+
+ /**
+ * Returns the part name
+ * @return
+ */
+ public String getPartName();
+
+ /**
+ * Returns the service name
+ * @return
+ */
+ public String getServiceName();
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/SimpleComponent.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/SimpleComponent.java
new file mode 100644
index 0000000000..059c6dbf2d
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/SimpleComponent.java
@@ -0,0 +1,25 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.assembly;
+
+
+/**
+ * A simple component, specifically not an {@link Aggregate}.
+ */
+public interface SimpleComponent extends Component {
+}
+ \ No newline at end of file
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Subsystem.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Subsystem.java
new file mode 100644
index 0000000000..7a14847353
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Subsystem.java
@@ -0,0 +1,38 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.assembly;
+
+
+
+/**
+ * Represents a subsystem.
+ */
+public interface Subsystem extends Aggregate {
+
+ /**
+ * Returns the subsystem uri.
+ * @return
+ */
+ String getURI();
+
+ /**
+ * Sets the subsystem uri.
+ * @param value
+ */
+ void setURI(String value);
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Wire.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Wire.java
new file mode 100644
index 0000000000..dfe553210a
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Wire.java
@@ -0,0 +1,48 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.assembly;
+
+
+/**
+ * A connection between a requestor (source) and a provider (target).
+ */
+public interface Wire extends Extensible {
+ /**
+ * Returns the URI for the source of the request.
+ * @return the URI for the source of the request
+ */
+ ServiceURI getSource();
+
+ /**
+ * Sets the URI for the source of the request.
+ * @param uri the URI for the source of the request
+ */
+ void setSource(ServiceURI uri);
+
+ /**
+ * Returns the URI for the target of the request.
+ * @return the URI for the target of the request
+ */
+ ServiceURI getTarget();
+
+ /**
+ * Sets the URI for the target of the request.
+ * @param uri the URI for the target of the request
+ */
+ void setTarget(ServiceURI uri);
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/AggregateImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/AggregateImpl.java
new file mode 100644
index 0000000000..234fff6600
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/AggregateImpl.java
@@ -0,0 +1,305 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.assembly.impl;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.wsdl.Definition;
+import javax.wsdl.Import;
+
+import org.apache.tuscany.common.resource.ResourceLoader;
+import org.apache.tuscany.model.assembly.Aggregate;
+import org.apache.tuscany.model.assembly.AggregatePart;
+import org.apache.tuscany.model.assembly.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.AssemblyModelVisitor;
+import org.apache.tuscany.model.assembly.Component;
+import org.apache.tuscany.model.assembly.ConfiguredService;
+import org.apache.tuscany.model.assembly.EntryPoint;
+import org.apache.tuscany.model.assembly.ExternalService;
+import org.apache.tuscany.model.assembly.ServiceURI;
+import org.apache.tuscany.model.assembly.Wire;
+import org.apache.tuscany.sdo.util.SDOUtil;
+
+import commonj.sdo.helper.XSDHelper;
+
+/**
+ * An implementation of Aggregate.
+ */
+public abstract class AggregateImpl extends ExtensibleImpl implements Aggregate {
+
+ private String name;
+ private List<Component> components=new ArrayList<Component>();
+ private Map<String, Component> componentsMap;
+ private List<EntryPoint> entryPoints=new ArrayList<EntryPoint>();
+ private Map<String, EntryPoint> entryPointsMap;
+ private List<ExternalService> externalServices=new ArrayList<ExternalService>();
+ private Map<String, ExternalService> externalServicesMap;
+ private List<AggregatePart> aggregateParts;
+ private List<Wire> wires=new ArrayList<Wire>();
+ private List<Import> wsdlImports=new ArrayList<Import>();
+ private Map<String, List<Import>> wsdlImportsMap;
+ private AssemblyModelContext modelContext;
+
+ /**
+ * Constructor
+ */
+ protected AggregateImpl() {
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Aggregate#getName()
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Aggregate#setName(java.lang.String)
+ */
+ public void setName(String newName) {
+ checkNotFrozen();
+ name=newName;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Aggregate#getComponents()
+ */
+ public List<Component> getComponents() {
+ return components;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Aggregate#getComponent(java.lang.String)
+ */
+ public Component getComponent(String name) {
+ checkInitialized();
+ return componentsMap.get(name);
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Aggregate#getEntryPoints()
+ */
+ public List<EntryPoint> getEntryPoints() {
+ return entryPoints;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Aggregate#getEntryPoint(java.lang.String)
+ */
+ public EntryPoint getEntryPoint(String name) {
+ checkInitialized();
+ return entryPointsMap.get(name);
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Aggregate#getExternalServices()
+ */
+ public List<ExternalService> getExternalServices() {
+ return externalServices;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Aggregate#getExternalService(java.lang.String)
+ */
+ public ExternalService getExternalService(String name) {
+ checkInitialized();
+ return externalServicesMap.get(name);
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Aggregate#getAggregateParts()
+ */
+ public List<AggregatePart> getAggregateParts() {
+ checkInitialized();
+ return aggregateParts;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Aggregate#getWires()
+ */
+ public List<Wire> getWires() {
+ return wires;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Aggregate#getWSDLImports()
+ */
+ public List<Import> getWSDLImports() {
+ return wsdlImports;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Aggregate#getWSDLImports(java.lang.String)
+ */
+ public List<Import> getWSDLImports(String namespace) {
+ checkInitialized();
+ return wsdlImportsMap.get(namespace);
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Aggregate#getAssemblyModelContext()
+ */
+ public AssemblyModelContext getAssemblyModelContext() {
+ checkInitialized();
+ return modelContext;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Aggregate#getConfiguredService(org.apache.tuscany.model.assembly.ServiceURI)
+ */
+ public ConfiguredService getConfiguredService(ServiceURI address) {
+ String partName = address.getPartName();
+ String serviceName = address.getServiceName();
+ Component component = getComponent(partName);
+ if (component != null) {
+ if (serviceName != null) {
+ return component.getConfiguredService(serviceName);
+ } else {
+ if (!component.getConfiguredServices().isEmpty()) {
+ return component.getConfiguredServices().get(0);
+ } else {
+ return null;
+ }
+ }
+
+ } else {
+ ExternalService externalService = getExternalService(partName);
+ if (externalService != null) {
+ return externalService.getConfiguredService();
+ } else {
+ return null;
+ }
+ }
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyModelObject#initialize(org.apache.tuscany.model.assembly.AssemblyModelContext)
+ */
+ public void initialize(AssemblyModelContext modelContext) {
+ if (isInitialized())
+ return;
+ super.initialize(modelContext);
+
+ // Save the model context
+ this.modelContext=modelContext;
+
+ // Populate map of WSDL imports
+ ResourceLoader resourceLoader=modelContext.getApplicationResourceLoader();
+ wsdlImportsMap = new HashMap<String, List<Import>>();
+ for (Import wsdlImport : wsdlImports) {
+ String namespace=wsdlImport.getNamespaceURI();
+ List<Import> list=wsdlImportsMap.get(namespace);
+ if (list==null) {
+ list=new ArrayList<Import>();
+ wsdlImportsMap.put(namespace, list);
+ }
+ list.add(wsdlImport);
+
+ // Load the WSDL definition if necessary
+ if (wsdlImport.getDefinition()==null) {
+ String location=wsdlImport.getLocationURI();
+ Definition definition;
+ ClassLoader ccl=Thread.currentThread().getContextClassLoader();
+ try {
+ URL url=resourceLoader.getResource(location);
+ if (url==null)
+ throw new IllegalArgumentException("Cannot find "+location);
+ definition = modelContext.getAssemblyLoader().loadDefinition(url.toString());
+ Thread.currentThread().setContextClassLoader(modelContext.getApplicationResourceLoader().getClassLoader());
+ XSDHelper xsdHelper=SDOUtil.createXSDHelper(modelContext.getTypeHelper());
+ xsdHelper.define (url.openStream(), null);
+ } catch (IOException e) {
+ throw new IllegalArgumentException(e);
+ } finally {
+ Thread.currentThread().setContextClassLoader(ccl);
+ }
+ wsdlImport.setDefinition(definition);
+ }
+ }
+
+ // Populate maps of components, entry points and external services
+ aggregateParts = new ArrayList<AggregatePart>();
+ componentsMap = new HashMap<String, Component>();
+ for (Component component : components) {
+ componentsMap.put(component.getName(), component);
+ aggregateParts.add(component);
+ component.initialize(modelContext);
+ ((AggregatePartImpl)component).setAggregate(this);
+ }
+ entryPointsMap = new HashMap<String, EntryPoint>();
+ for (EntryPoint entryPoint : entryPoints) {
+ entryPointsMap.put(entryPoint.getName(), entryPoint);
+ aggregateParts.add(entryPoint);
+ entryPoint.initialize(modelContext);
+ ((AggregatePartImpl)entryPoint).setAggregate(this);
+ }
+ externalServicesMap = new HashMap<String, ExternalService>();
+ for (ExternalService externalService : externalServices) {
+ externalServicesMap.put(externalService.getName(), externalService);
+ aggregateParts.add(externalService);
+ externalService.initialize(modelContext);
+ ((AggregatePartImpl)externalService).setAggregate(this);
+ }
+ for (Wire wire : wires) {
+ wire.initialize(modelContext);
+ }
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyModelObject#freeze()
+ */
+ public void freeze() {
+ if (isFrozen())
+ return;
+ super.freeze();
+
+ // Freeze lists
+ wsdlImports=Collections.unmodifiableList(wsdlImports);
+ freeze(wsdlImports);
+ components=Collections.unmodifiableList(components);
+ freeze(components);
+ entryPoints=Collections.unmodifiableList(entryPoints);
+ freeze(entryPoints);
+ externalServices=Collections.unmodifiableList(externalServices);
+ freeze(externalServices);
+ wires=Collections.unmodifiableList(wires);
+ freeze(wires);
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyModelObject#accept(org.apache.tuscany.model.assembly.AssemblyModelVisitor)
+ */
+ public boolean accept(AssemblyModelVisitor visitor) {
+ if (!super.accept(visitor))
+ return false;
+
+ if (!accept(aggregateParts, visitor))
+ return false;
+
+ if (!accept(wires, visitor))
+ return false;
+
+ return true;
+ }
+
+} //ModuleImpl
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/AggregatePartImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/AggregatePartImpl.java
new file mode 100644
index 0000000000..b9a4434c58
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/AggregatePartImpl.java
@@ -0,0 +1,67 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.assembly.impl;
+
+import org.apache.tuscany.model.assembly.Aggregate;
+import org.apache.tuscany.model.assembly.AggregatePart;
+
+/**
+ * Implementation of AggregatePart.
+ */
+public abstract class AggregatePartImpl extends ExtensibleImpl implements AggregatePart {
+ private Aggregate aggregate;
+ private String name;
+
+ /**
+ * Constructor
+ */
+ protected AggregatePartImpl() {
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AggregatePart#getName()
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AggregatePart#setName(java.lang.String)
+ */
+ public void setName(String value) {
+ checkNotFrozen();
+ name=value;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AggregatePart#getAggregate()
+ */
+ public Aggregate getAggregate() {
+ checkInitialized();
+ return aggregate;
+ }
+
+ /**
+ * Sets the aggregate containing this aggregate part.
+ * @param aggregate
+ */
+ protected void setAggregate(Aggregate aggregate) {
+ checkNotFrozen();
+ this.aggregate=aggregate;
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/AssemblyFactoryImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/AssemblyFactoryImpl.java
new file mode 100644
index 0000000000..0c2550ab10
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/AssemblyFactoryImpl.java
@@ -0,0 +1,204 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.assembly.impl;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.model.assembly.AggregatePart;
+import org.apache.tuscany.model.assembly.AssemblyFactory;
+import org.apache.tuscany.model.assembly.ComponentType;
+import org.apache.tuscany.model.assembly.ConfiguredPort;
+import org.apache.tuscany.model.assembly.ConfiguredProperty;
+import org.apache.tuscany.model.assembly.ConfiguredReference;
+import org.apache.tuscany.model.assembly.ConfiguredService;
+import org.apache.tuscany.model.assembly.EntryPoint;
+import org.apache.tuscany.model.assembly.ExternalService;
+import org.apache.tuscany.model.assembly.Module;
+import org.apache.tuscany.model.assembly.ModuleComponent;
+import org.apache.tuscany.model.assembly.ModuleFragment;
+import org.apache.tuscany.model.assembly.Property;
+import org.apache.tuscany.model.assembly.Reference;
+import org.apache.tuscany.model.assembly.Service;
+import org.apache.tuscany.model.assembly.ServiceURI;
+import org.apache.tuscany.model.assembly.SimpleComponent;
+import org.apache.tuscany.model.assembly.Subsystem;
+import org.apache.tuscany.model.assembly.Wire;
+import org.apache.tuscany.model.types.java.JavaServiceContract;
+import org.apache.tuscany.model.types.java.impl.JavaServiceContractImpl;
+import org.apache.tuscany.model.types.wsdl.WSDLServiceContract;
+import org.apache.tuscany.model.types.wsdl.impl.WSDLServiceContractImpl;
+
+/**
+ * Default implementation of AssemblyFactory
+ */
+public class AssemblyFactoryImpl implements AssemblyFactory {
+
+ /**
+ * Constructor
+ */
+ public AssemblyFactoryImpl() {
+ super();
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyFactory#createSimpleComponent()
+ */
+ public SimpleComponent createSimpleComponent() {
+ return new SimpleComponentImpl();
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyFactory#createComponentType()
+ */
+ public ComponentType createComponentType() {
+ return new ComponentTypeImpl();
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyFactory#createEntryPoint()
+ */
+ public EntryPoint createEntryPoint() {
+ return new EntryPointImpl();
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyFactory#createExternalService()
+ */
+ public ExternalService createExternalService() {
+ return new ExternalServiceImpl();
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyFactory#createJavaServiceContract()
+ */
+ public JavaServiceContract createJavaServiceContract() {
+ return new JavaServiceContractImpl();
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyFactory#createModule()
+ */
+ public Module createModule() {
+ return new ModuleImpl();
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyFactory#createModuleFragment()
+ */
+ public ModuleFragment createModuleFragment() {
+ return new ModuleFragmentImpl();
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyFactory#createModuleComponent()
+ */
+ public ModuleComponent createModuleComponent() {
+ return new ModuleComponentImpl();
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyFactory#createProperty()
+ */
+ public Property createProperty() {
+ return new PropertyImpl();
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyFactory#createConfiguredProperty()
+ */
+ public ConfiguredProperty createConfiguredProperty() {
+ return new ConfiguredPropertyImpl();
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyFactory#createReference()
+ */
+ public Reference createReference() {
+ return new ReferenceImpl();
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyFactory#createConfiguredReference()
+ */
+ public ConfiguredReference createConfiguredReference() {
+ return new ConfiguredReferenceImpl();
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyFactory#createService()
+ */
+ public Service createService() {
+ return new ServiceImpl();
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyFactory#createConfiguredService()
+ */
+ public ConfiguredService createConfiguredService() {
+ return new ConfiguredServiceImpl();
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyFactory#createSubsystem()
+ */
+ public Subsystem createSubsystem() {
+ return new SubsystemImpl();
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyFactory#createWSDLServiceContract()
+ */
+ public WSDLServiceContract createWSDLServiceContract() {
+ return new WSDLServiceContractImpl();
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyFactory#createServiceURI(java.lang.String)
+ */
+ public ServiceURI createServiceURI(String uri) {
+ return new ServiceURIImpl(uri);
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyFactory#createServiceURI(org.apache.tuscany.model.assembly.ModuleComponent, java.lang.String)
+ */
+ public ServiceURI createServiceURI(ModuleComponent moduleComponent, String serviceName) {
+ return new ServiceURIImpl(moduleComponent, serviceName);
+ }
+
+ /*
+ * @see org.apache.tuscany.model.assembly.AssemblyFactory#createServiceURI(org.apache.tuscany.model.assembly.ModuleComponent, org.apache.tuscany.model.assembly.AggregatePart, org.apache.tuscany.model.assembly.ConfiguredPort)
+ */
+ public ServiceURI createServiceURI(ModuleComponent moduleComponent, AggregatePart aggregatePart, ConfiguredPort configuredPort) {
+ return new ServiceURIImpl(moduleComponent, aggregatePart, configuredPort);
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyFactory#createQName(java.lang.String)
+ */
+ public QName createQName(String uri) {
+ int h = uri.indexOf('#');
+ return new QName(uri.substring(0, h), uri.substring(h + 1));
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyFactory#createWire()
+ */
+ public Wire createWire() {
+ return new WireImpl();
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/AssemblyModelContextImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/AssemblyModelContextImpl.java
new file mode 100644
index 0000000000..221b3e0af6
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/AssemblyModelContextImpl.java
@@ -0,0 +1,92 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.assembly.impl;
+
+import org.apache.tuscany.common.resource.ResourceLoader;
+import org.apache.tuscany.model.assembly.AssemblyFactory;
+import org.apache.tuscany.model.assembly.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.loader.AssemblyModelLoader;
+import org.apache.tuscany.sdo.util.SDOUtil;
+
+import commonj.sdo.helper.TypeHelper;
+
+/**
+ */
+public class AssemblyModelContextImpl implements AssemblyModelContext {
+
+ private final AssemblyFactory assemblyFactory;
+ private final AssemblyModelLoader assemblyLoader;
+ private final ResourceLoader systemResourceLoader;
+ private final ResourceLoader applicationResourceLoader;
+ private final TypeHelper typeHelper;
+
+ public AssemblyModelContextImpl(AssemblyModelLoader assemblyLoader, ResourceLoader resourceLoader) {
+ this(new AssemblyFactoryImpl(), assemblyLoader, resourceLoader, resourceLoader);
+ }
+
+ public AssemblyModelContextImpl(AssemblyFactory assemblyFactory, AssemblyModelLoader assemblyLoader, ResourceLoader resourceLoader) {
+ this(assemblyFactory, assemblyLoader, resourceLoader, resourceLoader);
+ }
+
+ public AssemblyModelContextImpl(AssemblyFactory assemblyFactory, AssemblyModelLoader assemblyLoader, ResourceLoader resourceLoader, ResourceLoader artifactLoader) {
+ this(assemblyFactory, assemblyLoader, resourceLoader, artifactLoader, SDOUtil.createTypeHelper());
+ }
+
+ public AssemblyModelContextImpl(AssemblyFactory assemblyFactory, AssemblyModelLoader assemblyLoader, ResourceLoader resourceLoader, ResourceLoader artifactLoader, TypeHelper typeHelper) {
+ this.assemblyFactory = assemblyFactory;
+ this.assemblyLoader = assemblyLoader;
+ this.systemResourceLoader = resourceLoader;
+ this.applicationResourceLoader = artifactLoader;
+ this.typeHelper=typeHelper;
+
+ //FIXME the caller should configure the assemblyLoader himself
+ if (assemblyLoader!=null)
+ assemblyLoader.setModelContext(this);
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyModelContext#getAssemblyFactory()
+ */
+ public AssemblyFactory getAssemblyFactory() {
+ return assemblyFactory;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyModelContext#getSystemResourceLoader()
+ */
+ public ResourceLoader getSystemResourceLoader() {
+ return systemResourceLoader;
+ }
+
+ public ResourceLoader getApplicationResourceLoader() {
+ return applicationResourceLoader;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyModelContext#getAssemblyLoader()
+ */
+ public AssemblyModelLoader getAssemblyLoader() {
+ return assemblyLoader;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyModelContext#getTypeHelper()
+ */
+ public TypeHelper getTypeHelper() {
+ return typeHelper;
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/AssemblyModelObjectImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/AssemblyModelObjectImpl.java
new file mode 100644
index 0000000000..356fc4f0a9
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/AssemblyModelObjectImpl.java
@@ -0,0 +1,132 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.assembly.impl;
+
+import java.util.Collection;
+
+import org.apache.tuscany.model.assembly.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.AssemblyModelObject;
+import org.apache.tuscany.model.assembly.AssemblyModelVisitor;
+
+/**
+ * A base class for assembly model objects.
+ */
+public abstract class AssemblyModelObjectImpl implements AssemblyModelObject {
+
+ private boolean frozen;
+ private boolean initialized;
+
+ /**
+ * Constructor
+ */
+ protected AssemblyModelObjectImpl() {
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyModelObject#accept(org.apache.tuscany.model.assembly.AssemblyModelVisitor)
+ */
+ public boolean accept(AssemblyModelVisitor visitor) {
+ return visitor.visit(this);
+ }
+
+ /**
+ * Walk a visitor through a collection of model objects.
+ * @param collection
+ * @param visitor
+ * @return
+ */
+ protected boolean accept(Collection collection, AssemblyModelVisitor visitor) {
+ for (Object member : collection) {
+ if (member instanceof AssemblyModelObject) {
+ if (!((AssemblyModelObject)member).accept(visitor))
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyModelObject#freeze()
+ */
+ public void freeze() {
+ if (!frozen)
+ frozen=true;
+ }
+
+ /**
+ * Returns true if the object is frozen
+ */
+ protected boolean isFrozen() {
+ return frozen;
+ }
+
+ /**
+ * Freeze members of a collection
+ */
+ protected void freeze(Collection collection) {
+ for (Object member : collection) {
+ if (member instanceof AssemblyModelObject) {
+ ((AssemblyModelObject)member).freeze();
+ }
+ }
+ }
+
+ /**
+ * Check that the current model object can be modified.
+ * @throws IllegalStateException
+ */
+ protected void checkNotFrozen() {
+ if (frozen)
+ throw new IllegalStateException("Attempt to modify a frozen assembly model");
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyModelObject#initialize(org.apache.tuscany.model.assembly.AssemblyModelContext)
+ */
+ public void initialize(AssemblyModelContext modelContext) {
+ if (!initialized)
+ initialized=true;
+ }
+
+ /**
+ * Returns true if the object is initialized
+ */
+ protected boolean isInitialized() {
+ return initialized;
+ }
+
+ /**
+ * Initialize members of a collection
+ */
+ protected void initialize(Collection collection, AssemblyModelContext modelContext) {
+ for (Object member : collection) {
+ if (member instanceof AssemblyModelObject) {
+ ((AssemblyModelObject)member).initialize(modelContext);
+ }
+ }
+ }
+
+ /**
+ * Check that the current model object is initialized.
+ * @throws IllegalStateException
+ */
+ protected void checkInitialized() {
+ if (!initialized)
+ throw new IllegalStateException("Attempt to use an uninitialized assembly model");
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/BindingImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/BindingImpl.java
new file mode 100644
index 0000000000..cd1f0e2cb4
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/BindingImpl.java
@@ -0,0 +1,96 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.assembly.impl;
+
+import org.apache.tuscany.model.assembly.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.AssemblyModelVisitor;
+import org.apache.tuscany.model.assembly.Binding;
+
+/**
+ * An implementation of Binding.
+ */
+public class BindingImpl extends ExtensibleImpl implements Binding {
+
+ private String uri;
+ private Object runtimeConfiguration;
+
+ /**
+ * Constructor
+ */
+ protected BindingImpl() {
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Binding#getURI()
+ */
+ public String getURI() {
+ return uri;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Binding#setURI(java.lang.String)
+ */
+ public void setURI(String value) {
+ checkNotFrozen();
+ uri=value;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyModelObject#initialize(org.apache.tuscany.model.assembly.AssemblyModelContext)
+ */
+ public void initialize(AssemblyModelContext modelContext) {
+ if (isInitialized())
+ return;
+ super.initialize(modelContext);
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyModelObject#freeze()
+ */
+ public void freeze() {
+ if (isFrozen())
+ return;
+ super.freeze();
+
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.RuntimeConfigurationHolder#getRuntimeConfiguration()
+ */
+ public Object getRuntimeConfiguration() {
+ return runtimeConfiguration;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.RuntimeConfigurationHolder#setRuntimeConfiguration(java.lang.Object)
+ */
+ public void setRuntimeConfiguration(Object configuration) {
+ checkNotFrozen();
+ this.runtimeConfiguration = configuration;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.impl.AggregateImpl#accept(org.apache.tuscany.model.assembly.AssemblyModelVisitor)
+ */
+ public boolean accept(AssemblyModelVisitor visitor) {
+ if (!super.accept(visitor))
+ return false;
+
+ return true;
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ComponentImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ComponentImpl.java
new file mode 100644
index 0000000000..2033ebe7f7
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ComponentImpl.java
@@ -0,0 +1,222 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.assembly.impl;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.model.assembly.AssemblyFactory;
+import org.apache.tuscany.model.assembly.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.AssemblyModelVisitor;
+import org.apache.tuscany.model.assembly.Component;
+import org.apache.tuscany.model.assembly.ComponentImplementation;
+import org.apache.tuscany.model.assembly.ConfiguredProperty;
+import org.apache.tuscany.model.assembly.ConfiguredReference;
+import org.apache.tuscany.model.assembly.ConfiguredService;
+import org.apache.tuscany.model.assembly.Property;
+import org.apache.tuscany.model.assembly.Reference;
+import org.apache.tuscany.model.assembly.Service;
+
+/**
+ * An implementation of Component.
+ */
+public abstract class ComponentImpl extends AggregatePartImpl implements Component {
+
+ private List<ConfiguredReference> configuredReferences=new ArrayList<ConfiguredReference>();
+ private Map<String, ConfiguredReference> configuredReferencesMap;
+ private List<ConfiguredService> configuredServices=new ArrayList<ConfiguredService>();
+ private Map<String, ConfiguredService> configuredServicesMap;
+ private List<ConfiguredProperty> configuredProperties=new ArrayList<ConfiguredProperty>();
+ private Map<String, ConfiguredProperty> configuredPropertiesMap;
+ private ComponentImplementation implementation;
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Component#getComponentImplementation()
+ */
+ public ComponentImplementation getComponentImplementation() {
+ return implementation;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Component#setComponentImplementation(org.apache.tuscany.model.assembly.ComponentImplementation)
+ */
+ public void setComponentImplementation(ComponentImplementation value) {
+ checkNotFrozen();
+ implementation=value;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Component#getConfiguredServices()
+ */
+ public List<ConfiguredService> getConfiguredServices() {
+ return configuredServices;
+ }
+
+ public ConfiguredService getConfiguredService(String name) {
+ checkInitialized();
+ return configuredServicesMap.get(name);
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Component#getConfiguredReferences()
+ */
+ public List<ConfiguredReference> getConfiguredReferences() {
+ return configuredReferences;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Component#getConfiguredReference(java.lang.String)
+ */
+ public ConfiguredReference getConfiguredReference(String name) {
+ checkInitialized();
+ return configuredReferencesMap.get(name);
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Component#getConfiguredProperties()
+ */
+ public List<ConfiguredProperty> getConfiguredProperties() {
+ return configuredProperties;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Component#getConfiguredProperty(java.lang.String)
+ */
+ public ConfiguredProperty getConfiguredProperty(String name) {
+ checkInitialized();
+ return configuredPropertiesMap.get(name);
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyModelObject#initialize(org.apache.tuscany.model.assembly.AssemblyModelContext)
+ */
+ public void initialize(AssemblyModelContext modelContext) {
+ if (isInitialized())
+ return;
+ super.initialize(modelContext);
+
+ // Initialize the implementation
+ ComponentImplementation implementation = getComponentImplementation();
+ if (implementation != null) {
+ implementation.initialize(modelContext);
+ }
+
+ // Derive the configured services, references and properties from the component implementation
+ //FIXME we have two options here: either just index the configured services, references and properties
+ // that we find in the corresponding lists, or derive them from the services, references and properties on
+ // the component type, for now just check if the lists are empty or not to determine which option to go with
+ configuredServicesMap = new HashMap<String, ConfiguredService>();
+ configuredReferencesMap = new HashMap<String, ConfiguredReference>();
+ configuredPropertiesMap = new HashMap<String, ConfiguredProperty>();
+ if (configuredServices.isEmpty() && configuredReferences.isEmpty() && configuredProperties.isEmpty()) {
+ if (implementation != null) {
+ AssemblyFactory factory = modelContext.getAssemblyFactory();
+ for (Service service : implementation.getComponentType().getServices()) {
+ ConfiguredService configuredService = factory.createConfiguredService();
+ configuredService.setPort(service);
+ configuredServices.add(configuredService);
+ configuredServicesMap.put(service.getName(), configuredService);
+ ((ConfiguredPortImpl)configuredService).setAggregatePart(this);
+ configuredService.initialize(modelContext);
+ }
+
+ for (Reference reference : implementation.getComponentType().getReferences()) {
+ ConfiguredReference configuredReference = factory.createConfiguredReference();
+ configuredReference.setPort(reference);
+ configuredReferences.add(configuredReference);
+ configuredReferencesMap.put(reference.getName(), configuredReference);
+ ((ConfiguredPortImpl)configuredReference).setAggregatePart(this);
+ configuredReference.initialize(modelContext);
+ }
+
+ // Derive configured properties from the properties on the component type
+ for (Property property : implementation.getComponentType().getProperties()) {
+ ConfiguredProperty configuredProperty = factory.createConfiguredProperty();
+ configuredProperty.setProperty(property);
+ configuredProperties.add(configuredProperty);
+ configuredPropertiesMap.put(property.getName(), configuredProperty);
+ configuredProperty.initialize(modelContext);
+ }
+
+ }
+ } else {
+
+ // Just populate the maps of services, references and properties from the contents of
+ // the corresponding lists
+ for (ConfiguredService configuredService : configuredServices) {
+ configuredServicesMap.put(configuredService.getService().getName(), configuredService);
+ ((ConfiguredPortImpl)configuredService).setAggregatePart(this);
+ configuredService.initialize(modelContext);
+ }
+
+ for (ConfiguredReference configuredReference : configuredReferences) {
+ configuredReferencesMap.put(configuredReference.getReference().getName(), configuredReference);
+ ((ConfiguredPortImpl)configuredReference).setAggregatePart(this);
+ configuredReference.initialize(modelContext);
+ }
+
+ for (ConfiguredProperty configuredProperty : configuredProperties) {
+ configuredPropertiesMap.put(configuredProperty.getProperty().getName(), configuredProperty);
+ configuredProperty.initialize(modelContext);
+ }
+ }
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyModelObject#freeze()
+ */
+ public void freeze() {
+ if (isFrozen())
+ return;
+ super.freeze();
+
+ // Freeze configured services, references and properties
+ configuredServices=Collections.unmodifiableList(configuredServices);
+ freeze(configuredServices);
+ configuredReferences=Collections.unmodifiableList(configuredReferences);
+ freeze(configuredReferences);
+ configuredProperties=Collections.unmodifiableList(configuredProperties);
+ freeze(configuredProperties);
+ if (implementation!=null)
+ implementation.freeze();
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.impl.AssemblyModelObjectImpl#accept(org.apache.tuscany.model.assembly.AssemblyModelVisitor)
+ */
+ public boolean accept(AssemblyModelVisitor visitor) {
+ if (!super.accept(visitor))
+ return false;
+
+ if (!accept(configuredServices, visitor))
+ return false;
+ if (!accept(configuredReferences, visitor))
+ return false;
+ if (!accept(configuredProperties, visitor))
+ return false;
+ if (implementation!=null) {
+ if (!implementation.accept(visitor))
+ return false;
+ }
+
+ return true;
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ComponentImplementationImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ComponentImplementationImpl.java
new file mode 100644
index 0000000000..f14a86c713
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ComponentImplementationImpl.java
@@ -0,0 +1,108 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.assembly.impl;
+
+import org.apache.tuscany.model.assembly.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.AssemblyModelVisitor;
+import org.apache.tuscany.model.assembly.ComponentImplementation;
+import org.apache.tuscany.model.assembly.ComponentType;
+
+/**
+ * An implementation of ComponentImplementation.
+ */
+public class ComponentImplementationImpl extends ExtensibleImpl implements ComponentImplementation {
+
+ private ComponentType componentType;
+ private Object runtimeConfiguration;
+
+ /**
+ * Constructor
+ */
+ protected ComponentImplementationImpl() {
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ComponentImplementation#getComponentType()
+ */
+ public ComponentType getComponentType() {
+ return componentType;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ComponentImplementation#setComponentType(org.apache.tuscany.model.assembly.ComponentType)
+ */
+ public void setComponentType(ComponentType componentType) {
+ checkNotFrozen();
+ this.componentType=componentType;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyModelObject#initialize(org.apache.tuscany.model.assembly.AssemblyModelContext)
+ */
+ public void initialize(AssemblyModelContext modelContext) {
+ if (isInitialized())
+ return;
+ super.initialize(modelContext);
+
+ if (componentType!=null)
+ componentType.initialize(modelContext);
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyModelObject#freeze()
+ */
+ public void freeze() {
+ if (isFrozen())
+ return;
+ super.freeze();
+
+ // Freeze component type
+ if (componentType!=null)
+ componentType.freeze();
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.RuntimeConfigurationHolder#getRuntimeConfiguration()
+ */
+ public Object getRuntimeConfiguration() {
+ return runtimeConfiguration;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.RuntimeConfigurationHolder#setRuntimeConfiguration(java.lang.Object)
+ */
+ public void setRuntimeConfiguration(Object configuration) {
+ checkNotFrozen();
+ this.runtimeConfiguration = configuration;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.impl.AggregateImpl#accept(org.apache.tuscany.model.assembly.AssemblyModelVisitor)
+ */
+ public boolean accept(AssemblyModelVisitor visitor) {
+ if (!super.accept(visitor))
+ return false;
+
+ if (componentType!=null) {
+ if (!componentType.accept(visitor))
+ return false;
+ }
+
+ return true;
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ComponentTypeImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ComponentTypeImpl.java
new file mode 100644
index 0000000000..baef2e9b2a
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ComponentTypeImpl.java
@@ -0,0 +1,152 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.assembly.impl;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.model.assembly.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.AssemblyModelVisitor;
+import org.apache.tuscany.model.assembly.ComponentType;
+import org.apache.tuscany.model.assembly.Property;
+import org.apache.tuscany.model.assembly.Reference;
+import org.apache.tuscany.model.assembly.Service;
+
+/**
+ * An implementation of ComponentType.
+ */
+public class ComponentTypeImpl extends ExtensibleImpl implements ComponentType {
+
+ private List<Reference> references=new ArrayList<Reference>();
+ private Map<String, Reference> referencesMap;
+ private List<Service> services=new ArrayList<Service>();
+ private Map<String, Service> servicesMap;
+ private List<Property> properties=new ArrayList<Property>();
+ private Map<String, Property> propertiesMap;
+
+ /**
+ * Constructor
+ */
+ protected ComponentTypeImpl() {
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ComponentType#getReferences()
+ */
+ public List<Reference> getReferences() {
+ return references;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ComponentType#getReference(java.lang.String)
+ */
+ public Reference getReference(String name) {
+ checkInitialized();
+ return referencesMap.get(name);
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ComponentType#getServices()
+ */
+ public List<Service> getServices() {
+ return services;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ComponentType#getService(java.lang.String)
+ */
+ public Service getService(String name) {
+ checkInitialized();
+ return servicesMap.get(name);
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ComponentType#getProperties()
+ */
+ public List<Property> getProperties() {
+ return properties;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ComponentType#getProperty(java.lang.String)
+ */
+ public Property getProperty(String name) {
+ checkInitialized();
+ return propertiesMap.get(name);
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyModelObject#initialize(org.apache.tuscany.model.assembly.AssemblyModelContext)
+ */
+ public void initialize(AssemblyModelContext modelContext) {
+ if (isInitialized())
+ return;
+ super.initialize(modelContext);
+
+ // Populate maps of references, properties and services
+ referencesMap = new HashMap<String, Reference>();
+ for (Reference reference : references) {
+ referencesMap.put(reference.getName(), reference);
+ reference.initialize(modelContext);
+ }
+ propertiesMap = new HashMap<String, Property>();
+ for (Property property : properties) {
+ propertiesMap.put(property.getName(), property);
+ property.initialize(modelContext);
+ }
+ servicesMap = new HashMap<String, Service>();
+ for (Service service : services) {
+ servicesMap.put(service.getName(), service);
+ service.initialize(modelContext);
+ }
+ }
+
+ public void freeze() {
+ if (isFrozen())
+ return;
+ super.freeze();
+
+ // Freeze lists of services, references and properties
+ services=Collections.unmodifiableList(services);
+ freeze(services);
+ references=Collections.unmodifiableList(references);
+ freeze(references);
+ properties=Collections.unmodifiableList(properties);
+ freeze(properties);
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.impl.AssemblyModelObjectImpl#accept(org.apache.tuscany.model.assembly.AssemblyModelVisitor)
+ */
+ public boolean accept(AssemblyModelVisitor visitor) {
+ if (!super.accept(visitor))
+ return false;
+
+ if (!accept(services, visitor))
+ return false;
+ if (!accept(references, visitor))
+ return false;
+ if (!accept(properties, visitor))
+ return false;
+
+ return true;
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ConfiguredPortImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ConfiguredPortImpl.java
new file mode 100644
index 0000000000..9662d13dc7
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ConfiguredPortImpl.java
@@ -0,0 +1,142 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.assembly.impl;
+
+import org.apache.tuscany.model.assembly.AggregatePart;
+import org.apache.tuscany.model.assembly.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.AssemblyModelVisitor;
+import org.apache.tuscany.model.assembly.ConfiguredPort;
+import org.apache.tuscany.model.assembly.Port;
+
+/**
+ * Implementation of ConfiguredPort.
+ */
+public abstract class ConfiguredPortImpl extends AssemblyModelObjectImpl implements ConfiguredPort {
+ private AggregatePart aggregatePart;
+ private Port port;
+
+ private Object runtimeConfiguration;
+ private Object proxyFactory;
+
+ /**
+ * Constructor
+ */
+ protected ConfiguredPortImpl() {
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ConfiguredPort#getPort()
+ */
+ public Port getPort() {
+ return port;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ConfiguredPort#setPort(org.apache.tuscany.model.assembly.Port)
+ */
+ public void setPort(Port port) {
+ checkNotFrozen();
+ this.port = port;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ConfiguredPort#getAggregatePart()
+ */
+ public AggregatePart getAggregatePart() {
+ checkInitialized();
+ return aggregatePart;
+ }
+
+ /**
+ * Sets the aggregate part containing this configured port.
+ * @param aggregatePart
+ */
+ protected void setAggregatePart(AggregatePart aggregatePart) {
+ checkNotFrozen();
+ this.aggregatePart=aggregatePart;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ConfiguredPort#getProxyFactory()
+ */
+ public Object getProxyFactory() {
+ return proxyFactory;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ConfiguredPort#setProxyFactory(java.lang.Object)
+ */
+ public void setProxyFactory(Object proxyFactory) {
+ checkNotFrozen();
+ this.proxyFactory = proxyFactory;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.RuntimeConfigurationHolder#getRuntimeConfiguration()
+ */
+ public Object getRuntimeConfiguration() {
+ return runtimeConfiguration;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.RuntimeConfigurationHolder#setRuntimeConfiguration(java.lang.Object)
+ */
+ public void setRuntimeConfiguration(Object configuration) {
+ checkNotFrozen();
+ runtimeConfiguration = configuration;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.impl.AssemblyModelObjectImpl#initialize(org.apache.tuscany.model.assembly.AssemblyModelContext)
+ */
+ public void initialize(AssemblyModelContext modelContext) {
+ if (isInitialized())
+ return;
+ super.initialize(modelContext);
+
+ if (port!=null)
+ port.initialize(modelContext);
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.impl.AssemblyModelObjectImpl#freeze()
+ */
+ public void freeze() {
+ if (isFrozen())
+ return;
+ super.freeze();
+
+ if (port!=null)
+ port.freeze();
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.impl.AssemblyModelObjectImpl#accept(org.apache.tuscany.model.assembly.AssemblyModelVisitor)
+ */
+ public boolean accept(AssemblyModelVisitor visitor) {
+ if (!super.accept(visitor))
+ return false;
+
+ if (port!=null) {
+ if (!port.accept(visitor))
+ return false;
+ }
+
+ return true;
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ConfiguredPropertyImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ConfiguredPropertyImpl.java
new file mode 100644
index 0000000000..477c62ad44
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ConfiguredPropertyImpl.java
@@ -0,0 +1,123 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.assembly.impl;
+
+import org.apache.tuscany.model.assembly.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.AssemblyModelVisitor;
+import org.apache.tuscany.model.assembly.ConfiguredProperty;
+import org.apache.tuscany.model.assembly.OverrideOption;
+import org.apache.tuscany.model.assembly.Property;
+
+/**
+ * Implementation of ConfiguredProperty
+ */
+public class ConfiguredPropertyImpl extends AssemblyModelObjectImpl implements ConfiguredProperty {
+ private Property property;
+ private OverrideOption overrideOption;
+ private Object value;
+
+ /**
+ * Constructor
+ */
+ protected ConfiguredPropertyImpl() {
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ConfiguredProperty#getProperty()
+ */
+ public Property getProperty() {
+ return property;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ConfiguredProperty#setProperty(org.apache.tuscany.model.assembly.Property)
+ */
+ public void setProperty(Property property) {
+ checkNotFrozen();
+ this.property = property;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ConfiguredProperty#getValue()
+ */
+ public Object getValue() {
+ return value;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ConfiguredProperty#setValue(java.lang.Object)
+ */
+ public void setValue(Object value) {
+ checkNotFrozen();
+ this.value = value;
+ }
+
+ /*
+ * @see org.apache.tuscany.model.assembly.ConfiguredProperty#getOverrideOption()
+ */
+ public OverrideOption getOverrideOption() {
+ return overrideOption;
+ }
+
+ /*
+ * @see org.apache.tuscany.model.assembly.ConfiguredProperty#setOverrideOption(org.apache.tuscany.model.assembly.OverrideOption)
+ */
+ public void setOverrideOption(OverrideOption value) {
+ checkNotFrozen();
+ this.overrideOption=value;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.impl.AssemblyModelObjectImpl#initialize(org.apache.tuscany.model.assembly.AssemblyModelContext)
+ */
+ public void initialize(AssemblyModelContext modelContext) {
+ if (isInitialized())
+ return;
+ super.initialize(modelContext);
+
+ if (property!=null)
+ property.initialize(modelContext);
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.impl.AssemblyModelObjectImpl#freeze()
+ */
+ public void freeze() {
+ if (isFrozen())
+ return;
+ super.freeze();
+
+ if (property!=null)
+ property.freeze();
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.impl.AssemblyModelObjectImpl#accept(org.apache.tuscany.model.assembly.AssemblyModelVisitor)
+ */
+ public boolean accept(AssemblyModelVisitor visitor) {
+ if (!super.accept(visitor))
+ return false;
+
+ if (property!=null) {
+ if (!property.accept(visitor))
+ return false;
+ }
+
+ return true;
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ConfiguredReferenceImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ConfiguredReferenceImpl.java
new file mode 100644
index 0000000000..c9bc9b332f
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ConfiguredReferenceImpl.java
@@ -0,0 +1,72 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.assembly.impl;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.tuscany.model.assembly.ConfiguredReference;
+import org.apache.tuscany.model.assembly.ConfiguredService;
+import org.apache.tuscany.model.assembly.Reference;
+
+/**
+ * An implementation of ConfiguredReference.
+ */
+public class ConfiguredReferenceImpl extends ConfiguredPortImpl implements ConfiguredReference {
+
+ private List<ConfiguredService> targetConfiguredServices = new ArrayList<ConfiguredService>();
+
+ /**
+ * Constructor
+ */
+ protected ConfiguredReferenceImpl() {
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ConfiguredReference#getReference()
+ */
+ public Reference getReference() {
+ return (Reference) super.getPort();
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ConfiguredReference#setReference(org.apache.tuscany.model.assembly.Reference)
+ */
+ public void setReference(Reference reference) {
+ checkNotFrozen();
+ super.setPort(reference);
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ConfiguredReference#getTargetConfiguredServices()
+ */
+ public List<ConfiguredService> getTargetConfiguredServices() {
+ return targetConfiguredServices;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.impl.ConfiguredPortImpl#freeze()
+ */
+ public void freeze() {
+ super.freeze();
+
+ // Freeze list of configured services
+ targetConfiguredServices=Collections.unmodifiableList(targetConfiguredServices);
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ConfiguredServiceImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ConfiguredServiceImpl.java
new file mode 100644
index 0000000000..3e5d1a9cf5
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ConfiguredServiceImpl.java
@@ -0,0 +1,48 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.assembly.impl;
+
+import org.apache.tuscany.model.assembly.ConfiguredService;
+import org.apache.tuscany.model.assembly.Service;
+
+/**
+ * An implementation of ConfiguredService.
+ */
+public class ConfiguredServiceImpl extends ConfiguredPortImpl implements ConfiguredService {
+
+ /**
+ * Constructor
+ */
+ protected ConfiguredServiceImpl() {
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ConfiguredService#getService()
+ */
+ public Service getService() {
+ return (Service) super.getPort();
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ConfiguredService#setService(org.apache.tuscany.model.assembly.Service)
+ */
+ public void setService(Service service) {
+ checkNotFrozen();
+ super.setPort(service);
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/EntryPointImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/EntryPointImpl.java
new file mode 100644
index 0000000000..0d39089be9
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/EntryPointImpl.java
@@ -0,0 +1,145 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.assembly.impl;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.tuscany.model.assembly.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.AssemblyModelVisitor;
+import org.apache.tuscany.model.assembly.Binding;
+import org.apache.tuscany.model.assembly.ConfiguredReference;
+import org.apache.tuscany.model.assembly.ConfiguredService;
+import org.apache.tuscany.model.assembly.EntryPoint;
+
+/**
+ * An implementation of EntryPoint.
+ */
+public class EntryPointImpl extends AggregatePartImpl implements EntryPoint {
+
+ private ConfiguredService configuredService;
+ private ConfiguredReference configuredReference;
+ private List<Binding> bindings=new ArrayList<Binding>();
+
+ /**
+ * Constructor
+ */
+ protected EntryPointImpl() {
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.EntryPoint#getConfiguredReference()
+ */
+ public ConfiguredReference getConfiguredReference() {
+ return configuredReference;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.EntryPoint#setConfiguredReference(org.apache.tuscany.model.assembly.ConfiguredReference)
+ */
+ public void setConfiguredReference(ConfiguredReference configuredReference) {
+ checkNotFrozen();
+ this.configuredReference=configuredReference;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.EntryPoint#getConfiguredService()
+ */
+ public ConfiguredService getConfiguredService() {
+ return configuredService;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.EntryPoint#setConfiguredService(org.apache.tuscany.model.assembly.ConfiguredService)
+ */
+ public void setConfiguredService(ConfiguredService configuredService) {
+ checkNotFrozen();
+ this.configuredService=configuredService;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.EntryPoint#getBindings()
+ */
+ public List<Binding> getBindings() {
+ return bindings;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyModelObject#initialize(org.apache.tuscany.model.assembly.AssemblyModelContext)
+ */
+ public void initialize(AssemblyModelContext modelContext) {
+ if (isInitialized())
+ return;
+ super.initialize(modelContext);
+
+ // Initialize the service contract and reference to the published service
+ if (configuredReference != null) {
+ ((ConfiguredPortImpl)configuredReference).setAggregatePart(this);
+ configuredReference.initialize(modelContext);
+ }
+ if (configuredService != null) {
+ ((ConfiguredPortImpl)configuredService).setAggregatePart(this);
+ configuredService.initialize(modelContext);
+ }
+
+ // Initialize the bindings
+ initialize(bindings, modelContext);
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyModelObject#freeze()
+ */
+ public void freeze() {
+ if (isFrozen())
+ return;
+ super.freeze();
+
+ // Freeze the service contract and configured reference
+ if (configuredReference != null)
+ configuredReference.freeze();
+ if (configuredService != null)
+ configuredService.freeze();
+
+ // Freeze the bindings
+ bindings=Collections.unmodifiableList(bindings);
+ freeze(bindings);
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.impl.AssemblyModelObjectImpl#accept(org.apache.tuscany.model.assembly.AssemblyModelVisitor)
+ */
+ public boolean accept(AssemblyModelVisitor visitor) {
+ if (!super.accept(visitor))
+ return false;
+
+ if (configuredReference!=null) {
+ if (!configuredReference.accept(visitor))
+ return false;
+ }
+
+ if (configuredService!=null) {
+ if (!configuredService.accept(visitor))
+ return false;
+ }
+
+ if (!accept(bindings, visitor))
+ return false;
+
+ return true;
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ExtensibleImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ExtensibleImpl.java
new file mode 100644
index 0000000000..05f2082ced
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ExtensibleImpl.java
@@ -0,0 +1,92 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.assembly.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.model.assembly.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.AssemblyModelVisitor;
+import org.apache.tuscany.model.assembly.Extensible;
+
+/**
+ * An implementation of Extensible.
+ */
+public abstract class ExtensibleImpl extends AssemblyModelObjectImpl implements Extensible {
+
+ private List<Object> extensibilityElements=new ArrayList<Object>();
+ private List<Object> extensibilityAttributes=new ArrayList<Object>();
+
+ /**
+ * Constructor
+ */
+ protected ExtensibleImpl() {
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Extensible#getExtensibilityElements()
+ */
+ public List getExtensibilityElements() {
+ return extensibilityElements;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Extensible#getExtensibilityAttributes()
+ */
+ public List getExtensibilityAttributes() {
+ return extensibilityAttributes;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyModelObject#initialize(org.apache.tuscany.model.assembly.AssemblyModelContext)
+ */
+ public void initialize(AssemblyModelContext modelContext) {
+ if (isInitialized())
+ return;
+ super.initialize(modelContext);
+
+ // Initialize extensibility elements and attributes
+ initialize(extensibilityElements, modelContext);
+ initialize(extensibilityAttributes, modelContext);
+ }
+
+ public void freeze() {
+ if (isFrozen())
+ return;
+ super.freeze();
+
+ // Freeze extensibility elements and attributes
+ freeze(extensibilityElements);
+ freeze(extensibilityAttributes);
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.impl.AssemblyModelObjectImpl#accept(org.apache.tuscany.model.assembly.AssemblyModelVisitor)
+ */
+ public boolean accept(AssemblyModelVisitor visitor) {
+ if (!super.accept(visitor))
+ return false;
+
+ if (!accept(extensibilityElements, visitor))
+ return false;
+ if (!accept(extensibilityAttributes, visitor))
+ return false;
+
+ return true;
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ExternalServiceImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ExternalServiceImpl.java
new file mode 100644
index 0000000000..33eced7e1f
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ExternalServiceImpl.java
@@ -0,0 +1,135 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.assembly.impl;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.tuscany.model.assembly.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.AssemblyModelVisitor;
+import org.apache.tuscany.model.assembly.Binding;
+import org.apache.tuscany.model.assembly.ConfiguredService;
+import org.apache.tuscany.model.assembly.ExternalService;
+import org.apache.tuscany.model.assembly.OverrideOption;
+
+/**
+ * An implementation ExternalService.
+ */
+public class ExternalServiceImpl extends AggregatePartImpl implements ExternalService {
+
+ private ConfiguredService configuredService;
+ private OverrideOption overrideOption;
+ private List<Binding> bindings=new ArrayList<Binding>();
+
+ /**
+ * Constructor
+ */
+ protected ExternalServiceImpl() {
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.sdo.impl.ExternalServiceImpl#getOverrideOption()
+ */
+ public OverrideOption getOverrideOption() {
+ return overrideOption;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ExternalService#setOverrideOption(org.apache.tuscany.model.assembly.OverrideOption)
+ */
+ public void setOverrideOption(OverrideOption newOverridable) {
+ checkNotFrozen();
+ overrideOption=newOverridable;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ExternalService#getBindings()
+ */
+ public List<Binding> getBindings() {
+ return bindings;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ExternalService#getConfiguredService()
+ */
+ public ConfiguredService getConfiguredService() {
+ return configuredService;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ExternalService#setConfiguredService(org.apache.tuscany.model.assembly.ConfiguredService)
+ */
+ public void setConfiguredService(ConfiguredService configuredService) {
+ checkNotFrozen();
+ this.configuredService=configuredService;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyModelObject#initialize(org.apache.tuscany.model.assembly.AssemblyModelContext)
+ */
+ public void initialize(AssemblyModelContext modelContext) {
+ if (isInitialized())
+ return;
+ super.initialize(modelContext);
+
+ // Initialize the configured service
+ if (configuredService != null) {
+ ((ConfiguredPortImpl)configuredService).setAggregatePart(this);
+ configuredService.initialize(modelContext);
+ }
+
+ // Initialize the bindings
+ initialize(bindings, modelContext);
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyModelObject#freeze()
+ */
+ public void freeze() {
+ if (isFrozen())
+ return;
+ super.freeze();
+
+ // Freeze the configured service
+ if (configuredService!= null)
+ configuredService.freeze();
+
+ // Freeze the bindings
+ bindings=Collections.unmodifiableList(bindings);
+ freeze(bindings);
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.impl.ExtensibleImpl#accept(org.apache.tuscany.model.assembly.AssemblyModelVisitor)
+ */
+ public boolean accept(AssemblyModelVisitor visitor) {
+ if (!super.accept(visitor))
+ return false;
+
+ if (configuredService!=null) {
+ if (!configuredService.accept(visitor))
+ return false;
+ }
+
+ if (!accept(bindings, visitor))
+ return false;
+
+ return true;
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ModuleComponentImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ModuleComponentImpl.java
new file mode 100644
index 0000000000..d830c5c8d8
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ModuleComponentImpl.java
@@ -0,0 +1,65 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.assembly.impl;
+
+import org.apache.tuscany.model.assembly.Module;
+import org.apache.tuscany.model.assembly.ModuleComponent;
+
+/**
+ * An implementation of ModuleComponent.
+ */
+public class ModuleComponentImpl extends ComponentImpl implements ModuleComponent {
+
+ private String uri;
+
+ /**
+ * Constructor
+ */
+ protected ModuleComponentImpl() {
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ModuleComponent#setModuleImplementation(org.apache.tuscany.model.assembly.Module)
+ */
+ public void setModuleImplementation(Module module) {
+ checkNotFrozen();
+ super.setComponentImplementation(module);
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ModuleComponent#getModuleImplementation()
+ */
+ public Module getModuleImplementation() {
+ return (Module)super.getComponentImplementation();
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ModuleComponent#getURI()
+ */
+ public String getURI() {
+ return uri;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ModuleComponent#setURI(java.lang.String)
+ */
+ public void setURI(String value) {
+ checkNotFrozen();
+ uri=value;
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ModuleFragmentImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ModuleFragmentImpl.java
new file mode 100644
index 0000000000..a36935dbfb
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ModuleFragmentImpl.java
@@ -0,0 +1,32 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.assembly.impl;
+
+import org.apache.tuscany.model.assembly.ModuleFragment;
+
+/**
+ * An implementation of ModuleFragment.
+ */
+public class ModuleFragmentImpl extends AggregateImpl implements ModuleFragment {
+
+ /**
+ * Constructor
+ */
+ protected ModuleFragmentImpl() {
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ModuleImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ModuleImpl.java
new file mode 100644
index 0000000000..8d89590225
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ModuleImpl.java
@@ -0,0 +1,243 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.assembly.impl;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.model.assembly.AssemblyFactory;
+import org.apache.tuscany.model.assembly.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.AssemblyModelVisitor;
+import org.apache.tuscany.model.assembly.Component;
+import org.apache.tuscany.model.assembly.ComponentType;
+import org.apache.tuscany.model.assembly.ConfiguredProperty;
+import org.apache.tuscany.model.assembly.ConfiguredReference;
+import org.apache.tuscany.model.assembly.ConfiguredService;
+import org.apache.tuscany.model.assembly.EntryPoint;
+import org.apache.tuscany.model.assembly.ExternalService;
+import org.apache.tuscany.model.assembly.Module;
+import org.apache.tuscany.model.assembly.ModuleFragment;
+import org.apache.tuscany.model.assembly.Multiplicity;
+import org.apache.tuscany.model.assembly.OverrideOption;
+import org.apache.tuscany.model.assembly.Reference;
+import org.apache.tuscany.model.assembly.Service;
+import org.apache.tuscany.model.assembly.ServiceContract;
+import org.apache.tuscany.model.assembly.ServiceURI;
+import org.apache.tuscany.model.assembly.Wire;
+
+/**
+ * An implementation of Module.
+ */
+public class ModuleImpl extends AggregateImpl implements Module {
+
+ private List<ModuleFragment> moduleFragments = new ArrayList<ModuleFragment>();
+ private Map<String, ModuleFragment> moduleFragmentsMap;
+ private ComponentType componentType;
+ private Object runtimeConfiguration;
+
+ /**
+ * Constructor
+ */
+ protected ModuleImpl() {
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ComponentImplementation#getComponentType()
+ */
+ public ComponentType getComponentType() {
+ return componentType;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ComponentImplementation#setComponentType(org.apache.tuscany.model.assembly.ComponentType)
+ */
+ public void setComponentType(ComponentType componentType) {
+ checkNotFrozen();
+ this.componentType=componentType;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Module#getModuleFragments()
+ */
+ public List<ModuleFragment> getModuleFragments() {
+ return moduleFragments;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Module#getModuleFragment(java.lang.String)
+ */
+ public ModuleFragment getModuleFragment(String name) {
+ checkInitialized();
+ return moduleFragmentsMap.get(name);
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyModelObject#initialize(org.apache.tuscany.model.assembly.AssemblyModelContext)
+ */
+ public void initialize(AssemblyModelContext modelContext) {
+ if (isInitialized())
+ return;
+
+ // Populate map of module fragments
+ moduleFragmentsMap = new HashMap<String, ModuleFragment>();
+ for (ModuleFragment moduleFragment : moduleFragments) {
+ moduleFragmentsMap.put(moduleFragment.getName(), moduleFragment);
+
+ // Add all WSDL imports, components, entry points and external services from the module fragments
+ getWSDLImports().addAll(moduleFragment.getWSDLImports());
+ getComponents().addAll(moduleFragment.getComponents());
+ getEntryPoints().addAll(moduleFragment.getEntryPoints());
+ getExternalServices().addAll(moduleFragment.getExternalServices());
+
+ // Add all the wires from the module fragments
+ getWires().addAll(moduleFragment.getWires());
+
+ moduleFragment.initialize(modelContext);
+ }
+
+ // Initialize the aggregate
+ super.initialize(modelContext);
+
+ // Derive the component type from the entry points and external services in the module
+ // Also derive properties from the overridable properties of the components in the module
+ if (componentType==null) {
+ AssemblyFactory factory = modelContext.getAssemblyFactory();
+ componentType = factory.createComponentType();
+ for (EntryPoint entryPoint : getEntryPoints()) {
+ Service service = factory.createService();
+ service.setName(entryPoint.getName());
+ ServiceContract serviceContract = entryPoint.getConfiguredService().getService().getServiceContract();
+ if (serviceContract != null)
+ service.setServiceContract(serviceContract);
+ componentType.getServices().add(service);
+ }
+ for (ExternalService externalService : getExternalServices()) {
+ if (externalService.getOverrideOption()==null || externalService.getOverrideOption()==OverrideOption.NO)
+ continue;
+ Reference reference = factory.createReference();
+ reference.setName(externalService.getName());
+ ServiceContract serviceContract = externalService.getConfiguredService().getService().getServiceContract();
+ if (serviceContract != null)
+ reference.setServiceContract(serviceContract);
+ componentType.getReferences().add(reference);
+ }
+ for (Component component : getComponents()) {
+ for (ConfiguredProperty configuredProperty : component.getConfiguredProperties()) {
+ if (configuredProperty.getOverrideOption()==null || configuredProperty.getOverrideOption()==OverrideOption.NO)
+ continue;
+ componentType.getProperties().add(configuredProperty.getProperty());
+ }
+ }
+ }
+ componentType.initialize(modelContext);
+
+
+ // Wire the module parts
+ for (Wire wire : getWires()) {
+
+ // Get the source reference
+ ServiceURI sourceURI=wire.getSource();
+ ConfiguredReference configuredReference = null;
+ String partName = sourceURI.getPartName();
+ String referenceName = sourceURI.getServiceName();
+ if (referenceName != null) {
+ Component component = getComponent(partName);
+ if (component != null) {
+ configuredReference = component.getConfiguredReference(referenceName);
+ }
+ } else {
+ EntryPoint entryPoint = getEntryPoint(partName);
+ if (entryPoint != null) {
+ configuredReference = entryPoint.getConfiguredReference();
+ }
+ }
+ if (configuredReference == null) {
+ throw new IllegalArgumentException("Cannot find wire source " + sourceURI.getAddress());
+ } else {
+
+ // Resolve the target service endpoint
+ ServiceURI targetURI = wire.getTarget();
+ ConfiguredService configuredService = getConfiguredService(targetURI);
+ if (configuredService != null) {
+
+ // Wire the reference to the target
+ Multiplicity multiplicity=configuredReference.getReference().getMultiplicity();
+ if (multiplicity==Multiplicity.ZERO_N || multiplicity==Multiplicity.ONE_N) {
+ configuredReference.getTargetConfiguredServices().add(configuredService);
+ } else {
+ configuredReference.getTargetConfiguredServices().clear();
+ configuredReference.getTargetConfiguredServices().add(configuredService);
+ }
+ } else {
+ throw new IllegalArgumentException("Cannot find service for " + targetURI.getAddress());
+ }
+ }
+ }
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyModelObject#freeze()
+ */
+ public void freeze() {
+ if (isFrozen())
+ return;
+ super.freeze();
+
+ // Freeze component type and module fragments
+ if (componentType!=null)
+ componentType.freeze();
+ moduleFragments=Collections.unmodifiableList(moduleFragments);
+ freeze(moduleFragments);
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.RuntimeConfigurationHolder#getRuntimeConfiguration()
+ */
+ public Object getRuntimeConfiguration() {
+ return runtimeConfiguration;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.RuntimeConfigurationHolder#setRuntimeConfiguration(java.lang.Object)
+ */
+ public void setRuntimeConfiguration(Object configuration) {
+ checkNotFrozen();
+ this.runtimeConfiguration = configuration;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.impl.AggregateImpl#accept(org.apache.tuscany.model.assembly.AssemblyModelVisitor)
+ */
+ public boolean accept(AssemblyModelVisitor visitor) {
+ if (!super.accept(visitor))
+ return false;
+
+ if (componentType!=null) {
+ if (!componentType.accept(visitor))
+ return false;
+ }
+
+ if (!accept(moduleFragments, visitor))
+ return false;
+
+ return true;
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/PortImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/PortImpl.java
new file mode 100644
index 0000000000..ae92300d4e
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/PortImpl.java
@@ -0,0 +1,106 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.assembly.impl;
+
+import org.apache.tuscany.model.assembly.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.AssemblyModelVisitor;
+import org.apache.tuscany.model.assembly.Port;
+import org.apache.tuscany.model.assembly.ServiceContract;
+
+/**
+ * An implementation of Port.
+ */
+public abstract class PortImpl extends AssemblyModelObjectImpl implements Port {
+
+ private ServiceContract serviceContract;
+ private String name;
+
+ /**
+ * Constructor
+ */
+ protected PortImpl() {
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Port#getName()
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Port#setName(java.lang.String)
+ */
+ public void setName(String value) {
+ checkNotFrozen();
+ name=value;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Port#getServiceContract()
+ */
+ public ServiceContract getServiceContract() {
+ return serviceContract;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Port#setServiceContract(org.apache.tuscany.model.assembly.ServiceContract)
+ */
+ public void setServiceContract(ServiceContract value) {
+ checkNotFrozen();
+ serviceContract=value;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.impl.AssemblyModelObjectImpl#initialize(org.apache.tuscany.model.assembly.AssemblyModelContext)
+ */
+ public void initialize(AssemblyModelContext modelContext) {
+ if (isInitialized())
+ return;
+ super.initialize(modelContext);
+
+ if (serviceContract!=null)
+ serviceContract.initialize(modelContext);
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.impl.AssemblyModelObjectImpl#freeze()
+ */
+ public void freeze() {
+ if (isFrozen())
+ return;
+ super.freeze();
+
+ if (serviceContract!=null)
+ serviceContract.freeze();
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.impl.AssemblyModelObjectImpl#accept(org.apache.tuscany.model.assembly.AssemblyModelVisitor)
+ */
+ public boolean accept(AssemblyModelVisitor visitor) {
+ if (!super.accept(visitor))
+ return false;
+
+ if (serviceContract!=null) {
+ if (!serviceContract.accept(visitor))
+ return false;
+ }
+
+ return true;
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/PropertyImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/PropertyImpl.java
new file mode 100644
index 0000000000..f79ad2df3b
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/PropertyImpl.java
@@ -0,0 +1,178 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.assembly.impl;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.model.assembly.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.Property;
+import org.apache.tuscany.sdo.util.SDOUtil;
+
+import commonj.sdo.Type;
+
+/**
+ * An implementation of Property.
+ */
+public class PropertyImpl extends ExtensibleImpl implements Property {
+
+ private Object defaultValue;
+ private String name;
+ private boolean many;
+ private boolean required;
+ private Class type;
+
+ private Type sdoType;
+
+ /**
+ * Constructor
+ */
+ protected PropertyImpl() {
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Property#getDefaultValue()
+ */
+ public Object getDefaultValue() {
+ return defaultValue;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Property#getName()
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Property#getType()
+ */
+ public Class getType() {
+ return type;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Property#isMany()
+ */
+ public boolean isMany() {
+ return many;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Property#isRequired()
+ */
+ public boolean isRequired() {
+ return required;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Property#setDefaultValue(java.lang.Object)
+ */
+ public void setDefaultValue(Object value) {
+ defaultValue=value;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Property#setMany(boolean)
+ */
+ public void setMany(boolean value) {
+ checkNotFrozen();
+ many=value;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Property#setName(java.lang.String)
+ */
+ public void setName(String value) {
+ checkNotFrozen();
+ name=value;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Property#setRequired(boolean)
+ */
+ public void setRequired(boolean value) {
+ checkNotFrozen();
+ required=value;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Property#setType(java.lang.Class)
+ */
+ public void setType(Class value) {
+ checkNotFrozen();
+ type=value;
+ }
+
+ /**
+ * @param sdoType The sdoType to set.
+ */
+ public void setSDOType(Type sdoType) {
+ checkNotFrozen();
+ this.sdoType = sdoType;
+ }
+
+ /**
+ * @return Returns the sdoType.
+ */
+ public Type getSDOType() {
+ return sdoType;
+ }
+
+ private final static Map<Class, Type> typeMapping=new HashMap<Class, Type>();
+
+ static {
+ typeMapping.put(BigDecimal.class, SDOUtil.getXSDSDOType("decimal"));
+ typeMapping.put(BigInteger.class, SDOUtil.getXSDSDOType("integer"));
+ typeMapping.put(boolean.class, SDOUtil.getXSDSDOType("boolean"));
+ typeMapping.put(Boolean.class, SDOUtil.getXSDSDOType("boolean"));
+ typeMapping.put(byte.class, SDOUtil.getXSDSDOType("byte"));
+ typeMapping.put(Byte.class, SDOUtil.getXSDSDOType("Byte"));
+ typeMapping.put(byte[].class, SDOUtil.getXSDSDOType("hexBinary"));
+ typeMapping.put(char.class, SDOUtil.getXSDSDOType("string"));
+ typeMapping.put(Character.class, SDOUtil.getXSDSDOType("string"));
+ typeMapping.put(Date.class, SDOUtil.getXSDSDOType("dateTime"));
+ typeMapping.put(double.class, SDOUtil.getXSDSDOType("double"));
+ typeMapping.put(Double.class, SDOUtil.getXSDSDOType("double"));
+ typeMapping.put(float.class, SDOUtil.getXSDSDOType("float"));
+ typeMapping.put(Float.class, SDOUtil.getXSDSDOType("float"));
+ typeMapping.put(int.class, SDOUtil.getXSDSDOType("int"));
+ typeMapping.put(Integer.class, SDOUtil.getXSDSDOType("int"));
+ typeMapping.put(long.class, SDOUtil.getXSDSDOType("long"));
+ typeMapping.put(Long.class, SDOUtil.getXSDSDOType("long"));
+ typeMapping.put(short.class, SDOUtil.getXSDSDOType("short"));
+ typeMapping.put(Short.class, SDOUtil.getXSDSDOType("short"));
+ typeMapping.put(String.class, SDOUtil.getXSDSDOType("string"));
+ }
+
+ /*
+ * @see org.apache.tuscany.model.assembly.impl.ExtensibleImpl#initialize(org.apache.tuscany.model.assembly.AssemblyModelContext)
+ */
+ public void initialize(AssemblyModelContext modelContext) {
+ if (isInitialized())
+ return;
+ super.initialize(modelContext);
+
+ // Get the SDO type corresponding to the property's Java type
+ if (sdoType==null) {
+ sdoType=typeMapping.get(type);
+ }
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ReferenceImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ReferenceImpl.java
new file mode 100644
index 0000000000..8a2d348edc
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ReferenceImpl.java
@@ -0,0 +1,50 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.assembly.impl;
+
+import org.apache.tuscany.model.assembly.Multiplicity;
+import org.apache.tuscany.model.assembly.Reference;
+
+/**
+ * An implementation of Reference.
+ */
+public class ReferenceImpl extends PortImpl implements Reference {
+
+ private Multiplicity multiplicity;
+
+ /**
+ * Constructor
+ */
+ protected ReferenceImpl() {
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Reference#getMultiplicity()
+ */
+ public Multiplicity getMultiplicity() {
+ return multiplicity;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Reference#setMultiplicity(org.apache.tuscany.model.assembly.Multiplicity)
+ */
+ public void setMultiplicity(Multiplicity multiplicity) {
+ checkNotFrozen();
+ this.multiplicity=multiplicity;
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ServiceContractImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ServiceContractImpl.java
new file mode 100644
index 0000000000..c9fe9b269d
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ServiceContractImpl.java
@@ -0,0 +1,81 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.assembly.impl;
+
+import org.apache.tuscany.model.assembly.Scope;
+import org.apache.tuscany.model.assembly.ServiceContract;
+
+/**
+ * An implementation of ServiceContract.
+ */
+public class ServiceContractImpl extends ExtensibleImpl implements ServiceContract {
+
+ private Class interface_;
+ private Class callbackInterface;
+ private Scope scope;
+
+ /**
+ * Constructor
+ */
+ protected ServiceContractImpl() {
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ServiceContract#getCallbackInterface()
+ */
+ public Class getCallbackInterface() {
+ return callbackInterface;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ServiceContract#getInterface()
+ */
+ public Class getInterface() {
+ return interface_;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ServiceContract#getScope()
+ */
+ public Scope getScope() {
+ return scope;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ServiceContract#setCallbackInterface(java.lang.Class)
+ */
+ public void setCallbackInterface(Class value) {
+ checkNotFrozen();
+ callbackInterface=value;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ServiceContract#setInterface(java.lang.Class)
+ */
+ public void setInterface(Class value) {
+ checkNotFrozen();
+ interface_=value;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ServiceContract#setScope(org.apache.tuscany.model.assembly.Scope)
+ */
+ public void setScope(Scope scope) {
+ checkNotFrozen();
+ this.scope=scope;
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ServiceImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ServiceImpl.java
new file mode 100644
index 0000000000..230d89e373
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ServiceImpl.java
@@ -0,0 +1,32 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.assembly.impl;
+
+import org.apache.tuscany.model.assembly.Service;
+
+/**
+ * An implementation of Service.
+ */
+public class ServiceImpl extends PortImpl implements Service {
+
+ /**
+ * Constructor
+ */
+ protected ServiceImpl() {
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ServiceURIImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ServiceURIImpl.java
new file mode 100644
index 0000000000..6d2972fb7d
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ServiceURIImpl.java
@@ -0,0 +1,198 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.assembly.impl;
+
+import org.eclipse.emf.common.util.URI;
+
+import org.apache.tuscany.model.assembly.ConfiguredPort;
+import org.apache.tuscany.model.assembly.ConfiguredReference;
+import org.apache.tuscany.model.assembly.ConfiguredService;
+import org.apache.tuscany.model.assembly.ModuleComponent;
+import org.apache.tuscany.model.assembly.AggregatePart;
+import org.apache.tuscany.model.assembly.Service;
+import org.apache.tuscany.model.assembly.ServiceURI;
+
+/**
+ * An implementation of ServiceURI.
+ */
+public class ServiceURIImpl implements ServiceURI {
+
+ private String address;
+ private Boolean isSCAScheme;
+ private boolean isParsed;
+ private String moduleComponentName;
+ private String partName;
+ private String serviceName;
+
+ /**
+ * Constructor
+ */
+ protected ServiceURIImpl(String address) {
+ this.address = address;
+ }
+
+ /**
+ * Constructor
+ *
+ * @param moduleComponent
+ * @param configuredPort
+ */
+ protected ServiceURIImpl(ModuleComponent moduleComponent, AggregatePart aggregatePart, ConfiguredPort configuredPort) {
+ if (moduleComponent != null)
+ moduleComponentName = moduleComponent.getName();
+ else
+ moduleComponentName = "";
+ if (configuredPort instanceof ConfiguredService) {
+ partName = aggregatePart.getName();
+ ConfiguredService configuredService = (ConfiguredService) configuredPort;
+ Service service = configuredService.getService();
+ if (service != null) {
+ serviceName = configuredService.getService().getName();
+ address = "sca:///" + moduleComponentName + '/' + partName + '/' + serviceName;
+ } else {
+ address = "sca:///" + moduleComponentName + '/' + partName;
+ }
+
+ } else if (configuredPort instanceof ConfiguredReference) {
+ ConfiguredReference configuredReference = (ConfiguredReference) configuredPort;
+ partName = aggregatePart.getName();
+ serviceName = configuredReference.getReference().getName();
+ if (serviceName!=null)
+ address = "sca:///" + moduleComponentName + '/' + partName + '/' + serviceName;
+ else
+ address = "sca:///" + moduleComponentName + '/' + partName;
+ }
+
+ isSCAScheme = Boolean.TRUE;
+ isParsed = true;
+ }
+
+ /**
+ * Constructor
+ *
+ * @param moduleComponent
+ * @param service
+ */
+ protected ServiceURIImpl(ModuleComponent moduleComponent, String targetServiceName) {
+ if (moduleComponent != null)
+ moduleComponentName = moduleComponent.getName();
+ else
+ moduleComponentName = "";
+ int s = targetServiceName.indexOf('/');
+ if (s == -1) {
+ partName = targetServiceName;
+ address = "sca:///" + moduleComponentName + '/' + partName;
+ } else {
+ partName = targetServiceName.substring(0, s);
+ this.serviceName = targetServiceName.substring(s + 1);
+ address = "sca:///" + moduleComponentName + '/' + partName + '/' + this.serviceName;
+ }
+ isSCAScheme = Boolean.TRUE;
+ isParsed = true;
+ }
+
+ /**
+ * Returns true if the address scheme is sca:
+ *
+ * @return
+ */
+ public boolean isSCAScheme() {
+ if (isSCAScheme == null) {
+ if (address.startsWith("sca://")) {
+ isSCAScheme = Boolean.TRUE;
+ } else {
+ isSCAScheme = Boolean.FALSE;
+ }
+ }
+ return isSCAScheme.booleanValue();
+ }
+
+ /**
+ * Returns a URI for this address
+ *
+ * @return
+ */
+ public URI getURI() {
+ return URI.createURI(address);
+ }
+
+ /**
+ * @return Returns the address.
+ */
+ public String getAddress() {
+ return address;
+ }
+
+ /**
+ * Parse the address.
+ */
+ private void parse() {
+ isParsed = true;
+ if (isSCAScheme()) {
+ int s1 = address.indexOf('/', 6);
+ if (s1 == -1)
+ return;
+ s1++;
+ int s2 = address.indexOf('/', s1);
+ if (s2 == -1)
+ return;
+ moduleComponentName = address.substring(s1, s2);
+ s2++;
+ int s3 = address.indexOf('/', s2);
+ if (s3 == -1) {
+ partName = address.substring(s2);
+ return;
+ }
+ partName = address.substring(s2, s3);
+ s3++;
+ serviceName = address.substring(s3);
+ }
+ }
+
+ /**
+ * Returns the module component name
+ *
+ * @return
+ */
+ public String getModuleComponentName() {
+ if (!isParsed)
+ parse();
+ return moduleComponentName;
+ }
+
+ /**
+ * Returns the part name
+ *
+ * @return
+ */
+ public String getPartName() {
+ if (!isParsed)
+ parse();
+ return partName;
+ }
+
+ /**
+ * Returns the service name
+ * @return
+ */
+ public String getServiceName() {
+ if (!isParsed)
+ parse();
+ return serviceName;
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/SimpleComponentImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/SimpleComponentImpl.java
new file mode 100644
index 0000000000..6de56e0806
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/SimpleComponentImpl.java
@@ -0,0 +1,32 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.assembly.impl;
+
+import org.apache.tuscany.model.assembly.SimpleComponent;
+
+/**
+ * An implementation of SimpleComponent.
+ */
+public class SimpleComponentImpl extends ComponentImpl implements SimpleComponent {
+
+ /**
+ * Constructor
+ */
+ protected SimpleComponentImpl() {
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/SubsystemImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/SubsystemImpl.java
new file mode 100644
index 0000000000..7dc78ee1e6
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/SubsystemImpl.java
@@ -0,0 +1,49 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.assembly.impl;
+
+import org.apache.tuscany.model.assembly.Subsystem;
+
+/**
+ * An implementation of Subsystem.
+ */
+public class SubsystemImpl extends AggregateImpl implements Subsystem {
+
+ private String uri;
+
+ /**
+ * Constructor
+ */
+ protected SubsystemImpl() {
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Subsystem#getURI()
+ */
+ public String getURI() {
+ return uri;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Subsystem#setURI(java.lang.String)
+ */
+ public void setURI(String value) {
+ checkNotFrozen();
+ uri=value;
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/WireImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/WireImpl.java
new file mode 100644
index 0000000000..6cbf34334f
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/WireImpl.java
@@ -0,0 +1,66 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.assembly.impl;
+
+import org.apache.tuscany.model.assembly.ServiceURI;
+import org.apache.tuscany.model.assembly.Wire;
+
+/**
+ * An implementation of Wire.
+ */
+public class WireImpl extends ExtensibleImpl implements Wire {
+
+ private ServiceURI source;
+ private ServiceURI target;
+
+ /**
+ * Constructor
+ */
+ protected WireImpl() {
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Wire#getSource()
+ */
+ public ServiceURI getSource() {
+ return source;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Wire#setSource(org.apache.tuscany.model.assembly.ServiceURI)
+ */
+ public void setSource(ServiceURI uri) {
+ checkNotFrozen();
+ source=uri;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Wire#getTarget()
+ */
+ public ServiceURI getTarget() {
+ return target;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Wire#setTarget(org.apache.tuscany.model.assembly.ServiceURI)
+ */
+ public void setTarget(ServiceURI uri) {
+ checkNotFrozen();
+ target=uri;
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/loader/AssemblyModelLoader.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/loader/AssemblyModelLoader.java
new file mode 100644
index 0000000000..6b0895e56f
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/loader/AssemblyModelLoader.java
@@ -0,0 +1,81 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.assembly.loader;
+
+import java.util.List;
+
+import javax.wsdl.Definition;
+import javax.wsdl.PortType;
+
+import org.apache.tuscany.model.assembly.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.ComponentType;
+import org.apache.tuscany.model.assembly.Module;
+import org.apache.tuscany.model.assembly.ModuleFragment;
+import org.apache.tuscany.model.assembly.Subsystem;
+
+/**
+ * An assembly model loader.
+ */
+public interface AssemblyModelLoader {
+
+ /**
+ * Sets the model context to use.
+ * @param modelContext
+ */
+ void setModelContext(AssemblyModelContext modelContext);
+
+ /**
+ * Returns the module at the given uri
+ * @param uri
+ * @return
+ */
+ Module loadModule(String uri);
+
+ /**
+ * Returns the module at the given uri
+ * @param uri
+ * @return
+ */
+ ModuleFragment loadModuleFragment(String uri);
+
+ /**
+ * Returns the component type at the given uri
+ * @param uri
+ * @return
+ */
+ ComponentType loadComponentType(String uri);
+
+ /**
+ * Returns the subsystem at the given uri.
+ * @param uri
+ * @return
+ */
+ Subsystem loadSubsystem(String uri);
+
+ /**
+ * Load a WSDL definition
+ */
+ Definition loadDefinition(String uri);
+
+ /**
+ * Load definitions by namespace
+ * @param uri
+ * @return
+ */
+ List<Definition> loadDefinitions(String namespace);
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/scdl/loader/SCDLModelLoader.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/scdl/loader/SCDLModelLoader.java
new file mode 100644
index 0000000000..f8fdab2c6c
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/scdl/loader/SCDLModelLoader.java
@@ -0,0 +1,36 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.scdl.loader;
+
+import org.apache.tuscany.model.assembly.Aggregate;
+import org.apache.tuscany.model.assembly.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.AssemblyModelObject;
+
+/**
+ * An SCDL model loader.
+ */
+public interface SCDLModelLoader {
+
+ /**
+ * Load an SCDL model object into an assembly model.
+ * @param modelContext
+ * @param object
+ * @return
+ */
+ AssemblyModelObject load(AssemblyModelContext modelContext, Object object);
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/scdl/loader/impl/AssemblyModelLoadException.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/scdl/loader/impl/AssemblyModelLoadException.java
new file mode 100644
index 0000000000..db2ad2ff86
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/scdl/loader/impl/AssemblyModelLoadException.java
@@ -0,0 +1,41 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.scdl.loader.impl;
+
+import org.apache.tuscany.common.TuscanyRuntimeException;
+
+/**
+ * The root runtime exception for the model loader.
+ *
+ * @version $Rev$ $Date$
+ */
+public class AssemblyModelLoadException extends TuscanyRuntimeException {
+
+ public AssemblyModelLoadException() {
+ super();
+ }
+
+ public AssemblyModelLoadException(String message) {
+ super(message);
+ }
+
+ public AssemblyModelLoadException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public AssemblyModelLoadException(Throwable cause) {
+ super(cause);
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/scdl/loader/impl/SCDLAssemblyModelLoaderImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/scdl/loader/impl/SCDLAssemblyModelLoaderImpl.java
new file mode 100644
index 0000000000..cfe8b260ee
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/scdl/loader/impl/SCDLAssemblyModelLoaderImpl.java
@@ -0,0 +1,198 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.scdl.loader.impl;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.wsdl.Definition;
+import javax.wsdl.WSDLException;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLReader;
+
+import org.apache.tuscany.common.resource.ResourceLoader;
+import org.apache.tuscany.model.assembly.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.ComponentType;
+import org.apache.tuscany.model.assembly.Module;
+import org.apache.tuscany.model.assembly.ModuleFragment;
+import org.apache.tuscany.model.assembly.Subsystem;
+import org.apache.tuscany.model.assembly.loader.AssemblyModelLoader;
+import org.apache.tuscany.model.scdl.loader.SCDLModelLoader;
+import org.apache.tuscany.model.util.ModelTransformer;
+import org.apache.tuscany.model.util.ModelTransformerImpl;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+
+/**
+ */
+public class SCDLAssemblyModelLoaderImpl implements AssemblyModelLoader {
+
+ private SCDLXMLReader xmlReader=new SCDLXMLReader();
+ private WSDLReader wsdlReader;
+ private AssemblyModelContext modelContext;
+
+ private List<SCDLModelLoader> scdlModelLoaders;
+
+ private Map<String, ComponentType> componentTypes=new HashMap<String, ComponentType>();
+ private Map<String, Module> modules=new HashMap<String, Module>();
+ private Map<String, ModuleFragment> moduleFragments=new HashMap<String, ModuleFragment>();
+ private Map<String, Subsystem> subsystems=new HashMap<String, Subsystem>();
+ private Map<String, Definition> definitions=new HashMap<String, Definition>();
+ private Map<String, List<Definition>> definitionsByNamespace=new HashMap<String, List<Definition>>();
+
+ /**
+ * Constructor
+ */
+ public SCDLAssemblyModelLoaderImpl(List<SCDLModelLoader> loaders) {
+ scdlModelLoaders=loaders!=null? loaders:new ArrayList<SCDLModelLoader>();
+ }
+
+ /**
+ * @param modelContext The modelContext to set.
+ */
+ public void setModelContext(AssemblyModelContext modelContext) {
+ this.modelContext = modelContext;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.loader.AssemblyModelLoader#loadComponentType(java.lang.String)
+ */
+ public ComponentType loadComponentType(String uri) {
+ ComponentType componentType=componentTypes.get(uri);
+ if (componentType!=null)
+ return componentType;
+
+ // Load the SCDL component type
+ org.apache.tuscany.model.scdl.ComponentType scdlComponentType=xmlReader.getComponentType(uri);
+
+ // Transform it to an assembly component type
+ componentType=transform(scdlComponentType).getComponentType();
+
+ componentTypes.put(uri, componentType);
+ return componentType;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.loader.AssemblyModelLoader#loadModule(java.lang.String)
+ */
+ public Module loadModule(String uri) {
+ Module module=modules.get(uri);
+ if (module!=null)
+ return module;
+
+ // Load the SCDL module
+ org.apache.tuscany.model.scdl.Module scdlModule=xmlReader.getModule(uri);
+
+ // Transform it to an assembly module
+ module=transform(scdlModule).getModule();
+
+ modules.put(uri, module);
+ return module;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.loader.AssemblyModelLoader#loadModuleFragment(java.lang.String)
+ */
+ public ModuleFragment loadModuleFragment(String uri) {
+ ModuleFragment moduleFragment=moduleFragments.get(uri);
+ if (moduleFragment!=null)
+ return moduleFragment;
+
+ // Load the SCDL module fragment
+ org.apache.tuscany.model.scdl.ModuleFragment scdlFragment=xmlReader.getModuleFragment(uri);
+
+ // Transform it to an assembly module fragment
+ moduleFragment=transform(scdlFragment).getModuleFragment();
+
+ moduleFragments.put(uri, moduleFragment);
+ return moduleFragment;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.loader.AssemblyModelLoader#loadSubsystem(java.lang.String)
+ */
+ public Subsystem loadSubsystem(String uri) {
+ Subsystem subsystem=subsystems.get(uri);
+ if (subsystem!=null)
+ return subsystem;
+
+ // Load the SCDL subsystem
+ org.apache.tuscany.model.scdl.Subsystem scdlSubsystem=xmlReader.getSubsystem(uri);
+
+ subsystem=transform(scdlSubsystem).getSubsystem();
+
+ subsystems.put(uri, subsystem);
+ return subsystem;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.loader.AssemblyModelLoader#loadDefinition(java.lang.String)
+ */
+ public Definition loadDefinition(String uri) {
+ Definition definition=definitions.get(uri);
+ if (definition!=null)
+ return definition;
+
+ try {
+ if (wsdlReader==null)
+ wsdlReader=WSDLFactory.newInstance().newWSDLReader();
+ definition = wsdlReader.readWSDL(uri);
+ } catch (WSDLException e) {
+ throw new IllegalArgumentException(e);
+ }
+ if (definition==null)
+ throw new IllegalArgumentException("Could not load WSDL definition at "+uri);
+
+ definitions.put(uri, definition);
+
+ String namespace=definition.getTargetNamespace();
+ List<Definition> list=definitionsByNamespace.get(namespace);
+ if (list==null) {
+ list=new ArrayList<Definition>();
+ definitionsByNamespace.put(namespace, list);
+ }
+ list.add(definition);
+
+ return definition;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.loader.AssemblyModelLoader#loadDefinitions(java.lang.String)
+ */
+ public List<Definition> loadDefinitions(String namespace) {
+ return definitionsByNamespace.get(namespace);
+ }
+
+ /**
+ * Transform a model and return the handler containing the result of the transformation.
+ * @param object
+ * @return
+ */
+ private SCDLModelContentHandlerImpl transform(Object object) {
+ //FIXME Remove this dependency on EMF
+ Iterator contents=EcoreUtil.getAllContents(Collections.singleton(object), true);
+
+ ModelTransformer transformer=new ModelTransformerImpl();
+ SCDLModelContentHandlerImpl handler=new SCDLModelContentHandlerImpl(modelContext, scdlModelLoaders);
+ transformer.transform(contents, handler);
+ return handler;
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/scdl/loader/impl/SCDLModelContentHandlerImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/scdl/loader/impl/SCDLModelContentHandlerImpl.java
new file mode 100644
index 0000000000..f4f1f857e6
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/scdl/loader/impl/SCDLModelContentHandlerImpl.java
@@ -0,0 +1,708 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.scdl.loader.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import javax.wsdl.Definition;
+import javax.wsdl.Import;
+import javax.wsdl.WSDLException;
+import javax.wsdl.factory.WSDLFactory;
+
+import org.apache.tuscany.model.assembly.Aggregate;
+import org.apache.tuscany.model.assembly.AssemblyFactory;
+import org.apache.tuscany.model.assembly.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.ComponentImplementation;
+import org.apache.tuscany.model.assembly.ConfiguredProperty;
+import org.apache.tuscany.model.assembly.ConfiguredReference;
+import org.apache.tuscany.model.assembly.ConfiguredService;
+import org.apache.tuscany.model.assembly.OverrideOption;
+import org.apache.tuscany.model.assembly.Scope;
+import org.apache.tuscany.model.assembly.ServiceContract;
+import org.apache.tuscany.model.assembly.ServiceURI;
+import org.apache.tuscany.model.assembly.SimpleComponent;
+import org.apache.tuscany.model.assembly.Wire;
+import org.apache.tuscany.model.assembly.impl.PropertyImpl;
+import org.apache.tuscany.model.scdl.Binding;
+import org.apache.tuscany.model.scdl.Component;
+import org.apache.tuscany.model.scdl.ComponentType;
+import org.apache.tuscany.model.scdl.EntryPoint;
+import org.apache.tuscany.model.scdl.ExternalService;
+import org.apache.tuscany.model.scdl.Implementation;
+import org.apache.tuscany.model.scdl.JavaInterface;
+import org.apache.tuscany.model.scdl.Module;
+import org.apache.tuscany.model.scdl.ModuleComponent;
+import org.apache.tuscany.model.scdl.ModuleFragment;
+import org.apache.tuscany.model.scdl.ModuleWire;
+import org.apache.tuscany.model.scdl.Multiplicity;
+import org.apache.tuscany.model.scdl.OverrideOptions;
+import org.apache.tuscany.model.scdl.Property;
+import org.apache.tuscany.model.scdl.PropertyValues;
+import org.apache.tuscany.model.scdl.Reference;
+import org.apache.tuscany.model.scdl.Service;
+import org.apache.tuscany.model.scdl.Subsystem;
+import org.apache.tuscany.model.scdl.SystemWire;
+import org.apache.tuscany.model.scdl.WSDLImport;
+import org.apache.tuscany.model.scdl.WSDLPortType;
+import org.apache.tuscany.model.scdl.loader.SCDLModelLoader;
+import org.apache.tuscany.model.scdl.util.ScdlSwitch;
+import org.apache.tuscany.model.types.java.JavaServiceContract;
+import org.apache.tuscany.model.types.java.impl.JavaServiceContractImpl;
+import org.apache.tuscany.model.types.wsdl.WSDLServiceContract;
+import org.apache.tuscany.model.types.wsdl.impl.WSDLServiceContractImpl;
+import org.apache.tuscany.model.util.ModelContentHandler;
+import org.apache.tuscany.sdo.util.SDOUtil;
+import org.eclipse.emf.ecore.EObject;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.Sequence;
+import commonj.sdo.Type;
+
+/**
+ * A model content handler that transforms an SCDL model into an assembly model.
+ */
+public class SCDLModelContentHandlerImpl extends ScdlSwitch implements ModelContentHandler {
+
+ private List contents;
+ private List linkers;
+ private Map targets;
+
+ private List<SCDLModelLoader> scdlModelLoaders;
+
+ private AssemblyModelContext modelContext;
+ private AssemblyFactory factory;
+ private org.apache.tuscany.model.assembly.ComponentType currentComponentType;
+ private org.apache.tuscany.model.assembly.Service currentService;
+ private org.apache.tuscany.model.assembly.Reference currentReference;
+ private org.apache.tuscany.model.assembly.Module currentModule;
+ private Aggregate currentAggregate;
+ private SimpleComponent currentComponent;
+ private org.apache.tuscany.model.assembly.ExternalService currentExternalService;
+ private org.apache.tuscany.model.assembly.EntryPoint currentEntryPoint;
+ private org.apache.tuscany.model.assembly.ModuleFragment currentModuleFragment;
+ private org.apache.tuscany.model.assembly.Subsystem currentSubsystem;
+ private org.apache.tuscany.model.assembly.ModuleComponent currentModuleComponent;
+ private Definition definition;
+
+ /**
+ * Constructor
+ */
+ public SCDLModelContentHandlerImpl(AssemblyModelContext modelContext, List<SCDLModelLoader> scdlModelLoaders) {
+ this.modelContext=modelContext;
+ this.factory=modelContext.getAssemblyFactory();
+ this.scdlModelLoaders=scdlModelLoaders;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.util.ModelContentHandler#doSwitch(java.lang.Object)
+ */
+ public Object doSwitch(Object object) {
+ return super.doSwitch((EObject)object);
+ }
+
+ /**
+ * @see org.apache.tuscany.model.util.ModelContentHandler#startModel()
+ */
+ public void startModel() {
+ }
+
+ /**
+ * @see org.apache.tuscany.model.util.ModelContentHandler#endModel()
+ */
+ public void endModel() {
+ }
+
+ /**
+ * @see org.apache.tuscany.model.util.ModelContentHandler#setContents(java.util.List)
+ */
+ public void setContents(List contents) {
+ this.contents=contents;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.util.ModelContentHandler#setLinkers(java.util.List)
+ */
+ public void setLinkers(List linkers) {
+ this.linkers=linkers;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.util.ModelContentHandler#setTargets(java.util.Map)
+ */
+ public void setTargets(Map targets) {
+ this.targets=targets;
+ }
+
+ /**
+ * @return Returns the componentType.
+ */
+ public org.apache.tuscany.model.assembly.ComponentType getComponentType() {
+ return currentComponentType;
+ }
+
+ /**
+ * @return Returns the module.
+ */
+ public org.apache.tuscany.model.assembly.Module getModule() {
+ return currentModule;
+ }
+
+ /**
+ * @return Returns the subsystem.
+ */
+ public org.apache.tuscany.model.assembly.Subsystem getSubsystem() {
+ return currentSubsystem;
+ }
+
+ /**
+ * @return Returns the moduleFragment.
+ */
+ public org.apache.tuscany.model.assembly.ModuleFragment getModuleFragment() {
+ return currentModuleFragment;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.scdl.util.ScdlSwitch#caseComponentType(org.apache.tuscany.model.scdl.ComponentType)
+ */
+ public Object caseComponentType(ComponentType object) {
+ org.apache.tuscany.model.assembly.ComponentType componentType=factory.createComponentType();
+ contents.add(componentType);
+ currentComponentType=componentType;
+ return componentType;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.scdl.util.ScdlSwitch#caseService(org.apache.tuscany.model.scdl.Service)
+ */
+ public Object caseService(Service object) {
+ final org.apache.tuscany.model.assembly.Service service=factory.createService();
+ service.setName(object.getName());
+
+ linkers.add(new Runnable() {
+ public void run() {
+ currentComponentType.getServices().add(service);
+ };
+ });
+
+ currentService=service;
+ return service;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.scdl.util.ScdlSwitch#caseReference(org.apache.tuscany.model.scdl.Reference)
+ */
+ public Object caseReference(Reference object) {
+ final org.apache.tuscany.model.assembly.Reference reference=factory.createReference();
+ reference.setName(object.getName());
+ reference.setMultiplicity(transformMultiplicity(object.getMultiplicity()));
+
+ linkers.add(new Runnable() {
+ public void run() {
+ currentComponentType.getReferences().add(reference);
+ };
+ });
+
+ currentReference=reference;
+ return reference;
+ }
+
+ /**
+ * Transforms an SCDL multiplicity into an assembly model multiplicity.
+ * @param multiplicity
+ * @return
+ */
+ private org.apache.tuscany.model.assembly.Multiplicity transformMultiplicity(Multiplicity multiplicity) {
+ if (multiplicity==Multiplicity._01_LITERAL)
+ return org.apache.tuscany.model.assembly.Multiplicity.ZERO_ONE;
+ else if (multiplicity==Multiplicity._0N_LITERAL)
+ return org.apache.tuscany.model.assembly.Multiplicity.ZERO_N;
+ else if (multiplicity==Multiplicity._11_LITERAL)
+ return org.apache.tuscany.model.assembly.Multiplicity.ONE_ONE;
+ else if (multiplicity==Multiplicity._1N_LITERAL)
+ return org.apache.tuscany.model.assembly.Multiplicity.ONE_N;
+ else
+ return org.apache.tuscany.model.assembly.Multiplicity.ONE_ONE;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.scdl.util.ScdlSwitch#caseJavaInterface(org.apache.tuscany.model.scdl.JavaInterface)
+ */
+ public Object caseJavaInterface(JavaInterface object) {
+ final JavaServiceContract serviceContract=factory.createJavaServiceContract();
+ serviceContract.setScope(Scope.INSTANCE);
+
+ ((JavaServiceContractImpl)serviceContract).setInterfaceName(object.getInterface());
+ ((JavaServiceContractImpl)serviceContract).setCallbackInterfaceName(object.getCallbackInterface());
+
+ linkServiceContract(object, serviceContract);
+
+ return serviceContract;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.scdl.util.ScdlSwitch#caseWSDLPortType(org.apache.tuscany.model.scdl.WSDLPortType)
+ */
+ public Object caseWSDLPortType(WSDLPortType object) {
+ final WSDLServiceContract serviceContract=factory.createWSDLServiceContract();
+ serviceContract.setScope(Scope.INSTANCE);
+
+ ((WSDLServiceContractImpl)serviceContract).setPortTypeURI(object.getInterface());
+ ((WSDLServiceContractImpl)serviceContract).setCallbackPortTypeURI(object.getCallbackInterface());
+
+ linkServiceContract(object, serviceContract);
+
+ return serviceContract;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.scdl.util.ScdlSwitch#caseWSDLImport(org.apache.tuscany.model.scdl.WSDLImport)
+ */
+ public Object caseWSDLImport(WSDLImport object) {
+ if (definition==null) {
+ try {
+ WSDLFactory wsdlFactory=WSDLFactory.newInstance();
+ definition=wsdlFactory.newDefinition();
+ } catch (WSDLException e) {
+ throw new IllegalStateException(e);
+ }
+
+ }
+ final Import wsdlImport=definition.createImport();
+ wsdlImport.setNamespaceURI(object.getNamespace());
+ wsdlImport.setLocationURI(object.getLocation());
+
+ linkers.add(new Runnable() {
+ public void run() {
+ currentAggregate.getWSDLImports().add(wsdlImport);
+ };
+ });
+
+ return wsdlImport;
+ }
+
+ /**
+ * Link a service contract with the correct owner.
+ * @param object
+ * @param serviceContract
+ */
+ private void linkServiceContract(Object object, final ServiceContract serviceContract) {
+ Object container=((DataObject)object).getContainer();
+ if (container instanceof Service) {
+
+ // Set a service contract on a service
+ final org.apache.tuscany.model.assembly.Service service=currentService;
+ linkers.add(new Runnable() {
+ public void run() {
+ service.setServiceContract(serviceContract);
+ }
+ });
+ }
+ else if (container instanceof Reference) {
+
+ // Set a service contract on a reference
+ final org.apache.tuscany.model.assembly.Reference reference=currentReference;
+ linkers.add(new Runnable() {
+ public void run() {
+ reference.setServiceContract(serviceContract);
+ }
+ });
+ } else if (container instanceof ExternalService) {
+
+ // Set a service contract on an external service
+ final org.apache.tuscany.model.assembly.ExternalService externalService=currentExternalService;
+ linkers.add(new Runnable() {
+ public void run() {
+ externalService.getConfiguredService().getService().setServiceContract(serviceContract);
+ }
+ });
+ } else if (container instanceof EntryPoint) {
+
+ // Set a service contract on an entry point
+ final org.apache.tuscany.model.assembly.EntryPoint entryPoint=currentEntryPoint;
+ linkers.add(new Runnable() {
+ public void run() {
+ entryPoint.getConfiguredService().getService().setServiceContract(serviceContract);
+ entryPoint.getConfiguredReference().getReference().setServiceContract(serviceContract);
+ }
+ });
+ }
+ }
+
+ /**
+ * @see org.apache.tuscany.model.scdl.util.ScdlSwitch#caseProperty(org.apache.tuscany.model.scdl.Property)
+ */
+ public Object caseProperty(Property object) {
+ final org.apache.tuscany.model.assembly.Property property=factory.createProperty();
+ property.setName(object.getName());
+ property.setDefaultValue(object.getDefault());
+ property.setMany(object.isMany());
+ property.setRequired(object.isRequired());
+
+ Object dataType=object.getDataType();
+ if (dataType!=null) {
+ String typeName=dataType.toString();
+ typeName=typeName.substring(typeName.indexOf(':')+1);
+ Type type=SDOUtil.getXSDSDOType(typeName);
+ ((PropertyImpl)property).setSDOType(type);
+ property.setType(type.getInstanceClass());
+ } else {
+ property.setType(String.class);
+ }
+
+ linkers.add(new Runnable() {
+ public void run() {
+ currentComponentType.getProperties().add(property);
+ };
+ });
+
+ return property;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.scdl.util.ScdlSwitch#caseModule(org.apache.tuscany.model.scdl.Module)
+ */
+ public Object caseModule(Module object) {
+ org.apache.tuscany.model.assembly.Module module=factory.createModule();
+ module.setName(object.getName());
+ contents.add(module);
+ currentModule=module;
+ currentAggregate=module;
+ return module;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.scdl.util.ScdlSwitch#caseModuleFragment(org.apache.tuscany.model.scdl.ModuleFragment)
+ */
+ public Object caseModuleFragment(ModuleFragment object) {
+ org.apache.tuscany.model.assembly.ModuleFragment moduleFragment=factory.createModuleFragment();
+ moduleFragment.setName(object.getName());
+ contents.add(moduleFragment);
+ currentModuleFragment=moduleFragment;
+ currentAggregate=moduleFragment;
+ return moduleFragment;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.scdl.util.ScdlSwitch#caseComponent(org.apache.tuscany.model.scdl.Component)
+ */
+ public Object caseComponent(Component object) {
+ final SimpleComponent component=factory.createSimpleComponent();
+ component.setName(object.getName());
+ linkers.add(new Runnable() {
+ public void run() {
+ currentAggregate.getComponents().add(component);
+ component.initialize(modelContext);
+ };
+ });
+ currentComponent=component;
+ return component;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.scdl.util.ScdlSwitch#casePropertyValues(org.apache.tuscany.model.scdl.PropertyValues)
+ */
+ public Object casePropertyValues(final PropertyValues object) {
+
+ // Grab the current component
+ final SimpleComponent component=currentComponent;
+ linkers.add(new Runnable() {
+ public void run() {
+
+ // Initialize the component's configured properties
+ Sequence sequence = object.getAny();
+ for (int p = 0, n = sequence.size(); p < n; p++) {
+
+ // Get each property value element
+ commonj.sdo.Property propertyElementDef = sequence.getProperty(p);
+ DataObject propertyElement = (DataObject) sequence.getValue(p);
+
+ // Get the corresponding property definition
+ String propertyName = propertyElementDef.getName();
+ ConfiguredProperty configuredProperty=component.getConfiguredProperty(propertyName);
+ if (configuredProperty == null) {
+ throw new IllegalArgumentException("Undefined property " + propertyName);
+ }
+
+ // Check if the property is overridable
+ Sequence attrs=propertyElement.getSequence("anyAttribute");
+ if (attrs!=null && attrs.size()!=0) {
+ commonj.sdo.Property attr=attrs.getProperty(0);
+ if (attr!=null && attr.getName().equals("overridable")) {
+ Object overridable=attrs.getValue(0);
+ if ("may".equals(overridable))
+ configuredProperty.setOverrideOption(OverrideOption.MAY);
+ else if ("must".equals(overridable))
+ configuredProperty.setOverrideOption(OverrideOption.MUST);
+ else if ("no".equals(overridable))
+ configuredProperty.setOverrideOption(OverrideOption.NO);
+ }
+ }
+
+ // Get the property value text and convert to the expected java type
+ Sequence text = propertyElement.getSequence("any");
+ if (text != null && text.size() != 0) {
+ String rawValue = text.getValue(0).toString();
+ Type type=((PropertyImpl)configuredProperty.getProperty()).getSDOType();
+ Object value;
+ if (type!=null) {
+ value=SDOUtil.createFromString(type, rawValue);
+ } else {
+ value=rawValue;
+ }
+ configuredProperty.setValue(value);
+ }
+ }
+ }
+ });
+
+ return object;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.scdl.util.ScdlSwitch#caseReferenceValues(org.apache.tuscany.model.scdl.ReferenceValues)
+ */
+ public Object caseReferenceValues(final org.apache.tuscany.model.scdl.ReferenceValues object) {
+
+ // Grab the current component
+ final SimpleComponent component=this.currentComponent;
+
+ linkers.add(new Runnable() {
+ public void run() {
+
+ // Initialize the component's configured references
+ Sequence sequence = object.getAny();
+ for (int r = 0, n = sequence.size(); r < n; r++) {
+
+ // Get each reference value element
+ commonj.sdo.Property referenceElementDef = sequence.getProperty(r);
+ DataObject referenceElement = (DataObject) sequence.getValue(r);
+
+ // Get the corresponding reference definition
+ String referenceName = referenceElementDef.getName();
+ ConfiguredReference configuredReference=component.getConfiguredReference(referenceName);
+ if (configuredReference == null) {
+ throw new IllegalArgumentException("Undefined reference " + referenceName);
+ }
+ ServiceURI referenceURI=factory.createServiceURI(null, component, configuredReference);
+
+ // Get the reference value text
+ Sequence text = referenceElement.getSequence(0);
+ if (text != null && text.size() != 0) {
+ String uri = text.getValue(0).toString();
+ ServiceURI serviceURI=factory.createServiceURI(null, uri);
+
+ // Create a wire
+ Wire wire=factory.createWire();
+ wire.setSource(referenceURI);
+ wire.setTarget(serviceURI);
+ currentAggregate.getWires().add(wire);
+ }
+ }
+ }
+ });
+
+ return object;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.scdl.util.ScdlSwitch#caseEntryPoint(org.apache.tuscany.model.scdl.EntryPoint)
+ */
+ public Object caseEntryPoint(final EntryPoint object) {
+ final org.apache.tuscany.model.assembly.EntryPoint entryPoint=factory.createEntryPoint();
+ entryPoint.setName(object.getName());
+
+ // Create a configured service and a configured reference for this entry point
+ org.apache.tuscany.model.assembly.Service service=factory.createService();
+ service.setName(entryPoint.getName());
+ ConfiguredService configuredService=factory.createConfiguredService();
+ configuredService.setService(service);
+ entryPoint.setConfiguredService(configuredService);
+ org.apache.tuscany.model.assembly.Reference reference=factory.createReference();
+ reference.setName(null);
+ reference.setMultiplicity(transformMultiplicity(object.getMultiplicity()));
+ final ConfiguredReference configuredReference=factory.createConfiguredReference();
+ configuredReference.setReference(reference);
+ entryPoint.setConfiguredReference(configuredReference);
+
+ linkers.add(new Runnable() {
+ public void run() {
+ currentAggregate.getEntryPoints().add(entryPoint);
+
+ // Create wires to the target service
+ final List<Wire>wires=new ArrayList<Wire>();
+ ServiceURI referenceURI=factory.createServiceURI(null, entryPoint, configuredReference);
+ for (String uri : (List<String>)object.getReference()) {
+ ServiceURI serviceURI=factory.createServiceURI(null, uri);
+ final Wire wire=factory.createWire();
+ wire.setSource(referenceURI);
+ wire.setTarget(serviceURI);
+ wires.add(wire);
+ }
+
+ currentAggregate.getWires().addAll(wires);
+ };
+ });
+
+ currentEntryPoint=entryPoint;
+ return entryPoint;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.scdl.util.ScdlSwitch#caseExternalService(org.apache.tuscany.model.scdl.ExternalService)
+ */
+ public Object caseExternalService(ExternalService object) {
+ final org.apache.tuscany.model.assembly.ExternalService externalService=factory.createExternalService();
+ externalService.setName(object.getName());
+
+ OverrideOptions overrideOptions=object.getOverridable();
+ if (overrideOptions==OverrideOptions.MAY_LITERAL)
+ externalService.setOverrideOption(OverrideOption.MAY);
+ else if (overrideOptions==OverrideOptions.MUST_LITERAL)
+ externalService.setOverrideOption(OverrideOption.MUST);
+ else if (overrideOptions==OverrideOptions.NO_LITERAL)
+ externalService.setOverrideOption(OverrideOption.NO);
+ else
+ externalService.setOverrideOption(OverrideOption.NO);
+
+ // Create a configured service for this external service
+ org.apache.tuscany.model.assembly.Service service=factory.createService();
+ service.setName(externalService.getName());
+ ConfiguredService configuredService=factory.createConfiguredService();
+ configuredService.setService(service);
+ externalService.setConfiguredService(configuredService);
+
+ linkers.add(new Runnable() {
+ public void run() {
+ currentAggregate.getExternalServices().add(externalService);
+ };
+ });
+ currentExternalService=externalService;
+ return externalService;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.scdl.util.ScdlSwitch#caseSubsystem(org.apache.tuscany.model.scdl.Subsystem)
+ */
+ public Object caseSubsystem(Subsystem object) {
+ org.apache.tuscany.model.assembly.Subsystem subsystem=factory.createSubsystem();
+ subsystem.setName(object.getName());
+ subsystem.setURI(object.getUri());
+ currentSubsystem=subsystem;
+ currentAggregate=subsystem;
+ return subsystem;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.scdl.util.ScdlSwitch#caseModuleComponent(org.apache.tuscany.model.scdl.ModuleComponent)
+ */
+ public Object caseModuleComponent(ModuleComponent object) {
+ final org.apache.tuscany.model.assembly.ModuleComponent moduleComponent=factory.createModuleComponent();
+ moduleComponent.setName(object.getName());
+ moduleComponent.setURI(object.getUri());
+
+ linkers.add(new Runnable() {
+ public void run() {
+ currentAggregate.getComponents().add(moduleComponent);
+ };
+ });
+
+ currentModuleComponent=moduleComponent;
+ return moduleComponent;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.scdl.util.ScdlSwitch#caseModuleWire(org.apache.tuscany.model.scdl.ModuleWire)
+ */
+ public Object caseModuleWire(ModuleWire object) {
+ final Wire wire=factory.createWire();
+ wire.setSource(factory.createServiceURI(null, object.getSourceUri()));
+ wire.setTarget(factory.createServiceURI(null, object.getTargetUri()));
+
+ linkers.add(new Runnable() {
+ public void run() {
+ currentAggregate.getWires().add(wire);
+ };
+ });
+
+ return wire;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.scdl.util.ScdlSwitch#caseSystemWire(org.apache.tuscany.model.scdl.SystemWire)
+ */
+ public Object caseSystemWire(SystemWire object) {
+ final Wire wire=factory.createWire();
+ wire.setSource(factory.createServiceURI(object.getSource().toString()));
+ wire.setTarget(factory.createServiceURI(object.getTarget().toString()));
+
+ linkers.add(new Runnable() {
+ public void run() {
+ currentAggregate.getWires().add(wire);
+ };
+ });
+
+ return wire;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.scdl.util.ScdlSwitch#caseImplementation(org.apache.tuscany.model.scdl.Implementation)
+ */
+ public Object caseImplementation(Implementation object) {
+ final SimpleComponent component=currentComponent;
+
+ for (SCDLModelLoader scdlModelLoader : scdlModelLoaders) {
+
+ // Invoke an SCDL loader to handle the specific implementation type
+ final ComponentImplementation implementation=(ComponentImplementation)scdlModelLoader.load(modelContext, object);
+ if (implementation!=null) {
+ component.setComponentImplementation(implementation);
+ return implementation;
+ }
+
+ }
+ return null;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.scdl.util.ScdlSwitch#caseBinding(org.apache.tuscany.model.scdl.Binding)
+ */
+ public Object caseBinding(Binding object) {
+
+ final List<org.apache.tuscany.model.assembly.Binding> bindings;
+ Object container=((DataObject)object).getContainer();
+ if (container instanceof EntryPoint) {
+ bindings=currentEntryPoint.getBindings();
+ } else if (container instanceof ExternalService) {
+ bindings=currentExternalService.getBindings();
+ } else
+ bindings=null;
+
+ for (SCDLModelLoader scdlModelLoader : scdlModelLoaders) {
+
+ // Invoke an SCDL loader to handle the specific binding type
+ final org.apache.tuscany.model.assembly.Binding binding=(org.apache.tuscany.model.assembly.Binding)scdlModelLoader.load(modelContext, object);
+ if (binding!=null) {
+ bindings.add(binding);
+ return binding;
+ }
+
+ }
+ return null;
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/scdl/loader/impl/SCDLXMLReader.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/scdl/loader/impl/SCDLXMLReader.java
new file mode 100644
index 0000000000..6fa426b2f8
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/scdl/loader/impl/SCDLXMLReader.java
@@ -0,0 +1,109 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.scdl.loader.impl;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.model.scdl.ComponentType;
+import org.apache.tuscany.model.scdl.Module;
+import org.apache.tuscany.model.scdl.ModuleFragment;
+import org.apache.tuscany.model.scdl.ScdlFactory;
+import org.apache.tuscany.model.scdl.Subsystem;
+import org.apache.tuscany.model.scdl.impl.ScdlPackageImpl;
+import org.apache.tuscany.sdo.util.DataObjectUtil;
+import org.apache.tuscany.sdo.util.SDOUtil;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+
+import commonj.sdo.helper.XMLDocument;
+import commonj.sdo.helper.XMLHelper;
+
+/**
+ */
+public class SCDLXMLReader extends ResourceSetImpl {
+
+ private Map<String, Object> cache=new HashMap<String, Object>();
+
+ // Initialize the SDO runtime and register the SCDL model
+ static {
+ DataObjectUtil.initRuntime();
+ SDOUtil.registerStaticTypes(ScdlFactory.class);
+ }
+
+ /**
+ * Constructor
+ */
+ public SCDLXMLReader() {
+ }
+
+ /**
+ * Returns an SCDL module.
+ * @param uri
+ * @return
+ */
+ public Module getModule(String uri) {
+ return (Module)getRootObject(uri);
+ }
+
+ /**
+ * Returns an SCDL module fragment.
+ * @param uri
+ * @return
+ */
+ public ModuleFragment getModuleFragment(String uri) {
+ return (ModuleFragment)getRootObject(uri);
+ }
+
+ /**
+ * Returns an SCDL component type.
+ * @param uri
+ * @return
+ */
+ public ComponentType getComponentType(String uri) {
+ return (ComponentType)getRootObject(uri);
+ }
+
+ /**
+ * Returns an SCDL subsystem.
+ * @param uri
+ * @return
+ */
+ public Subsystem getSubsystem(String uri) {
+ return (Subsystem)getRootObject(uri);
+ }
+
+ /**
+ * Returns the root object at the given URI.
+ * @param uri
+ * @return
+ */
+ private Object getRootObject(String uri) {
+ Object object = cache.get(uri);
+ if (object==null) {
+ try {
+ XMLDocument document=XMLHelper.INSTANCE.load(new URL(uri).openStream());
+ return document.getRootObject();
+ } catch (IOException e) {
+ throw new RuntimeException(uri, e);
+ }
+ }
+ return object;
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/types/java/JavaServiceContract.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/types/java/JavaServiceContract.java
new file mode 100644
index 0000000000..0a4ea54947
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/types/java/JavaServiceContract.java
@@ -0,0 +1,27 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.types.java;
+
+import org.apache.tuscany.model.assembly.ServiceContract;
+
+
+/**
+ * Represents a Java service contract.
+ */
+public interface JavaServiceContract extends ServiceContract {
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/types/java/impl/JavaServiceContractImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/types/java/impl/JavaServiceContractImpl.java
new file mode 100644
index 0000000000..589678acbb
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/types/java/impl/JavaServiceContractImpl.java
@@ -0,0 +1,81 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.types.java.impl;
+
+import org.apache.tuscany.model.assembly.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.impl.ServiceContractImpl;
+import org.apache.tuscany.model.types.java.JavaServiceContract;
+
+/**
+ * An implementation of JavaServiceContract.
+ */
+public class JavaServiceContractImpl extends ServiceContractImpl implements JavaServiceContract {
+
+ private String interfaceName;
+ private String callbackInterfaceName;
+
+ /**
+ * Constructor
+ */
+ public JavaServiceContractImpl() {
+ }
+
+ /**
+ * @param interfaceName The interfaceName to set.
+ */
+ public void setInterfaceName(String interfaceName) {
+ this.interfaceName = interfaceName;
+ }
+
+ /**
+ * @param callbackInterfaceName The callbackInterfaceName to set.
+ */
+ public void setCallbackInterfaceName(String callbackInterfaceName) {
+ this.callbackInterfaceName = callbackInterfaceName;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.impl.ExtensibleImpl#initialize(org.apache.tuscany.model.assembly.AssemblyModelContext)
+ */
+ public void initialize(AssemblyModelContext modelContext) {
+ if (isInitialized())
+ return;
+
+ // Load the interface
+ if (getInterface()==null && interfaceName!=null) {
+ try {
+ Class interfaceClass=modelContext.getApplicationResourceLoader().loadClass(interfaceName);
+ setInterface(interfaceClass);
+ } catch (ClassNotFoundException e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+ // Load the callback interface
+ if (getCallbackInterface()==null && callbackInterfaceName!=null) {
+ try {
+ Class callbackInterfaceClass=modelContext.getApplicationResourceLoader().loadClass(callbackInterfaceName);
+ setInterface(callbackInterfaceClass);
+ } catch (ClassNotFoundException e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+ super.initialize(modelContext);
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/types/wsdl/WSDLServiceContract.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/types/wsdl/WSDLServiceContract.java
new file mode 100644
index 0000000000..6133e4a02b
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/types/wsdl/WSDLServiceContract.java
@@ -0,0 +1,52 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.types.wsdl;
+
+import javax.wsdl.PortType;
+
+import org.apache.tuscany.model.assembly.ServiceContract;
+
+/**
+ * A WSDL service contract.
+ */
+public interface WSDLServiceContract extends ServiceContract {
+
+ /**
+ * Returns the WSDL portType.
+ * @return
+ */
+ PortType getPortType();
+
+ /**
+ * Sets the WSDL portType.
+ * @param portType
+ */
+ void setPortType(PortType portType);
+
+ /**
+ * Returns the callback WSDL portType.
+ * @return
+ */
+ PortType getCallbackPortType();
+
+ /**
+ * Sets the callback WSDL portType.
+ * @param portType
+ */
+ void setCallbackPortType(PortType portType);
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/types/wsdl/impl/WSDLServiceContractImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/types/wsdl/impl/WSDLServiceContractImpl.java
new file mode 100644
index 0000000000..262503feb0
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/types/wsdl/impl/WSDLServiceContractImpl.java
@@ -0,0 +1,212 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.types.wsdl.impl;
+
+import static org.objectweb.asm.Opcodes.ACC_ABSTRACT;
+import static org.objectweb.asm.Opcodes.ACC_INTERFACE;
+import static org.objectweb.asm.Opcodes.ACC_PUBLIC;
+import static org.objectweb.asm.Opcodes.V1_5;
+
+import java.util.List;
+
+import javax.wsdl.Definition;
+import javax.wsdl.Operation;
+import javax.wsdl.PortType;
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.common.resource.ResourceLoader;
+import org.apache.tuscany.model.assembly.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.impl.ServiceContractImpl;
+import org.apache.tuscany.model.assembly.loader.AssemblyModelLoader;
+import org.apache.tuscany.model.types.wsdl.WSDLServiceContract;
+import org.apache.tuscany.model.util.XMLNameUtil;
+import org.objectweb.asm.ClassWriter;
+import org.objectweb.asm.Type;
+
+import commonj.sdo.DataObject;
+
+/**
+ * An implementation of WSDLServiceContract.
+ */
+public class WSDLServiceContractImpl extends ServiceContractImpl implements WSDLServiceContract {
+
+ private PortType portType;
+ private PortType callbackPortType;
+ private String portTypeURI;
+ private String callbackPortTypeURI;
+
+ /**
+ * Constructor
+ */
+ public WSDLServiceContractImpl() {
+ }
+
+ /**
+ * @see org.apache.tuscany.model.types.wsdl.WSDLServiceContract#getPortType()
+ */
+ public PortType getPortType() {
+ return portType;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.types.wsdl.WSDLServiceContract#setPortType(javax.wsdl.PortType)
+ */
+ public void setPortType(PortType portType) {
+ checkNotFrozen();
+ this.portType=portType;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.types.wsdl.WSDLServiceContract#getCallbackPortType()
+ */
+ public PortType getCallbackPortType() {
+ return callbackPortType;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.types.wsdl.WSDLServiceContract#setCallbackPortType(javax.wsdl.PortType)
+ */
+ public void setCallbackPortType(PortType portType) {
+ checkNotFrozen();
+ callbackPortType=portType;
+ }
+
+ /**
+ * @param portTypeURI The portTypeURI to set.
+ */
+ public void setPortTypeURI(String portTypeURI) {
+ this.portTypeURI = portTypeURI;
+ }
+
+ /**
+ * @param callbackPortTypeURI The callbackPortTypeURI to set.
+ */
+ public void setCallbackPortTypeURI(String callbackPortTypeURI) {
+ this.callbackPortTypeURI = callbackPortTypeURI;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.impl.ExtensibleImpl#initialize(org.apache.tuscany.model.assembly.AssemblyModelContext)
+ */
+ public void initialize(AssemblyModelContext modelContext) {
+ if (isInitialized())
+ return;
+ super.initialize(modelContext);
+
+ // Resolve the WSDL portType and callback portType
+ AssemblyModelLoader modelLoader=modelContext.getAssemblyLoader();
+ if (portTypeURI!=null && portType==null) {
+ portType=getPortType(modelLoader, portTypeURI);
+ }
+ if (callbackPortTypeURI!=null && callbackPortType==null) {
+ callbackPortType=getPortType(modelLoader, callbackPortTypeURI);
+ }
+
+ // Load the Java interface for the portType
+ if (portType!=null && getInterface()==null) {
+ QName qname=portType.getQName();
+ String interfaceName=XMLNameUtil.getFullyQualifiedClassNameFromQName(qname.getNamespaceURI(), qname.getLocalPart());
+ Class interfaceClass;
+ try {
+ // Load the interface
+ interfaceClass=modelContext.getApplicationResourceLoader().loadClass(interfaceName);
+ } catch (ClassNotFoundException e) {
+ // Generate the interface on the fly
+ interfaceClass=generateJavaInterface(modelContext.getApplicationResourceLoader(), portType, interfaceName);
+ }
+ super.setInterface(interfaceClass);
+ }
+
+ // Load the Java interface for the callback portType
+ if (callbackPortType!=null && getCallbackInterface()==null) {
+ QName qname=callbackPortType.getQName();
+ String interfaceName=XMLNameUtil.getFullyQualifiedClassNameFromQName(qname.getNamespaceURI(), qname.getLocalPart());
+ Class interfaceClass;
+ try {
+ // Load the interface
+ interfaceClass=modelContext.getApplicationResourceLoader().loadClass(interfaceName);
+ } catch (ClassNotFoundException e) {
+ // Generate the interface on the fly
+ interfaceClass=generateJavaInterface(modelContext.getApplicationResourceLoader(), portType, interfaceName);
+ }
+ super.setCallbackInterface(interfaceClass);
+ }
+ }
+
+ /**
+ * Get a portType from the given uri
+ * @param loader
+ * @param uri
+ * @return
+ */
+ private PortType getPortType(AssemblyModelLoader loader, String uri) {
+
+ // Get the WSDL port namespace and name
+ int h=uri.indexOf('#');
+ String namespace=uri.substring(0,h);
+ String name=uri.substring(h+1);
+ QName qname=new QName(namespace, name);
+
+ // Load the WSDL definitions for the given namespace
+ List<Definition> definitions=loader.loadDefinitions(namespace);
+ if (definitions==null)
+ throw new IllegalArgumentException("Cannot find WSDL definition for "+namespace);
+ for (Definition definition: definitions) {
+
+ // Find the port with the given name
+ PortType portType=definition.getPortType(qname);
+ return portType;
+ }
+ throw new IllegalArgumentException("Cannot find WSDL portType "+uri);
+ }
+
+ /**
+ * Generate a Java interface from a WSDL portType.
+ * @param portType
+ * @param interfaceName
+ * @return
+ */
+ private Class generateJavaInterface(ResourceLoader resourceLoader, PortType portType, String interfaceName) {
+ ClassWriter cw=new ClassWriter(false);
+
+ // Generate the interface
+ interfaceName=interfaceName.replace('.', '/');
+ cw.visit(V1_5, ACC_PUBLIC + ACC_ABSTRACT + ACC_INTERFACE, interfaceName, null, "java/lang/Object", new String[0]);
+
+
+ // Generate methods from the WSDL operations
+ for (Operation operation : (List<Operation>)portType.getOperations()) {
+ String methodName=XMLNameUtil.getJavaNameFromXMLName(operation.getName(), false);
+
+ //FIXME integrate XSD to Java type mapping here
+ String inputType = Type.getDescriptor(String.class);
+ String outputType = Type.getDescriptor(String.class);
+
+ cw.visitMethod(ACC_PUBLIC + ACC_ABSTRACT, methodName, "("+inputType+")"+outputType, null, null).visitEnd();
+ }
+
+ // Generate the bytecodes
+ cw.visitEnd();
+ byte[] bytes=cw.toByteArray();
+
+ // Add the class to the resource loader
+ Class interfaceClass=(Class)resourceLoader.addClass(bytes);
+
+ return interfaceClass;
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/util/ModelContentHandler.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/util/ModelContentHandler.java
new file mode 100644
index 0000000000..515d2128ec
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/util/ModelContentHandler.java
@@ -0,0 +1,71 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.util;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * A model content handler. This mimics a SAX content handler for models and
+ * receives notification of the content of a model. A model content handler is
+ * responsible for handling model content notifications. As part of the handling
+ * the handler can produce new contents.
+ */
+public interface ModelContentHandler {
+
+ /**
+ * Starts handling of a model.
+ */
+ public void startModel();
+
+ /**
+ * Ends handling of a model.
+ */
+ public void endModel();
+
+ /**
+ * Sets the contents list, where the content handler should store
+ * the contents that it produces.
+ * @param contents The contents to set
+ */
+ public void setContents(List contents);
+
+ /**
+ * Sets the linkers list. A content handler can add linker objects to this
+ * list. Linker objects must implement java.lang.Runnable. They are
+ * run as part of the endModel notification processing.
+ * Typically linker objects are used to resolve model forward references
+ * or establish model relationships after the model content has been
+ * handled.
+ * @param linkers The linkers to set
+ */
+ public void setLinkers(List linkers);
+
+ /**
+ * Sets the targets map. This map keeps track of the objects returned by
+ * the content handler for each object passed to its doSwitch method.
+ * @param targets The targets to set
+ */
+ public void setTargets(Map targets);
+
+ /**
+ * This method dispatches handling of the given object (XYZ for example) to a
+ * corresponding "caseXYZ()" method on the content handler.
+ */
+ public Object doSwitch(Object object);
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/util/ModelTransformer.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/util/ModelTransformer.java
new file mode 100644
index 0000000000..2a6fbe2f8a
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/util/ModelTransformer.java
@@ -0,0 +1,51 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.util;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * A model transformer. Invokes a model content handler to perform the actual transformation.
+ */
+public interface ModelTransformer {
+
+ /**
+ * Uses a ModelContentHandler to transform a model.
+ */
+ public List transform(Iterator iterator, ModelContentHandler handler);
+
+ /**
+ * Uses a ModelContentHandler to transform a model. Performs the first
+ * transform pass.
+ */
+ public List transformPass1(Iterator iterator, ModelContentHandler handler, List deferredHandlers);
+
+ /**
+ * Uses a ModelContentHandler to transform a model. Performs the first
+ * transform pass.
+ */
+ public List transformPass1(Iterator iterator, final ModelContentHandler handler, List deferredHandlers, Map targets, List contents);
+
+ /**
+ * Uses a ModelContentHandler to transform a model. Performs the second
+ * transform pass.
+ */
+ public void transformPass2(List deferredHandlers);
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/util/ModelTransformerImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/util/ModelTransformerImpl.java
new file mode 100644
index 0000000000..85458b03ef
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/util/ModelTransformerImpl.java
@@ -0,0 +1,125 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.util;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+
+/**
+ * @author jsdelfino
+ *
+ * Base implementation for a model transformer.
+ * Invokes a model content handler to perform the actual transformation.
+ */
+public class ModelTransformerImpl implements ModelTransformer {
+
+ /**
+ * Uses a ModelContentHandler to transform a model.
+ */
+ public List transform(Iterator iterator, ModelContentHandler handler) {
+
+ // Pass 1: visit the source model and create target model objects
+ List linkers=new ArrayList();
+ List contents=transformPass1(iterator, handler, linkers);
+
+ // Pass 2: resolve the links between the target model objects
+ transformPass2(linkers);
+
+ // Return the target model contents
+ return contents;
+ }
+
+ /**
+ * Uses a ModelContentHandler to transform a model.
+ */
+ public List transformPass1(Iterator iterator, final ModelContentHandler handler, List deferredHandlers, Map targets, List contents) {
+
+ // Initialize the handler
+ handler.setTargets(targets);
+ handler.setLinkers(deferredHandlers);
+ handler.setContents(contents);
+
+ // This runnable will invoke endModel and clean up the handler
+ Runnable cleanup=new Runnable() {
+ public void run() {
+
+ // Cleanup
+ handler.endModel();
+
+ handler.setTargets(null);
+ handler.setLinkers(null);
+ handler.setContents(null);
+ }
+ };
+
+ // Run the handler
+ try {
+ handler.startModel();
+
+ // Pass 1: compile, visit the source model and create target model objects
+ for (; iterator.hasNext(); ) {
+ Object source=iterator.next();
+ if (source==null)
+ System.out.println("Ooops");
+ Object target=handler.doSwitch(source);
+
+ // Record source to target associations
+ targets.put(source,target);
+ }
+
+ // Add the cleanup runnable
+ deferredHandlers.add(cleanup);
+
+ } catch (Exception e) {
+
+ // An exception occurred, run the cleanup now
+ cleanup.run();
+ throw new RuntimeException(e);
+ }
+
+ // return the target model contents
+ // note that this list may actually be populated in pass2
+ return contents;
+ }
+
+ /**
+ * Uses a ModelContentHandler to transform a model.
+ */
+ public List transformPass1(Iterator iterator, final ModelContentHandler handler, List deferredHandlers) {
+ Map targets=new HashMap();
+ List contents=new ArrayList();
+ return transformPass1(iterator,handler,deferredHandlers,targets,contents);
+ }
+
+ /**
+ * Uses a ModelContentHandler to transform a model.
+ */
+ public void transformPass2(List deferredHandlers) {
+
+ // Pass 2: link, resolve the links between the target model objects
+ for (Iterator i=deferredHandlers.iterator(); i.hasNext(); ) {
+ Runnable runnable=(Runnable)i.next();
+ runnable.run();
+ }
+
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/util/XMLNameUtil.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/util/XMLNameUtil.java
new file mode 100644
index 0000000000..be707dbb9c
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/util/XMLNameUtil.java
@@ -0,0 +1,227 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.util;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.emf.common.util.URI;
+
+/**
+ * A utility class that converts between XML names and Java names.
+ */
+public class XMLNameUtil {
+
+ private static final List domains = Arrays.asList(new String[]{"COM", "com", "ORG", "org"});
+
+ /**
+ * Constructor
+ */
+ private XMLNameUtil() {
+ super();
+ }
+
+ /**
+ * Return an EPackage name for the given namespace.
+ *
+ * @param namespace
+ * @return
+ */
+ public static String getPackageNameFromNamespace(String namespace) {
+
+ URI uri = URI.createURI(namespace);
+ List parsedName;
+ if (uri.isHierarchical()) {
+ String host = uri.host();
+ if (host != null && host.startsWith("www.")) {
+ host = host.substring(4);
+ }
+ parsedName = parseName(host, '.');
+ Collections.reverse(parsedName);
+ if (!parsedName.isEmpty()) {
+ parsedName.set(0, ((String) parsedName.get(0)).toLowerCase());
+ }
+
+ parsedName.addAll(parseName(uri.trimFileExtension().path(), '/'));
+
+ } else {
+ String opaquePart = uri.opaquePart();
+ int index = opaquePart.indexOf(":");
+ if (index != -1 && "urn".equalsIgnoreCase(uri.scheme())) {
+ parsedName = parseName(opaquePart.substring(0, index), '-');
+ if (parsedName.size() > 0 && domains.contains(parsedName.get(parsedName.size() - 1))) {
+ Collections.reverse(parsedName);
+ parsedName.set(0, ((String) parsedName.get(0)).toLowerCase());
+ }
+ parsedName.addAll(parseName(opaquePart.substring(index + 1), '/'));
+
+ } else {
+ parsedName = parseName(opaquePart, '/');
+ }
+ }
+
+ StringBuffer qualifiedPackageName = new StringBuffer();
+ for (Iterator i = parsedName.iterator(); i.hasNext();) {
+ String packageName = (String) i.next();
+ if (packageName.length() > 0) {
+ if (qualifiedPackageName.length() > 0) {
+ qualifiedPackageName.append('.');
+ }
+ qualifiedPackageName.append(getJavaNameFromXMLName(packageName, false));
+ }
+ }
+ return qualifiedPackageName.toString();
+
+ }
+
+ /**
+ * Returns a namespace prefix for the given package Name
+ *
+ * @param packageName
+ * @return
+ */
+ public static String getNSPrefixFromPackageName(String packageName) {
+ String nsPrefix = packageName;
+ int index = nsPrefix.lastIndexOf('.');
+ return index == -1 ? nsPrefix : nsPrefix.substring(index + 1);
+ }
+
+ /**
+ * Parse the given name.
+ *
+ * @param sourceName
+ * @param separator
+ * @return
+ */
+ private static List parseName(String sourceName, char separator) {
+ List result = new ArrayList();
+ if (sourceName != null) {
+ StringBuffer currentWord = new StringBuffer();
+ boolean lastIsLower = false;
+ for (int index = 0, length = sourceName.length(); index < length; ++index) {
+ char curChar = sourceName.charAt(index);
+ if (!Character.isJavaIdentifierPart(curChar)) {
+ curChar = separator;
+ }
+ if (Character.isUpperCase(curChar) || (!lastIsLower && Character.isDigit(curChar)) || curChar == separator) {
+ if (lastIsLower && currentWord.length() > 1 || curChar == separator && currentWord.length() > 0) {
+ result.add(currentWord.toString());
+ currentWord = new StringBuffer();
+ }
+ lastIsLower = false;
+ } else {
+ if (!lastIsLower) {
+ int currentWordLength = currentWord.length();
+ if (currentWordLength > 1) {
+ char lastChar = currentWord.charAt(--currentWordLength);
+ currentWord.setLength(currentWordLength);
+ result.add(currentWord.toString());
+ currentWord = new StringBuffer();
+ currentWord.append(lastChar);
+ }
+ }
+ lastIsLower = true;
+ }
+
+ if (curChar != separator) {
+ currentWord.append(curChar);
+ }
+ }
+
+ result.add(currentWord.toString());
+ }
+ return result;
+ }
+
+ /**
+ * Returns a valid Java name from an XML Name
+ *
+ * @param name
+ * @param isUpperCase
+ * @return
+ */
+ public static String getJavaNameFromXMLName(String name, boolean isUpperCase) {
+ List parsedName = parseName(name, '_');
+ StringBuffer result = new StringBuffer();
+ for (Iterator i = parsedName.iterator(); i.hasNext();) {
+ String nameComponent = (String) i.next();
+ if (nameComponent.length() > 0) {
+ if (result.length() > 0 || isUpperCase) {
+ result.append(Character.toUpperCase(nameComponent.charAt(0)));
+ result.append(nameComponent.substring(1));
+ } else {
+ result.append(nameComponent);
+ }
+ }
+ }
+
+ return result.length() == 0 ? "_" : Character.isJavaIdentifierStart(result.charAt(0)) ? isUpperCase ? result.toString() : decapitalizeName(result.toString()) : "_" + result;
+ }
+
+ /**
+ * Returns a valid fully qualified class name from a QName
+ * @param namespace
+ * @param name
+ * @return
+ */
+ public static String getFullyQualifiedClassNameFromQName(String namespace, String name) {
+ return XMLNameUtil.getPackageNameFromNamespace(namespace)+'.'+XMLNameUtil.getJavaNameFromXMLName(name, true);
+ }
+
+ /**
+ * Decapitalize a name.
+ * @param name
+ * @return
+ */
+ public static String decapitalizeName(String name) {
+ if (name.length() == 0) {
+ return name;
+ } else {
+ String lowerName = name.toLowerCase();
+ int i;
+ for (i = 0; i < name.length(); i++) {
+ if (name.charAt(i) == lowerName.charAt(i)) {
+ break;
+ }
+ }
+ if (i > 1 && i < name.length()) {
+ --i;
+ }
+ return name.substring(0, i).toLowerCase() + name.substring(i);
+ }
+ }
+
+ /**
+ * Capitalize a name.
+ * @param name
+ * @return
+ */
+ public static String capitalizeName(String name) {
+ int l=name.length();
+ if (l == 0) {
+ return name;
+ } else if (l==1) {
+ return name.toUpperCase();
+ } else {
+ return name.substring(0, 1).toUpperCase() + name.substring(1);
+ }
+ }
+
+} \ No newline at end of file
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/resources/model/assembly.mdl b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/resources/model/assembly.mdl
new file mode 100644
index 0000000000..63349ead08
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/resources/model/assembly.mdl
@@ -0,0 +1,6092 @@
+
+(object Petal
+ version 42
+ _written "Rose 4.5.8163.3"
+ charSet 0)
+
+(object Design "Logical View"
+ is_unit TRUE
+ is_loaded TRUE
+ defaults (object defaults
+ rightMargin 0.250000
+ leftMargin 0.250000
+ topMargin 0.250000
+ bottomMargin 0.500000
+ pageOverlap 0.250000
+ clipIconLabels TRUE
+ autoResize FALSE
+ snapToGrid FALSE
+ gridX 16
+ gridY 16
+ defaultFont (object Font
+ size 10
+ face "Arial"
+ bold FALSE
+ italics FALSE
+ underline FALSE
+ strike FALSE
+ color 0
+ default_color TRUE)
+ showMessageNum 1
+ showClassOfObject TRUE
+ notation "Unified")
+ root_usecase_package (object Class_Category "Use Case View"
+ quid "4367BF7F0006"
+ exportControl "Public"
+ global TRUE
+ logical_models (list unit_reference_list)
+ logical_presentations (list unit_reference_list
+ (object UseCaseDiagram "Main"
+ quid "4367BF7F0037"
+ title "Main"
+ zoom 100
+ max_height 28350
+ max_width 21600
+ origin_x 0
+ origin_y 0
+ items (list diagram_item_list))))
+ root_category (object Class_Category "Logical View"
+ quid "4367BF7F0005"
+ exportControl "Public"
+ global TRUE
+ subsystem "Component View"
+ quidu "4367BF7F0007"
+ logical_models (list unit_reference_list
+ (object Class_Category "Assembly"
+ quid "4367BFA901F9"
+ exportControl "Public"
+ logical_models (list unit_reference_list
+ (object Class "Aggregate"
+ quid "4367BFB702AD"
+ class_attributes (list class_attribute_list
+ (object ClassAttribute "name"
+ quid "4367C06602E1")))
+ (object Class "Part"
+ quid "4367BFD202AC"
+ class_attributes (list class_attribute_list
+ (object ClassAttribute "name"
+ quid "4367C07801CE")))
+ (object Class "Component"
+ quid "4367C00800BF"
+ superclasses (list inheritance_relationship_list
+ (object Inheritance_Relationship
+ quid "4367C286003A"
+ supplier "Logical View::Assembly::Part"
+ quidu "4367BFD202AC")))
+ (object Class "ExternalService"
+ quid "4367C00E009F"
+ superclasses (list inheritance_relationship_list
+ (object Inheritance_Relationship
+ quid "4367C289032D"
+ supplier "Logical View::Assembly::Part"
+ quidu "4367BFD202AC"))
+ class_attributes (list class_attribute_list
+ (object ClassAttribute "overridable"
+ quid "4367C3ED00C2")))
+ (object Class "EntryPoint"
+ quid "4367C0210101"
+ superclasses (list inheritance_relationship_list
+ (object Inheritance_Relationship
+ quid "4367C27E030A"
+ supplier "Logical View::Assembly::Part"
+ quidu "4367BFD202AC")))
+ (object Class "Binding"
+ quid "4367C18A02C3"
+ class_attributes (list class_attribute_list
+ (object ClassAttribute "uri"
+ quid "4367C191020E"))
+ abstract TRUE)
+ (object Class "ConfiguredImplementation"
+ quid "4367C1D70165"
+ abstract TRUE)
+ (object Class "ConfiguredService"
+ quid "4367C1E10105"
+ superclasses (list inheritance_relationship_list
+ (object Inheritance_Relationship
+ quid "4367C5EB01DE"
+ supplier "Logical View::Assembly::ConfiguredPort"
+ quidu "4367C5D400C3")))
+ (object Class "ConfiguredReference"
+ quid "4367C1EC0011"
+ superclasses (list inheritance_relationship_list
+ (object Inheritance_Relationship
+ quid "4367C5EE02D3"
+ supplier "Logical View::Assembly::ConfiguredPort"
+ quidu "4367C5D400C3")))
+ (object Class "ConfiguredProperty"
+ quid "4367C205012F"
+ class_attributes (list class_attribute_list
+ (object ClassAttribute "value"
+ quid "4367CBD8024E")))
+ (object Class "ComponentType"
+ quid "4367C2A20289")
+ (object Class "Service"
+ quid "4367C2B1014A"
+ superclasses (list inheritance_relationship_list
+ (object Inheritance_Relationship
+ quid "4367C5A80001"
+ supplier "Logical View::Assembly::Port"
+ quidu "4367C58302CF"))
+ class_attributes (list class_attribute_list
+ (object ClassAttribute "name"
+ quid "4367C81C022B")))
+ (object Class "Reference"
+ quid "4367C2B90318"
+ superclasses (list inheritance_relationship_list
+ (object Inheritance_Relationship
+ quid "4367C5AB00EC"
+ supplier "Logical View::Assembly::Port"
+ quidu "4367C58302CF"))
+ class_attributes (list class_attribute_list
+ (object ClassAttribute "multiplicity"
+ quid "4367C69F01AB")))
+ (object Class "Property"
+ quid "4367C2C30381"
+ class_attributes (list class_attribute_list
+ (object ClassAttribute "default"
+ quid "4367C61B02A5")
+ (object ClassAttribute "many"
+ quid "4367C620007C")
+ (object ClassAttribute "name"
+ quid "4367C6230225")
+ (object ClassAttribute "required"
+ quid "4367C626025B")))
+ (object Class "Interface"
+ quid "4367C4260179"
+ abstract TRUE)
+ (object Class "InterfaceType"
+ quid "4367C43900EA")
+ (object Class "Module"
+ quid "4367C4C90079"
+ superclasses (list inheritance_relationship_list
+ (object Inheritance_Relationship
+ quid "4367C4CF001D"
+ supplier "Logical View::Assembly::Implementation"
+ quidu "436833C300FA")
+ (object Inheritance_Relationship
+ quid "4367C4D4009D"
+ supplier "Logical View::Assembly::Aggregate"
+ quidu "4367BFB702AD")))
+ (object Class "ModuleComponent"
+ quid "4367C4EA0315"
+ superclasses (list inheritance_relationship_list
+ (object Inheritance_Relationship
+ quid "4367C4FA01C4"
+ supplier "Logical View::Assembly::Component"
+ quidu "4367C00800BF")))
+ (object Class "ModuleFragment"
+ quid "4367C50C038C"
+ superclasses (list inheritance_relationship_list
+ (object Inheritance_Relationship
+ quid "4367C52000D8"
+ supplier "Logical View::Assembly::Aggregate"
+ quidu "4367BFB702AD")))
+ (object Class "Port"
+ quid "4367C58302CF")
+ (object Class "ConfiguredPort"
+ quid "4367C5D400C3")
+ (object Class "OperationType"
+ quid "4367C64601FD")
+ (object Class "Type"
+ quid "4367C65D0124")
+ (object Class "Subsystem"
+ quid "4367C757032C"
+ superclasses (list inheritance_relationship_list
+ (object Inheritance_Relationship
+ quid "4367C76B03AD"
+ supplier "Logical View::Assembly::Aggregate"
+ quidu "4367BFB702AD"))
+ class_attributes (list class_attribute_list
+ (object ClassAttribute "uri"
+ quid "4367C763003A")))
+ (object Class "Implementation"
+ quid "436833C300FA"
+ abstract TRUE)
+ (object Class "ConfiguredModule"
+ quid "436836780038"
+ superclasses (list inheritance_relationship_list
+ (object Inheritance_Relationship
+ quid "436836C701A4"
+ supplier "Logical View::Assembly::ConfiguredImplementation"
+ quidu "4367C1D70165")))
+ (object Association "$UNNAMED$0"
+ quid "4367C02A0050"
+ roles (list role_list
+ (object Role "$UNNAMED$1"
+ quid "4367C02A03D5"
+ supplier "Logical View::Assembly::Aggregate"
+ quidu "4367BFB702AD"
+ is_navigable TRUE
+ is_aggregate TRUE)
+ (object Role "entryPoints"
+ quid "4367C02A03D6"
+ label "entryPoints"
+ supplier "Logical View::Assembly::EntryPoint"
+ quidu "4367C0210101"
+ client_cardinality (value cardinality "0..n")
+ Containment "By Value"
+ is_navigable TRUE)))
+ (object Association "$UNNAMED$2"
+ quid "4367C02C025B"
+ roles (list role_list
+ (object Role "$UNNAMED$3"
+ quid "4367C02D022B"
+ supplier "Logical View::Assembly::Aggregate"
+ quidu "4367BFB702AD"
+ is_navigable TRUE
+ is_aggregate TRUE)
+ (object Role "components"
+ quid "4367C02D022C"
+ label "components"
+ supplier "Logical View::Assembly::Component"
+ quidu "4367C00800BF"
+ client_cardinality (value cardinality "0..n")
+ Containment "By Value"
+ is_navigable TRUE)))
+ (object Association "$UNNAMED$4"
+ quid "4367C02F02C4"
+ roles (list role_list
+ (object Role "$UNNAMED$5"
+ quid "4367C03002ED"
+ supplier "Logical View::Assembly::Aggregate"
+ quidu "4367BFB702AD"
+ is_navigable TRUE
+ is_aggregate TRUE)
+ (object Role "externalServices"
+ quid "4367C03002EE"
+ label "externalServices"
+ supplier "Logical View::Assembly::ExternalService"
+ quidu "4367C00E009F"
+ client_cardinality (value cardinality "0..n")
+ Containment "By Value"
+ is_navigable TRUE)))
+ (object Association "$UNNAMED$6"
+ quid "4367C10E0314"
+ roles (list role_list
+ (object Role "aggregate"
+ quid "4367C10F0348"
+ label "aggregate"
+ supplier "Logical View::Assembly::Aggregate"
+ quidu "4367BFB702AD"
+ is_navigable TRUE
+ is_aggregate TRUE)
+ (object Role "parts"
+ quid "4367C10F0349"
+ label "parts"
+ supplier "Logical View::Assembly::Part"
+ quidu "4367BFD202AC"
+ client_cardinality (value cardinality "0..n")
+ Containment "By Value"
+ is_navigable TRUE)))
+ (object Association "$UNNAMED$7"
+ quid "4367C265015F"
+ roles (list role_list
+ (object Role "$UNNAMED$8"
+ quid "4367C2660110"
+ supplier "Logical View::Assembly::Component"
+ quidu "4367C00800BF"
+ is_navigable TRUE
+ is_aggregate TRUE)
+ (object Role "$UNNAMED$9"
+ quid "4367C2660111"
+ supplier "Logical View::Assembly::ConfiguredService"
+ quidu "4367C1E10105"
+ client_cardinality (value cardinality "0..n")
+ Containment "By Value"
+ is_navigable TRUE)))
+ (object Association "$UNNAMED$10"
+ quid "4367C269025F"
+ roles (list role_list
+ (object Role "$UNNAMED$11"
+ quid "4367C26A026B"
+ supplier "Logical View::Assembly::Component"
+ quidu "4367C00800BF"
+ is_navigable TRUE
+ is_aggregate TRUE)
+ (object Role "$UNNAMED$12"
+ quid "4367C26A026C"
+ supplier "Logical View::Assembly::ConfiguredReference"
+ quidu "4367C1EC0011"
+ client_cardinality (value cardinality "0..n")
+ Containment "By Value"
+ is_navigable TRUE)))
+ (object Association "$UNNAMED$13"
+ quid "4367C26D0297"
+ roles (list role_list
+ (object Role "$UNNAMED$14"
+ quid "4367C26E037F"
+ supplier "Logical View::Assembly::Component"
+ quidu "4367C00800BF"
+ is_navigable TRUE
+ is_aggregate TRUE)
+ (object Role "$UNNAMED$15"
+ quid "4367C26E0380"
+ supplier "Logical View::Assembly::ConfiguredProperty"
+ quidu "4367C205012F"
+ client_cardinality (value cardinality "0..n")
+ Containment "By Value"
+ is_navigable TRUE)))
+ (object Association "$UNNAMED$16"
+ quid "4367C29500DC"
+ roles (list role_list
+ (object Role "$UNNAMED$17"
+ quid "4367C296021E"
+ supplier "Logical View::Assembly::Component"
+ quidu "4367C00800BF"
+ is_navigable TRUE
+ is_aggregate TRUE)
+ (object Role "$UNNAMED$18"
+ quid "4367C296021F"
+ supplier "Logical View::Assembly::ConfiguredImplementation"
+ quidu "4367C1D70165"
+ client_cardinality (value cardinality "1..1")
+ Containment "By Value"
+ is_navigable TRUE)))
+ (object Association "$UNNAMED$19"
+ quid "4367C2D50200"
+ roles (list role_list
+ (object Role "$UNNAMED$20"
+ quid "4367C2D60099"
+ supplier "Logical View::Assembly::ComponentType"
+ quidu "4367C2A20289"
+ is_navigable TRUE
+ is_aggregate TRUE)
+ (object Role "$UNNAMED$21"
+ quid "4367C2D6009A"
+ supplier "Logical View::Assembly::Service"
+ quidu "4367C2B1014A"
+ client_cardinality (value cardinality "1..n")
+ Containment "By Value"
+ is_navigable TRUE)))
+ (object Association "$UNNAMED$22"
+ quid "4367C2D8018C"
+ roles (list role_list
+ (object Role "$UNNAMED$23"
+ quid "4367C2D9015C"
+ supplier "Logical View::Assembly::ComponentType"
+ quidu "4367C2A20289"
+ is_navigable TRUE
+ is_aggregate TRUE)
+ (object Role "$UNNAMED$24"
+ quid "4367C2D9015D"
+ supplier "Logical View::Assembly::Reference"
+ quidu "4367C2B90318"
+ client_cardinality (value cardinality "0..n")
+ Containment "By Value"
+ is_navigable TRUE)))
+ (object Association "$UNNAMED$25"
+ quid "4367C2DC002A"
+ roles (list role_list
+ (object Role "$UNNAMED$26"
+ quid "4367C2DD0035"
+ supplier "Logical View::Assembly::ComponentType"
+ quidu "4367C2A20289"
+ is_navigable TRUE
+ is_aggregate TRUE)
+ (object Role "$UNNAMED$27"
+ quid "4367C2DD0036"
+ supplier "Logical View::Assembly::Property"
+ quidu "4367C2C30381"
+ client_cardinality (value cardinality "0..n")
+ Containment "By Value"
+ is_navigable TRUE)))
+ (object Association "$UNNAMED$28"
+ quid "4367C2E901EB"
+ roles (list role_list
+ (object Role "$UNNAMED$29"
+ quid "4367C2EA020A"
+ supplier "Logical View::Assembly::Property"
+ quidu "4367C2C30381"
+ client_cardinality (value cardinality "1..1")
+ is_navigable TRUE)
+ (object Role "$UNNAMED$30"
+ quid "4367C2EA020B"
+ supplier "Logical View::Assembly::ConfiguredProperty"
+ quidu "4367C205012F")))
+ (object Association "$UNNAMED$31"
+ quid "4367C2F00000"
+ roles (list role_list
+ (object Role "$UNNAMED$32"
+ quid "4367C2F10174"
+ supplier "Logical View::Assembly::ComponentType"
+ quidu "4367C2A20289"
+ client_cardinality (value cardinality "1..1")
+ is_navigable TRUE)
+ (object Role "$UNNAMED$33"
+ quid "4367C2F10175"
+ supplier "Logical View::Assembly::ConfiguredImplementation"
+ quidu "4367C1D70165")))
+ (object Association "$UNNAMED$34"
+ quid "4367C3170350"
+ roles (list role_list
+ (object Role "$UNNAMED$35"
+ quid "4367C319008C"
+ supplier "Logical View::Assembly::ExternalService"
+ quidu "4367C00E009F"
+ is_navigable TRUE
+ is_aggregate TRUE)
+ (object Role "$UNNAMED$36"
+ quid "4367C319008D"
+ supplier "Logical View::Assembly::ConfiguredService"
+ quidu "4367C1E10105"
+ client_cardinality (value cardinality "1..1")
+ Containment "By Value"
+ is_navigable TRUE)))
+ (object Association "$UNNAMED$37"
+ quid "4367C396015E"
+ roles (list role_list
+ (object Role "$UNNAMED$38"
+ quid "4367C39700D3"
+ supplier "Logical View::Assembly::EntryPoint"
+ quidu "4367C0210101"
+ is_navigable TRUE
+ is_aggregate TRUE)
+ (object Role "$UNNAMED$39"
+ quid "4367C39700D4"
+ supplier "Logical View::Assembly::Binding"
+ quidu "4367C18A02C3"
+ client_cardinality (value cardinality "0..n")
+ Containment "By Value"
+ is_navigable TRUE)))
+ (object Association "$UNNAMED$40"
+ quid "4367C39A0240"
+ roles (list role_list
+ (object Role "$UNNAMED$41"
+ quid "4367C39B01AB"
+ supplier "Logical View::Assembly::ExternalService"
+ quidu "4367C00E009F"
+ is_navigable TRUE
+ is_aggregate TRUE)
+ (object Role "$UNNAMED$42"
+ quid "4367C39B01AC"
+ supplier "Logical View::Assembly::Binding"
+ quidu "4367C18A02C3"
+ client_cardinality (value cardinality "0..n")
+ Containment "By Value"
+ is_navigable TRUE)))
+ (object Association "$UNNAMED$43"
+ quid "4367C39F021F"
+ roles (list role_list
+ (object Role "$UNNAMED$44"
+ quid "4367C3A0031B"
+ supplier "Logical View::Assembly::EntryPoint"
+ quidu "4367C0210101"
+ is_navigable TRUE
+ is_aggregate TRUE)
+ (object Role "$UNNAMED$45"
+ quid "4367C3A0031C"
+ supplier "Logical View::Assembly::ConfiguredReference"
+ quidu "4367C1EC0011"
+ client_cardinality (value cardinality "1..1")
+ Containment "By Value"
+ is_navigable TRUE)))
+ (object Association "$UNNAMED$46"
+ quid "4367C4330286"
+ roles (list role_list
+ (object Role "$UNNAMED$47"
+ quid "4367C4340327"
+ supplier "Logical View::Assembly::Port"
+ quidu "4367C58302CF"
+ is_navigable TRUE
+ is_aggregate TRUE)
+ (object Role "$UNNAMED$48"
+ quid "4367C4340328"
+ supplier "Logical View::Assembly::Interface"
+ quidu "4367C4260179"
+ client_cardinality (value cardinality "1..1")
+ Containment "By Value"
+ is_navigable TRUE)))
+ (object Association "$UNNAMED$49"
+ quid "4367C4440168"
+ roles (list role_list
+ (object Role "$UNNAMED$50"
+ quid "4367C44500FB"
+ supplier "Logical View::Assembly::InterfaceType"
+ quidu "4367C43900EA"
+ client_cardinality (value cardinality "0..1")
+ is_navigable TRUE)
+ (object Role "$UNNAMED$51"
+ quid "4367C44500FC"
+ supplier "Logical View::Assembly::Interface"
+ quidu "4367C4260179")))
+ (object Association "$UNNAMED$52"
+ quid "4367C44A01DF"
+ roles (list role_list
+ (object Role "$UNNAMED$53"
+ quid "4367C44C0155"
+ supplier "Logical View::Assembly::InterfaceType"
+ quidu "4367C43900EA"
+ client_cardinality (value cardinality "1..1")
+ is_navigable TRUE)
+ (object Role "$UNNAMED$54"
+ quid "4367C44C0156"
+ supplier "Logical View::Assembly::Interface"
+ quidu "4367C4260179")))
+ (object Association "$UNNAMED$55"
+ quid "4367C52701D2"
+ roles (list role_list
+ (object Role "$UNNAMED$56"
+ quid "4367C52801FC"
+ supplier "Logical View::Assembly::Module"
+ quidu "4367C4C90079"
+ is_navigable TRUE
+ is_aggregate TRUE)
+ (object Role "$UNNAMED$57"
+ quid "4367C52801FD"
+ supplier "Logical View::Assembly::ModuleFragment"
+ quidu "4367C50C038C"
+ client_cardinality (value cardinality "0..n")
+ Containment "By Value"
+ is_navigable TRUE)))
+ (object Association "$UNNAMED$58"
+ quid "4367C5E00369"
+ roles (list role_list
+ (object Role "$UNNAMED$59"
+ quid "4367C5E10342"
+ supplier "Logical View::Assembly::Port"
+ quidu "4367C58302CF"
+ client_cardinality (value cardinality "1..1")
+ is_navigable TRUE)
+ (object Role "$UNNAMED$60"
+ quid "4367C5E10343"
+ supplier "Logical View::Assembly::ConfiguredPort"
+ quidu "4367C5D400C3")))
+ (object Association "$UNNAMED$61"
+ quid "4367C65601D8"
+ roles (list role_list
+ (object Role "$UNNAMED$62"
+ quid "4367C65701A7"
+ supplier "Logical View::Assembly::InterfaceType"
+ quidu "4367C43900EA"
+ is_navigable TRUE
+ is_aggregate TRUE)
+ (object Role "$UNNAMED$63"
+ quid "4367C65701A8"
+ supplier "Logical View::Assembly::OperationType"
+ quidu "4367C64601FD"
+ client_cardinality (value cardinality "0..n")
+ Containment "By Value"
+ is_navigable TRUE)))
+ (object Association "$UNNAMED$64"
+ quid "4367C66702F5"
+ roles (list role_list
+ (object Role "$UNNAMED$65"
+ quid "4367C6680328"
+ supplier "Logical View::Assembly::OperationType"
+ quidu "4367C64601FD")
+ (object Role "exceptionTypes"
+ quid "4367C6680329"
+ label "exceptionTypes"
+ supplier "Logical View::Assembly::Type"
+ quidu "4367C65D0124"
+ client_cardinality (value cardinality "0..n")
+ is_navigable TRUE)))
+ (object Association "$UNNAMED$66"
+ quid "4367C66B039B"
+ roles (list role_list
+ (object Role "$UNNAMED$67"
+ quid "4367C66C02FC"
+ supplier "Logical View::Assembly::OperationType"
+ quidu "4367C64601FD")
+ (object Role "outputType"
+ quid "4367C66C02FD"
+ label "outputType"
+ supplier "Logical View::Assembly::Type"
+ quidu "4367C65D0124"
+ client_cardinality (value cardinality "0..1")
+ is_navigable TRUE)))
+ (object Association "$UNNAMED$68"
+ quid "4367C671033F"
+ roles (list role_list
+ (object Role "$UNNAMED$69"
+ quid "4367C6730202"
+ supplier "Logical View::Assembly::OperationType"
+ quidu "4367C64601FD")
+ (object Role "inputType"
+ quid "4367C6730203"
+ label "inputType"
+ supplier "Logical View::Assembly::Type"
+ quidu "4367C65D0124"
+ client_cardinality (value cardinality "1..1")
+ is_navigable TRUE)))
+ (object Association "$UNNAMED$70"
+ quid "4367C6790391"
+ roles (list role_list
+ (object Role "$UNNAMED$71"
+ quid "4367C67B0073"
+ supplier "Logical View::Assembly::Type"
+ quidu "4367C65D0124"
+ is_navigable TRUE)
+ (object Role "$UNNAMED$72"
+ quid "4367C67B007D"
+ supplier "Logical View::Assembly::Property"
+ quidu "4367C2C30381")))
+ (object Association "$UNNAMED$73"
+ quid "4367C6C10222"
+ roles (list role_list
+ (object Role "serviceEndpoints"
+ quid "4367C6C20129"
+ label "serviceEndpoints"
+ supplier "Logical View::Assembly::ConfiguredService"
+ quidu "4367C1E10105"
+ client_cardinality (value cardinality "0..n")
+ is_navigable TRUE)
+ (object Role "$UNNAMED$74"
+ quid "4367C6C2012A"
+ supplier "Logical View::Assembly::ConfiguredReference"
+ quidu "4367C1EC0011")))
+ (object Association "$UNNAMED$75"
+ quid "4367C73A0384"
+ roles (list role_list
+ (object Role "$UNNAMED$76"
+ quid "4367C73C0020"
+ supplier "Logical View::Assembly::Service"
+ quidu "4367C2B1014A"
+ client_cardinality (value cardinality "1..1")
+ is_navigable TRUE)
+ (object Role "$UNNAMED$77"
+ quid "4367C73C0021"
+ supplier "Logical View::Assembly::ConfiguredService"
+ quidu "4367C1E10105")))
+ (object Association "$UNNAMED$78"
+ quid "4367C740038D"
+ roles (list role_list
+ (object Role "$UNNAMED$79"
+ quid "4367C7420001"
+ supplier "Logical View::Assembly::Reference"
+ quidu "4367C2B90318"
+ client_cardinality (value cardinality "1..1")
+ is_navigable TRUE)
+ (object Role "$UNNAMED$80"
+ quid "4367C7420002"
+ supplier "Logical View::Assembly::ConfiguredReference"
+ quidu "4367C1EC0011")))
+ (object Association "$UNNAMED$81"
+ quid "43682F4B0394"
+ roles (list role_list
+ (object Role "$UNNAMED$82"
+ quid "43682F4D0076"
+ supplier "Logical View::Assembly::ModuleComponent"
+ quidu "4367C4EA0315"
+ is_navigable TRUE
+ is_aggregate TRUE)
+ (object Role "$UNNAMED$83"
+ quid "43682F4D0077"
+ supplier "Logical View::Assembly::ConfiguredModule"
+ quidu "436836780038"
+ client_cardinality (value cardinality "1..1")
+ Containment "By Value"
+ is_navigable TRUE)))
+ (object Association "$UNNAMED$84"
+ quid "436834860263"
+ roles (list role_list
+ (object Role "$UNNAMED$85"
+ quid "436834870246"
+ supplier "Logical View::Assembly::Subsystem"
+ quidu "4367C757032C"
+ is_navigable TRUE
+ is_aggregate TRUE)
+ (object Role "$UNNAMED$86"
+ quid "436834870247"
+ supplier "Logical View::Assembly::ModuleComponent"
+ quidu "4367C4EA0315"
+ client_cardinality (value cardinality "0..n")
+ Containment "By Value"
+ is_navigable TRUE)))
+ (object Association "$UNNAMED$87"
+ quid "436835A101A2"
+ roles (list role_list
+ (object Role "$UNNAMED$88"
+ quid "436835A20289"
+ supplier "Logical View::Assembly::Implementation"
+ quidu "436833C300FA"
+ client_cardinality (value cardinality "0..1")
+ is_navigable TRUE)
+ (object Role "$UNNAMED$89"
+ quid "436835A2028A"
+ supplier "Logical View::Assembly::ConfiguredImplementation"
+ quidu "4367C1D70165")))
+ (object Association "$UNNAMED$90"
+ quid "436836850218"
+ roles (list role_list
+ (object Role "$UNNAMED$91"
+ quid "43683686027D"
+ supplier "Logical View::Assembly::ConfiguredModule"
+ quidu "436836780038")
+ (object Role "$UNNAMED$92"
+ quid "43683686027E"
+ supplier "Logical View::Assembly::Module"
+ quidu "4367C4C90079"
+ client_cardinality (value cardinality "1..1")
+ is_navigable TRUE)))
+ (object Association "$UNNAMED$93"
+ quid "43683779039F"
+ roles (list role_list
+ (object Role "$UNNAMED$94"
+ quid "4368377C0082"
+ supplier "Logical View::Assembly::ComponentType"
+ quidu "4367C2A20289"
+ client_cardinality (value cardinality "1..1")
+ is_navigable TRUE)
+ (object Role "$UNNAMED$95"
+ quid "4368377C0083"
+ supplier "Logical View::Assembly::Component"
+ quidu "4367C00800BF"))))
+ logical_presentations (list unit_reference_list
+ (object ClassDiagram "Main"
+ quid "4367BFB001D1"
+ title "Main"
+ zoom 65
+ max_height 28350
+ max_width 21600
+ origin_x 1596
+ origin_y 0
+ items (list diagram_item_list
+ (object ClassView "Class" "Logical View::Assembly::ConfiguredPort" @1
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (2634, 1211)
+ label (object ItemLabel
+ Parent_View @1
+ location (2456, 1142)
+ fill_color 13434879
+ nlines 1
+ max_width 356
+ justify 0
+ label "ConfiguredPort")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "4367C5D400C3"
+ width 374
+ height 163
+ annotation 8)
+ (object ClassView "Class" "Logical View::Assembly::Port" @2
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (3441, 1216)
+ label (object ItemLabel
+ Parent_View @2
+ location (3311, 1147)
+ fill_color 13434879
+ nlines 1
+ max_width 261
+ justify 0
+ label "Port")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "4367C58302CF"
+ width 279
+ height 163
+ annotation 8)
+ (object AssociationViewNew "$UNNAMED$58" @3
+ location (3061, 1212)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C5E00369"
+ roleview_list (list RoleViews
+ (object RoleView "$UNNAMED$59" @4
+ Parent_View @3
+ location (1135, 341)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C5E10342"
+ client @3
+ supplier @2
+ line_style 0
+ label (object SegLabel @5
+ Parent_View @4
+ location (3243, 1254)
+ anchor 2
+ anchor_loc 1
+ nlines 1
+ max_width 15
+ justify 0
+ label "1..1"
+ pctDist 0.763992
+ height 40
+ orientation 1))
+ (object RoleView "$UNNAMED$60" @6
+ Parent_View @3
+ location (1135, 341)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C5E10343"
+ client @3
+ supplier @1
+ line_style 0)))
+ (object ClassView "Class" "Logical View::Assembly::Interface" @7
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (3955, 1139)
+ font (object Font
+ italics TRUE)
+ label (object ItemLabel
+ Parent_View @7
+ location (3825, 1066)
+ fill_color 13434879
+ nlines 1
+ max_width 261
+ justify 0
+ label "Interface")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "4367C4260179"
+ width 279
+ height 173
+ annotation 8)
+ (object AssociationViewNew "$UNNAMED$46" @8
+ location (3697, 1176)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C4330286"
+ roleview_list (list RoleViews
+ (object RoleView "$UNNAMED$47" @9
+ Parent_View @8
+ location (1011, 170)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C4340327"
+ client @8
+ supplier @2
+ line_style 0)
+ (object RoleView "$UNNAMED$48" @10
+ Parent_View @8
+ location (1011, 170)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C4340328"
+ client @8
+ supplier @7
+ line_style 0
+ label (object SegLabel @11
+ Parent_View @10
+ location (3799, 1203)
+ anchor 2
+ anchor_loc 1
+ nlines 1
+ max_width 15
+ justify 0
+ label "1..1"
+ pctDist 0.813510
+ height 41
+ orientation 1))))
+ (object ClassView "Class" "Logical View::Assembly::InterfaceType" @12
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (3955, 1643)
+ label (object ItemLabel
+ Parent_View @12
+ location (3764, 1590)
+ fill_color 13434879
+ nlines 1
+ max_width 382
+ justify 0
+ label "InterfaceType")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "4367C43900EA"
+ width 400
+ height 131
+ annotation 8)
+ (object AssociationViewNew "$UNNAMED$49" @13
+ location (3866, 1367)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C4440168"
+ roleview_list (list RoleViews
+ (object RoleView "$UNNAMED$50" @14
+ Parent_View @13
+ location (1180, 361)
+ label (object SegLabel @15
+ Parent_View @14
+ location (3863, 1554)
+ hidden TRUE
+ anchor 1
+ anchor_loc 1
+ nlines 1
+ max_width 60
+ justify 0
+ label ""
+ pctDist 0.800000
+ height 42
+ orientation 1)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C44500FB"
+ client @13
+ supplier @12
+ vertices (list Points
+ (3866, 1367)
+ (3845, 1423)
+ (3921, 1577))
+ line_style 0
+ label (object SegLabel @16
+ Parent_View @14
+ location (3857, 1543)
+ anchor 2
+ anchor_loc 1
+ nlines 1
+ max_width 15
+ justify 0
+ label "0..1"
+ pctDist 0.746635
+ height 43
+ orientation 1))
+ (object RoleView "$UNNAMED$51" @17
+ Parent_View @13
+ location (1180, 361)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C44500FC"
+ client @13
+ supplier @7
+ line_style 0)))
+ (object AssociationViewNew "$UNNAMED$52" @18
+ location (4002, 1388)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C44A01DF"
+ roleview_list (list RoleViews
+ (object RoleView "$UNNAMED$53" @19
+ Parent_View @18
+ location (1316, 382)
+ label (object SegLabel @20
+ Parent_View @19
+ location (3945, 1529)
+ hidden TRUE
+ anchor 1
+ anchor_loc 1
+ nlines 1
+ max_width 60
+ justify 0
+ label ""
+ pctDist 0.800000
+ height 42
+ orientation 1)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C44C0155"
+ client @18
+ supplier @12
+ vertices (list Points
+ (4002, 1388)
+ (4013, 1447)
+ (3973, 1577))
+ line_style 0
+ label (object SegLabel @21
+ Parent_View @19
+ location (4036, 1548)
+ anchor 2
+ anchor_loc 1
+ nlines 1
+ max_width 15
+ justify 0
+ label "1..1"
+ pctDist 0.769913
+ height 51
+ orientation 0))
+ (object RoleView "$UNNAMED$54" @22
+ Parent_View @18
+ location (1316, 382)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C44C0156"
+ client @18
+ supplier @7
+ line_style 0)))
+ (object ClassView "Class" "Logical View::Assembly::OperationType" @23
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (3960, 1960)
+ label (object ItemLabel
+ Parent_View @23
+ location (3774, 1891)
+ fill_color 13434879
+ nlines 1
+ max_width 372
+ justify 0
+ label "OperationType")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "4367C64601FD"
+ width 390
+ height 162
+ annotation 8)
+ (object AssociationViewNew "$UNNAMED$61" @24
+ location (3956, 1793)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C65601D8"
+ roleview_list (list RoleViews
+ (object RoleView "$UNNAMED$62" @25
+ Parent_View @24
+ location (975, 69)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C65701A7"
+ client @24
+ supplier @12
+ line_style 0)
+ (object RoleView "$UNNAMED$63" @26
+ Parent_View @24
+ location (975, 69)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C65701A8"
+ client @24
+ supplier @23
+ line_style 0
+ label (object SegLabel @27
+ Parent_View @26
+ location (4005, 1843)
+ anchor 2
+ anchor_loc 1
+ nlines 1
+ max_width 15
+ justify 0
+ label "0..*"
+ pctDist 0.583172
+ height 48
+ orientation 0))))
+ (object ClassView "Class" "Logical View::Assembly::Binding" @28
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (1659, 2077)
+ font (object Font
+ italics TRUE)
+ label (object ItemLabel
+ Parent_View @28
+ location (1505, 2008)
+ fill_color 13434879
+ nlines 1
+ max_width 308
+ justify 0
+ label "Binding")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "4367C18A02C3"
+ compartment (object Compartment
+ Parent_View @28
+ location (1505, 2071)
+ icon_style "Icon"
+ fill_color 13434879
+ anchor 2
+ nlines 2
+ max_width 103)
+ width 326
+ height 163
+ annotation 8)
+ (object NoteView @29
+ location (4165, 2265)
+ label (object ItemLabel
+ Parent_View @29
+ location (3990, 2190)
+ fill_color 13434879
+ nlines 3
+ max_width 315
+ label "input, output and exception types")
+ line_color 3342489
+ fill_color 13434879
+ width 375
+ height 163)
+ (object NoteView @30
+ location (4268, 1394)
+ label (object ItemLabel
+ Parent_View @30
+ location (4083, 1323)
+ fill_color 13434879
+ nlines 3
+ max_width 334
+ label "interface and callback interface")
+ line_color 3342489
+ fill_color 13434879
+ width 394
+ height 154)
+ (object ClassView "Class" "Logical View::Assembly::ModuleFragment" @31
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (1370, 557)
+ label (object ItemLabel
+ Parent_View @31
+ location (1185, 477)
+ fill_color 13434879
+ nlines 1
+ max_width 371
+ justify 0
+ label "ModuleFragment")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "4367C50C038C"
+ width 389
+ height 184
+ annotation 8)
+ (object ClassView "Class" "Logical View::Assembly::Subsystem" @32
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (322, 207)
+ label (object ItemLabel
+ Parent_View @32
+ location (86, 119)
+ fill_color 13434879
+ nlines 1
+ max_width 472
+ justify 0
+ label "Subsystem")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "4367C757032C"
+ compartment (object Compartment
+ Parent_View @32
+ location (86, 177)
+ icon_style "Icon"
+ fill_color 13434879
+ anchor 2
+ nlines 2
+ max_width 103)
+ width 490
+ height 201
+ annotation 8)
+ (object ClassView "Class" "Logical View::Assembly::Module" @33
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (2484, 221)
+ label (object ItemLabel
+ Parent_View @33
+ location (2277, 123)
+ fill_color 13434879
+ nlines 1
+ max_width 414
+ justify 0
+ label "Module")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "4367C4C90079"
+ width 432
+ height 221
+ annotation 8)
+ (object AssociationViewNew "$UNNAMED$55" @34
+ location (1915, 391)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C52701D2"
+ roleview_list (list RoleViews
+ (object RoleView "$UNNAMED$56" @35
+ Parent_View @34
+ location (89, -1440)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C52801FC"
+ client @34
+ supplier @33
+ line_style 0)
+ (object RoleView "$UNNAMED$57" @36
+ Parent_View @34
+ location (89, -1440)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C52801FD"
+ client @34
+ supplier @31
+ line_style 0
+ label (object SegLabel @37
+ Parent_View @36
+ location (1890, 443)
+ anchor 2
+ anchor_loc 1
+ nlines 1
+ max_width 15
+ justify 0
+ label "0..*"
+ pctDist 0.110588
+ height 43
+ orientation 0))))
+ (object ClassView "Class" "Logical View::Assembly::ModuleComponent" @38
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (970, 216)
+ label (object ItemLabel
+ Parent_View @38
+ location (739, 132)
+ fill_color 13434879
+ nlines 1
+ max_width 463
+ justify 0
+ label "ModuleComponent")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "4367C4EA0315"
+ width 481
+ height 193
+ annotation 8)
+ (object AssociationViewNew "$UNNAMED$84" @39
+ location (648, 211)
+ stereotype TRUE
+ line_color 12632256
+ quidu "436834860263"
+ roleview_list (list RoleViews
+ (object RoleView "$UNNAMED$85" @40
+ Parent_View @39
+ location (-443, -183)
+ stereotype TRUE
+ line_color 3342489
+ quidu "436834870246"
+ client @39
+ supplier @32
+ line_style 0)
+ (object RoleView "$UNNAMED$86" @41
+ Parent_View @39
+ location (-443, -183)
+ stereotype TRUE
+ line_color 3342489
+ quidu "436834870247"
+ client @39
+ supplier @38
+ line_style 0
+ label (object SegLabel @42
+ Parent_View @41
+ location (693, 255)
+ anchor 2
+ anchor_loc 1
+ nlines 1
+ max_width 15
+ justify 0
+ label "0..*"
+ pctDist 0.549832
+ height 43
+ orientation 1))))
+ (object ClassView "Class" "Logical View::Assembly::ConfiguredModule" @43
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (1686, 216)
+ label (object ItemLabel
+ Parent_View @43
+ location (1484, 146)
+ fill_color 13434879
+ nlines 1
+ max_width 405
+ justify 0
+ label "ConfiguredModule")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "436836780038"
+ width 423
+ height 164
+ annotation 8)
+ (object AssociationViewNew "$UNNAMED$90" @44
+ location (2082, 217)
+ stereotype TRUE
+ line_color 3342489
+ quidu "436836850218"
+ roleview_list (list RoleViews
+ (object RoleView "$UNNAMED$91" @45
+ Parent_View @44
+ location (-369, -23)
+ stereotype TRUE
+ line_color 3342489
+ quidu "43683686027D"
+ client @44
+ supplier @43
+ line_style 0)
+ (object RoleView "$UNNAMED$92" @46
+ Parent_View @44
+ location (-369, -23)
+ stereotype TRUE
+ line_color 3342489
+ quidu "43683686027E"
+ client @44
+ supplier @33
+ line_style 0
+ label (object SegLabel @47
+ Parent_View @46
+ location (2201, 251)
+ anchor 2
+ anchor_loc 1
+ nlines 1
+ max_width 15
+ justify 0
+ label "1..1"
+ pctDist 0.649262
+ height 33
+ orientation 1))))
+ (object AssociationViewNew "$UNNAMED$81" @48
+ location (1342, 216)
+ stereotype TRUE
+ line_color 12632256
+ quidu "43682F4B0394"
+ roleview_list (list RoleViews
+ (object RoleView "$UNNAMED$82" @49
+ Parent_View @48
+ location (-566, -5)
+ stereotype TRUE
+ line_color 3342489
+ quidu "43682F4D0076"
+ client @48
+ supplier @38
+ line_style 0)
+ (object RoleView "$UNNAMED$83" @50
+ Parent_View @48
+ location (-566, -5)
+ stereotype TRUE
+ line_color 3342489
+ quidu "43682F4D0077"
+ client @48
+ supplier @43
+ line_style 0
+ label (object SegLabel @51
+ Parent_View @50
+ location (1431, 183)
+ anchor 2
+ anchor_loc 1
+ nlines 1
+ max_width 15
+ justify 0
+ label "1..1"
+ pctDist 0.677064
+ height 34
+ orientation 0))))
+ (object ClassView "Class" "Logical View::Assembly::Part" @52
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (282, 1734)
+ label (object ItemLabel
+ Parent_View @52
+ location (144, 1652)
+ fill_color 13434879
+ nlines 1
+ max_width 276
+ justify 0
+ label "Part")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "4367BFD202AC"
+ compartment (object Compartment
+ Parent_View @52
+ location (144, 1710)
+ icon_style "Icon"
+ fill_color 13434879
+ anchor 2
+ nlines 2
+ max_width 159)
+ width 294
+ height 188
+ annotation 8)
+ (object ClassView "Class" "Logical View::Assembly::ExternalService" @53
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (1065, 2289)
+ label (object ItemLabel
+ Parent_View @53
+ location (887, 2205)
+ fill_color 13434879
+ nlines 1
+ max_width 357
+ justify 0
+ label "ExternalService")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "4367C00E009F"
+ compartment (object Compartment
+ Parent_View @53
+ location (887, 2263)
+ icon_style "Icon"
+ fill_color 13434879
+ anchor 2
+ nlines 2
+ max_width 250)
+ width 375
+ height 192
+ annotation 8)
+ (object AssociationViewNew "$UNNAMED$40" @54
+ location (1373, 2177)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C39A0240"
+ roleview_list (list RoleViews
+ (object RoleView "$UNNAMED$41" @55
+ Parent_View @54
+ location (749, 499)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C39B01AB"
+ client @54
+ supplier @53
+ line_style 0)
+ (object RoleView "$UNNAMED$42" @56
+ Parent_View @54
+ location (749, 499)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C39B01AC"
+ client @54
+ supplier @28
+ line_style 0
+ label (object SegLabel @57
+ Parent_View @56
+ location (1484, 2184)
+ anchor 2
+ anchor_loc 1
+ nlines 1
+ max_width 15
+ justify 0
+ label "0..*"
+ pctDist 0.781968
+ height 45
+ orientation 1))))
+ (object InheritView "" @58
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C289032D"
+ client @53
+ supplier @52
+ vertices (list Points
+ (877, 2266)
+ (659, 2241)
+ (352, 1828))
+ line_style 0)
+ (object ClassView "Class" "Logical View::Assembly::EntryPoint" @59
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (1024, 1697)
+ label (object ItemLabel
+ Parent_View @59
+ location (865, 1618)
+ fill_color 13434879
+ nlines 1
+ max_width 319
+ justify 0
+ label "EntryPoint")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "4367C0210101"
+ width 337
+ height 183
+ annotation 8)
+ (object AssociationViewNew "$UNNAMED$37" @60
+ location (1349, 1891)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C396015E"
+ roleview_list (list RoleViews
+ (object RoleView "$UNNAMED$38" @61
+ Parent_View @60
+ location (725, 213)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C39700D3"
+ client @60
+ supplier @59
+ line_style 0)
+ (object RoleView "$UNNAMED$39" @62
+ Parent_View @60
+ location (725, 213)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C39700D4"
+ client @60
+ supplier @28
+ line_style 0
+ label (object SegLabel @63
+ Parent_View @62
+ location (1533, 1950)
+ anchor 2
+ anchor_loc 1
+ nlines 1
+ max_width 15
+ justify 0
+ label "0..*"
+ pctDist 0.928105
+ height 44
+ orientation 0))))
+ (object InheritView "" @64
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C27E030A"
+ client @59
+ supplier @52
+ line_style 0)
+ (object ClassView "Class" "Logical View::Assembly::Type" @65
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (3664, 2296)
+ label (object ItemLabel
+ Parent_View @65
+ location (3557, 2247)
+ fill_color 13434879
+ nlines 1
+ max_width 214
+ justify 0
+ label "Type")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "4367C65D0124"
+ width 232
+ height 122
+ annotation 8)
+ (object AssociationViewNew "$UNNAMED$64" @66
+ location (3881, 2120)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C66702F5"
+ roleview_list (list RoleViews
+ (object RoleView "$UNNAMED$65" @67
+ Parent_View @66
+ location (1247, 106)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C6680328"
+ client @66
+ supplier @23
+ line_style 0)
+ (object RoleView "exceptionTypes" @68
+ Parent_View @66
+ location (1247, 106)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C6680329"
+ client @66
+ supplier @65
+ vertices (list Points
+ (3881, 2120)
+ (3855, 2174)
+ (3760, 2234))
+ line_style 0
+ label (object SegLabel @69
+ Parent_View @68
+ location (3833, 2235)
+ anchor 2
+ anchor_loc 1
+ nlines 1
+ max_width 15
+ justify 0
+ label "0..*"
+ pctDist 0.653401
+ height 40
+ orientation 0))))
+ (object AttachView "" @70
+ stereotype TRUE
+ line_color 3342489
+ client @29
+ supplier @66
+ line_style 0)
+ (object AssociationViewNew "$UNNAMED$66" @71
+ location (3802, 2137)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C66B039B"
+ roleview_list (list RoleViews
+ (object RoleView "$UNNAMED$67" @72
+ Parent_View @71
+ location (1168, 123)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C66C02FC"
+ client @71
+ supplier @23
+ line_style 0)
+ (object RoleView "outputType" @73
+ Parent_View @71
+ location (1168, 123)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C66C02FD"
+ client @71
+ supplier @65
+ line_style 0
+ label (object SegLabel @74
+ Parent_View @73
+ location (3759, 2156)
+ anchor 2
+ anchor_loc 1
+ nlines 1
+ max_width 15
+ justify 0
+ label "0..1"
+ pctDist 0.329806
+ height 21
+ orientation 1))))
+ (object AttachView "" @75
+ stereotype TRUE
+ line_color 3342489
+ client @29
+ supplier @71
+ line_style 0)
+ (object AssociationViewNew "$UNNAMED$68" @76
+ location (3770, 2078)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C671033F"
+ roleview_list (list RoleViews
+ (object RoleView "$UNNAMED$69" @77
+ Parent_View @76
+ location (1136, 64)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C6730202"
+ client @76
+ supplier @23
+ line_style 0)
+ (object RoleView "inputType" @78
+ Parent_View @76
+ location (1136, 64)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C6730203"
+ client @76
+ supplier @65
+ vertices (list Points
+ (3770, 2078)
+ (3720, 2111)
+ (3682, 2234))
+ line_style 0
+ label (object SegLabel @79
+ Parent_View @78
+ location (3659, 2182)
+ anchor 2
+ anchor_loc 1
+ nlines 1
+ max_width 15
+ justify 0
+ label "1..1"
+ pctDist 0.773759
+ height 39
+ orientation 1))))
+ (object AttachView "" @80
+ stereotype TRUE
+ line_color 3342489
+ client @29
+ supplier @76
+ line_style 0)
+ (object ClassView "Class" "Logical View::Assembly::Property" @81
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (2790, 1913)
+ label (object ItemLabel
+ Parent_View @81
+ location (2645, 1756)
+ fill_color 13434879
+ nlines 1
+ max_width 290
+ justify 0
+ label "Property")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "4367C2C30381"
+ compartment (object Compartment
+ Parent_View @81
+ location (2645, 1814)
+ icon_style "Icon"
+ fill_color 13434879
+ anchor 2
+ nlines 5
+ max_width 203)
+ width 308
+ height 338
+ annotation 8)
+ (object AssociationViewNew "$UNNAMED$70" @82
+ location (3245, 2112)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C6790391"
+ roleview_list (list RoleViews
+ (object RoleView "$UNNAMED$71" @83
+ Parent_View @82
+ location (1168, 892)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C67B0073"
+ client @82
+ supplier @65
+ line_style 0)
+ (object RoleView "$UNNAMED$72" @84
+ Parent_View @82
+ location (1168, 892)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C67B007D"
+ client @82
+ supplier @81
+ line_style 0)))
+ (object ClassView "Class" "Logical View::Assembly::Service" @85
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (3340, 846)
+ label (object ItemLabel
+ Parent_View @85
+ location (3167, 776)
+ fill_color 13434879
+ nlines 1
+ max_width 347
+ justify 0
+ label "Service")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "4367C2B1014A"
+ compartment (object Compartment
+ Parent_View @85
+ location (3167, 834)
+ icon_style "Icon"
+ fill_color 13434879
+ anchor 2
+ nlines 2
+ max_width 164)
+ width 365
+ height 164
+ annotation 8)
+ (object InheritView "" @86
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C5A80001"
+ client @85
+ supplier @2
+ line_style 0)
+ (object ClassView "Class" "Logical View::Assembly::Reference" @87
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (3350, 1567)
+ label (object ItemLabel
+ Parent_View @87
+ location (3167, 1488)
+ fill_color 13434879
+ nlines 1
+ max_width 367
+ justify 0
+ label "Reference")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "4367C2B90318"
+ compartment (object Compartment
+ Parent_View @87
+ location (3167, 1546)
+ icon_style "Icon"
+ fill_color 13434879
+ anchor 2
+ nlines 2
+ max_width 253)
+ width 385
+ height 183
+ annotation 8)
+ (object InheritView "" @88
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C5AB00EC"
+ client @87
+ supplier @2
+ line_style 0)
+ (object ClassView "Class" "Logical View::Assembly::Aggregate" @89
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (419, 815)
+ label (object ItemLabel
+ Parent_View @89
+ location (194, 733)
+ fill_color 13434879
+ nlines 1
+ max_width 451
+ justify 0
+ label "Aggregate")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "4367BFB702AD"
+ compartment (object Compartment
+ Parent_View @89
+ location (194, 791)
+ icon_style "Icon"
+ fill_color 13434879
+ anchor 2
+ nlines 2
+ max_width 159)
+ width 469
+ height 188
+ annotation 8)
+ (object AssociationViewNew "$UNNAMED$6" @90
+ location (212, 1248)
+ stereotype TRUE
+ line_color 12632256
+ quidu "4367C10E0314"
+ roleview_list (list RoleViews
+ (object RoleView "aggregate" @91
+ Parent_View @90
+ location (-1159, 723)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C10F0348"
+ client @90
+ supplier @89
+ vertices (list Points
+ (212, 1248)
+ (174, 981)
+ (278, 909))
+ line_style 0)
+ (object RoleView "parts" @92
+ Parent_View @90
+ location (-1159, 723)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C10F0349"
+ client @90
+ supplier @52
+ line_style 0
+ label (object SegLabel @93
+ Parent_View @92
+ location (214, 1579)
+ anchor 2
+ anchor_loc 1
+ nlines 1
+ max_width 15
+ justify 0
+ label "0..*"
+ pctDist 0.833230
+ height 45
+ orientation 1))))
+ (object AssociationViewNew "$UNNAMED$4" @94
+ location (651, 1575)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C02F02C4"
+ roleview_list (list RoleViews
+ (object RoleView "$UNNAMED$5" @95
+ Parent_View @94
+ location (-451, 638)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C03002ED"
+ client @94
+ supplier @89
+ vertices (list Points
+ (651, 1575)
+ (510, 1332)
+ (434, 909))
+ line_style 0)
+ (object RoleView "externalServices" @96
+ Parent_View @94
+ location (-451, 638)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C03002EE"
+ client @94
+ supplier @53
+ line_style 0
+ label (object SegLabel @97
+ Parent_View @96
+ location (914, 2131)
+ anchor 2
+ anchor_loc 1
+ nlines 1
+ max_width 15
+ justify 0
+ label "0..*"
+ pctDist 0.858067
+ height 51
+ orientation 1))))
+ (object AssociationViewNew "$UNNAMED$0" @98
+ location (678, 1277)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C02A0050"
+ roleview_list (list RoleViews
+ (object RoleView "$UNNAMED$1" @99
+ Parent_View @98
+ location (297, 346)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C02A03D5"
+ client @98
+ supplier @89
+ line_style 0)
+ (object RoleView "entryPoints" @100
+ Parent_View @98
+ location (297, 346)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C02A03D6"
+ client @98
+ supplier @59
+ vertices (list Points
+ (678, 1277)
+ (741, 1390)
+ (939, 1605))
+ line_style 0
+ label (object SegLabel @101
+ Parent_View @100
+ location (973, 1554)
+ anchor 2
+ anchor_loc 1
+ nlines 1
+ max_width 15
+ justify 0
+ label "0..*"
+ pctDist 0.965692
+ height 60
+ orientation 0))))
+ (object InheritView "" @102
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C76B03AD"
+ client @32
+ supplier @89
+ line_style 0)
+ (object InheritView "" @103
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C52000D8"
+ client @31
+ supplier @89
+ line_style 0)
+ (object ClassView "Class" "Logical View::Assembly::ConfiguredProperty" @104
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (2239, 1836)
+ label (object ItemLabel
+ Parent_View @104
+ location (2047, 1771)
+ fill_color 13434879
+ nlines 1
+ max_width 385
+ justify 0
+ label "ConfiguredProperty")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "4367C205012F"
+ compartment (object Compartment
+ Parent_View @104
+ location (2047, 1829)
+ icon_style "Icon"
+ fill_color 13434879
+ anchor 2
+ nlines 2
+ max_width 150)
+ width 403
+ height 154
+ annotation 8)
+ (object AssociationViewNew "$UNNAMED$28" @105
+ location (2537, 1876)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C2E901EB"
+ roleview_list (list RoleViews
+ (object RoleView "$UNNAMED$29" @106
+ Parent_View @105
+ location (1178, 683)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C2EA020A"
+ client @105
+ supplier @81
+ line_style 0
+ label (object SegLabel @107
+ Parent_View @106
+ location (2608, 1941)
+ anchor 2
+ anchor_loc 1
+ nlines 1
+ max_width 15
+ justify 0
+ label "1..1"
+ pctDist 0.806972
+ height 55
+ orientation 1))
+ (object RoleView "$UNNAMED$30" @108
+ Parent_View @105
+ location (1178, 683)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C2EA020B"
+ client @105
+ supplier @104
+ line_style 0)))
+ (object ClassView "Class" "Logical View::Assembly::ConfiguredService" @109
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (1925, 1197)
+ label (object ItemLabel
+ Parent_View @109
+ location (1697, 1138)
+ fill_color 13434879
+ nlines 1
+ max_width 457
+ justify 0
+ label "ConfiguredService")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "4367C1E10105"
+ width 475
+ height 143
+ annotation 8)
+ (object AssociationViewNew "$UNNAMED$34" @110
+ location (1503, 1730)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C3170350"
+ roleview_list (list RoleViews
+ (object RoleView "$UNNAMED$35" @111
+ Parent_View @110
+ location (223, 968)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C319008C"
+ client @110
+ supplier @53
+ line_style 0)
+ (object RoleView "$UNNAMED$36" @112
+ Parent_View @110
+ location (223, 968)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C319008D"
+ client @110
+ supplier @109
+ line_style 0
+ label (object SegLabel @113
+ Parent_View @112
+ location (1790, 1305)
+ anchor 2
+ anchor_loc 1
+ nlines 1
+ max_width 15
+ justify 0
+ label "1..1"
+ pctDist 0.870036
+ height 39
+ orientation 0))))
+ (object InheritView "" @114
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C5EB01DE"
+ client @109
+ supplier @1
+ line_style 0)
+ (object AssociationViewNew "$UNNAMED$75" @115
+ location (2659, 1013)
+ stereotype TRUE
+ line_color 12632256
+ quidu "4367C73A0384"
+ roleview_list (list RoleViews
+ (object RoleView "$UNNAMED$76" @116
+ Parent_View @115
+ location (1257, 535)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C73C0020"
+ client @115
+ supplier @85
+ line_style 0
+ label (object SegLabel @117
+ Parent_View @116
+ location (3121, 954)
+ anchor 2
+ anchor_loc 1
+ nlines 1
+ max_width 15
+ justify 0
+ label "1..1"
+ pctDist 0.900000
+ height 54
+ orientation 1))
+ (object RoleView "$UNNAMED$77" @118
+ Parent_View @115
+ location (1257, 535)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C73C0021"
+ client @115
+ supplier @109
+ line_style 0)))
+ (object ClassView "Class" "Logical View::Assembly::ConfiguredReference" @119
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (2109, 1507)
+ label (object ItemLabel
+ Parent_View @119
+ location (1906, 1444)
+ fill_color 13434879
+ nlines 1
+ max_width 407
+ justify 0
+ label "ConfiguredReference")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "4367C1EC0011"
+ width 425
+ height 150
+ annotation 8)
+ (object AssociationViewNew "$UNNAMED$43" @120
+ location (1544, 1605)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C39F021F"
+ roleview_list (list RoleViews
+ (object RoleView "$UNNAMED$44" @121
+ Parent_View @120
+ location (211, 636)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C3A0031B"
+ client @120
+ supplier @59
+ line_style 0)
+ (object RoleView "$UNNAMED$45" @122
+ Parent_View @120
+ location (211, 636)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C3A0031C"
+ client @120
+ supplier @119
+ line_style 0
+ label (object SegLabel @123
+ Parent_View @122
+ location (1842, 1587)
+ anchor 2
+ anchor_loc 1
+ nlines 1
+ max_width 15
+ justify 0
+ label "1..1"
+ pctDist 0.831865
+ height 35
+ orientation 1))))
+ (object InheritView "" @124
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C5EE02D3"
+ client @119
+ supplier @1
+ line_style 0)
+ (object AssociationViewNew "$UNNAMED$73" @125
+ location (2015, 1349)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C6C10222"
+ roleview_list (list RoleViews
+ (object RoleView "serviceEndpoints" @126
+ Parent_View @125
+ location (728, 561)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C6C20129"
+ client @125
+ supplier @109
+ line_style 0
+ label (object SegLabel @127
+ Parent_View @126
+ location (2032, 1282)
+ anchor 2
+ anchor_loc 1
+ nlines 1
+ max_width 15
+ justify 0
+ label "0..*"
+ pctDist 0.540799
+ height 49
+ orientation 1))
+ (object RoleView "$UNNAMED$74" @128
+ Parent_View @125
+ location (728, 561)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C6C2012A"
+ client @125
+ supplier @119
+ line_style 0)))
+ (object AssociationViewNew "$UNNAMED$78" @129
+ location (2739, 1537)
+ stereotype TRUE
+ line_color 12632256
+ quidu "4367C740038D"
+ roleview_list (list RoleViews
+ (object RoleView "$UNNAMED$79" @130
+ Parent_View @129
+ location (1452, 749)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C7420001"
+ client @129
+ supplier @87
+ line_style 0
+ label (object SegLabel @131
+ Parent_View @130
+ location (3112, 1609)
+ anchor 2
+ anchor_loc 1
+ nlines 1
+ max_width 15
+ justify 0
+ label "1..1"
+ pctDist 0.900000
+ height 54
+ orientation 1))
+ (object RoleView "$UNNAMED$80" @132
+ Parent_View @129
+ location (1452, 749)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C7420002"
+ client @129
+ supplier @119
+ line_style 0)))
+ (object NoteView @133
+ location (3319, 207)
+ label (object ItemLabel
+ Parent_View @133
+ location (2990, 107)
+ fill_color 13434879
+ nlines 4
+ max_width 623
+ label "Relationships marked grey are specialized relationships derived from relationships on the base classes")
+ line_color 3342489
+ fill_color 13434879
+ width 683
+ height 212)
+ (object ClassView "Class" "Logical View::Assembly::Implementation" @134
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (2382, 572)
+ font (object Font
+ italics TRUE)
+ label (object ItemLabel
+ Parent_View @134
+ location (2170, 483)
+ fill_color 13434879
+ nlines 1
+ max_width 424
+ justify 0
+ label "Implementation")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "436833C300FA"
+ width 442
+ height 202
+ annotation 8)
+ (object ClassView "Class" "Logical View::Assembly::Component" @135
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (1048, 1236)
+ label (object ItemLabel
+ Parent_View @135
+ location (889, 1128)
+ fill_color 13434879
+ nlines 1
+ max_width 318
+ justify 0
+ label "Component")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "4367C00800BF"
+ width 336
+ height 240
+ annotation 8)
+ (object AssociationViewNew "$UNNAMED$2" @136
+ location (720, 1015)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C02C025B"
+ roleview_list (list RoleViews
+ (object RoleView "$UNNAMED$3" @137
+ Parent_View @136
+ location (-4, 75)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C02D022B"
+ client @136
+ supplier @89
+ line_style 0)
+ (object RoleView "components" @138
+ Parent_View @136
+ location (-4, 75)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C02D022C"
+ client @136
+ supplier @135
+ line_style 0
+ label (object SegLabel @139
+ Parent_View @138
+ location (792, 1130)
+ anchor 2
+ anchor_loc 1
+ nlines 1
+ max_width 15
+ justify 0
+ label "0..*"
+ pctDist 0.647499
+ height 55
+ orientation 1))))
+ (object AssociationViewNew "$UNNAMED$13" @140
+ location (1651, 1539)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C26D0297"
+ roleview_list (list RoleViews
+ (object RoleView "$UNNAMED$14" @141
+ Parent_View @140
+ location (292, 346)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C26E037F"
+ client @140
+ supplier @135
+ line_style 0)
+ (object RoleView "$UNNAMED$15" @142
+ Parent_View @140
+ location (292, 346)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C26E0380"
+ client @140
+ supplier @104
+ line_style 0
+ label (object SegLabel @143
+ Parent_View @142
+ location (2108, 1709)
+ anchor 2
+ anchor_loc 1
+ nlines 1
+ max_width 15
+ justify 0
+ label "0..*"
+ pctDist 0.989365
+ height 54
+ orientation 0))))
+ (object InheritView "" @144
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C4FA01C4"
+ client @38
+ supplier @135
+ line_style 0)
+ (object AssociationViewNew "$UNNAMED$7" @145
+ location (1451, 1216)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C265015F"
+ roleview_list (list RoleViews
+ (object RoleView "$UNNAMED$8" @146
+ Parent_View @145
+ location (171, 454)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C2660110"
+ client @145
+ supplier @135
+ line_style 0)
+ (object RoleView "$UNNAMED$9" @147
+ Parent_View @145
+ location (171, 454)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C2660111"
+ client @145
+ supplier @109
+ line_style 0
+ label (object SegLabel @148
+ Parent_View @147
+ location (1623, 1246)
+ anchor 2
+ anchor_loc 1
+ nlines 1
+ max_width 15
+ justify 0
+ label "0..*"
+ pctDist 0.721799
+ height 37
+ orientation 1))))
+ (object AssociationViewNew "$UNNAMED$10" @149
+ location (1556, 1364)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C269025F"
+ roleview_list (list RoleViews
+ (object RoleView "$UNNAMED$11" @150
+ Parent_View @149
+ location (223, 395)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C26A026B"
+ client @149
+ supplier @135
+ line_style 0)
+ (object RoleView "$UNNAMED$12" @151
+ Parent_View @149
+ location (223, 395)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C26A026C"
+ client @149
+ supplier @119
+ line_style 0
+ label (object SegLabel @152
+ Parent_View @151
+ location (1882, 1409)
+ anchor 2
+ anchor_loc 1
+ nlines 1
+ max_width 15
+ justify 0
+ label "0..*"
+ pctDist 0.932217
+ height 38
+ orientation 0))))
+ (object InheritView "" @153
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C286003A"
+ client @135
+ supplier @52
+ vertices (list Points
+ (879, 1242)
+ (347, 1265)
+ (294, 1639))
+ line_style 0)
+ (object ClassView "Class" "Logical View::Assembly::ComponentType" @154
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (3024, 567)
+ label (object ItemLabel
+ Parent_View @154
+ location (2843, 492)
+ fill_color 13434879
+ nlines 1
+ max_width 363
+ justify 0
+ label "ComponentType")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "4367C2A20289"
+ width 381
+ height 175
+ annotation 8)
+ (object AssociationViewNew "$UNNAMED$25" @155
+ location (2913, 1198)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C2DC002A"
+ roleview_list (list RoleViews
+ (object RoleView "$UNNAMED$26" @156
+ Parent_View @155
+ location (861, 27)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C2DD0035"
+ client @155
+ supplier @154
+ line_style 0)
+ (object RoleView "$UNNAMED$27" @157
+ Parent_View @155
+ location (861, 27)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C2DD0036"
+ client @155
+ supplier @81
+ line_style 0
+ label (object SegLabel @158
+ Parent_View @157
+ location (2881, 1698)
+ anchor 2
+ anchor_loc 1
+ nlines 1
+ max_width 15
+ justify 0
+ label "0..*"
+ pctDist 0.900000
+ height 54
+ orientation 0))))
+ (object AssociationViewNew "$UNNAMED$19" @159
+ location (3185, 708)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C2D50200"
+ roleview_list (list RoleViews
+ (object RoleView "$UNNAMED$20" @160
+ Parent_View @159
+ location (1142, -35)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C2D60099"
+ client @159
+ supplier @154
+ line_style 0)
+ (object RoleView "$UNNAMED$21" @161
+ Parent_View @159
+ location (1142, -35)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C2D6009A"
+ client @159
+ supplier @85
+ line_style 0
+ label (object SegLabel @162
+ Parent_View @161
+ location (3277, 719)
+ anchor 2
+ anchor_loc 1
+ nlines 1
+ max_width 15
+ justify 0
+ label "1..*"
+ pctDist 0.900000
+ height 54
+ orientation 0))))
+ (object AssociationViewNew "$UNNAMED$22" @163
+ location (3096, 1115)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C2D8018C"
+ roleview_list (list RoleViews
+ (object RoleView "$UNNAMED$23" @164
+ Parent_View @163
+ location (1050, 159)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C2D9015C"
+ client @163
+ supplier @154
+ vertices (list Points
+ (3096, 1115)
+ (3067, 1063)
+ (3030, 654))
+ line_style 0)
+ (object RoleView "$UNNAMED$24" @165
+ Parent_View @163
+ location (1050, 159)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C2D9015D"
+ client @163
+ supplier @87
+ line_style 0
+ label (object SegLabel @166
+ Parent_View @165
+ location (3324, 1414)
+ anchor 2
+ anchor_loc 1
+ nlines 1
+ max_width 15
+ justify 0
+ label "0..*"
+ pctDist 0.900000
+ height 54
+ orientation 0))))
+ (object AssociationViewNew "$UNNAMED$93" @167
+ location (2110, 983)
+ stereotype TRUE
+ line_color 12632256
+ quidu "43683779039F"
+ roleview_list (list RoleViews
+ (object RoleView "$UNNAMED$94" @168
+ Parent_View @167
+ location (1062, -253)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4368377C0082"
+ client @167
+ supplier @154
+ vertices (list Points
+ (2110, 983)
+ (2771, 827)
+ (2938, 654))
+ line_style 0
+ label (object SegLabel @169
+ Parent_View @168
+ location (2844, 689)
+ anchor 2
+ anchor_loc 1
+ nlines 1
+ max_width 15
+ justify 0
+ label "1..1"
+ pctDist 0.902899
+ height 44
+ orientation 0))
+ (object RoleView "$UNNAMED$95" @170
+ Parent_View @167
+ location (1062, -253)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4368377C0083"
+ client @167
+ supplier @135
+ line_style 0)))
+ (object ClassView "Class" "Logical View::Assembly::ConfiguredImplementation" @171
+ ShowCompartmentStereotypes TRUE
+ IncludeAttribute TRUE
+ IncludeOperation TRUE
+ location (1696, 889)
+ font (object Font
+ italics TRUE)
+ label (object ItemLabel
+ Parent_View @171
+ location (1441, 815)
+ fill_color 13434879
+ nlines 1
+ max_width 511
+ justify 0
+ label "ConfiguredImplementation")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "4367C1D70165"
+ width 529
+ height 173
+ annotation 8)
+ (object AssociationViewNew "$UNNAMED$87" @172
+ location (1985, 627)
+ stereotype TRUE
+ line_color 3342489
+ quidu "436835A101A2"
+ roleview_list (list RoleViews
+ (object RoleView "$UNNAMED$88" @173
+ Parent_View @172
+ location (-331, -195)
+ stereotype TRUE
+ line_color 3342489
+ quidu "436835A20289"
+ client @172
+ supplier @134
+ line_style 0
+ label (object SegLabel @174
+ Parent_View @173
+ location (2149, 657)
+ anchor 2
+ anchor_loc 1
+ nlines 1
+ max_width 15
+ justify 0
+ label "0..1"
+ pctDist 0.900000
+ height 54
+ orientation 1))
+ (object RoleView "$UNNAMED$89" @175
+ Parent_View @172
+ location (-331, -195)
+ stereotype TRUE
+ line_color 3342489
+ quidu "436835A2028A"
+ client @172
+ supplier @171
+ vertices (list Points
+ (1985, 627)
+ (1926, 635)
+ (1773, 802))
+ line_style 0)))
+ (object AssociationViewNew "$UNNAMED$16" @176
+ location (1375, 1060)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C29500DC"
+ roleview_list (list RoleViews
+ (object RoleView "$UNNAMED$17" @177
+ Parent_View @176
+ location (4, -362)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C296021E"
+ client @176
+ supplier @135
+ line_style 0)
+ (object RoleView "$UNNAMED$18" @178
+ Parent_View @176
+ location (4, -362)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C296021F"
+ client @176
+ supplier @171
+ line_style 0
+ label (object SegLabel @179
+ Parent_View @178
+ location (1393, 996)
+ anchor 2
+ anchor_loc 1
+ nlines 1
+ max_width 15
+ justify 0
+ label "1..1"
+ pctDist 0.257075
+ height 49
+ orientation 0))))
+ (object AssociationViewNew "$UNNAMED$31" @180
+ location (2407, 787)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C2F00000"
+ roleview_list (list RoleViews
+ (object RoleView "$UNNAMED$32" @181
+ Parent_View @180
+ location (1074, -669)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C2F10174"
+ client @180
+ supplier @154
+ vertices (list Points
+ (2407, 787)
+ (2603, 760)
+ (2833, 653))
+ line_style 0
+ label (object SegLabel @182
+ Parent_View @181
+ location (2672, 679)
+ anchor 2
+ anchor_loc 1
+ nlines 1
+ max_width 15
+ justify 0
+ label "1..1"
+ pctDist 0.652556
+ height 46
+ orientation 0))
+ (object RoleView "$UNNAMED$33" @183
+ Parent_View @180
+ location (1074, -669)
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C2F10175"
+ client @180
+ supplier @171
+ line_style 0)))
+ (object InheritView "" @184
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C4D4009D"
+ client @33
+ supplier @89
+ vertices (list Points
+ (2267, 255)
+ (787, 500)
+ (528, 720))
+ line_style 0)
+ (object InheritView "" @185
+ stereotype TRUE
+ line_color 3342489
+ quidu "4367C4CF001D"
+ client @33
+ supplier @134
+ line_style 0)
+ (object InheritView "" @186
+ stereotype TRUE
+ line_color 3342489
+ quidu "436836C701A4"
+ client @43
+ supplier @171
+ line_style 0)
+ (object AttachView "" @187
+ stereotype TRUE
+ line_color 3342489
+ client @30
+ supplier @18
+ line_style 0)
+ (object AttachView "" @188
+ stereotype TRUE
+ line_color 3342489
+ client @30
+ supplier @13
+ vertices (list Points
+ (4070, 1360)
+ (3941, 1341)
+ (3866, 1367))
+ line_style 0))))))
+ logical_presentations (list unit_reference_list
+ (object ClassDiagram "Main"
+ quid "4367BF7F000E"
+ title "Main"
+ zoom 100
+ max_height 28350
+ max_width 21600
+ origin_x 0
+ origin_y 0
+ items (list diagram_item_list
+ (object CategoryView "Logical View::Assembly" @189
+ location (216, 375)
+ label (object ItemLabel
+ Parent_View @189
+ location (72, 291)
+ fill_color 13434879
+ nlines 2
+ max_width 288
+ justify 0
+ label "Assembly")
+ icon_style "Icon"
+ line_color 3342489
+ fill_color 13434879
+ quidu "4367BFA901F9"
+ width 300
+ height 180)))))
+ root_subsystem (object SubSystem "Component View"
+ quid "4367BF7F0007"
+ physical_models (list unit_reference_list)
+ physical_presentations (list unit_reference_list
+ (object Module_Diagram "Main"
+ quid "4367BF7F0036"
+ title "Main"
+ zoom 100
+ max_height 28350
+ max_width 21600
+ origin_x 0
+ origin_y 0
+ items (list diagram_item_list))))
+ process_structure (object Processes
+ quid "4367BF7F0008"
+ ProcsNDevs (list
+ (object Process_Diagram "Deployment View"
+ quid "4367BF7F000A"
+ title "Deployment View"
+ zoom 100
+ max_height 28350
+ max_width 21600
+ origin_x 0
+ origin_y 0
+ items (list diagram_item_list))))
+ properties (object Properties
+ attributes (list Attribute_Set
+ (object Attribute
+ tool "DDL"
+ name "propertyId"
+ value "809135966")
+ (object Attribute
+ tool "DDL"
+ name "default__Project"
+ value (list Attribute_Set
+ (object Attribute
+ tool "DDL"
+ name "Directory"
+ value "AUTO GENERATE")
+ (object Attribute
+ tool "DDL"
+ name "DataBase"
+ value ("DataBaseSet" 800))
+ (object Attribute
+ tool "DDL"
+ name "DataBaseSet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "DDL"
+ name "ANSI"
+ value 800)
+ (object Attribute
+ tool "DDL"
+ name "Oracle"
+ value 801)
+ (object Attribute
+ tool "DDL"
+ name "SQLServer"
+ value 802)
+ (object Attribute
+ tool "DDL"
+ name "Sybase"
+ value 803)
+ (object Attribute
+ tool "DDL"
+ name "Watcom"
+ value 804)))
+ (object Attribute
+ tool "DDL"
+ name "PrimaryKeyColumnName"
+ value "Id")
+ (object Attribute
+ tool "DDL"
+ name "PrimaryKeyColumnType"
+ value "NUMBER(5)")
+ (object Attribute
+ tool "DDL"
+ name "ViewName"
+ value "V_")
+ (object Attribute
+ tool "DDL"
+ name "TableName"
+ value "T_")
+ (object Attribute
+ tool "DDL"
+ name "InheritSuffix"
+ value "_V")
+ (object Attribute
+ tool "DDL"
+ name "DropClause"
+ value FALSE)
+ (object Attribute
+ tool "DDL"
+ name "BaseViews"
+ value FALSE)
+ (object Attribute
+ tool "DDL"
+ name "DDLScriptFilename"
+ value "DDL1.SQL")))
+ (object Attribute
+ tool "DDL"
+ name "default__Attribute"
+ value (list Attribute_Set
+ (object Attribute
+ tool "DDL"
+ name "ColumnType"
+ value "VARCHAR")
+ (object Attribute
+ tool "DDL"
+ name "Length"
+ value "")
+ (object Attribute
+ tool "DDL"
+ name "NullsOK"
+ value TRUE)
+ (object Attribute
+ tool "DDL"
+ name "PrimaryKey"
+ value FALSE)
+ (object Attribute
+ tool "DDL"
+ name "Unique"
+ value FALSE)
+ (object Attribute
+ tool "DDL"
+ name "CompositeUnique"
+ value FALSE)
+ (object Attribute
+ tool "DDL"
+ name "CheckConstraint"
+ value "")))
+ (object Attribute
+ tool "DDL"
+ name "HiddenTool"
+ value FALSE)
+ (object Attribute
+ tool "framework"
+ name "HiddenTool"
+ value FALSE)
+ (object Attribute
+ tool "IDL"
+ name "propertyId"
+ value "809135966")
+ (object Attribute
+ tool "IDL"
+ name "default__Project"
+ value (list Attribute_Set
+ (object Attribute
+ tool "IDL"
+ name "CreateMissingDirectories"
+ value TRUE)
+ (object Attribute
+ tool "IDL"
+ name "StopOnError"
+ value TRUE)
+ (object Attribute
+ tool "IDL"
+ name "Directory"
+ value "AUTO GENERATE")
+ (object Attribute
+ tool "IDL"
+ name "GeneratePreserveRegions"
+ value TRUE)))
+ (object Attribute
+ tool "IDL"
+ name "default__Class"
+ value (list Attribute_Set
+ (object Attribute
+ tool "IDL"
+ name "ImplementationType"
+ value "")
+ (object Attribute
+ tool "IDL"
+ name "ConstValue"
+ value "")
+ (object Attribute
+ tool "IDL"
+ name "GenerateDefaultSpecifier"
+ value FALSE)
+ (object Attribute
+ tool "IDL"
+ name "DefaultSpecifier"
+ value "")
+ (object Attribute
+ tool "IDL"
+ name "IDLElement"
+ value TRUE)
+ (object Attribute
+ tool "IDL"
+ name "IDLSpecificationType"
+ value ("IDLSpecSet" 22))
+ (object Attribute
+ tool "IDL"
+ name "IDLSpecSet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "IDL"
+ name "Interface"
+ value 22)
+ (object Attribute
+ tool "IDL"
+ name "Typedef"
+ value 54)
+ (object Attribute
+ tool "IDL"
+ name "Enumeration"
+ value 8)
+ (object Attribute
+ tool "IDL"
+ name "Const"
+ value 71)
+ (object Attribute
+ tool "IDL"
+ name "Exception"
+ value 61)
+ (object Attribute
+ tool "IDL"
+ name "Struct"
+ value 51)
+ (object Attribute
+ tool "IDL"
+ name "Union"
+ value 81)))))
+ (object Attribute
+ tool "IDL"
+ name "default__Module-Spec"
+ value (list Attribute_Set
+ (object Attribute
+ tool "IDL"
+ name "Generate"
+ value TRUE)
+ (object Attribute
+ tool "IDL"
+ name "CmIdentification"
+ value (value Text " %X% %Q% %Z% %W%"))
+ (object Attribute
+ tool "IDL"
+ name "CopyrightNotice"
+ value (value Text ""))
+ (object Attribute
+ tool "IDL"
+ name "FileName"
+ value "AUTO GENERATE")
+ (object Attribute
+ tool "IDL"
+ name "GenerateIDLModule"
+ value FALSE)
+ (object Attribute
+ tool "IDL"
+ name "InclusionProtectionSymbol"
+ value "AUTO GENERATE")
+ (object Attribute
+ tool "IDL"
+ name "AdditionalIncludes"
+ value (value Text ""))
+ (object Attribute
+ tool "IDL"
+ name "IncludeBySimpleName"
+ value FALSE)))
+ (object Attribute
+ tool "IDL"
+ name "default__Module-Body"
+ value (list Attribute_Set
+ (object Attribute
+ tool "IDL"
+ name "CmIdentification"
+ value (value Text " %X% %Q% %Z% %W%"))
+ (object Attribute
+ tool "IDL"
+ name "CopyrightNotice"
+ value (value Text ""))
+ (object Attribute
+ tool "IDL"
+ name "FileName"
+ value "AUTO GENERATE")
+ (object Attribute
+ tool "IDL"
+ name "AdditionalIncludes"
+ value (value Text ""))
+ (object Attribute
+ tool "IDL"
+ name "IncludeBySimpleName"
+ value FALSE)))
+ (object Attribute
+ tool "IDL"
+ name "default__Operation"
+ value (list Attribute_Set
+ (object Attribute
+ tool "IDL"
+ name "OperationIsOneWay"
+ value FALSE)
+ (object Attribute
+ tool "IDL"
+ name "Context"
+ value "")
+ (object Attribute
+ tool "IDL"
+ name "Raises"
+ value "")))
+ (object Attribute
+ tool "IDL"
+ name "default__Attribute"
+ value (list Attribute_Set
+ (object Attribute
+ tool "IDL"
+ name "CaseSpecifier"
+ value "")
+ (object Attribute
+ tool "IDL"
+ name "GenerateDataMember"
+ value TRUE)
+ (object Attribute
+ tool "IDL"
+ name "DataMemberName"
+ value "$relationship")
+ (object Attribute
+ tool "IDL"
+ name "IsReadOnly"
+ value FALSE)
+ (object Attribute
+ tool "IDL"
+ name "IsConst"
+ value FALSE)
+ (object Attribute
+ tool "IDL"
+ name "ConstValue"
+ value "")))
+ (object Attribute
+ tool "IDL"
+ name "default__Has"
+ value (list Attribute_Set
+ (object Attribute
+ tool "IDL"
+ name "NameIfUnlabeled"
+ value "the_$supplier")
+ (object Attribute
+ tool "IDL"
+ name "GenerateDataMember"
+ value TRUE)
+ (object Attribute
+ tool "IDL"
+ name "DataMemberName"
+ value "$relationship")
+ (object Attribute
+ tool "IDL"
+ name "GenerateForwardReference"
+ value FALSE)
+ (object Attribute
+ tool "IDL"
+ name "IsReadOnly"
+ value FALSE)
+ (object Attribute
+ tool "IDL"
+ name "BoundedHasRelType"
+ value ("HasRelTypeSet" 47))
+ (object Attribute
+ tool "IDL"
+ name "HasRelTypeSet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "IDL"
+ name "Array"
+ value 24)
+ (object Attribute
+ tool "IDL"
+ name "Sequence"
+ value 47)))))
+ (object Attribute
+ tool "IDL"
+ name "default__Role"
+ value (list Attribute_Set
+ (object Attribute
+ tool "IDL"
+ name "NameIfUnlabeled"
+ value "the_$supplier")
+ (object Attribute
+ tool "IDL"
+ name "GenerateDataMember"
+ value TRUE)
+ (object Attribute
+ tool "IDL"
+ name "DataMemberName"
+ value "$relationship")
+ (object Attribute
+ tool "IDL"
+ name "GenerateForwardReference"
+ value FALSE)
+ (object Attribute
+ tool "IDL"
+ name "IsReadOnly"
+ value FALSE)
+ (object Attribute
+ tool "IDL"
+ name "BoundedRoleType"
+ value ("AssocTypeSet" 47))
+ (object Attribute
+ tool "IDL"
+ name "AssocTypeSet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "IDL"
+ name "Array"
+ value 24)
+ (object Attribute
+ tool "IDL"
+ name "Sequence"
+ value 47)))))
+ (object Attribute
+ tool "IDL"
+ name "default__Uses"
+ value (list Attribute_Set
+ (object Attribute
+ tool "IDL"
+ name "GenerateForwardReference"
+ value FALSE)))
+ (object Attribute
+ tool "IDL"
+ name "default__Subsystem"
+ value (list Attribute_Set
+ (object Attribute
+ tool "IDL"
+ name "Directory"
+ value "AUTO GENERATE")))
+ (object Attribute
+ tool "IDL"
+ name "HiddenTool"
+ value FALSE)
+ (object Attribute
+ tool "Java"
+ name "propertyId"
+ value "809135966")
+ (object Attribute
+ tool "Java"
+ name "default__Project"
+ value (list Attribute_Set
+ (object Attribute
+ tool "Java"
+ name "CreateMissingDirectories"
+ value TRUE)
+ (object Attribute
+ tool "Java"
+ name "StopOnError"
+ value FALSE)
+ (object Attribute
+ tool "Java"
+ name "Directory"
+ value "AUTO GENERATE")
+ (object Attribute
+ tool "Java"
+ name "UsePrefixes"
+ value FALSE)
+ (object Attribute
+ tool "Java"
+ name "InstanceVariablePrefix"
+ value "m_")
+ (object Attribute
+ tool "Java"
+ name "ClassVariablePrefix"
+ value "s_")
+ (object Attribute
+ tool "Java"
+ name "DefaultAttributeDataType"
+ value "int")
+ (object Attribute
+ tool "Java"
+ name "DefaultOperationReturnType"
+ value "void")))
+ (object Attribute
+ tool "Java"
+ name "default__Class"
+ value (list Attribute_Set
+ (object Attribute
+ tool "Java"
+ name "Final"
+ value FALSE)
+ (object Attribute
+ tool "Java"
+ name "GenerateDefaultConstructor"
+ value TRUE)
+ (object Attribute
+ tool "Java"
+ name "ConstructorIs"
+ value ("Ctor_Set" 62))
+ (object Attribute
+ tool "Java"
+ name "Ctor_Set"
+ value (list Attribute_Set
+ (object Attribute
+ tool "Java"
+ name "Public"
+ value 62)
+ (object Attribute
+ tool "Java"
+ name "Protected"
+ value 63)
+ (object Attribute
+ tool "Java"
+ name "Private"
+ value 64)))
+ (object Attribute
+ tool "Java"
+ name "GenerateFinalizer"
+ value FALSE)
+ (object Attribute
+ tool "Java"
+ name "GenerateStaticInitializer"
+ value FALSE)
+ (object Attribute
+ tool "Java"
+ name "GenerateInstanceInitializer"
+ value FALSE)))
+ (object Attribute
+ tool "Java"
+ name "default__Module-Spec"
+ value (list Attribute_Set
+ (object Attribute
+ tool "Java"
+ name "Generate"
+ value TRUE)
+ (object Attribute
+ tool "Java"
+ name "CmIdentification"
+ value (value Text ""))
+ (object Attribute
+ tool "Java"
+ name "CopyrightNotice"
+ value (value Text ""))
+ (object Attribute
+ tool "Java"
+ name "AdditionalImports"
+ value (value Text ""))))
+ (object Attribute
+ tool "Java"
+ name "default__Module-Body"
+ value (list Attribute_Set
+ (object Attribute
+ tool "Java"
+ name "Generate"
+ value TRUE)
+ (object Attribute
+ tool "Java"
+ name "CmIdentification"
+ value (value Text ""))
+ (object Attribute
+ tool "Java"
+ name "CopyrightNotice"
+ value (value Text ""))
+ (object Attribute
+ tool "Java"
+ name "AdditionalImports"
+ value (value Text ""))))
+ (object Attribute
+ tool "Java"
+ name "default__Operation"
+ value (list Attribute_Set
+ (object Attribute
+ tool "Java"
+ name "Abstract"
+ value FALSE)
+ (object Attribute
+ tool "Java"
+ name "Static"
+ value FALSE)
+ (object Attribute
+ tool "Java"
+ name "Final"
+ value FALSE)
+ (object Attribute
+ tool "Java"
+ name "Native"
+ value FALSE)
+ (object Attribute
+ tool "Java"
+ name "Synchronized"
+ value FALSE)))
+ (object Attribute
+ tool "Java"
+ name "default__Attribute"
+ value (list Attribute_Set
+ (object Attribute
+ tool "Java"
+ name "GenerateDataMember"
+ value TRUE)
+ (object Attribute
+ tool "Java"
+ name "Final"
+ value FALSE)
+ (object Attribute
+ tool "Java"
+ name "Transient"
+ value FALSE)
+ (object Attribute
+ tool "Java"
+ name "Volatile"
+ value FALSE)))
+ (object Attribute
+ tool "Java"
+ name "default__Role"
+ value (list Attribute_Set
+ (object Attribute
+ tool "Java"
+ name "GenerateDataMember"
+ value TRUE)
+ (object Attribute
+ tool "Java"
+ name "ContainerClass"
+ value "")
+ (object Attribute
+ tool "Java"
+ name "InitialValue"
+ value "")
+ (object Attribute
+ tool "Java"
+ name "Final"
+ value FALSE)
+ (object Attribute
+ tool "Java"
+ name "Transient"
+ value FALSE)
+ (object Attribute
+ tool "Java"
+ name "Volatile"
+ value FALSE)))
+ (object Attribute
+ tool "Java"
+ name "HiddenTool"
+ value FALSE)
+ (object Attribute
+ tool "Oracle8"
+ name "propertyId"
+ value "360000002")
+ (object Attribute
+ tool "Oracle8"
+ name "default__Project"
+ value (list Attribute_Set
+ (object Attribute
+ tool "Oracle8"
+ name "DDLScriptFilename"
+ value "DDL1.SQL")
+ (object Attribute
+ tool "Oracle8"
+ name "DropClause"
+ value FALSE)
+ (object Attribute
+ tool "Oracle8"
+ name "PrimaryKeyColumnName"
+ value "_ID")
+ (object Attribute
+ tool "Oracle8"
+ name "PrimaryKeyColumnType"
+ value "NUMBER(5,0)")
+ (object Attribute
+ tool "Oracle8"
+ name "SchemaNamePrefix"
+ value "")
+ (object Attribute
+ tool "Oracle8"
+ name "SchemaNameSuffix"
+ value "")
+ (object Attribute
+ tool "Oracle8"
+ name "TableNamePrefix"
+ value "")
+ (object Attribute
+ tool "Oracle8"
+ name "TableNameSuffix"
+ value "")
+ (object Attribute
+ tool "Oracle8"
+ name "TypeNamePrefix"
+ value "")
+ (object Attribute
+ tool "Oracle8"
+ name "TypeNameSuffix"
+ value "")
+ (object Attribute
+ tool "Oracle8"
+ name "ViewNamePrefix"
+ value "")
+ (object Attribute
+ tool "Oracle8"
+ name "ViewNameSuffix"
+ value "")
+ (object Attribute
+ tool "Oracle8"
+ name "VarrayNamePrefix"
+ value "")
+ (object Attribute
+ tool "Oracle8"
+ name "VarrayNameSuffix"
+ value "")
+ (object Attribute
+ tool "Oracle8"
+ name "NestedTableNamePrefix"
+ value "")
+ (object Attribute
+ tool "Oracle8"
+ name "NestedTableNameSuffix"
+ value "")
+ (object Attribute
+ tool "Oracle8"
+ name "ObjectTableNamePrefix"
+ value "")
+ (object Attribute
+ tool "Oracle8"
+ name "ObjectTableNameSuffix"
+ value "")))
+ (object Attribute
+ tool "Oracle8"
+ name "default__Module-Spec"
+ value (list Attribute_Set
+ (object Attribute
+ tool "Oracle8"
+ name "IsSchema"
+ value FALSE)))
+ (object Attribute
+ tool "Oracle8"
+ name "default__Class"
+ value (list Attribute_Set
+ (object Attribute
+ tool "Oracle8"
+ name "OID"
+ value "")
+ (object Attribute
+ tool "Oracle8"
+ name "WhereClause"
+ value "")
+ (object Attribute
+ tool "Oracle8"
+ name "CheckConstraint"
+ value "")
+ (object Attribute
+ tool "Oracle8"
+ name "CollectionTypeLength"
+ value "")
+ (object Attribute
+ tool "Oracle8"
+ name "CollectionTypePrecision"
+ value "")
+ (object Attribute
+ tool "Oracle8"
+ name "CollectionTypeScale"
+ value "")
+ (object Attribute
+ tool "Oracle8"
+ name "CollectionOfREFS"
+ value FALSE)))
+ (object Attribute
+ tool "Oracle8"
+ name "default__Operation"
+ value (list Attribute_Set
+ (object Attribute
+ tool "Oracle8"
+ name "MethodKind"
+ value ("MethodKindSet" 1903))
+ (object Attribute
+ tool "Oracle8"
+ name "OverloadID"
+ value "")
+ (object Attribute
+ tool "Oracle8"
+ name "OrderNumber"
+ value "")
+ (object Attribute
+ tool "Oracle8"
+ name "IsReadNoDataState"
+ value FALSE)
+ (object Attribute
+ tool "Oracle8"
+ name "IsReadNoProcessState"
+ value FALSE)
+ (object Attribute
+ tool "Oracle8"
+ name "IsWriteNoDataState"
+ value FALSE)
+ (object Attribute
+ tool "Oracle8"
+ name "IsWriteNoProcessState"
+ value FALSE)
+ (object Attribute
+ tool "Oracle8"
+ name "IsSelfish"
+ value FALSE)
+ (object Attribute
+ tool "Oracle8"
+ name "TriggerType"
+ value ("TriggerTypeSet" 1801))
+ (object Attribute
+ tool "Oracle8"
+ name "TriggerEvent"
+ value ("TriggerEventSet" 1601))
+ (object Attribute
+ tool "Oracle8"
+ name "TriggerText"
+ value "")
+ (object Attribute
+ tool "Oracle8"
+ name "TriggerReferencingNames"
+ value "")
+ (object Attribute
+ tool "Oracle8"
+ name "TriggerForEach"
+ value ("TriggerForEachSet" 1701))
+ (object Attribute
+ tool "Oracle8"
+ name "TriggerWhenClause"
+ value "")
+ (object Attribute
+ tool "Oracle8"
+ name "MethodKindSet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "Oracle8"
+ name "MapMethod"
+ value 1901)
+ (object Attribute
+ tool "Oracle8"
+ name "OrderMethod"
+ value 1902)
+ (object Attribute
+ tool "Oracle8"
+ name "Function"
+ value 1903)
+ (object Attribute
+ tool "Oracle8"
+ name "Procedure"
+ value 1904)
+ (object Attribute
+ tool "Oracle8"
+ name "Operator"
+ value 1905)
+ (object Attribute
+ tool "Oracle8"
+ name "Constructor"
+ value 1906)
+ (object Attribute
+ tool "Oracle8"
+ name "Destructor"
+ value 1907)
+ (object Attribute
+ tool "Oracle8"
+ name "Trigger"
+ value 1908)
+ (object Attribute
+ tool "Oracle8"
+ name "Calculated"
+ value 1909)))
+ (object Attribute
+ tool "Oracle8"
+ name "TriggerTypeSet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "Oracle8"
+ name "AFTER"
+ value 1801)
+ (object Attribute
+ tool "Oracle8"
+ name "BEFORE"
+ value 1802)
+ (object Attribute
+ tool "Oracle8"
+ name "INSTEAD OF"
+ value 1803)))
+ (object Attribute
+ tool "Oracle8"
+ name "TriggerForEachSet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "Oracle8"
+ name "ROW"
+ value 1701)
+ (object Attribute
+ tool "Oracle8"
+ name "STATEMENT"
+ value 1702)))
+ (object Attribute
+ tool "Oracle8"
+ name "TriggerEventSet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "Oracle8"
+ name "INSERT"
+ value 1601)
+ (object Attribute
+ tool "Oracle8"
+ name "UPDATE"
+ value 1602)
+ (object Attribute
+ tool "Oracle8"
+ name "DELETE"
+ value 1603)
+ (object Attribute
+ tool "Oracle8"
+ name "INSERT OR UPDATE"
+ value 1604)
+ (object Attribute
+ tool "Oracle8"
+ name "INSERT OR DELETE"
+ value 1605)
+ (object Attribute
+ tool "Oracle8"
+ name "UPDATE OR DELETE"
+ value 1606)
+ (object Attribute
+ tool "Oracle8"
+ name "INSERT OR UPDATE OR DELETE"
+ value 1607)))))
+ (object Attribute
+ tool "Oracle8"
+ name "default__Role"
+ value (list Attribute_Set
+ (object Attribute
+ tool "Oracle8"
+ name "OrderNumber"
+ value "")))
+ (object Attribute
+ tool "Oracle8"
+ name "default__Attribute"
+ value (list Attribute_Set
+ (object Attribute
+ tool "Oracle8"
+ name "OrderNumber"
+ value "")
+ (object Attribute
+ tool "Oracle8"
+ name "IsUnique"
+ value FALSE)
+ (object Attribute
+ tool "Oracle8"
+ name "NullsAllowed"
+ value TRUE)
+ (object Attribute
+ tool "Oracle8"
+ name "Length"
+ value "")
+ (object Attribute
+ tool "Oracle8"
+ name "Precision"
+ value "2")
+ (object Attribute
+ tool "Oracle8"
+ name "Scale"
+ value "6")
+ (object Attribute
+ tool "Oracle8"
+ name "IsIndex"
+ value FALSE)
+ (object Attribute
+ tool "Oracle8"
+ name "IsPrimaryKey"
+ value FALSE)
+ (object Attribute
+ tool "Oracle8"
+ name "CompositeUnique"
+ value FALSE)
+ (object Attribute
+ tool "Oracle8"
+ name "CheckConstraint"
+ value "")))
+ (object Attribute
+ tool "Oracle8"
+ name "HiddenTool"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "propertyId"
+ value "809135966")
+ (object Attribute
+ tool "cg"
+ name "default__Project"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "UseMSVC"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "HeaderFileExtension"
+ value "h")
+ (object Attribute
+ tool "cg"
+ name "HeaderFileBackupExtension"
+ value "h~")
+ (object Attribute
+ tool "cg"
+ name "HeaderFileTemporaryExtension"
+ value "h#")
+ (object Attribute
+ tool "cg"
+ name "CodeFileExtension"
+ value "cpp")
+ (object Attribute
+ tool "cg"
+ name "CodeFileBackupExtension"
+ value "cp~")
+ (object Attribute
+ tool "cg"
+ name "CodeFileTemporaryExtension"
+ value "cp#")
+ (object Attribute
+ tool "cg"
+ name "CreateMissingDirectories"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "StopOnError"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "ErrorLimit"
+ value 30)
+ (object Attribute
+ tool "cg"
+ name "Directory"
+ value "$ROSECPP_SOURCE")
+ (object Attribute
+ tool "cg"
+ name "PathSeparator"
+ value "")
+ (object Attribute
+ tool "cg"
+ name "FileNameFormat"
+ value "128vx_b")
+ (object Attribute
+ tool "cg"
+ name "BooleanType"
+ value "int")
+ (object Attribute
+ tool "cg"
+ name "AllowTemplates"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "AllowExplicitInstantiations"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "AllowProtectedInheritance"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "CommentWidth"
+ value 60)
+ (object Attribute
+ tool "cg"
+ name "OneByValueContainer"
+ value "$targetClass")
+ (object Attribute
+ tool "cg"
+ name "OneByReferenceContainer"
+ value "$targetClass *")
+ (object Attribute
+ tool "cg"
+ name "OptionalByValueContainer"
+ value "OptionalByValue<$targetClass>")
+ (object Attribute
+ tool "cg"
+ name "OptionalByReferenceContainer"
+ value "$targetClass *")
+ (object Attribute
+ tool "cg"
+ name "FixedByValueContainer"
+ value "$targetClass[$limit]")
+ (object Attribute
+ tool "cg"
+ name "UnorderedFixedByValueContainer"
+ value "$targetClass[$limit]")
+ (object Attribute
+ tool "cg"
+ name "FixedByReferenceContainer"
+ value "$targetClass *[$limit]")
+ (object Attribute
+ tool "cg"
+ name "UnorderedFixedByReferenceContainer"
+ value "$targetClass *[$limit]")
+ (object Attribute
+ tool "cg"
+ name "BoundedByValueContainer"
+ value "BoundedListByValue<$targetClass,$limit>")
+ (object Attribute
+ tool "cg"
+ name "UnorderedBoundedByValueContainer"
+ value "BoundedSetByValue<$targetClass,$limit>")
+ (object Attribute
+ tool "cg"
+ name "BoundedByReferenceContainer"
+ value "BoundedListByReference<$targetClass,$limit>")
+ (object Attribute
+ tool "cg"
+ name "UnorderedBoundedByReferenceContainer"
+ value "BoundedSetByReference<$targetClass,$limit>")
+ (object Attribute
+ tool "cg"
+ name "UnboundedByValueContainer"
+ value "UnboundedListByValue<$targetClass>")
+ (object Attribute
+ tool "cg"
+ name "UnorderedUnboundedByValueContainer"
+ value "UnboundedSetByValue<$targetClass>")
+ (object Attribute
+ tool "cg"
+ name "UnboundedByReferenceContainer"
+ value "UnboundedListByReference<$targetClass>")
+ (object Attribute
+ tool "cg"
+ name "UnorderedUnboundedByReferenceContainer"
+ value "UnboundedSetByReference<$targetClass>")
+ (object Attribute
+ tool "cg"
+ name "QualifiedByValueContainer"
+ value "AssociationByValue<$qualtype, $qualcont>")
+ (object Attribute
+ tool "cg"
+ name "UnorderedQualifiedByValueContainer"
+ value "DictionaryByValue<$qualtype, $qualcont>")
+ (object Attribute
+ tool "cg"
+ name "QualifiedByReferenceContainer"
+ value "AssociationByReference<$qualtype, $qualcont>")
+ (object Attribute
+ tool "cg"
+ name "UnorderedQualifiedByReferenceContainer"
+ value "DictionaryByReference<$qualtype, $qualcont>")
+ (object Attribute
+ tool "cg"
+ name "GeneratePreserveRegions"
+ value TRUE)))
+ (object Attribute
+ tool "cg"
+ name "default__Class"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "CodeName"
+ value "")
+ (object Attribute
+ tool "cg"
+ name "ImplementationType"
+ value "")
+ (object Attribute
+ tool "cg"
+ name "ClassKey"
+ value "class")
+ (object Attribute
+ tool "cg"
+ name "GenerateEmptyRegions"
+ value ("GenerateEmptyRegionSet" 3))
+ (object Attribute
+ tool "cg"
+ name "GenerateEmptyRegionSet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "None"
+ value 0)
+ (object Attribute
+ tool "cg"
+ name "Preserved"
+ value 1)
+ (object Attribute
+ tool "cg"
+ name "Unpreserved"
+ value 2)
+ (object Attribute
+ tool "cg"
+ name "All"
+ value 3)))
+ (object Attribute
+ tool "cg"
+ name "PutBodiesInSpec"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "GenerateDefaultConstructor"
+ value ("GenerateSet" 199))
+ (object Attribute
+ tool "cg"
+ name "DefaultConstructorVisibility"
+ value ("VisibilitySet" 45))
+ (object Attribute
+ tool "cg"
+ name "InlineDefaultConstructor"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "ExplicitDefaultConstructor"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "GenerateCopyConstructor"
+ value ("GenerateSet" 199))
+ (object Attribute
+ tool "cg"
+ name "CopyConstructorVisibility"
+ value ("VisibilitySet" 45))
+ (object Attribute
+ tool "cg"
+ name "InlineCopyConstructor"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "ExplicitCopyConstructor"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "GenerateDestructor"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "DestructorVisibility"
+ value ("VisibilitySet" 45))
+ (object Attribute
+ tool "cg"
+ name "DestructorKind"
+ value ("ThreeKindSet" 200))
+ (object Attribute
+ tool "cg"
+ name "InlineDestructor"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "GenerateAssignmentOperation"
+ value ("GenerateSet" 199))
+ (object Attribute
+ tool "cg"
+ name "AssignmentVisibility"
+ value ("VisibilitySet" 45))
+ (object Attribute
+ tool "cg"
+ name "AssignmentKind"
+ value ("ThreeKindSet" 200))
+ (object Attribute
+ tool "cg"
+ name "InlineAssignmentOperation"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "GenerateEqualityOperations"
+ value ("GenerateSet" 199))
+ (object Attribute
+ tool "cg"
+ name "EqualityVisibility"
+ value ("VisibilitySet" 45))
+ (object Attribute
+ tool "cg"
+ name "EqualityKind"
+ value ("FriendKindSet" 200))
+ (object Attribute
+ tool "cg"
+ name "InlineEqualityOperations"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "GenerateRelationalOperations"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "RelationalVisibility"
+ value ("VisibilitySet" 45))
+ (object Attribute
+ tool "cg"
+ name "RelationalKind"
+ value ("FriendKindSet" 200))
+ (object Attribute
+ tool "cg"
+ name "InlineRelationalOperations"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "GenerateStorageMgmtOperations"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "StorageMgmtVisibility"
+ value ("VisibilitySet" 45))
+ (object Attribute
+ tool "cg"
+ name "InlineStorageMgmtOperations"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "GenerateSubscriptOperation"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "SubscriptVisibility"
+ value ("VisibilitySet" 45))
+ (object Attribute
+ tool "cg"
+ name "SubscriptKind"
+ value ("ThreeKindSet" 200))
+ (object Attribute
+ tool "cg"
+ name "SubscriptResultType"
+ value "")
+ (object Attribute
+ tool "cg"
+ name "InlineSubscriptOperation"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "GenerateDereferenceOperation"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "DereferenceVisibility"
+ value ("VisibilitySet" 45))
+ (object Attribute
+ tool "cg"
+ name "DereferenceKind"
+ value ("ThreeKindSet" 200))
+ (object Attribute
+ tool "cg"
+ name "DereferenceResultType"
+ value "")
+ (object Attribute
+ tool "cg"
+ name "InlineDereferenceOperation"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "GenerateIndirectionOperation"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "IndirectionVisibility"
+ value ("VisibilitySet" 45))
+ (object Attribute
+ tool "cg"
+ name "IndirectionKind"
+ value ("ThreeKindSet" 200))
+ (object Attribute
+ tool "cg"
+ name "IndirectionResultType"
+ value "")
+ (object Attribute
+ tool "cg"
+ name "InlineIndirectionOperation"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "GenerateStreamOperations"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "StreamVisibility"
+ value ("VisibilitySet" 45))
+ (object Attribute
+ tool "cg"
+ name "InlineStreamOperations"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "ThreeKindSet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "Common"
+ value 200)
+ (object Attribute
+ tool "cg"
+ name "Virtual"
+ value 201)
+ (object Attribute
+ tool "cg"
+ name "Abstract"
+ value 202)))
+ (object Attribute
+ tool "cg"
+ name "KindSet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "Common"
+ value 200)
+ (object Attribute
+ tool "cg"
+ name "Virtual"
+ value 201)
+ (object Attribute
+ tool "cg"
+ name "Abstract"
+ value 202)
+ (object Attribute
+ tool "cg"
+ name "Static"
+ value 203)))
+ (object Attribute
+ tool "cg"
+ name "FriendKindSet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "Common"
+ value 200)
+ (object Attribute
+ tool "cg"
+ name "Virtual"
+ value 201)
+ (object Attribute
+ tool "cg"
+ name "Abstract"
+ value 202)
+ (object Attribute
+ tool "cg"
+ name "Friend"
+ value 204)))
+ (object Attribute
+ tool "cg"
+ name "GenerateSet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "DeclareAndDefine"
+ value 199)
+ (object Attribute
+ tool "cg"
+ name "DeclareOnly"
+ value 205)
+ (object Attribute
+ tool "cg"
+ name "DoNotDeclare"
+ value 206)))
+ (object Attribute
+ tool "cg"
+ name "VisibilitySet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "Public"
+ value 45)
+ (object Attribute
+ tool "cg"
+ name "Protected"
+ value 44)
+ (object Attribute
+ tool "cg"
+ name "Private"
+ value 43)
+ (object Attribute
+ tool "cg"
+ name "Implementation"
+ value 14)))
+ (object Attribute
+ tool "cg"
+ name "ConstValue"
+ value "")
+ (object Attribute
+ tool "cg"
+ name "GenerateDefaultSpecifier"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "DefaultSpecifier"
+ value "")))
+ (object Attribute
+ tool "cg"
+ name "default__Module-Spec"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "Generate"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "GenerateEmptyRegions"
+ value ("GenerateEmptyRegionSet" 3))
+ (object Attribute
+ tool "cg"
+ name "GenerateEmptyRegionSet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "None"
+ value 0)
+ (object Attribute
+ tool "cg"
+ name "Preserved"
+ value 1)
+ (object Attribute
+ tool "cg"
+ name "Unpreserved"
+ value 2)
+ (object Attribute
+ tool "cg"
+ name "All"
+ value 3)))
+ (object Attribute
+ tool "cg"
+ name "CmIdentification"
+ value (value Text " %X% %Q% %Z% %W%"))
+ (object Attribute
+ tool "cg"
+ name "CopyrightNotice"
+ value (value Text ""))
+ (object Attribute
+ tool "cg"
+ name "FileName"
+ value "AUTO GENERATE")
+ (object Attribute
+ tool "cg"
+ name "AllowExtensionlessFileName"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "InclusionProtectionSymbol"
+ value "AUTO GENERATE")
+ (object Attribute
+ tool "cg"
+ name "IncludeFormat"
+ value (value Text
+|// $package
+|#include "$file"
+|
+ ))
+ (object Attribute
+ tool "cg"
+ name "IncludeBySimpleName"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "IncludePrecompiledHeader"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "IncludeOrder"
+ value "AMIR")
+ (object Attribute
+ tool "cg"
+ name "AdditionalIncludes"
+ value (value Text ""))
+ (object Attribute
+ tool "cg"
+ name "InliningStyle"
+ value ("InliningStyleSet" 207))
+ (object Attribute
+ tool "cg"
+ name "InliningStyleSet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "InClassDeclaration"
+ value 208)
+ (object Attribute
+ tool "cg"
+ name "FollowingClassDeclaration"
+ value 207)))
+ (object Attribute
+ tool "cg"
+ name "TypesDefined"
+ value (value Text ""))
+ (object Attribute
+ tool "cg"
+ name "IncludeClosure"
+ value (value Text ""))))
+ (object Attribute
+ tool "cg"
+ name "default__Module-Body"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "Generate"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "GenerateEmptyRegions"
+ value ("GenerateEmptyRegionSet" 3))
+ (object Attribute
+ tool "cg"
+ name "GenerateEmptyRegionSet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "None"
+ value 0)
+ (object Attribute
+ tool "cg"
+ name "Preserved"
+ value 1)
+ (object Attribute
+ tool "cg"
+ name "Unpreserved"
+ value 2)
+ (object Attribute
+ tool "cg"
+ name "All"
+ value 3)))
+ (object Attribute
+ tool "cg"
+ name "CmIdentification"
+ value (value Text " %X% %Q% %Z% %W%"))
+ (object Attribute
+ tool "cg"
+ name "CopyrightNotice"
+ value (value Text ""))
+ (object Attribute
+ tool "cg"
+ name "FileName"
+ value "AUTO GENERATE")
+ (object Attribute
+ tool "cg"
+ name "AllowExtensionlessFileName"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "IncludeFormat"
+ value (value Text
+|// $package
+|#include "$file"
+|
+ ))
+ (object Attribute
+ tool "cg"
+ name "IncludeBySimpleName"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "IncludePrecompiledHeader"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "IncludeOrder"
+ value "AMIR")
+ (object Attribute
+ tool "cg"
+ name "AdditionalIncludes"
+ value (value Text ""))
+ (object Attribute
+ tool "cg"
+ name "InliningStyle"
+ value ("InliningStyleSet" 207))
+ (object Attribute
+ tool "cg"
+ name "InliningStyleSet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "InClassDeclaration"
+ value 208)
+ (object Attribute
+ tool "cg"
+ name "FollowingClassDeclaration"
+ value 207)))
+ (object Attribute
+ tool "cg"
+ name "TypesDefined"
+ value (value Text ""))
+ (object Attribute
+ tool "cg"
+ name "IncludeClosure"
+ value (value Text ""))))
+ (object Attribute
+ tool "cg"
+ name "default__Operation"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "CodeName"
+ value "")
+ (object Attribute
+ tool "cg"
+ name "OperationKind"
+ value ("OperationKindSet" 200))
+ (object Attribute
+ tool "cg"
+ name "OperationKindSet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "Common"
+ value 200)
+ (object Attribute
+ tool "cg"
+ name "Virtual"
+ value 201)
+ (object Attribute
+ tool "cg"
+ name "Abstract"
+ value 202)
+ (object Attribute
+ tool "cg"
+ name "Static"
+ value 203)
+ (object Attribute
+ tool "cg"
+ name "Friend"
+ value 204)))
+ (object Attribute
+ tool "cg"
+ name "OperationIsConst"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "OperationIsExplicit"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "Inline"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "EntryCode"
+ value (value Text ""))
+ (object Attribute
+ tool "cg"
+ name "ExitCode"
+ value (value Text ""))
+ (object Attribute
+ tool "cg"
+ name "GenerateEmptyRegions"
+ value ("GenerateEmptyRegionSet" 3))
+ (object Attribute
+ tool "cg"
+ name "GenerateEmptyRegionSet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "None"
+ value 0)
+ (object Attribute
+ tool "cg"
+ name "Preserved"
+ value 1)
+ (object Attribute
+ tool "cg"
+ name "Unpreserved"
+ value 2)
+ (object Attribute
+ tool "cg"
+ name "All"
+ value 3)))
+ (object Attribute
+ tool "cg"
+ name "BodyAnnotations"
+ value "")
+ (object Attribute
+ tool "cg"
+ name "OperationIsOneWay"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "Context"
+ value "")
+ (object Attribute
+ tool "cg"
+ name "Raises"
+ value "")))
+ (object Attribute
+ tool "cg"
+ name "default__Has"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "CodeName"
+ value "")
+ (object Attribute
+ tool "cg"
+ name "Ordered"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "NameIfUnlabeled"
+ value "the_$supplier")
+ (object Attribute
+ tool "cg"
+ name "GenerateDataMember"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "DataMemberName"
+ value "$relationship")
+ (object Attribute
+ tool "cg"
+ name "DataMemberVisibility"
+ value ("DataMemberVisibilitySet" 14))
+ (object Attribute
+ tool "cg"
+ name "DataMemberVisibilitySet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "Public"
+ value 45)
+ (object Attribute
+ tool "cg"
+ name "Protected"
+ value 44)
+ (object Attribute
+ tool "cg"
+ name "Private"
+ value 43)
+ (object Attribute
+ tool "cg"
+ name "Implementation"
+ value 14)
+ (object Attribute
+ tool "cg"
+ name "AtRelationshipVisibility"
+ value 210)))
+ (object Attribute
+ tool "cg"
+ name "DataMemberMutability"
+ value ("DataMemberMutabilitySet" 0))
+ (object Attribute
+ tool "cg"
+ name "DataMemberMutabilitySet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "Unrestricted"
+ value 0)
+ (object Attribute
+ tool "cg"
+ name "Mutable"
+ value 1)
+ (object Attribute
+ tool "cg"
+ name "Const"
+ value 2)))
+ (object Attribute
+ tool "cg"
+ name "DataMemberIsVolatile"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "DataMemberFieldSize"
+ value "")
+ (object Attribute
+ tool "cg"
+ name "InitialValue"
+ value (value Text ""))
+ (object Attribute
+ tool "cg"
+ name "GenerateGetOperation"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "GenerateSetOperation"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "GetName"
+ value "get_$relationship")
+ (object Attribute
+ tool "cg"
+ name "SetName"
+ value "set_$relationship")
+ (object Attribute
+ tool "cg"
+ name "GetSetKinds"
+ value ("GetSetKindsSet" 200))
+ (object Attribute
+ tool "cg"
+ name "GetSetKindsSet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "Common"
+ value 200)
+ (object Attribute
+ tool "cg"
+ name "Virtual"
+ value 201)
+ (object Attribute
+ tool "cg"
+ name "Abstract"
+ value 202)
+ (object Attribute
+ tool "cg"
+ name "Static"
+ value 203)
+ (object Attribute
+ tool "cg"
+ name "Friend"
+ value 204)))
+ (object Attribute
+ tool "cg"
+ name "ContainerClass"
+ value "")
+ (object Attribute
+ tool "cg"
+ name "SelectorName"
+ value "")
+ (object Attribute
+ tool "cg"
+ name "SelectorType"
+ value "")
+ (object Attribute
+ tool "cg"
+ name "GetIsConst"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "GetResultIsConst"
+ value ("GetResultIsConstSet" 2))
+ (object Attribute
+ tool "cg"
+ name "GetResultIsConstSet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "False"
+ value 0)
+ (object Attribute
+ tool "cg"
+ name "True"
+ value 1)
+ (object Attribute
+ tool "cg"
+ name "Same_As_Function"
+ value 2)))
+ (object Attribute
+ tool "cg"
+ name "GetSetByReference"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "InlineGet"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "SetReturnsValue"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "InlineSet"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "ForwardReferenceOnly"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "GenerateForwardReference"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "IsReadOnly"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "BoundedHasRelType"
+ value ("HasRelTypeSet" 47))
+ (object Attribute
+ tool "cg"
+ name "HasRelTypeSet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "Array"
+ value 24)
+ (object Attribute
+ tool "cg"
+ name "Sequence"
+ value 47)))))
+ (object Attribute
+ tool "cg"
+ name "default__Association"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "NameIfUnlabeled"
+ value "the_$targetClass")))
+ (object Attribute
+ tool "cg"
+ name "default__Inherit"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "InstanceArguments"
+ value "")))
+ (object Attribute
+ tool "cg"
+ name "default__Role"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "CodeName"
+ value "")
+ (object Attribute
+ tool "cg"
+ name "ForwardReferenceOnly"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "NameIfUnlabeled"
+ value "the_$targetClass")
+ (object Attribute
+ tool "cg"
+ name "GenerateDataMember"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "DataMemberName"
+ value "$target")
+ (object Attribute
+ tool "cg"
+ name "DataMemberVisibility"
+ value ("DataMemberVisibilitySet" 14))
+ (object Attribute
+ tool "cg"
+ name "DataMemberVisibilitySet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "Public"
+ value 45)
+ (object Attribute
+ tool "cg"
+ name "Protected"
+ value 44)
+ (object Attribute
+ tool "cg"
+ name "Private"
+ value 43)
+ (object Attribute
+ tool "cg"
+ name "Implementation"
+ value 14)
+ (object Attribute
+ tool "cg"
+ name "AtRelationshipVisibility"
+ value 210)))
+ (object Attribute
+ tool "cg"
+ name "DataMemberMutability"
+ value ("DataMemberMutabilitySet" 0))
+ (object Attribute
+ tool "cg"
+ name "DataMemberMutabilitySet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "Unrestricted"
+ value 0)
+ (object Attribute
+ tool "cg"
+ name "Mutable"
+ value 1)
+ (object Attribute
+ tool "cg"
+ name "Const"
+ value 2)))
+ (object Attribute
+ tool "cg"
+ name "DataMemberIsVolatile"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "DataMemberFieldSize"
+ value "")
+ (object Attribute
+ tool "cg"
+ name "InitialValue"
+ value (value Text ""))
+ (object Attribute
+ tool "cg"
+ name "ContainerClass"
+ value "")
+ (object Attribute
+ tool "cg"
+ name "ContainerGet"
+ value "$data.get($keys)")
+ (object Attribute
+ tool "cg"
+ name "ContainerSet"
+ value "$data.set($keys,$value)")
+ (object Attribute
+ tool "cg"
+ name "QualifiedContainer"
+ value "")
+ (object Attribute
+ tool "cg"
+ name "AssocClassContainer"
+ value "$supplier *")
+ (object Attribute
+ tool "cg"
+ name "AssocClassInitialValue"
+ value (value Text ""))
+ (object Attribute
+ tool "cg"
+ name "GetSetKinds"
+ value ("GetSetKindsSet" 200))
+ (object Attribute
+ tool "cg"
+ name "GetSetKindsSet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "Common"
+ value 200)
+ (object Attribute
+ tool "cg"
+ name "Virtual"
+ value 201)
+ (object Attribute
+ tool "cg"
+ name "Abstract"
+ value 202)
+ (object Attribute
+ tool "cg"
+ name "Static"
+ value 203)
+ (object Attribute
+ tool "cg"
+ name "Friend"
+ value 204)))
+ (object Attribute
+ tool "cg"
+ name "GetSetByReference"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "GenerateGetOperation"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "GetName"
+ value "get_$target")
+ (object Attribute
+ tool "cg"
+ name "GetIsConst"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "GetResultIsConst"
+ value ("GetResultIsConstSet" 2))
+ (object Attribute
+ tool "cg"
+ name "GetResultIsConstSet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "False"
+ value 0)
+ (object Attribute
+ tool "cg"
+ name "True"
+ value 1)
+ (object Attribute
+ tool "cg"
+ name "Same_As_Function"
+ value 2)))
+ (object Attribute
+ tool "cg"
+ name "InlineGet"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "GenerateSetOperation"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "SetName"
+ value "set_$target")
+ (object Attribute
+ tool "cg"
+ name "SetReturnsValue"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "InlineSet"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "QualifiedGetSetByReference"
+ value ("QualifiedGetSetByReferenceSet" 2))
+ (object Attribute
+ tool "cg"
+ name "QualifiedGetSetByReferenceSet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "False"
+ value 0)
+ (object Attribute
+ tool "cg"
+ name "True"
+ value 1)
+ (object Attribute
+ tool "cg"
+ name "Same_As_GetSetByReference"
+ value 2)))
+ (object Attribute
+ tool "cg"
+ name "GenerateQualifiedGetOperation"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "QualifiedGetName"
+ value "get_$target")
+ (object Attribute
+ tool "cg"
+ name "QualifiedGetIsConst"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "QualifiedGetResultIsConst"
+ value ("GetResultIsConstSet" 2))
+ (object Attribute
+ tool "cg"
+ name "InlineQualifiedGet"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "GenerateQualifiedSetOperation"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "QualifiedSetName"
+ value "set_$target")
+ (object Attribute
+ tool "cg"
+ name "QualifiedSetReturnsValue"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "InlineQualifiedSet"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "GenerateAssocClassDataMember"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "AssocClassDataMemberName"
+ value "$target")
+ (object Attribute
+ tool "cg"
+ name "AssocClassDataMemberVisibility"
+ value ("DataMemberVisibilitySet" 14))
+ (object Attribute
+ tool "cg"
+ name "DataMemberVisibilitySet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "Public"
+ value 45)
+ (object Attribute
+ tool "cg"
+ name "Protected"
+ value 44)
+ (object Attribute
+ tool "cg"
+ name "Private"
+ value 43)
+ (object Attribute
+ tool "cg"
+ name "Implementation"
+ value 14)
+ (object Attribute
+ tool "cg"
+ name "AtRelationshipVisibility"
+ value 210)))
+ (object Attribute
+ tool "cg"
+ name "AssocClassDataMemberMutability"
+ value ("DataMemberMutabilitySet" 0))
+ (object Attribute
+ tool "cg"
+ name "DataMemberMutabilitySet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "Unrestricted"
+ value 0)
+ (object Attribute
+ tool "cg"
+ name "Mutable"
+ value 1)
+ (object Attribute
+ tool "cg"
+ name "Const"
+ value 2)))
+ (object Attribute
+ tool "cg"
+ name "AssocClassDataMemberIsVolatile"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "AssocClassGetSetKinds"
+ value ("GetSetKindsSet" 200))
+ (object Attribute
+ tool "cg"
+ name "GenerateAssocClassGetOperation"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "AssocClassGetName"
+ value "get_$target")
+ (object Attribute
+ tool "cg"
+ name "AssocClassGetIsConst"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "AssocClassGetResultIsConst"
+ value ("GetResultIsConstSet" 2))
+ (object Attribute
+ tool "cg"
+ name "InlineAssocClassGet"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "GenerateAssocClassSetOperation"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "AssocClassSetName"
+ value "set_$target")
+ (object Attribute
+ tool "cg"
+ name "AssocClassSetReturnsValue"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "InlineAssocClassSet"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "AssocClassForwardReferenceOnly"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "GenerateForwardReference"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "IsReadOnly"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "BoundedRoleType"
+ value ("AssocTypeSet" 47))
+ (object Attribute
+ tool "cg"
+ name "AssocTypeSet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "Array"
+ value 24)
+ (object Attribute
+ tool "cg"
+ name "Sequence"
+ value 47)))))
+ (object Attribute
+ tool "cg"
+ name "default__Attribute"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "CodeName"
+ value "")
+ (object Attribute
+ tool "cg"
+ name "GenerateDataMember"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "DataMemberName"
+ value "$attribute")
+ (object Attribute
+ tool "cg"
+ name "DataMemberVisibility"
+ value ("DataMemberVisibilitySet" 14))
+ (object Attribute
+ tool "cg"
+ name "DataMemberVisibilitySet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "Public"
+ value 45)
+ (object Attribute
+ tool "cg"
+ name "Protected"
+ value 44)
+ (object Attribute
+ tool "cg"
+ name "Private"
+ value 43)
+ (object Attribute
+ tool "cg"
+ name "Implementation"
+ value 14)
+ (object Attribute
+ tool "cg"
+ name "AtAttributeVisibility"
+ value 211)))
+ (object Attribute
+ tool "cg"
+ name "DataMemberMutability"
+ value ("DataMemberMutabilitySet" 0))
+ (object Attribute
+ tool "cg"
+ name "DataMemberMutabilitySet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "Unrestricted"
+ value 0)
+ (object Attribute
+ tool "cg"
+ name "Mutable"
+ value 1)
+ (object Attribute
+ tool "cg"
+ name "Const"
+ value 2)))
+ (object Attribute
+ tool "cg"
+ name "DataMemberIsVolatile"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "DataMemberFieldSize"
+ value "")
+ (object Attribute
+ tool "cg"
+ name "GenerateGetOperation"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "GenerateSetOperation"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "GetName"
+ value "get_$attribute")
+ (object Attribute
+ tool "cg"
+ name "SetName"
+ value "set_$attribute")
+ (object Attribute
+ tool "cg"
+ name "GetSetKinds"
+ value ("GetSetKindsSet" 200))
+ (object Attribute
+ tool "cg"
+ name "GetSetKindsSet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "Common"
+ value 200)
+ (object Attribute
+ tool "cg"
+ name "Virtual"
+ value 201)
+ (object Attribute
+ tool "cg"
+ name "Abstract"
+ value 202)
+ (object Attribute
+ tool "cg"
+ name "Static"
+ value 203)
+ (object Attribute
+ tool "cg"
+ name "Friend"
+ value 204)))
+ (object Attribute
+ tool "cg"
+ name "GetIsConst"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "GetResultIsConst"
+ value ("GetResultIsConstSet" 2))
+ (object Attribute
+ tool "cg"
+ name "GetResultIsConstSet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "False"
+ value 0)
+ (object Attribute
+ tool "cg"
+ name "True"
+ value 1)
+ (object Attribute
+ tool "cg"
+ name "Same_As_Function"
+ value 2)))
+ (object Attribute
+ tool "cg"
+ name "GetSetByReference"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "InlineGet"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "SetReturnsValue"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "InlineSet"
+ value TRUE)
+ (object Attribute
+ tool "cg"
+ name "CaseSpecifier"
+ value "")
+ (object Attribute
+ tool "cg"
+ name "IsReadOnly"
+ value FALSE)))
+ (object Attribute
+ tool "cg"
+ name "default__Uses"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "ForwardReferenceOnly"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "BodyReferenceOnly"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "GenerateForwardReference"
+ value FALSE)))
+ (object Attribute
+ tool "cg"
+ name "default__Subsystem"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "Directory"
+ value "AUTO GENERATE")
+ (object Attribute
+ tool "cg"
+ name "DirectoryIsOnSearchList"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "PrecompiledHeader"
+ value "")))
+ (object Attribute
+ tool "cg"
+ name "default__Category"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "IsNamespace"
+ value FALSE)
+ (object Attribute
+ tool "cg"
+ name "Indent"
+ value 2)
+ (object Attribute
+ tool "cg"
+ name "CodeName"
+ value "")
+ (object Attribute
+ tool "cg"
+ name "GenerateEmptyRegions"
+ value ("GenerateEmptyRegionSet" 3))
+ (object Attribute
+ tool "cg"
+ name "GenerateEmptyRegionSet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "cg"
+ name "None"
+ value 0)
+ (object Attribute
+ tool "cg"
+ name "Preserved"
+ value 1)
+ (object Attribute
+ tool "cg"
+ name "Unpreserved"
+ value 2)
+ (object Attribute
+ tool "cg"
+ name "All"
+ value 3)))))
+ (object Attribute
+ tool "MSVC"
+ name "propertyId"
+ value "809135966")
+ (object Attribute
+ tool "MSVC"
+ name "default__Project"
+ value (list Attribute_Set
+ (object Attribute
+ tool "MSVC"
+ name "Version"
+ value "5.0")))
+ (object Attribute
+ tool "MSVC"
+ name "default__Class"
+ value (list Attribute_Set
+ (object Attribute
+ tool "MSVC"
+ name "Type"
+ value ("MSVCClassTypeSet" 0))
+ (object Attribute
+ tool "MSVC"
+ name "MSVCClassTypeSet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "MSVC"
+ name "Normal"
+ value 0)
+ (object Attribute
+ tool "MSVC"
+ name "Interface_Part"
+ value 1)
+ (object Attribute
+ tool "MSVC"
+ name "Connection_Part"
+ value 2)
+ (object Attribute
+ tool "MSVC"
+ name "Class_Factory"
+ value 3)))
+ (object Attribute
+ tool "MSVC"
+ name "CObjectFunctionality"
+ value ("CObjectFunctionalitySet" 0))
+ (object Attribute
+ tool "MSVC"
+ name "CObjectFunctionalitySet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "MSVC"
+ name "None"
+ value 0)
+ (object Attribute
+ tool "MSVC"
+ name "Dynamic"
+ value 1)
+ (object Attribute
+ tool "MSVC"
+ name "Dyncreate"
+ value 2)
+ (object Attribute
+ tool "MSVC"
+ name "Serial"
+ value 3)))
+ (object Attribute
+ tool "MSVC"
+ name "GenerateOverrideGroup"
+ value FALSE)
+ (object Attribute
+ tool "MSVC"
+ name "GenerateDataGroup"
+ value FALSE)
+ (object Attribute
+ tool "MSVC"
+ name "AFX_DATA_Entries"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "GenerateFieldGroup"
+ value FALSE)
+ (object Attribute
+ tool "MSVC"
+ name "AFX_FIELD_Entries"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "GenerateMessageGroup"
+ value FALSE)
+ (object Attribute
+ tool "MSVC"
+ name "GenerateMessageMap"
+ value FALSE)
+ (object Attribute
+ tool "MSVC"
+ name "AFX_MSG_MAP_Entries"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "MESSAGE_MAP_Entries"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "OLEFactory"
+ value ("OLEFactorySet" 0))
+ (object Attribute
+ tool "MSVC"
+ name "OLEFactorySet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "MSVC"
+ name "None"
+ value 0)
+ (object Attribute
+ tool "MSVC"
+ name "Built_in"
+ value 1)
+ (object Attribute
+ tool "MSVC"
+ name "Simple"
+ value 2)
+ (object Attribute
+ tool "MSVC"
+ name "Licensed"
+ value 3)))
+ (object Attribute
+ tool "MSVC"
+ name "OLEName"
+ value "")
+ (object Attribute
+ tool "MSVC"
+ name "OLEClassID"
+ value "")
+ (object Attribute
+ tool "MSVC"
+ name "GenerateOLECtlType"
+ value FALSE)
+ (object Attribute
+ tool "MSVC"
+ name "OLECtlType"
+ value "")
+ (object Attribute
+ tool "MSVC"
+ name "GenerateOLETypeLib"
+ value FALSE)
+ (object Attribute
+ tool "MSVC"
+ name "OLETypeLibID"
+ value "")
+ (object Attribute
+ tool "MSVC"
+ name "OLETypeLibMajor"
+ value "")
+ (object Attribute
+ tool "MSVC"
+ name "OLETypeLibMinor"
+ value "")
+ (object Attribute
+ tool "MSVC"
+ name "GeneratePropPageIDs"
+ value FALSE)
+ (object Attribute
+ tool "MSVC"
+ name "OLEPropPageIDs"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "GenerateDispatchMap"
+ value FALSE)
+ (object Attribute
+ tool "MSVC"
+ name "AFX_DISPATCH_Entries"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "AFX_DISPATCH_MAP_Entries"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "DISPATCH_MAP_Entries"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "StockProperties"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "StockFunctions"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "DispatchDefValue"
+ value "")
+ (object Attribute
+ tool "MSVC"
+ name "GenerateDispIdEnum"
+ value FALSE)
+ (object Attribute
+ tool "MSVC"
+ name "AFX_DISP_ID_Entries"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "GenerateInterfaceMap"
+ value FALSE)
+ (object Attribute
+ tool "MSVC"
+ name "INTERFACE_MAP_Entries"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "InitInterface"
+ value "")
+ (object Attribute
+ tool "MSVC"
+ name "GenerateEventMap"
+ value FALSE)
+ (object Attribute
+ tool "MSVC"
+ name "AFX_EVENT_Entries"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "AFX_EVENT_MAP_Entries"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "EVENT_MAP_Entries"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "StockEvents"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "GenerateEventSinkMap"
+ value FALSE)
+ (object Attribute
+ tool "MSVC"
+ name "AFX_EVENTSINK_Entries"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "AFX_EVENTSINK_MAP_Entries"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "EVENTSINK_MAP_Entries"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "PropNotifySinks"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "GenerateConnectionMap"
+ value FALSE)
+ (object Attribute
+ tool "MSVC"
+ name "CONNECTION_MAP_Entries"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "ConnectionPointIID"
+ value "")
+ (object Attribute
+ tool "MSVC"
+ name "InheritanceType"
+ value "")
+ (object Attribute
+ tool "MSVC"
+ name "DeclSpec"
+ value "")
+ (object Attribute
+ tool "MSVC"
+ name "OLECommands"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "MFCDeclares"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "MFCImplements"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "ATL_Declares"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "GenerateCOMMap"
+ value FALSE)
+ (object Attribute
+ tool "MSVC"
+ name "COM_MAP_Entries"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "GenerateConnectionPointMap"
+ value FALSE)
+ (object Attribute
+ tool "MSVC"
+ name "CONNECTION_POINT_MAP_Entries"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "GenerateMsgMap"
+ value FALSE)
+ (object Attribute
+ tool "MSVC"
+ name "MSG_MAP_Entries"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "GeneratePropertyMap"
+ value FALSE)
+ (object Attribute
+ tool "MSVC"
+ name "PROPERTY_MAP_Entries"
+ value (value Text ""))))
+ (object Attribute
+ tool "MSVC"
+ name "default__Operation"
+ value (list Attribute_Set
+ (object Attribute
+ tool "MSVC"
+ name "Type"
+ value ("MSVCOperationTypeSet" 0))
+ (object Attribute
+ tool "MSVC"
+ name "MSVCOperationTypeSet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "MSVC"
+ name "Normal"
+ value 0)
+ (object Attribute
+ tool "MSVC"
+ name "Virtual_Override"
+ value 1)
+ (object Attribute
+ tool "MSVC"
+ name "Message_Handler"
+ value 2)
+ (object Attribute
+ tool "MSVC"
+ name "Dispatch_Handler"
+ value 3)
+ (object Attribute
+ tool "MSVC"
+ name "Event_Firing_Function"
+ value 4)
+ (object Attribute
+ tool "MSVC"
+ name "Event_Sink_Handler"
+ value 5)
+ (object Attribute
+ tool "MSVC"
+ name "Std_OLE_Method"
+ value 6)
+ (object Attribute
+ tool "MSVC"
+ name "Command_Parser"
+ value 7)
+ (object Attribute
+ tool "MSVC"
+ name "Property_Get_Function"
+ value 8)
+ (object Attribute
+ tool "MSVC"
+ name "Property_Set_Function"
+ value 9)
+ (object Attribute
+ tool "MSVC"
+ name "Property_Notify_Function"
+ value 10)
+ (object Attribute
+ tool "MSVC"
+ name "Macro_Generated_Function"
+ value 11)))
+ (object Attribute
+ tool "MSVC"
+ name "AFX_MSG_MAP_Entries"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "MESSAGE_MAP_Entries"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "AFX_DISPATCH_MAP_Entries"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "DISPATCH_MAP_Entries"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "AFX_EVENT_MAP_Entries"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "EVENT_MAP_Entries"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "AFX_EVENTSINK_MAP_Entries"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "EVENTSINK_MAP_Entries"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "CallType"
+ value "")
+ (object Attribute
+ tool "MSVC"
+ name "DeclSpec"
+ value "")
+ (object Attribute
+ tool "MSVC"
+ name "BodyImage"
+ value (value Text ""))))
+ (object Attribute
+ tool "MSVC"
+ name "default__Role"
+ value (list Attribute_Set
+ (object Attribute
+ tool "MSVC"
+ name "Type"
+ value ("MSVCAttributeTypeSet" 0))
+ (object Attribute
+ tool "MSVC"
+ name "MSVCAttributeTypeSet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "MSVC"
+ name "Normal"
+ value 0)
+ (object Attribute
+ tool "MSVC"
+ name "Member_Property"
+ value 1)
+ (object Attribute
+ tool "MSVC"
+ name "Get_Set_Property"
+ value 2)
+ (object Attribute
+ tool "MSVC"
+ name "Dialog_Data"
+ value 3)
+ (object Attribute
+ tool "MSVC"
+ name "Field_Data"
+ value 4)
+ (object Attribute
+ tool "MSVC"
+ name "Stock_Property"
+ value 5)))
+ (object Attribute
+ tool "MSVC"
+ name "AFX_DISPATCH_MAP_Entries"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "DISPATCH_MAP_Entries"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "DeclSpec"
+ value "")
+ (object Attribute
+ tool "MSVC"
+ name "PointerBase"
+ value "")
+ (object Attribute
+ tool "MSVC"
+ name "CallType"
+ value "")
+ (object Attribute
+ tool "MSVC"
+ name "StockPropertyImplementation"
+ value "")))
+ (object Attribute
+ tool "MSVC"
+ name "default__Has"
+ value (list Attribute_Set
+ (object Attribute
+ tool "MSVC"
+ name "Type"
+ value ("MSVCAttributeTypeSet" 0))
+ (object Attribute
+ tool "MSVC"
+ name "MSVCAttributeTypeSet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "MSVC"
+ name "Normal"
+ value 0)
+ (object Attribute
+ tool "MSVC"
+ name "Member_Property"
+ value 1)
+ (object Attribute
+ tool "MSVC"
+ name "Get_Set_Property"
+ value 2)
+ (object Attribute
+ tool "MSVC"
+ name "Dialog_Data"
+ value 3)
+ (object Attribute
+ tool "MSVC"
+ name "Field_Data"
+ value 4)
+ (object Attribute
+ tool "MSVC"
+ name "Stock_Property"
+ value 5)))
+ (object Attribute
+ tool "MSVC"
+ name "AFX_DISPATCH_MAP_Entries"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "DISPATCH_MAP_Entries"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "DeclSpec"
+ value "")
+ (object Attribute
+ tool "MSVC"
+ name "PointerBase"
+ value "")
+ (object Attribute
+ tool "MSVC"
+ name "CallType"
+ value "")
+ (object Attribute
+ tool "MSVC"
+ name "StockPropertyImplementation"
+ value "")))
+ (object Attribute
+ tool "MSVC"
+ name "default__Attribute"
+ value (list Attribute_Set
+ (object Attribute
+ tool "MSVC"
+ name "Type"
+ value ("MSVCAttributeTypeSet" 0))
+ (object Attribute
+ tool "MSVC"
+ name "MSVCAttributeTypeSet"
+ value (list Attribute_Set
+ (object Attribute
+ tool "MSVC"
+ name "Normal"
+ value 0)
+ (object Attribute
+ tool "MSVC"
+ name "Member_Property"
+ value 1)
+ (object Attribute
+ tool "MSVC"
+ name "Get_Set_Property"
+ value 2)
+ (object Attribute
+ tool "MSVC"
+ name "Dialog_Data"
+ value 3)
+ (object Attribute
+ tool "MSVC"
+ name "Field_Data"
+ value 4)
+ (object Attribute
+ tool "MSVC"
+ name "Stock_Property"
+ value 5)))
+ (object Attribute
+ tool "MSVC"
+ name "AFX_DISPATCH_MAP_Entries"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "DISPATCH_MAP_Entries"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "DeclSpec"
+ value "")
+ (object Attribute
+ tool "MSVC"
+ name "PointerBase"
+ value "")
+ (object Attribute
+ tool "MSVC"
+ name "CallType"
+ value "")
+ (object Attribute
+ tool "MSVC"
+ name "StockPropertyImplementation"
+ value "")))
+ (object Attribute
+ tool "MSVC"
+ name "default__Module-Spec"
+ value (list Attribute_Set
+ (object Attribute
+ tool "MSVC"
+ name "GenerateIncludesGroup"
+ value FALSE)
+ (object Attribute
+ tool "MSVC"
+ name "AFX_INCLUDES_Entries"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "GenerateInsertLocation"
+ value FALSE)))
+ (object Attribute
+ tool "MSVC"
+ name "default__Module-Body"
+ value (list Attribute_Set
+ (object Attribute
+ tool "MSVC"
+ name "GenerateIncludesGroup"
+ value FALSE)
+ (object Attribute
+ tool "MSVC"
+ name "AFX_INCLUDES_Entries"
+ value (value Text ""))
+ (object Attribute
+ tool "MSVC"
+ name "GenerateInsertLocation"
+ value FALSE)))
+ (object Attribute
+ tool "cg"
+ name "HiddenTool"
+ value FALSE)
+ (object Attribute
+ tool "TypeLibImporter"
+ name "HiddenTool"
+ value FALSE))
+ quid "4367BF7F0009"))
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/resources/model/assembly.ppt b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/resources/model/assembly.ppt
new file mode 100644
index 0000000000..717f54a1ba
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/resources/model/assembly.ppt
Binary files differ
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/resources/model/sca-binding-sca.xsd b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/resources/model/sca-binding-sca.xsd
new file mode 100644
index 0000000000..2e379cfa59
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/resources/model/sca-binding-sca.xsd
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- (c) Copyright BEA Systems Inc. and IBM Corporation 2005 -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://www.osoa.org/xmlns/sca/0.9"
+ xmlns:sca="http://www.osoa.org/xmlns/sca/0.9"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core.xsd"/>
+
+ <element name="binding.sca" type="sca:SCABinding" substitutionGroup="sca:binding"/>
+ <complexType name="SCABinding">
+ <complexContent>
+ <extension base="sca:Binding">
+ <sequence>
+ <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </extension>
+ </complexContent>
+ </complexType>
+</schema> \ No newline at end of file
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/resources/model/sca-binding-webservice.xsd b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/resources/model/sca-binding-webservice.xsd
new file mode 100644
index 0000000000..51b6458958
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/resources/model/sca-binding-webservice.xsd
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- (c) Copyright BEA Systems Inc. and IBM Corporation 2005 -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://www.osoa.org/xmlns/sca/0.9"
+ xmlns:sca="http://www.osoa.org/xmlns/sca/0.9"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core.xsd"/>
+
+ <element name="binding.ws" type="sca:WebServiceBinding" substitutionGroup="sca:binding"/>
+ <complexType name="WebServiceBinding">
+ <complexContent>
+ <extension base="sca:Binding">
+ <sequence>
+ <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="port" type="anyURI" use="required"/>
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </extension>
+ </complexContent>
+ </complexType>
+</schema> \ No newline at end of file
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/resources/model/sca-core.xsd b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/resources/model/sca-core.xsd
new file mode 100644
index 0000000000..a9cb8582f0
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/resources/model/sca-core.xsd
@@ -0,0 +1,225 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- (c) Copyright BEA Systems Inc. and IBM Corporation 2005 -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://www.osoa.org/xmlns/sca/0.9"
+ xmlns:sca="http://www.osoa.org/xmlns/sca/0.9"
+ xmlns:sdo="commonj.sdo/xml"
+ xmlns:sdojava="commonj.sdo/java"
+ sdojava:package="org.apache.tuscany.model.scdl"
+ elementFormDefault="qualified">
+
+ <element name="componentType" type="sca:ComponentType"/>
+ <complexType name="ComponentType">
+ <sequence>
+ <element minOccurs="0" maxOccurs="unbounded" name="service" type="sca:Service"/>
+ <element minOccurs="0" maxOccurs="unbounded" name="reference" type="sca:Reference"/>
+ <element minOccurs="0" maxOccurs="unbounded" name="property" type="sca:Property"/>
+ <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </complexType>
+
+ <complexType name="Service">
+ <sequence>
+ <element minOccurs="1" maxOccurs="1" ref="sca:interface"/>
+ <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="name" type="NCName" use="required"/>
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </complexType>
+
+ <element name="interface" type="sca:Interface"/>
+ <complexType name="Interface"/>
+
+ <complexType name="Reference">
+ <sequence>
+ <element minOccurs="1" maxOccurs="1" ref="sca:interface"/>
+ <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="name" type="NCName" use="required"/>
+ <attribute name="multiplicity" type="sca:Multiplicity" use="optional" default="1..1"/>
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </complexType>
+
+ <complexType name="Property">
+ <sequence>
+ <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="name" type="NCName" use="required"/>
+ <attribute name="type" type="QName" use="required" sdo:name="dataType"/>
+ <attribute name="many" type="boolean" default="false" use="optional"/>
+ <attribute name="required" type="boolean" default="false" use="optional"/>
+ <attribute name="default" type="string" use="optional"/>
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </complexType>
+
+
+ <element name="moduleFragment" type="sca:ModuleFragment"/>
+ <complexType name="ModuleFragment">
+ <sequence>
+ <element minOccurs="0" maxOccurs="unbounded" name="entryPoint" type="sca:EntryPoint"/>
+ <element minOccurs="0" maxOccurs="unbounded" name="component" type="sca:Component"/>
+ <element minOccurs="0" maxOccurs="unbounded" name="externalService" type="sca:ExternalService"/>
+ <element minOccurs="0" maxOccurs="unbounded" name="wire" type="sca:ModuleWire"/>
+ <!-- This is a Tuscany extension -->
+ <element minOccurs="0" maxOccurs="unbounded" name="import" type="sca:Import"/>
+ <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="name" type="NCName" use="required"/>
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </complexType>
+
+ <element name="module" type="sca:Module"/>
+ <complexType name="Module">
+ <complexContent>
+ <extension base="sca:ModuleFragment"/>
+ </complexContent>
+ </complexType>
+
+ <complexType name="EntryPoint">
+ <sequence>
+ <element minOccurs="0" maxOccurs="1" ref="sca:interface"/>
+ <element minOccurs="1" maxOccurs="unbounded" ref="sca:binding"/>
+ <element minOccurs="1" maxOccurs="unbounded" name="reference" type="anyURI"/>
+ <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="name" type="NCName" use="required"/>
+ <attribute name="multiplicity" type="sca:Multiplicity" use="optional" default="1..1"/>
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </complexType>
+ <!-- a multiplicity 1..1 or 0..n sample
+ <reference>StockQuoteComponent</reference> - type must be URI
+ a multiplicity 1..n or 0..n sample
+ <reference>StockQuoteComponent1</reference> - type must be URI
+ <reference>StockQuoteComponent2</reference>
+ -->
+
+ <element name="binding" type="sca:Binding"/>
+ <complexType name="Binding">
+ <attribute name="uri" type="anyURI" use="optional"/>
+ </complexType>
+
+ <complexType name="Component">
+ <sequence>
+ <element minOccurs="1" maxOccurs="1" ref="sca:implementation"/>
+ <element minOccurs="0" maxOccurs="1" name="properties" type="sca:PropertyValues"/>
+ <element minOccurs="0" maxOccurs="1" name="references" type="sca:ReferenceValues"/>
+ <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="name" type="NCName" use="required"/>
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </complexType>
+ <!-- a multiplicity 1..1 or 0..1 sample
+ <references>
+ <v:stockQuote>StockQuoteComponent</v:stockquote> - type must be URI
+ </references>
+ a multiplicity 1..n or 0..n sample
+ <references>
+ <v:stockQuote>StockQuoteComponent1</v:stockQuote> - type must be URI
+ <v:stockQuote>StockQuoteComponent2</v:stockQuote>
+ </references>
+ -->
+
+ <element name="implementation" type="sca:Implementation"/>
+ <complexType name="Implementation"/>
+
+ <complexType name="PropertyValues">
+ <sequence>
+ <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </complexType>
+
+ <complexType name="ReferenceValues">
+ <sequence>
+ <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </complexType>
+
+
+ <complexType name="ExternalService">
+ <sequence>
+ <element minOccurs="1" maxOccurs="1" ref="sca:interface"/>
+ <element minOccurs="0" maxOccurs="unbounded" ref="sca:binding"/>
+ </sequence>
+ <attribute name="name" type="NCName" use="required"/>
+ <attribute name="overridable" type="sca:OverrideOptions" default="may" use="optional"/>
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </complexType>
+
+
+ <complexType name="ModuleWire">
+ <sequence>
+ <element minOccurs="1" maxOccurs="1" ref="sca:source.uri"/>
+ <element minOccurs="1" maxOccurs="1" ref="sca:target.uri"/>
+ <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </complexType>
+
+ <element name="source" type="anyType"/>
+ <element name="target" type="anyType"/>
+
+ <element name="source.uri" type="anyURI" substitutionGroup="sca:source"/>
+ <element name="target.uri" type="anyURI" substitutionGroup="sca:target"/>
+
+ <element name="subsystem" type="sca:Subsystem"/>
+ <complexType name="Subsystem">
+ <sequence>
+ <element minOccurs="0" maxOccurs="unbounded" name="entryPoint" type="sca:EntryPoint"/>
+ <element minOccurs="0" maxOccurs="unbounded" name="moduleComponent" type="sca:ModuleComponent"/>
+ <element minOccurs="0" maxOccurs="unbounded" name="externalService" type="sca:ExternalService"/>
+ <element minOccurs="0" maxOccurs="unbounded" name="wire" type="sca:SystemWire"/>
+ <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="name" type="NCName" use="required"/>
+ <attribute name="uri" type="anyURI" use="optional"/>
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </complexType>
+
+ <complexType name="ModuleComponent">
+ <sequence>
+ <element minOccurs="0" maxOccurs="1" name="properties" type="sca:PropertyValues"/>
+ <element minOccurs="0" maxOccurs="1" name="references" type="sca:ReferenceValues"/>
+ <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="name" type="NCName" use="required"/>
+ <attribute name="module" type="NCName" use="required"/>
+ <attribute name="uri" type="anyURI" use="optional"/>
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </complexType>
+
+ <complexType name="SystemWire">
+ <sequence>
+ <element minOccurs="1" maxOccurs="1" ref="sca:source"/>
+ <element minOccurs="1" maxOccurs="1" ref="sca:target"/>
+ <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ </complexType>
+
+ <element name="source.epr" type="anyType" substitutionGroup="sca:source"/>
+ <element name="target.epr" type="anyType" substitutionGroup="sca:target"/>
+
+ <simpleType name="Multiplicity">
+ <restriction base="string">
+ <enumeration value="0..1"/>
+ <enumeration value="1..1"/>
+ <enumeration value="0..n"/>
+ <enumeration value="1..n"/>
+ </restriction>
+ </simpleType>
+
+ <simpleType name="OverrideOptions">
+ <restriction base="string">
+ <enumeration value="no"/>
+ <enumeration value="may"/>
+ <enumeration value="must"/>
+ </restriction>
+ </simpleType>
+
+ <!-- This is a Tuscany extension -->
+ <element name="import" type="sca:Import"/>
+ <complexType name="Import"/>
+
+</schema> \ No newline at end of file
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/resources/model/sca-implementation-java.xsd b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/resources/model/sca-implementation-java.xsd
new file mode 100644
index 0000000000..cf155e3dfb
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/resources/model/sca-implementation-java.xsd
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- (c) Copyright BEA Systems Inc. and IBM Corporation 2005 -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://www.osoa.org/xmlns/sca/0.9"
+ xmlns:sca="http://www.osoa.org/xmlns/sca/0.9"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core.xsd"/>
+
+ <element name="implementation.java" type="sca:JavaImplementation" substitutionGroup="sca:implementation"/>
+ <complexType name="JavaImplementation">
+ <complexContent>
+ <extension base="sca:Implementation">
+ <sequence>
+ <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="class" type="NCName" use="required"/>
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </extension>
+ </complexContent>
+ </complexType>
+</schema> \ No newline at end of file
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/resources/model/sca-interface-java.xsd b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/resources/model/sca-interface-java.xsd
new file mode 100644
index 0000000000..b0f9aec48c
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/resources/model/sca-interface-java.xsd
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- (c) Copyright BEA Systems Inc. and IBM Corporation 2005 -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://www.osoa.org/xmlns/sca/0.9"
+ xmlns:sca="http://www.osoa.org/xmlns/sca/0.9"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core.xsd"/>
+
+ <element name="interface.java" type="sca:JavaInterface" substitutionGroup="sca:interface"/>
+ <complexType name="JavaInterface">
+ <complexContent>
+ <extension base="sca:Interface">
+ <sequence>
+ <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="interface" type="NCName" use="required"/>
+ <attribute name="callbackInterface" type="NCName" use="optional"/>
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </extension>
+ </complexContent>
+ </complexType>
+</schema> \ No newline at end of file
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/resources/model/sca-interface-wsdl.xsd b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/resources/model/sca-interface-wsdl.xsd
new file mode 100644
index 0000000000..dd06917da5
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/resources/model/sca-interface-wsdl.xsd
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- (c) Copyright BEA Systems Inc. and IBM Corporation 2005 -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://www.osoa.org/xmlns/sca/0.9"
+ xmlns:sca="http://www.osoa.org/xmlns/sca/0.9"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core.xsd"/>
+
+ <element name="interface.wsdl" type="sca:WSDLPortType" substitutionGroup="sca:interface"/>
+ <complexType name="WSDLPortType">
+ <complexContent>
+ <extension base="sca:Interface">
+ <sequence>
+ <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="interface" type="anyURI" use="required"/>
+ <attribute name="callbackInterface" type="anyURI" use="optional"/>
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <!-- This is a Tuscany extension -->
+ <element name="import.wsdl" type="sca:WSDLImport" substitutionGroup="sca:import"/>
+ <complexType name="WSDLImport">
+ <complexContent>
+ <extension base="sca:Import">
+ <sequence>
+ <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="namespace" type="anyURI" use="required"/>
+ <attribute name="location" type="anyURI" use="required"/>
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+</schema> \ No newline at end of file
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/resources/model/sca.xsd b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/resources/model/sca.xsd
new file mode 100644
index 0000000000..c2438bc1d4
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/resources/model/sca.xsd
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- (c) Copyright BEA Systems Inc. and IBM Corporation 2005 -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://www.osoa.org/xmlns/sca/0.9"
+ xmlns:sdojava="commonj.sdo/java"
+ xmlns:sca="http://www.osoa.org/xmlns/sca/0.9"
+ sdojava:package="org.apache.tuscany.model.scdl">
+
+ <include schemaLocation="sca-core.xsd"/>
+
+ <include schemaLocation="sca-interface-java.xsd"/>
+ <include schemaLocation="sca-interface-wsdl.xsd"/>
+
+ <include schemaLocation="sca-implementation-java.xsd"/>
+
+ <include schemaLocation="sca-binding-webservice.xsd"/>
+ <include schemaLocation="sca-binding-sca.xsd"/>
+
+</schema> \ No newline at end of file
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/resources/org/apache/tuscany/model/Messages.properties b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/resources/org/apache/tuscany/model/Messages.properties
new file mode 100644
index 0000000000..4581e44bff
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/resources/org/apache/tuscany/model/Messages.properties
@@ -0,0 +1,25 @@
+# Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
+#
+# 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.
+# ====================================================================
+# To code developer:
+# Do NOT change the properties between this line and the
+# "%%% END OF TRANSLATED PROPERTIES %%%" line.
+# Make a new property name, append to the end of the file and change
+# the code to use the new property.
+# ====================================================================
+
+# =====================================================================
+# %%% END OF TRANSLATED PROPERTIES %%%
+# =====================================================================
+# NLS_MESSAGEFORMAT_ALL
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/SCDLAssemblyLoaderTestCase.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/SCDLAssemblyLoaderTestCase.java
new file mode 100644
index 0000000000..482a10d0f4
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/SCDLAssemblyLoaderTestCase.java
@@ -0,0 +1,69 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.assembly.tests;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.common.resource.ResourceLoader;
+import org.apache.tuscany.common.resource.impl.ResourceLoaderImpl;
+import org.apache.tuscany.model.assembly.AssemblyFactory;
+import org.apache.tuscany.model.assembly.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.Component;
+import org.apache.tuscany.model.assembly.EntryPoint;
+import org.apache.tuscany.model.assembly.Module;
+import org.apache.tuscany.model.assembly.impl.AssemblyFactoryImpl;
+import org.apache.tuscany.model.assembly.impl.AssemblyModelContextImpl;
+import org.apache.tuscany.model.assembly.loader.AssemblyModelLoader;
+import org.apache.tuscany.model.scdl.loader.impl.SCDLAssemblyModelLoaderImpl;
+
+/**
+ */
+public class SCDLAssemblyLoaderTestCase extends TestCase {
+
+ /**
+ *
+ */
+ public SCDLAssemblyLoaderTestCase() {
+ super();
+ }
+
+ public void testLoader() {
+
+ ResourceLoader resourceLoader=new ResourceLoaderImpl(Thread.currentThread().getContextClassLoader());
+ AssemblyModelLoader assemblyLoader=new SCDLAssemblyModelLoaderImpl(null);
+ AssemblyFactory assemblyFactory=new AssemblyFactoryImpl();
+ AssemblyModelContext modelContext=new AssemblyModelContextImpl(assemblyFactory, assemblyLoader, resourceLoader);
+
+ Module module = assemblyLoader.loadModule(getClass().getResource("sca.module").toString());
+ module.initialize(modelContext);
+ Assert.assertTrue(module.getName().equals("tuscany.model.assembly.tests.bigbank.account"));
+
+ Component foundComponent=module.getComponent("AccountServiceComponent");
+ Assert.assertTrue(foundComponent!= null);
+
+ EntryPoint foundEntryPoint=module.getEntryPoint("AccountService");
+ Assert.assertTrue(foundEntryPoint!= null);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/SCDLXMLReaderTestCase.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/SCDLXMLReaderTestCase.java
new file mode 100644
index 0000000000..c1beac4e9a
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/SCDLXMLReaderTestCase.java
@@ -0,0 +1,67 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.assembly.tests;
+
+import java.util.List;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.model.scdl.Component;
+import org.apache.tuscany.model.scdl.EntryPoint;
+import org.apache.tuscany.model.scdl.Module;
+import org.apache.tuscany.model.scdl.loader.impl.SCDLXMLReader;
+
+/**
+ */
+public class SCDLXMLReaderTestCase extends TestCase {
+
+ /**
+ *
+ */
+ public SCDLXMLReaderTestCase() {
+ super();
+ }
+
+ public void testLoader() {
+
+ SCDLXMLReader loader = new SCDLXMLReader();
+ Module module = loader.getModule(getClass().getResource("sca.module").toString());
+ Assert.assertTrue(module.getName().equals("tuscany.model.assembly.tests.bigbank.account"));
+
+ Component foundComponent=null;
+ for (Component component : (List<Component>)module.getComponent()) {
+ if (component.getName().equals("AccountServiceComponent"))
+ foundComponent=component;
+ }
+ Assert.assertTrue(foundComponent!= null);
+
+ EntryPoint foundEntryPoint=null;
+ for (EntryPoint entryPoint: (List<EntryPoint>)module.getEntryPoint()) {
+ if (entryPoint.getName().equals("AccountService"))
+ foundEntryPoint=entryPoint;
+ }
+ Assert.assertTrue(foundEntryPoint!= null);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/account/AccountReport.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/account/AccountReport.java
new file mode 100644
index 0000000000..b1b5913adc
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/account/AccountReport.java
@@ -0,0 +1,32 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.assembly.tests.bigbank.account.services.account;
+
+import java.util.List;
+
+/**
+ * @model
+ */
+
+public interface AccountReport {
+
+ /**
+ * @model type="services.account.AccountSummary"
+ */
+
+ List getAccountSummaries();
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/account/AccountService.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/account/AccountService.java
new file mode 100644
index 0000000000..83df13439a
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/account/AccountService.java
@@ -0,0 +1,25 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.assembly.tests.bigbank.account.services.account;
+
+import org.osoa.sca.annotations.Remotable;
+
+@Remotable
+public interface AccountService {
+
+ public AccountReport getAccountReport(String customerID);
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/account/AccountService.wsdl b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/account/AccountService.wsdl
new file mode 100644
index 0000000000..921218c5b9
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/account/AccountService.wsdl
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
+
+ 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.
+ -->
+<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:tns="http://www.bigbank.com/AccountService/"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://www.bigbank.com/AccountService/"
+
+ name="AccountService">
+
+ <wsdl:types>
+ <xsd:schema targetNamespace="http://www.bigbank.com/AccountService/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <xsd:element name="customerID" type="xsd:string"/>
+ <xsd:element name="getAccountReportResponse" type="tns:AccountReport"/>
+
+ <xsd:complexType name="AccountReport">
+ <xsd:sequence>
+ <xsd:element name="accountSummary" type="tns:AccountSummary" maxOccurs="unbounded"/>
+ </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:customerID" 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="AccountServiceSOAP" type="tns:AccountService">
+ <soap:binding style="document"
+ transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="getAccountReport">
+ <soap:operation
+ soapAction="http://www.bigbank.com/AccountService/getAccountReport"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="AccountService">
+ <wsdl:port binding="tns:AccountServiceSOAP"
+ name="AccountServiceSOAP">
+ <soap:address location=""/>
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/account/AccountServiceImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/account/AccountServiceImpl.java
new file mode 100644
index 0000000000..a5619bb41e
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/account/AccountServiceImpl.java
@@ -0,0 +1,42 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.assembly.tests.bigbank.account.services.account;
+
+import org.osoa.sca.annotations.Property;
+import org.osoa.sca.annotations.Reference;
+
+import org.apache.tuscany.model.assembly.tests.bigbank.account.services.accountdata.AccountDataService;
+import org.apache.tuscany.model.assembly.tests.bigbank.account.services.stockquote.StockQuoteService;
+
+public class AccountServiceImpl implements AccountService {
+
+ @Property
+ public String currency = "USD";
+
+ @Reference
+ public AccountDataService accountDataService;
+ @Reference
+ public StockQuoteService stockQuoteService;
+
+ public AccountServiceImpl() {
+ }
+
+ public AccountReport getAccountReport(String customerID) {
+ return null;
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/account/AccountSummary.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/account/AccountSummary.java
new file mode 100644
index 0000000000..c1650c79fa
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/account/AccountSummary.java
@@ -0,0 +1,46 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.assembly.tests.bigbank.account.services.account;
+
+/**
+ * @model
+ */
+
+public interface AccountSummary {
+
+ /**
+ * @model
+ */
+ String getAccountNumber();
+
+ void setAccountNumber(String accountNumber);
+
+ /**
+ * @model
+ */
+ String getAccountType();
+
+ void setAccountType(String accountType);
+
+ /**
+ * @model
+ */
+ float getBalance();
+
+ void setBalance(float balance);
+}
+
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/accountdata/AccountDataService.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/accountdata/AccountDataService.java
new file mode 100644
index 0000000000..04ae8e5bd5
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/accountdata/AccountDataService.java
@@ -0,0 +1,26 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.assembly.tests.bigbank.account.services.accountdata;
+
+public interface AccountDataService {
+
+ CheckingAccount getCheckingAccount(String customerID);
+
+ SavingsAccount getSavingsAccount(String customerID);
+
+ StockAccount getStockAccount(String customerID);
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/accountdata/AccountDataServiceImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/accountdata/AccountDataServiceImpl.java
new file mode 100644
index 0000000000..eaf4b9486e
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/accountdata/AccountDataServiceImpl.java
@@ -0,0 +1,48 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.assembly.tests.bigbank.account.services.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/sca-java-1.x/tags/java-stable-20060304/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/accountdata/CheckingAccount.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/accountdata/CheckingAccount.java
new file mode 100644
index 0000000000..d4f2f8be6c
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/accountdata/CheckingAccount.java
@@ -0,0 +1,39 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.assembly.tests.bigbank.account.services.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/sca-java-1.x/tags/java-stable-20060304/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/accountdata/SavingsAccount.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/accountdata/SavingsAccount.java
new file mode 100644
index 0000000000..73474585da
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/accountdata/SavingsAccount.java
@@ -0,0 +1,39 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.assembly.tests.bigbank.account.services.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/sca-java-1.x/tags/java-stable-20060304/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/accountdata/StockAccount.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/accountdata/StockAccount.java
new file mode 100644
index 0000000000..eeb7238abc
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/accountdata/StockAccount.java
@@ -0,0 +1,48 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.assembly.tests.bigbank.account.services.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/sca-java-1.x/tags/java-stable-20060304/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/stockquote/StockQuoteService.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/stockquote/StockQuoteService.java
new file mode 100644
index 0000000000..7545e9fbbb
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/stockquote/StockQuoteService.java
@@ -0,0 +1,24 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.assembly.tests.bigbank.account.services.stockquote;
+
+public interface StockQuoteService {
+
+ public float getQuote(String symbol);
+}
+
+ \ No newline at end of file
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/stockquote/StockQuoteServiceImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/stockquote/StockQuoteServiceImpl.java
new file mode 100644
index 0000000000..85f85340ec
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/stockquote/StockQuoteServiceImpl.java
@@ -0,0 +1,28 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.model.assembly.tests.bigbank.account.services.stockquote;
+
+/* Dummy'd up StockQuoteService, override webservice for now */
+
+public class StockQuoteServiceImpl implements StockQuoteService {
+
+ public float getQuote(String symbol) {
+ // Just hardcode for now
+ return 83.00f;
+ }
+
+} \ No newline at end of file
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/stockquote/StockQuoteWebService.wsdl b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/stockquote/StockQuoteWebService.wsdl
new file mode 100644
index 0000000000..9678d9d6ea
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/stockquote/StockQuoteWebService.wsdl
@@ -0,0 +1,98 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
+
+ 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.
+ -->
+<wsdl:definitions targetNamespace="http://webservice.stockquote" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://webservice.stockquote" xmlns:intf="http://webservice.stockquote" xmlns:tns1="http://stockquote" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="">
+ <!--WSDL created by Apache Axis version: 1.2.1
+Built on Jun 14, 2005 (09:15:57 EDT)-->
+ <wsdl:types>
+ <schema elementFormDefault="qualified" targetNamespace="http://stockquote" xmlns="http://www.w3.org/2001/XMLSchema">
+ <complexType name="GetQuoteRequest">
+ <sequence>
+ <element name="symbol" nillable="true" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ <complexType name="GetQuoteResponse">
+ <sequence>
+ <element name="price" type="xsd:float"/>
+ </sequence>
+ </complexType>
+ </schema>
+ <schema elementFormDefault="qualified" targetNamespace="http://webservice.stockquote" xmlns="http://www.w3.org/2001/XMLSchema">
+ <import namespace="http://stockquote"/>
+ <element name="request" type="tns1:GetQuoteRequest"/>
+ <element name="getQuoteReturn" type="tns1:GetQuoteResponse"/>
+ </schema>
+ </wsdl:types>
+
+ <wsdl:message name="getQuoteResponse">
+
+ <wsdl:part element="impl:getQuoteReturn" name="getQuoteReturn"/>
+
+ </wsdl:message>
+
+ <wsdl:message name="getQuoteRequest">
+
+ <wsdl:part element="impl:request" name="request"/>
+
+ </wsdl:message>
+
+ <wsdl:portType name="StockQuoteWebService">
+
+ <wsdl:operation name="getQuote" parameterOrder="request">
+
+ <wsdl:input message="impl:getQuoteRequest" name="getQuoteRequest"/>
+
+ <wsdl:output message="impl:getQuoteResponse" name="getQuoteResponse"/>
+
+ </wsdl:operation>
+
+ </wsdl:portType>
+
+ <wsdl:binding name="StockQuoteWebServiceSoapBinding" type="impl:StockQuoteWebService">
+
+ <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+
+ <wsdl:operation name="getQuote">
+
+ <wsdlsoap:operation soapAction=""/>
+
+ <wsdl:input name="getQuoteRequest">
+
+ <wsdlsoap:body use="literal"/>
+
+ </wsdl:input>
+
+ <wsdl:output name="getQuoteResponse">
+
+ <wsdlsoap:body use="literal"/>
+
+ </wsdl:output>
+
+ </wsdl:operation>
+
+ </wsdl:binding>
+
+ <wsdl:service name="StockQuoteWebServiceService">
+
+ <wsdl:port binding="impl:StockQuoteWebServiceSoapBinding" name="StockQuoteWebService">
+
+ <wsdlsoap:address location="http://localhost:8123/StockQuoteWebService/services/StockQuoteWebService"/>
+
+ </wsdl:port>
+
+ </wsdl:service>
+
+</wsdl:definitions>
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/test/resources/org/apache/tuscany/model/assembly/tests/sca.module b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/test/resources/org/apache/tuscany/model/assembly/tests/sca.module
new file mode 100644
index 0000000000..7d81262730
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/test/resources/org/apache/tuscany/model/assembly/tests/sca.module
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
+
+ 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.
+ -->
+<module xmlns="http://www.osoa.org/xmlns/sca/0.9" xmlns:v="http://www.osoa.org/xmlns/sca/values/0.9"
+
+ name="tuscany.model.assembly.tests.bigbank.account">
+
+ <entryPoint name="AccountService">
+ <interface.java interface="org.apache.tuscany.model.assembly.tests.bigbank.account.services.account.AccountService"/>
+ <binding.ws port="http://www.bigbank.com/AccountService#AccountServiceSOAP"/>
+ <!--
+ <reference>AccountServiceComponent</reference>
+ -->
+ </entryPoint>
+
+ <component name="AccountServiceComponent">
+ <implementation.java class="org.apache.tuscany.model.assembly.tests.bigbank.account.services.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.tuscany.model.assembly.tests.bigbank.account.services.accountdata.AccountDataServiceImpl"/>
+ </component>
+
+ <component name="StockQuoteService">
+ <implementation.java class="org.apache.tuscany.model.assembly.tests.bigbank.account.services.stockquote.StockQuoteServiceImpl"/>
+ </component>
+
+ <!--
+ <externalService name="StockQuoteService">
+ <interface.java interface="org.apache.tuscany.model.assembly.tests.bigbank.account.services.stockquote"/>
+ <binding.ws port="http://www.quickstockquote.com/StockQuoteService#StockQuoteServiceSOAP"/>
+ </externalService>
+ -->
+
+</module>
+
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/test/resources/org/apache/tuscany/model/assembly/tests/sca.subsystem b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/test/resources/org/apache/tuscany/model/assembly/tests/sca.subsystem
new file mode 100644
index 0000000000..bff90f010d
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/test/resources/org/apache/tuscany/model/assembly/tests/sca.subsystem
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
+
+ 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.
+ -->
+<subsystem xmlns="http://www.osoa.org/xmlns/sca/0.9"
+
+ name="tuscany.runtime.bigbank.account">
+
+ <moduleComponent name="AccountModuleComponent" module="tuscany.runtime.bigbank.account"/>
+
+</subsystem>
+
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/plugin/LICENSE.txt b/sca-java-1.x/tags/java-stable-20060304/sca/plugin/LICENSE.txt
new file mode 100644
index 0000000000..d645695673
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/plugin/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/sca-java-1.x/tags/java-stable-20060304/sca/plugin/pom.xml b/sca-java-1.x/tags/java-stable-20060304/sca/plugin/pom.xml
new file mode 100644
index 0000000000..3f3dbfcd1c
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/plugin/pom.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Copyright (c) 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.
+ -->
+<project>
+ <parent>
+ <groupId>org.apache.tuscany</groupId>
+ <artifactId>tuscany-sca</artifactId>
+ <version>SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>tuscany-sca-plugin</artifactId>
+ <packaging>maven-plugin</packaging>
+ <version>SNAPSHOT</version>
+ <name>Tuscany SCA Maven Plugin</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-plugin-api</artifactId>
+ <version>2.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany</groupId>
+ <artifactId>tuscany-sca-tools</artifactId>
+ <version>${pom.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/plugin/src/main/java/org/apache/tuscany/tools/wsdl2java/plugin/WSDL2JavaGeneratorMojo.java b/sca-java-1.x/tags/java-stable-20060304/sca/plugin/src/main/java/org/apache/tuscany/tools/wsdl2java/plugin/WSDL2JavaGeneratorMojo.java
new file mode 100644
index 0000000000..b351982e13
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/plugin/src/main/java/org/apache/tuscany/tools/wsdl2java/plugin/WSDL2JavaGeneratorMojo.java
@@ -0,0 +1,101 @@
+/**
+ *
+ * Copyright 2005 BEA Systems Inc.
+ * Copyright 2005 International Business Machines Corporation
+ *
+ * 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.tools.wsdl2java.plugin;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.tuscany.tools.wsdl2java.generate.WSDL2JavaGenerator;
+
+/**
+ * @version $Rev$ $Date$
+ * @goal generate
+ * @phase generate-sources
+ * @description Generate SDO interface classes from an XML Schema
+ */
+public class WSDL2JavaGeneratorMojo extends AbstractMojo {
+ /**
+ * The directory containing wsdl files; defaults to ${basedir}/src/main/wsdl
+ * @parameter expression="${basedir}/src/main/wsdl"
+ */
+ private String wsdlDir;
+
+ /**
+ * Name of the wsdl file; if omitted all files in the directory are processed
+ * @parameter
+ */
+ private File wsdlFile;
+
+ /**
+ * The Java package to generate into. By default the value is derived from the schema URI.
+ *
+ * @parameter
+ */
+ private String javaPackage;
+
+ /**
+ * The directory to generate into; defaults to ${project.build.directory}/wsdl2java-source
+ *
+ * @parameter expression="${project.build.directory}/wsdl2java-source"
+ */
+ private String targetDirectory;
+
+ /**
+ * @parameter expression="${project.compileSourceRoots}"
+ * @readonly
+ */
+ private List compilerSourceRoots;
+
+ public void execute() throws MojoExecutionException {
+ File[] files;
+ if (wsdlFile == null) {
+ files = new File(wsdlDir).listFiles(FILTER);
+ } else {
+ files = new File[]{wsdlFile};
+ }
+
+ int genOptions = 0;
+
+ for (int i = 0; i < files.length; i++) {
+ File file = files[i];
+ File marker = new File(targetDirectory, ".gen#" + file.getName());
+ if (file.lastModified() > marker.lastModified()) {
+ getLog().info("Generating Java service interfaces from " + file);
+ WSDL2JavaGenerator.generateFromWSDL(file.toString(), targetDirectory, javaPackage, null, genOptions);
+ }
+ try {
+ marker.createNewFile();
+ } catch (IOException e) {
+ throw new MojoExecutionException(e.getMessage(), e);
+ }
+ marker.setLastModified(System.currentTimeMillis());
+ }
+
+ compilerSourceRoots.add(targetDirectory);
+ }
+
+ private static final FileFilter FILTER = new FileFilter() {
+ public boolean accept(File pathname) {
+ return (pathname.isFile() || !pathname.isHidden());
+ }
+ };
+} \ No newline at end of file
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/pom.xml b/sca-java-1.x/tags/java-stable-20060304/sca/pom.xml
new file mode 100644
index 0000000000..f07e22f69e
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/pom.xml
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Copyright (c) 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.
+ -->
+<project>
+ <parent>
+ <groupId>org.apache.tuscany</groupId>
+ <artifactId>tuscany-project</artifactId>
+ <version>SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>tuscany-sca</artifactId>
+ <packaging>pom</packaging>
+ <name>Tuscany SCA Implementation Project</name>
+ <version>SNAPSHOT</version>
+
+ <modules>
+ <module>common</module>
+ <module>model</module>
+ <module>core</module>
+ <!-- <module>binding.axis</module> -->
+ <module>binding.axis2</module>
+ <module>container.java</module>
+ <module>container.js</module>
+ <module>tomcat</module>
+ <module>tools</module>
+ <module>plugin</module>
+ </modules>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <includes>
+ <include>**/*TestCase.java</include>
+ </includes>
+ </configuration>
+ </plugin>
+ </plugins>
+ <testResources>
+ <testResource>
+ <directory>src/test/java</directory>
+ <includes>
+ <include>**/*.componentType</include>
+ </includes>
+ </testResource>
+ <testResource>
+ <directory>src/test/resources</directory>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ </testResource>
+ </testResources>
+ </build>
+</project>
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/LICENSE.txt b/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/LICENSE.txt
new file mode 100644
index 0000000000..d645695673
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/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/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/pom.xml b/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/pom.xml
new file mode 100644
index 0000000000..26e610c67a
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/pom.xml
@@ -0,0 +1,106 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Copyright (c) 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.
+ -->
+<project>
+ <parent>
+ <groupId>org.apache.tuscany</groupId>
+ <artifactId>tuscany-sca</artifactId>
+ <version>SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>tuscany-tomcat</artifactId>
+ <name>Tuscany Apache Tomcat Integration</name>
+ <description>Integration of the Tuscany runtime with Apache Tomcat.</description>
+ <version>SNAPSHOT</version>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany</groupId>
+ <artifactId>tuscany-container-java</artifactId>
+ <version>${pom.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany</groupId>
+ <artifactId>tuscany-binding-axis2</artifactId>
+ <version>${pom.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+
+ <dependency>
+ <groupId>tomcat</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>5.0.18</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>tomcat</groupId>
+ <artifactId>catalina</artifactId>
+ <version>5.5.15</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>tomcat</groupId>
+ <artifactId>tomcat-util</artifactId>
+ <version>5.5.15</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>tomcat</groupId>
+ <artifactId>tomcat-coyote</artifactId>
+ <version>5.5.15</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>tomcat</groupId>
+ <artifactId>tomcat-http</artifactId>
+ <version>5.5.15</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>tomcat</groupId>
+ <artifactId>naming-factory</artifactId>
+ <version>5.5.15</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>tomcat</groupId>
+ <artifactId>naming-resources</artifactId>
+ <version>5.5.15</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.0.4</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-modeler</groupId>
+ <artifactId>commons-modeler</artifactId>
+ <version>1.1M1</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/ContainerLoader.java b/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/ContainerLoader.java
new file mode 100644
index 0000000000..60c9a7961f
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/ContainerLoader.java
@@ -0,0 +1,100 @@
+/**
+ *
+ * Copyright 2005 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.tomcat;
+
+import java.beans.PropertyChangeListener;
+
+import org.apache.catalina.Container;
+import org.apache.catalina.Loader;
+
+/**
+ * Implementation of a TomcatLoader that allows privileged servlets from the container
+ * classloader to be loaded into an unprivileged application. This allows the Tuscany
+ * integration code to add servlets to the application, for example, to handle web
+ * services requests.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ContainerLoader implements Loader {
+ private static final String INFO = ContainerLoader.class.getName() + "/SNAPSHOT";
+ private final ClassLoader cl;
+ private Container container;
+
+ /**
+ * Constructor specifying the classloader to be used.
+ *
+ * @param cl the classloader this Loader wraps, typically the container classloader
+ */
+ public ContainerLoader(ClassLoader cl) {
+ this.cl = cl;
+ }
+
+ public void backgroundProcess() {
+ }
+
+ public ClassLoader getClassLoader() {
+ return cl;
+ }
+
+ public Container getContainer() {
+ return container;
+ }
+
+ public void setContainer(Container container) {
+ this.container = container;
+ }
+
+ public boolean getDelegate() {
+ return false;
+ }
+
+ public void setDelegate(boolean delegate) {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getInfo() {
+ return INFO;
+ }
+
+ public boolean getReloadable() {
+ return false;
+ }
+
+ public void setReloadable(boolean reloadable) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void addRepository(String repository) {
+ throw new UnsupportedOperationException();
+ }
+
+ public String[] findRepositories() {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean modified() {
+ throw new UnsupportedOperationException();
+ }
+
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ throw new UnsupportedOperationException();
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/TuscanyContextListener.java b/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/TuscanyContextListener.java
new file mode 100644
index 0000000000..04977dbc27
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/TuscanyContextListener.java
@@ -0,0 +1,144 @@
+/**
+ *
+ * Copyright 2005 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.tomcat;
+
+import java.io.IOException;
+
+import javax.servlet.ServletContext;
+
+import org.apache.catalina.Context;
+import org.apache.catalina.Lifecycle;
+import org.apache.catalina.LifecycleEvent;
+import org.apache.catalina.LifecycleListener;
+import org.apache.catalina.Valve;
+import org.apache.catalina.core.StandardWrapper;
+
+import org.apache.tuscany.binding.axis2.handler.WebServiceEntryPointServlet;
+import org.apache.tuscany.common.resource.ResourceLoader;
+import org.apache.tuscany.common.resource.impl.ResourceLoaderImpl;
+import org.apache.tuscany.core.config.ConfigurationException;
+import org.apache.tuscany.core.config.ConfigurationLoadException;
+import org.apache.tuscany.core.config.ModuleComponentConfigurationLoader;
+import org.apache.tuscany.core.config.impl.ModuleComponentConfigurationLoaderImpl;
+import org.apache.tuscany.core.context.AggregateContext;
+import org.apache.tuscany.core.context.EventContext;
+import org.apache.tuscany.core.runtime.RuntimeContext;
+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;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class TuscanyContextListener implements LifecycleListener {
+ private static final String TUSCANY_RUNTIME_NAME = RuntimeContext.class.getName();
+ public static final String MODULE_COMPONENT_NAME = "org.apache.tuscany.core.webapp.ModuleComponentContext";
+
+ private final AssemblyFactory modelFactory;
+ private final AssemblyModelLoader modelLoader;
+ private final RuntimeContext runtime;
+ private final ResourceLoader systemLoader;
+ private AggregateContext moduleContext;
+
+ public TuscanyContextListener(RuntimeContext runtimeContext, AssemblyFactory modelFactory, AssemblyModelLoader modelLoader, ResourceLoader systemLoader) {
+ this.runtime = runtimeContext;
+ this.modelFactory = modelFactory;
+ this.modelLoader = modelLoader;
+ this.systemLoader = systemLoader;
+ }
+
+ public void lifecycleEvent(LifecycleEvent event) {
+ String type = event.getType();
+ if (Lifecycle.START_EVENT.equals(type)) {
+ startContext((Context) event.getLifecycle());
+ } else if (Lifecycle.STOP_EVENT.equals(type)) {
+ stopContext((Context) event.getLifecycle());
+ }
+ }
+
+ private void startContext(Context ctx) {
+ ResourceLoader resourceLoader = new ResourceLoaderImpl(ctx.getLoader().getClassLoader());
+ try {
+ if (resourceLoader.getResource("sca.module") == null) {
+ return;
+ }
+ } catch (IOException e) {
+ return;
+ }
+ ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
+ Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
+ try {
+ AssemblyModelContext modelContext = new AssemblyModelContextImpl(modelFactory, modelLoader, systemLoader, resourceLoader);
+ ModuleComponentConfigurationLoader loader = new ModuleComponentConfigurationLoaderImpl(modelContext);
+
+ try {
+ // Load the SCDL configuration of the application module
+ ModuleComponent moduleComponent = loader.loadModuleComponent(ctx.getName(), ctx.getPath());
+
+ // Register it under the root application context
+ AggregateContext rootContext = runtime.getRootContext();
+ rootContext.registerModelObject(moduleComponent);
+ moduleContext = (AggregateContext)rootContext.getContext(moduleComponent.getName());
+ moduleContext.registerModelObject(moduleComponent.getComponentImplementation());
+ } catch (ConfigurationLoadException e) {
+ throw new UnsupportedOperationException();
+ } catch (ConfigurationException e) {
+ throw new UnsupportedOperationException();
+ }
+ } finally {
+ Thread.currentThread().setContextClassLoader(oldCl);
+ }
+
+ moduleContext.fireEvent(EventContext.MODULE_START, null);
+
+ // add a valve to this context's pipeline that will associate the request with the runtime
+ Valve valve = new TuscanyValve(moduleContext);
+ ctx.getPipeline().addValve(valve);
+
+ // add the web service servlet wrapper
+ addWebServiceWrapper(ctx);
+
+ // add the RuntimeContext in as a servlet context parameter
+ ServletContext servletContext = ctx.getServletContext();
+ servletContext.setAttribute(TUSCANY_RUNTIME_NAME, runtime);
+ servletContext.setAttribute(MODULE_COMPONENT_NAME, moduleContext);
+ }
+
+ private void stopContext(Context ctx) {
+ if (moduleContext!=null) {
+ moduleContext.fireEvent(EventContext.MODULE_START, null);
+ }
+ // todo unload module component from runtime
+ }
+
+ private static void addWebServiceWrapper(Context ctx) {
+ // todo this should not depend on axis2, we need an API in the model for embedders
+ // todo should only add this servlet if we need it
+ // todo servlet implementation should be determined by the binding implementation
+ // todo should get path from entry point definition and not hard code to /services
+
+ Class<WebServiceEntryPointServlet> servletClass = WebServiceEntryPointServlet.class;
+ StandardWrapper wrapper = new StandardWrapper();
+ wrapper.setName("TuscanyAxis2EntryPointServlet");
+ wrapper.setLoader(new ContainerLoader(servletClass.getClassLoader()));
+ wrapper.setServletClass(servletClass.getName());
+ ctx.addChild(wrapper);
+ ctx.addServletMapping("/services/*", wrapper.getName());
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/TuscanyHost.java b/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/TuscanyHost.java
new file mode 100644
index 0000000000..b6e6db6da7
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/TuscanyHost.java
@@ -0,0 +1,162 @@
+/**
+ *
+ * Copyright 2005 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.tomcat;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.catalina.Container;
+import org.apache.catalina.LifecycleException;
+import org.apache.catalina.core.StandardContext;
+import org.apache.catalina.core.StandardHost;
+import org.apache.catalina.util.StringManager;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.tuscany.common.monitor.impl.NullMonitorFactory;
+import org.apache.tuscany.common.resource.ResourceLoader;
+import org.apache.tuscany.common.resource.impl.ResourceLoaderImpl;
+import org.apache.tuscany.core.builder.RuntimeConfigurationBuilder;
+import org.apache.tuscany.core.builder.impl.DefaultWireBuilder;
+import org.apache.tuscany.core.config.ConfigurationLoadException;
+import org.apache.tuscany.core.config.ModuleComponentConfigurationLoader;
+import org.apache.tuscany.core.config.impl.ModuleComponentConfigurationLoaderImpl;
+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.runtime.RuntimeContext;
+import org.apache.tuscany.core.runtime.RuntimeContextImpl;
+import org.apache.tuscany.core.system.builder.SystemComponentContextBuilder;
+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.AssemblyFactoryImpl;
+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;
+
+/**
+ * A Tomcat listener to be attached to a Host container to add SCA runtime functionality.
+ * The listener wraps a Tuscany runtime and listens for container events to detect the
+ * addition and removal of Context children.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TuscanyHost extends StandardHost {
+ private static final String SYSTEM_MODULE_COMPONENT = "org.apache.tuscany.core.system";
+ private static final Log log = LogFactory.getLog(TuscanyHost.class);
+ private static final StringManager sm = StringManager.getManager("org.apache.tuscany.tomcat");
+
+ private RuntimeContext runtime;
+ private AssemblyModelLoader modelLoader;
+ private AssemblyFactory modelFactory;
+ private ResourceLoader systemLoader;
+
+ public synchronized void start() throws LifecycleException {
+ startRuntime();
+ super.start();
+ }
+
+ public synchronized void stop() throws LifecycleException {
+ super.stop();
+ stopRuntime();
+ }
+
+ private void startRuntime() {
+ systemLoader = new ResourceLoaderImpl(getClass().getClassLoader());
+
+ // Create an assembly model factory
+ modelFactory = new AssemblyFactoryImpl();
+
+ // Create an assembly model loader
+ List<SCDLModelLoader> scdlLoaders=new ArrayList<SCDLModelLoader>();
+ scdlLoaders.add(new SystemSCDLModelLoader());
+ modelLoader = new SCDLAssemblyModelLoaderImpl(scdlLoaders);
+
+ // Create an assembly model context
+ AssemblyModelContext modelContext = new AssemblyModelContextImpl(modelFactory, modelLoader, systemLoader);
+
+ // Load the system module component
+ ModuleComponentConfigurationLoader loader = new ModuleComponentConfigurationLoaderImpl(modelContext);
+ ModuleComponent systemModuleComponent;
+ try {
+ systemModuleComponent = loader.loadSystemModuleComponent(SYSTEM_MODULE_COMPONENT, SYSTEM_MODULE_COMPONENT);
+ } catch (ConfigurationLoadException e) {
+ log.warn(sm.getString("runtime.loadSystemFailed"), e);
+ return;
+ }
+
+ List<RuntimeConfigurationBuilder> configBuilders = new ArrayList();
+ configBuilders.add((new SystemComponentContextBuilder()));
+ configBuilders.add(new SystemEntryPointBuilder());
+ configBuilders.add(new SystemExternalServiceBuilder());
+
+ runtime = new RuntimeContextImpl(new NullMonitorFactory(), scdlLoaders, configBuilders, new DefaultWireBuilder());
+ runtime.start();
+
+ try {
+ SystemAggregateContext systemContext = runtime.getSystemContext();
+ systemContext.registerModelObject(systemModuleComponent);
+
+ // Get the aggregate context representing the system module component
+ AggregateContext systemModuleComponentContext = (AggregateContext) systemContext.getContext(SYSTEM_MODULE_COMPONENT);
+ systemModuleComponentContext.registerModelObject(systemModuleComponent.getComponentImplementation());
+ systemModuleComponentContext.fireEvent(EventContext.MODULE_START, null);
+ } catch (Exception e) {
+ log.warn(sm.getString("runtime.registerSystemFailed"), e);
+ runtime.stop();
+ runtime = null;
+ return;
+ }
+
+ log.info(sm.getString("runtime.started"));
+ }
+
+ private void stopRuntime() {
+ if (runtime == null) {
+ return;
+ }
+
+ runtime.stop();
+ runtime = null;
+ log.info(sm.getString("runtime.stopped"));
+ }
+
+ public synchronized void addChild(Container child) {
+ if (!(child instanceof StandardContext)) {
+ throw new IllegalArgumentException(sm.getString("tuscanyHost.notContext"));
+ }
+ StandardContext ctx = (StandardContext) child;
+ ctx.addLifecycleListener(new TuscanyContextListener(runtime, modelFactory, modelLoader, systemLoader));
+ super.addChild(child);
+ }
+
+ public String toString() {
+
+ StringBuffer sb = new StringBuffer(132);
+ if (getParent() != null) {
+ sb.append(getParent().toString()).append('.');
+ }
+ sb.append("TuscanyHost[").append(getName()).append(']');
+ return (sb.toString());
+
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/TuscanyValve.java b/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/TuscanyValve.java
new file mode 100644
index 0000000000..d5383b64ea
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/TuscanyValve.java
@@ -0,0 +1,118 @@
+/**
+ *
+ * Copyright 2005 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.tomcat;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.catalina.connector.Request;
+import org.apache.catalina.connector.Response;
+import org.apache.catalina.valves.ValveBase;
+import org.osoa.sca.CurrentModuleContext;
+import org.osoa.sca.ModuleContext;
+import org.osoa.sca.SCA;
+
+import org.apache.tuscany.core.context.AggregateContext;
+import org.apache.tuscany.core.context.EventContext;
+import org.apache.tuscany.core.context.EventException;
+import org.apache.tuscany.core.context.webapp.LazyHTTPSessionId;
+
+/**
+ * Valve that can be added to a pipeline to automatically set the SCA environment as each request is processed.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TuscanyValve extends ValveBase {
+ /**
+ * Name of the note that contains the request id
+ */
+ private static final String REQUEST_ID = "org.apache.tuscany.tomcat.REQUEST_ID";
+
+ private static final ContextBinder BINDER = new ContextBinder();
+
+ private final AggregateContext moduleComponentContext;
+
+ public TuscanyValve(AggregateContext moduleComponentContext) {
+ this.moduleComponentContext = moduleComponentContext;
+ }
+
+ public void invoke(Request request, Response response) throws IOException, ServletException {
+ Object oldRequestId = request.getNote(REQUEST_ID);
+ ModuleContext oldContext = CurrentModuleContext.getContext();
+
+ // bind the current module context to the thread for use by CurrentModuleContext
+ BINDER.setContext((ModuleContext) moduleComponentContext);
+ try {
+ if (oldRequestId != null) {
+ // the request has already been started, just invoke the next valve
+ next.invoke(request, response);
+ } else {
+ // tell the runtime a new request is starting
+ Object requestId = new Object();
+ // jfm
+ if (request.getSession(false) != null) {
+ // A session is already active
+ moduleComponentContext
+ .fireEvent(EventContext.SESSION_NOTIFY, ((HttpServletRequest) request).getSession(true));
+ } else {
+ // Create a lazy wrapper since a session is not yet active
+ moduleComponentContext.fireEvent(EventContext.SESSION_NOTIFY, new LazyHTTPSessionId(
+ (HttpServletRequest) request));
+ }
+ // jfm
+ try {
+ moduleComponentContext.fireEvent(EventContext.REQUEST_START, requestId);
+ } catch (Exception e) {
+ throw new ServletException(e.getMessage(), e);
+ }
+ request.setNote(REQUEST_ID, requestId);
+
+ try {
+ // invoke the next valve in the pipeline
+ next.invoke(request, response);
+ } finally {
+ // notify the runtime the request is ending
+ request.removeNote(REQUEST_ID);
+ try {
+ moduleComponentContext.fireEvent(EventContext.REQUEST_END, requestId);
+ } catch (Exception e) {
+ // the application already did its work, log and ignore
+ // todo log this exception
+ }
+ }
+ }
+ } finally {
+ // restore the previous module context onto the thread
+ BINDER.setContext(oldContext);
+ }
+ }
+
+ private static class ContextBinder extends SCA {
+ public void setContext(ModuleContext context) {
+ setModuleContext(context);
+ }
+
+ public void start() {
+ throw new AssertionError();
+ }
+
+ public void stop() {
+ throw new AssertionError();
+ }
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/lifecycle/listener/BootstrapConfigurationException.java b/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/lifecycle/listener/BootstrapConfigurationException.java
new file mode 100644
index 0000000000..39f24cba8f
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/lifecycle/listener/BootstrapConfigurationException.java
@@ -0,0 +1,41 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.tomcat.lifecycle.listener;
+
+import org.apache.tuscany.common.TuscanyException;
+
+/**
+ * Signals an exception booting the Tuscany runtime hosted in a Tomcat instance
+ *
+ * @version $Rev$ $Date$
+ */
+public class BootstrapConfigurationException extends TuscanyException {
+
+ public BootstrapConfigurationException() {
+ super();
+ }
+
+ public BootstrapConfigurationException(String message) {
+ super(message);
+ }
+
+ public BootstrapConfigurationException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public BootstrapConfigurationException(Throwable cause) {
+ super(cause);
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/lifecycle/listener/RuntimeBootstrap.java b/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/lifecycle/listener/RuntimeBootstrap.java
new file mode 100644
index 0000000000..16cad1cb1b
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/lifecycle/listener/RuntimeBootstrap.java
@@ -0,0 +1,113 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.tomcat.lifecycle.listener;
+
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.List;
+
+import javax.naming.Context;
+import javax.naming.Name;
+import javax.naming.RefAddr;
+import javax.naming.Reference;
+import javax.naming.spi.ObjectFactory;
+
+import org.apache.tuscany.common.monitor.MonitorFactory;
+import org.apache.tuscany.core.builder.RuntimeConfigurationBuilder;
+import org.apache.tuscany.core.config.ModuleComponentConfigurationLoader;
+import org.apache.tuscany.core.config.JavaIntrospectionHelper;
+import org.apache.tuscany.core.system.builder.SystemComponentContextBuilder;
+import org.apache.tuscany.core.system.builder.SystemEntryPointBuilder;
+import org.apache.tuscany.core.system.builder.SystemExternalServiceBuilder;
+import org.apache.tuscany.core.runtime.RuntimeContext;
+import org.apache.tuscany.core.runtime.RuntimeContextImpl;
+
+/**
+ * Bootstraps an SCA runtime hosted by a Tomcat instance. The runtime will be bound to JNDI and accessed by
+ * {@link org.apache.tuscany.tomcat.lifecycle.listener.WebAppLifecycleListener}s that deploy web archives as module
+ * components.
+ * <p>
+ * Tomcat is configured by adding the following to <code>server.xml</code> under the
+ * <code>GlobalNamingResources</code> element:
+ *
+ * <pre>
+ * &lt;Resource name=&quot;TuscanyRuntime&quot; auth=&quot;Container&quot; type=&quot;org.apache.tuscany.core.runtime.RuntimeContext&quot;
+ * description=&quot;Tuscany Runtime&quot;
+ * factory=&quot; org.apache.tuscany.tomcat.lifecycle.listener.RuntimeBootstrap&quot;
+ * monitor=&quot;[monitor factory]&quot; loader=&quot;[configuration loader]&quot;/&gt;
+ * </pre>
+ *
+ * @version $Rev$ $Date$
+ */
+public class RuntimeBootstrap implements ObjectFactory {
+
+ public static final String RUNTIME_NAME = "TuscanyRuntime";
+
+ public RuntimeBootstrap() {
+ }
+
+ public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?, ?> environment)
+ throws BootstrapConfigurationException {
+ if (!RUNTIME_NAME.equals(name)) {
+ throw new BootstrapConfigurationException("Tuscany Runtime must be configured with JNDI address of " + RUNTIME_NAME);
+ }
+ MonitorFactory monitorFactory = null;
+ ModuleComponentConfigurationLoader configurationLoader = null;
+
+ Reference ref = (Reference) obj;
+ if (!RuntimeContext.class.getName().equals(ref.getClassName())) {
+ throw new BootstrapConfigurationException("Invalid runtime configuration");
+ }
+ RefAddr monitorAddr = ref.get("monitor");
+ RefAddr loaderAddr = ref.get("loader");
+ if (loaderAddr == null) {
+ throw new BootstrapConfigurationException("No configuration laoder specified in Tomcat configuration");
+ }
+ if (monitorAddr != null) {
+ try {
+ Class monitorFactoryClass = JavaIntrospectionHelper.loadClass(monitorAddr.getContent().toString());
+ monitorFactory = (MonitorFactory) monitorFactoryClass.newInstance();
+ } catch (ClassNotFoundException e) {
+ throw new BootstrapConfigurationException("Unable to find monitor factory class specified in Tomcat configuration", e);
+ } catch (InstantiationException e) {
+ throw new BootstrapConfigurationException("Error initializing monitor factory in Tomcat configuration", e);
+ } catch (IllegalAccessException e) {
+ throw new BootstrapConfigurationException("Error initializing monitor factory in Tomcat configuration", e);
+ }
+ }
+// try {
+// Class configurationLoaderClass = JavaIntrospectionHelper.loadClass(loaderAddr.getContent().toString());
+// configurationLoader = (ConfigurationLoader) configurationLoaderClass.newInstance();
+// } catch (ClassNotFoundException e) {
+// throw new BootstrapConfigurationException("Unable to find configuration loader class specified in Tomcat configuration", e);
+// } catch (InstantiationException e) {
+// throw new BootstrapConfigurationException("Error initializing configuration loader in Tomcat configuration", e);
+// } catch (IllegalAccessException e) {
+// throw new BootstrapConfigurationException("Error initializing configuration loader in Tomcat configuration", e);
+// }
+ // create the SCA Runtime and have it bound in the global JNDI context
+ return new RuntimeContextImpl(monitorFactory, null, createBuilders(),null);
+ }
+
+ /**
+ * Creates a collection of bootstrap builders
+ */
+ private List<RuntimeConfigurationBuilder> createBuilders() {
+ List<RuntimeConfigurationBuilder> builders = new ArrayList();
+ builders.add((new SystemComponentContextBuilder()));
+ builders.add(new SystemEntryPointBuilder());
+ builders.add(new SystemExternalServiceBuilder());
+ return builders;
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/lifecycle/listener/TomcatServerLifecycleListener.java b/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/lifecycle/listener/TomcatServerLifecycleListener.java
new file mode 100644
index 0000000000..0da95bde17
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/lifecycle/listener/TomcatServerLifecycleListener.java
@@ -0,0 +1,40 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.tomcat.lifecycle.listener;
+
+import org.apache.catalina.LifecycleEvent;
+import org.apache.catalina.LifecycleListener;
+
+/**
+ * This class manages the lifecycle of the SCA container in Tomcat.
+ * @deprecated
+ */
+public class TomcatServerLifecycleListener implements LifecycleListener {
+ //private CoreModuleContext containerModuleContext;
+
+ /**
+ * Constructor
+ */
+ public TomcatServerLifecycleListener() {
+ }
+
+ /**
+ * @see org.apache.catalina.LifecycleListener#lifecycleEvent(org.apache.catalina.LifecycleEvent)
+ */
+ public void lifecycleEvent(LifecycleEvent lifecycleEvent) {
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/lifecycle/listener/TomcatWebAppLifecycleListener.java b/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/lifecycle/listener/TomcatWebAppLifecycleListener.java
new file mode 100644
index 0000000000..d1e7d8de39
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/lifecycle/listener/TomcatWebAppLifecycleListener.java
@@ -0,0 +1,249 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.tomcat.lifecycle.listener;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.catalina.Context;
+import org.apache.catalina.Lifecycle;
+import org.apache.catalina.LifecycleEvent;
+import org.apache.catalina.LifecycleListener;
+import org.apache.catalina.deploy.FilterDef;
+import org.apache.catalina.deploy.FilterMap;
+import org.apache.tuscany.common.monitor.impl.NullMonitorFactory;
+import org.apache.tuscany.common.resource.ResourceLoader;
+import org.apache.tuscany.common.resource.impl.ResourceLoaderImpl;
+import org.apache.tuscany.core.builder.RuntimeConfigurationBuilder;
+import org.apache.tuscany.core.builder.impl.DefaultWireBuilder;
+import org.apache.tuscany.core.config.ModuleComponentConfigurationLoader;
+import org.apache.tuscany.core.config.impl.ModuleComponentConfigurationLoaderImpl;
+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.webapp.HTTPSessionExpirationListener;
+import org.apache.tuscany.core.context.webapp.TuscanyRequestFilter;
+import org.apache.tuscany.core.context.webapp.TuscanyWebAppRuntime;
+import org.apache.tuscany.core.runtime.RuntimeContext;
+import org.apache.tuscany.core.runtime.RuntimeContextImpl;
+import org.apache.tuscany.core.system.builder.SystemComponentContextBuilder;
+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.AssemblyFactoryImpl;
+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;
+import org.osoa.sca.ServiceRuntimeException;
+
+//FIXME This is a temporary hack to bootstrap the runtime in a Tomcat environment and do some bringup testing, the real bootstrap code is
+// still under construction
+
+/**
+ * Responsible for initializing web applications as module components in a
+ * Tomcat instance. When a web app is being loaded in Tomcat, this listener
+ * receives a callback to register a corresponding module component and set up
+ * the appropriate Servlet filters in the web context.
+ * <p/>
+ * Note that Tomcat loads this class in the standard (common/lib) classloader
+ * even though the context classloader is that of the web app being loaded.
+ * Consequently, the transitive closure of class references must not include
+ * <tt>ModuleContext</tt> or <tt>ModuleManager</tt>
+ * <p/>
+ * TODO decide if we want to set this up as a Tomcat listener or as a web app
+ * listener Setting this up as a web app listener allows users to set the
+ * context path, avoiding a performance hit for SCA event processing in contexts
+ * where it is not used. The downside is the potential for user error. For
+ * example, SCA event filters must be manually configured. We probably should
+ * provide both options
+ * FIXME fix the exception handling
+ */
+public class TomcatWebAppLifecycleListener implements LifecycleListener {
+
+ private final static String SYSTEM_MODULE_COMPONENT = "org.apache.tuscany.core.system";
+
+ /**
+ * Constructor
+ */
+ public TomcatWebAppLifecycleListener() {
+ }
+
+ /**
+ * Callback for receiving web application events. When a web app containing
+ * an SCA configuration is initialized, a module component is created and
+ * appropriate SCA filters are set for in the web context. If a web app stop
+ * event is received, the corresponding module component is deregistered from
+ * the system.
+ */
+ public void lifecycleEvent(LifecycleEvent event) {
+ String lifecycleEventType = event.getType();
+ Object lifecycleEventSource = event.getSource();
+
+ if (Lifecycle.START_EVENT.equals(lifecycleEventType) && lifecycleEventSource instanceof Context) {
+
+ // The web app is starting
+ Context context = (Context) lifecycleEventSource;
+ try {
+
+ // Get the application classloader
+ ClassLoader applicationClassLoader = Thread.currentThread().getContextClassLoader();
+ ResourceLoader resourceLoader = new ResourceLoaderImpl(applicationClassLoader);
+
+ // Check if the web app contains an sca.module file
+ URL url;
+ try {
+ url = resourceLoader.getResource("sca.module");
+ } catch (IOException e) {
+ url = null;
+ }
+ if (url != null) {
+ // The Web app has an sca.module file
+ // Get the module component name from the context
+ String moduleComponentName = context.getPath().substring(1);
+ try {
+
+ // Create an assembly model factory
+ AssemblyFactory modelFactory=new AssemblyFactoryImpl();
+
+ // Create an assembly model loader
+ List<SCDLModelLoader> scdlLoaders=new ArrayList<SCDLModelLoader>();
+ scdlLoaders.add(new SystemSCDLModelLoader());
+ AssemblyModelLoader modelLoader=new SCDLAssemblyModelLoaderImpl(scdlLoaders);
+
+ // Create an assembly model context
+ AssemblyModelContext modelContext = new AssemblyModelContextImpl(modelFactory, modelLoader, resourceLoader);
+
+ // Create system configuration builders
+ List<RuntimeConfigurationBuilder> configBuilders = new ArrayList();
+ configBuilders.add((new SystemComponentContextBuilder()));
+ configBuilders.add(new SystemEntryPointBuilder());
+ configBuilders.add(new SystemExternalServiceBuilder());
+
+ // Create a runtime context and start it
+ RuntimeContext runtimeContext = new RuntimeContextImpl(new NullMonitorFactory(), scdlLoaders, configBuilders,new DefaultWireBuilder());
+ runtimeContext.start();
+
+ // Get the system context
+ AggregateContext systemContext = runtimeContext.getSystemContext();
+
+ // Load the system module component
+ ModuleComponentConfigurationLoader loader = new ModuleComponentConfigurationLoaderImpl(modelContext);
+ ModuleComponent systemModuleComponent = loader.loadSystemModuleComponent(SYSTEM_MODULE_COMPONENT, SYSTEM_MODULE_COMPONENT);
+
+ // Register it with the system context
+ systemContext.registerModelObject(systemModuleComponent);
+
+ // Get the aggregate context representing the system module component
+ AggregateContext systemModuleComponentContext = (AggregateContext) systemContext.getContext(SYSTEM_MODULE_COMPONENT);
+ systemModuleComponentContext.registerModelObject(systemModuleComponent.getComponentImplementation());
+ systemModuleComponentContext.fireEvent(EventContext.MODULE_START, null);
+
+ // Load the SCDL configuration of the application module
+ String uri = context.getPath().substring(1);
+ ModuleComponent moduleComponent = loader.loadModuleComponent(moduleComponentName, uri);
+
+ // Register it under the root application context
+ runtimeContext.getRootContext().registerModelObject(moduleComponent);
+ AggregateContext moduleContext=(AggregateContext)runtimeContext.getContext(moduleComponent.getName());
+ moduleContext.registerModelObject(moduleComponent.getComponentImplementation());
+
+ // Create a Tuscany runtime and store it in the servlet
+ // context
+ TuscanyWebAppRuntime tuscanyRuntime = new TuscanyWebAppRuntime(moduleContext);
+ context.getServletContext().setAttribute(TuscanyWebAppRuntime.class.getName(), tuscanyRuntime);
+
+ // Start the runtime and the module component context
+ tuscanyRuntime.start();
+ try {
+ //moduleContext.start();
+
+ moduleContext.fireEvent(EventContext.MODULE_START, null);
+
+ } finally {
+ tuscanyRuntime.stop();
+ }
+
+ // Set up the SCA web app filter and listener
+ FilterDef def = new FilterDef();
+ def.setDescription("SCA Filter");
+ def.setFilterClass(TuscanyRequestFilter.class.getName());
+ def.setFilterName("__modContext");
+ def.setDisplayName("SCA Filter");
+ FilterMap map = new FilterMap();
+ map.setFilterName("__modContext");
+ map.setURLPattern("/*");
+ context.addFilterDef(def);
+ context.addFilterMap(map);
+ context.addApplicationListener(HTTPSessionExpirationListener.class.getName());
+
+ } catch (CoreRuntimeException e) {
+ throw new ServiceRuntimeException(e);
+ } catch (Exception e) {
+ throw new ServiceRuntimeException(e);
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ } else if (Lifecycle.STOP_EVENT.equals(lifecycleEventType) && lifecycleEventSource instanceof Context) {
+
+ // The web app is stopping
+ Context context = (Context) lifecycleEventSource;
+ try {
+
+ // Get the tuscany runtime from the servlet context
+ // If the servlet context contains a tuscany runtime then this is a
+ // Tuscany app
+ TuscanyWebAppRuntime tuscanyRuntime = (TuscanyWebAppRuntime) context.getServletContext().getAttribute(
+ TuscanyWebAppRuntime.class.getName());
+ if (tuscanyRuntime != null) {
+
+ // Get the module component name from the servlet context
+ try {
+ // Start the runtime
+ tuscanyRuntime.start();
+ try {
+ // Stop the module context
+ AggregateContext aggregateContext = tuscanyRuntime.getModuleComponentContext();
+ aggregateContext.fireEvent(EventContext.MODULE_STOP, null);
+ aggregateContext.stop();
+ } finally {
+
+ // Stop the runtime
+ tuscanyRuntime.stop();
+
+ // Cleanup the servlet context
+ context.getServletContext().removeAttribute(TuscanyWebAppRuntime.class.getName());
+ }
+
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/lifecycle/listener/WebAppLifecycleListener.java b/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/lifecycle/listener/WebAppLifecycleListener.java
new file mode 100644
index 0000000000..0e9a80f13d
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/lifecycle/listener/WebAppLifecycleListener.java
@@ -0,0 +1,152 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.tomcat.lifecycle.listener;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.apache.catalina.Context;
+import org.apache.catalina.Lifecycle;
+import org.apache.catalina.LifecycleEvent;
+import org.apache.catalina.LifecycleListener;
+import org.apache.catalina.deploy.FilterDef;
+import org.apache.catalina.deploy.FilterMap;
+import org.apache.tuscany.common.TuscanyRuntimeException;
+import org.apache.tuscany.core.config.ConfigurationException;
+import org.apache.tuscany.core.context.AggregateContext;
+import org.apache.tuscany.core.context.EventContext;
+import org.apache.tuscany.core.context.webapp.HTTPSessionExpirationListener;
+import org.apache.tuscany.core.context.webapp.TuscanyRequestFilter;
+import org.apache.tuscany.core.context.webapp.TuscanyWebAppRuntime;
+import org.apache.tuscany.core.runtime.RuntimeContext;
+import org.apache.tuscany.core.runtime.RuntimeMonitor;
+import org.apache.tuscany.model.assembly.ModuleComponent;
+
+/**
+ * Responsible for initializing web applications as module components in a Tomcat instance. When a web app is being
+ * loaded in Tomcat, this listener receives a callback to register a corresponding module component and set up the
+ * appropriate Servlet filters in the web context.
+ * <p>
+ * Note that Tomcat loads this class in the standard (common/lib) classloader even though the context classloader is
+ * that of the web app being loaded.
+ */
+public class WebAppLifecycleListener implements LifecycleListener {
+
+ private RuntimeContext runtime;
+
+ private RuntimeMonitor monitor;
+
+ // ----------------------------------
+ // Constructors
+ // ----------------------------------
+
+ public WebAppLifecycleListener() {
+ // locate runtime in the global naming context
+ javax.naming.Context context = null;
+ try {
+ context = (javax.naming.Context) (new InitialContext()).lookup("java:/");
+ runtime = (RuntimeContext) context.lookup(RuntimeBootstrap.RUNTIME_NAME);
+ monitor = runtime.getMonitorFactory().getMonitor(RuntimeMonitor.class);
+ } catch (NamingException e) {
+ // FIXME need bootstrap logging;
+ return;
+ }
+ }
+
+ /**
+ * Callback for receiving web application events. When a web app containing an SCA configuration is initialized, a
+ * module component is created and appropriate SCA filters are set for in the web context. If a web app stop event
+ * is received, the corresponding module component is deregistered from the system.
+ */
+ public void lifecycleEvent(LifecycleEvent event) {
+ String lifecycleEventType = event.getType();
+ Object lifecycleEventSource = event.getSource();
+
+ if (Lifecycle.START_EVENT.equals(lifecycleEventType) && lifecycleEventSource instanceof Context) {
+ // The web app is starting
+ Context context = (Context) lifecycleEventSource;
+ String name = context.getPath().substring(1);
+ try {
+ ModuleComponent moduleComponent = null;// FIXME runtime.loadModuleComponent(name, "sca.module");
+ if (moduleComponent == null) {
+ return; // not an SCA module component
+ }
+ // create the module component
+ runtime.registerModelObject(moduleComponent);
+ AggregateContext aggregateContext = (AggregateContext) runtime.getContext(moduleComponent.getName());
+ TuscanyWebAppRuntime tuscanyRuntime = new TuscanyWebAppRuntime(aggregateContext);
+ context.getServletContext().setAttribute(TuscanyWebAppRuntime.class.getName(), tuscanyRuntime);
+ // Start the runtime and the module component context
+ tuscanyRuntime.start();
+ try {
+ aggregateContext.start();
+ aggregateContext.fireEvent(EventContext.MODULE_START, null);
+ } finally {
+ tuscanyRuntime.stop();
+ }
+ // Set up the SCA web app filter and listener
+ FilterDef def = new FilterDef();
+ def.setDescription("SCA Filter");
+ def.setFilterClass(TuscanyRequestFilter.class.getName());
+ def.setFilterName("__modContext");
+ def.setDisplayName("SCA Filter");
+ FilterMap map = new FilterMap();
+ map.setFilterName("__modContext");
+ map.setURLPattern("/*");
+ context.addFilterDef(def);
+ context.addFilterMap(map);
+ context.addApplicationListener(HTTPSessionExpirationListener.class.getName());
+ } catch (ConfigurationException e) {
+ e.addContextName(name);
+ monitor.log(e);
+ return;
+ } catch (TuscanyRuntimeException e) {
+ e.addContextName(name);
+ monitor.log(e);
+ return;
+ }
+ } else if (Lifecycle.STOP_EVENT.equals(lifecycleEventType) && lifecycleEventSource instanceof Context) {
+ // The web app is stopping
+ Context context = (Context) lifecycleEventSource;
+ // Get the tuscany runtime from the servlet context
+ TuscanyWebAppRuntime tuscanyRuntime = (TuscanyWebAppRuntime) context.getServletContext().getAttribute(
+ TuscanyWebAppRuntime.class.getName());
+ if (tuscanyRuntime == null) {
+ return; // not an SCA module
+ }
+ try {
+ // Stop the module context
+ tuscanyRuntime.start();
+ AggregateContext aggregateContext = tuscanyRuntime.getModuleComponentContext();
+ aggregateContext.fireEvent(EventContext.MODULE_STOP, null);
+ aggregateContext.stop();
+ } catch (TuscanyRuntimeException e) {
+ monitor.log(e);
+ } finally {
+ try {
+ tuscanyRuntime.stop();
+ } catch (TuscanyRuntimeException e) {
+ monitor.log(e);
+ } finally {
+ // Cleanup the servlet context
+ context.getServletContext().removeAttribute(TuscanyWebAppRuntime.class.getName());
+ }
+ }
+
+ }
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/main/resources/org/apache/tuscany/tomcat/LocalStrings.properties b/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/main/resources/org/apache/tuscany/tomcat/LocalStrings.properties
new file mode 100644
index 0000000000..213545ecee
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/main/resources/org/apache/tuscany/tomcat/LocalStrings.properties
@@ -0,0 +1,20 @@
+# Copyright (c) 2006 The Apache Software Foundation or its licensors, as applicable.
+#
+# 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.
+
+runtime.loadSystemFailed = Error loading system configuration:
+runtime.registerSystemFailed = Error registering system configuration:
+runtime.started = Started Tuscany runtime
+runtime.stopped = Stopped Tuscany runtime
+
+tuscanyHost.notContext = Child of a TuscanyHost must be a StandardContext \ No newline at end of file
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/main/resources/org/apache/tuscany/tomcat/Messages.properties b/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/main/resources/org/apache/tuscany/tomcat/Messages.properties
new file mode 100644
index 0000000000..f926ca6488
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/main/resources/org/apache/tuscany/tomcat/Messages.properties
@@ -0,0 +1,39 @@
+# Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
+#
+# 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.
+# ====================================================================
+# To code developer:
+# Do NOT change the properties between this line and the
+# "%%% END OF TRANSLATED PROPERTIES %%%" line.
+# Make a new property name, append to the end of the file and change
+# the code to use the new property.
+# ====================================================================
+
+# =====================================================================
+# %%% END OF TRANSLATED PROPERTIES %%%
+# =====================================================================
+# NLS_MESSAGEFORMAT_ALL
+
+SCA_STARTING =Tuscany: Starting SCA runtime.
+SCA_STARTED =Tuscany: Started SCA runtime.
+SCA_STOPPING =Tuscany: Stopping SCA runtime.
+SCA_STOPPED =Tuscany: Stopped SCA runtime.
+SCA_STARTING_MODULE =Tuscany: Starting SCA module component {0}.
+SCA_LOADED_MODULE =Tuscany: Loaded SCA module {0}.
+SCA_STARTED_MODULE =Tuscany: Started SCA module component {0}.
+SCA_STOPPING_MODULE =Tuscany: Stopping SCA module component {0}.
+SCA_STOPPED_MODULE =Tuscany: Stopped SCA module component {0}.
+SCA_START_MODULE_FAILED =Tuscany: Error starting SCA module component {0}: {1}.
+SCA_STOP_MODULE_FAILED =Tuscany: Error stopping SCA module component {0}: {1}.
+SCA_START_WEBAPP_FAILED =Tuscany: Error starting Web application {0}: {1}.
+SCA_STOP_WEBAPP_FAILED =Tuscany: Error stopping Web application {0}: {1}. \ No newline at end of file
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/test/java/org/apache/tuscany/tomcat/integration/AbstractTomcatTest.java b/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/test/java/org/apache/tuscany/tomcat/integration/AbstractTomcatTest.java
new file mode 100644
index 0000000000..1e9529b965
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/test/java/org/apache/tuscany/tomcat/integration/AbstractTomcatTest.java
@@ -0,0 +1,250 @@
+/**
+ *
+ * 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.tomcat.integration;
+
+import junit.framework.TestCase;
+import org.apache.catalina.Host;
+import org.apache.catalina.Globals;
+import org.apache.catalina.connector.Connector;
+import org.apache.catalina.connector.Request;
+import org.apache.catalina.connector.Response;
+import org.apache.catalina.core.StandardEngine;
+import org.apache.catalina.core.ApplicationFilterFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.OutputStream;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Enumeration;
+import java.util.Collections;
+import javax.servlet.ServletInputStream;
+import javax.servlet.ServletOutputStream;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class AbstractTomcatTest extends TestCase {
+ protected Host host;
+ protected MockRequest request;
+ protected MockResponse response;
+ protected StandardEngine engine;
+
+ protected void setupTomcat(File baseDir, Host host) throws Exception {
+ File appBase = new File(baseDir, "webapps").getCanonicalFile();
+
+ // Configure a Tomcat Engine
+ engine = new StandardEngine();
+ engine.setName("Catalina");
+ engine.setDefaultHost("localhost");
+ engine.setBaseDir(baseDir.getAbsolutePath());
+
+ this.host = host;
+ host.setName("localhost");
+ host.setAppBase(appBase.getAbsolutePath());
+ engine.addChild(host);
+
+ // build a empty request/response
+ Connector connector = new Connector("HTTP/1.1");
+ request = new MockRequest();
+ request.setConnector(connector);
+ response = new MockResponse();
+ request.setResponse(response);
+ request.setMethod("POST");
+ request.setScheme("http");
+ }
+
+ public static class MockRequest extends Request {
+ private String method;
+ private String scheme;
+ private String requestURI;
+ private String contentType;
+ private Map<String,String> headers = new HashMap();
+ private ServletInputStream inputStream;
+
+ public void setScheme(String scheme) {
+ this.scheme = scheme;
+ }
+
+ public void setMethod(String method) {
+ this.method = method;
+ }
+
+ public void setRequestURI(String requestURI) {
+ this.requestURI = requestURI;
+ }
+
+ public String getScheme() {
+ return scheme;
+ }
+
+ public String getMethod() {
+ return method;
+ }
+
+ public int getServerPort() {
+ return 80;
+ }
+
+ public String getServerName() {
+ return "localhost";
+ }
+
+ public String getRequestURI() {
+ return requestURI;
+ }
+
+ public void setAttribute(String name, Object value) {
+ if (name.startsWith("org.apache.tomcat.")) {
+ return;
+ }
+ super.setAttribute(name, value);
+ }
+
+ public Object getAttribute(String name) {
+ if (name.equals(Globals.DISPATCHER_TYPE_ATTR)) {
+ return (dispatcherType == null)
+ ? ApplicationFilterFactory.REQUEST_INTEGER
+ : dispatcherType;
+ } else if (name.equals(Globals.DISPATCHER_REQUEST_PATH_ATTR)) {
+ return (requestDispatcherPath == null)
+ ? getRequestPathMB().toString()
+ : requestDispatcherPath.toString();
+ }
+
+ return attributes.get(name);
+ }
+
+ public String getHeader(String name) {
+ return headers.get(name);
+ }
+
+ public Enumeration getHeaderNames() {
+ return Collections.enumeration(headers.keySet());
+ }
+
+ public void setContentType(String contentType) {
+ this.contentType = contentType;
+ }
+
+ public String getContentType() {
+ return contentType;
+ }
+
+ public ServletInputStream getInputStream() throws IOException {
+ return inputStream;
+ }
+
+ public InputStream getStream() {
+ return inputStream;
+ }
+
+ public void setStream(ServletInputStream stream) {
+ inputStream = stream;
+ }
+ }
+
+ public static class MockResponse extends Response {
+ private boolean suspended;
+ private String contentType;
+ private int status;
+ private Map headers = new HashMap();
+ private ServletOutputStream outputStream = new MockOutputStream();
+
+ public boolean isCommitted() {
+ return false;
+ }
+
+ public boolean isAppCommitted() {
+ return false;
+ }
+
+ public void sendAcknowledgement() {
+ }
+
+ public void setSuspended(boolean suspended) {
+ this.suspended = suspended;
+ }
+
+ public boolean isSuspended() {
+ return suspended;
+ }
+
+ public void setStatus(int status, String message) {
+ this.status = status;
+ }
+
+ public int getStatus() {
+ return status;
+ }
+
+ public void reset() {
+ }
+
+ public void addHeader(String name, String value) {
+ headers.put(name, value);
+ }
+
+ public String[] getHeaderNames() {
+ return (String[]) headers.keySet().toArray(new String[headers.size()]);
+ }
+
+ public String getContentType() {
+ return contentType;
+ }
+
+ public void setContentType(String contentType) {
+ this.contentType = contentType;
+ }
+
+ public OutputStream getStream() {
+ return outputStream;
+ }
+
+ public ServletOutputStream getOutputStream() throws IOException {
+ return outputStream;
+ }
+ }
+
+ public static class MockInputStream extends ServletInputStream {
+ private final byte[] bytes;
+ private int index;
+
+ public MockInputStream(byte[] bytes) {
+ this.bytes = bytes;
+ }
+
+ public int read() throws IOException {
+ if (index == bytes.length) {
+ return -1;
+ }
+ else {
+ return bytes[index++];
+ }
+ }
+ }
+
+ public static class MockOutputStream extends ServletOutputStream {
+ private ByteArrayOutputStream os = new ByteArrayOutputStream();
+
+ public void write(int b) throws IOException {
+ os.write(b);
+ }
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/test/java/org/apache/tuscany/tomcat/integration/TestServlet.java b/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/test/java/org/apache/tuscany/tomcat/integration/TestServlet.java
new file mode 100644
index 0000000000..d81e6cc081
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/test/java/org/apache/tuscany/tomcat/integration/TestServlet.java
@@ -0,0 +1,50 @@
+/**
+ *
+ * Copyright 2005 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.tomcat.integration;
+
+import java.io.IOException;
+import javax.servlet.GenericServlet;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.ServletException;
+
+import org.osoa.sca.ModuleContext;
+import org.osoa.sca.CurrentModuleContext;
+
+import org.apache.tuscany.core.runtime.RuntimeContext;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class TestServlet extends GenericServlet {
+
+ public void service(ServletRequest servletRequest, ServletResponse servletResponse) throws ServletException, IOException {
+ ModuleContext moduleContext = CurrentModuleContext.getContext();
+ if (moduleContext == null) {
+ throw new ServletException("No module context returned");
+ }
+ String name = moduleContext.getName();
+ if (!"testContext".equals(name)) {
+ throw new ServletException("Invalid module context name: " + name);
+ }
+
+ Object runtime = getServletContext().getAttribute("org.apache.tuscany.core.runtime.RuntimeContext");
+ if (!(runtime instanceof RuntimeContext)) {
+ throw new ServletException("Runtime not bound to org.apache.tuscany.core.runtime.RuntimeContext");
+ }
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/test/java/org/apache/tuscany/tomcat/integration/TomcatIntegrationTestCase.java b/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/test/java/org/apache/tuscany/tomcat/integration/TomcatIntegrationTestCase.java
new file mode 100644
index 0000000000..4c3b1516aa
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/test/java/org/apache/tuscany/tomcat/integration/TomcatIntegrationTestCase.java
@@ -0,0 +1,109 @@
+/**
+ *
+ * Copyright 2005 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.tomcat.integration;
+
+import org.apache.catalina.Valve;
+import org.apache.catalina.Loader;
+import org.apache.catalina.Wrapper;
+import org.apache.catalina.core.StandardContext;
+import org.apache.catalina.core.StandardWrapper;
+import org.apache.catalina.startup.ContextConfig;
+import org.apache.tuscany.tomcat.TuscanyHost;
+import org.apache.tuscany.tomcat.TuscanyValve;
+import org.apache.tuscany.tomcat.ContainerLoader;
+
+import java.io.File;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class TomcatIntegrationTestCase extends AbstractTomcatTest {
+ protected File app1;
+
+ public void testComponentIntegration() throws Exception {
+ // create the webapp Context
+ StandardContext ctx = new StandardContext();
+ ctx.addLifecycleListener(new ContextConfig());
+ ctx.setName("testContext");
+ ctx.setDocBase(app1.getAbsolutePath());
+
+ // define our test servlet
+ Loader loader = new ContainerLoader(TestServlet.class.getClassLoader());
+ StandardWrapper wrapper = new StandardWrapper();
+ wrapper.setServletClass(TestServlet.class.getName());
+ wrapper.setLoader(loader);
+ ctx.addChild(wrapper);
+
+ host.addChild(ctx);
+ boolean found = false;
+ for (Valve valve: ctx.getPipeline().getValves()) {
+ if (valve instanceof TuscanyValve) {
+ found = true;
+ break;
+ }
+ }
+ assertTrue("TuscanyValve not in pipeline", found);
+
+ request.setContext(ctx);
+ request.setWrapper(wrapper);
+ host.invoke(request, response);
+
+ host.removeChild(ctx);
+ }
+
+ public void testWebServiceIntegration() throws Exception {
+ // create the webapp Context
+ StandardContext ctx = new StandardContext();
+ ctx.addLifecycleListener(new ContextConfig());
+ ctx.setName("testContext");
+ ctx.setDocBase(app1.getAbsolutePath());
+
+ host.addChild(ctx);
+
+ Wrapper wrapper = (Wrapper) ctx.findChild("TuscanyAxis2EntryPointServlet");
+ assertNotNull("No webservice wrapper present", wrapper);
+ request.setContext(ctx);
+ request.setRequestURI("/services/epName");
+ request.setWrapper(wrapper);
+ request.setContentType("text/xml");
+ String xml = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:q0=\"http://helloworldaxis.samples.tuscany.apache.org\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n" +
+ "<soapenv:Body>\n" +
+ "<q0:getGreetings>\n" +
+ "<q0:in0>hello</q0:in0>\n" +
+ "</q0:getGreetings>\n" +
+ "</soapenv:Body>\n" +
+ "</soapenv:Envelope>\n";
+ request.setStream(new MockInputStream(xml.getBytes("UTF-8")));
+ host.invoke(request, response);
+
+ host.removeChild(ctx);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ app1 = new File(getClass().getResource("/app1").toURI());
+ File baseDir = new File(app1, "../../tomcat").getCanonicalFile();
+ setupTomcat(baseDir, new TuscanyHost());
+ engine.start();
+ }
+
+ protected void tearDown() throws Exception {
+ engine.stop();
+ super.tearDown();
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/test/java/org/apache/tuscany/tomcat/integration/TomcatStandaloneTestCase.java b/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/test/java/org/apache/tuscany/tomcat/integration/TomcatStandaloneTestCase.java
new file mode 100644
index 0000000000..b623b2e7b5
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/test/java/org/apache/tuscany/tomcat/integration/TomcatStandaloneTestCase.java
@@ -0,0 +1,63 @@
+package org.apache.tuscany.tomcat.integration;
+
+import org.apache.catalina.core.StandardContext;
+import org.apache.catalina.core.StandardWrapper;
+import org.apache.catalina.core.StandardHost;
+import org.apache.catalina.startup.ContextConfig;
+import org.apache.catalina.Valve;
+import org.apache.catalina.Wrapper;
+
+import org.apache.tuscany.tomcat.TuscanyValve;
+import org.apache.tuscany.tomcat.TuscanyHost;
+
+import java.io.File;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class TomcatStandaloneTestCase extends AbstractTomcatTest {
+ protected File app2;
+
+ public void testRuntimeIntegration() throws Exception {
+ StandardContext ctx = new StandardContext();
+
+ // caution: this sets the parent of the webapp loader to the test classloader so it can find TestServlet
+ // anything that relies on the TCCL may not work correctly
+ ClassLoader cl = TestServlet.class.getClassLoader();
+ ctx.setParentClassLoader(cl);
+
+ ctx.addLifecycleListener(new ContextConfig());
+ ctx.setName("testContext");
+ ctx.setDocBase(app2.getAbsolutePath());
+
+ host.addChild(ctx);
+ boolean found = false;
+ for (Valve valve: ctx.getPipeline().getValves()) {
+ if (valve instanceof TuscanyValve) {
+ found = true;
+ break;
+ }
+ }
+ assertFalse("TuscanyValve in pipeline", found);
+
+ request.setContext(ctx);
+ request.setWrapper((Wrapper) ctx.findChild("TestServlet"));
+ host.invoke(request, response);
+
+ host.removeChild(ctx);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ app2 = new File(getClass().getResource("/app2").toURI());
+ File baseDir = new File(app2, "../../tomcat").getCanonicalFile();
+ setupTomcat(baseDir, new StandardHost());
+ engine.start();
+ }
+
+ protected void tearDown() throws Exception {
+ engine.stop();
+ super.tearDown();
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/test/resources/app1/WEB-INF/axis2.xml b/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/test/resources/app1/WEB-INF/axis2.xml
new file mode 100644
index 0000000000..a38cf9864a
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/test/resources/app1/WEB-INF/axis2.xml
@@ -0,0 +1,167 @@
+<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>
+ <!-- Uncomment this to enable REST support -->
+ <!-- <parameter name="enableREST" locked="false">true</parameter>-->
+
+
+ <parameter name="userName" locked="false">admin</parameter>
+ <parameter name="password" locked="false">axis2</parameter>
+
+ <parameter name="seralizeLocation" locked="false">.</parameter>
+ <hostConfiguration>
+ <ip>127.0.0.1</ip>
+ <port>5555</port>
+ </hostConfiguration>
+
+
+ <!--if you want to extract the service archive file and work with that please uncomment this-->
+ <!--else , it wont extract archive file or does not take into consideration if someone drop-->
+ <!--exploded directory into /service directory-->
+ <!--<parameter name="extractServiceArchive" locked="false">true</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.axis2.receivers.RawXMLINOnlyMessageReceiver"/>
+ <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out"
+ class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
+ </messageReceivers>
+ <!-- ================================================= -->
+ <!-- Transport Ins -->
+ <!-- ================================================= -->
+ <transportReceiver name="http" class="org.apache.axis2.transport.http.SimpleHTTPServer">
+ <parameter name="port" locked="false">6060</parameter>
+ </transportReceiver>
+
+ <!-- Uncomment this one with the appropriate papameters to enable the SMTP transport Receiver
+ <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> -->
+
+ <!--REMOVED FOR TUSCANY transportReceiver name="tcp" class="org.apache.axis2.transport.tcp.TCPServer">
+ <parameter name="port" locked="false">6060</parameter>
+ </transportReceiver -->
+
+ <!--REMOVED FOR TUSCANY transportReceiver name="jms" class="org.apache.axis2.transport.jms.SimpleJMSListener">
+ <parameter name="transport.jms.Destination" locked="false">dynamicQueues/FOO</parameter>
+ <parameter name="java.naming.factory.initial" locked="false">
+ org.activemq.jndi.ActiveMQInitialContextFactory</parameter>
+ <parameter name="java.naming.provider.url" locked="false">tcp://localhost:61616</parameter>
+ </transportReceiver>
+ -->
+
+ <!-- ================================================= -->
+ <!-- Transport Outs -->
+ <!-- ================================================= -->
+
+ <!--REMOVED FOR TUSCANY transportSender name="tcp" class="org.apache.axis2.transport.tcp.TCPTransportSender"/> -->
+ <transportSender name="local" class="org.apache.axis2.transport.local.LocalTransportSender"/>
+ <!--REMOVED FOR TUSCANY transportSender name="jms" class="org.apache.axis2.transport.jms.JMSSender"/> -->
+ <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>
+
+ <!-- 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 -->
+ <!--REMOVED FOR 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="TransportIn"/>
+ <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="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="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>
+ <!-- System pre defined phases -->
+ <!-- After Postdispatch phase module author or or service author can add any phase he want -->
+ <phase name="userphase1"/>
+ </phaseOrder>
+ <phaseOrder type="outflow">
+ <!-- user can add his own phases to this area -->
+ <phase name="userphase1"/>
+ <!--system predefined phase-->
+ <!--these phase will run irrespective of the service-->
+ <phase name="PolicyDetermination"/>
+ <phase name="MessageOut"/>
+ </phaseOrder>
+ <phaseOrder type="INfaultflow">
+ <!-- user can add his own phases to this area -->
+ <phase name="userphase1"/>
+ </phaseOrder>
+ <phaseOrder type="Outfaultflow">
+ <!-- user can add his own phases to this area -->
+ <phase name="userphase1"/>
+ <phase name="PolicyDetermination"/>
+ <phase name="MessageOut"/>
+ </phaseOrder>
+</axisconfig>
+
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/test/resources/app1/WEB-INF/classes/sca.module b/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/test/resources/app1/WEB-INF/classes/sca.module
new file mode 100644
index 0000000000..4273a8171c
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/test/resources/app1/WEB-INF/classes/sca.module
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2005 BEA Sytems Inc.
+ Copyright (c) 2005 International Business Machines
+
+ 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.
+ -->
+<module xmlns="http://www.osoa.org/xmlns/sca/0.9" xmlns:v="http://www.osoa.org/xmlns/sca/values/0.9"
+ name="testModule">
+
+</module>
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/test/resources/app1/WEB-INF/web.xml b/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/test/resources/app1/WEB-INF/web.xml
new file mode 100644
index 0000000000..a363db8e12
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/test/resources/app1/WEB-INF/web.xml
@@ -0,0 +1,6 @@
+<!DOCTYPE web-app
+ PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+ "http://java.sun.com/dtd/web-app_2_3.dtd">
+
+<web-app>
+</web-app> \ No newline at end of file
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/test/resources/app1/index.html b/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/test/resources/app1/index.html
new file mode 100644
index 0000000000..55ecbd81ba
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/test/resources/app1/index.html
@@ -0,0 +1,3 @@
+<html>
+<body>Hello World</body>
+</html> \ No newline at end of file
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/test/resources/app2/WEB-INF/classes/sca.module b/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/test/resources/app2/WEB-INF/classes/sca.module
new file mode 100644
index 0000000000..fd1d63a7a6
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/test/resources/app2/WEB-INF/classes/sca.module
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2005 BEA Sytems Inc.
+ Copyright (c) 2005 International Business Machines
+
+ 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.
+ -->
+<module xmlns="http://www.osoa.org/xmlns/sca/0.9" xmlns:v="http://www.osoa.org/xmlns/sca/values/0.9"
+ name="testModule">
+
+</module>
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/test/resources/app2/WEB-INF/web.xml b/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/test/resources/app2/WEB-INF/web.xml
new file mode 100644
index 0000000000..abf92d4ca7
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/test/resources/app2/WEB-INF/web.xml
@@ -0,0 +1,29 @@
+<!DOCTYPE web-app
+ PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+ "http://java.sun.com/dtd/web-app_2_3.dtd">
+
+<web-app>
+ <context-param>
+ <param-name>org.apache.tuscany.core.webapp.ModuleComponentName</param-name>
+ <param-value>testContext</param-value>
+ </context-param>
+ <listener>
+ <listener-class>org.apache.tuscany.core.webapp.TuscanyServletListener</listener-class>
+ </listener>
+ <servlet>
+ <servlet-name>TestServlet</servlet-name>
+ <servlet-class>org.apache.tuscany.tomcat.integration.TestServlet</servlet-class>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>TestServlet</servlet-name>
+ <url-pattern>/servlet</url-pattern>
+ </servlet-mapping>
+ <filter>
+ <filter-name>TuscanyFilter</filter-name>
+ <filter-class>org.apache.tuscany.core.webapp.TuscanyRequestFilter</filter-class>
+ </filter>
+ <filter-mapping>
+ <filter-name>TuscanyFilter</filter-name>
+ <servlet-name>TestServlet</servlet-name>
+ </filter-mapping>
+</web-app> \ No newline at end of file
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/test/resources/app2/index.html b/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/test/resources/app2/index.html
new file mode 100644
index 0000000000..55ecbd81ba
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/tomcat/src/test/resources/app2/index.html
@@ -0,0 +1,3 @@
+<html>
+<body>Hello World</body>
+</html> \ No newline at end of file
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/tools/LICENSE.txt b/sca-java-1.x/tags/java-stable-20060304/sca/tools/LICENSE.txt
new file mode 100644
index 0000000000..d645695673
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/tools/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/sca-java-1.x/tags/java-stable-20060304/sca/tools/pom.xml b/sca-java-1.x/tags/java-stable-20060304/sca/tools/pom.xml
new file mode 100644
index 0000000000..5144519d67
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/tools/pom.xml
@@ -0,0 +1,110 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Copyright (c) 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.
+ -->
+<project>
+ <parent>
+ <groupId>org.apache.tuscany</groupId>
+ <artifactId>tuscany-sca</artifactId>
+ <version>SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>tuscany-sca-tools</artifactId>
+ <name>Tuscany SCA Tools</name>
+ <description>SCA Tools.</description>
+ <version>SNAPSHOT</version>
+
+ <repositories>
+ <repository>
+ <id>jeremy</id>
+ <url>http://people.apache.org/~jboynes/maven2</url>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany</groupId>
+ <artifactId>tuscany-sdo-impl</artifactId>
+ <version>SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany</groupId>
+ <artifactId>tuscany-model</artifactId>
+ <version>SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.eclipse.emf</groupId>
+ <artifactId>codegen</artifactId>
+ <version>2.2.0-I200602160000</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.eclipse.emf</groupId>
+ <artifactId>codegen-ecore</artifactId>
+ <version>2.2.0-I200602160000</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>axis2</groupId>
+ <artifactId>axis2-core</artifactId>
+ <version>0.94</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>axis2</groupId>
+ <artifactId>axis2-codegen</artifactId>
+ <version>0.94</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>axis</groupId>
+ <artifactId>axis-wsdl4j</artifactId>
+ <version>1.2</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.0.4</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.12</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/tools/src/main/java/org/apache/tuscany/tools/wsdl2java/generate/JavaInterfaceGenerator.java b/sca-java-1.x/tags/java-stable-20060304/sca/tools/src/main/java/org/apache/tuscany/tools/wsdl2java/generate/JavaInterfaceGenerator.java
new file mode 100644
index 0000000000..518f070ce4
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/tools/src/main/java/org/apache/tuscany/tools/wsdl2java/generate/JavaInterfaceGenerator.java
@@ -0,0 +1,142 @@
+/**
+ *
+ * Copyright 2005 BEA Systems Inc.
+ * Copyright 2005 International Business Machines Corporation
+ *
+ * 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.tools.wsdl2java.generate;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.wsdl.WSDLException;
+import javax.xml.namespace.QName;
+
+import org.apache.axis2.i18n.Messages;
+import org.apache.axis2.util.FileWriter;
+import org.apache.axis2.wsdl.builder.WOMBuilderFactory;
+import org.apache.axis2.wsdl.codegen.CodeGenConfiguration;
+import org.apache.axis2.wsdl.codegen.CodeGenerationException;
+import org.apache.axis2.wsdl.codegen.emitter.JavaEmitter;
+import org.apache.axis2.wsdl.codegen.extension.CodeGenExtension;
+import org.apache.axis2.wsdl.codegen.extension.DefaultDatabindingExtension;
+import org.apache.axis2.wsdl.codegen.extension.PackageFinder;
+import org.apache.axis2.wsdl.codegen.extension.WSDLValidatorExtension;
+import org.apache.axis2.wsdl.codegen.writer.InterfaceWriter;
+import org.apache.axis2.wsdl.databinding.JavaTypeMapper;
+import org.apache.axis2.wsdl.i18n.CodegenMessages;
+import org.apache.tuscany.model.util.XMLNameUtil;
+import org.apache.wsdl.WSDLDescription;
+import org.w3c.dom.Document;
+
+public class JavaInterfaceGenerator {
+
+ private List codegenExtensions = new ArrayList();
+ private CodeGenConfiguration codegenConfiguration;
+
+ public JavaInterfaceGenerator(String uri, String outputLocation, String packageName, Map<QName, String> typeMapping) throws CodeGenerationException {
+ WSDLDescription wom;
+ try {
+ wom = WOMBuilderFactory.getBuilder(org.apache.wsdl.WSDLConstants.WSDL_1_1).build(uri).getDescription();
+ } catch (WSDLException e) {
+ throw new CodeGenerationException(CodegenMessages.getMessage("engine.wsdlParsingException"), e);
+ }
+
+ if (packageName==null)
+ packageName=XMLNameUtil.getPackageNameFromNamespace(wom.getTargetNameSpace());
+
+ JavaTypeMapper typeMapper=new JavaTypeMapper();
+ for (Map.Entry<QName, String> e : typeMapping.entrySet() ) {
+ typeMapper.addTypeMappingName(e.getKey(), e.getValue());
+ }
+
+ codegenConfiguration = new CodeGenConfiguration(wom, new HashMap());
+ codegenConfiguration.setAdvancedCodeGenEnabled(false);
+ codegenConfiguration.setAsyncOn(false);
+ codegenConfiguration.setCodeGenerationStyle(0);
+ codegenConfiguration.setDatabindingType("sdo");
+ codegenConfiguration.setGenerateAll(true);
+ codegenConfiguration.setGenerateDeployementDescriptor(false);
+ codegenConfiguration.setOutputLanguage("java");
+ codegenConfiguration.setOutputLocation(new File(outputLocation));
+ codegenConfiguration.setPackageName(packageName);
+ codegenConfiguration.setPackClasses(false);
+ codegenConfiguration.setPolicyMap(new HashMap());
+ codegenConfiguration.setPortName(null);
+ codegenConfiguration.setServerSide(false);
+ codegenConfiguration.setServiceName(null);
+ codegenConfiguration.setSyncOn(true);
+ codegenConfiguration.setTypeMapper(typeMapper);
+ codegenConfiguration.setWriteMessageReceiver(false);
+ codegenConfiguration.setWriteTestCase(false);
+
+ addExtension(new WSDLValidatorExtension());
+ addExtension(new PackageFinder());
+ addExtension(new SDODataBindingCodegenExtension(typeMapper));
+ addExtension(new DefaultDatabindingExtension());
+ }
+
+ private void addExtension(CodeGenExtension ext) {
+ ext.init(codegenConfiguration);
+ codegenExtensions.add(ext);
+ }
+
+
+ public void generate() throws CodeGenerationException {
+ try {
+ for (int i = 0; i < codegenExtensions.size(); i++) {
+ ((CodeGenExtension) codegenExtensions.get(i)).engage();
+ }
+
+ class JavaInterfaceEmitter extends JavaEmitter {
+
+ protected void writeInterface(boolean writeDatabinders) throws Exception {
+ Document interfaceModel = createDOMDocumentForInterface(writeDatabinders);
+ if (!configuration.getOutputLocation().exists()) {
+ configuration.getOutputLocation().mkdirs();
+ }
+ InterfaceWriter interfaceWriter =
+ new InterfaceWriter(this.configuration.getOutputLocation(),
+ this.configuration.getOutputLanguage());
+
+ String packageName = interfaceModel.getDocumentElement().getAttribute("package");
+ String className = interfaceModel.getDocumentElement().getAttribute("name");
+
+ System.out.println(">> Generating Java class "+packageName+"."+className);
+ File outputFile = FileWriter.createClassFile(this.configuration.getOutputLocation(), packageName, className, ".java");
+ if (outputFile.exists())
+ outputFile.delete();
+
+ writeClass(interfaceModel, interfaceWriter);
+ };
+
+ };
+
+ JavaInterfaceEmitter emitter=new JavaInterfaceEmitter();
+ emitter.setCodeGenConfiguration(codegenConfiguration);
+ emitter.setMapper(codegenConfiguration.getTypeMapper());
+
+ emitter.writeInterface(false);
+
+ } catch (Exception e) {
+ throw new CodeGenerationException(e);
+ }
+ }
+
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/tools/src/main/java/org/apache/tuscany/tools/wsdl2java/generate/SDODataBindingCodegenExtension.java b/sca-java-1.x/tags/java-stable-20060304/sca/tools/src/main/java/org/apache/tuscany/tools/wsdl2java/generate/SDODataBindingCodegenExtension.java
new file mode 100644
index 0000000000..f310fe0f8a
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/tools/src/main/java/org/apache/tuscany/tools/wsdl2java/generate/SDODataBindingCodegenExtension.java
@@ -0,0 +1,48 @@
+/**
+ *
+ * Copyright 2005 BEA Systems Inc.
+ * Copyright 2005 International Business Machines Corporation
+ *
+ * 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.tools.wsdl2java.generate;
+
+import org.apache.axis2.wsdl.codegen.extension.AbstractDBProcessingExtension;
+import org.apache.axis2.wsdl.databinding.TypeMapper;
+
+/**
+ * SDO data binding codegen extension.
+ */
+public class SDODataBindingCodegenExtension extends AbstractDBProcessingExtension {
+
+ private TypeMapper typeMapper;
+
+ public SDODataBindingCodegenExtension(TypeMapper typeMapper) {
+ this.typeMapper=typeMapper;
+ }
+
+ protected boolean testFallThrough(String dbFrameworkName) {
+ return !dbFrameworkName.equals("sdo");
+ }
+
+ public void engage() {
+ if (testFallThrough(configuration.getDatabindingType())) {
+ return;
+ }
+
+ // Set the type mapper into the config
+ configuration.setTypeMapper(typeMapper);
+
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/tools/src/main/java/org/apache/tuscany/tools/wsdl2java/generate/WSDL2JavaGenerator.java b/sca-java-1.x/tags/java-stable-20060304/sca/tools/src/main/java/org/apache/tuscany/tools/wsdl2java/generate/WSDL2JavaGenerator.java
new file mode 100644
index 0000000000..0be15181fb
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/tools/src/main/java/org/apache/tuscany/tools/wsdl2java/generate/WSDL2JavaGenerator.java
@@ -0,0 +1,319 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.tools.wsdl2java.generate;
+
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.StringTokenizer;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sdo.helper.XSDHelperImpl;
+import org.apache.tuscany.sdo.util.DataObjectUtil;
+import org.eclipse.emf.codegen.ecore.genmodel.GenClass;
+import org.eclipse.emf.codegen.ecore.genmodel.GenModel;
+import org.eclipse.emf.codegen.ecore.genmodel.GenModelFactory;
+import org.eclipse.emf.codegen.ecore.genmodel.GenPackage;
+import org.eclipse.emf.codegen.util.CodeGenUtil;
+import org.eclipse.emf.common.util.Diagnostic;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.impl.EPackageRegistryImpl;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.util.BasicExtendedMetaData;
+import org.eclipse.emf.ecore.util.ExtendedMetaData;
+
+import commonj.sdo.helper.XSDHelper;
+
+
+public class WSDL2JavaGenerator {
+
+ /**
+ * Generate Java interfaces from WSDL
+ *
+ * Usage arguments:
+ *
+ * [ -targetDirectory <target-root-directory> ]
+ * [ -javaPackage <java-package-name> ]
+ * <wsdl-file>
+ *
+ * For example:
+ *
+ * generate somedir/somefile.wsdl
+ *
+ * Basic options:
+ *
+ * -targetDirectory
+ * Generates the Java source code in the specified directory. By default, the code is generated
+ * in the same directory as the input wsdl file.
+ * -javaPackage
+ * Overrides the Java package for the generated classes. By default the package name is derived
+ * from the targetNamespace of the WSDL definition being generated. For example, if the targetNamespace is
+ * "http://www.example.com/simple", the default package will be "com.example.simple".
+ */
+ public static void main(String args[])
+ {
+ if (args.length == 0)
+ {
+ printUsage();
+ return;
+ }
+
+
+ String targetDirectory = null;
+ String wsdlJavaPackage = null;
+ String xsdJavaPackage = null;
+
+ int genOptions = 0;
+
+ int index = 0;
+ for (; index < args.length && args[index].startsWith("-"); ++index)
+ {
+ if (args[index].equalsIgnoreCase("-targetDirectory"))
+ {
+ targetDirectory = args[++index];
+ }
+ else if (args[index].equalsIgnoreCase("-javaPackage"))
+ {
+ wsdlJavaPackage = args[++index];
+ }
+ //else if (...)
+ else
+ {
+ printUsage();
+ return;
+ }
+ }
+
+ String wsdlFileName = args[index];
+ if (wsdlFileName==null || targetDirectory==null) {
+ printUsage();
+ return;
+ }
+
+ generateFromWSDL(wsdlFileName, targetDirectory, wsdlJavaPackage, xsdJavaPackage, 0);
+
+ }
+
+ public static void generateFromWSDL(String wsdlFileName, String targetDirectory, String wsdlJavaPackage, String xsdJavaPackage, int genOptions)
+ {
+ DataObjectUtil.initRuntime();
+ EPackage.Registry packageRegistry = new EPackageRegistryImpl(EPackage.Registry.INSTANCE);
+ ExtendedMetaData extendedMetaData = new BasicExtendedMetaData(packageRegistry);
+ XSDHelper xsdHelper = new XSDHelperImpl(extendedMetaData);
+
+ try
+ {
+ File inputFile = new File(wsdlFileName).getAbsoluteFile();
+ InputStream inputStream = new FileInputStream(inputFile);
+ xsdHelper.define(inputStream, inputFile.toURI().toString());
+
+ if (targetDirectory == null)
+ {
+ targetDirectory = new File(wsdlFileName).getCanonicalFile().getParent();
+ }
+ else
+ {
+ targetDirectory = new File(targetDirectory).getCanonicalPath();
+ }
+
+ Map<QName, String> typeMapping=new HashMap<QName, String>();
+ if (!packageRegistry.values().isEmpty())
+ {
+ ResourceSet resourceSet = DataObjectUtil.createResourceSet();
+
+ List<GenPackage> genPackages=new ArrayList<GenPackage>();
+ Map<EClass, GenClass> genClasses=new HashMap<EClass, GenClass>();
+
+ for (Iterator iter = packageRegistry.values().iterator(); iter.hasNext();)
+ {
+ EPackage currentEPackage = (EPackage)iter.next();
+ String currentBasePackage = extractBasePackageName(currentEPackage, xsdJavaPackage);
+ String currentPrefix = CodeGenUtil.capName(currentEPackage.getName());
+
+ GenPackage currentGenPackage = createGenPackage(currentEPackage, currentBasePackage, currentPrefix, genOptions, resourceSet);
+ genPackages.add(currentGenPackage);
+ for (GenClass genClass : (List<GenClass>)currentGenPackage.getGenClasses()) {
+ genClasses.put(genClass.getEcoreClass(), genClass);
+ }
+
+ }
+
+ for (GenPackage currentGenPackage : genPackages) {
+ EPackage currentEPackage=currentGenPackage.getEcorePackage();
+ for (GenClass genClass : (List<GenClass>)currentGenPackage.getGenClasses()) {
+ QName qname=new QName(extendedMetaData.getNamespace(currentEPackage), extendedMetaData.getName(genClass.getEcoreClass()));
+ String interfaceName=currentGenPackage.getInterfacePackageName()+'.'+genClass.getInterfaceName();
+ typeMapping.put(qname, interfaceName);
+ }
+
+ EClass documentRoot=extendedMetaData.getDocumentRoot(currentEPackage);
+ if (documentRoot!=null) {
+ for (EStructuralFeature element : (List<EStructuralFeature>)extendedMetaData.getElements(documentRoot)) {
+ EClassifier elementType=element.getEType();
+ if (extendedMetaData.isAnonymous(elementType)) {
+ EClass eClass=(EClass)elementType;
+ EStructuralFeature feature=(EStructuralFeature)eClass.getEStructuralFeatures().get(0);
+ elementType=feature.getEType();
+ }
+ if (elementType instanceof EClass) {
+ GenClass genClass=genClasses.get(elementType);
+ QName qname=new QName(extendedMetaData.getNamespace(currentEPackage), extendedMetaData.getName(element));
+ String interfaceName=genClass.getGenPackage().getInterfacePackageName()+'.'+genClass.getInterfaceName();
+ typeMapping.put(qname, interfaceName);
+ } else if (elementType instanceof EClassifier) {
+ QName qname=new QName(extendedMetaData.getNamespace(currentEPackage), extendedMetaData.getName(element));
+ String interfaceName=elementType.getInstanceClass().getName();
+ typeMapping.put(qname, interfaceName);
+ }
+ }
+ }
+ }
+ }
+
+ try {
+ JavaInterfaceGenerator codeGenerator=new JavaInterfaceGenerator(wsdlFileName, targetDirectory, wsdlJavaPackage, typeMapping);
+ codeGenerator.generate();
+ } catch (Exception e) {
+ throw new IllegalArgumentException(e);
+ }
+
+ }
+ catch (IOException e)
+ {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+ public static GenPackage createGenPackage(EPackage ePackage, String basePackage, String prefix, int genOptions, ResourceSet resourceSet)
+ {
+ GenModel genModel = ecore2GenModel(ePackage, basePackage, prefix, genOptions);
+
+ URI ecoreURI = URI.createURI("file:///" + ePackage.getName() + ".ecore");
+ URI genModelURI = ecoreURI.trimFileExtension().appendFileExtension("genmodel");
+
+ Resource ecoreResource = resourceSet.createResource(ecoreURI);
+ ecoreResource.getContents().add(ePackage);
+
+ Resource genModelResource = resourceSet.createResource(genModelURI);
+ genModelResource.getContents().add(genModel);
+
+ return (GenPackage)genModel.getGenPackages().get(0);
+ }
+
+ public static GenModel ecore2GenModel(EPackage ePackage, String basePackage, String prefix, int genOptions)
+ {
+ GenModel genModel = GenModelFactory.eINSTANCE.createGenModel();
+ genModel.initialize(Collections.singleton(ePackage));
+
+ genModel.setRootExtendsInterface("");
+ genModel.setRootImplementsInterface("commonj.sdo.DataObject");
+ genModel.setRootExtendsClass("org.apache.tuscany.sdo.impl.DataObjectImpl");
+ genModel.setFeatureMapWrapperInterface("commonj.sdo.Sequence");
+ genModel.setFeatureMapWrapperInternalInterface("org.apache.tuscany.sdo.util.BasicSequence");
+ genModel.setFeatureMapWrapperClass("org.apache.tuscany.sdo.util.BasicSequence");
+ genModel.setSuppressEMFTypes(true);
+ genModel.setSuppressEMFMetaData(true);
+ genModel.setSuppressEMFModelTags(true);
+ genModel.setCanGenerate(true);
+ //FIXME workaround java.lang.NoClassDefFoundError: org/eclipse/jdt/core/jdom/IDOMNode with 02162006 build
+ genModel.setFacadeHelperClass("Hack");
+ genModel.setForceOverwrite(true);
+
+ GenPackage genPackage = (GenPackage)genModel.getGenPackages().get(0);
+
+ if (basePackage != null)
+ {
+ genPackage.setBasePackage(basePackage);
+ }
+ if (prefix != null)
+ {
+ genPackage.setPrefix(prefix);
+ }
+
+ return genModel;
+ }
+
+ public static String extractBasePackageName(EPackage ePackage, String javaPackage)
+ {
+ String qualifiedName = javaPackage != null ? javaPackage : ePackage.getName();
+ String name = /*CodeGenUtil.*/shortName(qualifiedName);
+ String baseName = qualifiedName.substring(0, qualifiedName.length() - name.length());
+ if (javaPackage != null || !name.equals(qualifiedName))
+ {
+ ePackage.setName(name);
+ }
+ return baseName != null ? /*CodeGenUtil.*/safeQualifiedName(baseName) : null;
+ }
+
+ public static String shortName(String qualifiedName)
+ {
+ int index = qualifiedName.lastIndexOf(".");
+ return index != -1 ? qualifiedName.substring(index + 1) : qualifiedName;
+ }
+
+ public static String safeQualifiedName(String qualifiedName)
+ {
+ StringBuffer safeQualifiedName = new StringBuffer();
+ for (StringTokenizer stringTokenizer = new StringTokenizer(qualifiedName, "."); stringTokenizer.hasMoreTokens();)
+ {
+ String name = stringTokenizer.nextToken();
+ safeQualifiedName.append(CodeGenUtil.safeName(name));
+ if (stringTokenizer.hasMoreTokens())
+ {
+ safeQualifiedName.append('.');
+ }
+ }
+ return safeQualifiedName.toString();
+ }
+
+ protected static void printDiagnostic(Diagnostic diagnostic, String indent)
+ {
+ System.out.print(indent);
+ System.out.println(diagnostic.getMessage());
+ for (Iterator i = diagnostic.getChildren().iterator(); i.hasNext();)
+ {
+ printDiagnostic((Diagnostic)i.next(), indent + " ");
+ }
+ }
+
+ protected static void printUsage()
+ {
+ System.out.println("Usage arguments:");
+ System.out.println(" [ -targetDirectory <target-root-directory> ]");
+ System.out.println(" [ -javaPackage <java-package-name> ]");
+ System.out.println(" <wsdl-file>");
+ System.out.println("");
+ System.out.println("For example:");
+ System.out.println("");
+ System.out.println(" generate somedir/somefile.wsdl");
+ }
+
+}