From bdd0a41aed7edf21ec2a65cfa17a86af2ef8c48a Mon Sep 17 00:00:00 2001 From: dims Date: Tue, 17 Jun 2008 00:23:01 +0000 Subject: Move Tuscany from Incubator to top level. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@668359 13f79535-47bb-0310-9956-ffa450edef68 --- sandbox/rfeng/aop-logging/.checkstyle | 24 + sandbox/rfeng/aop-logging/.pmd | 20 + sandbox/rfeng/aop-logging/.ruleset | 190 ++ sandbox/rfeng/aop-logging/LICENSE.txt | 202 ++ sandbox/rfeng/aop-logging/NOTICE.txt | 14 + sandbox/rfeng/aop-logging/pom.xml | 93 + .../apache/tuscany/sca/aspectj/LoggingAspect.java | 93 + .../apache/tuscany/sca/aspectj/TracingAspect.java | 82 + .../tuscany/sca/aspectj/MyTracingAspect.java | 60 + .../tuscany/sca/aspectj/TracingTestCase.java | 40 + .../src/test/resources/META-INF/aop.xml | 15 + sandbox/rfeng/aop-logging/test.bat | 3 + sandbox/rfeng/geronimo-demo/LICENSE.TXT | 2835 ++++++++++++++++++++ sandbox/rfeng/geronimo-demo/README.TXT | 54 + .../main/java/bigbank/account/AccountReport.java | 42 + .../main/java/bigbank/account/AccountService.java | 29 + .../java/bigbank/account/AccountServiceImpl.java | 72 + .../src/main/java/bigbank/accountdata/Account.java | 26 + .../bigbank/accountdata/AccountDataService.java | 28 + .../accountdata/AccountDataServiceImpl.java | 57 + .../java/bigbank/accountdata/BrokerService.java | 35 + .../java/bigbank/accountdata/CheckingAccount.java | 35 + .../java/bigbank/accountdata/SavingsAccount.java | 35 + .../java/bigbank/accountdata/StockAccount.java | 58 + .../main/java/bigbank/client/BigBankClient.java | 43 + .../java/bigbank/stockquote/StockQuoteImpl.java | 36 + .../java/bigbank/stockquote/StockQuoteService.java | 32 + .../bigbank/src/main/resources/BigBank.composite | 52 + .../bigbank/src/main/resources/wsdl/account.wsdl | 81 + .../src/test/java/bigbank/BigBankTestCase.java | 48 + .../ejbs/ejbModule/META-INF/MANIFEST.MF | 3 + .../ejbs/ejbModule/META-INF/ejb-jar.xml | 61 + .../ejbs/ejbModule/META-INF/openejb-jar.xml | 79 + .../bigbank/accountdata/BrokerService.java | 35 + .../bigbank/accountdata/BrokerServiceBean.java | 68 + .../bigbank/accountdata/BrokerServiceHome.java | 14 + .../ejbs/ejbModule/calculator/AddService.java | 27 + .../ejbs/ejbModule/calculator/AddServiceBean.java | 62 + .../ejbs/ejbModule/calculator/AddServiceHome.java | 30 + .../ejbs/ejbModule/calculator/AddServiceLocal.java | 26 + .../ejbModule/calculator/AddServiceLocalHome.java | 29 + .../geronimo-demo/ejbs/ejbModule/hello/Hello.java | 29 + .../ejbs/ejbModule/hello/HelloBean.java | 73 + .../ejbs/ejbModule/hello/HelloHome.java | 30 + .../ejbs/ejbModule/hello/HelloLocal.java | 26 + .../ejbs/ejbModule/hello/HelloLocalHome.java | 29 + sandbox/rfeng/geronimo-demo/scenario.doc | Bin 0 -> 29184 bytes sandbox/rfeng/geronimo-demo/scenario.png | Bin 0 -> 34852 bytes .../webs/WebContent/META-INF/MANIFEST.MF | 2 + .../webs/WebContent/WEB-INF/geronimo-web.xml | 21 + .../geronimo-demo/webs/WebContent/WEB-INF/web.xml | 33 + .../rfeng/geronimo-demo/webs/WebContent/index.jsp | 58 + .../src/bigbank/accountdata/AccountService.java | 28 + sandbox/rfeng/minicore/.checkstyle | 24 + sandbox/rfeng/minicore/.pmd | 20 + sandbox/rfeng/minicore/.ruleset | 190 ++ sandbox/rfeng/minicore/LICENSE.txt | 202 ++ sandbox/rfeng/minicore/NOTICE.txt | 14 + sandbox/rfeng/minicore/pom.xml | 74 + .../binding/local/AbstractLocalTargetInvoker.java | 78 + .../core/binding/local/LocalBindingBuilder.java | 52 + .../core/binding/local/LocalBindingDefinition.java | 39 + .../core/binding/local/LocalBindingLoader.java | 70 + .../binding/local/LocalCallbackTargetInvoker.java | 69 + .../core/binding/local/LocalReferenceBinding.java | 62 + .../core/binding/local/LocalServiceBinding.java | 60 + .../core/binding/local/LocalTargetInvoker.java | 79 + .../tuscany/core/bootstrap/Bootstrapper.java | 75 + .../core/bootstrap/DefaultBootstrapper.java | 224 ++ .../tuscany/core/bootstrap/ExtensionActivator.java | 31 + .../tuscany/core/builder/BuilderRegistryImpl.java | 185 ++ .../core/builder/ComponentNotFoundException.java | 36 + .../apache/tuscany/core/builder/ConnectorImpl.java | 385 +++ .../core/builder/IllegalCallbackException.java | 36 + .../builder/IncompatibleInterfacesException.java | 40 + .../core/builder/InvalidSourceTypeException.java | 35 + .../core/builder/InvalidTargetTypeException.java | 35 + .../tuscany/core/builder/NoBindingException.java | 35 + .../builder/NoCompatibleBindingsException.java | 34 + .../builder/NoConversationalContractException.java | 37 + .../core/builder/NoRegisteredBuilderException.java | 38 + .../builder/SourceServiceNotFoundException.java | 36 + .../builder/TargetServiceNotFoundException.java | 36 + .../core/builder/WireCreationException.java | 39 + .../builder/WirePostProcessorRegistryImpl.java | 50 + .../core/builder/WiringExceptionFormatter.java | 67 + .../core/component/CallableReferenceImpl.java | 60 + .../core/component/CallbackReferenceImpl.java | 33 + .../core/component/ComponentContextImpl.java | 97 + .../core/component/ComponentContextProvider.java | 44 + .../core/component/ComponentManagerImpl.java | 109 + .../tuscany/core/component/ScopeIdentifier.java | 35 + .../core/component/ServiceReferenceImpl.java | 52 + .../tuscany/core/component/SimpleWorkContext.java | 113 + .../component/SystemSingletonAtomicComponent.java | 138 + .../tuscany/core/component/WorkContextImpl.java | 214 ++ .../core/component/event/AbstractEvent.java | 39 + .../core/component/event/AbstractRequestEvent.java | 38 + .../core/component/event/ComponentEvent.java | 34 + .../core/component/event/ComponentStart.java | 47 + .../core/component/event/ComponentStop.java | 46 + .../core/component/event/ConversationEnd.java | 31 + .../core/component/event/ConversationStart.java | 31 + .../core/component/event/ConversationalEvent.java | 39 + .../core/component/event/HttpRequestEnded.java | 38 + .../core/component/event/HttpRequestStart.java | 38 + .../core/component/event/HttpSessionEnd.java | 38 + .../core/component/event/HttpSessionEvent.java | 45 + .../core/component/event/HttpSessionStart.java | 38 + .../tuscany/core/component/event/RequestEnd.java | 38 + .../tuscany/core/component/event/RequestEvent.java | 28 + .../tuscany/core/component/event/RequestStart.java | 37 + .../component/scope/AbstractScopeContainer.java | 265 ++ .../component/scope/CompositeScopeContainer.java | 114 + .../scope/ConversationalScopeContainer.java | 190 ++ .../component/scope/HttpSessionScopeContainer.java | 141 + .../core/component/scope/InstanceWrapperBase.java | 53 + .../component/scope/RequestScopeContainer.java | 130 + .../core/component/scope/ScopeRegistryImpl.java | 49 + .../component/scope/StatelessScopeContainer.java | 62 + .../core/deployer/AbstractDeploymentContext.java | 80 + .../core/deployer/ChildDeploymentContext.java | 71 + .../apache/tuscany/core/deployer/DeployerImpl.java | 197 ++ .../core/deployer/RootDeploymentContext.java | 74 + .../core/implementation/PojoWorkContextTunnel.java | 63 + .../composite/AbstractCompositeBuilder.java | 69 + .../composite/ComponentTimeoutException.java | 33 + .../implementation/composite/CompositeBuilder.java | 51 + .../composite/CompositeComponentImpl.java | 121 + .../composite/CompositeComponentTypeLoader.java | 65 + .../implementation/composite/CompositeLoader.java | 224 ++ .../composite/ManagedRequestContext.java | 58 + .../implementation/composite/ReferenceImpl.java | 71 + .../core/implementation/composite/ServiceImpl.java | 81 + .../core/injection/SingletonObjectFactory.java | 39 + .../tuscany/core/loader/ComponentLoader.java | 360 +++ .../core/loader/ComponentTypeElementLoader.java | 86 + .../apache/tuscany/core/loader/IncludeLoader.java | 105 + .../core/loader/LoaderExceptionFormatter.java | 67 + .../tuscany/core/loader/LoaderRegistryImpl.java | 179 ++ .../tuscany/core/loader/PolicySetLoader.java | 195 ++ .../apache/tuscany/core/loader/PropertyLoader.java | 98 + .../apache/tuscany/core/loader/PropertyUtils.java | 119 + .../tuscany/core/loader/ReferenceLoader.java | 107 + .../apache/tuscany/core/loader/ServiceLoader.java | 99 + .../core/loader/StringParserPropertyFactory.java | 191 ++ .../org/apache/tuscany/core/loader/WireLoader.java | 122 + .../core/monitor/DefaultExceptionFormatter.java | 54 + .../core/monitor/InvalidLevelException.java | 64 + .../core/monitor/JavaLoggingMonitorFactory.java | 120 + .../tuscany/core/monitor/MonitorFactoryUtil.java | 78 + .../tuscany/core/monitor/NullMonitorFactory.java | 68 + .../tuscany/core/monitor/ProxyMonitorFactory.java | 234 ++ .../tuscany/core/resolver/AutowireResolver.java | 64 + .../resolver/AutowireTargetNotFoundException.java | 30 + .../core/resolver/DefaultAutowireResolver.java | 181 ++ .../tuscany/core/runtime/AbstractRuntime.java | 379 +++ .../classloading/ClassLoaderRegistryImpl.java | 50 + .../core/services/store/memory/MemoryStore.java | 198 ++ .../org/apache/tuscany/core/util/FileHelper.java | 704 +++++ .../org/apache/tuscany/core/util/IOHelper.java | 182 ++ .../tuscany/core/util/JavaIntrospectionHelper.java | 439 +++ .../core/wire/CallbackInterfaceInterceptor.java | 60 + ...ompatibleServiceContractExceptionFormatter.java | 94 + .../tuscany/core/wire/InvocationChainImpl.java | 105 + .../tuscany/core/wire/InvokerInterceptor.java | 60 + .../core/wire/NoMethodForOperationException.java | 42 + .../tuscany/core/wire/NonBlockingInterceptor.java | 193 ++ .../core/wire/NonBlockingInterceptorBuilder.java | 55 + .../core/wire/OptimizedWireObjectFactory.java | 49 + .../tuscany/core/wire/ProxyServiceExtension.java | 115 + .../org/apache/tuscany/core/wire/WireImpl.java | 159 ++ .../tuscany/core/wire/WireObjectFactory.java | 85 + .../tuscany/core/wire/WireObjectFactory2.java | 65 + .../org/apache/tuscany/core/wire/WireUtils.java | 116 + .../org/apache/tuscany/core/composite.scdl | 48 + .../org/apache/tuscany/core/deployment.scdl | 62 + .../org/apache/tuscany/core/formatters.scdl | 44 + .../org/apache/tuscany/core/implementation.scdl | 79 + .../org/apache/tuscany/core/interfaceJava.scdl | 36 + .../apache/tuscany/core/javaImplementation.scdl | 40 + .../resources/org/apache/tuscany/core/loader.scdl | 53 + .../apache/tuscany/core/systemImplementation.scdl | 51 + .../local/AbstractLocalTargetInvokerTestCase.java | 72 + .../binding/local/LocalBindingBuilderTestCase.java | 40 + .../binding/local/LocalBindingLoaderTestCase.java | 70 + ...ckTargetInvokerInvocationExceptionTestCase.java | 84 + .../local/LocalCallbackTargetInvokerTestCase.java | 83 + ...ocalCallbackTargetInvokerThrowableTestCase.java | 89 + .../binding/local/LocalTargetInvokerTestCase.java | 115 + .../builder/BuilderRegistryNoBindingsTestCase.java | 89 + .../core/builder/BuilderRegistryTestCase.java | 190 ++ .../core/builder/ConnectorImplTestCase.java | 320 +++ .../builder/IllegalCallbackExceptionTestCase.java | 40 + .../IncompatibleInterfacesExceptionTestCase.java | 38 + .../InvalidSourceTypeExceptionTestCase.java | 39 + .../InvalidTargetTypeExceptionTestCase.java | 39 + .../TargetServiceNotFoundExceptionTestCase.java | 38 + .../WirePostProcessorRegistryImplTestCase.java | 48 + .../builder/WiringExceptionFormatterTestCase.java | 70 + .../component/ComponentManagerImplTestCase.java | 90 + .../component/JavaObjectRegistrationTestCase.java | 77 + .../SystemSingletonAtomicComponentTestCase.java | 82 + .../core/component/event/EventTestCase.java | 69 + .../scope/AbstractScopeContainerTestCase.java | 61 + .../scope/BasicCompositeScopeTestCase.java | 143 + .../scope/BasicConversationalScopeTestCase.java | 95 + .../scope/BasicHttpSessionScopeTestCase.java | 220 ++ .../component/scope/BasicRequestScopeTestCase.java | 167 ++ .../scope/BasicStatelessScopeTestCase.java | 89 + .../CompositeScopeInitDestroyErrorTestCase.java | 93 + ...lScopeContainerDestroyOnExpirationTestCase.java | 72 + ...ConversationalScopeContainerMaxAgeTestCase.java | 76 + ...rsationalScopeContainerMaxIdleTimeTestCase.java | 78 + ...rsationalScopeContainerPersistenceTestCase.java | 189 ++ .../scope/InstanceWrapperBaseTestCase.java | 64 + .../core/component/scope/WorkContextTestCase.java | 166 ++ .../composite/CompositeComponentImplTestCase.java | 79 + .../composite/DuplicateRegistrationTestCase.java | 120 + .../composite/ManagedRequestContextTestCase.java | 42 + .../composite/ReferenceImplTestCase.java | 55 + .../composite/ServiceImplTestCase.java | 56 + .../injection/SingletonObjectFactoryTestCase.java | 33 + .../tuscany/core/mock/component/AsyncTarget.java | 31 + .../core/mock/component/BadContextPojo.java | 28 + .../tuscany/core/mock/component/BadNamePojo.java | 26 + .../core/mock/component/BasicInterface.java | 30 + .../core/mock/component/BasicInterfaceImpl.java | 66 + .../mock/component/CompositeScopeComponent.java | 31 + .../component/CompositeScopeComponentImpl.java | 40 + .../CompositeScopeDestroyOnlyComponent.java | 36 + .../CompositeScopeInitDestroyComponent.java | 39 + .../component/CompositeScopeInitOnlyComponent.java | 42 + .../component/ConversationalScopeComponent.java | 29 + .../ConversationalScopeComponentImpl.java | 29 + .../ConversationalScopeDestroyOnlyComponent.java | 37 + .../ConversationalScopeInitDestroyComponent.java | 38 + .../ConversationalScopeInitOnlyComponent.java | 38 + .../core/mock/component/OrderException.java | 40 + .../core/mock/component/OrderedDependentPojo.java | 29 + .../mock/component/OrderedDependentPojoImpl.java | 36 + .../core/mock/component/OrderedEagerInitPojo.java | 60 + .../core/mock/component/OrderedInitPojo.java | 28 + .../core/mock/component/OrderedInitPojoImpl.java | 61 + .../tuscany/core/mock/component/OtherTarget.java | 31 + .../core/mock/component/OtherTargetImpl.java | 39 + .../core/mock/component/RequestScopeComponent.java | 30 + .../RequestScopeDestroyOnlyComponent.java | 38 + .../RequestScopeInitDestroyComponent.java | 38 + .../component/RequestScopeInitOnlyComponent.java | 39 + .../core/mock/component/SessionScopeComponent.java | 30 + .../mock/component/SessionScopeComponentImpl.java | 30 + .../SessionScopeInitDestroyComponent.java | 36 + .../component/SessionScopeInitOnlyComponent.java | 37 + .../tuscany/core/mock/component/SimpleTarget.java | 30 + .../core/mock/component/SimpleTargetImpl.java | 41 + .../apache/tuscany/core/mock/component/Source.java | 37 + .../tuscany/core/mock/component/SourceImpl.java | 63 + .../core/mock/component/StatelessComponent.java | 30 + .../mock/component/StatelessComponentImpl.java | 27 + .../apache/tuscany/core/mock/component/Target.java | 32 + .../tuscany/core/mock/component/TargetImpl.java | 38 + .../tuscany/core/mock/wire/MockStaticInvoker.java | 98 + .../core/mock/wire/MockSyncInterceptor.java | 55 + .../tuscany/core/mock/wire/MockTargetInvoker.java | 33 + .../monitor/DefaultExceptionFormatterTestCase.java | 59 + .../tuscany/core/monitor/JavaLoggingTestCase.java | 153 ++ .../resolver/DefaultAutowireResolverTestCase.java | 177 ++ .../services/store/memory/MemoryStoreTestCase.java | 166 ++ .../java/org/apache/tuscany/core/util/Bean1.java | 45 + .../java/org/apache/tuscany/core/util/Bean2.java | 47 + .../core/util/JavaIntrospectionHelperTestCase.java | 180 ++ .../org/apache/tuscany/core/util/SuperBean.java | 48 + .../wire/CallbackInterfaceInterceptorTestCase.java | 60 + .../core/wire/ContractCompatibilityTestCase.java | 390 +++ ...eServiceContractExceptionFormatterTestCase.java | 82 + .../core/wire/InvocationChainImplTestCase.java | 84 + .../NonBlockingInterceptorBuilderTestCase.java | 38 + .../core/wire/NonBlockingInterceptorTestCase.java | 75 + .../wire/OptimizedWireObjectFactoryTestCase.java | 44 + .../apache/tuscany/core/wire/WireImplTestCase.java | 50 + .../core/wire/WireObjectFactoryTestCase.java | 138 + .../core/wire/WireOptimizationTestCase.java | 113 + .../tuscany/core/wire/WireUtilsTestCase.java | 69 + .../resources/deployables/sample-calculator.jar | Bin 0 -> 26901 bytes .../src/test/resources/marshall/javaChangeSet.xml | 72 + .../tuscany/core/deployer/boot1-include.scdl | 32 + .../org/apache/tuscany/core/deployer/boot1.scdl | 34 + .../org/apache/tuscany/core/deployer/boot2.scdl | 160 ++ .../org/apache/tuscany/core/loader/TestPolicy.scdl | 51 + .../apache/tuscany/core/loader/test-include.scdl | 22 + .../org/apache/tuscany/core/policy/PolicySet.scdl | 66 + .../org/apache/tuscany/core/property/ipo.xml | 51 + .../tuscany/core/services/deployment/test.ext | 18 + .../tuscany/core/services/deployment/test.scdl | 22 + .../resources/repository/sample-calculator.jar | Bin 0 -> 26901 bytes sandbox/rfeng/runtime/embedded/.checkstyle | 24 + sandbox/rfeng/runtime/embedded/.pmd | 20 + sandbox/rfeng/runtime/embedded/.ruleset | 190 ++ sandbox/rfeng/runtime/embedded/LICENSE.txt | 202 ++ sandbox/rfeng/runtime/embedded/NOTICE.txt | 14 + sandbox/rfeng/runtime/embedded/pom.xml | 47 + .../java/org/apache/tuscany/api/SCARuntime.java | 249 ++ .../runtime/embedded/DefaultSCARuntime.java | 75 + .../tuscany/runtime/embedded/SimpleRuntime.java | 48 + .../runtime/embedded/SimpleRuntimeImpl.java | 136 + .../runtime/embedded/SimpleRuntimeInfo.java | 56 + .../runtime/embedded/SimpleRuntimeInfoImpl.java | 182 ++ .../src/test/java/calculator/AddService.java | 25 + .../src/test/java/calculator/AddServiceImpl.java | 30 + .../src/test/java/calculator/CalculatorClient.java | 51 + .../test/java/calculator/CalculatorService.java | 35 + .../java/calculator/CalculatorServiceImpl.java | 70 + .../src/test/java/calculator/DivideService.java | 25 + .../test/java/calculator/DivideServiceImpl.java | 30 + .../src/test/java/calculator/MultiplyService.java | 25 + .../test/java/calculator/MultiplyServiceImpl.java | 30 + .../src/test/java/calculator/SubtractService.java | 25 + .../test/java/calculator/SubtractServiceImpl.java | 30 + .../org/apache/tuscany/api/SCARuntimeTestCase.java | 57 + .../embedded/SimpleRuntimeImplTestCase.java | 60 + .../src/test/resources/application.composite | 46 + .../embedded/src/test/resources/system.composite | 349 +++ sandbox/rfeng/samples.M2/creditws-axis2/.classpath | 45 + sandbox/rfeng/samples.M2/creditws-axis2/.project | 17 + sandbox/rfeng/samples.M2/creditws-axis2/build.xml | 109 + .../build/lib/CreditCheckService.aar | Bin 0 -> 15388 bytes .../resources/CreditCheckService.wsdl | 71 + .../creditws-axis2/resources/services.xml | 14 + .../CreditCheckServiceMessageReceiverInOut.java | 144 + .../src/credit/CreditCheckServiceSkeleton.java | 29 + .../creditws-axis2/src/credit/ExtensionMapper.java | 24 + .../creditws-axis2/src/credit/GetCreditScore.java | 301 +++ .../src/credit/GetCreditScoreResponse.java | 290 ++ .../samples.M2/creditws-axis2/wsdl/credit.wsdl | 81 + sandbox/rfeng/samples.M2/creditws/.ruleset | 172 ++ sandbox/rfeng/samples.M2/creditws/pom.xml | 102 + .../creditws/src/main/java/credit/CreditCheck.java | 26 + .../src/main/java/credit/CreditCheckImpl.java | 34 + .../src/main/resources/META-INF/LICENSE.txt | 1277 +++++++++ .../creditws/src/main/resources/META-INF/NOTICE | 18 + .../src/main/resources/META-INF/README.txt | 35 + .../creditws/src/main/resources/wsdl/credit.wsdl | 81 + .../src/main/webapp/META-INF/tuscany/webapp.scdl | 139 + .../creditws/src/main/webapp/WEB-INF/default.scdl | 35 + .../creditws/src/main/webapp/WEB-INF/web.xml | 41 + sandbox/rfeng/samples.M2/mortgage/pom.xml | 79 + .../src/main/java/mortgage/CreditCheck.java | 29 + .../src/main/java/mortgage/CreditCheckImpl.java | 32 + .../mortgage/src/main/java/mortgage/Customer.java | 75 + .../src/main/java/mortgage/InterestRateQuote.java | 23 + .../main/java/mortgage/InterestRateQuoteImpl.java | 31 + .../src/main/java/mortgage/LoanApproval.java | 27 + .../src/main/java/mortgage/LoanApprovalImpl.java | 78 + .../src/main/java/mortgage/MortgageCalculator.java | 29 + .../main/java/mortgage/MortgageCalculatorImpl.java | 37 + .../src/main/java/mortgage/MortgageClient.java | 43 + .../src/main/java/mortgage/RiskAssessment.java | 27 + .../src/main/java/mortgage/RiskAssessmentImpl.java | 37 + .../src/main/resources/META-INF/LICENSE.txt | 1277 +++++++++ .../mortgage/src/main/resources/META-INF/NOTICE | 18 + .../src/main/resources/META-INF/sca/default.scdl | 47 + .../src/main/resources/META-INF/sca/default1.scdl | 50 + .../src/main/resources/META-INF/sca/default2.scdl | 50 + .../resources/MortgageCalculator.componentType | 27 + .../src/main/resources/MortgageCalculator.js | 25 + .../src/main/resources/doc/credit_composite.jpg | Bin 0 -> 73610 bytes .../src/main/resources/doc/credit_composite.png | Bin 0 -> 51153 bytes .../src/main/resources/doc/loan_approval.jpg | Bin 0 -> 162536 bytes .../src/main/resources/doc/loan_approval.png | Bin 0 -> 58247 bytes .../src/main/resources/doc/mortgage_assembly0.jpg | Bin 0 -> 145053 bytes .../src/main/resources/doc/mortgage_assembly0.png | Bin 0 -> 93773 bytes .../src/main/resources/doc/mortgage_assembly1.jpg | Bin 0 -> 181317 bytes .../src/main/resources/doc/mortgage_assembly1.png | Bin 0 -> 113404 bytes .../src/main/resources/doc/mortgage_assembly2.jpg | Bin 0 -> 180240 bytes .../src/main/resources/doc/mortgage_assembly2.png | Bin 0 -> 106656 bytes .../src/main/resources/doc/mortgage_composite.jpg | Bin 0 -> 343699 bytes .../src/main/resources/doc/mortgage_composite.png | Bin 0 -> 288351 bytes .../src/main/resources/doc/mortgage_diagrams.doc | Bin 0 -> 2278400 bytes .../src/main/resources/doc/mortgage_package1.jpg | Bin 0 -> 181031 bytes .../src/main/resources/doc/mortgage_package1.png | Bin 0 -> 34939 bytes .../src/main/resources/doc/mortgage_package2.jpg | Bin 0 -> 110930 bytes .../src/main/resources/doc/mortgage_package2.png | Bin 0 -> 58993 bytes .../src/main/resources/doc/mortgage_scenario.jpg | Bin 0 -> 185793 bytes .../src/main/resources/doc/mortgage_scenario.png | Bin 0 -> 106791 bytes .../mortgage/src/main/resources/doc/readme.html | 136 + .../mortgage/src/main/resources/wsdl/credit.wsdl | 84 + .../test/java/mortgage/MortgageClientTestCase.java | 61 + sandbox/rfeng/samples/calculatorws/.ruleset | 172 ++ sandbox/rfeng/samples/calculatorws/pom.xml | 130 + .../src/main/java/calculator/AddService.java | 25 + .../src/main/java/calculator/AddServiceImpl.java | 33 + .../src/main/java/calculator/CalculatorClient.java | 42 + .../main/java/calculator/CalculatorService.java | 38 + .../java/calculator/CalculatorServiceImpl.java | 72 + .../src/main/java/calculator/DivideService.java | 25 + .../main/java/calculator/DivideServiceImpl.java | 33 + .../src/main/java/calculator/MultiplyService.java | 25 + .../main/java/calculator/MultiplyServiceImpl.java | 33 + .../src/main/java/calculator/SubtractService.java | 25 + .../main/java/calculator/SubtractServiceImpl.java | 33 + .../src/main/resources/META-INF/LICENSE.txt | 1277 +++++++++ .../src/main/resources/META-INF/NOTICE | 18 + .../src/main/resources/META-INF/README.txt | 35 + .../src/main/resources/wsdl/calculator.wsdl | 155 ++ .../src/main/webapp/META-INF/sca/default.scdl | 57 + .../webapp/META-INF/tuscany/binding.axis2.scdl | 44 + .../webapp/META-INF/tuscany/databinding.axiom.scdl | 48 + .../webapp/META-INF/tuscany/databinding.sdo.scdl | 60 + .../webapp/META-INF/tuscany/interface.wsdl.scdl | 44 + .../src/main/webapp/META-INF/tuscany/webapp.scdl | 138 + .../calculatorws/src/main/webapp/WEB-INF/web.xml | 51 + sandbox/rfeng/samples/creditws/.ruleset | 172 ++ sandbox/rfeng/samples/creditws/pom.xml | 103 + .../creditws/src/main/java/credit/CreditCheck.java | 26 + .../src/main/java/credit/CreditCheckImpl.java | 34 + .../src/main/resources/META-INF/LICENSE.txt | 1277 +++++++++ .../creditws/src/main/resources/META-INF/NOTICE | 18 + .../src/main/resources/META-INF/README.txt | 35 + .../creditws/src/main/resources/wsdl/credit.wsdl | 81 + .../src/main/webapp/META-INF/tuscany/webapp.scdl | 139 + .../creditws/src/main/webapp/WEB-INF/default.scdl | 35 + .../creditws/src/main/webapp/WEB-INF/web.xml | 41 + sandbox/rfeng/samples/echo.databinding/.ruleset | 190 ++ sandbox/rfeng/samples/echo.databinding/NOTICE.txt | 14 + sandbox/rfeng/samples/echo.databinding/pom.xml | 112 + .../main/resources/META-INF/sca/binding.echo.scdl | 31 + .../src/test/java/echo/ComponentAImpl.java | 94 + .../src/test/java/echo/ComponentBImpl.java | 59 + .../src/test/java/echo/DataBindingITest.java | 51 + .../echo.databinding/src/test/java/echo/Echo.java | 32 + .../src/test/java/echo/Interface1.java | 32 + .../src/test/java/echo/Interface2.java | 36 + .../src/test/resources/wsdl/echo.wsdl | 45 + sandbox/rfeng/samples/mortgage/pom.xml | 142 + .../src/main/java/mortgage/CreditCheck.java | 29 + .../src/main/java/mortgage/CreditCheckImpl.java | 32 + .../mortgage/src/main/java/mortgage/Customer.java | 75 + .../src/main/java/mortgage/InterestRateQuote.java | 23 + .../main/java/mortgage/InterestRateQuoteImpl.java | 31 + .../src/main/java/mortgage/LoanApproval.java | 27 + .../src/main/java/mortgage/LoanApprovalImpl.java | 72 + .../src/main/java/mortgage/MortgageCalculator.java | 29 + .../main/java/mortgage/MortgageCalculatorImpl.java | 37 + .../src/main/java/mortgage/MortgageClient.java | 46 + .../src/main/java/mortgage/RiskAssessment.java | 27 + .../src/main/java/mortgage/RiskAssessmentImpl.java | 37 + .../src/main/resources/META-INF/LICENSE.txt | 1277 +++++++++ .../mortgage/src/main/resources/META-INF/NOTICE | 18 + .../src/main/resources/META-INF/sca/default.scdl | 48 + .../src/main/resources/META-INF/sca/default1.scdl | 50 + .../src/main/resources/META-INF/sca/default2.scdl | 50 + .../resources/MortgageCalculator.componentType | 27 + .../src/main/resources/MortgageCalculator.js | 25 + .../src/main/resources/doc/credit_composite.jpg | Bin 0 -> 73610 bytes .../src/main/resources/doc/credit_composite.png | Bin 0 -> 51153 bytes .../src/main/resources/doc/loan_approval.jpg | Bin 0 -> 162536 bytes .../src/main/resources/doc/loan_approval.png | Bin 0 -> 58247 bytes .../src/main/resources/doc/mortgage_assembly0.jpg | Bin 0 -> 145053 bytes .../src/main/resources/doc/mortgage_assembly0.png | Bin 0 -> 93773 bytes .../src/main/resources/doc/mortgage_assembly1.jpg | Bin 0 -> 181317 bytes .../src/main/resources/doc/mortgage_assembly1.png | Bin 0 -> 113404 bytes .../src/main/resources/doc/mortgage_assembly2.jpg | Bin 0 -> 180240 bytes .../src/main/resources/doc/mortgage_assembly2.png | Bin 0 -> 106656 bytes .../src/main/resources/doc/mortgage_composite.jpg | Bin 0 -> 343699 bytes .../src/main/resources/doc/mortgage_composite.png | Bin 0 -> 288351 bytes .../src/main/resources/doc/mortgage_diagrams.doc | Bin 0 -> 2278400 bytes .../src/main/resources/doc/mortgage_package1.jpg | Bin 0 -> 181031 bytes .../src/main/resources/doc/mortgage_package1.png | Bin 0 -> 34939 bytes .../src/main/resources/doc/mortgage_package2.jpg | Bin 0 -> 110930 bytes .../src/main/resources/doc/mortgage_package2.png | Bin 0 -> 58993 bytes .../src/main/resources/doc/mortgage_scenario.jpg | Bin 0 -> 225690 bytes .../src/main/resources/doc/mortgage_scenario.png | Bin 0 -> 106791 bytes .../mortgage/src/main/resources/doc/readme.html | 136 + .../mortgage/src/main/resources/wsdl/credit.wsdl | 84 + .../test/java/mortgage/MortgageClientTestCase.java | 61 + sandbox/rfeng/samples/pom.xml | 38 + 477 files changed, 40750 insertions(+) create mode 100644 sandbox/rfeng/aop-logging/.checkstyle create mode 100644 sandbox/rfeng/aop-logging/.pmd create mode 100644 sandbox/rfeng/aop-logging/.ruleset create mode 100644 sandbox/rfeng/aop-logging/LICENSE.txt create mode 100644 sandbox/rfeng/aop-logging/NOTICE.txt create mode 100644 sandbox/rfeng/aop-logging/pom.xml create mode 100644 sandbox/rfeng/aop-logging/src/main/java/org/apache/tuscany/sca/aspectj/LoggingAspect.java create mode 100644 sandbox/rfeng/aop-logging/src/main/java/org/apache/tuscany/sca/aspectj/TracingAspect.java create mode 100644 sandbox/rfeng/aop-logging/src/test/java/org/apache/tuscany/sca/aspectj/MyTracingAspect.java create mode 100644 sandbox/rfeng/aop-logging/src/test/java/org/apache/tuscany/sca/aspectj/TracingTestCase.java create mode 100644 sandbox/rfeng/aop-logging/src/test/resources/META-INF/aop.xml create mode 100644 sandbox/rfeng/aop-logging/test.bat create mode 100644 sandbox/rfeng/geronimo-demo/LICENSE.TXT create mode 100644 sandbox/rfeng/geronimo-demo/README.TXT create mode 100644 sandbox/rfeng/geronimo-demo/bigbank/src/main/java/bigbank/account/AccountReport.java create mode 100644 sandbox/rfeng/geronimo-demo/bigbank/src/main/java/bigbank/account/AccountService.java create mode 100644 sandbox/rfeng/geronimo-demo/bigbank/src/main/java/bigbank/account/AccountServiceImpl.java create mode 100644 sandbox/rfeng/geronimo-demo/bigbank/src/main/java/bigbank/accountdata/Account.java create mode 100644 sandbox/rfeng/geronimo-demo/bigbank/src/main/java/bigbank/accountdata/AccountDataService.java create mode 100644 sandbox/rfeng/geronimo-demo/bigbank/src/main/java/bigbank/accountdata/AccountDataServiceImpl.java create mode 100644 sandbox/rfeng/geronimo-demo/bigbank/src/main/java/bigbank/accountdata/BrokerService.java create mode 100644 sandbox/rfeng/geronimo-demo/bigbank/src/main/java/bigbank/accountdata/CheckingAccount.java create mode 100644 sandbox/rfeng/geronimo-demo/bigbank/src/main/java/bigbank/accountdata/SavingsAccount.java create mode 100644 sandbox/rfeng/geronimo-demo/bigbank/src/main/java/bigbank/accountdata/StockAccount.java create mode 100644 sandbox/rfeng/geronimo-demo/bigbank/src/main/java/bigbank/client/BigBankClient.java create mode 100644 sandbox/rfeng/geronimo-demo/bigbank/src/main/java/bigbank/stockquote/StockQuoteImpl.java create mode 100644 sandbox/rfeng/geronimo-demo/bigbank/src/main/java/bigbank/stockquote/StockQuoteService.java create mode 100644 sandbox/rfeng/geronimo-demo/bigbank/src/main/resources/BigBank.composite create mode 100644 sandbox/rfeng/geronimo-demo/bigbank/src/main/resources/wsdl/account.wsdl create mode 100644 sandbox/rfeng/geronimo-demo/bigbank/src/test/java/bigbank/BigBankTestCase.java create mode 100644 sandbox/rfeng/geronimo-demo/ejbs/ejbModule/META-INF/MANIFEST.MF create mode 100644 sandbox/rfeng/geronimo-demo/ejbs/ejbModule/META-INF/ejb-jar.xml create mode 100644 sandbox/rfeng/geronimo-demo/ejbs/ejbModule/META-INF/openejb-jar.xml create mode 100644 sandbox/rfeng/geronimo-demo/ejbs/ejbModule/bigbank/accountdata/BrokerService.java create mode 100644 sandbox/rfeng/geronimo-demo/ejbs/ejbModule/bigbank/accountdata/BrokerServiceBean.java create mode 100644 sandbox/rfeng/geronimo-demo/ejbs/ejbModule/bigbank/accountdata/BrokerServiceHome.java create mode 100644 sandbox/rfeng/geronimo-demo/ejbs/ejbModule/calculator/AddService.java create mode 100644 sandbox/rfeng/geronimo-demo/ejbs/ejbModule/calculator/AddServiceBean.java create mode 100644 sandbox/rfeng/geronimo-demo/ejbs/ejbModule/calculator/AddServiceHome.java create mode 100644 sandbox/rfeng/geronimo-demo/ejbs/ejbModule/calculator/AddServiceLocal.java create mode 100644 sandbox/rfeng/geronimo-demo/ejbs/ejbModule/calculator/AddServiceLocalHome.java create mode 100644 sandbox/rfeng/geronimo-demo/ejbs/ejbModule/hello/Hello.java create mode 100644 sandbox/rfeng/geronimo-demo/ejbs/ejbModule/hello/HelloBean.java create mode 100644 sandbox/rfeng/geronimo-demo/ejbs/ejbModule/hello/HelloHome.java create mode 100644 sandbox/rfeng/geronimo-demo/ejbs/ejbModule/hello/HelloLocal.java create mode 100644 sandbox/rfeng/geronimo-demo/ejbs/ejbModule/hello/HelloLocalHome.java create mode 100644 sandbox/rfeng/geronimo-demo/scenario.doc create mode 100644 sandbox/rfeng/geronimo-demo/scenario.png create mode 100644 sandbox/rfeng/geronimo-demo/webs/WebContent/META-INF/MANIFEST.MF create mode 100644 sandbox/rfeng/geronimo-demo/webs/WebContent/WEB-INF/geronimo-web.xml create mode 100644 sandbox/rfeng/geronimo-demo/webs/WebContent/WEB-INF/web.xml create mode 100644 sandbox/rfeng/geronimo-demo/webs/WebContent/index.jsp create mode 100644 sandbox/rfeng/geronimo-demo/webs/src/bigbank/accountdata/AccountService.java create mode 100644 sandbox/rfeng/minicore/.checkstyle create mode 100644 sandbox/rfeng/minicore/.pmd create mode 100644 sandbox/rfeng/minicore/.ruleset create mode 100644 sandbox/rfeng/minicore/LICENSE.txt create mode 100644 sandbox/rfeng/minicore/NOTICE.txt create mode 100644 sandbox/rfeng/minicore/pom.xml create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/AbstractLocalTargetInvoker.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/LocalBindingBuilder.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/LocalBindingDefinition.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/LocalBindingLoader.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/LocalCallbackTargetInvoker.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/LocalReferenceBinding.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/LocalServiceBinding.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/LocalTargetInvoker.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/bootstrap/Bootstrapper.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/bootstrap/DefaultBootstrapper.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/bootstrap/ExtensionActivator.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/BuilderRegistryImpl.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/ComponentNotFoundException.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/ConnectorImpl.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/IllegalCallbackException.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/IncompatibleInterfacesException.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/InvalidSourceTypeException.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/InvalidTargetTypeException.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/NoBindingException.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/NoCompatibleBindingsException.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/NoConversationalContractException.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/NoRegisteredBuilderException.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/SourceServiceNotFoundException.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/TargetServiceNotFoundException.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/WireCreationException.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/WirePostProcessorRegistryImpl.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/WiringExceptionFormatter.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/CallableReferenceImpl.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/CallbackReferenceImpl.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/ComponentContextImpl.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/ComponentContextProvider.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/ComponentManagerImpl.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/ScopeIdentifier.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/ServiceReferenceImpl.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/SimpleWorkContext.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/SystemSingletonAtomicComponent.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/WorkContextImpl.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/AbstractEvent.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/AbstractRequestEvent.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/ComponentEvent.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/ComponentStart.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/ComponentStop.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/ConversationEnd.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/ConversationStart.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/ConversationalEvent.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/HttpRequestEnded.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/HttpRequestStart.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/HttpSessionEnd.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/HttpSessionEvent.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/HttpSessionStart.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/RequestEnd.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/RequestEvent.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/RequestStart.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/scope/AbstractScopeContainer.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/scope/CompositeScopeContainer.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainer.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/scope/HttpSessionScopeContainer.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/scope/InstanceWrapperBase.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/scope/RequestScopeContainer.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/scope/ScopeRegistryImpl.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/scope/StatelessScopeContainer.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/deployer/AbstractDeploymentContext.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/deployer/ChildDeploymentContext.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/deployer/DeployerImpl.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/deployer/RootDeploymentContext.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/implementation/PojoWorkContextTunnel.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/implementation/composite/AbstractCompositeBuilder.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/implementation/composite/ComponentTimeoutException.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeBuilder.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeComponentImpl.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeComponentTypeLoader.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeLoader.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/implementation/composite/ManagedRequestContext.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/implementation/composite/ReferenceImpl.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/implementation/composite/ServiceImpl.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/injection/SingletonObjectFactory.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/loader/ComponentLoader.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/loader/ComponentTypeElementLoader.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/loader/IncludeLoader.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/loader/LoaderExceptionFormatter.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/loader/LoaderRegistryImpl.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/loader/PolicySetLoader.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/loader/PropertyLoader.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/loader/PropertyUtils.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/loader/ReferenceLoader.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/loader/ServiceLoader.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/loader/StringParserPropertyFactory.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/loader/WireLoader.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/monitor/DefaultExceptionFormatter.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/monitor/InvalidLevelException.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/monitor/JavaLoggingMonitorFactory.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/monitor/MonitorFactoryUtil.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/monitor/NullMonitorFactory.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/monitor/ProxyMonitorFactory.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/resolver/AutowireResolver.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/resolver/AutowireTargetNotFoundException.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/resolver/DefaultAutowireResolver.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/runtime/AbstractRuntime.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/services/classloading/ClassLoaderRegistryImpl.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/services/store/memory/MemoryStore.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/util/FileHelper.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/util/IOHelper.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/util/JavaIntrospectionHelper.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/CallbackInterfaceInterceptor.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/IncompatibleServiceContractExceptionFormatter.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/InvocationChainImpl.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/InvokerInterceptor.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/NoMethodForOperationException.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/NonBlockingInterceptor.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/NonBlockingInterceptorBuilder.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/OptimizedWireObjectFactory.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/ProxyServiceExtension.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/WireImpl.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/WireObjectFactory.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/WireObjectFactory2.java create mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/WireUtils.java create mode 100644 sandbox/rfeng/minicore/src/main/resources/org/apache/tuscany/core/composite.scdl create mode 100644 sandbox/rfeng/minicore/src/main/resources/org/apache/tuscany/core/deployment.scdl create mode 100644 sandbox/rfeng/minicore/src/main/resources/org/apache/tuscany/core/formatters.scdl create mode 100644 sandbox/rfeng/minicore/src/main/resources/org/apache/tuscany/core/implementation.scdl create mode 100644 sandbox/rfeng/minicore/src/main/resources/org/apache/tuscany/core/interfaceJava.scdl create mode 100644 sandbox/rfeng/minicore/src/main/resources/org/apache/tuscany/core/javaImplementation.scdl create mode 100644 sandbox/rfeng/minicore/src/main/resources/org/apache/tuscany/core/loader.scdl create mode 100644 sandbox/rfeng/minicore/src/main/resources/org/apache/tuscany/core/systemImplementation.scdl create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/binding/local/AbstractLocalTargetInvokerTestCase.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/binding/local/LocalBindingBuilderTestCase.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/binding/local/LocalBindingLoaderTestCase.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/binding/local/LocalCallbackTargetInvokerInvocationExceptionTestCase.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/binding/local/LocalCallbackTargetInvokerTestCase.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/binding/local/LocalCallbackTargetInvokerThrowableTestCase.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/binding/local/LocalTargetInvokerTestCase.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/builder/BuilderRegistryNoBindingsTestCase.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/builder/BuilderRegistryTestCase.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/builder/ConnectorImplTestCase.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/builder/IllegalCallbackExceptionTestCase.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/builder/IncompatibleInterfacesExceptionTestCase.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/builder/InvalidSourceTypeExceptionTestCase.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/builder/InvalidTargetTypeExceptionTestCase.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/builder/TargetServiceNotFoundExceptionTestCase.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/builder/WirePostProcessorRegistryImplTestCase.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/builder/WiringExceptionFormatterTestCase.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/ComponentManagerImplTestCase.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/JavaObjectRegistrationTestCase.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/SystemSingletonAtomicComponentTestCase.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/event/EventTestCase.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/AbstractScopeContainerTestCase.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/BasicCompositeScopeTestCase.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/BasicConversationalScopeTestCase.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/BasicHttpSessionScopeTestCase.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/BasicRequestScopeTestCase.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/BasicStatelessScopeTestCase.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/CompositeScopeInitDestroyErrorTestCase.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainerDestroyOnExpirationTestCase.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainerMaxAgeTestCase.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainerMaxIdleTimeTestCase.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainerPersistenceTestCase.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/InstanceWrapperBaseTestCase.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/WorkContextTestCase.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeComponentImplTestCase.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/implementation/composite/DuplicateRegistrationTestCase.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/implementation/composite/ManagedRequestContextTestCase.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/implementation/composite/ReferenceImplTestCase.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/implementation/composite/ServiceImplTestCase.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/injection/SingletonObjectFactoryTestCase.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/AsyncTarget.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/BadContextPojo.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/BadNamePojo.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/BasicInterface.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/BasicInterfaceImpl.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/CompositeScopeComponent.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/CompositeScopeComponentImpl.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/CompositeScopeDestroyOnlyComponent.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/CompositeScopeInitDestroyComponent.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/CompositeScopeInitOnlyComponent.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/ConversationalScopeComponent.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/ConversationalScopeComponentImpl.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/ConversationalScopeDestroyOnlyComponent.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/ConversationalScopeInitDestroyComponent.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/ConversationalScopeInitOnlyComponent.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/OrderException.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/OrderedDependentPojo.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/OrderedDependentPojoImpl.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/OrderedEagerInitPojo.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/OrderedInitPojo.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/OrderedInitPojoImpl.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/OtherTarget.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/OtherTargetImpl.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/RequestScopeComponent.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/RequestScopeDestroyOnlyComponent.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/RequestScopeInitDestroyComponent.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/RequestScopeInitOnlyComponent.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/SessionScopeComponent.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/SessionScopeComponentImpl.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/SessionScopeInitDestroyComponent.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/SessionScopeInitOnlyComponent.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/SimpleTarget.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/SimpleTargetImpl.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/Source.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/SourceImpl.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/StatelessComponent.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/StatelessComponentImpl.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/Target.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/TargetImpl.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/wire/MockStaticInvoker.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/wire/MockSyncInterceptor.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/wire/MockTargetInvoker.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/monitor/DefaultExceptionFormatterTestCase.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/monitor/JavaLoggingTestCase.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/resolver/DefaultAutowireResolverTestCase.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/services/store/memory/MemoryStoreTestCase.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/util/Bean1.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/util/Bean2.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/util/JavaIntrospectionHelperTestCase.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/util/SuperBean.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/wire/CallbackInterfaceInterceptorTestCase.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/wire/ContractCompatibilityTestCase.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/wire/IncompatibleServiceContractExceptionFormatterTestCase.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/wire/InvocationChainImplTestCase.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/wire/NonBlockingInterceptorBuilderTestCase.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/wire/NonBlockingInterceptorTestCase.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/wire/OptimizedWireObjectFactoryTestCase.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/wire/WireImplTestCase.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/wire/WireObjectFactoryTestCase.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/wire/WireOptimizationTestCase.java create mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/wire/WireUtilsTestCase.java create mode 100644 sandbox/rfeng/minicore/src/test/resources/deployables/sample-calculator.jar create mode 100644 sandbox/rfeng/minicore/src/test/resources/marshall/javaChangeSet.xml create mode 100644 sandbox/rfeng/minicore/src/test/resources/org/apache/tuscany/core/deployer/boot1-include.scdl create mode 100644 sandbox/rfeng/minicore/src/test/resources/org/apache/tuscany/core/deployer/boot1.scdl create mode 100644 sandbox/rfeng/minicore/src/test/resources/org/apache/tuscany/core/deployer/boot2.scdl create mode 100644 sandbox/rfeng/minicore/src/test/resources/org/apache/tuscany/core/loader/TestPolicy.scdl create mode 100644 sandbox/rfeng/minicore/src/test/resources/org/apache/tuscany/core/loader/test-include.scdl create mode 100644 sandbox/rfeng/minicore/src/test/resources/org/apache/tuscany/core/policy/PolicySet.scdl create mode 100644 sandbox/rfeng/minicore/src/test/resources/org/apache/tuscany/core/property/ipo.xml create mode 100644 sandbox/rfeng/minicore/src/test/resources/org/apache/tuscany/core/services/deployment/test.ext create mode 100644 sandbox/rfeng/minicore/src/test/resources/org/apache/tuscany/core/services/deployment/test.scdl create mode 100644 sandbox/rfeng/minicore/src/test/resources/repository/sample-calculator.jar create mode 100644 sandbox/rfeng/runtime/embedded/.checkstyle create mode 100644 sandbox/rfeng/runtime/embedded/.pmd create mode 100644 sandbox/rfeng/runtime/embedded/.ruleset create mode 100644 sandbox/rfeng/runtime/embedded/LICENSE.txt create mode 100644 sandbox/rfeng/runtime/embedded/NOTICE.txt create mode 100644 sandbox/rfeng/runtime/embedded/pom.xml create mode 100644 sandbox/rfeng/runtime/embedded/src/main/java/org/apache/tuscany/api/SCARuntime.java create mode 100644 sandbox/rfeng/runtime/embedded/src/main/java/org/apache/tuscany/runtime/embedded/DefaultSCARuntime.java create mode 100644 sandbox/rfeng/runtime/embedded/src/main/java/org/apache/tuscany/runtime/embedded/SimpleRuntime.java create mode 100644 sandbox/rfeng/runtime/embedded/src/main/java/org/apache/tuscany/runtime/embedded/SimpleRuntimeImpl.java create mode 100644 sandbox/rfeng/runtime/embedded/src/main/java/org/apache/tuscany/runtime/embedded/SimpleRuntimeInfo.java create mode 100644 sandbox/rfeng/runtime/embedded/src/main/java/org/apache/tuscany/runtime/embedded/SimpleRuntimeInfoImpl.java create mode 100644 sandbox/rfeng/runtime/embedded/src/test/java/calculator/AddService.java create mode 100644 sandbox/rfeng/runtime/embedded/src/test/java/calculator/AddServiceImpl.java create mode 100644 sandbox/rfeng/runtime/embedded/src/test/java/calculator/CalculatorClient.java create mode 100644 sandbox/rfeng/runtime/embedded/src/test/java/calculator/CalculatorService.java create mode 100644 sandbox/rfeng/runtime/embedded/src/test/java/calculator/CalculatorServiceImpl.java create mode 100644 sandbox/rfeng/runtime/embedded/src/test/java/calculator/DivideService.java create mode 100644 sandbox/rfeng/runtime/embedded/src/test/java/calculator/DivideServiceImpl.java create mode 100644 sandbox/rfeng/runtime/embedded/src/test/java/calculator/MultiplyService.java create mode 100644 sandbox/rfeng/runtime/embedded/src/test/java/calculator/MultiplyServiceImpl.java create mode 100644 sandbox/rfeng/runtime/embedded/src/test/java/calculator/SubtractService.java create mode 100644 sandbox/rfeng/runtime/embedded/src/test/java/calculator/SubtractServiceImpl.java create mode 100644 sandbox/rfeng/runtime/embedded/src/test/java/org/apache/tuscany/api/SCARuntimeTestCase.java create mode 100644 sandbox/rfeng/runtime/embedded/src/test/java/org/apache/tuscany/runtime/embedded/SimpleRuntimeImplTestCase.java create mode 100644 sandbox/rfeng/runtime/embedded/src/test/resources/application.composite create mode 100644 sandbox/rfeng/runtime/embedded/src/test/resources/system.composite create mode 100644 sandbox/rfeng/samples.M2/creditws-axis2/.classpath create mode 100644 sandbox/rfeng/samples.M2/creditws-axis2/.project create mode 100644 sandbox/rfeng/samples.M2/creditws-axis2/build.xml create mode 100644 sandbox/rfeng/samples.M2/creditws-axis2/build/lib/CreditCheckService.aar create mode 100644 sandbox/rfeng/samples.M2/creditws-axis2/resources/CreditCheckService.wsdl create mode 100644 sandbox/rfeng/samples.M2/creditws-axis2/resources/services.xml create mode 100644 sandbox/rfeng/samples.M2/creditws-axis2/src/credit/CreditCheckServiceMessageReceiverInOut.java create mode 100644 sandbox/rfeng/samples.M2/creditws-axis2/src/credit/CreditCheckServiceSkeleton.java create mode 100644 sandbox/rfeng/samples.M2/creditws-axis2/src/credit/ExtensionMapper.java create mode 100644 sandbox/rfeng/samples.M2/creditws-axis2/src/credit/GetCreditScore.java create mode 100644 sandbox/rfeng/samples.M2/creditws-axis2/src/credit/GetCreditScoreResponse.java create mode 100644 sandbox/rfeng/samples.M2/creditws-axis2/wsdl/credit.wsdl create mode 100644 sandbox/rfeng/samples.M2/creditws/.ruleset create mode 100644 sandbox/rfeng/samples.M2/creditws/pom.xml create mode 100644 sandbox/rfeng/samples.M2/creditws/src/main/java/credit/CreditCheck.java create mode 100644 sandbox/rfeng/samples.M2/creditws/src/main/java/credit/CreditCheckImpl.java create mode 100644 sandbox/rfeng/samples.M2/creditws/src/main/resources/META-INF/LICENSE.txt create mode 100644 sandbox/rfeng/samples.M2/creditws/src/main/resources/META-INF/NOTICE create mode 100644 sandbox/rfeng/samples.M2/creditws/src/main/resources/META-INF/README.txt create mode 100644 sandbox/rfeng/samples.M2/creditws/src/main/resources/wsdl/credit.wsdl create mode 100644 sandbox/rfeng/samples.M2/creditws/src/main/webapp/META-INF/tuscany/webapp.scdl create mode 100644 sandbox/rfeng/samples.M2/creditws/src/main/webapp/WEB-INF/default.scdl create mode 100644 sandbox/rfeng/samples.M2/creditws/src/main/webapp/WEB-INF/web.xml create mode 100644 sandbox/rfeng/samples.M2/mortgage/pom.xml create mode 100644 sandbox/rfeng/samples.M2/mortgage/src/main/java/mortgage/CreditCheck.java create mode 100644 sandbox/rfeng/samples.M2/mortgage/src/main/java/mortgage/CreditCheckImpl.java create mode 100644 sandbox/rfeng/samples.M2/mortgage/src/main/java/mortgage/Customer.java create mode 100644 sandbox/rfeng/samples.M2/mortgage/src/main/java/mortgage/InterestRateQuote.java create mode 100644 sandbox/rfeng/samples.M2/mortgage/src/main/java/mortgage/InterestRateQuoteImpl.java create mode 100644 sandbox/rfeng/samples.M2/mortgage/src/main/java/mortgage/LoanApproval.java create mode 100644 sandbox/rfeng/samples.M2/mortgage/src/main/java/mortgage/LoanApprovalImpl.java create mode 100644 sandbox/rfeng/samples.M2/mortgage/src/main/java/mortgage/MortgageCalculator.java create mode 100644 sandbox/rfeng/samples.M2/mortgage/src/main/java/mortgage/MortgageCalculatorImpl.java create mode 100644 sandbox/rfeng/samples.M2/mortgage/src/main/java/mortgage/MortgageClient.java create mode 100644 sandbox/rfeng/samples.M2/mortgage/src/main/java/mortgage/RiskAssessment.java create mode 100644 sandbox/rfeng/samples.M2/mortgage/src/main/java/mortgage/RiskAssessmentImpl.java create mode 100644 sandbox/rfeng/samples.M2/mortgage/src/main/resources/META-INF/LICENSE.txt create mode 100644 sandbox/rfeng/samples.M2/mortgage/src/main/resources/META-INF/NOTICE create mode 100644 sandbox/rfeng/samples.M2/mortgage/src/main/resources/META-INF/sca/default.scdl create mode 100644 sandbox/rfeng/samples.M2/mortgage/src/main/resources/META-INF/sca/default1.scdl create mode 100644 sandbox/rfeng/samples.M2/mortgage/src/main/resources/META-INF/sca/default2.scdl create mode 100644 sandbox/rfeng/samples.M2/mortgage/src/main/resources/MortgageCalculator.componentType create mode 100644 sandbox/rfeng/samples.M2/mortgage/src/main/resources/MortgageCalculator.js create mode 100644 sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/credit_composite.jpg create mode 100644 sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/credit_composite.png create mode 100644 sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/loan_approval.jpg create mode 100644 sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/loan_approval.png create mode 100644 sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/mortgage_assembly0.jpg create mode 100644 sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/mortgage_assembly0.png create mode 100644 sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/mortgage_assembly1.jpg create mode 100644 sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/mortgage_assembly1.png create mode 100644 sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/mortgage_assembly2.jpg create mode 100644 sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/mortgage_assembly2.png create mode 100644 sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/mortgage_composite.jpg create mode 100644 sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/mortgage_composite.png create mode 100644 sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/mortgage_diagrams.doc create mode 100644 sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/mortgage_package1.jpg create mode 100644 sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/mortgage_package1.png create mode 100644 sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/mortgage_package2.jpg create mode 100644 sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/mortgage_package2.png create mode 100644 sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/mortgage_scenario.jpg create mode 100644 sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/mortgage_scenario.png create mode 100644 sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/readme.html create mode 100644 sandbox/rfeng/samples.M2/mortgage/src/main/resources/wsdl/credit.wsdl create mode 100644 sandbox/rfeng/samples.M2/mortgage/src/test/java/mortgage/MortgageClientTestCase.java create mode 100644 sandbox/rfeng/samples/calculatorws/.ruleset create mode 100644 sandbox/rfeng/samples/calculatorws/pom.xml create mode 100644 sandbox/rfeng/samples/calculatorws/src/main/java/calculator/AddService.java create mode 100644 sandbox/rfeng/samples/calculatorws/src/main/java/calculator/AddServiceImpl.java create mode 100644 sandbox/rfeng/samples/calculatorws/src/main/java/calculator/CalculatorClient.java create mode 100644 sandbox/rfeng/samples/calculatorws/src/main/java/calculator/CalculatorService.java create mode 100644 sandbox/rfeng/samples/calculatorws/src/main/java/calculator/CalculatorServiceImpl.java create mode 100644 sandbox/rfeng/samples/calculatorws/src/main/java/calculator/DivideService.java create mode 100644 sandbox/rfeng/samples/calculatorws/src/main/java/calculator/DivideServiceImpl.java create mode 100644 sandbox/rfeng/samples/calculatorws/src/main/java/calculator/MultiplyService.java create mode 100644 sandbox/rfeng/samples/calculatorws/src/main/java/calculator/MultiplyServiceImpl.java create mode 100644 sandbox/rfeng/samples/calculatorws/src/main/java/calculator/SubtractService.java create mode 100644 sandbox/rfeng/samples/calculatorws/src/main/java/calculator/SubtractServiceImpl.java create mode 100644 sandbox/rfeng/samples/calculatorws/src/main/resources/META-INF/LICENSE.txt create mode 100644 sandbox/rfeng/samples/calculatorws/src/main/resources/META-INF/NOTICE create mode 100644 sandbox/rfeng/samples/calculatorws/src/main/resources/META-INF/README.txt create mode 100644 sandbox/rfeng/samples/calculatorws/src/main/resources/wsdl/calculator.wsdl create mode 100644 sandbox/rfeng/samples/calculatorws/src/main/webapp/META-INF/sca/default.scdl create mode 100644 sandbox/rfeng/samples/calculatorws/src/main/webapp/META-INF/tuscany/binding.axis2.scdl create mode 100644 sandbox/rfeng/samples/calculatorws/src/main/webapp/META-INF/tuscany/databinding.axiom.scdl create mode 100644 sandbox/rfeng/samples/calculatorws/src/main/webapp/META-INF/tuscany/databinding.sdo.scdl create mode 100644 sandbox/rfeng/samples/calculatorws/src/main/webapp/META-INF/tuscany/interface.wsdl.scdl create mode 100644 sandbox/rfeng/samples/calculatorws/src/main/webapp/META-INF/tuscany/webapp.scdl create mode 100644 sandbox/rfeng/samples/calculatorws/src/main/webapp/WEB-INF/web.xml create mode 100644 sandbox/rfeng/samples/creditws/.ruleset create mode 100644 sandbox/rfeng/samples/creditws/pom.xml create mode 100644 sandbox/rfeng/samples/creditws/src/main/java/credit/CreditCheck.java create mode 100644 sandbox/rfeng/samples/creditws/src/main/java/credit/CreditCheckImpl.java create mode 100644 sandbox/rfeng/samples/creditws/src/main/resources/META-INF/LICENSE.txt create mode 100644 sandbox/rfeng/samples/creditws/src/main/resources/META-INF/NOTICE create mode 100644 sandbox/rfeng/samples/creditws/src/main/resources/META-INF/README.txt create mode 100644 sandbox/rfeng/samples/creditws/src/main/resources/wsdl/credit.wsdl create mode 100644 sandbox/rfeng/samples/creditws/src/main/webapp/META-INF/tuscany/webapp.scdl create mode 100644 sandbox/rfeng/samples/creditws/src/main/webapp/WEB-INF/default.scdl create mode 100644 sandbox/rfeng/samples/creditws/src/main/webapp/WEB-INF/web.xml create mode 100644 sandbox/rfeng/samples/echo.databinding/.ruleset create mode 100644 sandbox/rfeng/samples/echo.databinding/NOTICE.txt create mode 100644 sandbox/rfeng/samples/echo.databinding/pom.xml create mode 100644 sandbox/rfeng/samples/echo.databinding/src/main/resources/META-INF/sca/binding.echo.scdl create mode 100644 sandbox/rfeng/samples/echo.databinding/src/test/java/echo/ComponentAImpl.java create mode 100644 sandbox/rfeng/samples/echo.databinding/src/test/java/echo/ComponentBImpl.java create mode 100644 sandbox/rfeng/samples/echo.databinding/src/test/java/echo/DataBindingITest.java create mode 100644 sandbox/rfeng/samples/echo.databinding/src/test/java/echo/Echo.java create mode 100644 sandbox/rfeng/samples/echo.databinding/src/test/java/echo/Interface1.java create mode 100644 sandbox/rfeng/samples/echo.databinding/src/test/java/echo/Interface2.java create mode 100644 sandbox/rfeng/samples/echo.databinding/src/test/resources/wsdl/echo.wsdl create mode 100644 sandbox/rfeng/samples/mortgage/pom.xml create mode 100644 sandbox/rfeng/samples/mortgage/src/main/java/mortgage/CreditCheck.java create mode 100644 sandbox/rfeng/samples/mortgage/src/main/java/mortgage/CreditCheckImpl.java create mode 100644 sandbox/rfeng/samples/mortgage/src/main/java/mortgage/Customer.java create mode 100644 sandbox/rfeng/samples/mortgage/src/main/java/mortgage/InterestRateQuote.java create mode 100644 sandbox/rfeng/samples/mortgage/src/main/java/mortgage/InterestRateQuoteImpl.java create mode 100644 sandbox/rfeng/samples/mortgage/src/main/java/mortgage/LoanApproval.java create mode 100644 sandbox/rfeng/samples/mortgage/src/main/java/mortgage/LoanApprovalImpl.java create mode 100644 sandbox/rfeng/samples/mortgage/src/main/java/mortgage/MortgageCalculator.java create mode 100644 sandbox/rfeng/samples/mortgage/src/main/java/mortgage/MortgageCalculatorImpl.java create mode 100644 sandbox/rfeng/samples/mortgage/src/main/java/mortgage/MortgageClient.java create mode 100644 sandbox/rfeng/samples/mortgage/src/main/java/mortgage/RiskAssessment.java create mode 100644 sandbox/rfeng/samples/mortgage/src/main/java/mortgage/RiskAssessmentImpl.java create mode 100644 sandbox/rfeng/samples/mortgage/src/main/resources/META-INF/LICENSE.txt create mode 100644 sandbox/rfeng/samples/mortgage/src/main/resources/META-INF/NOTICE create mode 100644 sandbox/rfeng/samples/mortgage/src/main/resources/META-INF/sca/default.scdl create mode 100644 sandbox/rfeng/samples/mortgage/src/main/resources/META-INF/sca/default1.scdl create mode 100644 sandbox/rfeng/samples/mortgage/src/main/resources/META-INF/sca/default2.scdl create mode 100644 sandbox/rfeng/samples/mortgage/src/main/resources/MortgageCalculator.componentType create mode 100644 sandbox/rfeng/samples/mortgage/src/main/resources/MortgageCalculator.js create mode 100644 sandbox/rfeng/samples/mortgage/src/main/resources/doc/credit_composite.jpg create mode 100644 sandbox/rfeng/samples/mortgage/src/main/resources/doc/credit_composite.png create mode 100644 sandbox/rfeng/samples/mortgage/src/main/resources/doc/loan_approval.jpg create mode 100644 sandbox/rfeng/samples/mortgage/src/main/resources/doc/loan_approval.png create mode 100644 sandbox/rfeng/samples/mortgage/src/main/resources/doc/mortgage_assembly0.jpg create mode 100644 sandbox/rfeng/samples/mortgage/src/main/resources/doc/mortgage_assembly0.png create mode 100644 sandbox/rfeng/samples/mortgage/src/main/resources/doc/mortgage_assembly1.jpg create mode 100644 sandbox/rfeng/samples/mortgage/src/main/resources/doc/mortgage_assembly1.png create mode 100644 sandbox/rfeng/samples/mortgage/src/main/resources/doc/mortgage_assembly2.jpg create mode 100644 sandbox/rfeng/samples/mortgage/src/main/resources/doc/mortgage_assembly2.png create mode 100644 sandbox/rfeng/samples/mortgage/src/main/resources/doc/mortgage_composite.jpg create mode 100644 sandbox/rfeng/samples/mortgage/src/main/resources/doc/mortgage_composite.png create mode 100644 sandbox/rfeng/samples/mortgage/src/main/resources/doc/mortgage_diagrams.doc create mode 100644 sandbox/rfeng/samples/mortgage/src/main/resources/doc/mortgage_package1.jpg create mode 100644 sandbox/rfeng/samples/mortgage/src/main/resources/doc/mortgage_package1.png create mode 100644 sandbox/rfeng/samples/mortgage/src/main/resources/doc/mortgage_package2.jpg create mode 100644 sandbox/rfeng/samples/mortgage/src/main/resources/doc/mortgage_package2.png create mode 100644 sandbox/rfeng/samples/mortgage/src/main/resources/doc/mortgage_scenario.jpg create mode 100644 sandbox/rfeng/samples/mortgage/src/main/resources/doc/mortgage_scenario.png create mode 100644 sandbox/rfeng/samples/mortgage/src/main/resources/doc/readme.html create mode 100644 sandbox/rfeng/samples/mortgage/src/main/resources/wsdl/credit.wsdl create mode 100644 sandbox/rfeng/samples/mortgage/src/test/java/mortgage/MortgageClientTestCase.java create mode 100644 sandbox/rfeng/samples/pom.xml (limited to 'sandbox/rfeng') diff --git a/sandbox/rfeng/aop-logging/.checkstyle b/sandbox/rfeng/aop-logging/.checkstyle new file mode 100644 index 0000000000..e3c216986d --- /dev/null +++ b/sandbox/rfeng/aop-logging/.checkstyle @@ -0,0 +1,24 @@ + + + + + + + diff --git a/sandbox/rfeng/aop-logging/.pmd b/sandbox/rfeng/aop-logging/.pmd new file mode 100644 index 0000000000..84af2f4d5d --- /dev/null +++ b/sandbox/rfeng/aop-logging/.pmd @@ -0,0 +1,20 @@ + + +true diff --git a/sandbox/rfeng/aop-logging/.ruleset b/sandbox/rfeng/aop-logging/.ruleset new file mode 100644 index 0000000000..ac8671859d --- /dev/null +++ b/sandbox/rfeng/aop-logging/.ruleset @@ -0,0 +1,190 @@ + + + + PMD Plugin preferences rule set + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/rfeng/aop-logging/LICENSE.txt b/sandbox/rfeng/aop-logging/LICENSE.txt new file mode 100644 index 0000000000..0084319535 --- /dev/null +++ b/sandbox/rfeng/aop-logging/LICENSE.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, serviceDefinition marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/sandbox/rfeng/aop-logging/NOTICE.txt b/sandbox/rfeng/aop-logging/NOTICE.txt new file mode 100644 index 0000000000..d83ebbe236 --- /dev/null +++ b/sandbox/rfeng/aop-logging/NOTICE.txt @@ -0,0 +1,14 @@ +${pom.name} +Copyright (c) 2005 - 2006 The Apache Software Foundation + +Apache Tuscany is an effort undergoing incubation at The Apache Software +Foundation (ASF), sponsored by the Apache Web Services PMC. Incubation is +required of all newly accepted projects until a further review indicates that +the infrastructure, communications, and decision making process have stabilized +in a manner consistent with other successful ASF projects. While incubation +status is not necessarily a reflection of the completeness or stability of the +code, it does indicate that the project has yet to be fully endorsed by the ASF. + +This product includes software developed by +The Apache Software Foundation (http://www.apache.org/). + diff --git a/sandbox/rfeng/aop-logging/pom.xml b/sandbox/rfeng/aop-logging/pom.xml new file mode 100644 index 0000000000..a08af87a44 --- /dev/null +++ b/sandbox/rfeng/aop-logging/pom.xml @@ -0,0 +1,93 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-modules + 1.0-incubating-SNAPSHOT + ../pom.xml + + tuscany-aop-logging + Apache Tuscany AOP-based Logging and Tracing + + + + aspectj + aspectjrt + 1.5.3 + + + aspectj + aspectjweaver + 1.5.3 + test + + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + LATEST + + + **/*TestCase.java + + brief + false + once + + + + + + org.codehaus.mojo + aspectj-maven-plugin + 1.0-beta-2 + + 1.5 + + + + + + + + compile + + test-compile + + + + + + + + diff --git a/sandbox/rfeng/aop-logging/src/main/java/org/apache/tuscany/sca/aspectj/LoggingAspect.java b/sandbox/rfeng/aop-logging/src/main/java/org/apache/tuscany/sca/aspectj/LoggingAspect.java new file mode 100644 index 0000000000..8ad64d498b --- /dev/null +++ b/sandbox/rfeng/aop-logging/src/main/java/org/apache/tuscany/sca/aspectj/LoggingAspect.java @@ -0,0 +1,93 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.aspectj; + +import java.util.Arrays; + +import org.aspectj.lang.JoinPoint; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.After; +import org.aspectj.lang.annotation.AfterReturning; +import org.aspectj.lang.annotation.AfterThrowing; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Before; +import org.aspectj.lang.annotation.Pointcut; + +/** + * @version $Rev$ $Date$ + */ +@Aspect +public class LoggingAspect { + @Pointcut("call(* org.apache.tuscany.sca..*(..)) && (!within(org.apache.tuscany.sca.aspectj.*Aspect))") + public void anyMethodCall() { + } + + @Pointcut("execution(* org.apache.tuscany.sca..*(..)) && (!within(org.apache.tuscany.sca.aspectj.*Aspect))") + public void anyMethodExecution() { + } + + @Pointcut("call(* java.util.logging.Logger.info(..))") + public void anyLogCall() { + } + + @Pointcut("cflow(anyMethodExecution()) && anyLogCall()") + public void anyLog() { + + } + + // @Around("anyMethodCall() || anyLog()") + @Around("anyLog()") + public Object around(ProceedingJoinPoint jp) throws Throwable { + System.out.println("Around: " + jp); + long start = System.currentTimeMillis(); + try { + return jp.proceed(); + } finally { + long end = System.currentTimeMillis(); + System.out.println("Roundtrip is " + (end - start) + "ms for " + jp.getSignature()); + } + + } + + @Before("anyMethodCall()") + public void before(JoinPoint jp) { + System.out.println("Before: " + jp); + System.out.println("Location: " + jp.getSourceLocation()); + System.out.println("This: " + jp.getThis()); + System.out.println("Target: " + jp.getTarget()); + System.out.println("Input: " + Arrays.asList(jp.getArgs())); + } + + @After("anyMethodCall()") + public void after(JoinPoint jp) { + System.out.println("After: " + jp); + } + + @AfterReturning(pointcut = "anyMethodCall()", returning = "result") + public void afterReturning(JoinPoint jp, Object result) { + System.out.println("After returning: " + jp + " " + result); + } + + @AfterThrowing(pointcut = "anyMethodCall()", throwing = "e") + public void afterThrowing(Exception e) { + } + +} diff --git a/sandbox/rfeng/aop-logging/src/main/java/org/apache/tuscany/sca/aspectj/TracingAspect.java b/sandbox/rfeng/aop-logging/src/main/java/org/apache/tuscany/sca/aspectj/TracingAspect.java new file mode 100644 index 0000000000..91489bae7d --- /dev/null +++ b/sandbox/rfeng/aop-logging/src/main/java/org/apache/tuscany/sca/aspectj/TracingAspect.java @@ -0,0 +1,82 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.aspectj; + +import org.aspectj.lang.JoinPoint; +import org.aspectj.lang.annotation.After; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Before; +import org.aspectj.lang.annotation.Pointcut; + +/** + * @version $Rev$ $Date$ + */ + +@Aspect +public abstract class TracingAspect { + + @Pointcut("") + protected abstract void entry(); + + @Pointcut("call(* java..*.*(..))") + protected void exit() { + } + + @Pointcut("entry() && !cflowbelow(entry())") + void start() { + } + + @Pointcut("cflow(entry()) && !exit() && !cflowbelow(exit()) && !within(org.apache.tuscany.sca.aspectj.*Aspect)") + void trace() { + } + + @Pointcut("!handler(*) && !preinitialization(new(..))") + protected void supportsAfterAdvice() { + } + + @Before("start()") + public void beforeStart() { + startLog(); + } + + @Before("trace() && supportsAfterAdvice()") + public void beforeTrace(JoinPoint.StaticPart jp) { + logEnter(jp); + } + + @After("trace() && supportsAfterAdvice()") + public void afterTrace(JoinPoint.StaticPart jp) { + logExit(jp); + } + + @After("start()") + public void afterStart() { + completeLog(); + } + + protected abstract void logEnter(JoinPoint.StaticPart jp); + + protected abstract void logExit(JoinPoint.StaticPart jp); + + protected abstract void startLog(); + + protected abstract void completeLog(); + +} diff --git a/sandbox/rfeng/aop-logging/src/test/java/org/apache/tuscany/sca/aspectj/MyTracingAspect.java b/sandbox/rfeng/aop-logging/src/test/java/org/apache/tuscany/sca/aspectj/MyTracingAspect.java new file mode 100644 index 0000000000..a6e9f90518 --- /dev/null +++ b/sandbox/rfeng/aop-logging/src/test/java/org/apache/tuscany/sca/aspectj/MyTracingAspect.java @@ -0,0 +1,60 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.aspectj; + +import org.aspectj.lang.JoinPoint.StaticPart; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Pointcut; + +/** + * @version $Rev$ $Date$ + */ +@Aspect +public class MyTracingAspect extends TracingAspect { + + public MyTracingAspect() { + super(); + } + + @Override + protected void completeLog() { + System.out.println("completeLog()"); + } + + @Pointcut("execution(* org.apache.tuscany.sca.aspectj.TracingTestCase.testAOP(..))") + protected void entry() { + } + + @Override + protected void logEnter(StaticPart jp) { + System.out.println("> " + jp.getSignature()); + } + + @Override + protected void logExit(StaticPart jp) { + System.out.println("< " + jp.getSignature()); + } + + @Override + protected void startLog() { + System.out.println("startLog()"); + } + +} diff --git a/sandbox/rfeng/aop-logging/src/test/java/org/apache/tuscany/sca/aspectj/TracingTestCase.java b/sandbox/rfeng/aop-logging/src/test/java/org/apache/tuscany/sca/aspectj/TracingTestCase.java new file mode 100644 index 0000000000..8dec0e60ba --- /dev/null +++ b/sandbox/rfeng/aop-logging/src/test/java/org/apache/tuscany/sca/aspectj/TracingTestCase.java @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.aspectj; + +import java.util.logging.Logger; + +import junit.framework.TestCase; + +/** + * @version $Rev$ $Date$ + */ +public class TracingTestCase extends TestCase { + + public void testAOP() { + Logger log = Logger.getLogger(getClass().getName()); + System.out.println("doSomething()"); + log.info("Hello, Log"); + } + + public static void main(String[] args) { + new TracingTestCase().testAOP(); + } +} diff --git a/sandbox/rfeng/aop-logging/src/test/resources/META-INF/aop.xml b/sandbox/rfeng/aop-logging/src/test/resources/META-INF/aop.xml new file mode 100644 index 0000000000..c9aeee3a63 --- /dev/null +++ b/sandbox/rfeng/aop-logging/src/test/resources/META-INF/aop.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/sandbox/rfeng/aop-logging/test.bat b/sandbox/rfeng/aop-logging/test.bat new file mode 100644 index 0000000000..07677ba691 --- /dev/null +++ b/sandbox/rfeng/aop-logging/test.bat @@ -0,0 +1,3 @@ +@echo off +set ASPECTJ_HOME=c:\aspectj1.5 +call %ASPECTJ_HOME%\bin\aj5.bat -cp target\classes;target\test-classes org.apache.tuscany.sca.aspectj.TracingTestCase \ No newline at end of file diff --git a/sandbox/rfeng/geronimo-demo/LICENSE.TXT b/sandbox/rfeng/geronimo-demo/LICENSE.TXT new file mode 100644 index 0000000000..da916aa639 --- /dev/null +++ b/sandbox/rfeng/geronimo-demo/LICENSE.TXT @@ -0,0 +1,2835 @@ + + 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. + +######################################################################### +## ADDITIONAL SOURCE LICENSES ## +######################################################################### + +The ASN1 codec implementation in the geronimo-util module was +developed by the Bouncy Castle project. (http://www.bouncycastle.org/). +Use of the source code, thus licensed, and the resultant binary are +subject to the terms and conditions of the following license. + +========================================================================= +== Bouncy Castle License (ASN1 codec in geronimo-util) == +========================================================================= + +The Bouncy Castle License + +Copyright (c) 2000-2005 The Legion Of The Bouncy Castle +(http://www.bouncycastle.org) + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + +######################################################################### +## APACHE GERONIMO DEPENDENCIES ## +######################################################################### + +A binary distribution of Apache Geronimo, or an Apache Geronimo server +which is built from source, includes a number of dependent packages +with separate copyright notices and license terms. Your use of these +dependent packages is subject to the terms and conditions of the +following licenses. + +========================================================================= +== ANTLR License == +========================================================================= + +ANTLR 2 License + +We reserve no legal rights to the ANTLR--it is fully in the public +domain. An individual or company may do whatever they wish with source +code distributed with ANTLR or the code generated by ANTLR, including +the incorporation of ANTLR, or its output, into commerical software. + +We encourage users to develop software with ANTLR. However, we do ask +that credit is given to us for developing ANTLR. By "credit", we mean +that if you use ANTLR or incorporate any source code into one of your +programs (commercial product, research project, or otherwise) that you +acknowledge this fact somewhere in the documentation, research report, +etc... If you like ANTLR and have developed a nice tool with the +output, please mention that you developed it using ANTLR. In addition, +we ask that the headers remain intact in our source code. As long as +these guidelines are kept, we expect to continue enhancing this system +and expect to make other tools available as they are completed. + + +========================================================================= +== Apache Commons BeanUtils License == +========================================================================= + +The Apache Software License, Version 1.1 + +Copyright (c) 1999-2003 The Apache Software Foundation. All rights +reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + +3. The end-user documentation included with the redistribution, if + any, must include the following acknowlegement: + "This product includes software developed by the + Apache Software Foundation (http://www.apache.org/)." + Alternately, this acknowlegement may appear in the software itself, + if and wherever such third-party acknowlegements normally appear. + +4. The names "The Jakarta Project", "Commons", and "Apache Software + Foundation" must not be used to endorse or promote products derived + from this software without prior written permission. For written + permission, please contact apache@apache.org. + +5. Products derived from this software may not be called "Apache" + nor may "Apache" appear in their names without prior written + permission of the Apache Group. + +THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR +ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +SUCH DAMAGE. +==================================================================== + +This software consists of voluntary contributions made by many +individuals on behalf of the Apache Software Foundation. For more +information on the Apache Software Foundation, please see +. + + +========================================================================= +== Apache Commons CLI License == +========================================================================= + +The Apache Software License, Version 1.1 + +Copyright (c) 1999-2001 The Apache Software Foundation. All rights +reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + +3. The end-user documentation included with the redistribution, if + any, must include the following acknowlegement: + "This product includes software developed by the + Apache Software Foundation (http://www.apache.org/)." + Alternately, this acknowlegement may appear in the software itself, + if and wherever such third-party acknowlegements normally appear. + +4. The names "The Jakarta Project", "Commons", and "Apache Software + Foundation" must not be used to endorse or promote products derived + from this software without prior written permission. For written + permission, please contact apache@apache.org. + +5. Products derived from this software may not be called "Apache" + nor may "Apache" appear in their names without prior written + permission of the Apache Group. + +THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR +ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +SUCH DAMAGE. +==================================================================== + +This software consists of voluntary contributions made by many +individuals on behalf of the Apache Software Foundation. For more +information on the Apache Software Foundation, please see +. + + +========================================================================= +== Apache Commons Discovery License == +========================================================================= + +The Apache Software License, Version 1.1 + +Copyright (c) 1999-2001 The Apache Software Foundation. All rights +reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + +3. The end-user documentation included with the redistribution, if + any, must include the following acknowlegement: + "This product includes software developed by the + Apache Software Foundation (http://www.apache.org/)." + Alternately, this acknowlegement may appear in the software itself, + if and wherever such third-party acknowlegements normally appear. + +4. The names "The Jakarta Project", "Commons", and "Apache Software + Foundation" must not be used to endorse or promote products derived + from this software without prior written permission. For written + permission, please contact apache@apache.org. + +5. Products derived from this software may not be called "Apache" + nor may "Apache" appear in their names without prior written + permission of the Apache Group. + +THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR +ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +SUCH DAMAGE. +==================================================================== + +This software consists of voluntary contributions made by many +individuals on behalf of the Apache Software Foundation. For more +information on the Apache Software Foundation, please see +. + + +========================================================================= +== Apache Commons Lang == +========================================================================= + +The Apache Software License, Version 1.1 + +Copyright (c) 2002-2003 The Apache Software Foundation. All rights +reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + +3. The end-user documentation included with the redistribution, if + any, must include the following acknowledgement: + "This product includes software developed by the + Apache Software Foundation (http://www.apache.org/)." + Alternately, this acknowledgement may appear in the software itself, + if and wherever such third-party acknowledgements normally appear. + +4. The names "The Jakarta Project", "Commons", and "Apache Software + Foundation" must not be used to endorse or promote products derived + from this software without prior written permission. For written + permission, please contact apache@apache.org. + +5. Products derived from this software may not be called "Apache" + nor may "Apache" appear in their names without prior written + permission of the Apache Software Foundation. + +THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR +ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +SUCH DAMAGE. +==================================================================== + +This software consists of voluntary contributions made by many +individuals on behalf of the Apache Software Foundation. For more +information on the Apache Software Foundation, please see +. + + +========================================================================= +== Apache Commons Resolver (included in xercesImpl) == +========================================================================= + +The Apache Software License, Version 1.1 + +Copyright (c) 2001-2003 The Apache Software Foundation. All rights +reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + +3. The end-user documentation included with the redistribution, if + any, must include the following acknowlegement: + "This product includes software developed by the + Apache Software Foundation (http://www.apache.org/)." + Alternately, this acknowlegement may appear in the software itself, + if and wherever such third-party acknowlegements normally appear. + +4. The names "The Jakarta Project", "Commons", and "Apache Software + Foundation" must not be used to endorse or promote products derived + from this software without prior written permission. For written + permission, please contact apache@apache.org. + +5. Products derived from this software may not be called "Apache" + nor may "Apache" appear in their names without prior written + permission of the Apache Group. + +THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR +ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +SUCH DAMAGE. +==================================================================== + +This software consists of voluntary contributions made by many +individuals on behalf of the Apache Software Foundation. For more +information on the Apache Software Foundation, please see +. + + +========================================================================= +== Apache CXF License == +========================================================================= + + +Apache CXF source code is licensed under the Apache License +Version 2.0. However, CXF is also covered by the following licenses: + +The BSD License + + Copyright (c) , All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. Neither the name of the + * nor the names of its contributors may be used to endorse or + * promote products derived from this software without specific + * prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED + TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF + THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + SUCH DAMAGE. + +-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + +OASIS takes no position regarding the validity or scope of any +intellectual property or other rights that might be claimed to pertain +to the implementation or use of the technology described in this +document or the extent to which any license under such rights might or +might not be available; neither does it represent that it has made any +effort to identify any such rights. Information on OASIS's procedures +with respect to rights in OASIS specifications can be found at the +OASIS website. Copies of claims of rights made available for +publication and any assurances of licenses to be made available, or +the result of an attempt made to obtain a general license or +permission for the use of such proprietary rights by implementors or +users of this specification, can be obtained from the OASIS Executive +Director. OASIS invites any interested party to bring to its +attention any copyrights, patents or patent applications, or other +proprietary rights which may cover technology that may be required to +implement this specification. Please address the information to the +OASIS Executive Director. + +Copyright (c) OASIS Open 2002-2004. All Rights Reserved. + +This document and translations of it may be copied +and furnished to others, and derivative works that comment on or +otherwise explain it or assist in its implementation may be prepared, +copied, published and distributed, in whole or in part, without +restriction of any kind, provided that the above copyright notice and +this paragraph are included on all such copies and derivative +works. However, this document itself does not be modified in any way, +such as by removing the copyright notice or references to OASIS, +except as needed for the purpose of developing OASIS specifications, +in which case the procedures for copyrights defined in the OASIS +Intellectual Property Rights document must be followed, or as required +to translate it into languages other than English. + +The limited permissions granted above are perpetual and will not be +revoked by OASIS or its successors or assigns. + +This document and the information contained herein is provided on an +"AS IS" basis and OASIS DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE +INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED +WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + +-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + +(c) 2001-2006 BEA Systems Inc., International Business Machines +Corporation, Microsoft Corporation, Inc., SAP AG, Sonic Software, and +VeriSign, Inc. All rights reserved. + +Permission to copy and display the WS-Policy Specification (the +"Specification", which includes WSDL and schema documents), in any +medium without fee or royalty is hereby granted, provided that you +include the following on ALL copies of the WS-Policy Specification, +that you make: + +1. A link or URL to the WS-Policy Specification at one of the Authors' +websites 2. The copyright notice as shown in the WS-Policy +Specification. + +BEA Systems, IBM, Microsoft, SAP, Sonic Software, and VeriSign +(collectively, the "Authors") each agree to grant you a license, under +royalty-free and otherwise reasonable, non-discriminatory terms and +conditions, to their respective essential patent claims that they deem +necessary to implement the WS-Policy Specification. + +THE WS-POLICY SPECIFICATION IS PROVIDED "AS IS," AND THE AUTHORS MAKE +NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING, BUT +NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE, NON-INFRINGEMENT, OR TITLE; THAT THE CONTENTS OF +THE WS-POLICY SPECIFICATION ARE SUITABLE FOR ANY PURPOSE; NOR THAT THE +IMPLEMENTATION OF SUCH CONTENTS WILL NOT INFRINGE ANY THIRD PARTY +PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS. + +THE AUTHORS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, +INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATING TO ANY +USE OR DISTRIBUTION OF THE WS-POLICY SPECIFICATION. + +The name and trademarks of the Authors may NOT be used in any manner, +including advertising or publicity pertaining to the WS-Policy +Specification or its contents without specific, written prior +permission. Title to copyright in the WS-Policy Specification will at +all times remain with the Authors. + +No other rights are granted by implication, estoppel or otherwise. + +-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + +Copyright (c) 2002-2004 BEA Systems Inc., International Business +Machines Corporation, Microsoft Corporation, Inc, SAP AG, and Sun +Microsystems, Inc.. All rights reserved. + +Permission to copy, display, perform, modify and distribute the +WS-Addressing Specification, and to authorize others to do the +foregoing, in any medium without fee or royalty is hereby granted for +the purpose of developing and evaluating the WS-Addressing +Specification. + +BEA, IBM, Microsoft, SAP AG, and Sun Microsystems (collectively, the +"Authors") each agree to grant a license to third parties, under +royalty-free and otherwise reasonable, non-discriminatory terms and +conditions, to their respective essential patent claims that they deem +necessary to implement the WS-Addressing Specification. + +DISCLAIMERS: + +THE WS-Addressing Specification IS PROVIDED "AS IS", AND THE AUTHORS +MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING, +BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE, NON-INFRINGEMENT, OR TITLE; THAT THE CONTENTS OF +THE WS-Addressing Specification IS SUITABLE FOR ANY PURPOSE; NOR THAT +THE IMPLEMENTATION OF SUCH CONTENTS WILL NOT INFRINGE ANY THIRD PARTY +PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS. + +THE AUTHORS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, +INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE +WS-Addressing Specification OR THE PERFORMANCE OR IMPLEMENTATION OF +THE CONTENTS THEREOF. + +You may remove these disclaimers from your modified versions of the +WS-Addressing Specification provided that you effectively disclaim all +warranties and liabilities on behalf of all copyright holders in the +copies of any such modified versions you distribute. + +The name and trademarks of the Authors may NOT be used in any manner, +including advertising or publicity pertaining to the WS-Addressing +Specification or its contents without specific, written prior +permission. Title to copyright in the WS-Addressing Specification will +at all times remain with the Authors. + +No other rights are granted by implication, estoppel or otherwise. + +-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + +Copyright 2001 - 2005, International Business Machines Corporation and +Microsoft Corporation All Rights Reserved + +License for WSDL Schema Files + +The Authors grant permission to copy and distribute the WSDL Schema +Files in any medium without fee or royalty as long as this notice and +license are distributed with them. The originals of these files can +be located at: + +http://schemas.xmlsoap.org/wsdl/2003-02-11.xsd + +THESE SCHEMA FILES ARE PROVIDED "AS IS," AND THE AUTHORS MAKE NO +REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THESE +FILES, INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT OR TITLE. THE +AUTHORS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, +INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATING TO ANY +USE OR DISTRIBUTION OF THESE FILES. + +The name and trademarks of the Authors may NOT be used in any manner, +including advertising or publicity pertaining to these files or any +program or service that uses these files, written prior permission. +Title to copyright in these files will at all times remain with the +Authors. + +No other rights are granted by implication, estoppel or otherwise. + + +========================================================================= +== Apache Jakarta Regexp License == +========================================================================= + +The Apache Software License, Version 1.1 + +Copyright (c) 1999-2002 The Apache Software Foundation. All rights +reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + +3. The end-user documentation included with the redistribution, if + any, must include the following acknowlegement: + "This product includes software developed by the + Apache Software Foundation (http://www.apache.org/)." + Alternately, this acknowlegement may appear in the software itself, + if and wherever such third-party acknowlegements normally appear. + +4. The names "The Jakarta Project", "Jakarta-Regexp", and "Apache Software + Foundation" must not be used to endorse or promote products derived + from this software without prior written permission. For written + permission, please contact apache@apache.org. + +5. Products derived from this software may not be called "Apache" + nor may "Apache" appear in their names without prior written + permission of the Apache Group. + +THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR +ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +SUCH DAMAGE. +==================================================================== + +This software consists of voluntary contributions made by many +individuals on behalf of the Apache Software Foundation. For more +information on the Apache Software Foundation, please see +. + + +========================================================================= +== Apache MyFaces License == +========================================================================= + +Apache CXF source code is licensed under the Apache License +Version 2.0. However, CXF is also covered by the following licenses: + +License +Copyright 1994-2005 Sun Microsystems, Inc. All Rights Reserved. +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + + + * Redistribution of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + + * Redistribution in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + + +Neither the name of Sun Microsystems, Inc. or the names of contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +This software is provided "AS IS," without a warranty of any kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +You acknowledge that this software is not designed, licensed or intended for use in the design, construction, operation or maintenance of any nuclear facility. + +========================================================================= +== Apache OpenJPA License == +========================================================================= + +Apache OpenJPA source code is licensed under the Apache License +Version 2.0. However, the openjpa-all jar file contains two files +orm-xsd.rsrc and persistence-xsd.rsrc which are licensed under +CDDL Version 1.0. + +COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 + +1. Definitions. + +1.1. Contributor means each individual or entity that creates or + contributes to the creation of Modifications. + +1.2. Contributor Version means the combination of the Original + Software, prior Modifications used by a Contributor (if any), and + the Modifications made by that particular Contributor. + +1.3. Covered Software means (a) the Original Software, or (b) + Modifications, or (c) the combination of files containing + Original Software with files containing Modifications, in each + case including portions thereof. + +1.4. Executable means the Covered Software in any form other than + Source Code. + +1.5. Initial Developer means the individual or entity that first makes + Original Software available under this License. + +1.6. Larger Work means a work which combines Covered Software or + portions thereof with code not governed by the terms of this + License. + +1.7. License means this document. + +1.8. Licensable means having the right to grant, to the maximum extent + possible, whether at the time of the initial grant or + subsequently acquired, any and all of the rights conveyed herein. + +1.9. Modifications means the Source Code and Executable form of any of + the following: + +A. Any file that results from an addition to, deletion from or +modification of the contents of a file containing Original Software or +previous Modifications; + +B. Any new file that contains any part of the Original Software or +previous Modification; or + +C. Any new file that is contributed or otherwise made available under +the terms of this License. + +1.10. Original Software means the Source Code and Executable form of + computer software code that is originally released under this + License. + +1.11. Patent Claims means any patent claim(s), now owned or hereafter + acquired, including without limitation, method, process, and + apparatus claims, in any patent Licensable by grantor. + +1.12. Source Code means (a) the common form of computer software code + in which modifications are made and (b) associated documentation + included in or with such code. + +1.13. You (or Your) means an individual or a legal entity exercising + rights under, and complying with all of the terms of, this + License. For legal entities, You includes any entity which + controls, is controlled by, or is under common control with + You. For purposes of this definition, control means (a)áthe + power, direct or indirect, to cause the direction or management + of such entity, whether by contract or otherwise, or + (b)áownership of more than fifty percent (50%) of the + outstanding shares or beneficial ownership of such entity. + +2. License Grants. + +2.1. The Initial Developer Grant. Conditioned upon Your compliance +with Section 3.1 below and subject to third party intellectual +property claims, the Initial Developer hereby grants You a world-wide, +royalty-free, non-exclusive license: (a) under intellectual property +rights (other than patent or trademark) Licensable by Initial +Developer, to use, reproduce, modify, display, perform, sublicense and +distribute the Original Software (or portions thereof), with or +without Modifications, and/or as part of a Larger Work; and (b) under +Patent Claims infringed by the making, using or selling of Original +Software, to make, have made, use, practice, sell, and offer for sale, +and/or otherwise dispose of the Original Software (or portions +thereof). (c) The licenses granted in Sectionsá2.1(a) and (b) are +effective on the date Initial Developer first distributes or otherwise +makes the Original Software available to a third party under the terms +of this License. (d) Notwithstanding Sectioná2.1(b) above, no patent +license is granted: (1)áfor code that You delete from the Original +Software, or (2)áfor infringements caused by: (i)áthe modification of +the Original Software, or (ii)áthe combination of the Original +Software with other software or devices. + +2.2. Contributor Grant. Conditioned upon Your compliance with Section +3.1 below and subject to third party intellectual property claims, +each Contributor hereby grants You a world-wide, royalty-free, +non-exclusive license: (a) under intellectual property rights (other +than patent or trademark) Licensable by Contributor to use, reproduce, +modify, display, perform, sublicense and distribute the Modifications +created by such Contributor (or portions thereof), either on an +unmodified basis, with other Modifications, as Covered Software and/or +as part of a Larger Work; and (b) under Patent Claims infringed by the +making, using, or selling of Modifications made by that Contributor +either alone and/or in combination with its Contributor Version (or +portions of such combination), to make, use, sell, offer for sale, +have made, and/or otherwise dispose of: (1)áModifications made by that +Contributor (or portions thereof); and (2)áthe combination of +Modifications made by that Contributor with its Contributor Version +(or portions of such combination). (c) The licenses granted in +Sectionsá2.2(a) and 2.2(b) are effective on the date Contributor first +distributes or otherwise makes the Modifications available to a third +party. (d) Notwithstanding Sectioná2.2(b) above, no patent license is +granted: (1)áfor any code that Contributor has deleted from the +Contributor Version; (2)áfor infringements caused by: (i)áthird party +modifications of Contributor Version, or (ii)áthe combination of +Modifications made by that Contributor with other software (except as +part of the Contributor Version) or other devices; or (3)áunder Patent +Claims infringed by Covered Software in the absence of Modifications +made by that Contributor. + +3. Distribution Obligations. + +3.1. Availability of Source Code. + +Any Covered Software that You distribute or otherwise make available +in Executable form must also be made available in Source Code form and +that Source Code form must be distributed only under the terms of this +License. You must include a copy of this License with every copy of +the Source Code form of the Covered Software You distribute or +otherwise make available. You must inform recipients of any such +Covered Software in Executable form as to how they can obtain such +Covered Software in Source Code form in a reasonable manner on or +through a medium customarily used for software exchange. + +3.2. Modifications. + +The Modifications that You create or to which You contribute are +governed by the terms of this License. You represent that You believe +Your Modifications are Your original creation(s) and/or You have +sufficient rights to grant the rights conveyed by this License. + +3.3. Required Notices. You must include a notice in each of Your +Modifications that identifies You as the Contributor of the +Modification. You may not remove or alter any copyright, patent or +trademark notices contained within the Covered Software, or any +notices of licensing or any descriptive text giving attribution to any +Contributor or the Initial Developer. + +3.4. Application of Additional Terms. You may not offer or impose any +terms on any Covered Software in Source Code form that alters or +restricts the applicable version of this License or the recipients +rights hereunder. You may choose to offer, and to charge a fee for, +warranty, support, indemnity or liability obligations to one or more +recipients of Covered Software. However, you may do so only on Your +own behalf, and not on behalf of the Initial Developer or any +Contributor. You must make it absolutely clear that any such warranty, +support, indemnity or liability obligation is offered by You alone, +and You hereby agree to indemnify the Initial Developer and every +Contributor for any liability incurred by the Initial Developer or +such Contributor as a result of warranty, support, indemnity or +liability terms You offer. + +3.5. Distribution of Executable Versions. You may distribute the +Executable form of the Covered Software under the terms of this +License or under the terms of a license of Your choice, which may +contain terms different from this License, provided that You are in +compliance with the terms of this License and that the license for the +Executable form does not attempt to limit or alter the recipients +rights in the Source Code form from the rights set forth in this +License. If You distribute the Covered Software in Executable form +under a different license, You must make it absolutely clear that any +terms which differ from this License are offered by You alone, not by +the Initial Developer or Contributor. You hereby agree to indemnify +the Initial Developer and every Contributor for any liability incurred +by the Initial Developer or such Contributor as a result of any such +terms You offer. + +3.6. Larger Works. You may create a Larger Work by combining Covered +Software with other code not governed by the terms of this License and +distribute the Larger Work as a single product. In such a case, You +must make sure the requirements of this License are fulfilled for the +Covered Software. + +4. Versions of the License. + +4.1. New Versions. Sun Microsystems, Inc. is the initial license +steward and may publish revised and/or new versions of this License +from time to time. Each version will be given a distinguishing version +number. Except as provided in Section 4.3, no one other than the +license steward has the right to modify this License. + +4.2. Effect of New Versions. + +You may always continue to use, distribute or otherwise make the +Covered Software available under the terms of the version of the +License under which You originally received the Covered Software. If +the Initial Developer includes a notice in the Original Software +prohibiting it from being distributed or otherwise made available +under any subsequent version of the License, You must distribute and +make the Covered Software available under the terms of the version of +the License under which You originally received the Covered +Software. Otherwise, You may also choose to use, distribute or +otherwise make the Covered Software available under the terms of any +subsequent version of the License published by the license steward. +4.3. Modified Versions. + +When You are an Initial Developer and You want to create a new license +for Your Original Software, You may create and use a modified version +of this License if You: (a)árename the license and remove any +references to the name of the license steward (except to note that the +license differs from this License); and (b)áotherwise make it clear +that the license contains terms which differ from this License. + +5. DISCLAIMER OF WARRANTY. + +COVERED SOFTWARE IS PROVIDED UNDER THIS LICENSE ON AN AS IS BASIS, +WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +WITHOUT LIMITATION, WARRANTIES THAT THE COVERED SOFTWARE IS FREE OF +DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR +NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF +THE COVERED SOFTWARE IS WITH YOU. SHOULD ANY COVERED SOFTWARE PROVE +DEFECTIVE IN ANY RESPECT, YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER +CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY SERVICING, REPAIR OR +CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART +OF THIS LICENSE. NO USE OF ANY COVERED SOFTWARE IS AUTHORIZED +HEREUNDER EXCEPT UNDER THIS DISCLAIMER. + +6. TERMINATION. + +6.1. This License and the rights granted hereunder will terminate + automatically if You fail to comply with terms herein and fail to + cure such breach within 30 days of becoming aware of the + breach. Provisions which, by their nature, must remain in effect + beyond the termination of this License shall survive. + +6.2. If You assert a patent infringement claim (excluding declaratory + judgment actions) against Initial Developer or a Contributor (the + Initial Developer or Contributor against whom You assert such + claim is referred to as Participant) alleging that the + Participant Software (meaning the Contributor Version where the + Participant is a Contributor or the Original Software where the + Participant is the Initial Developer) directly or indirectly + infringes any patent, then any and all rights granted directly or + indirectly to You by such Participant, the Initial Developer (if + the Initial Developer is not the Participant) and all + Contributors under Sectionsá2.1 and/or 2.2 of this License shall, + upon 60 days notice from Participant terminate prospectively and + automatically at the expiration of such 60 day notice period, + unless if within such 60 day period You withdraw Your claim with + respect to the Participant Software against such Participant + either unilaterally or pursuant to a written agreement with + Participant. + +6.3. In the event of termination under Sectionsá6.1 or 6.2 above, all + end user licenses that have been validly granted by You or any + distributor hereunder prior to termination (excluding licenses + granted to You by any distributor) shall survive termination. + +7. LIMITATION OF LIABILITY. + +UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT +(INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL +DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED +SOFTWARE, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY +PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES +OF ANY CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOST +PROFITS, LOSS OF GOODWILL, WORK STOPPAGE, COMPUTER FAILURE OR +MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL DAMAGES OR LOSSES, EVEN +IF SUCH PARTY SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF SUCH +DAMAGES. THIS LIMITATION OF LIABILITY SHALL NOT APPLY TO LIABILITY FOR +DEATH OR PERSONAL INJURY RESULTING FROM SUCH PARTYS NEGLIGENCE TO THE +EXTENT APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO +NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL +DAMAGES, SO THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU. + +8. U.S. GOVERNMENT END USERS. + +The Covered Software is a commercial item, as that term is defined in +48áC.F.R.á2.101 (Oct. 1995), consisting of commercial computer +software (as that term is defined at 48 C.F.R. á252.227-7014(a)(1)) +and commercial computer software documentation as such terms are used +in 48áC.F.R.á12.212 (Sept. 1995). Consistent with 48 C.F.R. 12.212 and +48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995), all +U.S. Government End Users acquire Covered Software with only those +rights set forth herein. This U.S. Government Rights clause is in lieu +of, and supersedes, any other FAR, DFAR, or other clause or provision +that addresses Government rights in computer software under this +License. + +9. MISCELLANEOUS. + +This License represents the complete agreement concerning subject +matter hereof. If any provision of this License is held to be +unenforceable, such provision shall be reformed only to the extent +necessary to make it enforceable. This License shall be governed by +the law of the jurisdiction specified in a notice contained within the +Original Software (except to the extent applicable law, if any, +provides otherwise), excluding such jurisdictions conflict-of-law +provisions. Any litigation relating to this License shall be subject +to the jurisdiction of the courts located in the jurisdiction and +venue specified in a notice contained within the Original Software, +with the losing party responsible for costs, including, without +limitation, court costs and reasonable attorneys fees and +expenses. The application of the United Nations Convention on +Contracts for the International Sale of Goods is expressly +excluded. Any law or regulation which provides that the language of a +contract shall be construed against the drafter shall not apply to +this License. You agree that You alone are responsible for compliance +with the United States export administration regulations (and the +export control laws and regulation of any other countries) when You +use, distribute or otherwise make available any Covered Software. + +10. RESPONSIBILITY FOR CLAIMS. + +As between Initial Developer and the Contributors, each party is +responsible for claims and damages arising, directly or indirectly, +out of its utilization of rights under this License and You agree to +work with Initial Developer and Contributors to distribute such +responsibility on an equitable basis. Nothing herein is intended or +shall be deemed to constitute any admission of liability. + +NOTICE PURSUANT TO SECTION 9 OF THE COMMON DEVELOPMENT AND +DISTRIBUTION LICENSE (CDDL) The GlassFish code released under the CDDL +shall be governed by the laws of the State of California (excluding +conflict-of-law provisions). Any litigation relating to this License +shall be subject to the jurisdiction of the Federal Courts of the +Northern District of California and the state courts of the State of +California, with venue lying in Santa Clara County, California. + + +========================================================================= +== Apache Jakarta ORO License == +========================================================================= + +The Apache Software License, Version 1.1 + +Copyright (c) 2000-2002 The Apache Software Foundation. All rights +reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + +3. The end-user documentation included with the redistribution, + if any, must include the following acknowledgment: + "This product includes software developed by the + Apache Software Foundation (http://www.apache.org/)." + Alternately, this acknowledgment may appear in the software itself, + if and wherever such third-party acknowledgments normally appear. + +4. The names "Apache" and "Apache Software Foundation", "Jakarta-Oro" + must not be used to endorse or promote products derived from this + software without prior written permission. For written + permission, please contact apache@apache.org. + +5. Products derived from this software may not be called "Apache" + or "Jakarta-Oro", nor may "Apache" or "Jakarta-Oro" appear in their + name, without prior written permission of the Apache Software Foundation. + +THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR +ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +SUCH DAMAGE. +==================================================================== + +This software consists of voluntary contributions made by many +individuals on behalf of the Apache Software Foundation. For more +information on the Apache Software Foundation, please see +. + + +========================================================================= +== Apache Yoko License == +========================================================================= + + +Apache Yoko source code is licensed under the Apache License +Version 2.0. However, yoko also contains elements covered by the +following licenses: + +This product is a collective work licensed under the Eclipse Public +License (EPL -- see below). The components of this work include: + + a) software developed by Celtix committers and licensed under the EPL; + and, + b) third-party components licensed under terms that may be different from + those of the EPL. Information about such licenses can be found in the + file named 3party-licenses.txt. + +-------------------------------------------------------------------------- + +Eclipse Public License - v 1.0 + +THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE +PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF +THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. + +1. DEFINITIONS + +"Contribution" means: + +a) in the case of the initial Contributor, the initial code and +documentation distributed under this Agreement, and +b) in the case of each subsequent Contributor: + +i) changes to the Program, and + +ii) additions to the Program; + +where such changes and/or additions to the Program originate from and +are distributed by that particular Contributor. A Contribution +'originates' from a Contributor if it was added to the Program by such +Contributor itself or anyone acting on such Contributor's behalf. +Contributions do not include additions to the Program which: (i) are +separate modules of software distributed in conjunction with the +Program under their own license agreement, and (ii) are not derivative +works of the Program. + +"Contributor" means any person or entity that distributes the Program. + +"Licensed Patents " mean patent claims licensable by a Contributor +which are necessarily infringed by the use or sale of its Contribution +alone or when combined with the Program. + +"Program" means the Contributions distributed in accordance with this +Agreement. + +"Recipient" means anyone who receives the Program under this +Agreement, including all Contributors. + +2. GRANT OF RIGHTS + +a) Subject to the terms of this Agreement, each Contributor hereby +grants Recipient a non-exclusive, worldwide, royalty-free copyright +license to reproduce, prepare derivative works of, publicly display, +publicly perform, distribute and sublicense the Contribution of such +Contributor, if any, and such derivative works, in source code and +object code form. + +b) Subject to the terms of this Agreement, each Contributor hereby +grants Recipient a non-exclusive, worldwide, royalty-free patent +license under Licensed Patents to make, use, sell, offer to sell, +import and otherwise transfer the Contribution of such Contributor, if +any, in source code and object code form. This patent license shall +apply to the combination of the Contribution and the Program if, at +the time the Contribution is added by the Contributor, such addition +of the Contribution causes such combination to be covered by the +Licensed Patents. The patent license shall not apply to any other +combinations which include the Contribution. No hardware per se is +licensed hereunder. + +c) Recipient understands that although each Contributor grants the +licenses to its Contributions set forth herein, no assurances are +provided by any Contributor that the Program does not infringe the +patent or other intellectual property rights of any other entity. Each +Contributor disclaims any liability to Recipient for claims brought by +any other entity based on infringement of intellectual property rights +or otherwise. As a condition to exercising the rights and licenses +granted hereunder, each Recipient hereby assumes sole responsibility +to secure any other intellectual property rights needed, if any. For +example, if a third party patent license is required to allow +Recipient to distribute the Program, it is Recipient's responsibility +to acquire that license before distributing the Program. + +d) Each Contributor represents that to its knowledge it has sufficient +copyright rights in its Contribution, if any, to grant the copyright +license set forth in this Agreement. + +3. REQUIREMENTS + +A Contributor may choose to distribute the Program in object code form +under its own license agreement, provided that: + +a) it complies with the terms and conditions of this Agreement; and + +b) its license agreement: + +i) effectively disclaims on behalf of all Contributors all warranties +and conditions, express and implied, including warranties or +conditions of title and non-infringement, and implied warranties or +conditions of merchantability and fitness for a particular purpose; + +ii) effectively excludes on behalf of all Contributors all liability +for damages, including direct, indirect, special, incidental and +consequential damages, such as lost profits; + +iii) states that any provisions which differ from this Agreement are +offered by that Contributor alone and not by any other party; and + +iv) states that source code for the Program is available from such +Contributor, and informs licensees how to obtain it in a reasonable +manner on or through a medium customarily used for software exchange. + +When the Program is made available in source code form: + +a) it must be made available under this Agreement; and + +b) a copy of this Agreement must be included with each copy of the +Program. + +Contributors may not remove or alter any copyright notices contained +within the Program. + +Each Contributor must identify itself as the originator of its +Contribution, if any, in a manner that reasonably allows subsequent +Recipients to identify the originator of the Contribution. + +4. COMMERCIAL DISTRIBUTION + +Commercial distributors of software may accept certain +responsibilities with respect to end users, business partners and the +like. While this license is intended to facilitate the commercial use +of the Program, the Contributor who includes the Program in a +commercial product offering should do so in a manner which does not +create potential liability for other Contributors. Therefore, if a +Contributor includes the Program in a commercial product offering, +such Contributor ("Commercial Contributor") hereby agrees to defend +and indemnify every other Contributor ("Indemnified Contributor") +against any losses, damages and costs (collectively "Losses") arising +from claims, lawsuits and other legal actions brought by a third party +against the Indemnified Contributor to the extent caused by the acts +or omissions of such Commercial Contributor in connection with its +distribution of the Program in a commercial product offering. The +obligations in this section do not apply to any claims or Losses +relating to any actual or alleged intellectual property infringement. +In order to qualify, an Indemnified Contributor must: a) promptly +notify the Commercial Contributor in writing of such claim, and b) +allow the Commercial Contributor to control, and cooperate with the +Commercial Contributor in, the defense and any related settlement +negotiations. The Indemnified Contributor may participate in any such +claim at its own expense. + +For example, a Contributor might include the Program in a commercial +product offering, Product X. That Contributor is then a Commercial +Contributor. If that Commercial Contributor then makes performance +claims, or offers warranties related to Product X, those performance +claims and warranties are such Commercial Contributor's responsibility +alone. Under this section, the Commercial Contributor would have to +defend claims against the other Contributors related to those +performance claims and warranties, and if a court requires any other +Contributor to pay any damages as a result, the Commercial Contributor +must pay those damages. + +5. NO WARRANTY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS +PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY +WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY +OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely +responsible for determining the appropriateness of using and +distributing the Program and assumes all risks associated with its +exercise of rights under this Agreement , including but not limited to +the risks and costs of program errors, compliance with applicable +laws, damage to or loss of data, programs or equipment, and +unavailability or interruption of operations. + +6. DISCLAIMER OF LIABILITY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR +ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING +WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR +DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED +HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +7. GENERAL + +If any provision of this Agreement is invalid or unenforceable under +applicable law, it shall not affect the validity or enforceability of +the remainder of the terms of this Agreement, and without further +action by the parties hereto, such provision shall be reformed to the +minimum extent necessary to make such provision valid and enforceable. + +If Recipient institutes patent litigation against any entity +(including a cross-claim or counterclaim in a lawsuit) alleging that +the Program itself (excluding combinations of the Program with other +software or hardware) infringes such Recipient's patent(s), then such +Recipient's rights granted under Section 2(b) shall terminate as of +the date such litigation is filed. + +All Recipient's rights under this Agreement shall terminate if it +fails to comply with any of the material terms or conditions of this +Agreement and does not cure such failure in a reasonable period of +time after becoming aware of such noncompliance. If all Recipient's +rights under this Agreement terminate, Recipient agrees to cease use +and distribution of the Program as soon as reasonably practicable. +However, Recipient's obligations under this Agreement and any licenses +granted by Recipient relating to the Program shall continue and +survive. + +Everyone is permitted to copy and distribute copies of this Agreement, +but in order to avoid inconsistency the Agreement is copyrighted and +may only be modified in the following manner. The Agreement Steward +reserves the right to publish new versions (including revisions) of +this Agreement from time to time. No one other than the Agreement +Steward has the right to modify this Agreement. The Eclipse Foundation +is the initial Agreement Steward. The Eclipse Foundation may assign +the responsibility to serve as the Agreement Steward to a suitable +separate entity. Each new version of the Agreement will be given a +distinguishing version number. The Program (including Contributions) +may always be distributed subject to the version of the Agreement +under which it was received. In addition, after a new version of the +Agreement is published, Contributor may elect to distribute the +Program (including its Contributions) under the new version. Except as +expressly stated in Sections 2(a) and 2(b) above, Recipient receives +no rights or licenses to the intellectual property of any Contributor +under this Agreement, whether expressly, by implication, estoppel or +otherwise. All rights in the Program not expressly granted under this +Agreement are reserved. + +This Agreement is governed by the laws of the State of New York and +the intellectual property laws of the United States of America. No +party to this Agreement will bring a legal action under this Agreement +more than one year after the cause of action arose. Each party waives +its rights to a jury trial in any resulting litigation. + +-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + +Object Management Group (OMG) classes + +/***** Copyright (c) 1999 Object Management Group. Unlimited rights to + duplicate and use this code are hereby granted provided that this + copyright notice is included. +*****/ + + + + +========================================================================= +== ASM License == +========================================================================= + +Copyright (c) 2000-2005 INRIA, France Telecom +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +3. Neither the name of the copyright holders nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +========================================================================= +== Backport-Util-Concurrent == +========================================================================= + +Copyright-Only Dedication (based on United States law) or Public Domain +Certification + +The person or persons who have associated work with this document (the +"Dedicator" or "Certifier") hereby either (a) certifies that, to the +best of his knowledge, the work of authorship identified is in the +public domain of the country from which the work is published, or (b) +hereby dedicates whatever copyright the dedicators holds in the work of +authorship identified below (the "Work") to the public domain. A +certifier, morever, dedicates any copyright interest he may have in the +associated work, and for these purposes, is described as a "dedicator" +below. + +A certifier has taken reasonable steps to verify the copyright status +of this work. Certifier recognizes that his good faith efforts may not +shield him from liability if in fact the work certified is not in the +public domain. + +Dedicator makes this dedication for the benefit of the public at large +and to the detriment of the Dedicator's heirs and successors. Dedicator +intends this dedication to be an overt act of relinquishment in perpetuity +of all present and future rights under copyright law, whether vested or +contingent, in the Work. Dedicator understands that such relinquishment +of all rights includes the relinquishment of all rights to enforce (by +lawsuit or otherwise) those copyrights in the Work. + +Dedicator recognizes that, once placed in the public domain, the Work +may be freely reproduced, distributed, transmitted, used, modified, built +upon, or otherwise exploited by anyone for any purpose, commercial or +non-commercial, and in any way, including by methods that have not yet +been invented or conceived. + + +========================================================================= +== Castor License == +========================================================================= + +New Apache-style license + +As of release 0.9.7, any new code artifacts should carry a new, Apache 2.0-style +license. This shall include files that have been changed substantially through +e.g. refactoring. + +Copyright 2004-2005 Werner Guttmann + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + + +Original Intalio license + +The code of this project is released under a BSD-like license [license.txt]: + +Copyright 1999-2004 (C) Intalio Inc., and others. All Rights +Reserved. Redistribution and use of this software and +associated documentation ("Software"), with or without +modification, are permitted provided that the following +conditions are met: + +1. Redistributions of source code must + retain copyright statements and notices. Redistributions must + also contain a copy of this document. + +2. Redistributions in + binary form must reproduce the above copyright notice, this + list of conditions and the following disclaimer in the + documentation and/or other materials provided with the + distribution. + +3. The name "ExoLab" must not be used to endorse + or promote products derived from this Software without prior + written permission of Intalio Inc. For written permission, + please contact info@exolab.org. + +4. Products derived from this Software may not be called "Castor" nor may + "Castor" appear in their names without prior written permission + of Intalio Inc. Exolab, Castor and Intalio are trademarks of + Intalio Inc. + +5. Due credit should be given to the ExoLab Project + (http://www.exolab.org/). + + +THIS SOFTWARE IS PROVIDED BY INTALIO AND CONTRIBUTORS ``AS IS'' AND +ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTALIO OR +ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH +DAMAGE. + + +========================================================================= +== Concurrent License == +========================================================================= + +TECHNOLOGY LICENSE FROM SUN MICROSYSTEMS, INC. TO DOUG LEA + +Whereas Doug Lea desires to utlized certain Java Software technologies +in the util.concurrent technology; and Whereas Sun Microsystems, Inc. +("Sun") desires that Doug Lea utilize certain Java Software technologies +in the util.concurrent technology; + +Therefore the parties agree as follows, effective May 31, 2002: "Java +Software technologies" means classes/java/util/ArrayList.java, and +classes/java/util/HashMap.java. + +The Java Software technologies are Copyright (c) 1994-2000 Sun +Microsystems, Inc. All rights reserved. Sun hereby grants Doug Lea a +non-exclusive, worldwide, non-transferrable license to use, reproduce, +create derivate works of, and distribute the Java Software and derivative +works thereof in source and binary forms as part of a larger work, and +to sublicense the right to use, reproduce and distribute the Java Software +and Doug Lea's derivative works as the part of larger works through +multiple tiers of sublicensees provided that the following conditions +are met: + +-Neither the name of or trademarks of Sun may be used to endorse or + promote products including or derived from the Java Software technology + without specific prior written permission; and +-Redistributions of source or binary code must contain the above + copyright notice, this notice and the following disclaimers: + +This software is provided "AS IS," without a warranty of any kind. ALL +EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING +ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE +OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. AND ITS +LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A +RESULT OF USING, MODIFYING OR DISTRIBUTING THE SOFTWARE OR ITS +DERIVATIVES. IN NO EVENT WILL SUN MICROSYSTEMS, INC. OR ITS LICENSORS BE +LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, +SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED +AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR +INABILITY TO USE SOFTWARE, EVEN IF SUN MICROSYSTEMS, INC. HAS BEEN +ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +You acknowledge that Software is not designed, licensed or intended for +use in the design, construction, operation or maintenance of any nuclear +facility. + +signed [Doug Lea] dated + + +========================================================================= +== CUP Parser Generator License (included in xalan jar) == +========================================================================= + +CUP Parser Generator Copyright Notice, License, and Disclaimer +(runtime.jar component) + +Copyright 1996-1999 by Scott Hudson, Frank Flannery, C. Scott Ananian + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, provided +that the above copyright notice appear in all copies and that both +the copyright notice and this permission notice and warranty disclaimer +appear in supporting documentation, and that the names of the authors +or their employers not be used in advertising or publicity pertaining +to distribution of the software without specific, written prior permission. + +The authors and their employers disclaim all warranties with regard to +this software, including all implied warranties of merchantability +and fitness. In no event shall the authors or their employers be liable +for any special, indirect or consequential damages or any damages +whatsoever resulting from loss of use, data or profits, whether in an action +of contract, negligence or other tortious action, arising out of or +in connection with the use or performance of this software. + + +========================================================================= +== Dojo License == +========================================================================= + +Copyright (c) 2005, The Dojo Foundation +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of the Dojo Foundation nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +========================================================================= +== Glassfish License == +========================================================================= + +COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 + +1. Definitions. + +1.1. Contributor means each individual or entity that creates or + contributes to the creation of Modifications. + +1.2. Contributor Version means the combination of the Original + Software, prior Modifications used by a Contributor (if any), and + the Modifications made by that particular Contributor. + +1.3. Covered Software means (a) the Original Software, or (b) + Modifications, or (c) the combination of files containing + Original Software with files containing Modifications, in each + case including portions thereof. + +1.4. Executable means the Covered Software in any form other than + Source Code. + +1.5. Initial Developer means the individual or entity that first makes + Original Software available under this License. + +1.6. Larger Work means a work which combines Covered Software or + portions thereof with code not governed by the terms of this + License. + +1.7. License means this document. + +1.8. Licensable means having the right to grant, to the maximum extent + possible, whether at the time of the initial grant or + subsequently acquired, any and all of the rights conveyed herein. + +1.9. Modifications means the Source Code and Executable form of any of + the following: + +A. Any file that results from an addition to, deletion from or +modification of the contents of a file containing Original Software or +previous Modifications; + +B. Any new file that contains any part of the Original Software or +previous Modification; or + +C. Any new file that is contributed or otherwise made available under +the terms of this License. + +1.10. Original Software means the Source Code and Executable form of + computer software code that is originally released under this + License. + +1.11. Patent Claims means any patent claim(s), now owned or hereafter + acquired, including without limitation, method, process, and + apparatus claims, in any patent Licensable by grantor. + +1.12. Source Code means (a) the common form of computer software code + in which modifications are made and (b) associated documentation + included in or with such code. + +1.13. You (or Your) means an individual or a legal entity exercising + rights under, and complying with all of the terms of, this + License. For legal entities, You includes any entity which + controls, is controlled by, or is under common control with + You. For purposes of this definition, control means (a)áthe + power, direct or indirect, to cause the direction or management + of such entity, whether by contract or otherwise, or + (b)áownership of more than fifty percent (50%) of the + outstanding shares or beneficial ownership of such entity. + +2. License Grants. + +2.1. The Initial Developer Grant. Conditioned upon Your compliance +with Section 3.1 below and subject to third party intellectual +property claims, the Initial Developer hereby grants You a world-wide, +royalty-free, non-exclusive license: (a) under intellectual property +rights (other than patent or trademark) Licensable by Initial +Developer, to use, reproduce, modify, display, perform, sublicense and +distribute the Original Software (or portions thereof), with or +without Modifications, and/or as part of a Larger Work; and (b) under +Patent Claims infringed by the making, using or selling of Original +Software, to make, have made, use, practice, sell, and offer for sale, +and/or otherwise dispose of the Original Software (or portions +thereof). (c) The licenses granted in Sectionsá2.1(a) and (b) are +effective on the date Initial Developer first distributes or otherwise +makes the Original Software available to a third party under the terms +of this License. (d) Notwithstanding Sectioná2.1(b) above, no patent +license is granted: (1)áfor code that You delete from the Original +Software, or (2)áfor infringements caused by: (i)áthe modification of +the Original Software, or (ii)áthe combination of the Original +Software with other software or devices. + +2.2. Contributor Grant. Conditioned upon Your compliance with Section +3.1 below and subject to third party intellectual property claims, +each Contributor hereby grants You a world-wide, royalty-free, +non-exclusive license: (a) under intellectual property rights (other +than patent or trademark) Licensable by Contributor to use, reproduce, +modify, display, perform, sublicense and distribute the Modifications +created by such Contributor (or portions thereof), either on an +unmodified basis, with other Modifications, as Covered Software and/or +as part of a Larger Work; and (b) under Patent Claims infringed by the +making, using, or selling of Modifications made by that Contributor +either alone and/or in combination with its Contributor Version (or +portions of such combination), to make, use, sell, offer for sale, +have made, and/or otherwise dispose of: (1)áModifications made by that +Contributor (or portions thereof); and (2)áthe combination of +Modifications made by that Contributor with its Contributor Version +(or portions of such combination). (c) The licenses granted in +Sectionsá2.2(a) and 2.2(b) are effective on the date Contributor first +distributes or otherwise makes the Modifications available to a third +party. (d) Notwithstanding Sectioná2.2(b) above, no patent license is +granted: (1)áfor any code that Contributor has deleted from the +Contributor Version; (2)áfor infringements caused by: (i)áthird party +modifications of Contributor Version, or (ii)áthe combination of +Modifications made by that Contributor with other software (except as +part of the Contributor Version) or other devices; or (3)áunder Patent +Claims infringed by Covered Software in the absence of Modifications +made by that Contributor. + +3. Distribution Obligations. + +3.1. Availability of Source Code. + +Any Covered Software that You distribute or otherwise make available +in Executable form must also be made available in Source Code form and +that Source Code form must be distributed only under the terms of this +License. You must include a copy of this License with every copy of +the Source Code form of the Covered Software You distribute or +otherwise make available. You must inform recipients of any such +Covered Software in Executable form as to how they can obtain such +Covered Software in Source Code form in a reasonable manner on or +through a medium customarily used for software exchange. + +3.2. Modifications. + +The Modifications that You create or to which You contribute are +governed by the terms of this License. You represent that You believe +Your Modifications are Your original creation(s) and/or You have +sufficient rights to grant the rights conveyed by this License. + +3.3. Required Notices. You must include a notice in each of Your +Modifications that identifies You as the Contributor of the +Modification. You may not remove or alter any copyright, patent or +trademark notices contained within the Covered Software, or any +notices of licensing or any descriptive text giving attribution to any +Contributor or the Initial Developer. + +3.4. Application of Additional Terms. You may not offer or impose any +terms on any Covered Software in Source Code form that alters or +restricts the applicable version of this License or the recipients +rights hereunder. You may choose to offer, and to charge a fee for, +warranty, support, indemnity or liability obligations to one or more +recipients of Covered Software. However, you may do so only on Your +own behalf, and not on behalf of the Initial Developer or any +Contributor. You must make it absolutely clear that any such warranty, +support, indemnity or liability obligation is offered by You alone, +and You hereby agree to indemnify the Initial Developer and every +Contributor for any liability incurred by the Initial Developer or +such Contributor as a result of warranty, support, indemnity or +liability terms You offer. + +3.5. Distribution of Executable Versions. You may distribute the +Executable form of the Covered Software under the terms of this +License or under the terms of a license of Your choice, which may +contain terms different from this License, provided that You are in +compliance with the terms of this License and that the license for the +Executable form does not attempt to limit or alter the recipients +rights in the Source Code form from the rights set forth in this +License. If You distribute the Covered Software in Executable form +under a different license, You must make it absolutely clear that any +terms which differ from this License are offered by You alone, not by +the Initial Developer or Contributor. You hereby agree to indemnify +the Initial Developer and every Contributor for any liability incurred +by the Initial Developer or such Contributor as a result of any such +terms You offer. + +3.6. Larger Works. You may create a Larger Work by combining Covered +Software with other code not governed by the terms of this License and +distribute the Larger Work as a single product. In such a case, You +must make sure the requirements of this License are fulfilled for the +Covered Software. + +4. Versions of the License. + +4.1. New Versions. Sun Microsystems, Inc. is the initial license +steward and may publish revised and/or new versions of this License +from time to time. Each version will be given a distinguishing version +number. Except as provided in Section 4.3, no one other than the +license steward has the right to modify this License. + +4.2. Effect of New Versions. + +You may always continue to use, distribute or otherwise make the +Covered Software available under the terms of the version of the +License under which You originally received the Covered Software. If +the Initial Developer includes a notice in the Original Software +prohibiting it from being distributed or otherwise made available +under any subsequent version of the License, You must distribute and +make the Covered Software available under the terms of the version of +the License under which You originally received the Covered +Software. Otherwise, You may also choose to use, distribute or +otherwise make the Covered Software available under the terms of any +subsequent version of the License published by the license steward. +4.3. Modified Versions. + +When You are an Initial Developer and You want to create a new license +for Your Original Software, You may create and use a modified version +of this License if You: (a)árename the license and remove any +references to the name of the license steward (except to note that the +license differs from this License); and (b)áotherwise make it clear +that the license contains terms which differ from this License. + +5. DISCLAIMER OF WARRANTY. + +COVERED SOFTWARE IS PROVIDED UNDER THIS LICENSE ON AN AS IS BASIS, +WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +WITHOUT LIMITATION, WARRANTIES THAT THE COVERED SOFTWARE IS FREE OF +DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR +NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF +THE COVERED SOFTWARE IS WITH YOU. SHOULD ANY COVERED SOFTWARE PROVE +DEFECTIVE IN ANY RESPECT, YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER +CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY SERVICING, REPAIR OR +CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART +OF THIS LICENSE. NO USE OF ANY COVERED SOFTWARE IS AUTHORIZED +HEREUNDER EXCEPT UNDER THIS DISCLAIMER. + +6. TERMINATION. + +6.1. This License and the rights granted hereunder will terminate + automatically if You fail to comply with terms herein and fail to + cure such breach within 30 days of becoming aware of the + breach. Provisions which, by their nature, must remain in effect + beyond the termination of this License shall survive. + +6.2. If You assert a patent infringement claim (excluding declaratory + judgment actions) against Initial Developer or a Contributor (the + Initial Developer or Contributor against whom You assert such + claim is referred to as Participant) alleging that the + Participant Software (meaning the Contributor Version where the + Participant is a Contributor or the Original Software where the + Participant is the Initial Developer) directly or indirectly + infringes any patent, then any and all rights granted directly or + indirectly to You by such Participant, the Initial Developer (if + the Initial Developer is not the Participant) and all + Contributors under Sectionsá2.1 and/or 2.2 of this License shall, + upon 60 days notice from Participant terminate prospectively and + automatically at the expiration of such 60 day notice period, + unless if within such 60 day period You withdraw Your claim with + respect to the Participant Software against such Participant + either unilaterally or pursuant to a written agreement with + Participant. + +6.3. In the event of termination under Sectionsá6.1 or 6.2 above, all + end user licenses that have been validly granted by You or any + distributor hereunder prior to termination (excluding licenses + granted to You by any distributor) shall survive termination. + +7. LIMITATION OF LIABILITY. + +UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT +(INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL +DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED +SOFTWARE, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY +PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES +OF ANY CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOST +PROFITS, LOSS OF GOODWILL, WORK STOPPAGE, COMPUTER FAILURE OR +MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL DAMAGES OR LOSSES, EVEN +IF SUCH PARTY SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF SUCH +DAMAGES. THIS LIMITATION OF LIABILITY SHALL NOT APPLY TO LIABILITY FOR +DEATH OR PERSONAL INJURY RESULTING FROM SUCH PARTYS NEGLIGENCE TO THE +EXTENT APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO +NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL +DAMAGES, SO THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU. + +8. U.S. GOVERNMENT END USERS. + +The Covered Software is a commercial item, as that term is defined in +48áC.F.R.á2.101 (Oct. 1995), consisting of commercial computer +software (as that term is defined at 48 C.F.R. á252.227-7014(a)(1)) +and commercial computer software documentation as such terms are used +in 48áC.F.R.á12.212 (Sept. 1995). Consistent with 48 C.F.R. 12.212 and +48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995), all +U.S. Government End Users acquire Covered Software with only those +rights set forth herein. This U.S. Government Rights clause is in lieu +of, and supersedes, any other FAR, DFAR, or other clause or provision +that addresses Government rights in computer software under this +License. + +9. MISCELLANEOUS. + +This License represents the complete agreement concerning subject +matter hereof. If any provision of this License is held to be +unenforceable, such provision shall be reformed only to the extent +necessary to make it enforceable. This License shall be governed by +the law of the jurisdiction specified in a notice contained within the +Original Software (except to the extent applicable law, if any, +provides otherwise), excluding such jurisdictions conflict-of-law +provisions. Any litigation relating to this License shall be subject +to the jurisdiction of the courts located in the jurisdiction and +venue specified in a notice contained within the Original Software, +with the losing party responsible for costs, including, without +limitation, court costs and reasonable attorneys fees and +expenses. The application of the United Nations Convention on +Contracts for the International Sale of Goods is expressly +excluded. Any law or regulation which provides that the language of a +contract shall be construed against the drafter shall not apply to +this License. You agree that You alone are responsible for compliance +with the United States export administration regulations (and the +export control laws and regulation of any other countries) when You +use, distribute or otherwise make available any Covered Software. + +10. RESPONSIBILITY FOR CLAIMS. + +As between Initial Developer and the Contributors, each party is +responsible for claims and damages arising, directly or indirectly, +out of its utilization of rights under this License and You agree to +work with Initial Developer and Contributors to distribute such +responsibility on an equitable basis. Nothing herein is intended or +shall be deemed to constitute any admission of liability. + +NOTICE PURSUANT TO SECTION 9 OF THE COMMON DEVELOPMENT AND +DISTRIBUTION LICENSE (CDDL) The GlassFish code released under the CDDL +shall be governed by the laws of the State of California (excluding +conflict-of-law provisions). Any litigation relating to this License +shall be subject to the jurisdiction of the Federal Courts of the +Northern District of California and the state courts of the State of +California, with venue lying in Santa Clara County, California. + + +========================================================================= +== HOWL License == +========================================================================= + +Copyright (c) 2004, Bull S.A. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +========================================================================= +== JDBM License == +========================================================================= + +JDBM LICENSE v1.00 + +Redistribution and use of this software and associated documentation +("Software"), with or without modification, are permitted provided +that the following conditions are met: + +1. Redistributions of source code must retain copyright + statements and notices. Redistributions must also contain a + copy of this document. + +2. Redistributions in binary form must reproduce the + above copyright notice, this list of conditions and the + following disclaimer in the documentation and/or other + materials provided with the distribution. + +3. The name "JDBM" must not be used to endorse or promote + products derived from this Software without prior written + permission of Cees de Groot. For written permission, + please contact cg@cdegroot.com. + +4. Products derived from this Software may not be called "JDBM" + nor may "JDBM" appear in their names without prior written + permission of Cees de Groot. + +5. Due credit should be given to the JDBM Project + (http://jdbm.sourceforge.net/). + +THIS SOFTWARE IS PROVIDED BY THE JDBM PROJECT AND CONTRIBUTORS +``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT +NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +CEES DE GROOT OR ANY CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED +OF THE POSSIBILITY OF SUCH DAMAGE. + +Copyright 2000 (C) Cees de Groot. All Rights Reserved. +Contributions are Copyright (C) 2000 by their associated contributors. + + +========================================================================= +== JDOM License == +========================================================================= + +Copyright (C) 2000-2004 Jason Hunter & Brett McLaughlin. +All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions, and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions, and the disclaimer that follows + these conditions in the documentation and/or other materials + provided with the distribution. + + 3. The name "JDOM" must not be used to endorse or promote products + derived from this software without prior written permission. For + written permission, please contact . + + 4. Products derived from this software may not be called "JDOM", nor + may "JDOM" appear in their name, without prior written permission + from the JDOM Project Management . + + In addition, we request (but do not require) that you include in the + end-user documentation provided with the redistribution and/or in the + software itself an acknowledgement equivalent to the following: + "This product includes software developed by the + JDOM Project (http://www.jdom.org/)." + Alternatively, the acknowledgment may be graphical using the logos + available at http://www.jdom.org/images/logos. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE JDOM AUTHORS OR THE PROJECT + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + SUCH DAMAGE. + + This software consists of voluntary contributions made by many + individuals on behalf of the JDOM Project and was originally + created by Jason Hunter and + Brett McLaughlin . For more information + on the JDOM Project, please see . + + +========================================================================= +== JLine License == +========================================================================= + +Copyright (c) 2002-2006, Marc Prud'hommeaux +All rights reserved. + +Redistribution and use in source and binary forms, with or +without modification, are permitted provided that the following +conditions are met: + +Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + +Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with +the distribution. + +Neither the name of JLine nor the names of its contributors +may be used to endorse or promote products derived from this +software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED +OF THE POSSIBILITY OF SUCH DAMAGE. + + +========================================================================= +== OGNL License == +========================================================================= + +The OpenSymphony Software License, Version 1.1 + +(this license is derived and fully compatible with the Apache Software +License - see http://www.apache.org/LICENSE.txt) + +Copyright (c) 2001-2004 The OpenSymphony Group. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + +3. The end-user documentation included with the redistribution, + if any, must include the following acknowledgment: + "This product includes software developed by the + OpenSymphony Group (http://www.opensymphony.com/)." + Alternately, this acknowledgment may appear in the software itself, + if and wherever such third-party acknowledgments normally appear. + +4. The names "OpenSymphony" and "The OpenSymphony Group" + must not be used to endorse or promote products derived from this + software without prior written permission. For written + permission, please contact license@opensymphony.com . + +5. Products derived from this software may not be called "OpenSymphony" + or "OGNL", nor may "OpenSymphony" or "OGNL" appear in their + name, without prior written permission of the OpenSymphony Group. + +THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR +ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +SUCH DAMAGE. + + +========================================================================= +== Serp License == +========================================================================= + +Copyright (c) 2002, A. Abram White +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. +* Neither the name of 'serp' nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +========================================================================= +== SL4J License == +========================================================================= + +Copyright (c) 2004-2005 SLF4J.ORG +Copyright (c) 2004-2005 QOS.ch + +All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, and/or sell copies of the Software, and to permit persons +to whom the Software is furnished to do so, provided that the above +copyright notice(s) and this permission notice appear in all copies of +the Software and that both the above copyright notice(s) and this +permission notice appear in supporting documentation. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY +SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER +RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF +CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +Except as contained in this notice, the name of a copyright holder +shall not be used in advertising or otherwise to promote the sale, use +or other dealings in this Software without prior written authorization +of the copyright holder. + +========================================================================= +== WSDL4J License == +========================================================================= + +Common Public License - v 1.0 + + +THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON +PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE +PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. + + +1. DEFINITIONS + +"Contribution" means: + +a) in the case of the initial Contributor, the initial code and + documentation distributed under this Agreement, and + +b) in the case of each subsequent Contributor: + +i) changes to the Program, and + +ii) additions to the Program; + +where such changes and/or additions to the Program originate from and are +distributed by that particular Contributor. A Contribution 'originates' +from a Contributor if it was added to the Program by such Contributor +itself or anyone acting on such Contributor's behalf. Contributions do not +include additions to the Program which: (i) are separate modules of +software distributed in conjunction with the Program under their own +license agreement, and (ii) are not derivative works of the Program. + +"Contributor" means any person or entity that distributes the Program. + + +"Licensed Patents " mean patent claims licensable by a Contributor which +are necessarily infringed by the use or sale of its Contribution alone or +when combined with the Program. + + +"Program" means the Contributions distributed in accordance with this +Agreement. + + +"Recipient" means anyone who receives the Program under this Agreement, +including all Contributors. + + +2. GRANT OF RIGHTS + +a) Subject to the terms of this Agreement, each Contributor hereby grants +Recipient a non-exclusive, worldwide, royalty-free copyright license to +reproduce, prepare derivative works of, publicly display, publicly +perform, distribute and sublicense the Contribution of such Contributor, +if any, and such derivative works, in source code and object code form. + +b) Subject to the terms of this Agreement, each Contributor hereby grants +Recipient a non-exclusive, worldwide, royalty-free patent license under +Licensed Patents to make, use, sell, offer to sell, import and otherwise +transfer the Contribution of such Contributor, if any, in source code and +object code form. This patent license shall apply to the combination of the +Contribution and the Program if, at the time the Contribution is added by +the Contributor, such addition of the Contribution causes such combination +to be covered by the Licensed Patents. The patent license shall not apply +to any other combinations which include the Contribution. No hardware per se +is licensed hereunder. + +c) Recipient understands that although each Contributor grants the licenses +to its Contributions set forth herein, no assurances are provided by any +Contributor that the Program does not infringe the patent or other +intellectual property rights of any other entity. Each Contributor disclaims +any liability to Recipient for claims brought by any other entity based on +infringement of intellectual property rights or otherwise. As a condition to +exercising the rights and licenses granted hereunder, each Recipient hereby +assumes sole responsibility to secure any other intellectual property rights +needed, if any. For example, if a third party patent license is required to +allow Recipient to distribute the Program, it is Recipient's responsibility +to acquire that license before distributing the Program. + +d) Each Contributor represents that to its knowledge it has sufficient +copyright rights in its Contribution, if any, to grant the copyright license +set forth in this Agreement. + +3. REQUIREMENTS + +A Contributor may choose to distribute the Program in object code form under +its own license agreement, provided that: + +a) it complies with the terms and conditions of this Agreement; and + +b) its license agreement: + +i) effectively disclaims on behalf of all Contributors all warranties and +conditions, express and implied, including warranties or conditions of title +and non-infringement, and implied warranties or conditions of merchantability +and fitness for a particular purpose; + +ii) effectively excludes on behalf of all Contributors all liability for +damages, including direct, indirect, special, incidental and consequential +damages, such as lost profits; + +iii) states that any provisions which differ from this Agreement are offered +by that Contributor alone and not by any other party; and + +iv) states that source code for the Program is available from such +Contributor, and informs licensees how to obtain it in a reasonable manner on +or through a medium customarily used for software exchange. + +When the Program is made available in source code form: + +a) it must be made available under this Agreement; and + +b) a copy of this Agreement must be included with each copy of the Program. + +Contributors may not remove or alter any copyright notices contained within +the Program. + +Each Contributor must identify itself as the originator of its +Contribution, if any, in a manner that reasonably allows subsequent +Recipients to identify the originator of the Contribution. + +4. COMMERCIAL DISTRIBUTION + +Commercial distributors of software may accept certain responsibilities +with respect to end users, business partners and the like. While this +license is intended to facilitate the commercial use of the Program, the +Contributor who includes the Program in a commercial product offering +should do so in a manner which does not create potential liability for +other Contributors. Therefore, if a Contributor includes the Program in a +commercial product offering, such Contributor ("Commercial Contributor") +hereby agrees to defend and indemnify every other Contributor ("Indemnified +Contributor") against any losses, damages and costs (collectively "Losses") +arising from claims, lawsuits and other legal actions brought by a third +party against the Indemnified Contributor to the extent caused by the acts +or omissions of such Commercial Contributor in connection with its +distribution of the Program in a commercial product offering. The +obligations in this section do not apply to any claims or Losses relating +to any actual or alleged intellectual property infringement. In order to +qualify, +an Indemnified Contributor must: a) promptly notify the Commercial +Contributor in writing of such claim, and b) allow the Commercial +Contributor to control, and cooperate with the Commercial Contributor in, +the defense and any related settlement negotiations. The Indemnified +Contributor may participate in any such claim at its own expense. + + +For example, a Contributor might include the Program in a commercial +product offering, Product X. That Contributor is then a Commercial +Contributor. If that Commercial Contributor then makes performance claims, +or offers warranties related to Product X, those performance claims and +warranties are such Commercial Contributor's responsibility alone. Under +this section, the Commercial Contributor would have to defend claims +against the other Contributors related to those performance claims and +warranties, and if a court requires any other Contributor to pay any +damages as a result, the Commercial Contributor must pay those damages. + + +5. NO WARRANTY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED +ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER +EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR +CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A +PARTICULAR PURPOSE. Each Recipient is solely responsible for determining +the appropriateness of using and distributing the Program and assumes all +risks associated with its exercise of rights under this Agreement, +including but not limited to the risks and costs of program errors, +compliance with applicable laws, damage to or loss of data, programs or +equipment, and unavailability or interruption of operations. + + +6. DISCLAIMER OF LIABILITY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY +CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION +LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE +EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + +7. GENERAL + +If any provision of this Agreement is invalid or unenforceable under +applicable law, it shall not affect the validity or enforceability of +the remainder of the terms of this Agreement, and without further action +by the parties hereto, such provision shall be reformed to the minimum +extent necessary to make such provision valid and enforceable. + + +If Recipient institutes patent litigation against a Contributor with +respect to a patent applicable to software (including a cross-claim or +counterclaim in a lawsuit), then any patent licenses granted by that +Contributor to such Recipient under this Agreement shall terminate as +of the date such litigation is filed. In addition, if Recipient +institutes patent litigation against any entity (including a cross-claim +or counterclaim in a lawsuit) alleging that the Program itself (excluding +combinations of the Program with other software or hardware) infringes +such Recipient's patent(s), then such Recipient's rights granted under +Section 2(b) shall terminate as of the date such litigation is filed. + + +All Recipient's rights under this Agreement shall terminate if it fails +to comply with any of the material terms or conditions of this Agreement +and does not cure such failure in a reasonable period of time after +becoming aware of such noncompliance. If all Recipient's rights under this +Agreement terminate, Recipient agrees to cease use and distribution of the +Program as soon as reasonably practicable. However, Recipient's obligations +under this Agreement and any licenses granted by Recipient relating to the +Program shall continue and survive. + + +Everyone is permitted to copy and distribute copies of this Agreement, +but in order to avoid inconsistency the Agreement is copyrighted and may +only be modified in the following manner. The Agreement Steward reserves +the right to publish new versions (including revisions) of this Agreement +from time to time. No one other than the Agreement Steward has the right +to modify this Agreement. IBM is the initial Agreement Steward. IBM may +assign the responsibility to serve as the Agreement Steward to a suitable +separate entity. Each new version of the Agreement will be given a +distinguishing version number. The Program (including Contributions) may +always be distributed subject to the version of the Agreement under which +it was received. In addition, after a new version of the Agreement is +published, Contributor may elect to distribute the Program (including its +Contributions) under the new version. Except as expressly stated in +Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to +the intellectual property of any Contributor under this Agreement, whether +expressly, by implication, estoppel or otherwise. All rights in the Program +not expressly granted under this Agreement are reserved. + + +This Agreement is governed by the laws of the State of New York and the +intellectual property laws of the United States of America. No party to this +Agreement will bring a legal action under this Agreement more than one year +after the cause of action arose. Each party waives its rights to a jury +trial in any resulting litigation. + + +========================================================================= +== W3C Document Object Model License (xercesImpl) == +========================================================================= + +Document Object Model Level 2 Core is a platform and language-neutral +interface that allows programs and scripts to dynamically access and +update the content and structure of documents. The Document Object +Model Level 2 Core builds on the Document Object Model Level 1 Core. + +The DOM Level 2 Core is made of a set of core interfaces to create and +manipulate the structure and contents of a document. The Core also +contains specialized interfaces dedicated to XML. + +W3C IPR SOFTWARE NOTICE + +Copyright (c) 2000 World Wide Web Consortium, (Massachusetts Institute +of Technology, Institut National de Recherche en Informatique et en +Automatique, Keio University). All Rights Reserved. + +The DOM bindings are published under the W3C Software Copyright Notice +and License. The software license requires "Notice of any changes or +modifications to the W3C files, including the date changes were made." +Consequently, modified versions of the DOM bindings must document that +they do not conform to the W3C standard; in the case of the IDL +binding, the pragma prefix can no longer be 'w3c.org'; in the case of +the Java binding, the package names can no longer be in the 'org.w3c' +package. + +Note: The original version of the W3C Software Copyright Notice and +License could be found at +http://www.w3.org/Consortium/Legal/copyright-software-19980720 + +Copyright (c) 1994-2000 World Wide Web Consortium, (Massachusetts +Institute of Technology, Institut National de Recherche en +Informatique et en Automatique, Keio University). All Rights +Reserved. http://www.w3.org/Consortium/Legal/ + +This W3C work (including software, documents, or other related items) +is being provided by the copyright holders under the following +license. By obtaining, using and/or copying this work, you (the +licensee) agree that you have read, understood, and will comply with +the following terms and conditions: + +Permission to use, copy, and modify this software and its +documentation, with or without modification, for any purpose and +without fee or royalty is hereby granted, provided that you include +the following on ALL copies of the software and documentation or +portions thereof, including modifications, that you make: + +The full text of this NOTICE in a location viewable to users of the +redistributed or derivative work. Any pre-existing intellectual +property disclaimers, notices, or terms and conditions. If none exist, +a short notice of the following form (hypertext is preferred, text is +permitted) should be used within the body of any redistributed or +derivative code: "Copyright (c) [$date-of-software] World Wide Web +Consortium, (Massachusetts Institute of Technology, Institut National +de Recherche en Informatique et en Automatique, Keio University). All +Rights Reserved. http://www.w3.org/Consortium/Legal/" Notice of any +changes or modifications to the W3C files, including the date changes +were made. (We recommend you provide URIs to the location from which +the code is derived.) THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS +IS," AND COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF +MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE +OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY +PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS. + +COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL +OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR +DOCUMENTATION. + +The name and trademarks of copyright holders may NOT be used in +advertising or publicity pertaining to the software without specific, +written prior permission. Title to copyright in this software and any +associated documentation will at all times remain with copyright +holders. + + +========================================================================= +== W3C Software License (xercesImpl and xmlParserAPIs) == +========================================================================= + +W3C (c) SOFTWARE NOTICE AND LICENSE + +Copyright (c) 1994-2002 World Wide Web Consortium, (Massachusetts +Institute of Technology, Institut National de Recherche en +Informatique et en Automatique, Keio University). All Rights +Reserved. http://www.w3.org/Consortium/Legal/ + +This W3C work (including software, documents, or other related items) +is being provided by the copyright holders under the following +license. By obtaining, using and/or copying this work, you (the +licensee) agree that you have read, understood, and will comply with +the following terms and conditions: + +Permission to use, copy, modify, and distribute this software and its +documentation, with or without modification, for any purpose and +without fee or royalty is hereby granted, provided that you include +the following on ALL copies of the software and documentation or +portions thereof, including modifications, that you make: + +The full text of this NOTICE in a location viewable to users of the +redistributed or derivative work. Any pre-existing intellectual +property disclaimers, notices, or terms and conditions. If none exist, +a short notice of the following form (hypertext is preferred, text is +permitted) should be used within the body of any redistributed or +derivative code: "Copyright (c) [$date-of-software] World Wide Web +Consortium, (Massachusetts Institute of Technology, Institut National +de Recherche en Informatique et en Automatique, Keio University). All +Rights Reserved. http://www.w3.org/Consortium/Legal/" Notice of any +changes or modifications to the W3C files, including the date changes +were made. (We recommend you provide URIs to the location from which +the code is derived.) THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS +IS," AND COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF +MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE +OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY +PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS. + +COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL +OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR +DOCUMENTATION. + +The name and trademarks of copyright holders may NOT be used in +advertising or publicity pertaining to the software without specific, +written prior permission. Title to copyright in this software and any +associated documentation will at all times remain with copyright +holders. + +____________________________________ + +This formulation of W3C's notice and license became active on August +14 1998 so as to improve compatibility with GPL. This version ensures +that W3C software licensing terms are no more restrictive than GPL and +consequently W3C software may be distributed in GPL packages. See the +older formulation for the policy prior to this date. Please see our +Copyright FAQ for common questions about using materials from our +site, including specific terms and conditions for packages like +libwww, Amaya, and Jigsaw. Other questions about this notice can be +directed to site-policy@w3.org. + + +========================================================================= +== xpp3 License == +========================================================================= + +Indiana University Extreme! Lab Software License + +Version 1.1.1 + +Copyright (c) 2002 Extreme! Lab, Indiana University. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the distribution. + +3. The end-user documentation included with the redistribution, if any, + must include the following acknowledgment: + + "This product includes software developed by the Indiana University + Extreme! Lab (http://www.extreme.indiana.edu/)." + +Alternately, this acknowledgment may appear in the software itself, +if and wherever such third-party acknowledgments normally appear. + +4. The names "Indiana Univeristy" and "Indiana Univeristy Extreme! Lab" +must not be used to endorse or promote products derived from this +software without prior written permission. For written permission, +please contact http://www.extreme.indiana.edu/. + +5. Products derived from this software may not use "Indiana Univeristy" +name nor may "Indiana Univeristy" appear in their name, without prior +written permission of the Indiana University. + +THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE AUTHORS, COPYRIGHT HOLDERS OR ITS CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +========================================================================= +== XStream License == +========================================================================= + +Copyright (c) 2003-2006, Joe Walnes +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions and the following disclaimer. Redistributions in +binary form must reproduce the above copyright notice, this list of +conditions and the following disclaimer in the documentation and/or other +materials provided with the distribution. + +Neither the name of XStream nor the names of its contributors may be used +to endorse or promote products derived from this software without +specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER +OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/sandbox/rfeng/geronimo-demo/README.TXT b/sandbox/rfeng/geronimo-demo/README.TXT new file mode 100644 index 0000000000..502da1e53f --- /dev/null +++ b/sandbox/rfeng/geronimo-demo/README.TXT @@ -0,0 +1,54 @@ +README for Tuscany/Geronimo Integration Demo +============================================ + +The demo application is built on top of the code from geronimo sandbox: + +https://svn.apache.org/repos/asf/geronimo/sandbox/tuscany-integration (By Vamsi and Manu from Geronimo community, Thank you!). + +The pre-built binary images can be found at: +http://people.apache.org/~rfeng/tuscany-geronimo/images/ + +1) Check out the Geronimo 2.0.0 branch from https://svn.apache.org/repos/asf/geronimo/server/branches/2.0.0/ and run a top-down maven build +from the root. + +Note: +a. The Geronimo 2.0 M6 is not good enough. +b. I was trying to build modules and assembilies but it failed. + +2) Unzip the assemblies/target/geronimo-tomcat6-jee5-2.0-SNAPSHOT-bin.tar.gz to a local folder ( will be used below to +represent the home directory for geronimo). + +3) Copy tuscany-binding-ejb-0.91-incubating.jar to overwrite +\repository\org\apache\tuscany\sca\tuscany-binding-ejb\0.91-incubating\tuscany-binding-ejb-0.91-incubating.jar + +3.2) Copy tuscany-host-geronimo-1.0-incubating-SNAPSHOT.jar to overwrite +\repository\org\apache\tuscany\sca\tuscany-host-geronimo\1.0-incubating-SNAPSHOT\tuscany-host-geronimo-1.0-incubating-SNAPSHOT.jar + +4) Start the Geronimo server (\bin\startup.bat) + +5) Install the geronimo-tuscany-plugin: + +deploy.bat install-plugin geronimo-tuscany-plugin-1.0-incubating-SNAPSHOT.car + +6) Start the admin console (http://localhost:8080/console) or use deploy tool to: + +a) Make sure org.apache.geronimo.configs/openejb-corba-deployer/2.0-SNAPSHOT/car is started. Look under System Modules in Admin Console. +b) Deploy sample-geronimo-bigbank.jar +c) Deploy sample-geronimo-ejbs.jar +d) Deploy sample-geronimo-webs.war + +Note: +* If Geronimo complains that \var\catalina\work\bigbank folder is read only, change the attribute. +* If you want to use a different port other than 8080 for the web service, you need to a Tomcat HTTP connector for the new port. + + +7) Load the samples into your WTP(Eclipse) +Check out the three modules from http://svn.apache.org/repos/asf/incubator/tuscany/sandbox/rfeng/geronimo-demo/ + +8) Run the demo + +From the browser: http://localhost:8080/sample-geronimo-webs + +Start the Web Service Explorer from inside WTP(Eclipse) to work with http://localhost:8080/bigbank/AccountService + + diff --git a/sandbox/rfeng/geronimo-demo/bigbank/src/main/java/bigbank/account/AccountReport.java b/sandbox/rfeng/geronimo-demo/bigbank/src/main/java/bigbank/account/AccountReport.java new file mode 100644 index 0000000000..3f207e2f79 --- /dev/null +++ b/sandbox/rfeng/geronimo-demo/bigbank/src/main/java/bigbank/account/AccountReport.java @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package bigbank.account; + +import java.util.List; + +/** + */ +public class AccountReport { + private List summaries; + private String currency; + + public AccountReport(String currency, List summaries) { + this.currency = currency; + this.summaries = summaries; + } + + public List getAccountSummaries() { return summaries; } + + public String getCurrency() { return currency; } + + public String toString() { + return "currency: "+ currency + ", " + summaries; + } + +} diff --git a/sandbox/rfeng/geronimo-demo/bigbank/src/main/java/bigbank/account/AccountService.java b/sandbox/rfeng/geronimo-demo/bigbank/src/main/java/bigbank/account/AccountService.java new file mode 100644 index 0000000000..ca15b795e3 --- /dev/null +++ b/sandbox/rfeng/geronimo-demo/bigbank/src/main/java/bigbank/account/AccountService.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package bigbank.account; + +import org.osoa.sca.annotations.Remotable; + +/** + * Interface for a account service + */ +@Remotable +public interface AccountService { + public String getAccountReport(String customerID); +} diff --git a/sandbox/rfeng/geronimo-demo/bigbank/src/main/java/bigbank/account/AccountServiceImpl.java b/sandbox/rfeng/geronimo-demo/bigbank/src/main/java/bigbank/account/AccountServiceImpl.java new file mode 100644 index 0000000000..f1e3f60049 --- /dev/null +++ b/sandbox/rfeng/geronimo-demo/bigbank/src/main/java/bigbank/account/AccountServiceImpl.java @@ -0,0 +1,72 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package bigbank.account; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import org.osoa.sca.annotations.Property; +import org.osoa.sca.annotations.Reference; + +import bigbank.accountdata.AccountDataService; +import bigbank.accountdata.CheckingAccount; +import bigbank.accountdata.SavingsAccount; +import bigbank.accountdata.StockAccount; +import bigbank.stockquote.StockQuoteService; + +/** + * Account service implementation + */ +public class AccountServiceImpl implements AccountService { + + @Reference + public AccountDataService accountDataService; + + @Reference + public StockQuoteService stockQuoteService; + + @Property + public String currency; + + public String getAccountReport(String s) { + List summaries = new ArrayList(); + + CheckingAccount ca = accountDataService.getCheckingAccount(s); + summaries.add(ca.getSummary()); + + SavingsAccount sa = accountDataService.getSavingsAccount(s); + summaries.add(sa.getSummary()); + + StockAccount sk = accountDataService.getStockAccount(s); + + double balance = 0.0; + for (Map.Entry st : sk.getStocks().entrySet()) { + double price = stockQuoteService.getQuote(st.getKey()); + balance += price * st.getValue(); + } + sk.setBalance(balance); + summaries.add(sk.getSummary()); + + AccountReport report = new AccountReport(currency, summaries); + + return report.toString(); + } + +} diff --git a/sandbox/rfeng/geronimo-demo/bigbank/src/main/java/bigbank/accountdata/Account.java b/sandbox/rfeng/geronimo-demo/bigbank/src/main/java/bigbank/accountdata/Account.java new file mode 100644 index 0000000000..a5ae7b3955 --- /dev/null +++ b/sandbox/rfeng/geronimo-demo/bigbank/src/main/java/bigbank/accountdata/Account.java @@ -0,0 +1,26 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package bigbank.accountdata; + +/** + * Interface for a account service + */ +public interface Account { + String getSummary(); +} diff --git a/sandbox/rfeng/geronimo-demo/bigbank/src/main/java/bigbank/accountdata/AccountDataService.java b/sandbox/rfeng/geronimo-demo/bigbank/src/main/java/bigbank/accountdata/AccountDataService.java new file mode 100644 index 0000000000..c354de387b --- /dev/null +++ b/sandbox/rfeng/geronimo-demo/bigbank/src/main/java/bigbank/accountdata/AccountDataService.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package bigbank.accountdata; + +/** + * Interface for a account data service + */ +public interface AccountDataService { + public CheckingAccount getCheckingAccount(String customerID); + public SavingsAccount getSavingsAccount(String customerID); + public StockAccount getStockAccount(String customerID); +} diff --git a/sandbox/rfeng/geronimo-demo/bigbank/src/main/java/bigbank/accountdata/AccountDataServiceImpl.java b/sandbox/rfeng/geronimo-demo/bigbank/src/main/java/bigbank/accountdata/AccountDataServiceImpl.java new file mode 100644 index 0000000000..fb422a18c4 --- /dev/null +++ b/sandbox/rfeng/geronimo-demo/bigbank/src/main/java/bigbank/accountdata/AccountDataServiceImpl.java @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package bigbank.accountdata; + +import org.osoa.sca.annotations.Reference; + +/** + * Account data service implementation + */ +public class AccountDataServiceImpl implements AccountDataService { + @Reference + public BrokerService brokerService; + + 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"); + java.util.Map list = brokerService.getPortfolio(customerID); + stockAccount.getStocks().putAll(list); + + return stockAccount; + } +} diff --git a/sandbox/rfeng/geronimo-demo/bigbank/src/main/java/bigbank/accountdata/BrokerService.java b/sandbox/rfeng/geronimo-demo/bigbank/src/main/java/bigbank/accountdata/BrokerService.java new file mode 100644 index 0000000000..321e090f8d --- /dev/null +++ b/sandbox/rfeng/geronimo-demo/bigbank/src/main/java/bigbank/accountdata/BrokerService.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package bigbank.accountdata; + +import java.util.Map; + +import org.osoa.sca.annotations.Remotable; + +/** + * Interface for a account data service + */ +@Remotable +public interface BrokerService { + /** + * @param customerID + * @return A map of stocks (key: symbol, value: qty) + */ + public Map getPortfolio(String customerID); +} diff --git a/sandbox/rfeng/geronimo-demo/bigbank/src/main/java/bigbank/accountdata/CheckingAccount.java b/sandbox/rfeng/geronimo-demo/bigbank/src/main/java/bigbank/accountdata/CheckingAccount.java new file mode 100644 index 0000000000..11bdff757e --- /dev/null +++ b/sandbox/rfeng/geronimo-demo/bigbank/src/main/java/bigbank/accountdata/CheckingAccount.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package bigbank.accountdata; + +/** + * An account service implementation for a checking account + */ +public class CheckingAccount implements Account { + private String accountNumber; + private double balance; + + public String getAccountNumber() { return accountNumber; } + public void setAccountNumber(String n) { this.accountNumber = n; } + + public double getBalance() { return balance; } + public void setBalance(double b) { this.balance = b; } + + public String getSummary() { return "ID:" + accountNumber + ", balance:" + balance; } +} diff --git a/sandbox/rfeng/geronimo-demo/bigbank/src/main/java/bigbank/accountdata/SavingsAccount.java b/sandbox/rfeng/geronimo-demo/bigbank/src/main/java/bigbank/accountdata/SavingsAccount.java new file mode 100644 index 0000000000..b791024076 --- /dev/null +++ b/sandbox/rfeng/geronimo-demo/bigbank/src/main/java/bigbank/accountdata/SavingsAccount.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package bigbank.accountdata; + +/** + * An account service implementation for a savings account + */ +public class SavingsAccount implements Account { + private String accountNumber; + private double balance; + + public String getAccountNumber() { return accountNumber; } + public void setAccountNumber(String n) { this.accountNumber = n; } + + public double getBalance() { return balance; } + public void setBalance(double b) { this.balance = b; } + + public String getSummary() { return "ID:" + accountNumber + ", balance:" + balance; } +} diff --git a/sandbox/rfeng/geronimo-demo/bigbank/src/main/java/bigbank/accountdata/StockAccount.java b/sandbox/rfeng/geronimo-demo/bigbank/src/main/java/bigbank/accountdata/StockAccount.java new file mode 100644 index 0000000000..57f1682bd8 --- /dev/null +++ b/sandbox/rfeng/geronimo-demo/bigbank/src/main/java/bigbank/accountdata/StockAccount.java @@ -0,0 +1,58 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package bigbank.accountdata; + +import java.util.HashMap; +import java.util.Map; + +/** + * An account service implementation for a stock account + */ +public class StockAccount implements Account { + private String accountNumber; + private Map stocks = new HashMap(); + private double balance; + + public String getAccountNumber() { + return accountNumber; + } + + public void setAccountNumber(String n) { + this.accountNumber = n; + } + + public double getBalance() { + return balance; + } + + public void setBalance(double balance) { + this.balance = balance; + } + + public String getSummary() { + return "ID:" + accountNumber + ", stocks:" + stocks + ", balance:" + balance; + } + + /** + * @return the stocks + */ + public Map getStocks() { + return stocks; + } +} diff --git a/sandbox/rfeng/geronimo-demo/bigbank/src/main/java/bigbank/client/BigBankClient.java b/sandbox/rfeng/geronimo-demo/bigbank/src/main/java/bigbank/client/BigBankClient.java new file mode 100644 index 0000000000..edbf910d37 --- /dev/null +++ b/sandbox/rfeng/geronimo-demo/bigbank/src/main/java/bigbank/client/BigBankClient.java @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package bigbank.client; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +import bigbank.account.AccountService; + +/** + * This client program shows how to create an SCA runtime, start it, + * and locate and invoke a SCA component + */ +public class BigBankClient { + public static void main(String[] args) throws Exception { + + SCADomain scaDomain = SCADomain.newInstance("BigBank.composite"); + + AccountService accountService = scaDomain.getService(AccountService.class, + "AccountServiceComponent"); + + System.out.println("Account summary: " + accountService.getAccountReport("Foo") ); + + scaDomain.close(); + } + +} diff --git a/sandbox/rfeng/geronimo-demo/bigbank/src/main/java/bigbank/stockquote/StockQuoteImpl.java b/sandbox/rfeng/geronimo-demo/bigbank/src/main/java/bigbank/stockquote/StockQuoteImpl.java new file mode 100644 index 0000000000..0512d40b0b --- /dev/null +++ b/sandbox/rfeng/geronimo-demo/bigbank/src/main/java/bigbank/stockquote/StockQuoteImpl.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package bigbank.stockquote; + + +/** + * This class implements the StockQuote service. + */ +public class StockQuoteImpl implements StockQuoteService { + + public double getQuote(String symbol) { + double price = 104.0 + Math.random(); + price = ((int)(price * 100)) / 100.0; + + System.out.println("Getting stock quote for: " + symbol + ", value: "+ price); + + return price; + } + +} diff --git a/sandbox/rfeng/geronimo-demo/bigbank/src/main/java/bigbank/stockquote/StockQuoteService.java b/sandbox/rfeng/geronimo-demo/bigbank/src/main/java/bigbank/stockquote/StockQuoteService.java new file mode 100644 index 0000000000..7961279352 --- /dev/null +++ b/sandbox/rfeng/geronimo-demo/bigbank/src/main/java/bigbank/stockquote/StockQuoteService.java @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package bigbank.stockquote; + +import org.osoa.sca.annotations.Remotable; + + +/** + * This is the business interface of the StockQuote service. + */ +@Remotable +public interface StockQuoteService { + + public double getQuote(String symbol); +} + diff --git a/sandbox/rfeng/geronimo-demo/bigbank/src/main/resources/BigBank.composite b/sandbox/rfeng/geronimo-demo/bigbank/src/main/resources/BigBank.composite new file mode 100644 index 0000000000..0fd97e2103 --- /dev/null +++ b/sandbox/rfeng/geronimo-demo/bigbank/src/main/resources/BigBank.composite @@ -0,0 +1,52 @@ + + + + + + + + + + + + + USD + + + + + + + + + + + + + + + diff --git a/sandbox/rfeng/geronimo-demo/bigbank/src/main/resources/wsdl/account.wsdl b/sandbox/rfeng/geronimo-demo/bigbank/src/main/resources/wsdl/account.wsdl new file mode 100644 index 0000000000..46bbf3d7bd --- /dev/null +++ b/sandbox/rfeng/geronimo-demo/bigbank/src/main/resources/wsdl/account.wsdl @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/rfeng/geronimo-demo/bigbank/src/test/java/bigbank/BigBankTestCase.java b/sandbox/rfeng/geronimo-demo/bigbank/src/test/java/bigbank/BigBankTestCase.java new file mode 100644 index 0000000000..42d780953d --- /dev/null +++ b/sandbox/rfeng/geronimo-demo/bigbank/src/test/java/bigbank/BigBankTestCase.java @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package bigbank; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +import bigbank.account.AccountService; + +/** + * Tests out the big bank service + * + */ +public class BigBankTestCase extends TestCase { + + private SCADomain scaDomain; + AccountService accountService; + + protected void setUp() throws Exception { + scaDomain = SCADomain.newInstance("BigBank.composite"); + accountService = scaDomain.getService(AccountService.class, "AccountServiceComponent"); + } + + protected void tearDown() throws Exception { + scaDomain.close(); + } + + public void test() throws Exception { + System.out.println("Account summary: " + accountService.getAccountReport("Foo") ); + } +} diff --git a/sandbox/rfeng/geronimo-demo/ejbs/ejbModule/META-INF/MANIFEST.MF b/sandbox/rfeng/geronimo-demo/ejbs/ejbModule/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..5e9495128c --- /dev/null +++ b/sandbox/rfeng/geronimo-demo/ejbs/ejbModule/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Class-Path: + diff --git a/sandbox/rfeng/geronimo-demo/ejbs/ejbModule/META-INF/ejb-jar.xml b/sandbox/rfeng/geronimo-demo/ejbs/ejbModule/META-INF/ejb-jar.xml new file mode 100644 index 0000000000..20567491a2 --- /dev/null +++ b/sandbox/rfeng/geronimo-demo/ejbs/ejbModule/META-INF/ejb-jar.xml @@ -0,0 +1,61 @@ + + + + Tuscany Sample EJBs + + + + Broker Service Session Bean + BrokerServiceBean + BrokerServiceBean + bigbank.accountdata.BrokerServiceHome + bigbank.accountdata.BrokerService + bigbank.accountdata.BrokerServiceBean + Stateless + Container + + + Hello Bean + HelloBean + HelloBean + hello.HelloHome + hello.Hello + hello.HelloLocalHome + hello.HelloLocal + hello.HelloBean + Stateless + Container + + + AddService Bean + AddServiceBean + AddServiceBean + calculator.AddServiceHome + calculator.AddService + calculator.AddServiceLocalHome + calculator.AddServiceLocal + calculator.AddServiceBean + Stateless + Container + + + diff --git a/sandbox/rfeng/geronimo-demo/ejbs/ejbModule/META-INF/openejb-jar.xml b/sandbox/rfeng/geronimo-demo/ejbs/ejbModule/META-INF/openejb-jar.xml new file mode 100644 index 0000000000..80e5df1d3c --- /dev/null +++ b/sandbox/rfeng/geronimo-demo/ejbs/ejbModule/META-INF/openejb-jar.xml @@ -0,0 +1,79 @@ + + + + + + org.apache.tuscany.sca.samples + sample-geronimo-ejbs + 1.0-incubating-SNAPSHOT + jar + + + + org.apache.geronimo.configs + j2ee-corba-yoko + car + + + + + + + + BrokerServiceBean + BrokerServiceBean + IdentityTokenNoSecurity + + + HelloBean + HelloBean + IdentityTokenNoSecurity + + + AddServiceBean + AddServiceBean + IdentityTokenNoSecurity + + + + IdentityTokenNoSecurity + + UnprotectedServer + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/rfeng/geronimo-demo/ejbs/ejbModule/bigbank/accountdata/BrokerService.java b/sandbox/rfeng/geronimo-demo/ejbs/ejbModule/bigbank/accountdata/BrokerService.java new file mode 100644 index 0000000000..ca2a1e0304 --- /dev/null +++ b/sandbox/rfeng/geronimo-demo/ejbs/ejbModule/bigbank/accountdata/BrokerService.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package bigbank.accountdata; + +import java.rmi.RemoteException; +import java.util.Map; + +import javax.ejb.EJBObject; + +/** + * Interface for a account data service + */ +public interface BrokerService extends EJBObject { + /** + * @param customerID + * @return A map of stocks (key: symbol, value: qty) + */ + public Map getPortfolio(String customerID) throws RemoteException; +} diff --git a/sandbox/rfeng/geronimo-demo/ejbs/ejbModule/bigbank/accountdata/BrokerServiceBean.java b/sandbox/rfeng/geronimo-demo/ejbs/ejbModule/bigbank/accountdata/BrokerServiceBean.java new file mode 100644 index 0000000000..6d16b05026 --- /dev/null +++ b/sandbox/rfeng/geronimo-demo/ejbs/ejbModule/bigbank/accountdata/BrokerServiceBean.java @@ -0,0 +1,68 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package bigbank.accountdata; + +import java.util.HashMap; +import java.util.Map; + +import javax.ejb.CreateException; +import javax.ejb.SessionBean; +import javax.ejb.SessionContext; + +/** + * Account data service implementation + */ +public class BrokerServiceBean implements SessionBean { + private SessionContext ctx; + + public void ejbCreate() throws CreateException { + // when bean is created + } + + public void ejbActivate() { + // when bean is activated + } + + public void ejbPassivate() { + // when bean is deactivated + } + + public void ejbRemove() { + // when bean is removed + } + + public void setSessionContext(SessionContext ctx) { + this.ctx = ctx; + } + + public void unsetSessionContext() { + this.ctx = null; + } + + public Map getPortfolio(String customerID) { + System.out.println("BrokerServiceBean.getPortfolio(" + customerID + ")..."); + + Map list = new HashMap(); + list.put("IBM", 100); + list.put("MSFT", 50); + + return list; + + } +} diff --git a/sandbox/rfeng/geronimo-demo/ejbs/ejbModule/bigbank/accountdata/BrokerServiceHome.java b/sandbox/rfeng/geronimo-demo/ejbs/ejbModule/bigbank/accountdata/BrokerServiceHome.java new file mode 100644 index 0000000000..92fa8195c4 --- /dev/null +++ b/sandbox/rfeng/geronimo-demo/ejbs/ejbModule/bigbank/accountdata/BrokerServiceHome.java @@ -0,0 +1,14 @@ +// AddServiceHome.java + +package bigbank.accountdata; + +import java.rmi.RemoteException; + +import javax.ejb.CreateException; +import javax.ejb.EJBHome; + +public interface BrokerServiceHome extends EJBHome { + + public BrokerService create() throws CreateException, RemoteException; + +} diff --git a/sandbox/rfeng/geronimo-demo/ejbs/ejbModule/calculator/AddService.java b/sandbox/rfeng/geronimo-demo/ejbs/ejbModule/calculator/AddService.java new file mode 100644 index 0000000000..d42224f1e8 --- /dev/null +++ b/sandbox/rfeng/geronimo-demo/ejbs/ejbModule/calculator/AddService.java @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import java.rmi.RemoteException; + +import javax.ejb.EJBObject; + +public interface AddService extends EJBObject { + public double add(double a, double b) throws RemoteException; +} diff --git a/sandbox/rfeng/geronimo-demo/ejbs/ejbModule/calculator/AddServiceBean.java b/sandbox/rfeng/geronimo-demo/ejbs/ejbModule/calculator/AddServiceBean.java new file mode 100644 index 0000000000..2f070232e5 --- /dev/null +++ b/sandbox/rfeng/geronimo-demo/ejbs/ejbModule/calculator/AddServiceBean.java @@ -0,0 +1,62 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import javax.ejb.CreateException; +import javax.ejb.EJBException; +import javax.ejb.SessionBean; +import javax.ejb.SessionContext; + +public class AddServiceBean implements SessionBean { + + public SessionContext ctx; + + public AddServiceBean() { + // constructor + } + + public void ejbCreate() throws CreateException { + // when bean is created + } + + public void ejbActivate() { + // when bean is activated + } + + public void ejbPassivate() { + // when bean is deactivated + } + + public void ejbRemove() { + // when bean is removed + } + + public void setSessionContext(SessionContext ctx) { + this.ctx = ctx; + } + + public void unsetSessionContext() { + this.ctx = null; + } + + public double add(double a, double b) throws EJBException { + return a + b; + } + +} diff --git a/sandbox/rfeng/geronimo-demo/ejbs/ejbModule/calculator/AddServiceHome.java b/sandbox/rfeng/geronimo-demo/ejbs/ejbModule/calculator/AddServiceHome.java new file mode 100644 index 0000000000..78d09e269b --- /dev/null +++ b/sandbox/rfeng/geronimo-demo/ejbs/ejbModule/calculator/AddServiceHome.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import java.rmi.RemoteException; + +import javax.ejb.CreateException; +import javax.ejb.EJBHome; + +public interface AddServiceHome extends EJBHome { + + public AddService create() throws CreateException, RemoteException; + +} diff --git a/sandbox/rfeng/geronimo-demo/ejbs/ejbModule/calculator/AddServiceLocal.java b/sandbox/rfeng/geronimo-demo/ejbs/ejbModule/calculator/AddServiceLocal.java new file mode 100644 index 0000000000..f3473016cf --- /dev/null +++ b/sandbox/rfeng/geronimo-demo/ejbs/ejbModule/calculator/AddServiceLocal.java @@ -0,0 +1,26 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import javax.ejb.EJBException; +import javax.ejb.EJBLocalObject; + +public interface AddServiceLocal extends EJBLocalObject { + public double add(double a, double b) throws EJBException; +} diff --git a/sandbox/rfeng/geronimo-demo/ejbs/ejbModule/calculator/AddServiceLocalHome.java b/sandbox/rfeng/geronimo-demo/ejbs/ejbModule/calculator/AddServiceLocalHome.java new file mode 100644 index 0000000000..4c53d27e37 --- /dev/null +++ b/sandbox/rfeng/geronimo-demo/ejbs/ejbModule/calculator/AddServiceLocalHome.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import javax.ejb.CreateException; +import javax.ejb.EJBException; +import javax.ejb.EJBLocalHome; + +public interface AddServiceLocalHome extends EJBLocalHome { + + public AddServiceLocal create() throws CreateException, EJBException; + +} diff --git a/sandbox/rfeng/geronimo-demo/ejbs/ejbModule/hello/Hello.java b/sandbox/rfeng/geronimo-demo/ejbs/ejbModule/hello/Hello.java new file mode 100644 index 0000000000..b4b11b90fe --- /dev/null +++ b/sandbox/rfeng/geronimo-demo/ejbs/ejbModule/hello/Hello.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package hello; + +import java.rmi.RemoteException; + +import javax.ejb.EJBObject; + +public interface Hello extends EJBObject +{ + public String sayHello(String myName) + throws RemoteException; +} diff --git a/sandbox/rfeng/geronimo-demo/ejbs/ejbModule/hello/HelloBean.java b/sandbox/rfeng/geronimo-demo/ejbs/ejbModule/hello/HelloBean.java new file mode 100644 index 0000000000..f3a99cc840 --- /dev/null +++ b/sandbox/rfeng/geronimo-demo/ejbs/ejbModule/hello/HelloBean.java @@ -0,0 +1,73 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package hello; + +import javax.ejb.CreateException; +import javax.ejb.EJBException; +import javax.ejb.SessionBean; +import javax.ejb.SessionContext; + +public class HelloBean implements SessionBean +{ + + public SessionContext ctx; + + public HelloBean() + { + // constructor + } + + public void ejbCreate() + throws CreateException + { + // when bean is created + } + + public void ejbActivate() + { + // when bean is activated + } + + public void ejbPassivate() + { + // when bean is deactivated + } + + public void ejbRemove() + { + // when bean is removed + } + + public void setSessionContext(SessionContext ctx) + { + this.ctx = ctx; + } + + public void unsetSessionContext() + { + this.ctx = null; + } + + + public String sayHello(String myName) throws EJBException + { + return ("Hello " + myName); + } + +} diff --git a/sandbox/rfeng/geronimo-demo/ejbs/ejbModule/hello/HelloHome.java b/sandbox/rfeng/geronimo-demo/ejbs/ejbModule/hello/HelloHome.java new file mode 100644 index 0000000000..51b397f7d3 --- /dev/null +++ b/sandbox/rfeng/geronimo-demo/ejbs/ejbModule/hello/HelloHome.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package hello; + +import java.rmi.RemoteException; + +import javax.ejb.CreateException; +import javax.ejb.EJBHome; + +public interface HelloHome extends EJBHome { + + public Hello create() throws CreateException, RemoteException; + +} diff --git a/sandbox/rfeng/geronimo-demo/ejbs/ejbModule/hello/HelloLocal.java b/sandbox/rfeng/geronimo-demo/ejbs/ejbModule/hello/HelloLocal.java new file mode 100644 index 0000000000..c6121de273 --- /dev/null +++ b/sandbox/rfeng/geronimo-demo/ejbs/ejbModule/hello/HelloLocal.java @@ -0,0 +1,26 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package hello; + +import javax.ejb.EJBException; +import javax.ejb.EJBLocalObject; + +public interface HelloLocal extends EJBLocalObject { + public String sayHello(String myName) throws EJBException; +} diff --git a/sandbox/rfeng/geronimo-demo/ejbs/ejbModule/hello/HelloLocalHome.java b/sandbox/rfeng/geronimo-demo/ejbs/ejbModule/hello/HelloLocalHome.java new file mode 100644 index 0000000000..f34734de10 --- /dev/null +++ b/sandbox/rfeng/geronimo-demo/ejbs/ejbModule/hello/HelloLocalHome.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package hello; + +import javax.ejb.CreateException; +import javax.ejb.EJBException; +import javax.ejb.EJBLocalHome; + +public interface HelloLocalHome extends EJBLocalHome { + + public HelloLocal create() throws CreateException, EJBException; + +} diff --git a/sandbox/rfeng/geronimo-demo/scenario.doc b/sandbox/rfeng/geronimo-demo/scenario.doc new file mode 100644 index 0000000000..55a7b6b27e Binary files /dev/null and b/sandbox/rfeng/geronimo-demo/scenario.doc differ diff --git a/sandbox/rfeng/geronimo-demo/scenario.png b/sandbox/rfeng/geronimo-demo/scenario.png new file mode 100644 index 0000000000..e212b9f759 Binary files /dev/null and b/sandbox/rfeng/geronimo-demo/scenario.png differ diff --git a/sandbox/rfeng/geronimo-demo/webs/WebContent/META-INF/MANIFEST.MF b/sandbox/rfeng/geronimo-demo/webs/WebContent/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..58630c02ef --- /dev/null +++ b/sandbox/rfeng/geronimo-demo/webs/WebContent/META-INF/MANIFEST.MF @@ -0,0 +1,2 @@ +Manifest-Version: 1.0 + diff --git a/sandbox/rfeng/geronimo-demo/webs/WebContent/WEB-INF/geronimo-web.xml b/sandbox/rfeng/geronimo-demo/webs/WebContent/WEB-INF/geronimo-web.xml new file mode 100644 index 0000000000..215f8e759d --- /dev/null +++ b/sandbox/rfeng/geronimo-demo/webs/WebContent/WEB-INF/geronimo-web.xml @@ -0,0 +1,21 @@ + + + + + org.apache.tuscany.samples + sample-geronimo-webs + 1.0-incubating-SNAPSHOT + war + + + + org.apache.geronimo.configs + geronimo-tuscany-plugin + 1.0-incubating-SNAPSHOT + car + + + + + + \ No newline at end of file diff --git a/sandbox/rfeng/geronimo-demo/webs/WebContent/WEB-INF/web.xml b/sandbox/rfeng/geronimo-demo/webs/WebContent/WEB-INF/web.xml new file mode 100644 index 0000000000..8e2ae22d9c --- /dev/null +++ b/sandbox/rfeng/geronimo-demo/webs/WebContent/WEB-INF/web.xml @@ -0,0 +1,33 @@ + + + + + + + Tuscany BigBank Service Sample + + + index.jsp + + + + + diff --git a/sandbox/rfeng/geronimo-demo/webs/WebContent/index.jsp b/sandbox/rfeng/geronimo-demo/webs/WebContent/index.jsp new file mode 100644 index 0000000000..2748718ffe --- /dev/null +++ b/sandbox/rfeng/geronimo-demo/webs/WebContent/index.jsp @@ -0,0 +1,58 @@ +<%-- + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +--%> + +<%@ page import="org.apache.tuscany.sca.host.embedded.SCADomain"%> +<%@ page import="bigbank.accountdata.AccountService"%> +<%@page import="java.util.Date"%> + +<%@ page contentType="text/html;charset=UTF-8" language="java"%> +<% +try { +%> +<% + org.apache.geronimo.kernel.Kernel kernel = org.apache.geronimo.kernel.KernelRegistry.getSingleKernel(); + SCADomain domain = + ((org.apache.geronimo.tuscany.EmbeddedSCADomainGBean)kernel + .getGBean(org.apache.geronimo.tuscany.EmbeddedSCADomainGBean.class)).getScaDomain(); + AccountService accountService = domain.getService(AccountService.class, "AccountServiceComponent"); +%> + + +BigBank Sample + + + + + + + + + + + + + +
DateAccount Report
<%=new Date()%><%=accountService.getAccountReport("foo")%>
+ + +<% + } catch (Throwable e) { + e.printStackTrace(); + } +%> diff --git a/sandbox/rfeng/geronimo-demo/webs/src/bigbank/accountdata/AccountService.java b/sandbox/rfeng/geronimo-demo/webs/src/bigbank/accountdata/AccountService.java new file mode 100644 index 0000000000..617d829c42 --- /dev/null +++ b/sandbox/rfeng/geronimo-demo/webs/src/bigbank/accountdata/AccountService.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package bigbank.accountdata; + + +/** + * Interface for a account service + */ +// @Remotable +public interface AccountService { + public String getAccountReport(String customerID); +} diff --git a/sandbox/rfeng/minicore/.checkstyle b/sandbox/rfeng/minicore/.checkstyle new file mode 100644 index 0000000000..3e57539570 --- /dev/null +++ b/sandbox/rfeng/minicore/.checkstyle @@ -0,0 +1,24 @@ + + + + + + + diff --git a/sandbox/rfeng/minicore/.pmd b/sandbox/rfeng/minicore/.pmd new file mode 100644 index 0000000000..ffc4fe2bbb --- /dev/null +++ b/sandbox/rfeng/minicore/.pmd @@ -0,0 +1,20 @@ + + +true diff --git a/sandbox/rfeng/minicore/.ruleset b/sandbox/rfeng/minicore/.ruleset new file mode 100644 index 0000000000..ba9b5ce886 --- /dev/null +++ b/sandbox/rfeng/minicore/.ruleset @@ -0,0 +1,190 @@ + + + + PMD Plugin preferences rule set + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/rfeng/minicore/LICENSE.txt b/sandbox/rfeng/minicore/LICENSE.txt new file mode 100644 index 0000000000..0084319535 --- /dev/null +++ b/sandbox/rfeng/minicore/LICENSE.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, serviceDefinition marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/sandbox/rfeng/minicore/NOTICE.txt b/sandbox/rfeng/minicore/NOTICE.txt new file mode 100644 index 0000000000..d83ebbe236 --- /dev/null +++ b/sandbox/rfeng/minicore/NOTICE.txt @@ -0,0 +1,14 @@ +${pom.name} +Copyright (c) 2005 - 2006 The Apache Software Foundation + +Apache Tuscany is an effort undergoing incubation at The Apache Software +Foundation (ASF), sponsored by the Apache Web Services PMC. Incubation is +required of all newly accepted projects until a further review indicates that +the infrastructure, communications, and decision making process have stabilized +in a manner consistent with other successful ASF projects. While incubation +status is not necessarily a reflection of the completeness or stability of the +code, it does indicate that the project has yet to be fully endorsed by the ASF. + +This product includes software developed by +The Apache Software Foundation (http://www.apache.org/). + diff --git a/sandbox/rfeng/minicore/pom.xml b/sandbox/rfeng/minicore/pom.xml new file mode 100644 index 0000000000..eb0895a4b8 --- /dev/null +++ b/sandbox/rfeng/minicore/pom.xml @@ -0,0 +1,74 @@ + + + + + org.apache.tuscany.sca + kernel + 2.0-alpha2-incubating-SNAPSHOT + + 4.0.0 + org.apache.tuscany.sca.kernel + tuscany-minicore + jar + Apache Tuscany SCA Core + Core Tuscany runtime. + + + + org.apache.tuscany.sca.kernel + tuscany-spi + ${project.version} + compile + + + + org.codehaus.woodstox + wstx-asl + + + + junit + junit + + + + org.easymock + easymockclassextension + + + + + + + src/main/resources + true + + + ${notice.dir} + META-INF + true + + LICENSE.txt + NOTICE.txt + + + + + diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/AbstractLocalTargetInvoker.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/AbstractLocalTargetInvoker.java new file mode 100644 index 0000000000..4a06bc8c74 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/AbstractLocalTargetInvoker.java @@ -0,0 +1,78 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.binding.local; + +import java.lang.reflect.InvocationTargetException; + +import org.apache.tuscany.spi.wire.Interceptor; +import org.apache.tuscany.spi.wire.InvocationChain; +import org.apache.tuscany.spi.wire.InvocationRuntimeException; +import org.apache.tuscany.spi.wire.Message; +import org.apache.tuscany.spi.wire.TargetInvoker; +import org.apache.tuscany.spi.component.WorkContext; + +/** + * Base class for dispatching to a composite reference using the local binding + * + * @version $Rev$ $Date$ + */ +public abstract class AbstractLocalTargetInvoker implements TargetInvoker { + protected boolean cacheable; + + public boolean isCacheable() { + return cacheable; + } + + public void setCacheable(boolean cacheable) { + this.cacheable = cacheable; + } + + public boolean isOptimizable() { + return isCacheable(); // we only need to check if the scopes are correct + } + + public Object invokeTarget(final Object payload, short sequence, WorkContext workContext) throws InvocationTargetException { + throw new InvocationTargetException(new UnsupportedOperationException()); + } + + protected Message invoke(InvocationChain chain, TargetInvoker invoker, Message msg) throws Throwable { + Interceptor headInterceptor = chain.getHeadInterceptor(); + if (headInterceptor == null) { + try { + // short-circuit the dispatch and invoke the target directly + if (invoker == null) { + String name = chain.getOperation().getName(); + throw new AssertionError("No target invoker [" + name + "]"); + } + return invoker.invoke(msg); + } catch (InvocationRuntimeException e) { + // the cause was thrown by the target so throw it + throw e.getCause(); + } + } else { + msg.setTargetInvoker(invoker); + return headInterceptor.invoke(msg); + } + } + + @Override + public AbstractLocalTargetInvoker clone() throws CloneNotSupportedException { + return (AbstractLocalTargetInvoker) super.clone(); + } +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/LocalBindingBuilder.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/LocalBindingBuilder.java new file mode 100644 index 0000000000..63a9147b29 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/LocalBindingBuilder.java @@ -0,0 +1,52 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.binding.local; + +import org.apache.tuscany.spi.builder.BuilderException; +import org.apache.tuscany.spi.component.ReferenceBinding; +import org.apache.tuscany.spi.component.ServiceBinding; +import org.apache.tuscany.spi.deployer.DeploymentContext; +import org.apache.tuscany.spi.extension.BindingBuilderExtension; +import org.apache.tuscany.spi.model.ReferenceDefinition; +import org.apache.tuscany.spi.model.ServiceDefinition; + +/** + * Creates runtime artifacts for the local binding + * + * @version $Rev$ $Date$ + */ +public class LocalBindingBuilder extends BindingBuilderExtension { + + protected Class getBindingType() { + return LocalBindingDefinition.class; + } + + public ServiceBinding build(ServiceDefinition serviceDefinition, + LocalBindingDefinition bindingDefinition, + DeploymentContext context) throws BuilderException { + return new LocalServiceBinding(serviceDefinition.getUri()); + } + + + public ReferenceBinding build(ReferenceDefinition referenceDefinition, + LocalBindingDefinition bindingDefinition, + DeploymentContext context) throws BuilderException { + return new LocalReferenceBinding(referenceDefinition.getUri(), bindingDefinition.getTargetUri()); + } +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/LocalBindingDefinition.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/LocalBindingDefinition.java new file mode 100644 index 0000000000..9317a47457 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/LocalBindingDefinition.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.binding.local; + +import java.net.URI; + +import org.apache.tuscany.spi.model.BindingDefinition; + + +/** + * Represents the local by-reference binding + * + * @version $Rev$ $Date$ + */ +public class LocalBindingDefinition extends BindingDefinition { + + public LocalBindingDefinition() { + } + + public LocalBindingDefinition(URI targetUri) { + super(targetUri); + } +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/LocalBindingLoader.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/LocalBindingLoader.java new file mode 100644 index 0000000000..3442f1ca4c --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/LocalBindingLoader.java @@ -0,0 +1,70 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.binding.local; + +import java.net.URI; +import java.net.URISyntaxException; +import javax.xml.namespace.QName; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; + +import org.osoa.sca.annotations.Reference; + +import org.apache.tuscany.spi.deployer.DeploymentContext; +import org.apache.tuscany.spi.extension.LoaderExtension; +import org.apache.tuscany.spi.loader.LoaderException; +import org.apache.tuscany.spi.loader.LoaderRegistry; +import org.apache.tuscany.spi.model.ModelObject; +import org.apache.tuscany.spi.wire.Wire; + +/** + * Loader responsible for handling the local binding + * + * @version $Rev$ $Date$ + */ +public class LocalBindingLoader extends LoaderExtension { + + /** + * Constructor specifies the registry to register with. + * + * @param registry the LoaderRegistry this loader should register with + */ + public LocalBindingLoader(@Reference LoaderRegistry registry) { + super(registry); + } + + public QName getXMLType() { + return Wire.LOCAL_BINDING; + } + + public LocalBindingDefinition load( + ModelObject object, + XMLStreamReader reader, + DeploymentContext deploymentContext) throws XMLStreamException, LoaderException { + String uri = reader.getAttributeValue(null, "uri"); + if (uri != null) { + try { + return new LocalBindingDefinition(new URI(uri)); + } catch (URISyntaxException e) { + throw new LoaderException(e); + } + } + return new LocalBindingDefinition(); + } +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/LocalCallbackTargetInvoker.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/LocalCallbackTargetInvoker.java new file mode 100644 index 0000000000..c505ee99ab --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/LocalCallbackTargetInvoker.java @@ -0,0 +1,69 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.binding.local; + +import java.util.Map; + +import org.apache.tuscany.spi.model.Operation; +import org.apache.tuscany.spi.wire.InvocationChain; +import org.apache.tuscany.spi.wire.InvocationRuntimeException; +import org.apache.tuscany.spi.wire.Message; +import org.apache.tuscany.spi.wire.MessageImpl; +import org.apache.tuscany.spi.wire.TargetInvoker; +import org.apache.tuscany.spi.wire.Wire; + +/** + * Dispatches a callback invocation to the callback instance + * + * @version $Rev$ $Date$ + */ +public class LocalCallbackTargetInvoker extends AbstractLocalTargetInvoker { + private Operation operation; + private Wire wire; + + public LocalCallbackTargetInvoker(Operation operation, Wire wire) { + assert operation != null : "Operation method cannot be null"; + this.operation = operation; + this.wire = wire; + } + + public Message invoke(Message msg) throws InvocationRuntimeException { + try { + return invoke(operation, msg); + } catch (Throwable e) { + Message faultMsg = new MessageImpl(); + faultMsg.setBodyWithFault(e); + return faultMsg; + } + } + + private Message invoke(Operation operation, Message msg) throws Throwable { + //TODO optimize as this is slow in local invocations + Map, InvocationChain> chains = wire.getCallbackInvocationChains(); + InvocationChain chain = chains.get(operation); + TargetInvoker invoker = chain.getTargetInvoker(); + return invoke(chain, invoker, msg); + } + + @Override + public LocalCallbackTargetInvoker clone() throws CloneNotSupportedException { + return (LocalCallbackTargetInvoker) super.clone(); + } + +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/LocalReferenceBinding.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/LocalReferenceBinding.java new file mode 100644 index 0000000000..b70df0e23a --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/LocalReferenceBinding.java @@ -0,0 +1,62 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.binding.local; + +import java.net.URI; +import javax.xml.namespace.QName; + +import org.apache.tuscany.spi.CoreRuntimeException; +import org.apache.tuscany.spi.component.TargetInvokerCreationException; +import org.apache.tuscany.spi.extension.ReferenceBindingExtension; +import org.apache.tuscany.spi.model.Operation; +import org.apache.tuscany.spi.model.physical.PhysicalOperationDefinition; +import org.apache.tuscany.spi.wire.TargetInvoker; +import org.apache.tuscany.spi.wire.Wire; + +/** + * The runtime representaion of the local reference binding + * + * @version $Rev$ $Date$ + * @Deprecated + */ +public class LocalReferenceBinding extends ReferenceBindingExtension { + + public LocalReferenceBinding(URI name, URI targetUri) throws CoreRuntimeException { + super(name, targetUri); + } + + public QName getBindingType() { + return Wire.LOCAL_BINDING; + } + + public TargetInvoker createTargetInvoker(String name, Operation operation) + throws TargetInvokerCreationException { + if (operation.isCallback()) { + return new LocalCallbackTargetInvoker(operation, wire); + } else { + return new LocalTargetInvoker(operation, wire); + } + } + + public TargetInvoker createTargetInvoker(String targetName, PhysicalOperationDefinition operation) + throws TargetInvokerCreationException { + return null; + } + +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/LocalServiceBinding.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/LocalServiceBinding.java new file mode 100644 index 0000000000..543a0f53b4 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/LocalServiceBinding.java @@ -0,0 +1,60 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.binding.local; + +import java.net.URI; +import javax.xml.namespace.QName; + +import org.apache.tuscany.spi.CoreRuntimeException; +import org.apache.tuscany.spi.component.TargetInvokerCreationException; +import org.apache.tuscany.spi.extension.ServiceBindingExtension; +import org.apache.tuscany.spi.model.Operation; +import org.apache.tuscany.spi.model.physical.PhysicalOperationDefinition; +import org.apache.tuscany.spi.wire.TargetInvoker; +import org.apache.tuscany.spi.wire.Wire; + +/** + * The runtime representaion of the local service binding + * + * @version $Rev$ $Date$ + */ +public class LocalServiceBinding extends ServiceBindingExtension { + + public LocalServiceBinding(URI name) throws CoreRuntimeException { + super(name); + } + + public QName getBindingType() { + return Wire.LOCAL_BINDING; + } + + public TargetInvoker createTargetInvoker(String name, Operation operation) + throws TargetInvokerCreationException { + if (operation.isCallback()) { + return new LocalCallbackTargetInvoker(operation, getWire()); + } else { + return new LocalTargetInvoker(operation, getWire()); + } + } + + public TargetInvoker createTargetInvoker(String targetName, PhysicalOperationDefinition operation) + throws TargetInvokerCreationException { + return null; + } +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/LocalTargetInvoker.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/LocalTargetInvoker.java new file mode 100644 index 0000000000..b89a70a9e0 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/LocalTargetInvoker.java @@ -0,0 +1,79 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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.binding.local; + +import java.net.URI; + +import org.apache.tuscany.spi.model.Operation; +import org.apache.tuscany.spi.util.UriHelper; +import org.apache.tuscany.spi.wire.InvocationChain; +import org.apache.tuscany.spi.wire.InvocationRuntimeException; +import org.apache.tuscany.spi.wire.Message; +import org.apache.tuscany.spi.wire.MessageImpl; +import org.apache.tuscany.spi.wire.TargetInvoker; +import org.apache.tuscany.spi.wire.Wire; + +/** + * Dispatches an invocation through a composite service or reference using the local binding + * + * @version $Rev$ $Date$ + */ +public class LocalTargetInvoker extends AbstractLocalTargetInvoker { + private InvocationChain chain; + private URI fromAddress; + private boolean contractHasCallback; + + public LocalTargetInvoker(Operation operation, Wire wire) { + assert operation != null; + chain = wire.getInvocationChains().get(operation); + assert chain != null; + if (wire.getSourceUri() != null) { + fromAddress = URI.create(UriHelper.getBaseName(wire.getSourceUri())); + } + contractHasCallback = !wire.getCallbackInvocationChains().isEmpty(); + } + + @Override + public LocalTargetInvoker clone() throws CloneNotSupportedException { + return (LocalTargetInvoker) super.clone(); + } + + public Message invoke(Message msg) throws InvocationRuntimeException { + try { + TargetInvoker invoker = chain.getTargetInvoker(); + assert invoker != null; + // Pushing the from address only needs to happen in the outbound (forward) direction for callbacks + if (contractHasCallback) { + //JFM do we need this? + msg.pushCallbackUri(fromAddress); + } + + return invoke(chain, invoker, msg); + } catch (Throwable e) { + Message faultMsg = new MessageImpl(); + faultMsg.setBodyWithFault(e); + return faultMsg; + } + } + + + public boolean isOptimizable() { + return true; + } +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/bootstrap/Bootstrapper.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/bootstrap/Bootstrapper.java new file mode 100644 index 0000000000..a52e8e2f83 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/bootstrap/Bootstrapper.java @@ -0,0 +1,75 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.bootstrap; + +import org.apache.tuscany.core.resolver.AutowireResolver; +import org.apache.tuscany.host.MonitorFactory; +import org.apache.tuscany.spi.builder.Connector; +import org.apache.tuscany.spi.component.ComponentManager; +import org.apache.tuscany.spi.component.ScopeRegistry; +import org.apache.tuscany.spi.deployer.Deployer; + +/** + * Interface that abstracts the process used to create a running Tuscany system. Implementation of this may provide + * different mechanisms for creating the primoridal system components used to boot the core to the level where it can + * support end-user applications. + * + * @version $Rev$ $Date$ + */ +public interface Bootstrapper { + /** + * Return the MonitorFactory being used by the implementation to provide monitor interfaces for the primordial + * components. + * + * @return the MonitorFactory being used by the bootstrapper + */ + MonitorFactory getMonitorFactory(); + + /** + * Create a Deployer that can be used to deploy the system definition. This will most likely only support a small + * subset of the available programming model. + * + * @return a new primordial Deployer + */ + Deployer createDeployer(); + + /** + * Create a ScopeRegistry that supports the Scopes supported for primordial components + * + * @return a new primordial ScopeRegistry + */ + ScopeRegistry getScopeRegistry(); + + /** + * Create a Connector that can wire together primordial components. + * + * @return a new primordial Connector + */ + Connector getConnector(); + + /** + * Returns the AutowireResolver that resolves autowire targets + * + * @return the AutowireResolver that resolves autowire targets + */ + AutowireResolver getAutowireResolver(); + + ComponentManager getComponentManager(); + +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/bootstrap/DefaultBootstrapper.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/bootstrap/DefaultBootstrapper.java new file mode 100644 index 0000000000..db6cba72f9 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/bootstrap/DefaultBootstrapper.java @@ -0,0 +1,224 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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.bootstrap; + +import javax.xml.stream.XMLInputFactory; + +import org.apache.tuscany.core.binding.local.LocalBindingBuilder; +import org.apache.tuscany.core.binding.local.LocalBindingDefinition; +import org.apache.tuscany.core.binding.local.LocalBindingLoader; +import org.apache.tuscany.core.builder.BuilderRegistryImpl; +import org.apache.tuscany.core.component.scope.AbstractScopeContainer; +import org.apache.tuscany.core.component.scope.CompositeScopeContainer; +import org.apache.tuscany.core.component.scope.RequestScopeContainer; +import org.apache.tuscany.core.component.scope.ScopeRegistryImpl; +import org.apache.tuscany.core.component.scope.StatelessScopeContainer; +import org.apache.tuscany.core.deployer.DeployerImpl; +import org.apache.tuscany.core.implementation.composite.CompositeBuilder; +import org.apache.tuscany.core.implementation.composite.CompositeComponentTypeLoader; +import org.apache.tuscany.core.implementation.composite.CompositeLoader; +import org.apache.tuscany.core.loader.ComponentLoader; +import org.apache.tuscany.core.loader.ComponentTypeElementLoader; +import org.apache.tuscany.core.loader.IncludeLoader; +import org.apache.tuscany.core.loader.LoaderRegistryImpl; +import org.apache.tuscany.core.loader.PropertyLoader; +import org.apache.tuscany.core.loader.ReferenceLoader; +import org.apache.tuscany.core.loader.ServiceLoader; +import org.apache.tuscany.core.resolver.AutowireResolver; +import org.apache.tuscany.host.MonitorFactory; +import org.apache.tuscany.spi.builder.Builder; +import org.apache.tuscany.spi.builder.Connector; +import org.apache.tuscany.spi.component.ComponentManager; +import org.apache.tuscany.spi.component.ScopeContainerMonitor; +import org.apache.tuscany.spi.component.ScopeRegistry; +import org.apache.tuscany.spi.deployer.Deployer; +import org.apache.tuscany.spi.extension.LoaderExtension; +import org.apache.tuscany.spi.implementation.java.Introspector; +import org.apache.tuscany.spi.loader.Loader; +import org.apache.tuscany.spi.loader.LoaderRegistry; +import org.apache.tuscany.spi.loader.PropertyObjectFactory; +import org.apache.tuscany.spi.model.CompositeImplementation; + +/** + * A default implementation of a Bootstrapper. Please see the documentation on + * the individual methods for how the primordial components are created. + * + * @version $Rev$ $Date$ + */ +public class DefaultBootstrapper implements Bootstrapper { + private final MonitorFactory monitorFactory; + private final XMLInputFactory xmlFactory; + private final ComponentManager componentManager; + private final AutowireResolver resolver; + private final Connector connector; + private final ScopeRegistry scopeRegistry; + + /** + * Create a default bootstrapper. + * + * @param monitorFactory the MonitorFactory to be used to create monitors + * for the primordial components + * @param xmlFactory the XMLInputFactory to be used by the components to + * load XML artifacts + * @param componentManager the component manager for the runtime instance + * @param resolver the autowire resolver for the runtime instance + * @param connector the connector for the runtime instance + */ + public DefaultBootstrapper(MonitorFactory monitorFactory, + XMLInputFactory xmlFactory, + ComponentManager componentManager, + AutowireResolver resolver, + Connector connector) { + this.monitorFactory = monitorFactory; + this.xmlFactory = xmlFactory; + this.componentManager = componentManager; + this.resolver = resolver; + this.connector = connector; + this.scopeRegistry = createScopeRegistry(); + } + + /** + * Returns the MonitorFactory being used by this bootstrapper. + * + * @return the MonitorFactory being used by this bootstrapper + */ + public MonitorFactory getMonitorFactory() { + return monitorFactory; + } + + /** + * Create primordial deployer that can be used to load the system + * definition. + * + * @return the primordial deployer + */ + public Deployer createDeployer() { + ScopeRegistry scopeRegistry = getScopeRegistry(); + Builder builder = createBuilder(scopeRegistry); + Loader loader = createLoader(null, null); + DeployerImpl deployer = new DeployerImpl(xmlFactory, loader, builder, componentManager, resolver, connector); + deployer.setMonitor(getMonitorFactory().getMonitor(ScopeContainerMonitor.class)); + deployer.setScopeRegistry(getScopeRegistry()); + return deployer; + } + + /** + * Create a basic ScopeRegistry containing the ScopeContainers that are + * available to components in the system definition. The implementation + * returned only support COMPOSITE scope. + * + * @return a new ScopeRegistry + */ + private ScopeRegistry createScopeRegistry() { + ScopeRegistry scopeRegistry = new ScopeRegistryImpl(); + ScopeContainerMonitor monitor = monitorFactory.getMonitor(ScopeContainerMonitor.class); + AbstractScopeContainer[] containers = new AbstractScopeContainer[] {new CompositeScopeContainer(monitor), + new StatelessScopeContainer(monitor), + new RequestScopeContainer(monitor), + // new ConversationalScopeContainer(monitor), + // new HttpSessionScopeContainer(monitor) + }; + for (AbstractScopeContainer c : containers) { + c.start(); + scopeRegistry.register(c); + } + + return scopeRegistry; + } + + /** + * Create a new Connector that can be used to wire primordial components + * together. + * + * @return a new Connector + */ + public Connector getConnector() { + return connector; + } + + public AutowireResolver getAutowireResolver() { + return resolver; + } + + /** + * Helper method for registering a loader with the registry. The Loader is + * registered once for the QName returned by its + * {@link LoaderExtension#getXMLType()} method. + * + * @param registry the LoaderRegistry to register with + * @param loader the Loader to register + */ + protected void registerLoader(LoaderRegistry registry, LoaderExtension loader) { + registry.registerLoader(loader.getXMLType(), loader); + } + + public LoaderRegistry createLoader(PropertyObjectFactory propertyFactory, Introspector introspector) { + LoaderRegistryImpl loaderRegistry = new LoaderRegistryImpl(monitorFactory + .getMonitor(LoaderRegistryImpl.Monitor.class)); + + // register element loaders + registerLoader(loaderRegistry, new ComponentLoader(loaderRegistry, propertyFactory)); + registerLoader(loaderRegistry, new ComponentTypeElementLoader(loaderRegistry)); + registerLoader(loaderRegistry, new CompositeLoader(loaderRegistry, null)); + registerLoader(loaderRegistry, new IncludeLoader(loaderRegistry)); + registerLoader(loaderRegistry, new PropertyLoader(loaderRegistry)); + registerLoader(loaderRegistry, new ReferenceLoader(loaderRegistry)); + registerLoader(loaderRegistry, new ServiceLoader(loaderRegistry)); + registerLoader(loaderRegistry, new LocalBindingLoader(loaderRegistry)); + + loaderRegistry.registerLoader(CompositeImplementation.class, new CompositeComponentTypeLoader(loaderRegistry)); + return loaderRegistry; + } + + /** + * Create a Builder that can be used to build the components in the system + * definition. The default implementation only supports implementations from + * the system programming model. + * + * @param scopeRegistry the ScopeRegistry defining the component scopes that + * will be supported + * @return a new Builder + */ + private Builder createBuilder(ScopeRegistry scopeRegistry) { + BuilderRegistryImpl builderRegistry = new BuilderRegistryImpl(scopeRegistry); + CompositeBuilder compositeBuilder = new CompositeBuilder(); + compositeBuilder.setBuilderRegistry(builderRegistry); + compositeBuilder.setScopeRegistry(scopeRegistry); + compositeBuilder.init(); + // builderRegistry.register(CompositeImplementation.class, + // compositeBuilder); + builderRegistry.register(LocalBindingDefinition.class, new LocalBindingBuilder()); + return builderRegistry; + } + + /** + * @return the componentManager + */ + public ComponentManager getComponentManager() { + return componentManager; + } + + /** + * @return the scopeRegistry + */ + public ScopeRegistry getScopeRegistry() { + return scopeRegistry; + } + +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/bootstrap/ExtensionActivator.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/bootstrap/ExtensionActivator.java new file mode 100644 index 0000000000..92f526dd8b --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/bootstrap/ExtensionActivator.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.core.bootstrap; + +import org.apache.tuscany.spi.builder.BuilderRegistry; +import org.apache.tuscany.spi.loader.LoaderRegistry; + +/** + * @version $Rev$ $Date$ + */ +public interface ExtensionActivator { + void start(LoaderRegistry loaderRegistry, BuilderRegistry builderRegistry); + void stop(); +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/BuilderRegistryImpl.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/BuilderRegistryImpl.java new file mode 100644 index 0000000000..33dd2175f9 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/BuilderRegistryImpl.java @@ -0,0 +1,185 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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 java.net.URI; +import java.util.HashMap; +import java.util.Map; + +import org.osoa.sca.annotations.EagerInit; + +import org.apache.tuscany.spi.builder.BindingBuilder; +import org.apache.tuscany.spi.builder.BuilderException; +import org.apache.tuscany.spi.builder.BuilderRegistry; +import org.apache.tuscany.spi.builder.ComponentBuilder; +import org.apache.tuscany.spi.builder.ScopeNotFoundException; +import org.apache.tuscany.spi.component.Component; +import org.apache.tuscany.spi.component.Reference; +import org.apache.tuscany.spi.component.ReferenceBinding; +import org.apache.tuscany.spi.component.ScopeContainer; +import org.apache.tuscany.spi.component.ScopeRegistry; +import org.apache.tuscany.spi.component.Service; +import org.apache.tuscany.spi.component.ServiceBinding; +import org.apache.tuscany.spi.deployer.DeploymentContext; +import org.apache.tuscany.spi.model.BindingDefinition; +import org.apache.tuscany.spi.model.ComponentDefinition; +import org.apache.tuscany.spi.model.ComponentType; +import org.apache.tuscany.spi.model.Implementation; +import org.apache.tuscany.spi.model.ReferenceDefinition; +import org.apache.tuscany.spi.model.Scope; +import org.apache.tuscany.spi.model.ServiceContract; +import org.apache.tuscany.spi.model.ServiceDefinition; + +import org.apache.tuscany.core.binding.local.LocalBindingDefinition; +import org.apache.tuscany.core.implementation.composite.ReferenceImpl; +import org.apache.tuscany.core.implementation.composite.ServiceImpl; + +/** + * The default builder registry in the runtime + * + * @version $Rev$ $Date$ + */ +@EagerInit +public class BuilderRegistryImpl implements BuilderRegistry { + private ScopeRegistry scopeRegistry; + + private final Map>, ComponentBuilder>> componentBuilders = + new HashMap>, ComponentBuilder>>(); + private final Map, BindingBuilder> bindingBuilders = + new HashMap, BindingBuilder>(); + + public BuilderRegistryImpl(@org.osoa.sca.annotations.Reference ScopeRegistry scopeRegistry) { + this.scopeRegistry = scopeRegistry; + } + + public > void register(Class implClass, ComponentBuilder builder) { + componentBuilders.put(implClass, builder); + } + + public > void unregister(Class implClass) { + componentBuilders.remove(implClass); + } + + public void register(Class implClass, BindingBuilder builder) { + bindingBuilders.put(implClass, builder); + } + + @SuppressWarnings("unchecked") + public > Component build( + ComponentDefinition componentDefinition, + DeploymentContext context) throws BuilderException { + Class implClass = componentDefinition.getImplementation().getClass(); + // noinspection SuspiciousMethodCalls + ComponentBuilder componentBuilder = (ComponentBuilder) componentBuilders.get(implClass); + if (componentBuilder == null) { + String name = implClass.getName(); + throw new NoRegisteredBuilderException("No builder registered for implementation", name); + } + Component component = componentBuilder.build(componentDefinition, context); + assert component != null; + component.setDefaultPropertyValues(componentDefinition.getPropertyValues()); + Scope scope = componentDefinition.getImplementation().getComponentType().getImplementationScope(); + if (scope == Scope.SYSTEM || scope == Scope.COMPOSITE) { + component.setScopeContainer(context.getCompositeScope()); + } else { + // Check for conversational contract if conversational scope + if (scope == Scope.CONVERSATION) { + boolean hasConversationalContract = false; + ComponentType componentType = + componentDefinition.getImplementation().getComponentType(); + Map services = componentType.getServices(); + for (ServiceDefinition serviceDef : services.values()) { + ServiceContract contract = serviceDef.getServiceContract(); + if (contract.isConversational()) { + hasConversationalContract = true; + break; + } + } + if (!hasConversationalContract) { + String name = implClass.getName(); + throw new NoConversationalContractException( + "No conversational contract for conversational implementation", name); + } + } + // Now it's ok to set the scope container + ScopeContainer scopeContainer = scopeRegistry.getScopeContainer(scope); + if (scopeContainer == null) { + throw new ScopeNotFoundException(scope.toString()); + } + component.setScopeContainer(scopeContainer); + } + context.getComponents().put(component.getUri(), component); + ComponentType componentType = componentDefinition.getImplementation().getComponentType(); + assert componentType != null : "Component type must be set"; + return component; + } + + @SuppressWarnings({"unchecked"}) + public Service build(ServiceDefinition serviceDefinition, DeploymentContext context) throws BuilderException { + URI uri = serviceDefinition.getUri(); + ServiceContract serviceContract = serviceDefinition.getServiceContract(); + if (serviceDefinition.getBindings().isEmpty()) { + // if no bindings are configured, default to the local binding. + // this should be changed to allow runtime selection + if (serviceDefinition.getBindings().isEmpty()) { + // TODO JFM implement capability for the runtime to choose a binding + serviceDefinition.addBinding(new LocalBindingDefinition()); + } + } + URI targetUri = serviceDefinition.getTarget(); + Service service = new ServiceImpl(uri, serviceContract, targetUri); + for (BindingDefinition definition : serviceDefinition.getBindings()) { + Class bindingClass = definition.getClass(); + // noinspection SuspiciousMethodCalls + BindingBuilder bindingBuilder = bindingBuilders.get(bindingClass); + if (bindingBuilder == null) { + throw new NoRegisteredBuilderException("No builder registered for type", bindingClass.getName()); + } + ServiceBinding binding = bindingBuilder.build(serviceDefinition, definition, context); + service.addServiceBinding(binding); + } + return service; + } + + @SuppressWarnings("unchecked") + public Reference build(ReferenceDefinition referenceDefinition, DeploymentContext context) throws BuilderException { + URI uri = referenceDefinition.getUri(); + ServiceContract contract = referenceDefinition.getServiceContract(); + if (referenceDefinition.getBindings().isEmpty()) { + // if no bindings are configured, default to the local binding. + // this should be changed to allow runtime selection + if (referenceDefinition.getBindings().isEmpty()) { + // TODO JFM implement capability for the runtime to choose a binding + referenceDefinition.addBinding(new LocalBindingDefinition()); + } + } + + Reference reference = new ReferenceImpl(uri, contract); + for (BindingDefinition bindingDefinition : referenceDefinition.getBindings()) { + Class bindingClass = bindingDefinition.getClass(); + // noinspection SuspiciousMethodCalls + BindingBuilder bindingBuilder = bindingBuilders.get(bindingClass); + ReferenceBinding binding = bindingBuilder.build(referenceDefinition, bindingDefinition, context); + reference.addReferenceBinding(binding); + + } + return reference; + } + +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/ComponentNotFoundException.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/ComponentNotFoundException.java new file mode 100644 index 0000000000..a46e038cb9 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/ComponentNotFoundException.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.builder; + +import java.net.URI; + +import org.apache.tuscany.spi.builder.WiringException; + +/** + * Indicates a component was not found during wiring + * + * @version $Rev$ $Date$ + */ +public class ComponentNotFoundException extends WiringException { + + public ComponentNotFoundException(String message, URI name) { + super(message, name, name); + } + +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/ConnectorImpl.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/ConnectorImpl.java new file mode 100644 index 0000000000..6923fb6837 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/ConnectorImpl.java @@ -0,0 +1,385 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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 java.net.URI; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import javax.xml.namespace.QName; + +import org.osoa.sca.annotations.Constructor; + +import org.apache.tuscany.spi.builder.BuilderException; +import org.apache.tuscany.spi.builder.Connector; +import org.apache.tuscany.spi.builder.WiringException; +import org.apache.tuscany.spi.builder.interceptor.InterceptorBuilderRegistry; +import org.apache.tuscany.spi.builder.physical.WireAttacherRegistry; +import org.apache.tuscany.spi.component.AtomicComponent; +import org.apache.tuscany.spi.component.Component; +import org.apache.tuscany.spi.component.ComponentManager; +import org.apache.tuscany.spi.component.Invocable; +import org.apache.tuscany.spi.component.Reference; +import org.apache.tuscany.spi.component.ReferenceBinding; +import org.apache.tuscany.spi.component.Service; +import org.apache.tuscany.spi.component.ServiceBinding; +import org.apache.tuscany.spi.component.TargetInvokerCreationException; +import org.apache.tuscany.spi.component.WorkContext; +import org.apache.tuscany.spi.model.ComponentDefinition; +import org.apache.tuscany.spi.model.ComponentType; +import org.apache.tuscany.spi.model.CompositeComponentType; +import org.apache.tuscany.spi.model.Implementation; +import org.apache.tuscany.spi.model.Operation; +import org.apache.tuscany.spi.model.ReferenceDefinition; +import org.apache.tuscany.spi.model.ReferenceTarget; +import org.apache.tuscany.spi.model.Scope; +import org.apache.tuscany.spi.model.ServiceContract; +import org.apache.tuscany.spi.model.ServiceDefinition; +import org.apache.tuscany.spi.model.physical.PhysicalInterceptorDefinition; +import org.apache.tuscany.spi.model.physical.PhysicalOperationDefinition; +import org.apache.tuscany.spi.model.physical.PhysicalWireDefinition; +import org.apache.tuscany.spi.model.physical.PhysicalWireSourceDefinition; +import org.apache.tuscany.spi.model.physical.PhysicalWireTargetDefinition; +import org.apache.tuscany.spi.services.work.WorkScheduler; +import org.apache.tuscany.spi.util.UriHelper; +import org.apache.tuscany.spi.wire.Interceptor; +import org.apache.tuscany.spi.wire.InvocationChain; +import org.apache.tuscany.spi.wire.Wire; +import org.apache.tuscany.spi.wire.WirePostProcessorRegistry; + +import org.apache.tuscany.core.wire.InvocationChainImpl; +import org.apache.tuscany.core.wire.InvokerInterceptor; +import org.apache.tuscany.core.wire.NonBlockingInterceptor; +import org.apache.tuscany.core.wire.WireImpl; +import org.apache.tuscany.core.wire.WireUtils; + +/** + * The default connector implmentation + * + * @version $$Rev$$ $$Date$$ + */ +public class ConnectorImpl implements Connector { + private WirePostProcessorRegistry postProcessorRegistry; + private ComponentManager componentManager; + private WorkContext workContext; + private WorkScheduler scheduler; + private InterceptorBuilderRegistry interceptorBuilderRegistry; + private WireAttacherRegistry attacherRegistry; + + public ConnectorImpl(ComponentManager componentManager) { + this.componentManager = componentManager; + } + + @Constructor + public ConnectorImpl( + @org.osoa.sca.annotations.Reference InterceptorBuilderRegistry interceptorBuilderRegistry, + @org.osoa.sca.annotations.Reference WireAttacherRegistry attacherRegistry, + @org.osoa.sca.annotations.Reference WirePostProcessorRegistry processorRegistry, + @org.osoa.sca.annotations.Reference ComponentManager componentManager, + @org.osoa.sca.annotations.Reference WorkScheduler scheduler, + @org.osoa.sca.annotations.Reference WorkContext workContext) { + this.attacherRegistry = attacherRegistry; + this.interceptorBuilderRegistry = interceptorBuilderRegistry; + this.postProcessorRegistry = processorRegistry; + this.componentManager = componentManager; + this.scheduler = scheduler; + this.workContext = workContext; + } + + /** + * Note this method will not work yet + *

+ * Wires a source and target component based on a wire defintion + * + * @param definition the wire definition + * @throws WiringException + */ + public void connect(PhysicalWireDefinition definition) throws BuilderException { + URI sourceUri = definition.getSourceUri(); + assert sourceUri != null; + URI targetUri = definition.getTargetUri(); + assert targetUri != null; + URI baseSourceUri = UriHelper.getDefragmentedName(sourceUri); + URI baseTargetUri = UriHelper.getDefragmentedName(targetUri); + Component source = componentManager.getComponent(baseSourceUri); + if (source == null) { + throw new ComponentNotFoundException("Wire source component not found", baseSourceUri); + } + Wire wire = createWire(definition); + + PhysicalWireSourceDefinition sourceDefinition = definition.getSource(); + PhysicalWireTargetDefinition targetDefinition = definition.getTarget(); + Component target; + if (baseTargetUri != null) { + target = componentManager.getComponent(baseTargetUri); + if (target == null) { + throw new ComponentNotFoundException("Wire target component not found", baseTargetUri); + } + } else { + target = null; + } + attacherRegistry.attachToSource(source, sourceDefinition, target, targetDefinition, wire); + attacherRegistry.attachToTarget(source, sourceDefinition, target, targetDefinition, wire); + } + + public void connect(ComponentDefinition> definition) throws WiringException { + URI sourceUri = definition.getUri(); + Component source = componentManager.getComponent(sourceUri); + if (source == null) { + throw new ComponentNotFoundException("Source not found", sourceUri); + } + ComponentType type = definition.getImplementation().getComponentType(); + if (type instanceof CompositeComponentType) { + CompositeComponentType compositeType = (CompositeComponentType) type; + for (ComponentDefinition> child : compositeType.getComponents().values()) { + connect(child); + } + for (ServiceDefinition child : compositeType.getServices().values()) { + connect(child); + } + for (ReferenceDefinition child : compositeType.getReferences().values()) { + connect(child); + } + } + Map targets = definition.getReferenceTargets(); + for (ReferenceTarget referenceTarget : targets.values()) { + List wires = new ArrayList(); + String refName = referenceTarget.getReferenceName().getFragment(); + ReferenceDefinition refDefinition = type.getReferences().get(refName); + assert refDefinition != null; + List uris = referenceTarget.getTargets(); + for (URI uri : uris) { + URI targetUri = UriHelper.getDefragmentedName(uri); + Component target = componentManager.getComponent(targetUri); + if (target == null && !refDefinition.isRequired()) { + // a non-required reference, just skip + continue; + } + if (target == null) { + throw new ComponentNotFoundException("Target not found", targetUri); + } + String fragment = uri.getFragment(); + URI sourceURI = refDefinition.getUri(); + Wire wire = createWire(sourceURI, uri, refDefinition.getServiceContract(), Wire.LOCAL_BINDING); + try { + attachInvokers(fragment, wire, source, target); + } catch (TargetInvokerCreationException e) { + throw new WireCreationException("Error creating invoker", sourceUri, targetUri, e); + } + if (postProcessorRegistry != null) { + postProcessorRegistry.process(wire); + } + optimize(source, target, wire); + wires.add(wire); + if (!wire.getCallbackInvocationChains().isEmpty()) { + target.attachCallbackWire(wire); + } + } + if (wires.size() > 1) { + // attach as a multiplicity + source.attachWires(wires); + } else if (wires.size() == 1) { + // attach as a single wire + Wire wire = wires.get(0); + source.attachWire(wire); + } + } + } + + /** + * @deprecated + */ + protected void connect(ServiceDefinition definition) throws WiringException { + URI uri = definition.getUri(); + URI sourceUri = UriHelper.getDefragmentedName(uri); + URI targetUri = definition.getTarget(); + URI baseTargetUri = UriHelper.getDefragmentedName(targetUri); + Component source = componentManager.getComponent(sourceUri); + if (source == null) { + throw new ComponentNotFoundException("Source not found", sourceUri); + } + Service service = source.getService(uri.getFragment()); + if (service == null) { + throw new SourceServiceNotFoundException("Service not found on composite", uri); + } + Component target = componentManager.getComponent(baseTargetUri); + if (target == null) { + throw new ComponentNotFoundException("Target not found", sourceUri); + } + ServiceContract contract = definition.getServiceContract(); + // TODO if no binding, do local + for (ServiceBinding binding : service.getServiceBindings()) { + Wire wire = createWire(uri, targetUri, contract, binding.getBindingType()); + binding.setWire(wire); + if (postProcessorRegistry != null) { + postProcessorRegistry.process(wire); + } + try { + attachInvokers(definition.getTarget().getFragment(), wire, binding, target); + } catch (TargetInvokerCreationException e) { + throw new WireCreationException("Error creating invoker", sourceUri, baseTargetUri, e); + } + } + } + + /** + * @deprecated + */ + protected void connect(ReferenceDefinition definition) throws WiringException { + URI uri = definition.getUri(); + URI sourceUri = UriHelper.getDefragmentedName(uri); + Component source = componentManager.getComponent(sourceUri); + if (source == null) { + throw new ComponentNotFoundException("Source not found", sourceUri); + } + Reference reference = source.getReference(uri.getFragment()); + if (reference == null) { + throw new SourceServiceNotFoundException("Reference not found on composite", uri); + } + + for (ReferenceBinding binding : reference.getReferenceBindings()) { + // create wire + if (Wire.LOCAL_BINDING.equals(binding.getBindingType())) { + URI targetUri = binding.getTargetUri(); + ServiceContract contract = binding.getBindingServiceContract(); + QName type = binding.getBindingType(); + Wire wire = createWire(sourceUri, targetUri, contract, type); + binding.setWire(wire); + // wire local bindings to their targets + Component target = componentManager.getComponent(UriHelper.getDefragmentedName(targetUri)); + if (target == null) { + throw new ComponentNotFoundException("Target not found", sourceUri); + } + try { + attachInvokers(targetUri.getFragment(), wire, binding, target); + } catch (TargetInvokerCreationException e) { + throw new WireCreationException("Error creating invoker", sourceUri, targetUri, e); + } + } else { + Wire wire = createWire(sourceUri, null, binding.getBindingServiceContract(), binding.getBindingType()); + if (postProcessorRegistry != null) { + postProcessorRegistry.process(wire); + } + binding.setWire(wire); + } + } + } + + protected Wire createWire(PhysicalWireDefinition definition) throws BuilderException { + URI sourceURI = definition.getSourceUri(); + URI targetUri = definition.getTargetUri(); + Wire wire = new WireImpl(); + wire.setSourceUri(sourceURI); + wire.setTargetUri(targetUri); + for (PhysicalOperationDefinition operation : definition.getOperations()) { + InvocationChain chain = new InvocationChainImpl(operation); + for (PhysicalInterceptorDefinition interceptorDefinition : operation.getInterceptors()) { + Interceptor interceptor = interceptorBuilderRegistry.build(interceptorDefinition); + chain.addInterceptor(interceptor); + } + wire.addInvocationChain(operation, chain); + } + return wire; + } + + protected Wire createWire(URI sourceURI, URI targetUri, ServiceContract contract, QName bindingType) { + Wire wire = new WireImpl(bindingType); + wire.setSourceContract(contract); + wire.setTargetContract(contract); + wire.setSourceUri(sourceURI); + wire.setTargetUri(targetUri); + for (Operation operation : contract.getOperations().values()) { + InvocationChain chain = new InvocationChainImpl(operation); + if (operation.isNonBlocking()) { + chain.addInterceptor(new NonBlockingInterceptor(scheduler, workContext)); + } + chain.addInterceptor(new InvokerInterceptor()); + wire.addInvocationChain(operation, chain); + + } + for (Operation operation : contract.getCallbackOperations().values()) { + InvocationChain chain = new InvocationChainImpl(operation); + if (operation.isNonBlocking()) { + chain.addInterceptor(new NonBlockingInterceptor(scheduler, workContext)); + } + chain.addInterceptor(new InvokerInterceptor()); + wire.addCallbackInvocationChain(operation, chain); + } + return wire; + } + + /** + * @Deprecated + */ + private void attachInvokers(String name, Wire wire, Invocable source, Invocable target) + throws TargetInvokerCreationException { + // TODO section will deleted be replaced when we cut-over to the physical marshallers + for (InvocationChain chain : wire.getInvocationChains().values()) { + chain.setTargetInvoker(target.createTargetInvoker(name, chain.getOperation())); + } + for (InvocationChain chain : wire.getCallbackInvocationChains().values()) { + chain.setTargetInvoker(source.createTargetInvoker(null, chain.getOperation())); + } + } + + /** + * @Deprecated + */ + protected void optimize(Component source, Component target, Wire wire) { + boolean optimizableScopes = isOptimizable(source.getScope(), target.getScope()); + if (optimizableScopes && target.isOptimizable() && WireUtils.isOptimizable(wire)) { + wire.setOptimizable(true); + wire.setTarget((AtomicComponent) target); + } else { + wire.setOptimizable(false); + } + } + + protected boolean isOptimizable(Scope pReferrer, Scope pReferee) { + if (pReferrer == Scope.UNDEFINED + || pReferee == Scope.UNDEFINED + || pReferrer == Scope.CONVERSATION + || pReferee == Scope.CONVERSATION) { + return false; + } + if (pReferee == pReferrer) { + return true; + } else if (pReferrer == Scope.STATELESS) { + return true; + } else if (pReferee == Scope.STATELESS) { + return false; + } else if (pReferrer == Scope.REQUEST && pReferee == Scope.SESSION) { + return true; + } else if (pReferrer == Scope.REQUEST && pReferee == Scope.COMPOSITE) { + return true; + } else if (pReferrer == Scope.REQUEST && pReferee == Scope.SYSTEM) { + return true; + } else if (pReferrer == Scope.SESSION && pReferee == Scope.COMPOSITE) { + return true; + } else if (pReferrer == Scope.SESSION && pReferee == Scope.SYSTEM) { + return true; + } else //noinspection SimplifiableIfStatement + if (pReferrer == Scope.SYSTEM && pReferee == Scope.COMPOSITE) { + // case where a service context points to a composite scoped component + return true; + } else { + return pReferrer == Scope.COMPOSITE && pReferee == Scope.SYSTEM; + } + } +} \ No newline at end of file diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/IllegalCallbackException.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/IllegalCallbackException.java new file mode 100644 index 0000000000..183ccea1b8 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/IllegalCallbackException.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.builder; + +import java.net.URI; + +import org.apache.tuscany.spi.builder.WiringException; + +/** + * Denotes an illegal callback + * + * @version $Rev$ $Date$ + */ +public class IllegalCallbackException extends WiringException { + + public IllegalCallbackException(String message, String identifier, URI sourceUri, URI targetUri) { + super(message, identifier, sourceUri, targetUri); + } + +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/IncompatibleInterfacesException.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/IncompatibleInterfacesException.java new file mode 100644 index 0000000000..1a9c74aa3b --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/IncompatibleInterfacesException.java @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.builder; + +import java.net.URI; + +import org.apache.tuscany.spi.builder.WiringException; + +/** + * Denotes an attempt to wire incompatible interfaces + * + * @version $Rev$ $Date$ + */ +public class IncompatibleInterfacesException extends WiringException { + + public IncompatibleInterfacesException(URI source, URI target) { + super("Incompatible source and target interfaces", source, target); + } + + public IncompatibleInterfacesException(URI source, URI target, Throwable throwable) { + super("Incompatible source and target interfaces", source, target, throwable); + } + +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/InvalidSourceTypeException.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/InvalidSourceTypeException.java new file mode 100644 index 0000000000..d9df445530 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/InvalidSourceTypeException.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.builder; + +import java.net.URI; + +import org.apache.tuscany.spi.builder.WiringException; + +/** + * Denotes an invalid source type for a wire + * + * @version $Rev$ $Date$ + */ +public class InvalidSourceTypeException extends WiringException { + + public InvalidSourceTypeException(String message, URI sourceUri, URI targetUri) { + super(message, sourceUri, targetUri); + } +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/InvalidTargetTypeException.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/InvalidTargetTypeException.java new file mode 100644 index 0000000000..e3c26c75d2 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/InvalidTargetTypeException.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.builder; + +import java.net.URI; + +import org.apache.tuscany.spi.builder.WiringException; + +/** + * Denotes an invalid target service for a wire + * + * @version $Rev$ $Date$ + */ +public class InvalidTargetTypeException extends WiringException { + + public InvalidTargetTypeException(String message, URI sourceUri, URI targetUri) { + super(message, sourceUri, targetUri); + } +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/NoBindingException.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/NoBindingException.java new file mode 100644 index 0000000000..c351013297 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/NoBindingException.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.builder; + +import java.net.URI; + +import org.apache.tuscany.spi.builder.WiringException; + +/** + * Denotes no binding was specified for a wire + * + * @version $Rev$ $Date$ + */ +public class NoBindingException extends WiringException { + + public NoBindingException(String message, URI sourceUri, URI targetUri) { + super(message, sourceUri, targetUri); + } +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/NoCompatibleBindingsException.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/NoCompatibleBindingsException.java new file mode 100644 index 0000000000..3c49767333 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/NoCompatibleBindingsException.java @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.builder; + +import java.net.URI; + +import org.apache.tuscany.spi.builder.WiringException; + +/** + * @version $Rev$ $Date$ + */ +public class NoCompatibleBindingsException extends WiringException { + + public NoCompatibleBindingsException(URI sourceName, URI targetName) { + super("No compatible bindings for source and target", sourceName, targetName); + } + +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/NoConversationalContractException.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/NoConversationalContractException.java new file mode 100644 index 0000000000..71eb9ebd26 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/NoConversationalContractException.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.builder; + +import org.apache.tuscany.spi.builder.BuilderException; + +/** + * Raised when a component has conversational scope but no conversational contract + * + * @version $Rev: 487877 $ $Date: 2006-12-16 15:32:16 -0500 (Sat, 16 Dec 2006) $ + */ +public class NoConversationalContractException extends BuilderException { + + public NoConversationalContractException(String message, String identifier) { + super(message, identifier); + } + + public NoConversationalContractException(String message) { + super(message); + } +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/NoRegisteredBuilderException.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/NoRegisteredBuilderException.java new file mode 100644 index 0000000000..340a20f239 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/NoRegisteredBuilderException.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.builder; + +import org.apache.tuscany.spi.builder.BuilderException; + +/** + * Raised when a builder cannot be found for a SCDL entry type + * + * @version $Rev$ $Date$ + */ +public class NoRegisteredBuilderException extends BuilderException { + + public NoRegisteredBuilderException(String message, String identifier) { + super(message, identifier); + } + + public NoRegisteredBuilderException(String message) { + super(message); + } + +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/SourceServiceNotFoundException.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/SourceServiceNotFoundException.java new file mode 100644 index 0000000000..7d3d49b937 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/SourceServiceNotFoundException.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.builder; + +import java.net.URI; + +import org.apache.tuscany.spi.builder.WiringException; + +/** + * Indicates the source service of a wire was not found + * + * @version $Rev$ $Date$ + */ +public class SourceServiceNotFoundException extends WiringException { + + public SourceServiceNotFoundException(String message, URI sourceName) { + super(message, sourceName, null); + } + +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/TargetServiceNotFoundException.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/TargetServiceNotFoundException.java new file mode 100644 index 0000000000..f22b421aa7 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/TargetServiceNotFoundException.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.builder; + +import java.net.URI; + +import org.apache.tuscany.spi.builder.WiringException; + +/** + * Indicates the target service of a reference was not found + * + * @version $Rev$ $Date$ + */ +public class TargetServiceNotFoundException extends WiringException { + + public TargetServiceNotFoundException(String message, URI sourceName, URI targetName) { + super(message, sourceName, targetName); + } + +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/WireCreationException.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/WireCreationException.java new file mode 100644 index 0000000000..117bb23180 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/WireCreationException.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.builder; + +import java.net.URI; + +import org.apache.tuscany.spi.builder.WiringException; + +/** + * Denotes an error creating a wire + * + * @version $Rev$ $Date$ + */ +public class WireCreationException extends WiringException { + + public WireCreationException(String message, URI sourceUri, Throwable e) { + super(message, sourceUri, null, e); + } + + public WireCreationException(String message, URI sourceUri, URI targetUri, Throwable e) { + super(message, sourceUri, targetUri, e); + } +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/WirePostProcessorRegistryImpl.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/WirePostProcessorRegistryImpl.java new file mode 100644 index 0000000000..6f611956be --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/WirePostProcessorRegistryImpl.java @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.builder; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.tuscany.spi.wire.Wire; +import org.apache.tuscany.spi.wire.WirePostProcessor; +import org.apache.tuscany.spi.wire.WirePostProcessorRegistry; + +/** + * The default implementation of a WirePostProcessor + * + * @version $Rev$ $Date$ + */ +public class WirePostProcessorRegistryImpl implements WirePostProcessorRegistry { + + private final List processors = new ArrayList(); + + public void process(Wire wire) { + for (WirePostProcessor processor : processors) { + processor.process(wire); + } + } + + public void register(WirePostProcessor processor) { + processors.add(processor); + } + + public void unregister(WirePostProcessor processor) { + processors.remove(processor); + } +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/WiringExceptionFormatter.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/WiringExceptionFormatter.java new file mode 100644 index 0000000000..661dc8bfea --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/WiringExceptionFormatter.java @@ -0,0 +1,67 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.builder; + +import java.io.PrintWriter; + +import org.osoa.sca.annotations.Destroy; +import org.osoa.sca.annotations.EagerInit; +import org.osoa.sca.annotations.Reference; + +import org.apache.tuscany.spi.builder.WiringException; + +import org.apache.tuscany.host.monitor.ExceptionFormatter; +import org.apache.tuscany.host.monitor.FormatterRegistry; + +/** + * Formats {@link WiringException}s + * + * @version $Rev$ $Date$ + */ +@EagerInit +public class WiringExceptionFormatter implements ExceptionFormatter { + private FormatterRegistry factory; + + public WiringExceptionFormatter(@Reference FormatterRegistry factory) { + this.factory = factory; + factory.register(this); + } + + public boolean canFormat(Class type) { + return WiringException.class.isAssignableFrom(type); + } + + @Destroy + public void destroy() { + factory.unregister(this); + } + + public PrintWriter write(PrintWriter writer, Throwable exception) { + assert exception instanceof WiringException; + WiringException e = (WiringException) exception; + e.appendBaseMessage(writer); + if (e.getSourceUri() != null) { + writer.write("\nSource : " + e.getSourceUri()); + } + if (e.getTargetUri() != null) { + writer.write("\nTarget : " + e.getTargetUri()); + } + return writer; + } +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/CallableReferenceImpl.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/CallableReferenceImpl.java new file mode 100644 index 0000000000..e674112a89 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/CallableReferenceImpl.java @@ -0,0 +1,60 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.component; + +import org.osoa.sca.CallableReference; +import org.osoa.sca.Conversation; + +import org.apache.tuscany.spi.ObjectFactory; + +/** + * Base class for implementations of service and callback references. + * + * @version $Rev$ $Date$ + * @param the type of the business interface + */ +public abstract class CallableReferenceImpl implements CallableReference { + private final Class businessInterface; + private final ObjectFactory factory; + + protected CallableReferenceImpl(Class businessInterface, ObjectFactory factory) { + this.businessInterface = businessInterface; + this.factory = factory; + } + + public B getService() { + return factory.getInstance(); + } + + public Class getBusinessInterface() { + return businessInterface; + } + + public boolean isConversational() { + return false; + } + + public Conversation getConversation() { + return null; + } + + public Object getCallbackID() { + return null; + } +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/CallbackReferenceImpl.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/CallbackReferenceImpl.java new file mode 100644 index 0000000000..532a8b2bad --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/CallbackReferenceImpl.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.component; + +import org.apache.tuscany.spi.ObjectFactory; + +/** + * Default implementation of a callback reference. + * + * @version $Rev$ $Date$ + * @param the type of the business interface + */ +public class CallbackReferenceImpl extends CallableReferenceImpl { + public CallbackReferenceImpl(Class businessInterface, ObjectFactory factory) { + super(businessInterface, factory); + } +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/ComponentContextImpl.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/ComponentContextImpl.java new file mode 100644 index 0000000000..c8047abdab --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/ComponentContextImpl.java @@ -0,0 +1,97 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.component; + +import org.osoa.sca.CallableReference; +import org.osoa.sca.ComponentContext; +import org.osoa.sca.RequestContext; +import org.osoa.sca.ServiceReference; +import org.osoa.sca.ServiceRuntimeException; + +import org.apache.tuscany.api.TuscanyRuntimeException; +import org.apache.tuscany.spi.ObjectFactory; +import org.apache.tuscany.spi.component.AtomicComponent; +import org.apache.tuscany.spi.component.Component; + +/** + * Implementation of ComponentContext that delegates to a ComponentContextProvider. + * + * @version $Rev$ $Date$ + */ +public class ComponentContextImpl implements ComponentContext { + private final ComponentContextProvider component; + + public ComponentContextImpl(ComponentContextProvider component) { + this.component = component; + } + + public String getURI() { + try { + return component.getUri().toString(); + } catch (TuscanyRuntimeException e) { + throw new ServiceRuntimeException(e.getMessage(), e); + } + } + + public > R cast(B target) throws IllegalArgumentException { + try { + return (R) component.cast(target); + } catch (TuscanyRuntimeException e) { + throw new ServiceRuntimeException(e.getMessage(), e); + } + } + + public B getService(Class businessInterface, String referenceName) { + try { + return component.getService(businessInterface, referenceName); + } catch (TuscanyRuntimeException e) { + throw new ServiceRuntimeException(e.getMessage(), e); + } + } + + public ServiceReference getServiceReference(Class businessInterface, String referenceName) { + try { + return component.getServiceReference(businessInterface, referenceName); + } catch (TuscanyRuntimeException e) { + throw new ServiceRuntimeException(e.getMessage(), e); + } + } + + public B getProperty(Class type, String propertyName) { + try { + return component.getProperty(type, propertyName); + } catch (TuscanyRuntimeException e) { + throw new ServiceRuntimeException(e.getMessage(), e); + } + } + + public ServiceReference createSelfReference(Class businessInterface) { + // FIXME: How to get the ObjectFactory? + ObjectFactory factory = ((AtomicComponent) component).createObjectFactory(); + return new ServiceReferenceImpl(businessInterface, factory); + } + + public ServiceReference createSelfReference(Class businessInterface, String serviceName) { + return null; + } + + public RequestContext getRequestContext() { + return null; + } +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/ComponentContextProvider.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/ComponentContextProvider.java new file mode 100644 index 0000000000..4237d8b09f --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/ComponentContextProvider.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.component; + +import java.net.URI; + +import org.osoa.sca.ComponentContext; +import org.osoa.sca.ServiceReference; +import org.osoa.sca.CallableReference; + +/** + * Interface implemented by Component's that want to expose a ComponentContext. + * + * @version $Rev$ $Date$ + */ +public interface ComponentContextProvider { + ComponentContext getComponentContext(); + + URI getUri(); + + B getService(Class businessInterface, String referenceName); + + ServiceReference getServiceReference(Class businessInterface, String referenceName); + + B getProperty(Class type, String propertyName); + + > R cast(B target); +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/ComponentManagerImpl.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/ComponentManagerImpl.java new file mode 100644 index 0000000000..76958c88ff --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/ComponentManagerImpl.java @@ -0,0 +1,109 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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.component; + +import java.net.URI; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +import org.apache.tuscany.spi.component.AtomicComponent; +import org.apache.tuscany.spi.component.Component; +import org.apache.tuscany.spi.component.ComponentManager; +import org.apache.tuscany.spi.component.DuplicateNameException; +import org.apache.tuscany.spi.component.RegistrationException; +import org.apache.tuscany.spi.event.Event; +import org.apache.tuscany.spi.model.ServiceContract; +import org.apache.tuscany.spi.services.management.TuscanyManagementService; +import org.apache.tuscany.spi.idl.java.JavaServiceContract; + +import org.apache.tuscany.core.resolver.AutowireResolver; + +/** + * Default implementation of the component manager + * + * @version $Rev$ $Date$ + */ +public class ComponentManagerImpl implements ComponentManager { + private TuscanyManagementService managementService; + private AutowireResolver resolver; + private Map components; + + public ComponentManagerImpl() { + components = new ConcurrentHashMap(); + } + + public ComponentManagerImpl(TuscanyManagementService managementService, AutowireResolver resolver) { + this(); + this.managementService = managementService; + this.resolver = resolver; + } + + public synchronized void register(Component component) throws RegistrationException { + URI uri = component.getUri(); + assert uri != null; + assert !uri.toString().endsWith("/"); + if (components.containsKey(uri)) { + throw new DuplicateNameException(uri.toString()); + } + components.put(uri, component); + + if (managementService != null && component instanceof AtomicComponent) { + // FIXME shouldn't it take the canonical name and also not distinguish atomic components? + managementService.registerComponent(component.getUri().toString(), component); + } + } + + public void registerJavaObject(URI uri, JavaServiceContract service, I instance) + throws RegistrationException { + SystemSingletonAtomicComponent component = + new SystemSingletonAtomicComponent(uri, service, instance); + register(component); + if (resolver != null) { + for (ServiceContract contract : component.getServiceContracts()) { + resolver.addHostUri(contract, uri); + } + } + } + + public void registerJavaObject(URI uri, List> services, I instance) + throws RegistrationException { + SystemSingletonAtomicComponent component = + new SystemSingletonAtomicComponent(uri, services, instance); + register(component); + if (resolver != null) { + for (ServiceContract contract : component.getServiceContracts()) { + resolver.addHostUri(contract, uri); + } + } + } + + public synchronized void unregister(Component component) throws RegistrationException { + URI uri = component.getUri(); + components.remove(uri); + } + + public Component getComponent(URI name) { + return components.get(name); + } + + public void onEvent(Event event) { + throw new UnsupportedOperationException(); + } +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/ScopeIdentifier.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/ScopeIdentifier.java new file mode 100644 index 0000000000..35125b85ef --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/ScopeIdentifier.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.component; + +/** + * 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.spi.component.WorkContext + */ +public interface ScopeIdentifier { + + /** + * Returns the scope id for the request. + */ + Object getIdentifier(); +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/ServiceReferenceImpl.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/ServiceReferenceImpl.java new file mode 100644 index 0000000000..4d57d3efe0 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/ServiceReferenceImpl.java @@ -0,0 +1,52 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.component; + +import org.osoa.sca.ServiceReference; + +import org.apache.tuscany.spi.ObjectFactory; + +/** + * Default implementation of a ServiceReference. + * + * @version $Rev$ $Date$ + * @param the type of the business interface + */ +public class ServiceReferenceImpl extends CallableReferenceImpl implements ServiceReference { + public ServiceReferenceImpl(Class businessInterface, ObjectFactory factory) { + super(businessInterface, factory); + } + + public Object getConversationID() { + return null; + } + + public void setConversationID(Object conversationId) throws IllegalStateException { + } + + public void setCallbackID(Object callbackID) { + } + + public Object getCallback() { + return null; + } + + public void setCallback(Object callback) { + } +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/SimpleWorkContext.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/SimpleWorkContext.java new file mode 100644 index 0000000000..7e978f6f35 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/SimpleWorkContext.java @@ -0,0 +1,113 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.component; + +import java.util.Map; +import java.util.HashMap; +import java.util.List; +import java.util.LinkedList; +import java.util.ArrayList; +import java.net.URI; + +import org.apache.tuscany.spi.component.WorkContext; +import org.apache.tuscany.spi.component.AtomicComponent; +import org.apache.tuscany.spi.wire.Wire; + +/** + * A simple WorkContext implementation that provides basic thread-local support + * for storing work context information. The implementation is not + * thread safe. + * + * @version $Rev$ $Date$ + */ +public class SimpleWorkContext implements WorkContext { + private final Map identifiers = new HashMap(); + private final List serviceNameStack = new ArrayList(); + + private LinkedList callbackUris; + private LinkedList callbackWires; + private Object correlationId; + private AtomicComponent currentAtomicComponent; + + public Object getIdentifier(Object type) { + return identifiers.get(type); + } + + public void setIdentifier(Object type, Object identifier) { + identifiers.put(type, identifier); + } + + public void clearIdentifier(Object type) { + identifiers.remove(type); + } + + public void clearIdentifiers() { + identifiers.clear(); + } + + public LinkedList getCallbackUris() { + return callbackUris; + } + + public void setCallbackUris(LinkedList uris) { + this.callbackUris = uris; + } + + public LinkedList getCallbackWires() { + return callbackWires; + } + + public void setCallbackWires(LinkedList wires) { + this.callbackWires = wires; + } + + public Object getCorrelationId() { + return correlationId; + } + + public void setCorrelationId(Object correlationId) { + this.correlationId = correlationId; + } + + public AtomicComponent getCurrentAtomicComponent() { + return currentAtomicComponent; + } + + public void setCurrentAtomicComponent(AtomicComponent currentAtomicComponent) { + this.currentAtomicComponent = currentAtomicComponent; + } + + public String getCurrentServiceName() { + assert !serviceNameStack.isEmpty(); + return serviceNameStack.get(serviceNameStack.size() - 1); + } + + public void pushServiceName(String name) { + serviceNameStack.add(name); + } + + public String popServiceName() { + assert !serviceNameStack.isEmpty(); + return serviceNameStack.remove(serviceNameStack.size() - 1); + } + + public void clearServiceNames() { + serviceNameStack.clear(); + } +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/SystemSingletonAtomicComponent.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/SystemSingletonAtomicComponent.java new file mode 100644 index 0000000000..872853506e --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/SystemSingletonAtomicComponent.java @@ -0,0 +1,138 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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.component; + +import java.net.URI; +import java.util.ArrayList; +import java.util.List; + +import org.apache.tuscany.core.injection.SingletonObjectFactory; +import org.apache.tuscany.spi.ObjectCreationException; +import org.apache.tuscany.spi.ObjectFactory; +import org.apache.tuscany.spi.component.AtomicComponent; +import org.apache.tuscany.spi.component.InstanceWrapper; +import org.apache.tuscany.spi.component.TargetInvokerCreationException; +import org.apache.tuscany.spi.component.TargetResolutionException; +import org.apache.tuscany.spi.extension.AbstractComponentExtension; +import org.apache.tuscany.spi.idl.java.JavaServiceContract; +import org.apache.tuscany.spi.model.Operation; +import org.apache.tuscany.spi.model.Scope; +import org.apache.tuscany.spi.model.ServiceContract; +import org.apache.tuscany.spi.model.physical.PhysicalOperationDefinition; +import org.apache.tuscany.spi.wire.TargetInvoker; +import org.apache.tuscany.spi.wire.Wire; + +/** + * An {@link org.apache.tuscany.spi.component.AtomicComponent} used when registering objects directly into a composite + * + * @version $$Rev$$ $$Date$$ + */ +public class SystemSingletonAtomicComponent extends AbstractComponentExtension + implements AtomicComponent { + private T instance; + private List serviceContracts = new ArrayList(); + + public SystemSingletonAtomicComponent(URI name, JavaServiceContract contract, T instance) { + super(name); + this.instance = instance; + this.serviceContracts.add(contract); + } + + public SystemSingletonAtomicComponent(URI name, List> services, T instance) { + super(name); + this.instance = instance; + for (ServiceContract contract : services) { + serviceContracts.add(contract); + } + } + + public Scope getScope() { + return Scope.COMPOSITE; + } + + public boolean isEagerInit() { + return false; + } + + public int getInitLevel() { + return 0; + } + + public long getMaxIdleTime() { + return -1; + } + + public long getMaxAge() { + return -1; + } + + public T getTargetInstance() throws TargetResolutionException { + return instance; + } + + public Object createInstance() throws ObjectCreationException { + throw new UnsupportedOperationException(); + } + + public void removeInstance() { + throw new UnsupportedOperationException(); + } + + public InstanceWrapper createInstanceWrapper() throws ObjectCreationException { + throw new UnsupportedOperationException(); + } + + public ObjectFactory createObjectFactory() { + return new SingletonObjectFactory(instance); + } + + public boolean isOptimizable() { + return true; + } + + public void attachWire(Wire wire) { + throw new UnsupportedOperationException(); + } + + public void attachWires(List wires) { + throw new UnsupportedOperationException(); + } + + public List getWires(String name) { + throw new UnsupportedOperationException(); + } + + public void attachCallbackWire(Wire wire) { + throw new UnsupportedOperationException(); + } + + public TargetInvoker createTargetInvoker(String targetName, Operation operation) { + return null; + } + + public TargetInvoker createTargetInvoker(String targetName, PhysicalOperationDefinition operation) + throws TargetInvokerCreationException { + return null; + } + + public List getServiceContracts() { + return serviceContracts; + } + +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/WorkContextImpl.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/WorkContextImpl.java new file mode 100644 index 0000000000..3eb6e9d3eb --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/WorkContextImpl.java @@ -0,0 +1,214 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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.component; + +import java.net.URI; +import java.util.ArrayList; +import java.util.IdentityHashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +import org.apache.tuscany.spi.component.AtomicComponent; +import org.apache.tuscany.spi.component.WorkContext; +import org.apache.tuscany.spi.wire.Wire; + +/** + * An implementation of an {@link org.apache.tuscany.spi.component.WorkContext} that handles event-to-thread + * associations using an InheritableThreadLocal + * + * @version $Rev$ $Date$ + */ +public class WorkContextImpl implements WorkContext { + private static final Object CORRELATION_ID = new Object(); + private static final Object CALLBACK_URIS = new Object(); + private static final Object CURRENT_ATOMIC = new Object(); + private static final Object CURRENT_SERVICE_NAMES = new Object(); + private static final Object CALLBACK_WIRES = new Object(); + + // [rfeng] We cannot use InheritableThreadLocal for message ids here since it's shared by parent and children + private ThreadLocal> workContext = new ThreadLocal>(); + + // [rfeng] Session id requires InheritableThreadLocal + private ThreadLocal> inheritableContext = new InheritableThreadLocal>(); + + public WorkContextImpl() { + super(); + } + + public Object getCorrelationId() { + Map map = workContext.get(); + if (map == null) { + return null; + } + return map.get(CORRELATION_ID); + } + + public void setCorrelationId(Object id) { + Map map = getWorkContextMap(); + map.put(CORRELATION_ID, id); + } + + public AtomicComponent getCurrentAtomicComponent() { + Map map = workContext.get(); + if (map == null) { + return null; + } + return (AtomicComponent) map.get(CURRENT_ATOMIC); + } + + public void setCurrentAtomicComponent(AtomicComponent component) { + Map map = getWorkContextMap(); + map.put(CURRENT_ATOMIC, component); + } + + @SuppressWarnings("unchecked") + public LinkedList getCallbackUris() { + Map map = workContext.get(); + if (map == null) { + return null; + } + return (LinkedList) map.get(CALLBACK_URIS); + } + + public void setCallbackUris(LinkedList uris) { + Map map = getWorkContextMap(); + map.put(CALLBACK_URIS, uris); + } + + + @SuppressWarnings({"unchecked"}) + public LinkedList getCallbackWires() { + Map map = workContext.get(); + if (map == null) { + return null; + } + return (LinkedList) map.get(CALLBACK_WIRES); + } + + public void setCallbackWires(LinkedList wires) { + Map map = getWorkContextMap(); + map.put(CALLBACK_WIRES, wires); + } + + + public Object getIdentifier(Object type) { + Map map = inheritableContext.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 = inheritableContext.get(); + if (map == null) { + map = new IdentityHashMap(); + inheritableContext.set(map); + } + map.put(type, identifier); + } + + public void clearIdentifier(Object type) { + if (type == null) { + return; + } + Map map = inheritableContext.get(); + if (map != null) { + map.remove(type); + } + } + + public void clearIdentifiers() { + inheritableContext.remove(); + } + + @SuppressWarnings({"unchecked"}) + public String popServiceName() { + Map map = inheritableContext.get(); + if (map == null) { + return null; + } + List stack = (List) map.get(CURRENT_SERVICE_NAMES); + if (stack == null || stack.size() < 1) { + return null; + } + String name = stack.remove(stack.size() - 1); + if (stack.size() == 0) { + // cleanup to avoid leaks + map.remove(CURRENT_SERVICE_NAMES); + } + return name; + } + + @SuppressWarnings({"unchecked"}) + public String getCurrentServiceName() { + Map map = inheritableContext.get(); + if (map == null) { + return null; + } + List stack = (List) map.get(CURRENT_SERVICE_NAMES); + if (stack == null || stack.size() < 1) { + return null; + } + return stack.get(stack.size() - 1); + } + + @SuppressWarnings({"unchecked"}) + public void pushServiceName(String name) { + Map map = inheritableContext.get(); + List names; + if (map == null) { + map = new IdentityHashMap(); + inheritableContext.set(map); + names = new ArrayList(); + map.put(CURRENT_SERVICE_NAMES, names); + } else { + names = (List) map.get(CURRENT_SERVICE_NAMES); + if (names == null) { + names = new ArrayList(); + map.put(CURRENT_SERVICE_NAMES, names); + } + } + names.add(name); + } + + public void clearServiceNames() { + Map map = inheritableContext.get(); + if (map == null) { + return; + } + map.remove(CURRENT_SERVICE_NAMES); + } + + private Map getWorkContextMap() { + Map map = workContext.get(); + if (map == null) { + map = new IdentityHashMap(); + workContext.set(map); + } + return map; + } +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/AbstractEvent.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/AbstractEvent.java new file mode 100644 index 0000000000..6d026ca08c --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/AbstractEvent.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.component.event; + +import org.apache.tuscany.spi.event.Event; + +/** + * A basic implementation of a runtime event + * + * @version $$Rev$$ $$Date$$ + */ +public abstract class AbstractEvent implements Event { + protected Object source; + + public AbstractEvent(Object source) { + assert source != null : "Source id was null"; + this.source = source; + } + + public Object getSource() { + return source; + } +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/AbstractRequestEvent.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/AbstractRequestEvent.java new file mode 100644 index 0000000000..762b917600 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/AbstractRequestEvent.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.component.event; + +/** + * Base implementation of a request event + * + * @version $$Rev$$ $$Date$$ + */ +public abstract class AbstractRequestEvent extends AbstractEvent implements RequestEvent { + + /** + * Creates a new event + * + * @param source the source of the event + */ + public AbstractRequestEvent(Object source) { + super(source); + } + + +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/ComponentEvent.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/ComponentEvent.java new file mode 100644 index 0000000000..7de32a56d0 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/ComponentEvent.java @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.component.event; + +import java.net.URI; + +import org.apache.tuscany.spi.event.Event; + +/** + * Implemented by runtime events associated with a component, e.g. lifecycle events + * + * @version $$Rev$$ $$Date$$ + */ +public interface ComponentEvent extends Event { + + URI getComponentUri(); + +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/ComponentStart.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/ComponentStart.java new file mode 100644 index 0000000000..6be1c88d3f --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/ComponentStart.java @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.component.event; + +import java.net.URI; + +/** + * Propagated when a component starts + * + * @version $$Rev$$ $$Date$$ + */ +public class ComponentStart extends AbstractEvent implements ComponentEvent { + + private URI uri; + + /** + * Creates a component start event + * + * @param source the source of the event + * @param componentURI the uri of the component being started + */ + public ComponentStart(Object source, URI componentURI) { + super(source); + this.uri = componentURI; + } + + public URI getComponentUri() { + return uri; + } + +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/ComponentStop.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/ComponentStop.java new file mode 100644 index 0000000000..ac0a7fd5c0 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/ComponentStop.java @@ -0,0 +1,46 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.component.event; + +import java.net.URI; + +/** + * Propagated when a component stops + * + * @version $$Rev$$ $$Date$$ + */ +public class ComponentStop extends AbstractEvent implements ComponentEvent { + + private URI uri; + + /** + * Creates a component stop event + * + * @param source the source of the event + * @param componentUri the composite component associated the component being stopped + */ + public ComponentStop(Object source, URI componentUri) { + super(source); + this.uri = componentUri; + } + + public URI getComponentUri() { + return uri; + } +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/ConversationEnd.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/ConversationEnd.java new file mode 100644 index 0000000000..4a51d970c3 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/ConversationEnd.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.component.event; + +/** + * Propagated when a conversation session is expired + * + * @version $$Rev: 430937 $$ $$Date: 2006-08-11 21:17:56 -0400 (Fri, 11 Aug 2006) $$ + */ +public class ConversationEnd extends ConversationalEvent { + + public ConversationEnd(Object source, Object id) { + super(source, id); + } +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/ConversationStart.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/ConversationStart.java new file mode 100644 index 0000000000..5725369bf6 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/ConversationStart.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.component.event; + +/** + * Propagated when a conversation session has started + * + * @version $$Rev: 430937 $$ $$Date: 2006-08-11 21:17:56 -0400 (Fri, 11 Aug 2006) $$ + */ +public class ConversationStart extends ConversationalEvent { + + public ConversationStart(Object source, Object id) { + super(source, id); + } +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/ConversationalEvent.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/ConversationalEvent.java new file mode 100644 index 0000000000..a75086e745 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/ConversationalEvent.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.component.event; + +/** + * A base implementation of conversational session events in the runtime + * + * @version $$Rev: 430937 $$ $$Date: 2006-08-11 21:17:56 -0400 (Fri, 11 Aug 2006) $$ + */ +public class ConversationalEvent extends AbstractEvent { + + private Object id; + + public ConversationalEvent(Object source, Object id) { + super(source); + assert id != null : "Conversation id was null"; + this.id = id; + } + + public Object getId() { + return id; + } +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/HttpRequestEnded.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/HttpRequestEnded.java new file mode 100644 index 0000000000..01bd769031 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/HttpRequestEnded.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.component.event; + +/** + * Propagated when an HTTP-based request has ended. + * + * @version $$Rev: 430937 $$ $$Date: 2006-08-11 21:17:56 -0400 (Fri, 11 Aug 2006) $$ + */ +public class HttpRequestEnded extends HttpSessionEvent { + + /** + * Creates a new event + * + * @param source the source of the event + * @param id the id of the HTTP session being ended + */ + public HttpRequestEnded(Object source, Object id) { + super(source, id); + } + +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/HttpRequestStart.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/HttpRequestStart.java new file mode 100644 index 0000000000..9d0ff80dd7 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/HttpRequestStart.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.component.event; + +/** + * Propagated when an HTTP-based request has started + * + * @version $$Rev: 430937 $$ $$Date: 2006-08-11 21:17:56 -0400 (Fri, 11 Aug 2006) $$ + */ +public class HttpRequestStart extends HttpSessionEvent { + + /** + * Creates a new event + * + * @param source the source of the event + * @param id the id of the HTTP session being ended + */ + public HttpRequestStart(Object source, Object id) { + super(source, id); + } + +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/HttpSessionEnd.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/HttpSessionEnd.java new file mode 100644 index 0000000000..7f2bebe94a --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/HttpSessionEnd.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.component.event; + +/** + * Propagated when an HTTP-based session is expired + * + * @version $$Rev$$ $$Date$$ + */ +public class HttpSessionEnd extends HttpSessionEvent { + + /** + * Creates a new event + * + * @param source the source of the event + * @param id the id of the HTTP session being ended + */ + public HttpSessionEnd(Object source, Object id) { + super(source, id); + } + +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/HttpSessionEvent.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/HttpSessionEvent.java new file mode 100644 index 0000000000..ed245d0930 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/HttpSessionEvent.java @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.component.event; + +/** + * A base implementation of HTTP-based session events in the runtime + * + * @version $$Rev$$ $$Date$$ + */ +public abstract class HttpSessionEvent extends AbstractEvent { + + private Object id; + + public HttpSessionEvent(Object source, Object id) { + super(source); + assert id != null : "Session id was null"; + this.id = id; + } + + + public Object getSource() { + return source; + } + + public Object getId() { + return id; + } + +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/HttpSessionStart.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/HttpSessionStart.java new file mode 100644 index 0000000000..7f9c0fadea --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/HttpSessionStart.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.component.event; + +/** + * Propagated when an HTTP-based session has started + * + * @version $$Rev$$ $$Date$$ + */ +public class HttpSessionStart extends HttpSessionEvent { + + /** + * Creates a new event + * + * @param source the source of the event + * @param id the id of the HTTP session being ended + */ + public HttpSessionStart(Object source, Object id) { + super(source, id); + } + +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/RequestEnd.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/RequestEnd.java new file mode 100644 index 0000000000..25856e86f8 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/RequestEnd.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.component.event; + +/** + * Propagated when a request completes or is ended + * + * @version $$Rev$$ $$Date$$ + */ +public class RequestEnd extends AbstractRequestEvent { + + /** + * Creates a new event + * + * @param source the source of the event + */ + public RequestEnd(Object source) { + super(source); + } + + +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/RequestEvent.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/RequestEvent.java new file mode 100644 index 0000000000..9a6d767236 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/RequestEvent.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.component.event; + +/** + * Implemented by runtime events associated request + * + * @version $$Rev$$ $$Date$$ + */ +public interface RequestEvent { + +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/RequestStart.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/RequestStart.java new file mode 100644 index 0000000000..466f52551a --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/RequestStart.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.component.event; + +/** + * Propagated when a request is started in the runtime + * + * @version $$Rev$$ $$Date$$ + */ +public class RequestStart extends AbstractRequestEvent { + + /** + * Creates a new event + * + * @param source the source of the event + */ + public RequestStart(Object source) { + super(source); + } + +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/scope/AbstractScopeContainer.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/scope/AbstractScopeContainer.java new file mode 100644 index 0000000000..7fa8765426 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/scope/AbstractScopeContainer.java @@ -0,0 +1,265 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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.component.scope; + + +import java.net.URI; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +import org.osoa.sca.annotations.Destroy; +import org.osoa.sca.annotations.Init; +import org.osoa.sca.annotations.Reference; + +import org.apache.tuscany.spi.AbstractLifecycle; +import org.apache.tuscany.spi.component.AtomicComponent; +import org.apache.tuscany.spi.component.GroupInitializationException; +import org.apache.tuscany.spi.component.InstanceWrapper; +import org.apache.tuscany.spi.component.PersistenceException; +import org.apache.tuscany.spi.component.ScopeContainer; +import org.apache.tuscany.spi.component.ScopeContainerMonitor; +import org.apache.tuscany.spi.component.ScopeRegistry; +import org.apache.tuscany.spi.component.TargetDestructionException; +import org.apache.tuscany.spi.component.TargetResolutionException; +import org.apache.tuscany.spi.event.Event; +import org.apache.tuscany.spi.model.Scope; + +/** + * Implements functionality common to scope contexts. + * + * @version $Rev$ $Date$ + */ +public abstract class AbstractScopeContainer extends AbstractLifecycle + implements ScopeContainer { + + private static final Comparator> COMPARATOR = new Comparator>() { + public int compare(AtomicComponent o1, AtomicComponent o2) { + return o1.getInitLevel() - o2.getInitLevel(); + } + }; + + private final Scope scope; + protected final ScopeContainerMonitor monitor; + + protected final Map, URI> componentGroups = + new ConcurrentHashMap, URI>(); + + protected final Map contextGroups = new ConcurrentHashMap(); + + // the queue of components to eagerly initialize in each group + protected final Map>> initQueues = + new HashMap>>(); + + // the queue of instanceWrappers to destroy, in the order that their instances were created + protected final Map>> destroyQueues = + new ConcurrentHashMap>>(); + + public AbstractScopeContainer(Scope scope, ScopeContainerMonitor monitor) { + this.scope = scope; + this.monitor = monitor; + } + + public Scope getScope() { + return scope; + } + + @Reference + public void setScopeRegistry(ScopeRegistry scopeRegistry) { + scopeRegistry.register(this); + } + + @Init + public synchronized void start() { + int lifecycleState = getLifecycleState(); + if (lifecycleState != UNINITIALIZED && lifecycleState != STOPPED) { + throw new IllegalStateException("Scope must be in UNINITIALIZED or STOPPED state [" + lifecycleState + "]"); + } + setLifecycleState(RUNNING); + } + + @Destroy + public synchronized void stop() { + int lifecycleState = getLifecycleState(); + if (lifecycleState != RUNNING) { + throw new IllegalStateException("Scope in wrong state [" + lifecycleState + "]"); + } + setLifecycleState(STOPPED); + componentGroups.clear(); + contextGroups.clear(); + synchronized (initQueues) { + initQueues.clear(); + } + destroyQueues.clear(); + } + + protected void checkInit() { + if (getLifecycleState() != RUNNING) { + throw new IllegalStateException("Scope container not running [" + getLifecycleState() + "]"); + } + } + + public void onEvent(Event event) { + } + + public void register(AtomicComponent component, URI groupId) { + checkInit(); + if (component.isEagerInit()) { + componentGroups.put(component, groupId); + synchronized (initQueues) { + List> initQueue = initQueues.get(groupId); + if (initQueue == null) { + initQueue = new ArrayList>(); + initQueues.put(groupId, initQueue); + } + // FIXME it would be more efficient to binary search and then insert + initQueue.add(component); + Collections.sort(initQueue, COMPARATOR); + } + } + } + + public void unregister(AtomicComponent component) { + if (component.isEagerInit()) { + URI groupId = componentGroups.remove(component); + synchronized (initQueues) { + List> initQueue = initQueues.get(groupId); + initQueue.remove(component); + if (initQueue.isEmpty()) { + initQueues.remove(groupId); + } + } + } + } + + public void startContext(KEY contextId, URI groupId) throws GroupInitializationException { + assert !contextGroups.containsKey(contextId); + contextGroups.put(contextId, groupId); + destroyQueues.put(contextId, new ArrayList>()); + + // get and clone initialization queue + List> initQueue; + synchronized (initQueues) { + initQueue = initQueues.get(groupId); + if (initQueue != null) { + initQueue = new ArrayList>(initQueue); + } + } + if (initQueue != null) { + initializeComponents(contextId, initQueue); + } + } + + public void stopContext(KEY contextId) { + assert contextGroups.containsKey(contextId); + shutdownComponents(destroyQueues.get(contextId)); + contextGroups.remove(contextId); + destroyQueues.remove(contextId); + } + + public InstanceWrapper getWrapper(AtomicComponent component, KEY contextId) + throws TargetResolutionException { + return null; + } + + public InstanceWrapper getAssociatedWrapper(AtomicComponent component, KEY contextId) + throws TargetResolutionException { + return null; + } + + public void returnWrapper(AtomicComponent component, InstanceWrapper wrapper, KEY contextId) + throws TargetDestructionException { + } + + public void remove(AtomicComponent component) throws PersistenceException { + throw new UnsupportedOperationException("Scope does not support persistence"); + } + + /** + * Initialise an ordered list of components. + * The list is traversed in order and the getWrapper() method called for each to + * associate an instance with the supplied context. + * + * @param contextId the contextId to associated with the component instances + * @param components the components to be initialized + * @throws GroupInitializationException if one or more components threw an exception during initialization + */ + protected void initializeComponents(KEY contextId, List> components) + throws GroupInitializationException { + List causes = null; + for (AtomicComponent component : components) { + try { + getWrapper(component, contextId); + + } catch (Exception e) { + if (causes == null) { + causes = new ArrayList(); + } + causes.add(e); + } + } + if (causes != null) { + throw new GroupInitializationException(String.valueOf(contextId), causes); + } + } + + /** + * Shut down an ordered list of instances. + * The list passed to this method is treated as a live, mutable list + * so any instances added to this list as shutdown is occuring will also be shut down. + * + * @param instances the list of instances to shutdown + */ + protected void shutdownComponents(List> instances) { + while (true) { + InstanceWrapper toDestroy; + synchronized (instances) { + if (instances.size() == 0) { + return; + } + toDestroy = instances.remove(instances.size() - 1); + } + try { + toDestroy.stop(); + } catch (TargetDestructionException e) { + // log the error from destroy but continue + monitor.destructionError(e); + } + } + } + + public String toString() { + return "In state [" + super.toString() + ']'; + } + + /** + * Creates a new physical instance of a component, wrapped in an InstanceWrapper. + * + * @param component the component whose instance should be created + * @return a wrapped instance that has been injected but not yet started + * @throws TargetResolutionException if there was a problem creating the instance + */ + protected InstanceWrapper createInstance(AtomicComponent component) throws TargetResolutionException { + return component.createInstanceWrapper(); + } +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/scope/CompositeScopeContainer.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/scope/CompositeScopeContainer.java new file mode 100644 index 0000000000..1a5dbcdcd4 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/scope/CompositeScopeContainer.java @@ -0,0 +1,114 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.component.scope; + +import java.net.URI; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +import org.osoa.sca.annotations.EagerInit; +import org.osoa.sca.annotations.Service; + +import org.apache.tuscany.api.annotation.Monitor; +import org.apache.tuscany.spi.component.AtomicComponent; +import org.apache.tuscany.spi.component.InstanceWrapper; +import org.apache.tuscany.spi.component.ScopeContainerMonitor; +import org.apache.tuscany.spi.component.TargetDestructionException; +import org.apache.tuscany.spi.component.TargetInitializationException; +import org.apache.tuscany.spi.component.TargetNotFoundException; +import org.apache.tuscany.spi.component.TargetResolutionException; +import org.apache.tuscany.spi.component.ScopeContainer; +import org.apache.tuscany.spi.model.Scope; + +/** + * A scope context which manages atomic component instances keyed by composite + * + * @version $Rev$ $Date$ + */ +@EagerInit +@Service(ScopeContainer.class) +public class CompositeScopeContainer extends AbstractScopeContainer { + private static final InstanceWrapper EMPTY = new InstanceWrapper() { + public Object getInstance() { + return null; + } + + public boolean isStarted() { + return true; + } + + public void start() throws TargetInitializationException { + + } + + public void stop() throws TargetDestructionException { + + } + }; + + // there is one instance per component so we can index directly + private final Map, InstanceWrapper> instanceWrappers = + new ConcurrentHashMap, InstanceWrapper>(); + + public CompositeScopeContainer(@Monitor ScopeContainerMonitor monitor) { + super(Scope.COMPOSITE, monitor); + } + + public void register(AtomicComponent component, URI groupId) { + super.register(component, groupId); + instanceWrappers.put(component, EMPTY); + } + + public void unregister(AtomicComponent component) { + // FIXME should this component be destroyed already or do we need to stop it? + instanceWrappers.remove(component); + super.unregister(component); + } + + public synchronized void stop() { + super.stop(); + instanceWrappers.clear(); + } + + public InstanceWrapper getWrapper(AtomicComponent component, KEY contextId) + throws TargetResolutionException { + assert instanceWrappers.containsKey(component); + @SuppressWarnings("unchecked") + InstanceWrapper wrapper = (InstanceWrapper) instanceWrappers.get(component); + if (wrapper == EMPTY) { + // FIXME is there a potential race condition here that may result in two instances being created + wrapper = createInstance(component); + instanceWrappers.put(component, wrapper); + wrapper.start(); + destroyQueues.get(contextId).add(wrapper); + } + return wrapper; + } + + public InstanceWrapper getAssociatedWrapper(AtomicComponent component, KEY contextId) + throws TargetResolutionException { + assert instanceWrappers.containsKey(component); + @SuppressWarnings("unchecked") + InstanceWrapper wrapper = (InstanceWrapper) instanceWrappers.get(component); + if (wrapper == EMPTY) { + throw new TargetNotFoundException(component.getUri().toString()); + } + return wrapper; + } +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainer.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainer.java new file mode 100644 index 0000000000..2d9d3d938c --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainer.java @@ -0,0 +1,190 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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.component.scope; + +import java.net.URI; + +import org.apache.tuscany.spi.component.AtomicComponent; +import org.apache.tuscany.spi.component.InstanceWrapper; +import org.apache.tuscany.spi.component.PersistenceException; +import org.apache.tuscany.spi.component.ScopeContainer; +import org.apache.tuscany.spi.component.ScopeContainerMonitor; +import org.apache.tuscany.spi.component.TargetDestructionException; +import org.apache.tuscany.spi.component.TargetResolutionException; +import org.apache.tuscany.spi.component.WorkContext; +import org.apache.tuscany.spi.event.Event; +import org.apache.tuscany.spi.event.RuntimeEventListener; +import org.apache.tuscany.spi.model.Scope; +import org.apache.tuscany.spi.services.store.Store; +import org.apache.tuscany.spi.services.store.StoreExpirationEvent; +import org.apache.tuscany.spi.services.store.StoreReadException; +import org.apache.tuscany.spi.services.store.StoreWriteException; + +/** + * A scope context which manages atomic component instances keyed on a conversation session + * + * @version $Rev: 452655 $ $Date: 2006-10-03 18:09:02 -0400 (Tue, 03 Oct 2006) $ + */ +public class ConversationalScopeContainer extends AbstractScopeContainer implements ScopeContainer { + private final WorkContext workContext; + private final Store nonDurableStore; + + public ConversationalScopeContainer(Store store, WorkContext workContext, final ScopeContainerMonitor monitor) { + super(Scope.CONVERSATION, monitor); + this.workContext = workContext; + this.nonDurableStore = store; + if (store != null) { + store.addListener(new ExpirationListener(monitor)); + } + } + + public void onEvent(Event event) { + checkInit(); + } + + public synchronized void start() { + if (lifecycleState != UNINITIALIZED && lifecycleState != STOPPED) { + throw new IllegalStateException("Scope must be in UNINITIALIZED or STOPPED state [" + lifecycleState + "]"); + } + lifecycleState = RUNNING; + } + + public synchronized void stop() { + lifecycleState = STOPPED; + } + + public void register(AtomicComponent component, URI groupId) { + super.register(component, groupId); + component.addListener(this); + } + + public void unregister(AtomicComponent component) { + // FIXME should all the instances associated with this component be remove already + component.removeListener(this); + super.unregister(component); + } + + public void persistNew(AtomicComponent component, String id, Object instance, long expiration) + throws PersistenceException { + try { + nonDurableStore.insertRecord(component, id, instance, expiration); + } catch (StoreWriteException e) { + throw new PersistenceException(e); + } + } + + public void persist(AtomicComponent component, String id, Object instance, long expiration) + throws PersistenceException { + try { + nonDurableStore.updateRecord(component, id, instance, expiration); + } catch (StoreWriteException e) { + throw new PersistenceException(e); + } + } + + public void remove(AtomicComponent component) throws PersistenceException { + String conversationId = getConversationId(); + try { + workContext.setCurrentAtomicComponent(component); + // FIXME this should be an InstanceWrapper and shouldn't we stop it? + Object instance = nonDurableStore.readRecord(component, conversationId); + if (instance != null) { + nonDurableStore.removeRecord(component, conversationId); + } + } catch (StoreReadException e) { + throw new PersistenceException(e); + } catch (StoreWriteException e) { + throw new PersistenceException(e); + } + } + + protected InstanceWrapper getInstanceWrapper(AtomicComponent component, boolean create) + throws TargetResolutionException { + String conversationId = getConversationId(); + try { + workContext.setCurrentAtomicComponent(component); + InstanceWrapper wrapper = (InstanceWrapper) nonDurableStore.readRecord(component, conversationId); + if (wrapper != null) { + if (component.getMaxIdleTime() > 0) { + // update expiration + long expire = System.currentTimeMillis() + component.getMaxIdleTime(); + nonDurableStore.updateRecord(component, conversationId, wrapper, expire); + } + } else if (create) { + // FIXME should the store really be persisting the wrappers + wrapper = component.createInstanceWrapper(); + wrapper.start(); + long expire = calculateExpiration(component); + nonDurableStore.insertRecord(component, conversationId, wrapper, expire); + } + return wrapper; + } catch (StoreReadException e) { + throw new TargetResolutionException("Error retrieving target instance", e); + } catch (StoreWriteException e) { + throw new TargetResolutionException("Error persisting target instance", e); + } finally { + workContext.setCurrentAtomicComponent(null); + } + } + + /** + * Returns the conversation id associated with the current invocation context + * @return the conversation id + */ + private String getConversationId() { + String conversationId = (String) workContext.getIdentifier(Scope.CONVERSATION); + assert conversationId != null; + return conversationId; + } + + private long calculateExpiration(AtomicComponent component) { + if (component.getMaxAge() > 0) { + long now = System.currentTimeMillis(); + return now + component.getMaxAge(); + } else if (component.getMaxIdleTime() > 0) { + long now = System.currentTimeMillis(); + return now + component.getMaxIdleTime(); + } else { + return Store.DEFAULT_EXPIRATION_OFFSET; + } + } + + /** + * Receives expiration events from the store and notifies the corresponding atomic component + */ + private static class ExpirationListener implements RuntimeEventListener { + private final ScopeContainerMonitor monitor; + + public ExpirationListener(ScopeContainerMonitor monitor) { + this.monitor = monitor; + } + + public void onEvent(Event event) { + if (event instanceof StoreExpirationEvent) { + StoreExpirationEvent expiration = (StoreExpirationEvent) event; + InstanceWrapper wrapper = (InstanceWrapper) expiration.getInstance(); + try { + wrapper.stop(); + } catch (TargetDestructionException e) { + monitor.destructionError(e); + } + } + } + } +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/scope/HttpSessionScopeContainer.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/scope/HttpSessionScopeContainer.java new file mode 100644 index 0000000000..5a398e921e --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/scope/HttpSessionScopeContainer.java @@ -0,0 +1,141 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.component.scope; + +import java.util.ArrayList; +import java.util.List; +import java.util.ListIterator; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +import org.apache.tuscany.spi.component.AtomicComponent; +import org.apache.tuscany.spi.component.ScopeContainerMonitor; +import org.apache.tuscany.spi.component.TargetDestructionException; +import org.apache.tuscany.spi.component.TargetResolutionException; +import org.apache.tuscany.spi.component.WorkContext; +import org.apache.tuscany.spi.component.InstanceWrapper; +import org.apache.tuscany.spi.event.Event; +import org.apache.tuscany.spi.model.Scope; + +import org.apache.tuscany.core.component.event.HttpSessionEnd; + +/** + * A scope context which manages atomic component instances keyed on HTTP session + * + * @version $Rev$ $Date$ + */ +public class HttpSessionScopeContainer extends AbstractScopeContainer { + private final WorkContext workContext; + private final Map> contexts; + private final Map> destroyQueues; + + public HttpSessionScopeContainer(WorkContext workContext, ScopeContainerMonitor monitor) { + super(Scope.SESSION, monitor); + this.workContext = workContext; + contexts = new ConcurrentHashMap>(); + destroyQueues = new ConcurrentHashMap>(); + } + + public void onEvent(Event event) { + checkInit(); + if (event instanceof HttpSessionEnd) { + Object key = ((HttpSessionEnd) event).getId(); + shutdownInstances(key); + workContext.clearIdentifier(key); + } + } + + public synchronized void start() { + if (lifecycleState != UNINITIALIZED && lifecycleState != STOPPED) { + throw new IllegalStateException("Scope must be in UNINITIALIZED or STOPPED state [" + lifecycleState + "]"); + } + lifecycleState = RUNNING; + } + + public synchronized void stop() { + contexts.clear(); + synchronized (destroyQueues) { + destroyQueues.clear(); + } + lifecycleState = STOPPED; + } + + public void register(AtomicComponent component, Object groupId) { + contexts.put(component, new ConcurrentHashMap()); + component.addListener(this); + } + + public void unregister(AtomicComponent component) { + // FIXME should all the instances associated with this component be destroyed already + contexts.remove(component); + component.removeListener(this); + super.unregister(component); + } + + protected InstanceWrapper getInstanceWrapper(AtomicComponent component, boolean create) + throws TargetResolutionException { + Object key = workContext.getIdentifier(Scope.SESSION); + assert key != null : "HTTP session key not bound in work context"; + return getInstance(component, key, create); + } + + private InstanceWrapper getInstance(AtomicComponent component, Object key, boolean create) + throws TargetResolutionException { + Map wrappers = contexts.get(component); + InstanceWrapper ctx = wrappers.get(key); + if (ctx == null && !create) { + return null; + } + if (ctx == null) { + ctx = component.createInstanceWrapper(); + ctx.start(); + wrappers.put(key, ctx); + List destroyQueue = destroyQueues.get(key); + if (destroyQueue == null) { + destroyQueue = new ArrayList(); + destroyQueues.put(key, destroyQueue); + } + synchronized (destroyQueue) { + destroyQueue.add(ctx); + } + } + return ctx; + + } + + private void shutdownInstances(Object key) { + List destroyQueue = destroyQueues.remove(key); + if (destroyQueue != null) { + for (Map map : contexts.values()) { + map.remove(key); + } + ListIterator iter = destroyQueue.listIterator(destroyQueue.size()); + synchronized (destroyQueue) { + while (iter.hasPrevious()) { + try { + iter.previous().stop(); + } catch (TargetDestructionException e) { + monitor.destructionError(e); + } + } + } + } + } + +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/scope/InstanceWrapperBase.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/scope/InstanceWrapperBase.java new file mode 100644 index 0000000000..def862fa7c --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/scope/InstanceWrapperBase.java @@ -0,0 +1,53 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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.component.scope; + +import org.apache.tuscany.spi.component.TargetDestructionException; +import org.apache.tuscany.spi.component.TargetInitializationException; +import org.apache.tuscany.spi.component.InstanceWrapper; + +/** + * @version $Rev$ $Date$ + */ +public class InstanceWrapperBase implements InstanceWrapper { + protected final T instance; + private boolean started; + + public InstanceWrapperBase(T instance) { + assert instance != null; + this.instance = instance; + } + + public T getInstance() { + assert started; + return instance; + } + + public boolean isStarted() { + return started; + } + + public void start() throws TargetInitializationException { + started = true; + } + + public void stop() throws TargetDestructionException { + started = false; + } +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/scope/RequestScopeContainer.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/scope/RequestScopeContainer.java new file mode 100644 index 0000000000..d40277dc23 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/scope/RequestScopeContainer.java @@ -0,0 +1,130 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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.component.scope; + +import java.net.URI; +import java.util.ArrayList; +import java.util.List; +import java.util.ListIterator; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +import org.apache.tuscany.spi.component.AtomicComponent; +import org.apache.tuscany.spi.component.ScopeContainerMonitor; +import org.apache.tuscany.spi.component.TargetDestructionException; +import org.apache.tuscany.spi.component.TargetResolutionException; +import org.apache.tuscany.spi.component.InstanceWrapper; +import org.apache.tuscany.spi.event.Event; +import org.apache.tuscany.spi.model.Scope; + +import org.apache.tuscany.core.component.event.RequestEnd; + +/** + * A scope context which manages atomic component instances keyed on the current request context + * + * @version $Rev$ $Date$ + */ +public class RequestScopeContainer extends AbstractScopeContainer { + private final Map> contexts; + private final Map> destroyQueues; + + public RequestScopeContainer(ScopeContainerMonitor monitor) { + super(Scope.REQUEST, monitor); + contexts = new ConcurrentHashMap>(); + destroyQueues = new ConcurrentHashMap>(); + } + + public void onEvent(Event event) { + checkInit(); + if (event instanceof RequestEnd) { + shutdownInstances(Thread.currentThread()); + } + } + + public synchronized void start() { + if (lifecycleState != UNINITIALIZED && lifecycleState != STOPPED) { + throw new IllegalStateException("Scope must be in UNINITIALIZED or STOPPED state [" + lifecycleState + "]"); + } + lifecycleState = RUNNING; + } + + public synchronized void stop() { + contexts.clear(); + synchronized (destroyQueues) { + destroyQueues.clear(); + } + lifecycleState = STOPPED; + } + + public void register(AtomicComponent component, URI groupId) { + super.register(component, groupId); + contexts.put(component, new ConcurrentHashMap()); + } + + public void unregister(AtomicComponent component) { + // FIXME should all the instances associated with this component be destroyed already + contexts.remove(component); + super.unregister(component); + } + + protected InstanceWrapper getInstanceWrapper(AtomicComponent component, boolean create) + throws TargetResolutionException { + Map instanceContextMap = contexts.get(component); + assert instanceContextMap != null : "Atomic component not registered"; + InstanceWrapper ctx = instanceContextMap.get(Thread.currentThread()); + if (ctx == null && !create) { + return null; + } + if (ctx == null) { + ctx = component.createInstanceWrapper(); + ctx.start(); + instanceContextMap.put(Thread.currentThread(), ctx); + List destroyQueue = destroyQueues.get(Thread.currentThread()); + if (destroyQueue == null) { + destroyQueue = new ArrayList(); + destroyQueues.put(Thread.currentThread(), destroyQueue); + } + synchronized (destroyQueue) { + destroyQueue.add(ctx); + } + } + return ctx; + } + + private void shutdownInstances(Thread key) { + List destroyQueue = destroyQueues.remove(key); + if (destroyQueue != null && destroyQueue.size() > 0) { + Thread thread = Thread.currentThread(); + for (Map map : contexts.values()) { + map.remove(thread); + } + ListIterator iter = destroyQueue.listIterator(destroyQueue.size()); + synchronized (destroyQueue) { + while (iter.hasPrevious()) { + try { + iter.previous().stop(); + } catch (TargetDestructionException e) { + monitor.destructionError(e); + } + } + } + } + } + +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/scope/ScopeRegistryImpl.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/scope/ScopeRegistryImpl.java new file mode 100644 index 0000000000..bcf05982eb --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/scope/ScopeRegistryImpl.java @@ -0,0 +1,49 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.component.scope; + +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +import org.apache.tuscany.spi.ObjectFactory; +import org.apache.tuscany.spi.component.ScopeContainer; +import org.apache.tuscany.spi.component.ScopeRegistry; +import org.apache.tuscany.spi.model.Scope; + +/** + * The default implementation of a scope registry + * + * @version $Rev$ $Date$ + */ +public class ScopeRegistryImpl implements ScopeRegistry { + private final Map scopeCache = + new ConcurrentHashMap(); + private final Map> factoryCache = + new ConcurrentHashMap>(); + + public void register(ScopeContainer container) { + scopeCache.put(container.getScope(), container); + } + + public ScopeContainer getScopeContainer(Scope scope) { + return scopeCache.get(scope); + } + + +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/scope/StatelessScopeContainer.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/scope/StatelessScopeContainer.java new file mode 100644 index 0000000000..0e1d5cab6a --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/scope/StatelessScopeContainer.java @@ -0,0 +1,62 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.component.scope; + +import org.osoa.sca.annotations.EagerInit; +import org.osoa.sca.annotations.Service; + +import org.apache.tuscany.spi.component.AtomicComponent; +import org.apache.tuscany.spi.component.InstanceWrapper; +import org.apache.tuscany.spi.component.ScopeContainerMonitor; +import org.apache.tuscany.spi.component.TargetDestructionException; +import org.apache.tuscany.spi.component.TargetResolutionException; +import org.apache.tuscany.spi.component.ScopeContainer; +import org.apache.tuscany.spi.model.Scope; +import org.apache.tuscany.api.annotation.Monitor; + +/** + * A scope context which manages stateless atomic component instances in a non-pooled fashion. + * + * @version $Rev$ $Date$ + */ +@EagerInit +@Service(ScopeContainer.class) +public class StatelessScopeContainer extends AbstractScopeContainer { + + public StatelessScopeContainer(@Monitor ScopeContainerMonitor monitor) { + super(Scope.STATELESS, monitor); + } + + public InstanceWrapper getWrapper(AtomicComponent component, KEY contextId) + throws TargetResolutionException { + InstanceWrapper ctx = createInstance(component); + ctx.start(); + return ctx; + } + + public InstanceWrapper getAssociatedWrapper(AtomicComponent component, KEY contextId) + throws TargetResolutionException { + throw new UnsupportedOperationException(); + } + + public void returnWrapper(AtomicComponent component, InstanceWrapper wrapper, KEY contextId) + throws TargetDestructionException { + wrapper.stop(); + } +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/deployer/AbstractDeploymentContext.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/deployer/AbstractDeploymentContext.java new file mode 100644 index 0000000000..8d24047781 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/deployer/AbstractDeploymentContext.java @@ -0,0 +1,80 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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.deployer; + +import java.net.URI; +import java.net.URL; +import java.util.HashMap; +import java.util.Map; + +import org.apache.tuscany.spi.component.Component; +import org.apache.tuscany.spi.deployer.DeploymentContext; + +/** + * Base class for DeploymentContext implementations. + * + * @version $Rev$ $Date$ + */ +public abstract class AbstractDeploymentContext implements DeploymentContext { + private final URI componentId; + private boolean autowire; + private final ClassLoader classLoader; + private final URL scdlLocation; + private final Map components = new HashMap(); + + /** + * Constructor defining properties of this context. + * + * @param classLoader the classloader for loading application resources + * @param scdlLocation the location of the SCDL defining this composite + * @param componentId the id of the component being deployed + * @param autowire if autowire is enabled + */ + protected AbstractDeploymentContext(ClassLoader classLoader, URL scdlLocation, URI componentId, boolean autowire) { + this.classLoader = classLoader; + this.scdlLocation = scdlLocation; + this.componentId = componentId; + this.autowire = autowire; + } + + public ClassLoader getClassLoader() { + return classLoader; + } + + public URL getScdlLocation() { + return scdlLocation; + } + + public URI getComponentId() { + return componentId; + } + + public boolean isAutowire() { + return autowire; + } + + public void setAutowire(boolean autowire) { + this.autowire = autowire; + } + + @Deprecated + public Map getComponents() { + return components; + } +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/deployer/ChildDeploymentContext.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/deployer/ChildDeploymentContext.java new file mode 100644 index 0000000000..c2f8ae07fc --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/deployer/ChildDeploymentContext.java @@ -0,0 +1,71 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.deployer; + +import java.net.URI; +import java.net.URL; +import javax.xml.stream.XMLInputFactory; + +import org.apache.tuscany.spi.component.ScopeContainer; +import org.apache.tuscany.spi.deployer.DeploymentContext; + +/** + * An holder that can be used during the load process to store information that is not part of the logical assembly + * model. This should be regarded as transient and references to this context should not be stored inside the model. + * + * @version $Rev$ $Date$ + */ +public class ChildDeploymentContext extends AbstractDeploymentContext { + private final DeploymentContext parent; + + /** + * Constructor defining properties of this context. + * + * @param parent the parent of this context + * @param classLoader the classloader for loading application resources + * @param scdlLocation the location of the SCDL defining this composite + * @param componentId the id of the component being deployed + * @param autowire if autowire is enabled + */ + public ChildDeploymentContext(DeploymentContext parent, + ClassLoader classLoader, + URL scdlLocation, + URI componentId, + boolean autowire) { + super(classLoader, scdlLocation, componentId, autowire); + assert parent != null; + this.parent = parent; + } + + public DeploymentContext getParent() { + return parent; + } + + public XMLInputFactory getXmlFactory() { + return parent.getXmlFactory(); + } + + public ScopeContainer getCompositeScope() { + return parent.getCompositeScope(); + } + + public URI getGroupId() { + return parent.getGroupId(); + } +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/deployer/DeployerImpl.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/deployer/DeployerImpl.java new file mode 100644 index 0000000000..18f078e4f6 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/deployer/DeployerImpl.java @@ -0,0 +1,197 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.deployer; + +import java.net.URI; +import java.util.Collection; +import javax.xml.stream.XMLInputFactory; + +import org.osoa.sca.annotations.Reference; + +import org.apache.tuscany.api.annotation.Monitor; +import org.apache.tuscany.core.resolver.AutowireResolver; +import org.apache.tuscany.spi.builder.Builder; +import org.apache.tuscany.spi.builder.BuilderException; +import org.apache.tuscany.spi.builder.BuilderInstantiationException; +import org.apache.tuscany.spi.builder.BuilderRegistry; +import org.apache.tuscany.spi.builder.Connector; +import org.apache.tuscany.spi.component.Component; +import org.apache.tuscany.spi.component.ComponentManager; +import org.apache.tuscany.spi.component.RegistrationException; +import org.apache.tuscany.spi.component.SCAObject; +import org.apache.tuscany.spi.component.ScopeContainer; +import org.apache.tuscany.spi.component.ScopeContainerMonitor; +import org.apache.tuscany.spi.component.ScopeRegistry; +import org.apache.tuscany.spi.deployer.Deployer; +import org.apache.tuscany.spi.deployer.DeploymentContext; +import org.apache.tuscany.spi.loader.Loader; +import org.apache.tuscany.spi.loader.LoaderException; +import org.apache.tuscany.spi.loader.LoaderRegistry; +import org.apache.tuscany.spi.model.ComponentDefinition; +import org.apache.tuscany.spi.model.Implementation; +import org.apache.tuscany.spi.model.Scope; +import org.apache.tuscany.spi.resolver.ResolutionException; + +/** + * Default implementation of Deployer. + * + * @version $Rev$ $Date$ + */ +public class DeployerImpl implements Deployer { + private XMLInputFactory xmlFactory; + private Loader loader; + private Builder builder; + private ScopeContainerMonitor monitor; + private AutowireResolver resolver; + private Connector connector; + private ComponentManager componentManager; + private ScopeRegistry scopeRegistry; + + + public DeployerImpl(XMLInputFactory xmlFactory, + Loader loader, + Builder builder, + ComponentManager componentManager, + AutowireResolver resolver, + Connector connector) { + this.xmlFactory = xmlFactory; + this.builder = builder; + this.loader = loader; + this.componentManager = componentManager; + this.resolver = resolver; + this.connector = connector; + } + + public DeployerImpl() { + xmlFactory = XMLInputFactory.newInstance("javax.xml.stream.XMLInputFactory", getClass().getClassLoader()); + } + + @Reference + public void setBuilder(BuilderRegistry builder) { + this.builder = builder; + } + + @Monitor + public void setMonitor(ScopeContainerMonitor monitor) { + this.monitor = monitor; + } + + @Reference + public void setResolver(AutowireResolver resolver) { + this.resolver = resolver; + } + + @Reference + public void setConnector(Connector connector) { + this.connector = connector; + } + + @Reference + public void setComponentManager(ComponentManager componentManager) { + this.componentManager = componentManager; + } + + @Reference + public void setScopeRegistry(ScopeRegistry scopeRegistry) { + this.scopeRegistry = scopeRegistry; + } + + public > Collection deploy(Component parent, + ComponentDefinition componentDefinition) + throws LoaderException, BuilderException, ResolutionException { + @SuppressWarnings("unchecked") + ScopeContainer scopeContainer = scopeRegistry.getScopeContainer(Scope.COMPOSITE); + URI groupId = componentDefinition.getUri(); + DeploymentContext deploymentContext = + new RootDeploymentContext(null, null, groupId, xmlFactory, scopeContainer, false); + // load the model + load(parent, componentDefinition, deploymentContext); + // resolve autowires + resolver.resolve(null, componentDefinition); + // build runtime artifacts + build(parent, componentDefinition, deploymentContext); +/* + // create a listener so the scope container is shutdown when the top-level composite stops + RuntimeEventListener listener = new RuntimeEventListener() { + public void onEvent(Event event) { + scopeContainer.onEvent(event); + if (event instanceof ComponentStop) { + scopeContainer.stop(); + } + } + }; + component.addListener(listener); +*/ + + Collection components = deploymentContext.getComponents().values(); + for (Component toRegister : components) { + try { + componentManager.register(toRegister); + } catch (RegistrationException e) { + throw new BuilderInstantiationException("Error registering component", e); + } + } + connector.connect(componentDefinition); + return components; + } + + /** + * Load the componentDefinition type information for the componentDefinition being deployed. For a typical + * deployment this will result in the SCDL definition being loaded. + * + * @param componentDefinition the componentDefinition being deployed + * @param deploymentContext the current deployment context + */ + protected > void load(Component parent, + ComponentDefinition componentDefinition, + DeploymentContext deploymentContext) throws LoaderException { + loader.loadComponentType(componentDefinition.getImplementation(), deploymentContext); + } + + + /** + * Build the runtime context for a loaded componentDefinition. + * + * @param parent the context that will be the parent of the new sub-context + * @param componentDefinition the componentDefinition being deployed + * @param deploymentContext the current deployment context + * @return the new runtime context + */ + protected > SCAObject build(Component parent, + ComponentDefinition componentDefinition, + DeploymentContext deploymentContext) + throws BuilderException { + return builder.build(componentDefinition, deploymentContext); + } + + /** + * @return the builder + */ + public Builder getBuilder() { + return builder; + } + + /** + * @return the loader + */ + public Loader getLoader() { + return loader; + } + +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/deployer/RootDeploymentContext.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/deployer/RootDeploymentContext.java new file mode 100644 index 0000000000..a523dadbf4 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/deployer/RootDeploymentContext.java @@ -0,0 +1,74 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.deployer; + +import java.net.URI; +import java.net.URL; +import javax.xml.stream.XMLInputFactory; + +import org.apache.tuscany.spi.component.ScopeContainer; +import org.apache.tuscany.spi.deployer.DeploymentContext; + +/** + * A holder that can be used during the load process to store information that is not part of the logical assembly + * model. This should be regarded as transient and references to this context should not be stored inside the model. + * + * @version $Rev$ $Date$ + */ +public class RootDeploymentContext extends AbstractDeploymentContext { + private final XMLInputFactory xmlFactory; + private final ScopeContainer scopeContainer; + + /** + * Constructor defining properties of this context. + * + * @param classLoader the classloader for loading application resources + * @param scdlLocation the location of the SCDL defining this composite + * @param componentId the id of the component being deployed + * @param xmlFactory a factory that can be used to obtain an StAX XMLStreamReader + * @param scopeContainer the scope context representing this deployment's COMPOSITE scope + * @param autowire if autowire is enabled + */ + public RootDeploymentContext(ClassLoader classLoader, + URL scdlLocation, + URI componentId, + XMLInputFactory xmlFactory, + ScopeContainer scopeContainer, + boolean autowire) { + super(classLoader, scdlLocation, componentId, autowire); + this.xmlFactory = xmlFactory; + this.scopeContainer = scopeContainer; + } + + public DeploymentContext getParent() { + return null; + } + + public XMLInputFactory getXmlFactory() { + return xmlFactory; + } + + public ScopeContainer getCompositeScope() { + return scopeContainer; + } + + public URI getGroupId() { + return getComponentId(); + } +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/implementation/PojoWorkContextTunnel.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/implementation/PojoWorkContextTunnel.java new file mode 100644 index 0000000000..cef6675f05 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/implementation/PojoWorkContextTunnel.java @@ -0,0 +1,63 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.implementation; + +import org.apache.tuscany.spi.component.WorkContext; + +/** + * Class for tunneling a WorkContext through the invocation of a user class. + * + * @version $Rev$ $Date$ + */ +public final class PojoWorkContextTunnel { + private PojoWorkContextTunnel() { + } + + private static final ThreadLocal CONTEXT = new ThreadLocal(); + + /** + * Set the WorkContext for the current thread. + * The current work context is returned and must be restored after the invocation is complete. + * Typical usage would be: + *
+     *   WorkContext old = PojoWorkContextTunnel.setThreadWorkContext(newContext);
+     *   try {
+     *      ... invoke user code ...
+     *   } finally {
+     *     PojoWorkContextTunnel.setThreadWorkContext(old);
+     *   }
+     * 
+ * @param context + * @return the current work context for the thread; this must be restored after the invocation is made + */ + public static WorkContext setThreadWorkContext(WorkContext context) { + WorkContext old = CONTEXT.get(); + CONTEXT.set(context); + return old; + } + + /** + * Returns the WorkContext for the current thread. + * + * @return the WorkContext for the current thread + */ + public static WorkContext getThreadWorkContext() { + return CONTEXT.get(); + } +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/implementation/composite/AbstractCompositeBuilder.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/implementation/composite/AbstractCompositeBuilder.java new file mode 100644 index 0000000000..d12b407ea7 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/implementation/composite/AbstractCompositeBuilder.java @@ -0,0 +1,69 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.implementation.composite; + +import org.apache.tuscany.spi.builder.BuilderException; +import org.apache.tuscany.spi.builder.BuilderInstantiationException; +import org.apache.tuscany.spi.component.Component; +import org.apache.tuscany.spi.component.Reference; +import org.apache.tuscany.spi.component.RegistrationException; +import org.apache.tuscany.spi.component.Service; +import org.apache.tuscany.spi.deployer.DeploymentContext; +import org.apache.tuscany.spi.extension.ComponentBuilderExtension; +import org.apache.tuscany.spi.model.ComponentDefinition; +import org.apache.tuscany.spi.model.CompositeComponentType; +import org.apache.tuscany.spi.model.Implementation; +import org.apache.tuscany.spi.model.ReferenceDefinition; +import org.apache.tuscany.spi.model.ServiceDefinition; + +/** + * Abstract builder for composites + * + * @version $Rev$ $Date$ + */ +public abstract class AbstractCompositeBuilder> + extends ComponentBuilderExtension { + + public Component build( + Component component, + CompositeComponentType componentType, + DeploymentContext deploymentContext) throws BuilderException { + for (ComponentDefinition> definition : componentType.getComponents().values()) { + builderRegistry.build(definition, deploymentContext); + } + for (ServiceDefinition definition : componentType.getServices().values()) { + try { + Service service = builderRegistry.build(definition, deploymentContext); + component.register(service); + } catch (RegistrationException e) { + throw new BuilderInstantiationException("Error registering service", e); + } + } + for (ReferenceDefinition definition : componentType.getReferences().values()) { + try { + Reference reference = builderRegistry.build(definition, deploymentContext); + component.register(reference); + } catch (RegistrationException e) { + throw new BuilderInstantiationException("Error registering reference", e); + } + } + return component; + } + +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/implementation/composite/ComponentTimeoutException.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/implementation/composite/ComponentTimeoutException.java new file mode 100644 index 0000000000..ed64cb1236 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/implementation/composite/ComponentTimeoutException.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.implementation.composite; + +import org.apache.tuscany.spi.component.ComponentRuntimeException; + +/** + * Denotes a condition where a component times out waiting to perform an operation + * + * @version $Rev$ $Date$ + */ +public class ComponentTimeoutException extends ComponentRuntimeException { + + public ComponentTimeoutException(String message) { + super(message); + } +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeBuilder.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeBuilder.java new file mode 100644 index 0000000000..51d360ec39 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeBuilder.java @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.implementation.composite; + +import java.net.URI; + +import org.apache.tuscany.spi.builder.BuilderException; +import org.apache.tuscany.spi.component.Component; +import org.apache.tuscany.spi.deployer.DeploymentContext; +import org.apache.tuscany.spi.model.ComponentDefinition; +import org.apache.tuscany.spi.model.CompositeComponentType; +import org.apache.tuscany.spi.model.CompositeImplementation; + +/** + * Instantiates a composite component from an assembly definition + * + * @version $Rev$ $Date$ + */ +public class CompositeBuilder extends AbstractCompositeBuilder { + + public Component build(ComponentDefinition componentDefinition, + DeploymentContext deploymentContext) throws BuilderException { + + CompositeImplementation implementation = componentDefinition.getImplementation(); + CompositeComponentType componentType = implementation.getComponentType(); + URI name = componentDefinition.getUri(); + CompositeComponentImpl component = new CompositeComponentImpl(name); + + return build(component, componentType, deploymentContext); + } + + protected Class getImplementationType() { + return CompositeImplementation.class; + } +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeComponentImpl.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeComponentImpl.java new file mode 100644 index 0000000000..8df05048c8 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeComponentImpl.java @@ -0,0 +1,121 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.implementation.composite; + +import java.net.URI; +import java.util.List; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + +import org.apache.tuscany.spi.event.Event; +import org.apache.tuscany.spi.extension.CompositeComponentExtension; +import org.apache.tuscany.spi.wire.Wire; + +import org.apache.tuscany.core.component.event.ComponentStop; + +/** + * The standard implementation of a composite component. Autowiring is performed by delegating to the parent composite. + * + * @version $Rev$ $Date$ + */ +public class CompositeComponentImpl extends CompositeComponentExtension { + public static final int DEFAULT_WAIT = 1000 * 60; + // Blocking latch to ensure the composite is initialized exactly once prior to servicing requests + protected CountDownLatch initializeLatch = new CountDownLatch(1); + protected final Object lock = new Object(); + // Indicates whether the composite context has been initialized + protected boolean initialized; + + /** + * Constructor + * + * @param name the name of this Component + */ + public CompositeComponentImpl(URI name) { + super(name); + } + + public void attachWire(Wire wire) { + throw new UnsupportedOperationException(); + } + + public void attachWires(List wires) { + throw new UnsupportedOperationException(); + } + + public List getWires(String name) { + throw new UnsupportedOperationException(); + } + + public void attachCallbackWire(Wire wire) { + throw new UnsupportedOperationException(); + } + + public void start() { + synchronized (lock) { + if (lifecycleState != UNINITIALIZED && lifecycleState != STOPPED) { + throw new IllegalStateException("Composite not in UNINITIALIZED state"); + } + initializeLatch.countDown(); + initialized = true; + lifecycleState = INITIALIZED; + } + } + + public void stop() { + if (lifecycleState == STOPPED) { + return; + } + + publish(new ComponentStop(this, getUri())); + // need to block a start until reset is complete + initializeLatch = new CountDownLatch(2); + lifecycleState = STOPPING; + initialized = false; + // allow initialized to be called + initializeLatch.countDown(); + lifecycleState = STOPPED; + } + + public void publish(Event event) { + if (lifecycleState == STOPPED) { + return; + } + checkInit(); + super.publish(event); + } + + /** + * Blocks until the composite context has been initialized + */ + protected void checkInit() throws ComponentTimeoutException { + if (!initialized) { + try { + /* block until the composite has initialized */ + boolean success = initializeLatch.await(DEFAULT_WAIT, TimeUnit.MILLISECONDS); + if (!success) { + throw new ComponentTimeoutException("Timeout waiting for context to initialize"); + } + } catch (InterruptedException e) { // should not happen + } + } + + } + +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeComponentTypeLoader.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeComponentTypeLoader.java new file mode 100644 index 0000000000..6cb31a8e20 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeComponentTypeLoader.java @@ -0,0 +1,65 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.implementation.composite; + +import java.net.URI; +import java.net.URL; + +import org.apache.tuscany.spi.deployer.CompositeClassLoader; +import org.apache.tuscany.spi.deployer.DeploymentContext; +import org.apache.tuscany.spi.extension.ComponentTypeLoaderExtension; +import org.apache.tuscany.spi.loader.LoaderException; +import org.apache.tuscany.spi.loader.LoaderRegistry; +import org.apache.tuscany.spi.model.CompositeComponentType; +import org.apache.tuscany.spi.model.CompositeImplementation; + +import org.apache.tuscany.core.deployer.ChildDeploymentContext; + +/** + * Loads a composite component type + * + * @version $Rev$ $Date$ + */ +public class CompositeComponentTypeLoader extends ComponentTypeLoaderExtension { + public CompositeComponentTypeLoader() { + } + + public CompositeComponentTypeLoader(LoaderRegistry loaderRegistry) { + super(loaderRegistry); + } + + protected Class getImplementationClass() { + return CompositeImplementation.class; + } + + public void load(CompositeImplementation implementation, DeploymentContext context) throws LoaderException { + URL scdlLocation = implementation.getScdlLocation(); + ClassLoader cl = new CompositeClassLoader(null, implementation.getClassLoader()); + URI componentId = URI.create(context.getComponentId().toString() + '/'); + DeploymentContext childContext = + new ChildDeploymentContext(context, cl, scdlLocation, componentId, context.isAutowire()); + CompositeComponentType componentType = loadFromSidefile(scdlLocation, childContext); + implementation.setComponentType(componentType); + } + + protected CompositeComponentType loadFromSidefile(URL url, DeploymentContext deploymentContext) + throws LoaderException { + return loaderRegistry.load(null, url, CompositeComponentType.class, deploymentContext); + } +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeLoader.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeLoader.java new file mode 100644 index 0000000000..008ee59de8 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeLoader.java @@ -0,0 +1,224 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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.implementation.composite; + +import static javax.xml.stream.XMLStreamConstants.END_ELEMENT; +import static javax.xml.stream.XMLStreamConstants.START_ELEMENT; +import static org.osoa.sca.Constants.SCA_NS; + +import java.net.URI; +import java.util.List; +import java.util.Map; + +import javax.xml.namespace.QName; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; + +import org.apache.tuscany.spi.deployer.DeploymentContext; +import org.apache.tuscany.spi.extension.LoaderExtension; +import org.apache.tuscany.spi.loader.InvalidServiceException; +import org.apache.tuscany.spi.loader.InvalidWireException; +import org.apache.tuscany.spi.loader.LoaderException; +import org.apache.tuscany.spi.loader.LoaderRegistry; +import org.apache.tuscany.spi.model.ComponentDefinition; +import org.apache.tuscany.spi.model.ComponentType; +import org.apache.tuscany.spi.model.CompositeComponentType; +import org.apache.tuscany.spi.model.Implementation; +import org.apache.tuscany.spi.model.Include; +import org.apache.tuscany.spi.model.ModelObject; +import org.apache.tuscany.spi.model.Property; +import org.apache.tuscany.spi.model.ReferenceDefinition; +import org.apache.tuscany.spi.model.ReferenceTarget; +import org.apache.tuscany.spi.model.ServiceDefinition; +import org.apache.tuscany.spi.model.WireDefinition; +import org.apache.tuscany.spi.services.artifact.ArtifactRepository; +import org.osoa.sca.annotations.Reference; + +/** + * Loads a composite component definition from an XML-based assembly file + * + * @version $Rev$ $Date$ + */ +public class CompositeLoader extends LoaderExtension { + public static final QName COMPOSITE = new QName(SCA_NS, "composite"); + public static final String URI_DELIMITER = "/"; + + private final ArtifactRepository artifactRepository; + + public CompositeLoader(@Reference + LoaderRegistry registry, @Reference + ArtifactRepository artifactRepository) { + super(registry); + this.artifactRepository = artifactRepository; + } + + public QName getXMLType() { + return COMPOSITE; + } + + public CompositeComponentType load(ModelObject object, XMLStreamReader reader, DeploymentContext deploymentContext) + throws XMLStreamException, LoaderException { + + String name = reader.getAttributeValue(null, "name"); + String targetNamespace = reader.getAttributeValue(null, "targetNamespace"); + boolean autowire = Boolean.parseBoolean(reader.getAttributeValue(null, "autowire")); + + CompositeComponentType> type = new CompositeComponentType>( + new QName( + targetNamespace, + name)); + type.setAutowire(autowire); + boolean done = false; + while (!done) { + switch (reader.next()) { + case START_ELEMENT: + boolean oldAutowire = deploymentContext.isAutowire(); + deploymentContext.setAutowire(autowire); + ModelObject o = registry.load(type, reader, deploymentContext); + deploymentContext.setAutowire(oldAutowire); + if (o instanceof ServiceDefinition) { + type.add((ServiceDefinition)o); + } else if (o instanceof ReferenceDefinition) { + type.add((ReferenceDefinition)o); + } else if (o instanceof Property) { + type.add((Property)o); + } else if (o instanceof ComponentDefinition) { + type.add((ComponentDefinition)o); + } else if (o instanceof Include) { + type.add((Include)o); + } else if (o instanceof WireDefinition) { + type.add((WireDefinition)o); + } else { + // add as an unknown model extension + if (o != null) { + type.getExtensions().put(o.getClass(), o); + } + } + reader.next(); + break; + case END_ELEMENT: + if (COMPOSITE.equals(reader.getName())) { + // if there are wire defintions then link them up to the + // relevant components + resolveWires(type); + verifyCompositeCompleteness(type); + done = true; + break; + } + } + } + for (ComponentDefinition> c : type.getComponents().values()) { + // PropertyHelper.processProperties(type, c, deploymentContext); + } + return type; + } + + protected void resolveWires(CompositeComponentType> composite) + throws InvalidWireException { + ComponentDefinition componentDefinition; + ServiceDefinition serviceDefinition; + List wireDefns = composite.getDeclaredWires(); + for (WireDefinition wire : wireDefns) { + URI targetUri = wire.getTarget(); + // validate the target before finding the source + validateTarget(targetUri, composite); + + String sourceName = wire.getSource().getPath(); // new + // QualifiedName(wire.getSource().getPath()); + serviceDefinition = composite.getDeclaredServices().get(sourceName); + if (serviceDefinition != null) { + serviceDefinition.setTarget(wire.getTarget()); + } else { + componentDefinition = composite.getDeclaredComponents().get(sourceName); + if (componentDefinition != null) { + if (wire.getSource().getFragment() == null) { + throw new InvalidWireException("Source reference not specified", sourceName); + } + URI referenceName = URI.create(wire.getSource().getFragment()); + ReferenceTarget referenceTarget = createReferenceTarget(referenceName, + targetUri, + componentDefinition); + componentDefinition.add(referenceTarget); + } else { + throw new InvalidWireException("Source not found", sourceName); + } + } + } + } + + private ReferenceTarget createReferenceTarget(URI componentReferenceName, + URI target, + ComponentDefinition componentDefn) throws InvalidWireException { + ComponentType componentType = componentDefn.getImplementation().getComponentType(); + if (componentReferenceName == null) { + // if there is ambiguity in determining the source of the wire or + // there is no reference to be wired + if (componentType.getReferences().size() > 1 || componentType.getReferences().isEmpty()) { + throw new InvalidWireException("Unable to determine unique source reference"); + } else { + Map references = componentType.getReferences(); + ReferenceDefinition definition = (ReferenceDefinition)references.values().iterator().next(); + componentReferenceName = definition.getUri(); + } + } + + ReferenceTarget referenceTarget = new ReferenceTarget(); + referenceTarget.setReferenceName(componentReferenceName); + referenceTarget.addTarget(target); + return referenceTarget; + } + + protected void verifyCompositeCompleteness(CompositeComponentType> composite) + throws InvalidServiceException { + // check if all of the composite services have been wired + for (ServiceDefinition svcDefn : composite.getDeclaredServices().values()) { + if (svcDefn.getTarget() == null) { + String identifier = svcDefn.getUri().toString(); + throw new InvalidServiceException("Composite service not wired to a target", identifier); + } + } + } + + private void validateTarget(URI target, + CompositeComponentType> composite) + throws InvalidWireException { + // if target is not a reference of the composite + String targetName = target.getPath(); + if (composite.getReferences().get(targetName) == null) { + ComponentDefinition targetDefinition = composite.getDeclaredComponents().get(targetName); + // if a target component exists in this composite + if (targetDefinition != null) { + Implementation implementation = targetDefinition.getImplementation(); + ComponentType componentType = implementation.getComponentType(); + Map services = componentType.getServices(); + if (target.getFragment() == null) { + if (services.size() > 1 || services.isEmpty()) { + throw new InvalidWireException("Ambiguous target", target.toString()); + } + } else { + if (services.get(target.getFragment()) == null) { + throw new InvalidWireException("Invalid target service", target.toString()); + } + } + } else { + throw new InvalidWireException("Target not found", target.toString()); + } + } + } +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/implementation/composite/ManagedRequestContext.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/implementation/composite/ManagedRequestContext.java new file mode 100644 index 0000000000..f2a8109ee3 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/implementation/composite/ManagedRequestContext.java @@ -0,0 +1,58 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.implementation.composite; + +import javax.security.auth.Subject; + +import org.osoa.sca.RequestContext; +import org.osoa.sca.ServiceReference; +import org.osoa.sca.CallableReference; + +import org.apache.tuscany.spi.component.WorkContext; + +/** + * @version $Rev$ $Date$ + */ +public class ManagedRequestContext implements RequestContext { + private WorkContext workContext; + + public ManagedRequestContext(WorkContext workContext) { + this.workContext = workContext; + } + + public Subject getSecuritySubject() { + throw new UnsupportedOperationException(); + } + + public String getServiceName() { + return workContext.getCurrentServiceName(); + } + + public ServiceReference getServiceReference() { + throw new UnsupportedOperationException(); + } + + public CB getCallback() { + throw new UnsupportedOperationException(); + } + + public CallableReference getCallbackReference() { + throw new UnsupportedOperationException(); + } +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/implementation/composite/ReferenceImpl.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/implementation/composite/ReferenceImpl.java new file mode 100644 index 0000000000..f824980f29 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/implementation/composite/ReferenceImpl.java @@ -0,0 +1,71 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.implementation.composite; + +import java.net.URI; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.apache.tuscany.spi.component.AbstractSCAObject; +import org.apache.tuscany.spi.component.Reference; +import org.apache.tuscany.spi.component.ReferenceBinding; +import org.apache.tuscany.spi.model.ServiceContract; + +/** + * The default implementation of a {@link org.apache.tuscany.spi.component.Reference} + * + * @version $Rev$ $Date$ + */ +public class ReferenceImpl extends AbstractSCAObject implements Reference { + private ServiceContract serviceContract; + private List bindings = new ArrayList(); + + public ReferenceImpl(URI name, ServiceContract contract) { + super(name); + this.serviceContract = contract; + } + + public ServiceContract getServiceContract() { + return serviceContract; + } + + public List getReferenceBindings() { + return Collections.unmodifiableList(bindings); + } + + public void addReferenceBinding(ReferenceBinding binding) { + bindings.add(binding); + } + + public void start() { + super.start(); + for (ReferenceBinding binding : bindings) { + binding.start(); + } + } + + public void stop() { + super.stop(); + for (ReferenceBinding binding : bindings) { + binding.stop(); + } + } + +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/implementation/composite/ServiceImpl.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/implementation/composite/ServiceImpl.java new file mode 100644 index 0000000000..b8b9b00b49 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/implementation/composite/ServiceImpl.java @@ -0,0 +1,81 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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.implementation.composite; + +import java.net.URI; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.apache.tuscany.spi.component.AbstractSCAObject; +import org.apache.tuscany.spi.component.Service; +import org.apache.tuscany.spi.component.ServiceBinding; +import org.apache.tuscany.spi.model.ServiceContract; + +/** + * The default implementation of a {@link Service} + * + * @version $Rev$ $Date$ + */ +public class ServiceImpl extends AbstractSCAObject implements Service { + private ServiceContract serviceContract; + private List bindings = new ArrayList(); + private URI targetUri; + + public ServiceImpl(URI name, ServiceContract contract) { + this(name, contract, null); + } + + public ServiceImpl(URI name, ServiceContract contract, URI targetUri) { + super(name); + this.serviceContract = contract; + this.targetUri = targetUri; + } + + public ServiceContract getServiceContract() { + return serviceContract; + } + + public URI getTargetUri() { + return targetUri; + } + + public List getServiceBindings() { + return Collections.unmodifiableList(bindings); + } + + public void addServiceBinding(ServiceBinding binding) { + bindings.add(binding); + } + + public void start() { + super.start(); + for (ServiceBinding binding : bindings) { + binding.start(); + } + } + + public void stop() { + super.stop(); + for (ServiceBinding binding : bindings) { + binding.stop(); + } + } + +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/injection/SingletonObjectFactory.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/injection/SingletonObjectFactory.java new file mode 100644 index 0000000000..713c1ae54f --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/injection/SingletonObjectFactory.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.injection; + +import org.apache.tuscany.spi.ObjectFactory; + +/** + * Implementation of ObjectFactory that returns a single instance, typically an immutable type. + * + * @version $Rev$ $Date$ + */ +public class SingletonObjectFactory implements ObjectFactory { + private final T instance; + + public SingletonObjectFactory(T instance) { + this.instance = instance; + } + + public T getInstance() { + return instance; + } + +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/loader/ComponentLoader.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/loader/ComponentLoader.java new file mode 100644 index 0000000000..b289e74a9b --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/loader/ComponentLoader.java @@ -0,0 +1,360 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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 static javax.xml.stream.XMLStreamConstants.END_ELEMENT; +import static javax.xml.stream.XMLStreamConstants.START_ELEMENT; +import static org.osoa.sca.Constants.SCA_NS; + +import java.lang.reflect.Type; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.StringTokenizer; + +import javax.xml.namespace.QName; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; + +import org.apache.tuscany.core.binding.local.LocalBindingDefinition; +import org.apache.tuscany.core.deployer.ChildDeploymentContext; +import org.apache.tuscany.spi.ObjectFactory; +import org.apache.tuscany.spi.QualifiedName; +import org.apache.tuscany.spi.deployer.DeploymentContext; +import org.apache.tuscany.spi.extension.LoaderExtension; +import org.apache.tuscany.spi.loader.InvalidReferenceException; +import org.apache.tuscany.spi.loader.InvalidValueException; +import org.apache.tuscany.spi.loader.LoaderException; +import org.apache.tuscany.spi.loader.LoaderRegistry; +import org.apache.tuscany.spi.loader.LoaderUtil; +import org.apache.tuscany.spi.loader.MissingImplementationException; +import org.apache.tuscany.spi.loader.MissingReferenceException; +import org.apache.tuscany.spi.loader.MissingRequiredPropertyException; +import org.apache.tuscany.spi.loader.PropertyObjectFactory; +import org.apache.tuscany.spi.loader.ReferenceMultiplicityViolationException; +import org.apache.tuscany.spi.loader.UndefinedPropertyException; +import org.apache.tuscany.spi.loader.UndefinedReferenceException; +import org.apache.tuscany.spi.loader.UnrecognizedElementException; +import org.apache.tuscany.spi.model.BindingDefinition; +import org.apache.tuscany.spi.model.ComponentDefinition; +import org.apache.tuscany.spi.model.ComponentType; +import org.apache.tuscany.spi.model.CompositeComponentType; +import org.apache.tuscany.spi.model.Implementation; +import org.apache.tuscany.spi.model.ModelObject; +import org.apache.tuscany.spi.model.Multiplicity; +import org.apache.tuscany.spi.model.Property; +import org.apache.tuscany.spi.model.PropertyValue; +import org.apache.tuscany.spi.model.ReferenceDefinition; +import org.apache.tuscany.spi.model.ReferenceTarget; +import org.apache.tuscany.spi.model.ServiceDefinition; +import org.osoa.sca.annotations.Constructor; +import org.osoa.sca.annotations.Reference; +import org.w3c.dom.Document; + +/** + * Loads a component definition from an XML-based assembly file + * + * @version $Rev$ $Date$ + */ +public class ComponentLoader extends LoaderExtension> { + private static final QName COMPONENT = new QName(SCA_NS, "component"); + private static final QName PROPERTY = new QName(SCA_NS, "property"); + private static final QName REFERENCE = new QName(SCA_NS, "reference"); + + private static final String PROPERTY_FILE_ATTR = "file"; + private static final String PROPERTY_NAME_ATTR = "name"; + private static final String PROPERTY_SOURCE_ATTR = "source"; + + private PropertyObjectFactory propertyFactory; + + @Constructor + public ComponentLoader(@Reference LoaderRegistry registry, @Reference PropertyObjectFactory propertyFactory) { + super(registry); + this.propertyFactory = propertyFactory; + } + + public QName getXMLType() { + return COMPONENT; + } + + @SuppressWarnings("unchecked") + public ComponentDefinition load(ModelObject object, XMLStreamReader reader, DeploymentContext context) + throws XMLStreamException, LoaderException { + assert COMPONENT.equals(reader.getName()); + String name = reader.getAttributeValue(null, "name"); + String initLevel = reader.getAttributeValue(null, "initLevel"); + String autowireAttr = reader.getAttributeValue(null, "autowire"); + boolean autowire; + if (autowireAttr == null) { + autowire = context.isAutowire(); + } else { + autowire = Boolean.parseBoolean(autowireAttr); + } + String runtimeAttr = reader.getAttributeValue(null, "runtimeId"); + URI runtimeId; + if (runtimeAttr != null) { + try { + runtimeId = new URI(runtimeAttr); + } catch (URISyntaxException e) { + throw new InvalidValueException(runtimeAttr, "runtimeId", e); + } + } else { + runtimeId = null; + } + + URI componentId = URI.create(context.getComponentId() + "/").resolve(name); + ClassLoader loader = context.getClassLoader(); + URL location = context.getScdlLocation(); + // xcv test + DeploymentContext childContext = new ChildDeploymentContext(context, loader, location, componentId, autowire); + Implementation impl = loadImplementation(reader, childContext); + registry.loadComponentType(impl, childContext); + + ComponentDefinition> componentDefinition = + new ComponentDefinition>(componentId, impl); + componentDefinition.setAutowire(autowire); + componentDefinition.setRuntimeId(runtimeId); + if (initLevel != null) { + if (initLevel.length() == 0) { + componentDefinition.setInitLevel(0); + } else { + try { + componentDefinition.setInitLevel(Integer.valueOf(initLevel)); + } catch (NumberFormatException e) { + throw new InvalidValueException(initLevel, "initValue", e); + } + } + } + + while (true) { + switch (reader.next()) { + case START_ELEMENT: + QName qname = reader.getName(); + if (PROPERTY.equals(qname)) { + loadProperty(reader, componentDefinition, childContext); + } else if (REFERENCE.equals(qname)) { + loadReference(reader, componentDefinition, childContext); + } else { + throw new UnrecognizedElementException(qname); + } + reader.next(); + break; + case END_ELEMENT: + if (reader.getName().equals(COMPONENT)) { + populatePropertyValues(componentDefinition); + ComponentType> type = + (ComponentType>) componentDefinition + .getImplementation().getComponentType(); + + for (ReferenceDefinition ref : type.getReferences().values()) { + // add reference target definitions if autowire is enabled for references that are not + // explicitly configured with autowire by the component + if (!componentDefinition.getReferenceTargets().containsKey(ref.getUri().getFragment())) { + if (autowire) { + ReferenceTarget referenceTarget = new ReferenceTarget(); + String compName = componentDefinition.getUri().toString(); + URI refName = URI.create(compName + ref.getUri().toString()); + referenceTarget.setReferenceName(refName); + referenceTarget.setAutowire(autowire); + componentDefinition.add(referenceTarget); + } + } + } + validate(componentDefinition); + return componentDefinition; + } + break; + } + } + } + + protected Implementation loadImplementation(XMLStreamReader reader, DeploymentContext context) + throws XMLStreamException, LoaderException { + reader.nextTag(); + ModelObject o = registry.load(null, reader, context); + if (!(o instanceof Implementation)) { + throw new MissingImplementationException(); + } + return (Implementation) o; + } + + @SuppressWarnings("unchecked") + protected void loadProperty(XMLStreamReader reader, ComponentDefinition definition, DeploymentContext context) + throws XMLStreamException, LoaderException { + String name = reader.getAttributeValue(null, PROPERTY_NAME_ATTR); + Implementation implementation = definition.getImplementation(); + ComponentType componentType = implementation.getComponentType(); + Property property = (Property) componentType.getProperties().get(name); + if (property == null) { + throw new UndefinedPropertyException(name); + } + PropertyValue propertyValue; + String source = reader.getAttributeValue(null, PROPERTY_SOURCE_ATTR); + String file = reader.getAttributeValue(null, PROPERTY_FILE_ATTR); + if (source != null || file != null) { + propertyValue = new PropertyValue(name, source, file); + propertyValue.setValue(property.getDefaultValue()); + LoaderUtil.skipToEndElement(reader); + } else { + try { + DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + Document value = PropertyUtils.createPropertyValue(reader, property.getXmlType(), documentBuilder); + propertyValue = new PropertyValue(name, value); + } catch (ParserConfigurationException e) { + throw new LoaderException(e); + } + } + ObjectFactory objectFactory = propertyFactory.createObjectFactory(property, propertyValue); + propertyValue.setValueFactory(objectFactory); + definition.add(propertyValue); + } + + protected void loadReference(XMLStreamReader reader, + ComponentDefinition componentDefinition, + DeploymentContext context) throws XMLStreamException, LoaderException { + String name = reader.getAttributeValue(null, "name"); + if (name == null) { + throw new InvalidReferenceException("No name specified"); + } + String target = reader.getAttributeValue(null, "target"); + boolean autowire = Boolean.parseBoolean(reader.getAttributeValue(null, "autowire")); + URI componentId = context.getComponentId(); + List uris = new ArrayList(); + if (target != null) { + StringTokenizer tokenizer = new StringTokenizer(target); + while (tokenizer.hasMoreTokens()) { + String token = tokenizer.nextToken(); + QualifiedName qName = new QualifiedName(token); + uris.add(componentId.resolve(qName.getFragment())); + } + } + + Implementation impl = componentDefinition.getImplementation(); + ComponentType componentType = impl.getComponentType(); + if (!componentType.getReferences().containsKey(name)) { + throw new UndefinedReferenceException(name); + } + if (componentType instanceof CompositeComponentType) { + if (uris.size() != 1) { + // FIXME not yet implemented + throw new UnsupportedOperationException(); + } + ReferenceDefinition definition = componentType.getReferences().get(name); + if (definition.getBindings().isEmpty()) { + // TODO JFM allow selection of a default binding + LocalBindingDefinition binding = new LocalBindingDefinition(uris.get(0)); + definition.addBinding(binding); + } else { + for (BindingDefinition binding : definition.getBindings()) { + binding.setTargetUri(uris.get(0)); + } + } + } else { + ReferenceTarget referenceTarget = componentDefinition.getReferenceTargets().get(name); + if (referenceTarget == null) { + referenceTarget = new ReferenceTarget(); + referenceTarget.setReferenceName(componentId.resolve('#' + name)); + referenceTarget.setAutowire(autowire); + componentDefinition.add(referenceTarget); + } + for (URI uri : uris) { + referenceTarget.addTarget(uri); + } + } + } + + @SuppressWarnings("unchecked") + protected void populatePropertyValues(ComponentDefinition> componentDefinition) + throws MissingRequiredPropertyException { + ComponentType componentType = componentDefinition.getImplementation().getComponentType(); + if (componentType != null) { + Map> properties = componentType.getProperties(); + Map> propertyValues = componentDefinition.getPropertyValues(); + + for (Property aProperty : properties.values()) { + if (propertyValues.get(aProperty.getName()) == null) { + if (aProperty.isRequired()) { + throw new MissingRequiredPropertyException(aProperty.getName()); + } else if (aProperty.getDefaultValue() != null) { + PropertyValue propertyValue = new PropertyValue(); + propertyValue.setName(aProperty.getName()); + propertyValue.setValue(aProperty.getDefaultValue()); +// propertyValue.setValueFactory(new SimplePropertyObjectFactory(aProperty, +// propertyValue.getValue())); + propertyValues.put(aProperty.getName(), propertyValue); + } + } + } + } + } + + /** + * Validates a component definition, ensuring all component type configuration elements are satisfied + */ + protected void validate(ComponentDefinition> definition) throws LoaderException { + // validate refererences + Implementation implementation = definition.getImplementation(); + ComponentType type = implementation.getComponentType(); + if (type == null) { + return; + } + for (ReferenceDefinition referenceDef : type.getReferences().values()) { + if (!referenceDef.isRequired()) { + continue; + } + String name = referenceDef.getUri().getFragment(); + ReferenceTarget target = definition.getReferenceTargets().get(name); + if (target == null) { + throw new MissingReferenceException(name); + } + if (target.isAutowire()) { + // autowire targets are not set yet + continue; + } + int count = target.getTargets().size(); + Multiplicity multiplicity = referenceDef.getMultiplicity(); + switch (multiplicity) { + case ZERO_N: + break; + case ZERO_ONE: + if (count > 1) { + throw new ReferenceMultiplicityViolationException(name, multiplicity, count); + } + break; + case ONE_ONE: + if (count != 1) { + throw new ReferenceMultiplicityViolationException(name, multiplicity, count); + } + break; + case ONE_N: + if (count < 1) { + throw new ReferenceMultiplicityViolationException(name, multiplicity, count); + } + break; + } + + } + } +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/loader/ComponentTypeElementLoader.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/loader/ComponentTypeElementLoader.java new file mode 100644 index 0000000000..beb0bc2731 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/loader/ComponentTypeElementLoader.java @@ -0,0 +1,86 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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 javax.xml.namespace.QName; +import static javax.xml.stream.XMLStreamConstants.END_ELEMENT; +import static javax.xml.stream.XMLStreamConstants.START_ELEMENT; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; + +import static org.osoa.sca.Constants.SCA_NS; +import org.osoa.sca.annotations.Constructor; +import org.osoa.sca.annotations.Reference; + +import org.apache.tuscany.spi.deployer.DeploymentContext; +import org.apache.tuscany.spi.extension.LoaderExtension; +import org.apache.tuscany.spi.loader.LoaderException; +import org.apache.tuscany.spi.loader.LoaderRegistry; +import org.apache.tuscany.spi.model.ComponentType; +import org.apache.tuscany.spi.model.ModelObject; +import org.apache.tuscany.spi.model.Property; +import org.apache.tuscany.spi.model.ReferenceDefinition; +import org.apache.tuscany.spi.model.ServiceDefinition; + +/** + * @version $Rev$ $Date$ + */ +public class ComponentTypeElementLoader extends LoaderExtension { + public static final QName COMPONENT_TYPE = new QName(SCA_NS, "componentType"); + + @Constructor + public ComponentTypeElementLoader(@Reference LoaderRegistry registry) { + super(registry); + } + + public QName getXMLType() { + return COMPONENT_TYPE; + } + + @SuppressWarnings("unchecked") + public ComponentType load(ModelObject object, XMLStreamReader reader, DeploymentContext context) + throws XMLStreamException, LoaderException { + assert COMPONENT_TYPE.equals(reader.getName()); + ComponentType> componentType; + if (object != null) { + assert object instanceof ComponentType; + // a specialized component type was passed in + componentType = (ComponentType>) object; + } else { + componentType = new ComponentType>(); + } + + while (true) { + switch (reader.next()) { + case START_ELEMENT: + ModelObject o = registry.load(componentType, reader, context); + if (o instanceof ServiceDefinition) { + componentType.add((ServiceDefinition) o); + } else if (o instanceof ReferenceDefinition) { + componentType.add((ReferenceDefinition) o); + } else if (o instanceof Property) { + componentType.add((Property) o); + } + break; + case END_ELEMENT: + return componentType; + } + } + } +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/loader/IncludeLoader.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/loader/IncludeLoader.java new file mode 100644 index 0000000000..e10a93bbc0 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/loader/IncludeLoader.java @@ -0,0 +1,105 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.loader; + +import java.net.MalformedURLException; +import java.net.URI; +import java.net.URL; +import javax.xml.namespace.QName; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; + +import static org.osoa.sca.Constants.SCA_NS; +import org.osoa.sca.annotations.Constructor; +import org.osoa.sca.annotations.Reference; + +import org.apache.tuscany.spi.deployer.DeploymentContext; +import org.apache.tuscany.spi.extension.LoaderExtension; +import org.apache.tuscany.spi.loader.LoaderException; +import org.apache.tuscany.spi.loader.LoaderRegistry; +import org.apache.tuscany.spi.loader.LoaderUtil; +import org.apache.tuscany.spi.loader.MissingIncludeException; +import org.apache.tuscany.spi.loader.MissingResourceException; +import org.apache.tuscany.spi.model.CompositeComponentType; +import org.apache.tuscany.spi.model.Include; +import org.apache.tuscany.spi.model.ModelObject; + +import org.apache.tuscany.core.deployer.ChildDeploymentContext; + +/** + * Loader that handles <include> elements. + * + * @version $Rev$ $Date$ + */ +public class IncludeLoader extends LoaderExtension { + private static final QName INCLUDE = new QName(SCA_NS, "include"); + + @Constructor + public IncludeLoader(@Reference LoaderRegistry registry) { + super(registry); + } + + public QName getXMLType() { + return INCLUDE; + } + + public Include load(ModelObject object, XMLStreamReader reader, DeploymentContext deploymentContext) + throws XMLStreamException, LoaderException { + + assert INCLUDE.equals(reader.getName()); + String name = reader.getAttributeValue(null, "name"); + String scdlLocation = reader.getAttributeValue(null, "scdlLocation"); + String scdlResource = reader.getAttributeValue(null, "scdlResource"); + LoaderUtil.skipToEndElement(reader); + + ClassLoader cl = deploymentContext.getClassLoader(); + URL url; + if (scdlLocation != null) { + try { + url = new URL(deploymentContext.getScdlLocation(), scdlLocation); + } catch (MalformedURLException e) { + throw new MissingResourceException(scdlLocation, name, e); + } + } else if (scdlResource != null) { + url = cl.getResource(scdlResource); + if (url == null) { + throw new MissingResourceException(scdlResource, name); + } + } else { + throw new MissingIncludeException("No SCDL location or resource specified", name); + } + + // when we include, the componentId remains that of the parent + URI componentId = deploymentContext.getComponentId(); + boolean autowire = deploymentContext.isAutowire(); + DeploymentContext childContext = new ChildDeploymentContext(deploymentContext, cl, url, componentId, autowire); + CompositeComponentType composite; + composite = loadFromSidefile(url, childContext); + + Include include = new Include(); + include.setName(name); + include.setScdlLocation(url); + include.setIncluded(composite); + return include; + } + + protected CompositeComponentType loadFromSidefile(URL url, DeploymentContext context) throws LoaderException { + return registry.load(null, url, CompositeComponentType.class, context); + } +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/loader/LoaderExceptionFormatter.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/loader/LoaderExceptionFormatter.java new file mode 100644 index 0000000000..26ec72ecb6 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/loader/LoaderExceptionFormatter.java @@ -0,0 +1,67 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.loader; + +import java.io.PrintWriter; + +import org.osoa.sca.annotations.Destroy; +import org.osoa.sca.annotations.EagerInit; +import org.osoa.sca.annotations.Reference; + +import org.apache.tuscany.spi.loader.LoaderException; + +import org.apache.tuscany.host.monitor.ExceptionFormatter; +import org.apache.tuscany.host.monitor.FormatterRegistry; + +/** + * Formats {@link org.apache.tuscany.spi.loader.LoaderException} events + * + * @version $Rev$ $Date$ + */ +@EagerInit +public class LoaderExceptionFormatter implements ExceptionFormatter { + private FormatterRegistry factory; + + public LoaderExceptionFormatter(@Reference FormatterRegistry factory) { + this.factory = factory; + factory.register(this); + } + + public boolean canFormat(Class type) { + return LoaderException.class.isAssignableFrom(type); + } + + @Destroy + public void destroy() { + factory.unregister(this); + } + + public PrintWriter write(PrintWriter writer, Throwable exception) { + assert exception instanceof LoaderException; + LoaderException e = (LoaderException) exception; + e.appendBaseMessage(writer); + if (e.getLine() != LoaderException.UNDEFINED) { + writer.write("\nLine: " + e.getLine() + "\n"); + writer.write("Column: " + e.getColumn() + "\n"); + } else { + writer.write("\n"); + } + return writer; + } +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/loader/LoaderRegistryImpl.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/loader/LoaderRegistryImpl.java new file mode 100644 index 0000000000..57fd1da870 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/loader/LoaderRegistryImpl.java @@ -0,0 +1,179 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.util.HashMap; +import java.util.Map; +import javax.xml.namespace.QName; +import javax.xml.stream.Location; +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; + +import org.osoa.sca.annotations.EagerInit; + +import org.apache.tuscany.spi.deployer.DeploymentContext; +import org.apache.tuscany.spi.loader.ComponentTypeLoader; +import org.apache.tuscany.spi.loader.InvalidConfigurationException; +import org.apache.tuscany.spi.loader.LoaderException; +import org.apache.tuscany.spi.loader.LoaderRegistry; +import org.apache.tuscany.spi.loader.StAXElementLoader; +import org.apache.tuscany.spi.loader.UnrecognizedComponentTypeException; +import org.apache.tuscany.spi.loader.UnrecognizedElementException; +import org.apache.tuscany.spi.model.Implementation; +import org.apache.tuscany.spi.model.ModelObject; + +/** + * The default implementation of a loader registry + * + * @version $Rev$ $Date$ + */ +@EagerInit +public class LoaderRegistryImpl implements LoaderRegistry { + private Monitor monitor; + private final Map> loaders = + new HashMap>(); + private final Map>, + ComponentTypeLoader>> componentTypeLoaders = + new HashMap>, ComponentTypeLoader>>(); + + public LoaderRegistryImpl(@org.apache.tuscany.api.annotation.Monitor Monitor monitor) { + this.monitor = monitor; + } + + public void registerLoader(QName element, StAXElementLoader loader) { + monitor.registeringLoader(element); + loaders.put(element, loader); + } + + public void unregisterLoader(QName element, StAXElementLoader loader) { + monitor.unregisteringLoader(element); + loaders.remove(element); + } + + public ModelObject load( + ModelObject object, + XMLStreamReader reader, + DeploymentContext deploymentContext) throws XMLStreamException, LoaderException { + QName name = reader.getName(); + monitor.elementLoad(name); + StAXElementLoader loader = loaders.get(name); + if (loader == null) { + throw new UnrecognizedElementException(name); + } + return loader.load(object, reader, deploymentContext); + } + + public MO load( + ModelObject object, + URL url, + Class type, + DeploymentContext ctx) throws LoaderException { + try { + XMLStreamReader reader; + InputStream is; + is = url.openStream(); + try { + XMLInputFactory factory = ctx.getXmlFactory(); + reader = factory.createXMLStreamReader(is); + try { + reader.nextTag(); + QName name = reader.getName(); + ModelObject mo = load(object, reader, ctx); + if (type.isInstance(mo)) { + return type.cast(mo); + } else { + UnrecognizedElementException e = new UnrecognizedElementException(name); + e.setResourceURI(url.toString()); + throw e; + } + } catch (LoaderException e) { + Location location = reader.getLocation(); + e.setLine(location.getLineNumber()); + e.setColumn(location.getColumnNumber()); + throw e; + } finally { + try { + reader.close(); + } catch (XMLStreamException e) { + // ignore + } + } + } finally { + try { + is.close(); + } catch (IOException e) { + // ignore + } + } + } catch (IOException e) { + LoaderException sfe = new LoaderException(e); + sfe.setResourceURI(url.toString()); + throw sfe; + } catch (XMLStreamException e) { + throw new InvalidConfigurationException("Invalid or missing resource", url.toString(), e); + } + } + + public > void registerLoader(Class key, ComponentTypeLoader loader) { + componentTypeLoaders.put(key, loader); + } + + public > void unregisterLoader(Class key) { + componentTypeLoaders.remove(key); + } + + @SuppressWarnings("unchecked") + public > void loadComponentType(I implementation, + DeploymentContext deploymentContext) + throws LoaderException { + Class key = (Class) implementation.getClass(); + ComponentTypeLoader loader = (ComponentTypeLoader) componentTypeLoaders.get(key); + if (loader == null) { + throw new UnrecognizedComponentTypeException(key); + } + loader.load(implementation, deploymentContext); + } + + public static interface Monitor { + /** + * Event emitted when a StAX element loader is registered. + * + * @param xmlType the QName of the element the loader will handle + */ + void registeringLoader(QName xmlType); + + /** + * Event emitted when a StAX element loader is unregistered. + * + * @param xmlType the QName of the element the loader will handle + */ + void unregisteringLoader(QName xmlType); + + /** + * Event emitted when a request is made to load an element. + * + * @param xmlType the QName of the element that should be loaded + */ + void elementLoad(QName xmlType); + } +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/loader/PolicySetLoader.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/loader/PolicySetLoader.java new file mode 100644 index 0000000000..66d2a87593 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/loader/PolicySetLoader.java @@ -0,0 +1,195 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.loader; + +import java.util.ArrayList; +import java.util.List; +import javax.xml.namespace.QName; +import static javax.xml.stream.XMLStreamConstants.END_ELEMENT; +import static javax.xml.stream.XMLStreamConstants.START_ELEMENT; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; + +import static org.osoa.sca.Constants.SCA_NS; +import org.osoa.sca.annotations.Constructor; +import org.osoa.sca.annotations.Reference; + +import org.apache.tuscany.spi.deployer.DeploymentContext; +import org.apache.tuscany.spi.extension.LoaderExtension; +import org.apache.tuscany.spi.loader.LoaderRegistry; +import org.apache.tuscany.spi.loader.LoaderUtil; +import org.apache.tuscany.spi.model.IntentMap; +import org.apache.tuscany.spi.model.IntentName; +import org.apache.tuscany.spi.model.ModelObject; +import org.apache.tuscany.spi.model.PolicySet; +import org.apache.tuscany.spi.model.PolicySetReference; +import org.apache.tuscany.spi.model.Qualifier; +import org.apache.tuscany.spi.model.WSPolicyAttachment; + +/** + * Loads a PolicySet definition from an SCDL file. + * + * @version $Rev$ $Date$ + */ +public class PolicySetLoader extends LoaderExtension { + + private static final String WSPOLICY_NAMESPACE = "http://schemas.xmlsoap.org/ws/2004/09/policy"; + + private static final QName POLICYSET = new QName(SCA_NS, "policySet"); + + private static final QName INTENTMAP = new QName(SCA_NS, "intentMap"); + + private static final QName QUALIFIER = new QName(SCA_NS, "qualifier"); + + private static final QName POLICYSETREFERENCE = new QName(SCA_NS, "policySetReference"); + + private static final QName WSPOLICYATTACHMENT = new QName(WSPOLICY_NAMESPACE, "PolicyAttachment"); + + @Constructor + public PolicySetLoader(@Reference LoaderRegistry registry) { + super(registry); + + } + + @Override + public QName getXMLType() { + return POLICYSET; + } + + public PolicySet load(ModelObject object, XMLStreamReader reader, + DeploymentContext deploymentContext) + throws XMLStreamException { + assert POLICYSET.equals(reader.getName()); + String name = reader.getAttributeValue(null, "name"); + String provides = reader.getAttributeValue(null, "provides"); + String appliesTo = reader.getAttributeValue(null, "appliesTo"); + PolicySet policySet = new PolicySet(new QName(SCA_NS, name), parseIntentName(provides)); + String[] appliesToArtifact = split(appliesTo); + for (String artifact : appliesToArtifact) { + policySet.addAppliedArtifacts(new QName(SCA_NS, artifact)); + } + while (true) { + switch (reader.next()) { + case START_ELEMENT: + QName qname = reader.getName(); + if (INTENTMAP.equals(qname)) { + policySet.addIntentMap(loadIntentMap(reader, deploymentContext)); + } else if (POLICYSETREFERENCE.equals(qname)) { + policySet.addPolicySetReference(loadPolicyReference(reader, deploymentContext)); + } else if (WSPOLICYATTACHMENT.equals(qname)) { + policySet.addWsPolicyAttachment(loadWSPolicyAttachment(reader, deploymentContext)); + } + + reader.next(); + break; + case END_ELEMENT: + if (reader.getName().equals(POLICYSET)) { + return policySet; + } + break; + } + } + + } + + private PolicySetReference loadPolicyReference(XMLStreamReader reader, DeploymentContext deploymentContext) + throws XMLStreamException { + assert POLICYSETREFERENCE.equals(reader.getName()); + String name = reader.getAttributeValue(null, "name"); + LoaderUtil.skipToEndElement(reader); + return new PolicySetReference(new QName(SCA_NS, name)); + } + + private IntentMap loadIntentMap(XMLStreamReader reader, DeploymentContext deploymentContext) + throws XMLStreamException { + assert INTENTMAP.equals(reader.getName()); + String defaultIntentAttr = reader.getAttributeValue(null, "default"); + String provides = reader.getAttributeValue(null, "provides"); + IntentMap intentMap = new IntentMap(defaultIntentAttr, java.util.Arrays.asList(split(provides))); + //parentPolicySet.addIntentMap(intentMap); + + while (true) { + switch (reader.next()) { + case START_ELEMENT: + QName qname = reader.getName(); + if (QUALIFIER.equals(qname)) { + intentMap.addQualifier(loadQualifier(reader, deploymentContext)); + } + reader.next(); + break; + case END_ELEMENT: + if (reader.getName().equals(INTENTMAP)) { + return intentMap; + } + } + } + + } + + private Qualifier loadQualifier(XMLStreamReader reader, DeploymentContext deploymentContext) + throws XMLStreamException { + assert QUALIFIER.equals(reader.getName()); + String name = reader.getAttributeValue(null, "name"); + Qualifier qualifier = new Qualifier(name); + while (true) { + switch (reader.next()) { + case START_ELEMENT: + QName qname = reader.getName(); + if (INTENTMAP.equals(qname)) { + qualifier.setIntentMap(loadIntentMap(reader, deploymentContext)); + } else if (WSPOLICYATTACHMENT.equals(qname)) { + qualifier.addWsPolicyAttachment(loadWSPolicyAttachment(reader, deploymentContext)); + } + reader.next(); + break; + case END_ELEMENT: + if (reader.getName().equals(QUALIFIER)) { + return qualifier; + } + } + } + + } + + private WSPolicyAttachment loadWSPolicyAttachment(XMLStreamReader reader, DeploymentContext deploymentContext) + throws XMLStreamException { + return new WSPolicyAttachment(); + } + + /** + * Split a string to string array separated by " " + */ + private static String[] split(String string) { + if (string == null) { + return new String[0]; + } + String[] intents = string.split("[ ]+"); + return intents; + } + + private static List parseIntentName(String attributes) { + String[] intents = split(attributes); + List result = new ArrayList(intents.length); + for (String intent : intents) { + result.add(new IntentName(intent)); + } + return result; + } + +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/loader/PropertyLoader.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/loader/PropertyLoader.java new file mode 100644 index 0000000000..ac39c135d9 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/loader/PropertyLoader.java @@ -0,0 +1,98 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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 javax.xml.namespace.QName; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; + +import org.w3c.dom.Document; +import static org.osoa.sca.Constants.SCA_NS; +import org.osoa.sca.annotations.Constructor; +import org.osoa.sca.annotations.Reference; + +import org.apache.tuscany.spi.deployer.DeploymentContext; +import org.apache.tuscany.spi.extension.LoaderExtension; +import org.apache.tuscany.spi.loader.LoaderException; +import org.apache.tuscany.spi.loader.LoaderRegistry; +import org.apache.tuscany.spi.model.ModelObject; +import org.apache.tuscany.spi.model.Property; + +/** + * Loads a property from an XML-based assembly file + * + * @version $Rev$ $Date$ + */ +public class PropertyLoader extends LoaderExtension { + public static final String PROPERTY_NAME_ATTR = "name"; + public static final String PROPERTY_TYPE_ATTR = "type"; + public static final String PROPERTY_MANY_ATTR = "many"; + public static final String REQUIRED_ATTR = "override"; + + public static final QName PROPERTY = new QName(SCA_NS, "property"); + private final DocumentBuilder documentBuilder; + + @Constructor + public PropertyLoader(@Reference LoaderRegistry registry) { + super(registry); + try { + documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + } catch (ParserConfigurationException e) { + // we should be able to construct the default DocumentBuilder + throw new AssertionError(e); + } + } + + public QName getXMLType() { + return PROPERTY; + } + + public Property load(ModelObject object, XMLStreamReader reader, + DeploymentContext ctx) + throws XMLStreamException, LoaderException { + assert PROPERTY.equals(reader.getName()); + String name = reader.getAttributeValue(null, PROPERTY_NAME_ATTR); + String typeName = reader.getAttributeValue(null, PROPERTY_TYPE_ATTR); + QName xmlType = null; + if (typeName != null) { + int index = typeName.indexOf(':'); + if (index != -1) { + String prefix = typeName.substring(0, index); + String localName = typeName.substring(index + 1); + String ns = reader.getNamespaceURI(prefix); + xmlType = new QName(ns, localName, prefix); + } + } + boolean many = Boolean.parseBoolean(reader.getAttributeValue(null, PROPERTY_MANY_ATTR)); + String required = reader.getAttributeValue(null, REQUIRED_ATTR); + Document value = PropertyUtils.createPropertyValue(reader, xmlType, documentBuilder); + + Property property = new Property(); + property.setRequired(Boolean.parseBoolean(required)); + property.setName(name); + property.setXmlType(xmlType); + property.setMany(many); + + property.setDefaultValue(value); + return property; + } +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/loader/PropertyUtils.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/loader/PropertyUtils.java new file mode 100644 index 0000000000..57c1e1b5f4 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/loader/PropertyUtils.java @@ -0,0 +1,119 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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 javax.xml.XMLConstants; +import javax.xml.namespace.QName; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.stream.XMLStreamConstants; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; + +import org.w3c.dom.Attr; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; + +/** + * @version $Rev$ $Date$ + */ +public final class PropertyUtils { + + private PropertyUtils() { + } + + public static Document createPropertyValue(XMLStreamReader reader, QName type, DocumentBuilder builder) + throws XMLStreamException { + Document doc = builder.newDocument(); + + // root element has no namespace and local name "value" + Element root = doc.createElementNS(null, "value"); + if (type != null) { + Attr xsi = doc.createAttributeNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, "xmlns:xsi"); + xsi.setValue(XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI); + root.setAttributeNodeNS(xsi); + + String prefix = type.getPrefix(); + if (prefix == null || prefix.length() == 0) { + prefix = "ns"; + } + Attr typeXmlns = doc.createAttributeNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, "xmlns:" + prefix); + typeXmlns.setValue(type.getNamespaceURI()); + root.setAttributeNodeNS(typeXmlns); + + Attr xsiType = doc.createAttributeNS(XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI, "xsi:type"); + xsiType.setValue(prefix + ":" + type.getLocalPart()); + root.setAttributeNodeNS(xsiType); + } + doc.appendChild(root); + + loadPropertyValue(reader, root); + return doc; + } + + /** + * Load a property value specification from an StAX stream into a DOM Document. Only elements, text and attributes + * are processed; all comments and other whitespace are ignored. + * + * @param reader the stream to read from + * @param root the DOM node to load + * @throws javax.xml.stream.XMLStreamException + * + */ + public static void loadPropertyValue(XMLStreamReader reader, Node root) throws XMLStreamException { + Document document = root.getOwnerDocument(); + Node current = root; + while (true) { + switch (reader.next()) { + case XMLStreamConstants.START_ELEMENT: + QName name = reader.getName(); + Element child = document.createElementNS(name.getNamespaceURI(), name.getLocalPart()); + + // add the attributes for this element + int count = reader.getAttributeCount(); + for (int i = 0; i < count; i++) { + String ns = reader.getAttributeNamespace(i); + String localPart = reader.getAttributeLocalName(i); + String value = reader.getAttributeValue(i); + child.setAttributeNS(ns, localPart, value); + } + + // push the new element and make it the current one + current.appendChild(child); + current = child; + break; + case XMLStreamConstants.CDATA: + current.appendChild(document.createCDATASection(reader.getText())); + break; + case XMLStreamConstants.CHARACTERS: + current.appendChild(document.createTextNode(reader.getText())); + break; + case XMLStreamConstants.END_ELEMENT: + // if we are back at the root then we are done + if (current == root) { + return; + } + + // pop the element off the stack + current = current.getParentNode(); + } + } + } + +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/loader/ReferenceLoader.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/loader/ReferenceLoader.java new file mode 100644 index 0000000000..54183d1c72 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/loader/ReferenceLoader.java @@ -0,0 +1,107 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.loader; + +import java.util.HashMap; +import java.util.Map; +import javax.xml.namespace.QName; +import static javax.xml.stream.XMLStreamConstants.END_ELEMENT; +import static javax.xml.stream.XMLStreamConstants.START_ELEMENT; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; + +import static org.osoa.sca.Constants.SCA_NS; +import org.osoa.sca.annotations.Constructor; +import org.osoa.sca.annotations.Reference; + +import org.apache.tuscany.spi.deployer.DeploymentContext; +import org.apache.tuscany.spi.extension.LoaderExtension; +import org.apache.tuscany.spi.loader.LoaderException; +import org.apache.tuscany.spi.loader.LoaderRegistry; +import org.apache.tuscany.spi.loader.UnrecognizedElementException; +import org.apache.tuscany.spi.model.BindingDefinition; +import org.apache.tuscany.spi.model.ModelObject; +import org.apache.tuscany.spi.model.Multiplicity; +import org.apache.tuscany.spi.model.ReferenceDefinition; +import org.apache.tuscany.spi.model.ServiceContract; + +/** + * Loads a reference from an XML-based assembly file + * + * @version $Rev$ $Date$ + */ +public class ReferenceLoader extends LoaderExtension { + public static final QName REFERENCE = new QName(SCA_NS, "reference"); + private static final Map MULTIPLICITY = new HashMap(4); + + static { + MULTIPLICITY.put("0..1", Multiplicity.ZERO_ONE); + MULTIPLICITY.put("1..1", Multiplicity.ONE_ONE); + MULTIPLICITY.put("0..n", Multiplicity.ZERO_N); + MULTIPLICITY.put("1..n", Multiplicity.ONE_N); + } + + @Constructor + public ReferenceLoader(@Reference LoaderRegistry registry) { + super(registry); + } + + public QName getXMLType() { + return REFERENCE; + } + + public ReferenceDefinition load(ModelObject object, XMLStreamReader reader, DeploymentContext context) + throws XMLStreamException, LoaderException { + assert REFERENCE.equals(reader.getName()); + String name = reader.getAttributeValue(null, "name"); + String multiplicityVal = reader.getAttributeValue(null, "multiplicity"); + Multiplicity multiplicity = multiplicity(multiplicityVal, Multiplicity.ONE_ONE); + ReferenceDefinition referenceDefinition = new ReferenceDefinition(); + referenceDefinition.setMultiplicity(multiplicity); + referenceDefinition.setUri(context.getComponentId().resolve('#' + name)); + while (true) { + switch (reader.next()) { + case START_ELEMENT: + ModelObject o = registry.load(null, reader, context); + if (o instanceof ServiceContract) { + referenceDefinition.setServiceContract((ServiceContract) o); + } else if (o instanceof BindingDefinition) { + referenceDefinition.addBinding((BindingDefinition) o); + } else { + throw new UnrecognizedElementException(reader.getName()); + } + break; + case END_ELEMENT: + return referenceDefinition; + } + } + } + + /** + * Convert a "multiplicity" attribute to the equivalent enum value. + * + * @param multiplicity the attribute to convert + * @param def the default value + * @return the enum equivalent + */ + private static Multiplicity multiplicity(String multiplicity, Multiplicity def) { + return multiplicity == null ? def : MULTIPLICITY.get(multiplicity); + } + +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/loader/ServiceLoader.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/loader/ServiceLoader.java new file mode 100644 index 0000000000..c5be797cda --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/loader/ServiceLoader.java @@ -0,0 +1,99 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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.net.URI; +import javax.xml.namespace.QName; +import static javax.xml.stream.XMLStreamConstants.END_ELEMENT; +import static javax.xml.stream.XMLStreamConstants.START_ELEMENT; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; + +import static org.osoa.sca.Constants.SCA_NS; +import org.osoa.sca.annotations.Constructor; +import org.osoa.sca.annotations.Reference; + +import org.apache.tuscany.spi.QualifiedName; +import org.apache.tuscany.spi.deployer.DeploymentContext; +import org.apache.tuscany.spi.extension.LoaderExtension; +import org.apache.tuscany.spi.loader.LoaderException; +import org.apache.tuscany.spi.loader.LoaderRegistry; +import org.apache.tuscany.spi.loader.UnrecognizedElementException; +import org.apache.tuscany.spi.model.BindingDefinition; +import org.apache.tuscany.spi.model.ModelObject; +import org.apache.tuscany.spi.model.ServiceContract; +import org.apache.tuscany.spi.model.ServiceDefinition; + +/** + * Loads a service definition from an XML-based assembly file + * + * @version $Rev$ $Date$ + */ +public class ServiceLoader extends LoaderExtension { + private static final QName SERVICE = new QName(SCA_NS, "service"); + + @Constructor + public ServiceLoader(@Reference LoaderRegistry registry) { + super(registry); + } + + public QName getXMLType() { + return SERVICE; + } + + public ServiceDefinition load(ModelObject object, XMLStreamReader reader, DeploymentContext context) + throws XMLStreamException, LoaderException { + assert SERVICE.equals(reader.getName()); + String name = reader.getAttributeValue(null, "name"); + URI compositeId = context.getComponentId(); + URI componentBase = URI.create(compositeId + "/"); + ServiceDefinition def = new ServiceDefinition(); + def.setUri(compositeId.resolve('#' + name)); + + URI targetUri = null; + String promote = reader.getAttributeValue(null, "promote"); + if (promote != null) { + QualifiedName qName = new QualifiedName(promote); + targetUri = componentBase.resolve(qName.getFragment()); + } + while (true) { + int i = reader.next(); + switch (i) { + case START_ELEMENT: + ModelObject o = registry.load(null, reader, context); + if (o instanceof ServiceContract) { + def.setServiceContract((ServiceContract) o); + } else if (o instanceof BindingDefinition) { + def.addBinding((BindingDefinition) o); + } else { + throw new UnrecognizedElementException(reader.getName()); + } + break; + case END_ELEMENT: + if (SERVICE.equals(reader.getName())) { + if (targetUri != null) { + def.setTarget(targetUri); + } + return def; + } + break; + } + } + } +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/loader/StringParserPropertyFactory.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/loader/StringParserPropertyFactory.java new file mode 100644 index 0000000000..eda09d6f11 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/loader/StringParserPropertyFactory.java @@ -0,0 +1,191 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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.beans.PropertyEditor; +import java.beans.PropertyEditorManager; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import javax.xml.stream.XMLStreamException; + +import org.apache.tuscany.spi.ObjectFactory; +import org.apache.tuscany.spi.loader.LoaderException; +import org.apache.tuscany.spi.loader.PropertyObjectFactory; +import org.apache.tuscany.spi.model.Property; +import org.apache.tuscany.spi.model.PropertyValue; + +import org.apache.tuscany.core.injection.SingletonObjectFactory; + +/** + * Implementation of StAXPropertyFactory that interprets the XML as + * + * @version $Rev$ $Date$ + */ +public class StringParserPropertyFactory implements PropertyObjectFactory { + + public ObjectFactory createObjectFactory(Property property, PropertyValue value) + throws LoaderException { + String text = value.getValue().getDocumentElement().getTextContent(); + return new SingletonObjectFactory(createInstance(text, property.getJavaType())); + } + + @SuppressWarnings("unchecked") + public T createInstance(String text, Class type) throws LoaderException { + // Class type = property.getJavaType(); + assert type != null : "property type is null"; + + // degenerate case where property type is a String + if (String.class.equals(type)) { + return type.cast(text); + } + + // special handler to convert hexBinary to a byte[] + if (byte[].class.equals(type)) { + byte[] instance = new byte[text.length() >> 1]; + for (int i = 0; i < instance.length; i++) { + instance[i] = + (byte) (Character.digit(text.charAt(i << 1), 16) << 4 | Character.digit(text + .charAt((i << 1) + 1), 16)); + } + return type.cast(instance); + } + + // does this type have a static valueOf(String) method? + try { + Method valueOf = type.getMethod("valueOf", String.class); + if (Modifier.isStatic(valueOf.getModifiers())) { + try { + return type.cast(valueOf.invoke(null, text)); + } catch (IllegalAccessException e) { + throw new AssertionError("getMethod returned an inaccessible method"); + } catch (InvocationTargetException e) { + // FIXME we should throw something better + throw new LoaderException(e.getCause()); + } + } + } catch (NoSuchMethodException e) { + // try something else + } + + // does this type have a constructor that takes a String? + try { + Constructor ctr = type.getConstructor(String.class); + return ctr.newInstance(text); + } catch (NoSuchMethodException e) { + // try something else + } catch (IllegalAccessException e) { + throw new AssertionError("getConstructor returned an inaccessible method"); + } catch (InstantiationException e) { + throw new LoaderException("Property type cannot be instantiated: " + type.getName()); + } catch (InvocationTargetException e) { + // FIXME we should throw something better + throw new LoaderException(e.getCause()); + } + + // do we have a property editor for it? + PropertyEditor editor = PropertyEditorManager.findEditor(type); + if (editor != null) { + try { + editor.setAsText(text); + return (T) editor.getValue(); + } catch (IllegalArgumentException e) { + // FIXME we should throw something better + throw new LoaderException(e); + + } + } + + // FIXME we should throw something better + throw new LoaderException("Do not have a way to parse a String into a " + type.getName()); + + } + + @SuppressWarnings("unchecked") + public ObjectFactory createObjectFactory(String text, Property property) + throws XMLStreamException, LoaderException { + Class type = property.getJavaType(); + assert type != null : "property type is null"; + + // degenerate case where property type is a String + if (String.class.equals(type)) { + return new SingletonObjectFactory(type.cast(text)); + } + + // special handler to convert hexBinary to a byte[] + if (byte[].class.equals(type)) { + byte[] instance = new byte[text.length() >> 1]; + for (int i = 0; i < instance.length; i++) { + instance[i] = + (byte) (Character.digit(text.charAt(i << 1), 16) << 4 | Character.digit(text + .charAt((i << 1) + 1), 16)); + } + return new SingletonObjectFactory(type.cast(instance)); + } + + // does this type have a static valueOf(String) method? + try { + Method valueOf = type.getMethod("valueOf", String.class); + if (Modifier.isStatic(valueOf.getModifiers())) { + try { + return new SingletonObjectFactory(type.cast(valueOf.invoke(null, text))); + } catch (IllegalAccessException e) { + throw new AssertionError("getMethod returned an inaccessible method"); + } catch (InvocationTargetException e) { + // FIXME we should throw something better + throw new LoaderException(e.getCause()); + } + } + } catch (NoSuchMethodException e) { + // try something else + } + + // does this type have a constructor that takes a String? + try { + Constructor ctr = type.getConstructor(String.class); + return new SingletonObjectFactory(ctr.newInstance(text)); + } catch (NoSuchMethodException e) { + // try something else + } catch (IllegalAccessException e) { + throw new AssertionError("getConstructor returned an inaccessible method"); + } catch (InstantiationException e) { + throw new LoaderException("Property type cannot be instantiated: " + type.getName()); + } catch (InvocationTargetException e) { + // FIXME we should throw something better + throw new LoaderException(e.getCause()); + } + + // do we have a property editor for it? + PropertyEditor editor = PropertyEditorManager.findEditor(type); + if (editor != null) { + try { + editor.setAsText(text); + return new SingletonObjectFactory((T) editor.getValue()); + } catch (IllegalArgumentException e) { + // FIXME we should throw something better + throw new LoaderException(e); + + } + } + + // FIXME we should throw something better + throw new LoaderException("Do not have a way to parse a String into a " + type.getName()); + } +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/loader/WireLoader.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/loader/WireLoader.java new file mode 100644 index 0000000000..9c60790111 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/loader/WireLoader.java @@ -0,0 +1,122 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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.net.URI; +import java.net.URISyntaxException; +import javax.xml.namespace.QName; +import static javax.xml.stream.XMLStreamConstants.END_ELEMENT; +import static javax.xml.stream.XMLStreamConstants.START_ELEMENT; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; + +import static org.osoa.sca.Constants.SCA_NS; +import org.osoa.sca.annotations.Constructor; +import org.osoa.sca.annotations.Reference; + +import org.apache.tuscany.spi.QualifiedName; +import org.apache.tuscany.spi.deployer.DeploymentContext; +import org.apache.tuscany.spi.extension.LoaderExtension; +import org.apache.tuscany.spi.loader.InvalidWireException; +import org.apache.tuscany.spi.loader.LoaderException; +import org.apache.tuscany.spi.loader.LoaderRegistry; +import org.apache.tuscany.spi.model.ModelObject; +import org.apache.tuscany.spi.model.WireDefinition; + +/** + * Loads a wire from an XML-based assembly file + * + * @version $Rev: 465084 $ $Date: 2006-10-18 04:00:49 +0530 (Wed, 18 Oct 2006) $ + */ +public class WireLoader extends LoaderExtension { + private static final QName WIRE = new QName(SCA_NS, "wire"); + private static final QName SOURCE_URI = new QName(SCA_NS, "source.uri"); + private static final QName TARGET_URI = new QName(SCA_NS, "target.uri"); + + @Constructor + public WireLoader(@Reference LoaderRegistry registry) { + super(registry); + } + + public QName getXMLType() { + return WIRE; + } + + public WireDefinition load( + ModelObject object, + XMLStreamReader reader, + DeploymentContext deploymentContext) throws XMLStreamException, LoaderException { + assert WIRE.equals(reader.getName()); + WireDefinition wireDefn; + URI sourceURI = null; + URI targetURI = null; + String uriString; + while (true) { + switch (reader.next()) { + case START_ELEMENT: + try { + if (reader.getName().equals(SOURCE_URI)) { + uriString = reader.getElementText(); + if (uriString != null && uriString.trim().length() > 0) { + QualifiedName name = new QualifiedName(uriString); + if (name.getPortName() == null) { + sourceURI = new URI(uriString); + } else { + sourceURI = new URI(name.getPartName() + "#" + name.getPortName()); + } + } else { + throw new InvalidWireException("Wire source not defined"); + } + } else if (reader.getName().equals(TARGET_URI)) { + uriString = reader.getElementText(); + if (uriString != null && uriString.trim().length() > 0) { + QualifiedName name = new QualifiedName(uriString); + if (name.getPortName() == null) { + targetURI = new URI(uriString); + } else { + targetURI = new URI(name.getPartName() + "#" + name.getPortName()); + } + } else { + throw new InvalidWireException("Wire target not defined"); + } + } else { + QName name = reader.getName(); + throw new InvalidWireException("Unrecognized element in wire ", name.toString()); + } + } catch (URISyntaxException e) { + throw new InvalidWireException("Invalid wire uri", e); + } + + reader.next(); + break; + case END_ELEMENT: + if (reader.getName().equals(WIRE)) { + if (sourceURI != null && targetURI != null) { + wireDefn = new WireDefinition(); + wireDefn.setSource(sourceURI); + wireDefn.setTarget(targetURI); + } else { + throw new InvalidWireException("Incomplete wire definition"); + } + return wireDefn; + } + } + } + } +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/monitor/DefaultExceptionFormatter.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/monitor/DefaultExceptionFormatter.java new file mode 100644 index 0000000000..14468061e3 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/monitor/DefaultExceptionFormatter.java @@ -0,0 +1,54 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.monitor; + +import java.io.PrintWriter; + +import org.apache.tuscany.api.TuscanyException; +import org.apache.tuscany.api.TuscanyRuntimeException; +import org.apache.tuscany.host.monitor.ExceptionFormatter; + +/** + * Performs basics formatting of exceptions for JDK logging + * + * @version $Rev$ $Date$ + */ +public class DefaultExceptionFormatter implements ExceptionFormatter { + + public DefaultExceptionFormatter() { + } + + public boolean canFormat(Class type) { + return Throwable.class.isAssignableFrom(type); + } + + public PrintWriter write(PrintWriter writer, Throwable exception) { + if (exception instanceof TuscanyException) { + TuscanyException e = (TuscanyException) exception; + e.appendBaseMessage(writer); + } else if (exception instanceof TuscanyRuntimeException) { + TuscanyRuntimeException e = (TuscanyRuntimeException) exception; + e.appendBaseMessage(writer); + } + writer.append("\n"); + return writer; + } + + +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/monitor/InvalidLevelException.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/monitor/InvalidLevelException.java new file mode 100644 index 0000000000..cf07b0f914 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/monitor/InvalidLevelException.java @@ -0,0 +1,64 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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.monitor; + +/** + * Exception indicating an invalid log level has been passed. + * + * @version $Rev$ $Date$ + */ +public class InvalidLevelException extends IllegalArgumentException { + private static final long serialVersionUID = 7767234706427841915L; + private final String method; + private final String level; + + /** + * Constructor specifying the method name and the level affected. + * + * @param method the name of the method being monitored + * @param level the invalid log level value + */ + public InvalidLevelException(String method, String level) { + super(); + this.method = method; + this.level = level; + } + + /** + * Returns the name of the method being monitored. + * + * @return the name of the method being monitored + */ + public String getMethod() { + return method; + } + + /** + * Returns the invalid log level specified. + * + * @return the invalid log level that was specified + */ + public String getLevel() { + return level; + } + + public String getMessage() { + return "Invalid level for method " + method + " : " + level; + } +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/monitor/JavaLoggingMonitorFactory.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/monitor/JavaLoggingMonitorFactory.java new file mode 100644 index 0000000000..4adff1b0db --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/monitor/JavaLoggingMonitorFactory.java @@ -0,0 +1,120 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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.monitor; + +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; +import java.util.ResourceBundle; +import java.util.logging.Level; +import java.util.logging.LogRecord; +import java.util.logging.Logger; + +import org.osoa.sca.annotations.Service; + +import org.apache.tuscany.host.MonitorFactory; +import org.apache.tuscany.host.monitor.FormatterRegistry; + +/** + * A factory for monitors that forwards events to a {@link java.util.logging.Logger Java Logging (JSR47) Logger}. + * + * @version $Rev$ $Date$ + * @see java.util.logging + */ +@Service(interfaces = {MonitorFactory.class, FormatterRegistry.class}) +public class JavaLoggingMonitorFactory extends ProxyMonitorFactory { + + /** + * Construct a MonitorFactory that will monitor the specified methods at the specified levels and generate messages + * using java.util.logging. + *

+ * The supplied Properties can be used to specify custom log levels for specific monitor methods. The key should be + * the method name in form returned by Class.getName() + '#' + Method.getName() and the value the log + * level to use as defined by {@link java.util.logging.Level}. + * + * @param levels definition of custom levels for specific monitored methods, may be null or empty. + * @param defaultLevel the default log level to use + * @param bundleName the name of a resource bundle that will be passed to the logger + * @see java.util.logging.Logger + */ + public JavaLoggingMonitorFactory(Properties levels, Level defaultLevel, String bundleName) { + Map configProperties = new HashMap(); + configProperties.put("levels", levels); + configProperties.put("defaultLevel", defaultLevel); + configProperties.put("bundleName", bundleName); + initInternal(configProperties); + } + + /** + * Constructs a MonitorFactory that needs to be subsequently configured via a call to {@link #initialize}. + */ + public JavaLoggingMonitorFactory() { + } + + protected InvocationHandler createInvocationHandler(Class monitorInterface, + Map levels) { + ResourceBundle bundle = locateBundle(monitorInterface, bundleName); + Logger logger = Logger.getLogger(monitorInterface.getName()); + return new LoggingHandler(logger, levels, bundle); + } + + private class LoggingHandler implements InvocationHandler { + private final Logger logger; + private final Map methodLevels; + private final ResourceBundle bundle; + + public LoggingHandler(Logger logger, + Map methodLevels, + ResourceBundle bundle + ) { + this.logger = logger; + this.methodLevels = methodLevels; + this.bundle = bundle; + } + + 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; + + LogRecord logRecord = new LogRecord(level, key); + logRecord.setLoggerName(className); + logRecord.setSourceClassName(className); + logRecord.setSourceMethodName(sourceMethod); + logRecord.setParameters(args); + if (args != null) { + for (Object o : args) { + if (o instanceof Throwable) { + logRecord.setMessage(formatException((Throwable) o)); + break; + } + } + } + logRecord.setResourceBundle(bundle); + logger.log(logRecord); + } + return null; + } + } +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/monitor/MonitorFactoryUtil.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/monitor/MonitorFactoryUtil.java new file mode 100644 index 0000000000..92224d469f --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/monitor/MonitorFactoryUtil.java @@ -0,0 +1,78 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.monitor; + +import org.apache.tuscany.host.MonitorFactory; + +import java.util.Map; + +/** + * Helper for creating MonitorFactory instances. + * + * @version $$Rev$$ $$Date$$ + */ + +public final class MonitorFactoryUtil { + /** + * Hide the constructor + */ + private MonitorFactoryUtil() { + } + + /** + * Creates a MonitorFactory instance of the specified type. + * @param name fully qualified classname of the desired MonitorFactory type + * @param props collection of initialization properties + * @return a configured MonitorFactory instance, or null if the factory could not be instantiated. + */ + @SuppressWarnings("unchecked") + public static MonitorFactory createMonitorFactory(String name, Map props) { + Class clazz; + try { + clazz = (Class) Class.forName(name); + } catch (ClassNotFoundException cnfe) { + return null; + } catch (ClassCastException cce) { + return null; + } + + return createMonitorFactory(clazz, props); + } + + /** + * Creates a MonitorFactory instance of the specified type. + * @param mfc class of the desired MonitorFactory type + * @param props collection of initialization properties + * @return a configured MonitorFactory instance, or null if the factory could not be instantiated. + */ + public static MonitorFactory createMonitorFactory(Class mfc, Map props) { + MonitorFactory mf; + try { + mf = mfc.newInstance(); + mf.initialize(props); + } catch (InstantiationException e) { + throw new AssertionError(e); + } catch (IllegalAccessException e) { + throw new AssertionError(e); + } + // allow IllegalArgumentException to propogate out + + return mf; + } +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/monitor/NullMonitorFactory.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/monitor/NullMonitorFactory.java new file mode 100644 index 0000000000..46c52e38f6 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/monitor/NullMonitorFactory.java @@ -0,0 +1,68 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.monitor; + +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Method; +import java.lang.reflect.Proxy; +import java.util.Map; + +import org.osoa.sca.annotations.EagerInit; + +import org.apache.tuscany.host.MonitorFactory; +import org.apache.tuscany.host.monitor.ExceptionFormatter; + +/** + * Implementation of a {@link MonitorFactory} that produces implementations that simply return. + * + * @version $Rev$ $Date$ + */ +@EagerInit +public class NullMonitorFactory implements MonitorFactory { + + /** + * Singleton hander that does nothing. + */ + private static final InvocationHandler NULL_MONITOR = new InvocationHandler() { + public Object invoke(Object proxy, Method method, Object[] args) { + return null; + } + }; + + public void initialize(Map configProperties) { + } + + public T getMonitor(Class 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)); + } + + public void register(ExceptionFormatter formatter) { + + } + + public void unregister(ExceptionFormatter formatter) { + + } +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/monitor/ProxyMonitorFactory.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/monitor/ProxyMonitorFactory.java new file mode 100644 index 0000000000..d9ca9e6cfc --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/monitor/ProxyMonitorFactory.java @@ -0,0 +1,234 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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.monitor; + +import java.util.Map; +import java.util.Properties; +import java.util.HashMap; +import java.util.ResourceBundle; +import java.util.Locale; +import java.util.MissingResourceException; +import java.util.List; +import java.util.ArrayList; +import java.util.WeakHashMap; +import java.util.logging.Level; +import java.lang.ref.WeakReference; +import java.lang.reflect.Method; +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Proxy; +import java.io.PrintWriter; +import java.io.StringWriter; + +import org.apache.tuscany.host.MonitorFactory; +import org.apache.tuscany.host.monitor.FormatterRegistry; +import org.apache.tuscany.host.monitor.ExceptionFormatter; +import org.apache.tuscany.api.annotation.LogLevel; + +/** + * @version $Rev$ $Date$ + */ +public abstract class ProxyMonitorFactory implements MonitorFactory, FormatterRegistry { + protected String bundleName; + protected final List formatters = new ArrayList(); + protected final ExceptionFormatter defaultFormatter = new DefaultExceptionFormatter(); + protected Level defaultLevel; + protected Map levels; + private final Map, WeakReference> proxies = new WeakHashMap, WeakReference>(); + + public void initialize(Map configProperties) { + if (configProperties == null) { + return; + } + initInternal(configProperties); + } + + protected void initInternal(Map configProperties) { + try { + this.defaultLevel = (Level) configProperties.get("defaultLevel"); + this.bundleName = (String) configProperties.get("bundleName"); + Properties levels = (Properties) configProperties.get("levels"); + + this.levels = new HashMap(); + if (levels != null) { + for (Map.Entry entry : levels.entrySet()) { + 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); + } + } + } + } catch (ClassCastException cce) { + throw new IllegalArgumentException(cce.getLocalizedMessage()); + } + } + + public synchronized T getMonitor(Class monitorInterface) { + T proxy = getCachedMonitor(monitorInterface); + if (proxy == null) { + proxy = createMonitor(monitorInterface); + proxies.put(monitorInterface, new WeakReference(proxy)); + } + return proxy; + } + + protected T getCachedMonitor(Class monitorInterface) { + WeakReference ref = proxies.get(monitorInterface); + return (ref != null) ? monitorInterface.cast(ref.get()) : null; + } + + protected T createMonitor(Class monitorInterface) { + String className = monitorInterface.getName(); + Method[] methods = monitorInterface.getMethods(); + Map levels = new HashMap(methods.length); + for (Method method : methods) { + String key = className + '#' + method.getName(); + Level level = null; + if (this.levels != null) { + 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) { + level = defaultLevel; + } + levels.put(method.getName(), level); + } + + InvocationHandler handler = createInvocationHandler(monitorInterface, levels); + Object proxy = Proxy.newProxyInstance(monitorInterface.getClassLoader(), + new Class[]{monitorInterface}, + handler); + return monitorInterface.cast(proxy); + } + + protected ResourceBundle locateBundle(Class monitorInterface, String bundleName) { + Locale locale = Locale.getDefault(); + ClassLoader cl = monitorInterface.getClassLoader(); + String packageName = monitorInterface.getPackage().getName(); + while (true) { + try { + return ResourceBundle.getBundle(packageName + '.' + bundleName, locale, cl); + } catch (MissingResourceException e) { + //ok + } + int index = packageName.lastIndexOf('.'); + if (index == -1) { + break; + } + packageName = packageName.substring(0, index); + } + try { + return ResourceBundle.getBundle(bundleName, locale, cl); + } catch (Exception e) { + return null; + } + } + + public void register(ExceptionFormatter formatter) { + formatters.add(formatter); + } + + public void unregister(ExceptionFormatter formatter) { + formatters.remove(formatter); + } + + protected abstract InvocationHandler createInvocationHandler(Class monitorInterface, + Map levels); + + protected String formatException(Throwable e) { + ExceptionFormatter formatter = defaultFormatter; + for (ExceptionFormatter candidate : formatters) { + if (candidate.canFormat(e.getClass())) { + formatter = candidate; + break; + } + } + StringWriter writer = new StringWriter(); + PrintWriter pw = new PrintWriter(writer); + formatter.write(pw, e); + format(pw, e); + pw.close(); + return writer.toString(); + } + + protected void format(PrintWriter writer, Throwable throwable) { + writer.println(throwable.getClass().getName()); + StackTraceElement[] trace = throwable.getStackTrace(); + for (StackTraceElement aTrace : trace) { + writer.println("\tat " + aTrace); + } + Throwable ourCause = throwable.getCause(); + + if (ourCause != null) { + printStackTraceAsCause(writer, ourCause, trace); + } + } + + protected void printStackTraceAsCause(PrintWriter pw, + Throwable throwable, + StackTraceElement[] causedTrace) { + + // Compute number of frames in common between this and caused + StackTraceElement[] trace = throwable.getStackTrace(); + int m = trace.length - 1; + int n = causedTrace.length - 1; + while (m >= 0 && n >= 0 && trace[m].equals(causedTrace[n])) { + m--; + n--; + } + int framesInCommon = trace.length - 1 - m; + + pw.println("Caused by: " + throwable.getClass().getName()); + + ExceptionFormatter formatter = defaultFormatter; + for (ExceptionFormatter candidate : formatters) { + if (candidate.canFormat(throwable.getClass())) { + formatter = candidate; + break; + } + } + formatter.write(pw, throwable); + + for (int i = 0; i <= m; i++) { + pw.println("\tat " + trace[i]); + } + if (framesInCommon != 0) { + pw.println("\t... " + framesInCommon + " more"); + } + + // Recurse if we have a cause + Throwable ourCause = throwable.getCause(); + if (ourCause != null) { + printStackTraceAsCause(pw, ourCause, trace); + } + } +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/resolver/AutowireResolver.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/resolver/AutowireResolver.java new file mode 100644 index 0000000000..8502f8d5f8 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/resolver/AutowireResolver.java @@ -0,0 +1,64 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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.resolver; + +import java.net.URI; + +import org.apache.tuscany.spi.model.ComponentDefinition; +import org.apache.tuscany.spi.model.CompositeComponentType; +import org.apache.tuscany.spi.model.Implementation; +import org.apache.tuscany.spi.model.ServiceContract; +import org.apache.tuscany.spi.resolver.ResolutionException; + +/** + * Implementations are responsible for resolving autowire targets in an SCA Domain. It is assumed that autowire + * resolution occurs after resource resolution as service interface classes may be laoded + * + * @version $Rev$ $Date$ + */ +public interface AutowireResolver { + + /** + * Resolves autowires for a component definition and its decendents + * + * @param parentDefinition the parent + * @param definition the component definition to resolve autowires for + * @throws ResolutionException + */ + void resolve(ComponentDefinition>> parentDefinition, + ComponentDefinition> definition) throws ResolutionException; + + /** + * Resolves autowires for a composite component type and its decendents + * + * @param compositeType the component type to resolve autowires for + * @throws ResolutionException + */ + @SuppressWarnings({"unchecked"}) + public void resolve(CompositeComponentType compositeType) throws ResolutionException; + + /** + * Adds the uri of a host system service that can be an autowire target + * + * @param contract the service contract of the system service + * @param uri the component uri + */ + void addHostUri(ServiceContract contract, URI uri); + +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/resolver/AutowireTargetNotFoundException.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/resolver/AutowireTargetNotFoundException.java new file mode 100644 index 0000000000..1526724ca9 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/resolver/AutowireTargetNotFoundException.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.resolver; + +import org.apache.tuscany.spi.resolver.ResolutionException; + +/** + * @version $Rev$ $Date$ + */ +public class AutowireTargetNotFoundException extends ResolutionException { + public AutowireTargetNotFoundException(String message, String identifier) { + super(message, identifier); + } +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/resolver/DefaultAutowireResolver.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/resolver/DefaultAutowireResolver.java new file mode 100644 index 0000000000..eab78e25d9 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/resolver/DefaultAutowireResolver.java @@ -0,0 +1,181 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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.resolver; + +import java.net.URI; +import java.util.HashMap; +import java.util.Map; + +import org.apache.tuscany.spi.model.ComponentDefinition; +import org.apache.tuscany.spi.model.ComponentType; +import org.apache.tuscany.spi.model.CompositeComponentType; +import org.apache.tuscany.spi.model.Implementation; +import org.apache.tuscany.spi.model.ReferenceDefinition; +import org.apache.tuscany.spi.model.ReferenceTarget; +import org.apache.tuscany.spi.model.ServiceContract; +import org.apache.tuscany.spi.model.ServiceDefinition; +import org.apache.tuscany.spi.resolver.ResolutionException; + +/** + * Default implementation of an autowire resolver + * + * @version $Rev$ $Date$ + */ +public class DefaultAutowireResolver implements AutowireResolver { + private Map hostAutowire = new HashMap(); + + + @SuppressWarnings({"unchecked"}) + public void resolve(ComponentDefinition>> parentDefinition, + ComponentDefinition> definition) + throws ResolutionException { + ComponentType type = definition.getImplementation().getComponentType(); + // resolve autowires + if (type instanceof CompositeComponentType) { + CompositeComponentType compositeType = (CompositeComponentType) type; + for (ComponentDefinition> child : compositeType.getComponents().values()) { + Implementation implementation = child.getImplementation(); + ComponentType childType = implementation.getComponentType(); + if (childType instanceof CompositeComponentType) { + // recurse decendents for composites + resolve((ComponentDefinition>>) definition, child); + } + Map targets = child.getReferenceTargets(); + for (ReferenceDefinition reference : childType.getReferences().values()) { + ReferenceTarget target = targets.get(reference.getUri().getFragment()); + if (target == null) { + continue; + } + if (target.isAutowire()) { + ServiceContract requiredContract = reference.getServiceContract(); + resolve(compositeType, requiredContract, target, reference.isRequired()); + } + } + } + } else { + // a leaf level component + ComponentType componentType = definition.getImplementation().getComponentType(); + Map targets = definition.getReferenceTargets(); + for (ReferenceDefinition reference : componentType.getReferences().values()) { + ReferenceTarget target = targets.get(reference.getUri().getFragment()); + if (target == null) { + continue; + } + if (target.isAutowire()) { + ServiceContract requiredContract = reference.getServiceContract(); + CompositeComponentType ctype = parentDefinition.getImplementation().getComponentType(); + resolve(ctype, requiredContract, target, reference.isRequired()); + } + } + } + } + + public void addHostUri(ServiceContract contract, URI uri) { + hostAutowire.put(contract, uri); + } + + public void resolve(CompositeComponentType compositeType) throws ResolutionException { + for (ComponentDefinition> child : compositeType.getComponents().values()) { + Implementation implementation = child.getImplementation(); + ComponentType childType = implementation.getComponentType(); + if (childType instanceof CompositeComponentType) { + // recurse decendents for composites + resolve(null, child); + } + Map targets = child.getReferenceTargets(); + for (ReferenceDefinition reference : childType.getReferences().values()) { + ReferenceTarget target = targets.get(reference.getUri().getFragment()); + if (target == null) { + continue; + } + if (target.isAutowire()) { + ServiceContract requiredContract = reference.getServiceContract(); + resolve(compositeType, requiredContract, target, reference.isRequired()); + } + } + } + } + /** + * Performs the actual resolution against a composite TODO this should be extensible allowing for path + * optimizations + * + * @param compositeType the composite component type to resolve against + * @param requiredContract the required target contract + * @param target the reference target + * @param required true if the autowire is required + * @throws AutowireTargetNotFoundException + * + */ + private void resolve(CompositeComponentType compositeType, + ServiceContract requiredContract, + ReferenceTarget target, + boolean required) throws AutowireTargetNotFoundException { + // for now, attempt to match on interface, assume the class can be loaded + Class requiredInterface = requiredContract.getInterfaceClass(); + if (requiredInterface == null) { + throw new UnsupportedOperationException("Only interfaces support for autowire"); + } + // autowire to a target in the parent + URI targetUri = null; + URI candidateUri = null; + // find a suitable target, starting with components first + for (ComponentDefinition> candidate : compositeType.getComponents().values()) { + Implementation candidateImpl = candidate.getImplementation(); + ComponentType candidateType = candidateImpl.getComponentType(); + for (ServiceDefinition service : candidateType.getServices().values()) { + Class serviceInterface = service.getServiceContract().getInterfaceClass(); + if (serviceInterface == null) { + continue; + } + if (requiredInterface.equals(serviceInterface)) { + targetUri = URI.create(candidate.getUri().toString() + service.getUri()); + break; + } else if (candidateUri == null && requiredInterface.isAssignableFrom(serviceInterface)) { + candidateUri = URI.create(candidate.getUri().toString() + service.getUri()); + } + } + if (targetUri != null) { + break; + } + } + if (targetUri == null) { + targetUri = resolvePrimordial(requiredContract); + } + if (candidateUri != null) { + targetUri = candidateUri; + } + if (targetUri != null) { + target.addTarget(targetUri); + } + if (targetUri == null && required) { + String uri = target.getReferenceName().toString(); + throw new AutowireTargetNotFoundException("No suitable target found for", uri); + } + } + + private URI resolvePrimordial(ServiceContract contract) { + Class requiredClass = contract.getInterfaceClass(); + for (Map.Entry entry : hostAutowire.entrySet()) { + if (requiredClass.isAssignableFrom(entry.getKey().getInterfaceClass())) { + return entry.getValue(); + } + } + return null; + } +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/runtime/AbstractRuntime.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/runtime/AbstractRuntime.java new file mode 100644 index 0000000000..4a9cbb1ff5 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/runtime/AbstractRuntime.java @@ -0,0 +1,379 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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 static org.apache.tuscany.spi.bootstrap.ComponentNames.TUSCANY_DEPLOYER; +import static org.apache.tuscany.spi.bootstrap.ComponentNames.TUSCANY_SYSTEM; +import static org.apache.tuscany.spi.bootstrap.ComponentNames.TUSCANY_SYSTEM_ROOT; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.URI; +import java.net.URL; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Enumeration; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import javax.xml.stream.XMLInputFactory; + +import org.apache.tuscany.core.bootstrap.Bootstrapper; +import org.apache.tuscany.core.bootstrap.DefaultBootstrapper; +import org.apache.tuscany.core.bootstrap.ExtensionActivator; +import org.apache.tuscany.core.builder.ConnectorImpl; +import org.apache.tuscany.core.component.ComponentManagerImpl; +import org.apache.tuscany.core.component.SimpleWorkContext; +import org.apache.tuscany.core.component.scope.CompositeScopeContainer; +import org.apache.tuscany.core.component.scope.ScopeRegistryImpl; +import org.apache.tuscany.core.deployer.DeployerImpl; +import org.apache.tuscany.core.monitor.NullMonitorFactory; +import org.apache.tuscany.core.resolver.AutowireResolver; +import org.apache.tuscany.core.resolver.DefaultAutowireResolver; +import org.apache.tuscany.core.services.classloading.ClassLoaderRegistryImpl; +import org.apache.tuscany.core.util.IOHelper; +import org.apache.tuscany.host.MonitorFactory; +import org.apache.tuscany.host.RuntimeInfo; +import org.apache.tuscany.host.management.ManagementService; +import org.apache.tuscany.host.monitor.FormatterRegistry; +import org.apache.tuscany.host.runtime.InitializationException; +import org.apache.tuscany.host.runtime.TuscanyRuntime; +import org.apache.tuscany.spi.builder.BuilderRegistry; +import org.apache.tuscany.spi.builder.Connector; +import org.apache.tuscany.spi.component.AtomicComponent; +import org.apache.tuscany.spi.component.Component; +import org.apache.tuscany.spi.component.ComponentManager; +import org.apache.tuscany.spi.component.RegistrationException; +import org.apache.tuscany.spi.component.ScopeContainerMonitor; +import org.apache.tuscany.spi.component.ScopeRegistry; +import org.apache.tuscany.spi.component.TargetResolutionException; +import org.apache.tuscany.spi.component.WorkContext; +import org.apache.tuscany.spi.deployer.Deployer; +import org.apache.tuscany.spi.idl.java.JavaServiceContract; +import org.apache.tuscany.spi.loader.LoaderRegistry; +import org.apache.tuscany.spi.services.classloading.ClassLoaderRegistry; +import org.apache.tuscany.spi.services.management.TuscanyManagementService; +import org.osoa.sca.ComponentContext; + +/** + * @version $Rev$ $Date$ + */ +public abstract class AbstractRuntime implements TuscanyRuntime { + private static final URI MONITOR_URI = TUSCANY_SYSTEM_ROOT.resolve("MonitorFactory"); + + private static final URI COMPONENT_MGR_URI = TUSCANY_SYSTEM_ROOT.resolve("ComponentManager"); + + private static final URI AUTOWIRE_RESOLVER_URI = TUSCANY_SYSTEM_ROOT.resolve("AutowireResolver"); + + private static final URI SCOPE_REGISTRY_URI = TUSCANY_SYSTEM_ROOT.resolve("ScopeRegistry"); + + private static final URI WORK_CONTEXT_URI = TUSCANY_SYSTEM.resolve("WorkContext"); + + private static final URI RUNTIME_INFO_URI = TUSCANY_SYSTEM_ROOT.resolve("RuntimeInfo"); + + private static final URI CLASSLOADER_REGISTRY_URI = TUSCANY_SYSTEM_ROOT.resolve("ClassLoaderRegistry"); + + private static final URI HOST_CLASSLOADER_ID = URI.create("sca://./hostClassLoader"); + + private static final URI BOOT_CLASSLOADER_ID = URI.create("sca://./bootClassLoader"); + + protected final XMLInputFactory xmlFactory; + protected URL systemScdl; + protected String applicationName; + protected URL applicationScdl; + protected Class runtimeInfoType; + protected ManagementService managementService; + + // primorial components automatically registered with the runtime + /** + * Information provided by the host about its runtime environment. + */ + protected I runtimeInfo; + + /** + * MonitorFactory provided by the host for directing events to its + * management framework. + */ + protected MonitorFactory monitorFactory; + + /** + * The ComponentManager that manages all components in this runtime. + */ + protected ComponentManager componentManager; + + /** + * Registry for ClassLoaders used by this runtime. + */ + protected ClassLoaderRegistry classLoaderRegistry; + + protected AutowireResolver resolver; + + protected Component systemComponent; + protected Component tuscanySystem; + + protected ScopeRegistry scopeRegistry; + protected Collection activators; + + protected AbstractRuntime(Class runtimeInfoType) { + this(runtimeInfoType, new NullMonitorFactory()); + } + + protected AbstractRuntime(Class runtimeInfoType, MonitorFactory monitorFactory) { + this.runtimeInfoType = runtimeInfoType; + this.monitorFactory = monitorFactory; + xmlFactory = XMLInputFactory.newInstance("javax.xml.stream.XMLInputFactory", getClass().getClassLoader()); + classLoaderRegistry = new ClassLoaderRegistryImpl(); + classLoaderRegistry.register(BOOT_CLASSLOADER_ID, getClass().getClassLoader()); + } + + public URL getSystemScdl() { + return systemScdl; + } + + public void setSystemScdl(URL systemScdl) { + this.systemScdl = systemScdl; + } + + public String getApplicationName() { + return applicationName; + } + + public void setApplicationName(String applicationName) { + this.applicationName = applicationName; + } + + public URL getApplicationScdl() { + return applicationScdl; + } + + public void setApplicationScdl(URL applicationScdl) { + this.applicationScdl = applicationScdl; + } + + public ClassLoader getHostClassLoader() { + return classLoaderRegistry.getClassLoader(HOST_CLASSLOADER_ID); + } + + public void setHostClassLoader(ClassLoader hostClassLoader) { + classLoaderRegistry.register(HOST_CLASSLOADER_ID, hostClassLoader); + } + + public I getRuntimeInfo() { + return runtimeInfo; + } + + public void setRuntimeInfo(I runtimeInfo) { + this.runtimeInfo = runtimeInfo; + } + + public MonitorFactory getMonitorFactory() { + return monitorFactory; + } + + public void setMonitorFactory(MonitorFactory monitorFactory) { + this.monitorFactory = monitorFactory; + } + + public ManagementService getManagementService() { + return managementService; + } + + public void setManagementService(ManagementService managementService) { + this.managementService = managementService; + } + + public void initialize() throws InitializationException { + // URI name = TUSCANY_SYSTEM_ROOT.resolve("main"); + Bootstrapper bootstrapper = createBootstrapper(); + Deployer deployer = bootstrapper.createDeployer(); + registerSystemComponent(TUSCANY_DEPLOYER, Deployer.class, deployer); + registerSystemComponent(WORK_CONTEXT_URI, WorkContext.class, new SimpleWorkContext()); + + this.scopeRegistry = bootstrapper.getScopeRegistry(); + + LoaderRegistry loaderRegistry = (LoaderRegistry)((DeployerImpl)deployer).getLoader(); + BuilderRegistry builderRegistry = (BuilderRegistry)((DeployerImpl)deployer).getBuilder(); + activators = getInstances(getHostClassLoader(), ExtensionActivator.class); + for (ExtensionActivator activator : activators) { + activator.start(loaderRegistry, builderRegistry); + } + + registerBaselineSystemComponents(); + } + + public void destroy() { + if (tuscanySystem != null) { + tuscanySystem.stop(); + tuscanySystem = null; + } + if (systemComponent != null) { + systemComponent.stop(); + systemComponent = null; + } + } + + public ComponentContext getComponentContext(URI componentId) { + Component component = componentManager.getComponent(componentId); + if (component == null) { + return null; + } + return component.getComponentContext(); + } + + protected Bootstrapper createBootstrapper() { + TuscanyManagementService tms = (TuscanyManagementService)getManagementService(); + resolver = new DefaultAutowireResolver(); + componentManager = new ComponentManagerImpl(tms, resolver); + Connector connector = new ConnectorImpl(componentManager); + return new DefaultBootstrapper(getMonitorFactory(), xmlFactory, componentManager, resolver, connector); + } + + protected void registerBaselineSystemComponents() throws InitializationException { + // register the RuntimeInfo provided by the host + registerSystemComponent(RUNTIME_INFO_URI, runtimeInfoType, runtimeInfo); + + // register the MonitorFactory provided by the host + List> monitorServices = new ArrayList>(); + monitorServices.add(MonitorFactory.class); + monitorServices.add(FormatterRegistry.class); + registerSystemComponent(MONITOR_URI, monitorServices, getMonitorFactory()); + + // register the ClassLoaderRegistry + registerSystemComponent(CLASSLOADER_REGISTRY_URI, ClassLoaderRegistry.class, classLoaderRegistry); + + // register the ComponentManager to that the fabric can wire to it + registerSystemComponent(COMPONENT_MGR_URI, ComponentManager.class, componentManager); + + // register the AutowireResolver + registerSystemComponent(AUTOWIRE_RESOLVER_URI, AutowireResolver.class, resolver); + + // register the ScopeRegistry + registerSystemComponent(SCOPE_REGISTRY_URI, ScopeRegistry.class, scopeRegistry); + } + + protected void registerSystemComponent(URI uri, Class type, I component) + throws InitializationException { + try { + JavaServiceContract contract = new JavaServiceContract(type); + componentManager.registerJavaObject(uri, contract, component); + } catch (RegistrationException e) { + throw new InitializationException(e); + } + } + + protected void registerSystemComponent(URI uri, List> types, I component) + throws InitializationException { + try { + List> contracts = new ArrayList>(); + for (Class type : types) { + contracts.add(new JavaServiceContract(type)); + + } + componentManager.registerJavaObject(uri, contracts, component); + } catch (RegistrationException e) { + throw new InitializationException(e); + } + } + + protected ComponentManager getComponentManager() { + return componentManager; + } + + protected ScopeRegistry getScopeRegistry() { + return scopeRegistry; + } + + protected WorkContext getWorkContext() { + try { + AtomicComponent component = (AtomicComponent)getComponentManager().getComponent(WORK_CONTEXT_URI); + return (WorkContext)component.getTargetInstance(); + } catch (TargetResolutionException e) { + throw new AssertionError(e); + } + } + + protected Deployer getDeployer() { + try { + AtomicComponent component = (AtomicComponent)getComponentManager().getComponent(TUSCANY_DEPLOYER); + return (Deployer)component.getTargetInstance(); + } catch (TargetResolutionException e) { + throw new AssertionError(e); + } + } + + /** + * Read the service name from a configuration file + * + * @param classLoader + * @param name The name of the service class + * @return A class name which extends/implements the service class + * @throws IOException + */ + private static Set getServiceNames(ClassLoader classLoader, String name) throws IOException { + Set set = new HashSet(); + Enumeration urls = classLoader.getResources("META-INF/services/" + name); + while (urls.hasMoreElements()) { + URL url = urls.nextElement(); + String service = getServiceName(url); + if (service != null) { + set.add(service); + + } + } + return set; + } + + private static String getServiceName(URL url) throws IOException { + InputStream is = IOHelper.getInputStream(url); + BufferedReader reader = null; + try { + reader = new BufferedReader(new InputStreamReader(is)); + while (true) { + String line = reader.readLine(); + if (line == null) { + break; + } else if (!line.startsWith("#")) { + return line.trim(); + } + } + } finally { + if (reader != null) { + reader.close(); + } + } + return null; + } + + private static Collection getInstances(final ClassLoader classLoader, Class serviceClass) { + List instances = new ArrayList(); + try { + Set services = getServiceNames(classLoader, serviceClass.getName()); + for (String className : services) { + Class cls = Class.forName(className, true, classLoader); + instances.add(serviceClass.cast(cls.newInstance())); // NOPMD + } + } catch (Exception e) { + throw new IllegalStateException(e); + } + return instances; + } +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/services/classloading/ClassLoaderRegistryImpl.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/services/classloading/ClassLoaderRegistryImpl.java new file mode 100644 index 0000000000..afa7f64246 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/services/classloading/ClassLoaderRegistryImpl.java @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.services.classloading; + +import java.net.URI; +import java.util.concurrent.ConcurrentHashMap; +import java.util.Map; + +import org.apache.tuscany.spi.services.classloading.ClassLoaderRegistry; +import org.apache.tuscany.spi.services.classloading.DuplicateClassLoaderException; + +/** + * Implementation of a registry for classloaders. + * + * @version $Rev$ $Date$ + */ +public class ClassLoaderRegistryImpl implements ClassLoaderRegistry { + private final Map registry = new ConcurrentHashMap(); + + public synchronized void register(URI id, ClassLoader classLoader) throws DuplicateClassLoaderException { + if (registry.containsKey(id)) { + throw new DuplicateClassLoaderException("Duplicate class loader", id.toString()); + } + registry.put(id, classLoader); + } + + public ClassLoader getClassLoader(URI id) { + return registry.get(id); + } + + public ClassLoader unregister(URI id) { + return registry.remove(id); + } +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/services/store/memory/MemoryStore.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/services/store/memory/MemoryStore.java new file mode 100644 index 0000000000..a48cd5a2d7 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/services/store/memory/MemoryStore.java @@ -0,0 +1,198 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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.services.store.memory; + +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; + +import org.osoa.sca.annotations.Destroy; +import org.osoa.sca.annotations.EagerInit; +import org.osoa.sca.annotations.Init; +import org.osoa.sca.annotations.Property; +import org.osoa.sca.annotations.Service; + +import org.apache.tuscany.spi.component.SCAObject; +import org.apache.tuscany.spi.event.AbstractEventPublisher; +import org.apache.tuscany.spi.services.store.DuplicateRecordException; +import org.apache.tuscany.spi.services.store.RecoveryListener; +import org.apache.tuscany.spi.services.store.Store; +import org.apache.tuscany.spi.services.store.StoreExpirationEvent; +import org.apache.tuscany.spi.services.store.StoreMonitor; +import org.apache.tuscany.spi.services.store.StoreWriteException; + +import org.apache.tuscany.api.annotation.Monitor; + +/** + * Implements a non-durable, non-transactional store using a simple in-memory map + * + * @version $Rev$ $Date$ + */ +@Service(Store.class) +@EagerInit +public class MemoryStore extends AbstractEventPublisher implements Store { + private Map> store; + // TODO integrate with a core threading scheme + private ScheduledExecutorService scheduler; + private long reaperInterval = 300000; + private StoreMonitor monitor; + private long defaultExpirationOffset = 600000; // 10 minutes + + public MemoryStore(@Monitor StoreMonitor monitor) { + this.monitor = monitor; + this.store = new ConcurrentHashMap>(); + this.scheduler = Executors.newSingleThreadScheduledExecutor(); + } + + /** + * Returns the maximum default expiration offset for records in the store + * + * @return the maximum default expiration offset for records in the store + */ + public long getDefaultExpirationOffset() { + return defaultExpirationOffset; + } + + /** + * Sets the maximum default expiration offset for records in the store + */ + @Property + public void setDefaultExpirationOffset(long defaultExpirationOffset) { + this.defaultExpirationOffset = defaultExpirationOffset; + } + + /** + * Sets the interval for expired entry scanning to be performed + */ + @Property + public void setReaperInterval(long reaperInterval) { + this.reaperInterval = reaperInterval; + } + + public long getReaperInterval() { + return reaperInterval; + } + + @Init + public void init() { + scheduler.scheduleWithFixedDelay(new Reaper(), reaperInterval, reaperInterval, TimeUnit.MILLISECONDS); + monitor.start("In-memory store started"); + } + + @Destroy + public void destroy() { + scheduler.shutdown(); + monitor.stop("In-memory store stopped"); + } + + public void insertRecord(SCAObject owner, String id, Object object, long expiration) throws StoreWriteException { + Map map = store.get(owner); + if (map == null) { + map = new ConcurrentHashMap(); + store.put(owner, map); + } + if (map.containsKey(id)) { + throw new DuplicateRecordException(owner.getUri().toString(), id); + } + map.put(id, new Record(object, expiration)); + } + + public void updateRecord(SCAObject owner, String id, Object object, long expiration) throws StoreWriteException { + Map map = store.get(owner); + if (map == null) { + throw new StoreWriteException("Record not found", owner.getUri().toString(), id); + } + Record record = map.get(id); + if (record == null) { + throw new StoreWriteException("Record not found", owner.getUri().toString(), id); + } + record.data = object; + } + + public Object readRecord(SCAObject owner, String id) { + Map map = store.get(owner); + if (map == null) { + return null; + } + Record record = map.get(id); + if (record != null) { + return record.data; + } + return null; + } + + public void removeRecords() { + store.clear(); + } + + public void removeRecord(SCAObject owner, String id) throws StoreWriteException { + Map map = store.get(owner); + if (map == null) { + throw new StoreWriteException("Owner not found", owner.getUri().toString(), id); + } + if (map.remove(id) == null) { + throw new StoreWriteException("Owner not found", owner.getUri().toString(), id); + } + } + + public void recover(RecoveryListener listener) { + throw new UnsupportedOperationException(); + } + + private class Record { + private Object data; + private long expiration = NEVER; + + public Record(Object data, long expiration) { + this.data = data; + this.expiration = expiration; + } + + public Object getData() { + return data; + } + + public long getExpiration() { + return expiration; + } + } + + private class Reaper implements Runnable { + + public void run() { + long now = System.currentTimeMillis(); + for (Map.Entry> entries : store.entrySet()) { + for (Map.Entry entry : entries.getValue().entrySet()) { + final long expiration = entry.getValue().expiration; + if (expiration != NEVER && now >= expiration) { + SCAObject owner = entries.getKey(); + Object instance = entry.getValue().getData(); + // notify listeners of the expiration + StoreExpirationEvent event = new StoreExpirationEvent(this, owner, instance); + publish(event); + entries.getValue().remove(entry.getKey()); + } + } + } + } + } + +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/util/FileHelper.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/util/FileHelper.java new file mode 100644 index 0000000000..2544c90846 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/util/FileHelper.java @@ -0,0 +1,704 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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.util; + +import java.io.File; +import java.io.FileFilter; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.net.URL; +import java.util.regex.Pattern; + +public class FileHelper { + /** + * The extension separator character. + */ + private static final char EXTENSION_SEPARATOR = '.'; + + /** + * The Unix separator character. + */ + private static final char UNIX_SEPARATOR = '/'; + + /** + * The Windows separator character. + */ + private static final char WINDOWS_SEPARATOR = '\\'; + + protected FileHelper() { + } + + /** + * Returns the index of the last directory separator character. + *

+ * This method will handle a file in either Unix or Windows format. The + * position of the last forward or backslash is returned. + *

+ * The output will be the same irrespective of the machine that the code is + * running on. + * + * @param filename the filename to find the last path separator in, null + * returns -1 + * @return the index of the last separator character, or -1 if there is no + * such character + */ + public static int indexOfLastSeparator(String filename) { + if (filename == null) { + return -1; + } + int lastUnixPos = filename.lastIndexOf(UNIX_SEPARATOR); + int lastWindowsPos = filename.lastIndexOf(WINDOWS_SEPARATOR); + return Math.max(lastUnixPos, lastWindowsPos); + } + + /** + * Returns the index of the last extension separator character, which is a + * dot. + *

+ * This method also checks that there is no directory separator after the + * last dot. To do this it uses {@link #indexOfLastSeparator(String)} which + * will handle a file in either Unix or Windows format. + *

+ * The output will be the same irrespective of the machine that the code is + * running on. + * + * @param filename the filename to find the last path separator in, null + * returns -1 + * @return the index of the last separator character, or -1 if there is no + * such character + */ + public static int indexOfExtension(String filename) { + if (filename == null) { + return -1; + } + int extensionPos = filename.lastIndexOf(EXTENSION_SEPARATOR); + int lastSeparator = indexOfLastSeparator(filename); + return lastSeparator > extensionPos ? -1 : extensionPos; + } + + /** + * Gets the name minus the path from a full filename. + *

+ * This method will handle a file in either Unix or Windows format. The text + * after the last forward or backslash is returned. + * + *

+     * a/b/c.txt --> c.txt
+     * a.txt     --> a.txt
+     * a/b/c     --> c
+     * a/b/c/    --> ""
+     * 
+ * + *

+ * The output will be the same irrespective of the machine that the code is + * running on. + * + * @param fileName the filename to query, null returns null + * @return the name of the file without the path, or an empty string if none + * exists + */ + public static String getName(String fileName) { + if (fileName == null) { + return null; + } + int index = indexOfLastSeparator(fileName); + return fileName.substring(index + 1); + } + + /** + * Gets the extension of a filename. + *

+ * This method returns the textual part of the filename after the last dot. + * There must be no directory separator after the dot. + * + *

+     * foo.txt      --> "txt"
+     * a/b/c.jpg    --> "jpg"
+     * a/b.txt/c    --> ""
+     * a/b/c        --> ""
+     * 
+ * + *

+ * The output will be the same irrespective of the machine that the code is + * running on. + * + * @param filename the filename to retrieve the extension of. + * @return the extension of the file or an empty string if none exists. + */ + public static String getExtension(String filename) { + if (filename == null) { + return null; + } + int index = indexOfExtension(filename); + if (index == -1) { + return ""; + } else { + return filename.substring(index + 1); + } + } + + /** + * Make a directory, including any necessary but nonexistent parent + * directories. If there already exists a file with specified name or the + * directory cannot be created then an exception is thrown. + * + * @param directory directory to create, not null + * @throws NullPointerException if the directory is null + * @throws IOException if the directory cannot be created + */ + public static void forceMkdir(File directory) throws IOException { + if (directory.exists()) { + if (directory.isFile()) { + String message = + "File " + directory + " exists and is " + "not a directory. Unable to create directory."; + throw new IOException(message); + } + } else { + if (!directory.mkdirs()) { + String message = "Unable to create directory " + directory; + throw new IOException(message); + } + } + } + + /** + * Delete a file. If file is a directory, delete it and all sub-directories. + *

+ * The difference between File.delete() and this method are: + *

    + *
  • A directory to be deleted does not have to be empty.
  • + *
  • You get exceptions when a file or directory cannot be deleted. + * (java.io.File methods returns a boolean)
  • + *
+ * + * @param file file or directory to delete, not null + * @throws NullPointerException if the directory is null + * @throws IOException in case deletion is unsuccessful + */ + public static void forceDelete(File file) throws IOException { + if (file.isDirectory()) { + deleteDirectory(file); + } else { + if (!file.exists()) { + throw new FileNotFoundException("File does not exist: " + file); + } + if (!file.delete()) { + String message = "Unable to delete file: " + file; + throw new IOException(message); + } + } + } + + /** + * Convert from a URL to a File. + *

+ * From version 1.1 this method will decode the URL. Syntax such as + * file:///my%20docs/file.txt will be correctly decoded to + * /my docs/file.txt. + * + * @param url the file URL to convert, null returns null + * @return the equivalent File object, or null + * if the URL's protocol is not file + * @throws IllegalArgumentException if the file is incorrectly encoded + */ + public static File toFile(URL url) { + if (url == null || !url.getProtocol().equals("file")) { + return null; + } else { + String filename = url.getFile().replace('/', File.separatorChar); + int pos = 0; + while ((pos = filename.indexOf('%', pos)) >= 0) { // NOPMD + if (pos + 2 < filename.length()) { + String hexStr = filename.substring(pos + 1, pos + 3); + char ch = (char)Integer.parseInt(hexStr, 16); + filename = filename.substring(0, pos) + ch + filename.substring(pos + 3); + } + } + return new File(filename); + } + } + + public static FileFilter getFileFilter(String regExp, boolean ignoreCase) { + return new RegExpFilter(regExp, ignoreCase); + } + + /** + * A regular-expression based resource filter + */ + public static class RegExpFilter implements FileFilter { + private Pattern pattern; + + public RegExpFilter(Pattern pattern) { + this.pattern = pattern; + } + + public RegExpFilter(String patternStr, boolean ignoreCase) { + this.pattern = Pattern.compile(patternStr, ignoreCase ? Pattern.CASE_INSENSITIVE : 0); + } + + public boolean accept(File file) { + return pattern.matcher(file.getName()).matches(); + } + + /** + * Convert wildcard into a regex pattern + * + * @param str + * @return + */ + public static RegExpFilter getWildcardFilter(String str, boolean ignoreCase) { + StringBuffer buffer = new StringBuffer(); + for (int i = 0; i < str.length(); i++) { + char ch = str.charAt(i); + if (ch == '?') { + buffer.append('.'); + } else if (ch == '*') { + buffer.append(".*"); + } else { + buffer.append(ch); + } + } + return new RegExpFilter(buffer.toString(), ignoreCase); + } + + } + + /** + * Clean a directory without deleting it. + * + * @param directory directory to clean + * @throws IOException in case cleaning is unsuccessful + */ + public static void cleanDirectory(File directory) throws IOException { + if (!directory.exists()) { + String message = directory + " does not exist"; + throw new IllegalArgumentException(message); + } + + if (!directory.isDirectory()) { + String message = directory + " is not a directory"; + throw new IllegalArgumentException(message); + } + + File[] files = directory.listFiles(); + if (files == null) { // null if security restricted + throw new IOException("Failed to list contents of " + directory); + } + + IOException exception = null; + for (int i = 0; i < files.length; i++) { + File file = files[i]; + try { + forceDelete(file); + } catch (IOException ioe) { + exception = ioe; + } + } + + if (null != exception) { + throw exception; + } + } + + /** + * Clean a directory without deleting it. + * + * @param directory directory to clean, must not be null + * @throws NullPointerException if the directory is null + * @throws IOException in case cleaning is unsuccessful + */ + private static void cleanDirectoryOnExit(File directory) throws IOException { + if (!directory.exists()) { + String message = directory + " does not exist"; + throw new IllegalArgumentException(message); + } + + if (!directory.isDirectory()) { + String message = directory + " is not a directory"; + throw new IllegalArgumentException(message); + } + + File[] files = directory.listFiles(); + if (files == null) { // null if security restricted + throw new IOException("Failed to list contents of " + directory); + } + + IOException exception = null; + for (int i = 0; i < files.length; i++) { + File file = files[i]; + try { + forceDeleteOnExit(file); + } catch (IOException ioe) { + exception = ioe; + } + } + + if (null != exception) { + throw exception; + } + } + + /** + * Copies a whole directory to a new location preserving the file dates. + *

+ * This method copies the specified directory and all its child directories + * and files to the specified destination. The destination is the new + * location and name of the directory. + *

+ * The destination directory is created if it does not exist. If the + * destination directory did exist, then this method merges the source with + * the destination, with the source taking precedence. + * + * @param srcDir an existing directory to copy, must not be + * null + * @param destDir the new directory, must not be null + * @throws NullPointerException if source or destination is + * null + * @throws IOException if source or destination is invalid + * @throws IOException if an IO error occurs during copying + * @since Commons IO 1.1 + */ + public static void copyDirectory(File srcDir, File destDir) throws IOException { + copyDirectory(srcDir, destDir, true); + } + + /** + * Copies a whole directory to a new location. + *

+ * This method copies the contents of the specified source directory to + * within the specified destination directory. + *

+ * The destination directory is created if it does not exist. If the + * destination directory did exist, then this method merges the source with + * the destination, with the source taking precedence. + * + * @param srcDir an existing directory to copy, must not be + * null + * @param destDir the new directory, must not be null + * @param preserveFileDate true if the file date of the copy should be the + * same as the original + * @throws NullPointerException if source or destination is + * null + * @throws IOException if source or destination is invalid + * @throws IOException if an IO error occurs during copying + * @since Commons IO 1.1 + */ + public static void copyDirectory(File srcDir, File destDir, boolean preserveFileDate) throws IOException { + if (srcDir == null) { + throw new NullPointerException("Source must not be null"); + } + if (destDir == null) { + throw new NullPointerException("Destination must not be null"); + } + if (!srcDir.exists()) { + throw new FileNotFoundException("Source '" + srcDir + "' does not exist"); + } + if (!srcDir.isDirectory()) { + throw new IOException("Source '" + srcDir + "' exists but is not a directory"); + } + if (srcDir.getCanonicalPath().equals(destDir.getCanonicalPath())) { + throw new IOException("Source '" + srcDir + "' and destination '" + destDir + "' are the same"); + } + doCopyDirectory(srcDir, destDir, preserveFileDate); + } + + // ----------------------------------------------------------------------- + /** + * Copies a directory to within another directory preserving the file dates. + *

+ * This method copies the source directory and all its contents to a + * directory of the same name in the specified destination directory. + *

+ * The destination directory is created if it does not exist. If the + * destination directory did exist, then this method merges the source with + * the destination, with the source taking precedence. + * + * @param srcDir an existing directory to copy, must not be + * null + * @param destDir the directory to place the copy in, must not be + * null + * @throws NullPointerException if source or destination is + * null + * @throws IOException if source or destination is invalid + * @throws IOException if an IO error occurs during copying + * @since Commons IO 1.2 + */ + public static void copyDirectoryToDirectory(File srcDir, File destDir) throws IOException { + if (srcDir == null) { + throw new NullPointerException("Source must not be null"); + } + if (!(srcDir.exists() && srcDir.isDirectory())) { + throw new IllegalArgumentException("Source '" + destDir + "' is not a directory"); + } + if (destDir == null) { + throw new NullPointerException("Destination must not be null"); + } + if (!(destDir.exists() && destDir.isDirectory())) { + throw new IllegalArgumentException("Destination '" + destDir + "' is not a directory"); + } + copyDirectory(srcDir, new File(destDir, srcDir.getName()), true); + } + + /** + * Copies a file to a new location preserving the file date. + *

+ * This method copies the contents of the specified source file to the + * specified destination file. The directory holding the destination file is + * created if it does not exist. If the destination file exists, then this + * method will overwrite it. + * + * @param srcFile an existing file to copy, must not be null + * @param destFile the new file, must not be null + * @throws NullPointerException if source or destination is + * null + * @throws IOException if source or destination is invalid + * @throws IOException if an IO error occurs during copying + * @see #copyFileToDirectory(File, File) + */ + public static void copyFile(File srcFile, File destFile) throws IOException { + copyFile(srcFile, destFile, true); + } + + /** + * Copies a file to a new location. + *

+ * This method copies the contents of the specified source file to the + * specified destination file. The directory holding the destination file is + * created if it does not exist. If the destination file exists, then this + * method will overwrite it. + * + * @param srcFile an existing file to copy, must not be null + * @param destFile the new file, must not be null + * @param preserveFileDate true if the file date of the copy should be the + * same as the original + * @throws NullPointerException if source or destination is + * null + * @throws IOException if source or destination is invalid + * @throws IOException if an IO error occurs during copying + * @see #copyFileToDirectory(File, File, boolean) + */ + public static void copyFile(File srcFile, File destFile, boolean preserveFileDate) throws IOException { + if (srcFile == null) { + throw new NullPointerException("Source must not be null"); + } + if (destFile == null) { + throw new NullPointerException("Destination must not be null"); + } + if (!srcFile.exists()) { + throw new FileNotFoundException("Source '" + srcFile + "' does not exist"); + } + if (srcFile.isDirectory()) { + throw new IOException("Source '" + srcFile + "' exists but is a directory"); + } + if (srcFile.getCanonicalPath().equals(destFile.getCanonicalPath())) { + throw new IOException("Source '" + srcFile + "' and destination '" + destFile + "' are the same"); + } + if (!(destFile.getParentFile() != null && destFile.getParentFile().exists())) { + if (!destFile.getParentFile().mkdirs()) { + throw new IOException("Destination '" + destFile + "' directory cannot be created"); + } + } + if (!(destFile.exists() && destFile.canWrite())) { + throw new IOException("Destination '" + destFile + "' exists but is read-only"); + } + doCopyFile(srcFile, destFile, preserveFileDate); + } + + // ----------------------------------------------------------------------- + /** + * Copies a file to a directory preserving the file date. + *

+ * This method copies the contents of the specified source file to a file of + * the same name in the specified destination directory. The destination + * directory is created if it does not exist. If the destination file + * exists, then this method will overwrite it. + * + * @param srcFile an existing file to copy, must not be null + * @param destDir the directory to place the copy in, must not be + * null + * @throws NullPointerException if source or destination is null + * @throws IOException if source or destination is invalid + * @throws IOException if an IO error occurs during copying + * @see #copyFile(File, File, boolean) + */ + public static void copyFileToDirectory(File srcFile, File destDir) throws IOException { + copyFileToDirectory(srcFile, destDir, true); + } + + /** + * Copies a file to a directory optionally preserving the file date. + *

+ * This method copies the contents of the specified source file to a file of + * the same name in the specified destination directory. The destination + * directory is created if it does not exist. If the destination file + * exists, then this method will overwrite it. + * + * @param srcFile an existing file to copy, must not be null + * @param destDir the directory to place the copy in, must not be + * null + * @param preserveFileDate true if the file date of the copy should be the + * same as the original + * @throws NullPointerException if source or destination is + * null + * @throws IOException if source or destination is invalid + * @throws IOException if an IO error occurs during copying + * @see #copyFile(File, File, boolean) + * @since Commons IO 1.3 + */ + public static void copyFileToDirectory(File srcFile, File destDir, boolean preserveFileDate) throws IOException { + if (destDir == null) { + throw new NullPointerException("Destination must not be null"); + } + if (!(destDir.exists() && destDir.isDirectory())) { + throw new IllegalArgumentException("Destination '" + destDir + "' is not a directory"); + } + copyFile(srcFile, new File(destDir, srcFile.getName()), preserveFileDate); + } + + // ----------------------------------------------------------------------- + /** + * Recursively delete a directory. + * + * @param directory directory to delete + * @throws IOException in case deletion is unsuccessful + */ + public static void deleteDirectory(File directory) throws IOException { + if (!directory.exists()) { + return; + } + + cleanDirectory(directory); + if (!directory.delete()) { + String message = "Unable to delete directory " + directory + "."; + throw new IOException(message); + } + } + + /** + * Recursively schedule directory for deletion on JVM exit. + * + * @param directory directory to delete, must not be null + * @throws NullPointerException if the directory is null + * @throws IOException in case deletion is unsuccessful + */ + private static void deleteDirectoryOnExit(File directory) throws IOException { + if (!directory.exists()) { + return; + } + + cleanDirectoryOnExit(directory); + directory.deleteOnExit(); + } + + /** + * Internal copy directory method. + * + * @param srcDir the validated source directory, must not be + * null + * @param destDir the validated destination directory, must not be + * null + * @param preserveFileDate whether to preserve the file date + * @throws IOException if an error occurs + * @since Commons IO 1.1 + */ + private static void doCopyDirectory(File srcDir, File destDir, boolean preserveFileDate) throws IOException { + if (destDir.exists()) { + if (!destDir.isDirectory()) { + throw new IOException("Destination '" + destDir + "' exists but is not a directory"); + } + } else { + if (!destDir.mkdirs()) { + throw new IOException("Destination '" + destDir + "' directory cannot be created"); + } + if (preserveFileDate) { + destDir.setLastModified(srcDir.lastModified()); + } + } + if (!destDir.canWrite()) { + throw new IOException("Destination '" + destDir + "' cannot be written to"); + } + // recurse + File[] files = srcDir.listFiles(); + if (files == null) { // null if security restricted + throw new IOException("Failed to list contents of " + srcDir); + } + for (int i = 0; i < files.length; i++) { + File copiedFile = new File(destDir, files[i].getName()); + if (files[i].isDirectory()) { + doCopyDirectory(files[i], copiedFile, preserveFileDate); + } else { + doCopyFile(files[i], copiedFile, preserveFileDate); + } + } + } + + /** + * Internal copy file method. + * + * @param srcFile the validated source file, must not be null + * @param destFile the validated destination file, must not be + * null + * @param preserveFileDate whether to preserve the file date + * @throws IOException if an error occurs + */ + private static void doCopyFile(File srcFile, File destFile, boolean preserveFileDate) throws IOException { + if (destFile.exists() && destFile.isDirectory()) { + throw new IOException("Destination '" + destFile + "' exists but is a directory"); + } + + FileInputStream input = new FileInputStream(srcFile); + try { + FileOutputStream output = new FileOutputStream(destFile); + try { + IOHelper.copy(input, output); + } finally { + IOHelper.closeQuietly(output); + } + } finally { + IOHelper.closeQuietly(input); + } + + if (srcFile.length() != destFile.length()) { + throw new IOException("Failed to copy full contents from '" + srcFile + "' to '" + destFile + "'"); + } + if (preserveFileDate) { + destFile.setLastModified(srcFile.lastModified()); + } + } + + /** + * Schedule a file to be deleted when JVM exits. If file is directory delete + * it and all sub-directories. + * + * @param file file or directory to delete, must not be null + * @throws NullPointerException if the file is null + * @throws IOException in case deletion is unsuccessful + */ + public static void forceDeleteOnExit(File file) throws IOException { + if (file.isDirectory()) { + deleteDirectoryOnExit(file); + } else { + file.deleteOnExit(); + } + } + +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/util/IOHelper.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/util/IOHelper.java new file mode 100644 index 0000000000..62a007bd05 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/util/IOHelper.java @@ -0,0 +1,182 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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.util; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.JarURLConnection; +import java.net.URL; +import java.util.jar.JarFile; + +public class IOHelper { + /** + * The default buffer size to use. + */ + private static final int DEFAULT_BUFFER_SIZE = 1024 * 4; + + protected IOHelper() { + + } + + /** + * Unconditionally close an InputStream. + *

+ * Equivalent to {@link InputStream#close()}, except any exceptions will be ignored. + * This is typically used in finally blocks. + * + * @param input the InputStream to close, may be null or already closed + */ + public static void closeQuietly(InputStream input) { + try { + if (input != null) { + input.close(); + } + } catch (IOException ioe) { + // ignore + } + } + + /** + * Unconditionally close an OutputStream. + *

+ * Equivalent to {@link OutputStream#close()}, except any exceptions will be ignored. + * This is typically used in finally blocks. + * + * @param output the OutputStream to close, may be null or already closed + */ + public static void closeQuietly(OutputStream output) { + try { + if (output != null) { + output.close(); + } + } catch (IOException ioe) { + // ignore + } + } + + /** + * Copy bytes from an InputStream to an + * OutputStream. + *

+ * This method buffers the input internally, so there is no need to use a + * BufferedInputStream. + * + * @param input the InputStream to read from + * @param output the OutputStream to write to + * @return the number of bytes copied + * @throws NullPointerException if the input or output is null + * @throws IOException if an I/O error occurs + * @since Commons IO 1.1 + */ + public static int copy(InputStream input, OutputStream output) throws IOException { + byte[] buffer = new byte[DEFAULT_BUFFER_SIZE]; + int count = 0; + int n = 0; + while (-1 != (n = input.read(buffer))) { // NOPMD + output.write(buffer, 0, n); + count += n; + } + return count; + } + + public static InputStream getInputStream(URL url) throws IOException { + return new SafeURLInputStream(url); + } + + /** + * This class is a workaround for URL stream issue as illustrated below. + * 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!/my.composite" We + * also need to turn off the JarFile cache. + * + * @see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4950148 + * + * @version $Rev$ $Date$ + */ + public static class SafeURLInputStream extends InputStream { + private JarFile jarFile; + private InputStream is; + + public SafeURLInputStream(URL url) throws IOException { + String protocol = url.getProtocol(); + if (protocol != null && (protocol.equals("jar"))) { + JarURLConnection connection = (JarURLConnection)url.openConnection(); + // We cannot use cache + connection.setUseCaches(false); + try { + is = connection.getInputStream(); + } catch (IOException e) { + throw e; + } + jarFile = connection.getJarFile(); + } else { + is = url.openStream(); + } + } + + public SafeURLInputStream(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/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/util/JavaIntrospectionHelper.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/util/JavaIntrospectionHelper.java new file mode 100644 index 0000000000..6b11725481 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/util/JavaIntrospectionHelper.java @@ -0,0 +1,439 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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.util; + +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; +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 final class JavaIntrospectionHelper { + + private static final Class[] EMPTY_CLASS_ARRY = new Class[0]; + + /** + * Hide the constructor + */ + private JavaIntrospectionHelper() { + } + + + /** + * Returns a collection of public, and protected fields declared by a class or one of its supertypes + */ + public static Set getAllPublicAndProtectedFields(Class clazz) { + return getAllPublicAndProtectedFields(clazz, new HashSet()); + } + + /** + * Recursively evaluates the type hierachy to return all fields that are public or protected + */ + private static Set getAllPublicAndProtectedFields(Class clazz, Set fields) { + if (clazz == null || clazz.isArray() || Object.class.equals(clazz)) { + return fields; + } + fields = getAllPublicAndProtectedFields(clazz.getSuperclass(), fields); + Field[] declaredFields = clazz.getDeclaredFields(); + for (Field field : declaredFields) { + int modifiers = field.getModifiers(); + if ((Modifier.isPublic(modifiers) || Modifier.isProtected(modifiers)) && !Modifier.isStatic(modifiers)) { + field.setAccessible(true); // ignore Java accessibility + fields.add(field); + } + } + return fields; + } + + /** + * Returns a collection of public and protected 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).

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 getAllUniquePublicProtectedMethods(Class clazz) { + return getAllUniqueMethods(clazz, new HashSet()); + } + + /** + * Recursively evaluates the type hierarchy to return all unique methods + */ + private static Set getAllUniqueMethods(Class pClass, Set 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 (Method declaredMethod : declaredMethods) { + int modifiers = declaredMethod.getModifiers(); + if ((!Modifier.isPublic(modifiers) && !Modifier.isProtected(modifiers)) || Modifier.isStatic(modifiers)) { + continue; + } + if (methods.size() == 0) { + methods.add(declaredMethod); + } 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(declaredMethod, method)) { + matched = true; + break; + } + } + if (!matched) { + // TODO ignore Java accessibility + declaredMethod.setAccessible(true); + temp.add(declaredMethod); + } + 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 + */ + public static Field findClosestMatchingField(String name, Class type, Set 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 + */ + public static Method findClosestMatchingMethod(String name, Class[] types, Set 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; + } + } + + /** + * Searches a collection of fields for one that matches by name and has a multiplicity type. i.e. a List or Array of + * interfaces + * + * @return a matching field or null + */ + public static Field findMultiplicityFieldByName(String name, Set fields) { + for (Field candidate : fields) { + if (candidate.getName().equals(name) + && (List.class.isAssignableFrom(candidate.getType()) || (candidate.getType().isArray() + && candidate.getType().getComponentType() != null && candidate.getType().getComponentType() + .isInterface()))) { + return candidate; + } + } + return null; + } + + /** + * Searches a collection of method for one that matches by name and has single parameter of a multiplicity type. + * i.e. a List or Array of interfaces + * + * @return a matching method or null + */ + public static Method findMultiplicityMethodByName(String name, Set methods) { + for (Method candidate : methods) { + if (candidate.getName().equals(name) + && candidate.getParameterTypes().length == 1 + && (List.class.isAssignableFrom(candidate.getParameterTypes()[0]) + || (candidate.getParameterTypes()[0].isArray() + && candidate.getParameterTypes()[0].getComponentType() != null + && candidate.getParameterTypes()[0].getComponentType().isInterface()))) { + return candidate; + } + } + 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 the implmentation class + */ + 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 foo is returned as getFoo + */ + 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, setFoo(var) is returned as property foo + */ + public static String toPropertyName(String name) { + if (!name.startsWith("set")) { + return name; + } + return Character.toLowerCase(name.charAt(3)) + name.substring(4); + } + + /** + * Takes a property name and converts it to a setter method name according to JavaBean conventions. For example, the + * property foo is returned as setFoo(var) + */ + 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 determine 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; + } + } + + /** + * Returns the generic types represented in the given type. Usage as follows: + * JavaIntrospectionHelper.getGenerics(field.getGenericType()); + *

+ * JavaIntrospectionHelper.getGenerics(m.getGenericParameterTypes()[0];); + * + * @return the generic types in order of declaration or an empty array if the type is not genericized + */ + public static List getGenerics(Type genericType) { + List classes = new ArrayList(); + if (genericType instanceof ParameterizedType) { + ParameterizedType ptype = (ParameterizedType) genericType; + // get the type arguments + Type[] targs = ptype.getActualTypeArguments(); + for (Type targ : targs) { + classes.add(targ); + } + } + return classes; + } + + /** + * Returns the generic type specified by the class at the given position as in: + *

+ * public class Foo{ //.. } + *

+ * JavaIntrospectionHelper.introspectGeneric(Foo.class,1); + *

+ * will return Baz. + */ + public static Class introspectGeneric(Class clazz, int pos) { + assert clazz != null : "No class specified"; + Type type = clazz.getGenericSuperclass(); + if (type instanceof ParameterizedType) { + Type[] args = ((ParameterizedType) type).getActualTypeArguments(); + if (args.length <= pos) { + throw new IllegalArgumentException("Invalid index value for generic class " + clazz.getName()); + } + return (Class) ((ParameterizedType) type).getActualTypeArguments()[pos]; + } else { + Type[] interfaces = clazz.getGenericInterfaces(); + for (Type itype : interfaces) { + if (!(itype instanceof ParameterizedType)) { + continue; + } + ParameterizedType interfaceType = (ParameterizedType) itype; + return (Class) interfaceType.getActualTypeArguments()[0]; + } + } + return null; + } + + /** + * Returns the set of interfaces implemented by the given class and its ancestors or a blank set if none + */ + public static Set getAllInterfaces(Class clazz) { + Set implemented = new HashSet(); + getAllInterfaces(clazz, implemented); + return implemented; + } + + private static void getAllInterfaces(Class clazz, Set implemented) { + Class[] interfaces = clazz.getInterfaces(); + for (Class interfaze : interfaces) { + implemented.add(interfaze); + } + Class superClass = clazz.getSuperclass(); + // Object has no superclass so check for null + if (superClass != null && !superClass.equals(Object.class)) { + getAllInterfaces(superClass, implemented); + } + } + +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/CallbackInterfaceInterceptor.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/CallbackInterfaceInterceptor.java new file mode 100644 index 0000000000..c0bf7780f5 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/CallbackInterfaceInterceptor.java @@ -0,0 +1,60 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.wire; + +import org.osoa.sca.NoRegisteredCallbackException; + +import org.apache.tuscany.spi.wire.Interceptor; +import org.apache.tuscany.spi.wire.Message; + +/** + * An interceptor applied to the forward direction of a wire that ensures the callback target implements the required + * service contract. This is required as callback targets may be set dynamically by service implementations. + * + * @version $Rev$ $Date$ + */ +public class CallbackInterfaceInterceptor implements Interceptor { + private boolean invokingServiceImplements; + private Interceptor next; + + public CallbackInterfaceInterceptor(boolean invokingServiceImplements) { + this.invokingServiceImplements = invokingServiceImplements; + } + + public Message invoke(Message msg) { + // TODO check in the context if a callback object is set, if so invoke next since the setCallback will + // perform the check + if (!invokingServiceImplements) { + throw new NoRegisteredCallbackException("Callback target does not implement the callback interface"); + } + return next.invoke(msg); + } + + public void setNext(Interceptor next) { + this.next = next; + } + + public Interceptor getNext() { + return next; + } + + public boolean isOptimizable() { + return false; + } +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/IncompatibleServiceContractExceptionFormatter.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/IncompatibleServiceContractExceptionFormatter.java new file mode 100644 index 0000000000..d5fca62e1b --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/IncompatibleServiceContractExceptionFormatter.java @@ -0,0 +1,94 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.wire; + +import java.io.PrintWriter; + +import org.osoa.sca.annotations.Destroy; +import org.osoa.sca.annotations.EagerInit; +import org.osoa.sca.annotations.Reference; + +import org.apache.tuscany.spi.model.Operation; +import org.apache.tuscany.spi.model.ServiceContract; +import org.apache.tuscany.spi.wire.IncompatibleServiceContractException; + +import org.apache.tuscany.host.monitor.ExceptionFormatter; +import org.apache.tuscany.host.monitor.FormatterRegistry; + +/** + * Formats {@link org.apache.tuscany.spi.wire.IncompatibleServiceContractException} for JDK logging + * + * @version $Rev$ $Date$ + */ +@EagerInit +public class IncompatibleServiceContractExceptionFormatter implements ExceptionFormatter { + private FormatterRegistry factory; + + public IncompatibleServiceContractExceptionFormatter(@Reference FormatterRegistry factory) { + this.factory = factory; + factory.register(this); + } + + public boolean canFormat(Class type) { + return IncompatibleServiceContractException.class.isAssignableFrom(type); + } + + @Destroy + public void destroy() { + factory.unregister(this); + } + + public PrintWriter write(PrintWriter writer, Throwable exception) { + assert exception instanceof IncompatibleServiceContractException; + IncompatibleServiceContractException e = (IncompatibleServiceContractException) exception; + e.appendBaseMessage(writer); + ServiceContract source = e.getSource(); + String sourceContractName = null; + if (source != null) { + sourceContractName = source.getInterfaceName(); + } + Operation sourceOperation = e.getSourceOperation(); + String sourceOpName = null; + if (sourceOperation != null) { + sourceOpName = sourceOperation.getName(); + } + if (sourceOpName == null) { + writer.write("\nSource Contract: " + sourceContractName); + } else { + writer.write("\nSource Contract: " + sourceContractName + "/" + sourceOpName); + } + ServiceContract target = e.getTarget(); + String targetContractName = null; + if (target != null) { + targetContractName = target.getInterfaceName(); + } + Operation targetOperation = e.getTargetOperation(); + String targetOpName = null; + if (targetOperation != null) { + targetOpName = targetOperation.getName(); + } + if (targetOpName == null) { + writer.write("\nTarget Contract: " + targetContractName + "\n"); + } else { + writer.write("\nTarget Contract: " + targetContractName + "/" + targetOpName + "\n"); + + } + return writer; + } +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/InvocationChainImpl.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/InvocationChainImpl.java new file mode 100644 index 0000000000..921b4e37fa --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/InvocationChainImpl.java @@ -0,0 +1,105 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.wire; + +import org.apache.tuscany.spi.model.Operation; +import org.apache.tuscany.spi.model.physical.PhysicalOperationDefinition; +import org.apache.tuscany.spi.wire.Interceptor; +import org.apache.tuscany.spi.wire.InvocationChain; +import org.apache.tuscany.spi.wire.TargetInvoker; + +/** + * Default implementation of an invocation chain + * + * @version $Rev$ $Date$ + */ +public class InvocationChainImpl implements InvocationChain { + protected Operation operation; + protected PhysicalOperationDefinition physicalOperation; + protected TargetInvoker targetInvoker; + protected Interceptor interceptorChainHead; + protected Interceptor interceptorChainTail; + + public InvocationChainImpl(PhysicalOperationDefinition operation) { + this.physicalOperation = operation; + } + + public InvocationChainImpl(Operation operation) { + assert operation != null; + this.operation = operation; + } + + public Operation getOperation() { + return operation; + } + + public PhysicalOperationDefinition getPhysicalOperation() { + return physicalOperation; + } + + public void setTargetInvoker(TargetInvoker invoker) { + this.targetInvoker = invoker; + } + + public TargetInvoker getTargetInvoker() { + return targetInvoker; + } + + public void addInterceptor(Interceptor interceptor) { + if (interceptorChainHead == null) { + interceptorChainHead = interceptor; + } else { + interceptorChainTail.setNext(interceptor); + } + interceptorChainTail = interceptor; + } + + public void addInterceptor(int index, Interceptor interceptor) { + int i = 0; + Interceptor next = interceptorChainHead; + Interceptor prev = null; + while (next != null && i < index) { + prev = next; + next = next.getNext(); + i++; + } + if (i == index) { + if (prev != null) { + prev.setNext(interceptor); + } else { + interceptorChainHead = interceptor; + } + interceptor.setNext(next); + if (next == null) { + interceptorChainTail = interceptor; + } + } else { + throw new ArrayIndexOutOfBoundsException(index); + } + } + + public Interceptor getHeadInterceptor() { + return interceptorChainHead; + } + + public Interceptor getTailInterceptor() { + return interceptorChainTail; + } + +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/InvokerInterceptor.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/InvokerInterceptor.java new file mode 100644 index 0000000000..10cc254451 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/InvokerInterceptor.java @@ -0,0 +1,60 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.wire; + +import org.apache.tuscany.spi.wire.Interceptor; +import org.apache.tuscany.spi.wire.InvocationRuntimeException; +import org.apache.tuscany.spi.wire.Message; +import org.apache.tuscany.spi.wire.TargetInvoker; + +/** + * Serves as a tail interceptor on a target wire chain. This implementation dispatches to the target invoker passed + * inside the wire message. Target invokers are passed from the source in order to allow for caching of target + * instances. + * + * @version $Rev$ $Date$ + * @Deprecated + * @see org.apache.tuscany.spi.wire.TargetInvoker + */ +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"); + } + + public Interceptor getNext() { + return null; + } + + public boolean isOptimizable() { + return true; + } + +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/NoMethodForOperationException.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/NoMethodForOperationException.java new file mode 100644 index 0000000000..aec281d190 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/NoMethodForOperationException.java @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.wire; + +import org.apache.tuscany.spi.wire.ProxyCreationException; + +/** + * Thrown when an {@link org.apache.tuscany.spi.model.Operation} cannot be mapped to a method on an interface + * @version $Rev$ $Date$ + */ +public class NoMethodForOperationException extends ProxyCreationException { + public NoMethodForOperationException() { + } + + public NoMethodForOperationException(String message) { + super(message); + } + + public NoMethodForOperationException(String message, Throwable cause) { + super(message, cause); + } + + public NoMethodForOperationException(Throwable cause) { + super(cause); + } +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/NonBlockingInterceptor.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/NonBlockingInterceptor.java new file mode 100644 index 0000000000..d4848cde71 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/NonBlockingInterceptor.java @@ -0,0 +1,193 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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.wire; + +import java.net.URI; +import java.util.LinkedList; + +import org.osoa.sca.ServiceRuntimeException; + +import org.apache.tuscany.spi.component.WorkContext; +import org.apache.tuscany.spi.model.Scope; +import org.apache.tuscany.spi.services.work.WorkScheduler; +import org.apache.tuscany.spi.wire.Interceptor; +import org.apache.tuscany.spi.wire.Message; +import org.apache.tuscany.spi.wire.TargetInvoker; +import org.apache.tuscany.spi.wire.Wire; + +/** + * Adds non-blocking behavior to an invocation chain + * + * @version $$Rev$$ $$Date$$ + */ +public class NonBlockingInterceptor implements Interceptor { + + private static final Message RESPONSE = new ImmutableMessage(); + + private WorkScheduler workScheduler; + private WorkContext workContext; + private Interceptor next; + + public NonBlockingInterceptor(WorkScheduler workScheduler, WorkContext workContext) { + this.workScheduler = workScheduler; + this.workContext = workContext; + } + + public NonBlockingInterceptor(WorkScheduler workScheduler, WorkContext workContext, Interceptor next) { + this.workScheduler = workScheduler; + this.workContext = workContext; + this.next = next; + } + + public Message invoke(final Message msg) { + // Retrieve conversation id to transfer to new thread + // Notice that we cannot clear the conversation id from the current thread + final Object conversationID = workContext.getIdentifier(Scope.CONVERSATION); + // Schedule the invocation of the next interceptor in a new Work instance + try { + workScheduler.scheduleWork(new Runnable() { + public void run() { + workContext.setCorrelationId(null); + // if we got a conversation id, transfer it to new thread + if (conversationID != null) { + workContext.setIdentifier(Scope.CONVERSATION, conversationID); + } + next.invoke(msg); + } + }); + } catch (Exception e) { + throw new ServiceRuntimeException(e); + } + return RESPONSE; + } + + public Interceptor getNext() { + return next; + } + + public void setNext(Interceptor next) { + this.next = next; + } + + public boolean isOptimizable() { + return false; + } + + /** + * A dummy message passed back on an invocation + */ + private static class ImmutableMessage implements Message { + + public Object getBody() { + return null; + } + + public void setBody(Object body) { + if (body != null) { + throw new UnsupportedOperationException(); + } + } + + public WorkContext getWorkContext() { + throw new UnsupportedOperationException(); + } + + public void setWorkContext(WorkContext workContext) { + throw new UnsupportedOperationException(); + } + + public void setTargetInvoker(TargetInvoker invoker) { + throw new UnsupportedOperationException(); + } + + public TargetInvoker getTargetInvoker() { + return null; + } + + public Message getRelatedCallbackMessage() { + return null; + } + + public URI getFromAddress() { + return null; + } + + public void setFromAddress(URI fromAddress) { + throw new UnsupportedOperationException(); + } + + public void pushCallbackUri(URI fromAddress) { + throw new UnsupportedOperationException(); + } + + public LinkedList getCallbackUris() { + return null; + } + + public void setCallbackUris(LinkedList uris) { + throw new UnsupportedOperationException(); + } + + public void pushCallbackWire(Wire wire) { + + } + + public LinkedList getCallbackWires() { + return null; + } + + public void setCallbackWires(LinkedList wires) { + + } + + public Object getMessageId() { + return null; + } + + public void setMessageId(Object messageId) { + throw new UnsupportedOperationException(); + } + + public Object getCorrelationId() { + return null; + } + + public void setCorrelationId(Object correlationId) { + throw new UnsupportedOperationException(); + } + + public boolean isFault() { + return false; + } + + public void setBodyWithFault(Object fault) { + throw new UnsupportedOperationException(); + } + + public short getConversationSequence() { + return TargetInvoker.NONE; + } + + public void setConversationSequence(short sequence) { + + } + + } + +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/NonBlockingInterceptorBuilder.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/NonBlockingInterceptorBuilder.java new file mode 100644 index 0000000000..8afcf8f6ad --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/NonBlockingInterceptorBuilder.java @@ -0,0 +1,55 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.wire; + +import javax.xml.namespace.QName; + +import org.osoa.sca.annotations.Reference; + +import org.apache.tuscany.spi.builder.BuilderException; +import org.apache.tuscany.spi.component.WorkContext; +import org.apache.tuscany.spi.extension.InterceptorBuilderExtension; +import org.apache.tuscany.spi.model.physical.PhysicalInterceptorDefinition; +import org.apache.tuscany.spi.services.work.WorkScheduler; +import org.apache.tuscany.spi.wire.Interceptor; + +/** + * Creates a non-blocking interceptor + * + * @version $Rev$ $Date$ + */ +public class NonBlockingInterceptorBuilder extends InterceptorBuilderExtension { + public static final QName QNAME = new QName("http://tuscany.apache.org/xmlns/sca/system/2.0-alpha", "nonblocking"); + private WorkContext workContext; + private WorkScheduler scheduler; + + public NonBlockingInterceptorBuilder(@Reference(required = true)WorkContext workContext, + @Reference(required = true)WorkScheduler scheduler) { + this.workContext = workContext; + this.scheduler = scheduler; + } + + public Interceptor build(PhysicalInterceptorDefinition definition) throws BuilderException { + return new NonBlockingInterceptor(scheduler, workContext); + } + + protected QName getName() { + return QNAME; + } +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/OptimizedWireObjectFactory.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/OptimizedWireObjectFactory.java new file mode 100644 index 0000000000..ab958234bd --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/OptimizedWireObjectFactory.java @@ -0,0 +1,49 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.wire; + +import org.apache.tuscany.spi.ObjectCreationException; +import org.apache.tuscany.spi.ObjectFactory; +import org.apache.tuscany.spi.component.TargetResolutionException; +import org.apache.tuscany.spi.wire.Wire; + +/** + * Returns a target instance directly from a wire + * + * @version $Rev$ $Date$ + * @Deprecated + */ +public class OptimizedWireObjectFactory implements ObjectFactory { + private final Class type; + private Wire wire; + + public OptimizedWireObjectFactory(Class type, Wire factory) { + this.wire = factory; + this.type = type; + } + + public B getInstance() throws ObjectCreationException { + try { + return type.cast(wire.getTargetInstance()); + } catch (TargetResolutionException e) { + throw new ObjectCreationException(e); + } + } + +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/ProxyServiceExtension.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/ProxyServiceExtension.java new file mode 100644 index 0000000000..7c8cf0db3a --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/ProxyServiceExtension.java @@ -0,0 +1,115 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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.wire; + +import org.apache.tuscany.spi.component.WorkContext; +import org.apache.tuscany.spi.model.Operation; +import org.apache.tuscany.spi.model.ServiceContract; +import org.apache.tuscany.spi.wire.IncompatibleServiceContractException; +import org.apache.tuscany.spi.wire.ProxyService; + +/** + * Base class for wire service extensions + * + * @version $Rev$ $Date$ + */ +public abstract class ProxyServiceExtension implements ProxyService { + protected WorkContext context; + + protected ProxyServiceExtension(WorkContext context) { + this.context = context; + } + + public boolean checkCompatibility(ServiceContract source, + ServiceContract target, + boolean ignoreCallback, + boolean silent) + throws IncompatibleServiceContractException { + if (source == target) { + // Shortcut for performance + return true; + } + if (source.isRemotable() != target.isRemotable()) { + if (!silent) { + throw new IncompatibleServiceContractException("Remotable settings do not match", source, target); + } else { + return false; + } + } + if (source.isConversational() != target.isConversational()) { + if (!silent) { + throw new IncompatibleServiceContractException("Interaction scopes do not match", source, target); + } else { + return false; + } + } + + for (Operation operation : source.getOperations().values()) { + Operation targetOperation = target.getOperations().get(operation.getName()); + if (targetOperation == null) { + if (!silent) { + throw new IncompatibleServiceContractException("Operation not found on target", source, target); + } else { + return false; + } + } + if (!operation.equals(targetOperation)) { + if (!silent) { + throw new IncompatibleServiceContractException("Target operations are not compatible", source, + target); + } else { + return false; + } + } + } + + if (ignoreCallback) { + return true; + } + + for (Operation operation : source.getCallbackOperations().values()) { + Operation targetOperation = target.getCallbackOperations().get(operation.getName()); + if (targetOperation == null) { + if (!silent) { + throw new IncompatibleServiceContractException("Callback operation not found on target", + source, + target, + null, + targetOperation); + } else { + return false; + } + } + if (!operation.equals(targetOperation)) { + if (!silent) { + throw new IncompatibleServiceContractException("Target callback operation is not compatible", + source, + target, + operation, + targetOperation); + } else { + return false; + } + } + } + return true; + } + + +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/WireImpl.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/WireImpl.java new file mode 100644 index 0000000000..7f748a15db --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/WireImpl.java @@ -0,0 +1,159 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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.wire; + +import java.net.URI; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import javax.xml.namespace.QName; + +import org.apache.tuscany.spi.component.AtomicComponent; +import org.apache.tuscany.spi.component.TargetResolutionException; +import org.apache.tuscany.spi.model.Operation; +import org.apache.tuscany.spi.model.ServiceContract; +import org.apache.tuscany.spi.model.physical.PhysicalOperationDefinition; +import org.apache.tuscany.spi.wire.InvocationChain; +import org.apache.tuscany.spi.wire.Wire; + +/** + * Default implementation of a Wire + * + * @version $Rev$ $Date$ + */ +public class WireImpl implements Wire { + private URI sourceUri; + private URI targetUri; + private QName bindingType; + private ServiceContract sourceContract; + private ServiceContract targetContract; + private boolean optimizable; + private Map, InvocationChain> chains = new HashMap, InvocationChain>(); + private Map, InvocationChain> callbackChains = new HashMap, InvocationChain>(); + private Map pChains = + new HashMap(); + private Map pCallbackChains = + new HashMap(); + private AtomicComponent target; + + /** + * Creates a wire with a local binding + */ + public WireImpl() { + } + + /** + * Creates a wire with the given binding type + * + * @param bindingType the binding type + */ + public WireImpl(QName bindingType) { + this.bindingType = bindingType; + } + + public URI getSourceUri() { + return sourceUri; + } + + public void setSourceUri(URI sourceUri) { + this.sourceUri = sourceUri; + } + + public URI getTargetUri() { + return targetUri; + } + + public void setTargetUri(URI targetUri) { + this.targetUri = targetUri; + } + + public QName getBindingType() { + return bindingType; + } + + + public ServiceContract getSourceContract() { + return sourceContract; + } + + public void setSourceContract(ServiceContract contract) { + this.sourceContract = contract; + } + + + public ServiceContract getTargetContract() { + return targetContract; + } + + public void setTargetContract(ServiceContract contract) { + this.targetContract = contract; + } + + public boolean isOptimizable() { + return optimizable; + } + + public void setOptimizable(boolean optimizable) { + this.optimizable = optimizable; + } + + public Object getTargetInstance() throws TargetResolutionException { + if (target == null) { + return null; + } + return target.getTargetInstance(); + } + + public void setTarget(AtomicComponent target) { + this.target = target; + } + + public Map, InvocationChain> getInvocationChains() { + return Collections.unmodifiableMap(chains); + } + + public void addInvocationChain(Operation operation, InvocationChain chain) { + chains.put(operation, chain); + } + + public void addInvocationChain(PhysicalOperationDefinition operation, InvocationChain chain) { + pChains.put(operation, chain); + } + + public Map getPhysicalInvocationChains() { + return Collections.unmodifiableMap(pChains); + } + + public Map, InvocationChain> getCallbackInvocationChains() { + return Collections.unmodifiableMap(callbackChains); + } + + public void addCallbackInvocationChain(Operation operation, InvocationChain chain) { + callbackChains.put(operation, chain); + } + + public Map getCallbackPhysicalInvocationChains() { + return Collections.unmodifiableMap(pCallbackChains); + } + + public void addCallbackInvocationChain(PhysicalOperationDefinition operation, InvocationChain chain) { + pCallbackChains.put(operation, chain); + } + +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/WireObjectFactory.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/WireObjectFactory.java new file mode 100644 index 0000000000..3d14138d56 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/WireObjectFactory.java @@ -0,0 +1,85 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.wire; + +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.Map; + +import org.apache.tuscany.spi.ObjectCreationException; +import org.apache.tuscany.spi.ObjectFactory; +import org.apache.tuscany.spi.component.TargetResolutionException; +import org.apache.tuscany.spi.wire.ChainHolder; +import org.apache.tuscany.spi.wire.Wire; +import org.apache.tuscany.spi.wire.ProxyService; + +/** + * Uses a wire to return an object instance + * @Deprecated + * + * @version $Rev$ $Date$ + */ +public class WireObjectFactory implements ObjectFactory { + private Class interfaze; + private Wire wire; + private ProxyService proxyService; + // the cache of proxy interface method to operation mappings + private Map mappings; + private boolean optimizable; + + /** + * Constructor. + * + * @param interfaze the interface to inject on the client + * @param wire the backing wire + * @param proxyService the wire service to create the proxy + * @throws NoMethodForOperationException + */ + public WireObjectFactory(Class interfaze, Wire wire, ProxyService proxyService) + throws NoMethodForOperationException { + this.interfaze = interfaze; + this.wire = wire; + this.proxyService = proxyService; + this.mappings = WireUtils.createInterfaceToWireMapping(interfaze, wire); + if (wire.isOptimizable() + && wire.getSourceContract().getInterfaceClass() != null + && interfaze.isAssignableFrom(wire.getSourceContract().getInterfaceClass())) { + optimizable = true; + } + } + + public T getInstance() throws ObjectCreationException { + if (optimizable) { + try { + return interfaze.cast(wire.getTargetInstance()); + } catch (TargetResolutionException e) { + throw new ObjectCreationException(e); + } + } else { + // clone the cached mappings + Map newChains = new HashMap(mappings.size()); + for (Map.Entry entry : mappings.entrySet()) { + newChains.put(entry.getKey(), entry.getValue().clone()); + } + return interfaze.cast(proxyService.createProxy(interfaze, wire, newChains)); + } + } + + +} diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/WireObjectFactory2.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/WireObjectFactory2.java new file mode 100644 index 0000000000..b5fab62d2f --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/WireObjectFactory2.java @@ -0,0 +1,65 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.wire; + +import java.lang.reflect.Method; +import java.util.Map; + +import org.apache.tuscany.spi.ObjectCreationException; +import org.apache.tuscany.spi.ObjectFactory; +import org.apache.tuscany.spi.wire.InvocationChain; +import org.apache.tuscany.spi.wire.ProxyService; +import org.apache.tuscany.spi.wire.Wire; + +/** + * Uses a wire to return an object instance + * + * @version $Rev$ $Date$ + */ +public class WireObjectFactory2 implements ObjectFactory { + private Class interfaze; + private boolean conversational; + private Wire wire; + private ProxyService proxyService; + // the cache of proxy interface method to operation mappings + private Map mappings; + + /** + * Constructor. + * + * @param interfaze the interface to inject on the client + * @param conversational if the wire is conversational + * @param wire the backing wire + * @param proxyService the wire service to create the proxy + * @throws NoMethodForOperationException if a method matching the operation cannot be found + */ + public WireObjectFactory2(Class interfaze, boolean conversational, Wire wire, ProxyService proxyService) + throws NoMethodForOperationException { + this.interfaze = interfaze; + this.conversational = conversational; + this.wire = wire; + this.proxyService = proxyService; + this.mappings = WireUtils.createInterfaceToWireMapping2(interfaze, wire); + } + + public T getInstance() throws ObjectCreationException { + return interfaze.cast(proxyService.createProxy2(interfaze, conversational, wire)); + } +} + diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/WireUtils.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/WireUtils.java new file mode 100644 index 0000000000..8b839dc8df --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/WireUtils.java @@ -0,0 +1,116 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.wire; + +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.Map; + +import static org.apache.tuscany.spi.idl.java.JavaIDLUtils.findMethod; +import static org.apache.tuscany.spi.idl.java.JavaIDLUtils.findMethod2; +import org.apache.tuscany.spi.model.Operation; +import org.apache.tuscany.spi.model.physical.PhysicalOperationDefinition; +import org.apache.tuscany.spi.wire.ChainHolder; +import org.apache.tuscany.spi.wire.Interceptor; +import org.apache.tuscany.spi.wire.InvocationChain; +import org.apache.tuscany.spi.wire.ProxyCreationException; +import org.apache.tuscany.spi.wire.Wire; + +/** + * Utilities for operating on wires + * + * @version $Rev$ $Date$ + */ +public final class WireUtils { + + private WireUtils() { + } + + + /** + * Maps methods on an interface to operations on a wire + * + * @param interfaze the interface to map from + * @param wire the wire to map to + * @return a collection of method to operation mappings + * @throws NoMethodForOperationException + * @Deprecated + */ + public static Map createInterfaceToWireMapping(Class interfaze, Wire wire) + throws NoMethodForOperationException { + Map, InvocationChain> invocationChains = wire.getInvocationChains(); + + Map chains = new HashMap(invocationChains.size()); + for (Map.Entry, InvocationChain> entry : invocationChains.entrySet()) { + Operation operation = entry.getKey(); + try { + Method method = findMethod(interfaze, operation); + chains.put(method, new ChainHolder(entry.getValue())); + } catch (NoSuchMethodException e) { + throw new NoMethodForOperationException(operation.getName()); + } + } + return chains; + } + + public static Map createInterfaceToWireMapping2(Class interfaze, Wire wire) + throws NoMethodForOperationException { + Map invocationChains = wire.getPhysicalInvocationChains(); + + Map chains = new HashMap(invocationChains.size()); + for (Map.Entry entry : invocationChains.entrySet()) { + PhysicalOperationDefinition operation = entry.getKey(); + try { + Method method = findMethod2(interfaze, operation); + chains.put(method, entry.getValue()); + } catch (NoSuchMethodException e) { + throw new NoMethodForOperationException(operation.getName()); + } catch (ClassNotFoundException e) { + throw new ProxyCreationException(e); + } + } + return chains; + } + + /** + * Determines if the given wire is optimizable, i.e. its invocation chains may be bypassed during an invocation. + * This is typically calculated during the connect phase to optimize away invocation chains. + * + * @param wire the wire + * @return true if the wire is optimizable + */ + public static boolean isOptimizable(Wire wire) { + for (InvocationChain chain : wire.getInvocationChains().values()) { + if (chain.getHeadInterceptor() != null) { + Interceptor current = chain.getHeadInterceptor(); + if (current == null) { + break; + } + while (current != null) { + if (!current.isOptimizable()) { + return false; + } + current = current.getNext(); + } + } + } + // if there is a callback, the wire is never optimizable since the callback target needs to be disambiguated + return wire.getCallbackInvocationChains().isEmpty(); + } +} diff --git a/sandbox/rfeng/minicore/src/main/resources/org/apache/tuscany/core/composite.scdl b/sandbox/rfeng/minicore/src/main/resources/org/apache/tuscany/core/composite.scdl new file mode 100644 index 0000000000..8cdf0ac2a8 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/resources/org/apache/tuscany/core/composite.scdl @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/rfeng/minicore/src/main/resources/org/apache/tuscany/core/deployment.scdl b/sandbox/rfeng/minicore/src/main/resources/org/apache/tuscany/core/deployment.scdl new file mode 100644 index 0000000000..804bd0bead --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/resources/org/apache/tuscany/core/deployment.scdl @@ -0,0 +1,62 @@ + + + + + + + + + target/deployables + + + + + + + target/repository + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/rfeng/minicore/src/main/resources/org/apache/tuscany/core/formatters.scdl b/sandbox/rfeng/minicore/src/main/resources/org/apache/tuscany/core/formatters.scdl new file mode 100644 index 0000000000..5d2c0db012 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/resources/org/apache/tuscany/core/formatters.scdl @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + diff --git a/sandbox/rfeng/minicore/src/main/resources/org/apache/tuscany/core/implementation.scdl b/sandbox/rfeng/minicore/src/main/resources/org/apache/tuscany/core/implementation.scdl new file mode 100644 index 0000000000..c81115aafa --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/resources/org/apache/tuscany/core/implementation.scdl @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/rfeng/minicore/src/main/resources/org/apache/tuscany/core/interfaceJava.scdl b/sandbox/rfeng/minicore/src/main/resources/org/apache/tuscany/core/interfaceJava.scdl new file mode 100644 index 0000000000..b0664dc67a --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/resources/org/apache/tuscany/core/interfaceJava.scdl @@ -0,0 +1,36 @@ + + + + + + + + + + + + diff --git a/sandbox/rfeng/minicore/src/main/resources/org/apache/tuscany/core/javaImplementation.scdl b/sandbox/rfeng/minicore/src/main/resources/org/apache/tuscany/core/javaImplementation.scdl new file mode 100644 index 0000000000..69110ec05c --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/resources/org/apache/tuscany/core/javaImplementation.scdl @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + diff --git a/sandbox/rfeng/minicore/src/main/resources/org/apache/tuscany/core/loader.scdl b/sandbox/rfeng/minicore/src/main/resources/org/apache/tuscany/core/loader.scdl new file mode 100644 index 0000000000..b22f5d05f1 --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/resources/org/apache/tuscany/core/loader.scdl @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/rfeng/minicore/src/main/resources/org/apache/tuscany/core/systemImplementation.scdl b/sandbox/rfeng/minicore/src/main/resources/org/apache/tuscany/core/systemImplementation.scdl new file mode 100644 index 0000000000..9a4178118f --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/resources/org/apache/tuscany/core/systemImplementation.scdl @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/binding/local/AbstractLocalTargetInvokerTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/binding/local/AbstractLocalTargetInvokerTestCase.java new file mode 100644 index 0000000000..dfda132671 --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/binding/local/AbstractLocalTargetInvokerTestCase.java @@ -0,0 +1,72 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.binding.local; + +import org.apache.tuscany.spi.wire.Interceptor; +import org.apache.tuscany.spi.wire.InvocationChain; +import org.apache.tuscany.spi.wire.Message; +import org.apache.tuscany.spi.wire.MessageImpl; +import org.apache.tuscany.spi.wire.TargetInvoker; + +import junit.framework.TestCase; +import org.apache.tuscany.core.mock.wire.MockTargetInvoker; +import org.easymock.EasyMock; +import org.easymock.IAnswer; + +/** + * @version $Rev$ $Date$ + */ +public class AbstractLocalTargetInvokerTestCase extends TestCase { + + public void testInvokerWithInterceptor() throws Throwable { + AbstractLocalTargetInvoker invoker = new MockTargetInvoker(); + Interceptor interceptor = EasyMock.createMock(Interceptor.class); + interceptor.invoke(EasyMock.isA(Message.class)); + EasyMock.expectLastCall().andStubAnswer(new IAnswer() { + public Object answer() throws Throwable { + Message msg = (Message) EasyMock.getCurrentArguments()[0]; + if (msg.getTargetInvoker() == null) { + fail("Target invoker not set"); + } + return null; + } + }); + EasyMock.replay(interceptor); + InvocationChain chain = EasyMock.createMock(InvocationChain.class); + EasyMock.expect(chain.getHeadInterceptor()).andReturn(interceptor); + EasyMock.replay(chain); + invoker.invoke(chain, EasyMock.createNiceMock(TargetInvoker.class), new MessageImpl()); + EasyMock.verify(chain); + EasyMock.verify(interceptor); + } + + public void testShortCircuitInvoke() throws Throwable { + AbstractLocalTargetInvoker invoker = new MockTargetInvoker(); + TargetInvoker targetInvoker = EasyMock.createMock(TargetInvoker.class); + EasyMock.expect(targetInvoker.invoke(EasyMock.isA(Message.class))).andReturn(new MessageImpl()); + EasyMock.replay(targetInvoker); + InvocationChain chain = EasyMock.createMock(InvocationChain.class); + EasyMock.expect(chain.getHeadInterceptor()).andReturn(null); + EasyMock.replay(chain); + invoker.invoke(chain, targetInvoker, new MessageImpl()); + EasyMock.verify(chain); + EasyMock.verify(targetInvoker); + } + +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/binding/local/LocalBindingBuilderTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/binding/local/LocalBindingBuilderTestCase.java new file mode 100644 index 0000000000..e628df47e2 --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/binding/local/LocalBindingBuilderTestCase.java @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.binding.local; + +import java.net.URI; + +import org.apache.tuscany.spi.component.ServiceBinding; +import org.apache.tuscany.spi.model.ServiceDefinition; + +import junit.framework.TestCase; + +/** + * @version $Rev$ $Date$ + */ +public class LocalBindingBuilderTestCase extends TestCase { + + public void testBuild() throws Exception { + LocalBindingBuilder builder = new LocalBindingBuilder(); + ServiceDefinition def = new ServiceDefinition(); + def.setUri(new URI("#foo")); + ServiceBinding binding = builder.build(def, null, null); + assertEquals(LocalServiceBinding.class, binding.getClass()); + } +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/binding/local/LocalBindingLoaderTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/binding/local/LocalBindingLoaderTestCase.java new file mode 100644 index 0000000000..0c35ae9a09 --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/binding/local/LocalBindingLoaderTestCase.java @@ -0,0 +1,70 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.binding.local; + +import java.net.URI; +import javax.xml.stream.XMLStreamReader; + +import org.apache.tuscany.spi.loader.LoaderException; + +import junit.framework.TestCase; +import org.easymock.EasyMock; + +/** + * @version $Rev$ $Date$ + */ +public class LocalBindingLoaderTestCase extends TestCase { + private LocalBindingLoader loader; + + public void testParse() throws Exception { + XMLStreamReader reader = EasyMock.createMock(XMLStreamReader.class); + EasyMock.expect(reader.getAttributeValue(null, "uri")).andReturn("foo"); + EasyMock.replay(reader); + LocalBindingDefinition definition = loader.load(null, reader, null); + assertEquals(new URI("foo"), definition.getTargetUri()); + EasyMock.verify(reader); + } + + public void testNoUri() throws Exception { + XMLStreamReader reader = EasyMock.createMock(XMLStreamReader.class); + EasyMock.expect(reader.getAttributeValue(null, "uri")).andReturn(null); + EasyMock.replay(reader); + LocalBindingDefinition definition = loader.load(null, reader, null); + assertNull(definition.getTargetUri()); + EasyMock.verify(reader); + } + + public void testBadUri() throws Exception { + XMLStreamReader reader = EasyMock.createMock(XMLStreamReader.class); + EasyMock.expect(reader.getAttributeValue(null, "uri")).andReturn("foo foo"); + EasyMock.replay(reader); + try { + loader.load(null, reader, null); + fail(); + } catch (LoaderException e) { + // expected + } + EasyMock.verify(reader); + } + + protected void setUp() throws Exception { + super.setUp(); + loader = new LocalBindingLoader(null); + } +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/binding/local/LocalCallbackTargetInvokerInvocationExceptionTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/binding/local/LocalCallbackTargetInvokerInvocationExceptionTestCase.java new file mode 100644 index 0000000000..9b83d95918 --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/binding/local/LocalCallbackTargetInvokerInvocationExceptionTestCase.java @@ -0,0 +1,84 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.binding.local; + +import java.lang.reflect.Type; + +import org.apache.tuscany.spi.model.Operation; +import org.apache.tuscany.spi.wire.Interceptor; +import org.apache.tuscany.spi.wire.InvocationChain; +import org.apache.tuscany.spi.wire.Message; +import org.apache.tuscany.spi.wire.MessageImpl; +import org.apache.tuscany.spi.wire.Wire; + +import junit.framework.TestCase; +import org.apache.tuscany.core.wire.InvocationChainImpl; +import org.apache.tuscany.core.wire.WireImpl; + +/** + * @version $Rev$ $Date$ + */ +public class LocalCallbackTargetInvokerInvocationExceptionTestCase extends TestCase { + + /** + * Verfies an InvocationTargetException thrown when invoking the target is propagated to the client correctly and + * the originating error is unwrapped + */ + public void testThrowableTargetInvocation() throws Exception { + Operation operation = new Operation("echo", null, null, null); + Interceptor head = new ErrorInterceptor(); + InvocationChain chain = new InvocationChainImpl(operation); + chain.addInterceptor(head); + Wire wire = new WireImpl(); + wire.addCallbackInvocationChain(operation, chain); + LocalCallbackTargetInvoker invoker = new LocalCallbackTargetInvoker(operation, wire); + Message msg = new MessageImpl(); + msg.setBody("foo"); + Message response = invoker.invoke(msg); + assertTrue(response.isFault()); + Object body = response.getBody(); + assertTrue(SomeException.class.equals(body.getClass())); + } + + private class SomeException extends Exception { + + } + + private class ErrorInterceptor implements Interceptor { + + public Message invoke(Message msg) { + msg.setBodyWithFault(new SomeException()); + return msg; + } + + public void setNext(Interceptor next) { + + } + + public Interceptor getNext() { + return null; + } + + public boolean isOptimizable() { + return false; + } + } + + +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/binding/local/LocalCallbackTargetInvokerTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/binding/local/LocalCallbackTargetInvokerTestCase.java new file mode 100644 index 0000000000..d922ec8033 --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/binding/local/LocalCallbackTargetInvokerTestCase.java @@ -0,0 +1,83 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.binding.local; + +import java.lang.reflect.Type; +import java.net.URI; +import java.util.HashMap; +import java.util.Map; + +import org.apache.tuscany.spi.model.Operation; +import org.apache.tuscany.spi.wire.Interceptor; +import org.apache.tuscany.spi.wire.InvocationChain; +import org.apache.tuscany.spi.wire.Message; +import org.apache.tuscany.spi.wire.MessageImpl; +import org.apache.tuscany.spi.wire.Wire; + +import junit.framework.TestCase; +import org.easymock.EasyMock; + +/** + * @version $Rev$ $Date$ + */ +public class LocalCallbackTargetInvokerTestCase extends TestCase { + private Wire wire; + private Message message; + private InvocationChain chain; + private Interceptor head; + private LocalCallbackTargetInvoker invoker; + + /** + * Verfies the normal execution path through a callback + */ + public void testNormalPathMessageInvocation() throws Exception { + Message response = invoker.invoke(message); + assertEquals("response", response.getBody()); + EasyMock.verify(wire); + EasyMock.verify(chain); + EasyMock.verify(head); + } + + protected void setUp() throws Exception { + super.setUp(); + URI targetAddress = URI.create("from"); + message = new MessageImpl(); + message.pushCallbackUri(targetAddress); + message.setBody("foo"); + Message response = new MessageImpl(); + response.setBody("response"); + Operation operation = new Operation("echo", null, null, null); + head = EasyMock.createMock(Interceptor.class); + EasyMock.expect(head.invoke(EasyMock.isA(Message.class))).andReturn(response); + EasyMock.replay(head); + chain = EasyMock.createMock(InvocationChain.class); + EasyMock.expect(chain.getTargetInvoker()).andReturn(null); + EasyMock.expect(chain.getHeadInterceptor()).andReturn(head); + EasyMock.replay(chain); + Map, InvocationChain> chains = new HashMap, InvocationChain>(); + chains.put(operation, chain); + wire = EasyMock.createMock(Wire.class); + EasyMock.expect(wire.getCallbackInvocationChains()).andReturn(chains); + EasyMock.replay(wire); + + invoker = new LocalCallbackTargetInvoker(operation, wire); + } + + +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/binding/local/LocalCallbackTargetInvokerThrowableTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/binding/local/LocalCallbackTargetInvokerThrowableTestCase.java new file mode 100644 index 0000000000..0c06842a60 --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/binding/local/LocalCallbackTargetInvokerThrowableTestCase.java @@ -0,0 +1,89 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.binding.local; + +import java.lang.reflect.Type; + +import org.apache.tuscany.spi.model.Operation; +import org.apache.tuscany.spi.wire.Interceptor; +import org.apache.tuscany.spi.wire.InvocationChain; +import org.apache.tuscany.spi.wire.Message; +import org.apache.tuscany.spi.wire.MessageImpl; +import org.apache.tuscany.spi.wire.Wire; + +import junit.framework.TestCase; +import org.apache.tuscany.core.wire.InvocationChainImpl; +import org.apache.tuscany.core.wire.WireImpl; + +/** + * @version $Rev$ $Date$ + */ +public class LocalCallbackTargetInvokerThrowableTestCase extends TestCase { + private LocalCallbackTargetInvoker invoker; + + /** + * Verfies an exception thrown in the target is propagated to the client correctly + */ + public void testThrowableTargetInvocation() throws Exception { + Message message = new MessageImpl(); + message.setBody("foo"); + Message response = invoker.invoke(message); + assertTrue(response.isFault()); + Object body = response.getBody(); + if (!(body instanceof InsidiousException)) { + fail(); + } + } + + @SuppressWarnings("unchecked") + protected void setUp() throws Exception { + super.setUp(); + Operation operation = new Operation("echo", null, null, null); + InvocationChain chain = new InvocationChainImpl(operation); + chain.addInterceptor(new InsidiuousInterceptor()); + Wire wire = new WireImpl(); + wire.addCallbackInvocationChain(operation, chain); + invoker = new LocalCallbackTargetInvoker(operation, wire); + } + + private class InsidiousException extends RuntimeException { + + } + + private class InsidiuousInterceptor implements Interceptor { + + public Message invoke(Message msg) throws InsidiousException { + throw new InsidiousException(); + } + + public void setNext(Interceptor next) { + + } + + public Interceptor getNext() { + return null; + } + + public boolean isOptimizable() { + return false; + } + } + + +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/binding/local/LocalTargetInvokerTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/binding/local/LocalTargetInvokerTestCase.java new file mode 100644 index 0000000000..e49447164d --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/binding/local/LocalTargetInvokerTestCase.java @@ -0,0 +1,115 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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.binding.local; + +import java.net.URI; + +import org.apache.tuscany.spi.model.Operation; +import org.apache.tuscany.spi.model.ServiceContract; +import org.apache.tuscany.spi.wire.InvocationChain; +import org.apache.tuscany.spi.wire.Message; +import org.apache.tuscany.spi.wire.MessageImpl; +import org.apache.tuscany.spi.wire.TargetInvoker; +import org.apache.tuscany.spi.wire.Wire; + +import junit.framework.TestCase; +import org.apache.tuscany.core.wire.InvocationChainImpl; +import org.apache.tuscany.core.wire.WireImpl; +import org.easymock.EasyMock; + +/** + * @version $Rev$ $Date$ + */ +public class LocalTargetInvokerTestCase extends TestCase { + private ServiceContract serviceContract; + private Operation operation; + + public void testInvoke() { + TargetInvoker targetInvoker = EasyMock.createMock(TargetInvoker.class); + EasyMock.expect(targetInvoker.invoke(EasyMock.isA(Message.class))).andReturn(new MessageImpl()); + EasyMock.replay(targetInvoker); + InvocationChain chain = new InvocationChainImpl(operation); + chain.setTargetInvoker(targetInvoker); + Wire wire = new WireImpl(); + wire.addInvocationChain(operation, chain); + wire.setSourceContract(serviceContract); + TargetInvoker invoker = new LocalTargetInvoker(operation, wire); + Message msg = invoker.invoke(new MessageImpl()); + assertFalse(msg.isFault()); + EasyMock.verify(targetInvoker); + } + + public void testCallbackSetInvoke() { + ServiceContract contract = new ServiceContract() { + + }; + contract.setCallbackClass(Object.class); + TargetInvoker targetInvoker = EasyMock.createMock(TargetInvoker.class); + EasyMock.expect(targetInvoker.invoke(EasyMock.isA(Message.class))).andReturn(new MessageImpl()); + EasyMock.replay(targetInvoker); + + InvocationChain chain = new InvocationChainImpl(operation); + chain.setTargetInvoker(targetInvoker); + InvocationChain callbackChain = new InvocationChainImpl(operation); + Wire wire = new WireImpl(); + wire.addInvocationChain(operation, chain); + wire.addCallbackInvocationChain(operation, callbackChain); + wire.setSourceContract(serviceContract); + URI uri = URI.create("foo"); + wire.setSourceUri(uri); + wire.addInvocationChain(operation, chain); + TargetInvoker invoker = new LocalTargetInvoker(operation, wire); + Message msg = EasyMock.createMock(Message.class); + msg.pushCallbackUri(EasyMock.eq(uri)); + EasyMock.replay(msg); + invoker.invoke(msg); + EasyMock.verify(msg); + EasyMock.verify(targetInvoker); + } + + public void testFaultInvoke() { + TargetInvoker targetInvoker = EasyMock.createMock(TargetInvoker.class); + EasyMock.expect(targetInvoker.invoke(EasyMock.isA(Message.class))).andThrow(new TestException()); + EasyMock.replay(targetInvoker); + + InvocationChain chain = new InvocationChainImpl(operation); + chain.setTargetInvoker(targetInvoker); + Wire wire = new WireImpl(); + wire.setSourceContract(serviceContract); + wire.addInvocationChain(operation, chain); + TargetInvoker invoker = new LocalTargetInvoker(operation, wire); + Message msg = invoker.invoke(new MessageImpl()); + assertTrue(msg.isFault()); + assertTrue(msg.getBody() instanceof TestException); + EasyMock.verify(targetInvoker); + } + + + protected void setUp() throws Exception { + super.setUp(); + serviceContract = new ServiceContract() { + }; + operation = new Operation("foo", null, null, null); + } + + + private class TestException extends RuntimeException { + + } +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/builder/BuilderRegistryNoBindingsTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/builder/BuilderRegistryNoBindingsTestCase.java new file mode 100644 index 0000000000..f13ed3367d --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/builder/BuilderRegistryNoBindingsTestCase.java @@ -0,0 +1,89 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.builder; + +import java.net.URI; + +import org.apache.tuscany.spi.builder.BuilderRegistry; +import org.apache.tuscany.spi.component.Component; +import org.apache.tuscany.spi.component.Reference; +import org.apache.tuscany.spi.component.ReferenceBinding; +import org.apache.tuscany.spi.component.Service; +import org.apache.tuscany.spi.component.ServiceBinding; +import org.apache.tuscany.spi.deployer.DeploymentContext; +import org.apache.tuscany.spi.model.Multiplicity; +import org.apache.tuscany.spi.model.ReferenceDefinition; +import org.apache.tuscany.spi.model.ServiceDefinition; + +import junit.framework.TestCase; +import org.apache.tuscany.core.binding.local.LocalBindingBuilder; +import org.apache.tuscany.core.binding.local.LocalBindingDefinition; +import org.apache.tuscany.core.binding.local.LocalReferenceBinding; +import org.apache.tuscany.core.binding.local.LocalServiceBinding; +import org.easymock.EasyMock; + +/** + * @version $Rev$ $Date$ + */ +public class BuilderRegistryNoBindingsTestCase extends TestCase { + private DeploymentContext deploymentContext; + private Component parent; + private BuilderRegistry registry; + + public void testNoServiceBindings() throws Exception { + ServiceBinding binding = EasyMock.createNiceMock(ServiceBinding.class); + EasyMock.replay(binding); + ServiceDefinition definition = new ServiceDefinition(URI.create("#foo"), null, false); + definition.setTarget(new URI("foo")); + EasyMock.replay(deploymentContext); + EasyMock.replay(parent); + + Service service = registry.build(definition, deploymentContext); + + assertEquals(1, service.getServiceBindings().size()); + assertTrue(service.getServiceBindings().get(0) instanceof LocalServiceBinding); + EasyMock.verify(deploymentContext); + EasyMock.verify(parent); + } + + public void testReferenceBindingBuilderDispatch() throws Exception { + ReferenceBinding binding = EasyMock.createNiceMock(ReferenceBinding.class); + EasyMock.replay(binding); + ReferenceDefinition definition = new ReferenceDefinition(URI.create("#foo"), null, Multiplicity.ONE_ONE); + EasyMock.replay(deploymentContext); + EasyMock.replay(parent); + + Reference reference = registry.build(definition, deploymentContext); + + assertEquals(1, reference.getReferenceBindings().size()); + assertTrue(reference.getReferenceBindings().get(0) instanceof LocalReferenceBinding); + EasyMock.verify(deploymentContext); + EasyMock.verify(parent); + } + + protected void setUp() throws Exception { + super.setUp(); + deploymentContext = EasyMock.createMock(DeploymentContext.class); + parent = EasyMock.createNiceMock(Component.class); + registry = new BuilderRegistryImpl(null); + registry.register(LocalBindingDefinition.class, new LocalBindingBuilder()); + } + + +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/builder/BuilderRegistryTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/builder/BuilderRegistryTestCase.java new file mode 100644 index 0000000000..34173154b8 --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/builder/BuilderRegistryTestCase.java @@ -0,0 +1,190 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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 java.net.URI; +import java.util.Map; + +import org.apache.tuscany.spi.builder.BindingBuilder; +import org.apache.tuscany.spi.builder.BuilderConfigException; +import org.apache.tuscany.spi.builder.BuilderRegistry; +import org.apache.tuscany.spi.builder.ComponentBuilder; +import org.apache.tuscany.spi.component.AtomicComponent; +import org.apache.tuscany.spi.component.Component; +import org.apache.tuscany.spi.component.Reference; +import org.apache.tuscany.spi.component.ReferenceBinding; +import org.apache.tuscany.spi.component.ScopeContainer; +import org.apache.tuscany.spi.component.ScopeRegistry; +import org.apache.tuscany.spi.component.Service; +import org.apache.tuscany.spi.component.ServiceBinding; +import org.apache.tuscany.spi.deployer.DeploymentContext; +import org.apache.tuscany.spi.model.BindingDefinition; +import org.apache.tuscany.spi.model.ComponentDefinition; +import org.apache.tuscany.spi.model.ComponentType; +import org.apache.tuscany.spi.model.CompositeComponentType; +import org.apache.tuscany.spi.model.CompositeImplementation; +import org.apache.tuscany.spi.model.Implementation; +import static org.apache.tuscany.spi.model.Multiplicity.ONE_ONE; +import org.apache.tuscany.spi.model.ReferenceDefinition; +import org.apache.tuscany.spi.model.Scope; +import org.apache.tuscany.spi.model.ServiceDefinition; + +import junit.framework.TestCase; +import org.easymock.EasyMock; + +/** + * @version $Rev$ $Date$ + */ +public class BuilderRegistryTestCase extends TestCase { + private DeploymentContext deploymentContext; + private ScopeContainer scopeContainer; + private Map components; + + //private BuilderRegistryImpl registry; + private Component parent; + + @SuppressWarnings({"unchecked"}) + public void testRegistration() throws Exception { + URI componentId = URI.create("sca://localhost/component"); + CompositeImplementation implementation = new CompositeImplementation(); + ComponentDefinition componentDefinition = + new ComponentDefinition(implementation); + componentDefinition.getImplementation().setComponentType(new CompositeComponentType()); + + Component component = EasyMock.createMock(Component.class); + component.setDefaultPropertyValues(componentDefinition.getPropertyValues()); + component.setScopeContainer(scopeContainer); + EasyMock.expect(component.getUri()).andReturn(componentId); + EasyMock.replay(component); + + EasyMock.expect(deploymentContext.getCompositeScope()).andReturn(scopeContainer); + EasyMock.expect(deploymentContext.getComponents()).andReturn(components); + EasyMock.replay(deploymentContext); + + EasyMock.expect(components.put(componentId, component)).andReturn(null); + EasyMock.replay(components); + + ComponentBuilder builder = EasyMock.createMock(ComponentBuilder.class); + EasyMock.expect(builder.build(componentDefinition, deploymentContext)).andReturn(component); + EasyMock.replay(builder); + + BuilderRegistry registry = new BuilderRegistryImpl(null); + registry.register(CompositeImplementation.class, builder); + + assertSame(component, registry.build(componentDefinition, deploymentContext)); + EasyMock.verify(builder); + } + + @SuppressWarnings({"unchecked"}) + public void testServiceBindingBuilderDispatch() throws Exception { + BuilderRegistry registry = new BuilderRegistryImpl(null); + ServiceBinding binding = EasyMock.createNiceMock(ServiceBinding.class); + EasyMock.replay(binding); + BindingBuilder builder = EasyMock.createMock(BindingBuilder.class); + EasyMock.expect(builder.build( + EasyMock.isA(ServiceDefinition.class), + EasyMock.isA(MockBindingDefinition.class), + EasyMock.isA(DeploymentContext.class))).andReturn(binding).times(2); + EasyMock.replay(builder); + registry.register(MockBindingDefinition.class, builder); + ServiceDefinition definition = new ServiceDefinition(URI.create("#foo"), null, false); + definition.addBinding(new MockBindingDefinition()); + definition.addBinding(new MockBindingDefinition()); + definition.setTarget(new URI("foo")); + Service service = registry.build(definition, deploymentContext); + assertEquals(2, service.getServiceBindings().size()); + } + + @SuppressWarnings({"unchecked"}) + public void testReferenceBindingBuilderDispatch() throws Exception { + BuilderRegistry registry = new BuilderRegistryImpl(null); + ReferenceBinding binding = EasyMock.createNiceMock(ReferenceBinding.class); + EasyMock.replay(binding); + BindingBuilder builder = EasyMock.createMock(BindingBuilder.class); + EasyMock.expect(builder.build( + EasyMock.isA(ReferenceDefinition.class), + EasyMock.isA(MockBindingDefinition.class), + EasyMock.isA(DeploymentContext.class))).andReturn(binding).times(2); + EasyMock.replay(builder); + registry.register(MockBindingDefinition.class, builder); + ReferenceDefinition definition = new ReferenceDefinition(URI.create("#foo"), null, ONE_ONE); + definition.addBinding(new MockBindingDefinition()); + definition.addBinding(new MockBindingDefinition()); + Reference reference = registry.build(definition, deploymentContext); + assertEquals(2, reference.getReferenceBindings().size()); + } + + @SuppressWarnings({"unchecked"}) + public void testNoConversationalContract() throws Exception { + ScopeRegistry scopeRegistry = EasyMock.createMock(ScopeRegistry.class); + ScopeContainer scopeContainer = EasyMock.createNiceMock(ScopeContainer.class); + EasyMock.expect(scopeRegistry.getScopeContainer(EasyMock.isA(Scope.class))).andReturn(scopeContainer); + EasyMock.replay(scopeRegistry); + BuilderRegistry registry = new BuilderRegistryImpl(scopeRegistry); + + AtomicComponent component = EasyMock.createNiceMock(AtomicComponent.class); + EasyMock.replay(component); + ComponentBuilder builder = EasyMock.createMock(ComponentBuilder.class); + EasyMock.expect(builder.build( + EasyMock.isA(ComponentDefinition.class), + EasyMock.isA(DeploymentContext.class))).andReturn(component); + EasyMock.replay(builder); + registry.register(FooImplementation.class, builder); + + FooImplementation impl = new FooImplementation(); + ComponentType componentType = new ComponentType(); + componentType.setImplementationScope(Scope.CONVERSATION); + impl.setComponentType(componentType); + URI uri = URI.create("foo"); + ComponentDefinition definition = new ComponentDefinition(uri, impl); + try { + registry.build(definition, deploymentContext); + fail("Should throw NoConversationalContractException"); + } catch (NoConversationalContractException e) { + // expected + } + } + + @SuppressWarnings({"unchecked"}) + protected void setUp() throws Exception { + super.setUp(); + deploymentContext = EasyMock.createMock(DeploymentContext.class); + parent = EasyMock.createNiceMock(Component.class); + scopeContainer = EasyMock.createMock(ScopeContainer.class); + components = EasyMock.createMock(Map.class); + } + + private class MockBuilder implements ComponentBuilder { + public Component build( + ComponentDefinition componentDefinition, + DeploymentContext deploymentContext) throws BuilderConfigException { + return null; + } + } + + private class MockBindingDefinition extends BindingDefinition { + + } + + private class FooImplementation extends Implementation { + + } + + +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/builder/ConnectorImplTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/builder/ConnectorImplTestCase.java new file mode 100644 index 0000000000..4c4e1a32b0 --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/builder/ConnectorImplTestCase.java @@ -0,0 +1,320 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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 java.lang.reflect.Type; +import java.net.URI; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import javax.xml.namespace.QName; + +import org.apache.tuscany.spi.component.AtomicComponent; +import org.apache.tuscany.spi.component.Component; +import org.apache.tuscany.spi.component.ComponentManager; +import org.apache.tuscany.spi.model.ComponentDefinition; +import org.apache.tuscany.spi.model.ComponentType; +import org.apache.tuscany.spi.model.Implementation; +import org.apache.tuscany.spi.model.Operation; +import org.apache.tuscany.spi.model.Property; +import org.apache.tuscany.spi.model.ReferenceDefinition; +import org.apache.tuscany.spi.model.ReferenceTarget; +import org.apache.tuscany.spi.model.Scope; +import org.apache.tuscany.spi.model.ServiceContract; +import org.apache.tuscany.spi.model.ServiceDefinition; +import org.apache.tuscany.spi.wire.Interceptor; +import org.apache.tuscany.spi.wire.InvocationChain; +import org.apache.tuscany.spi.wire.Wire; + +import junit.framework.TestCase; +import org.apache.tuscany.core.component.ComponentManagerImpl; +import org.apache.tuscany.core.wire.InvokerInterceptor; +import org.apache.tuscany.core.wire.NonBlockingInterceptor; +import org.easymock.EasyMock; + +/** + * @version $Rev$ $Date$ + */ +public class ConnectorImplTestCase extends TestCase { + private TestConnector connector; + private ComponentManager manager; + + public void testConnectTargetNotFound() throws Exception { + Implementation>> impl = + new Implementation>>() { + }; + ComponentType> type = + new ComponentType>(); + URI refUri = URI.create("ref"); + ReferenceDefinition referenceDefinition = new ReferenceDefinition(refUri, null); + referenceDefinition.setRequired(true); + type.add(referenceDefinition); + impl.setComponentType(type); + + URI sourceUri = URI.create("source"); + ComponentDefinition definition = + new ComponentDefinition>>>(impl); + definition.setUri(sourceUri); + ReferenceTarget referenceTarget = new ReferenceTarget(); + referenceTarget.setReferenceName(refUri); + referenceTarget.addTarget(URI.create("NotThere")); + definition.add(referenceTarget); + Component component = EasyMock.createMock(Component.class); + EasyMock.expect(component.getUri()).andReturn(sourceUri); + EasyMock.replay(component); + manager.register(component); + try { + connector.connect(definition); + fail(); + } catch (ComponentNotFoundException e) { + // expected + } + } + + /** + * Verifies a non-existent target does not throw an error. + *

+ * TODO JFM when the allocator is in place it should optimize connecting to non-existent targets but keep it for + * now + */ + public void testConnectTargetNotFoundNonRequiredReference() throws Exception { + Implementation>> impl = + new Implementation>>() { + }; + ComponentType> type = + new ComponentType>(); + URI refUri = URI.create("ref"); + ReferenceDefinition referenceDefinition = new ReferenceDefinition(refUri, null); + referenceDefinition.setRequired(false); + type.add(referenceDefinition); + impl.setComponentType(type); + + URI sourceUri = URI.create("source"); + ComponentDefinition definition = + new ComponentDefinition>>>(impl); + definition.setUri(sourceUri); + ReferenceTarget referenceTarget = new ReferenceTarget(); + referenceTarget.setReferenceName(refUri); + referenceTarget.addTarget(URI.create("NotThere")); + definition.add(referenceTarget); + Component component = EasyMock.createMock(Component.class); + EasyMock.expect(component.getUri()).andReturn(sourceUri); + EasyMock.replay(component); + manager.register(component); + connector.connect(definition); + } + + public void testNonOptimizableTargetComponent() throws Exception { + AtomicComponent source = EasyMock.createMock(AtomicComponent.class); + EasyMock.expect(source.getScope()).andReturn(Scope.COMPOSITE); + EasyMock.replay(source); + + AtomicComponent target = EasyMock.createMock(AtomicComponent.class); + EasyMock.expect(target.getScope()).andReturn(Scope.COMPOSITE); + EasyMock.expect(target.isOptimizable()).andReturn(false); + EasyMock.replay(target); + + Wire wire = EasyMock.createMock(Wire.class); + wire.setOptimizable(false); + EasyMock.replay(wire); + connector.optimize(source, target, wire); + EasyMock.verify(source); + EasyMock.verify(target); + EasyMock.verify(wire); + } + + public void testOptimizableTargetComponent() throws Exception { + AtomicComponent source = EasyMock.createMock(AtomicComponent.class); + EasyMock.expect(source.getScope()).andReturn(Scope.COMPOSITE); + EasyMock.replay(source); + + AtomicComponent target = EasyMock.createMock(AtomicComponent.class); + EasyMock.expect(target.getScope()).andReturn(Scope.COMPOSITE); + EasyMock.expect(target.isOptimizable()).andReturn(true); + EasyMock.replay(target); + + Wire wire = EasyMock.createMock(Wire.class); + wire.setOptimizable(true); + wire.setTarget(EasyMock.eq(target)); + wire.getInvocationChains(); + EasyMock.expectLastCall().andReturn(Collections.emptyMap()); + wire.getCallbackInvocationChains(); + EasyMock.expectLastCall().andReturn(Collections.emptyMap()); + EasyMock.replay(wire); + connector.optimize(source, target, wire); + EasyMock.verify(source); + EasyMock.verify(target); + } + + public void testIsOptimizable() { + assertTrue(connector.isOptimizable(Scope.STATELESS, Scope.STATELESS)); + assertTrue(connector.isOptimizable(Scope.STATELESS, Scope.COMPOSITE)); + assertFalse(connector.isOptimizable(Scope.STATELESS, Scope.CONVERSATION)); + assertTrue(connector.isOptimizable(Scope.STATELESS, Scope.REQUEST)); + assertTrue(connector.isOptimizable(Scope.STATELESS, Scope.SESSION)); + assertTrue(connector.isOptimizable(Scope.STATELESS, Scope.SYSTEM)); + + assertTrue(connector.isOptimizable(Scope.COMPOSITE, Scope.COMPOSITE)); + assertFalse(connector.isOptimizable(Scope.COMPOSITE, Scope.CONVERSATION)); + assertFalse(connector.isOptimizable(Scope.COMPOSITE, Scope.REQUEST)); + assertFalse(connector.isOptimizable(Scope.COMPOSITE, Scope.SESSION)); + assertFalse(connector.isOptimizable(Scope.COMPOSITE, Scope.STATELESS)); + assertTrue(connector.isOptimizable(Scope.COMPOSITE, Scope.SYSTEM)); + + assertFalse(connector.isOptimizable(Scope.CONVERSATION, Scope.COMPOSITE)); + assertFalse(connector.isOptimizable(Scope.CONVERSATION, Scope.CONVERSATION)); + assertFalse(connector.isOptimizable(Scope.CONVERSATION, Scope.REQUEST)); + assertFalse(connector.isOptimizable(Scope.CONVERSATION, Scope.SESSION)); + assertFalse(connector.isOptimizable(Scope.CONVERSATION, Scope.STATELESS)); + assertFalse(connector.isOptimizable(Scope.CONVERSATION, Scope.SYSTEM)); + + assertTrue(connector.isOptimizable(Scope.REQUEST, Scope.COMPOSITE)); + assertFalse(connector.isOptimizable(Scope.REQUEST, Scope.CONVERSATION)); + assertTrue(connector.isOptimizable(Scope.REQUEST, Scope.REQUEST)); + assertTrue(connector.isOptimizable(Scope.REQUEST, Scope.SESSION)); + assertFalse(connector.isOptimizable(Scope.REQUEST, Scope.STATELESS)); + assertTrue(connector.isOptimizable(Scope.REQUEST, Scope.SYSTEM)); + + assertTrue(connector.isOptimizable(Scope.SESSION, Scope.COMPOSITE)); + assertFalse(connector.isOptimizable(Scope.SESSION, Scope.CONVERSATION)); + assertFalse(connector.isOptimizable(Scope.SESSION, Scope.REQUEST)); + assertTrue(connector.isOptimizable(Scope.SESSION, Scope.SESSION)); + assertFalse(connector.isOptimizable(Scope.SESSION, Scope.STATELESS)); + assertTrue(connector.isOptimizable(Scope.SESSION, Scope.SYSTEM)); + + assertTrue(connector.isOptimizable(Scope.SYSTEM, Scope.COMPOSITE)); + assertFalse(connector.isOptimizable(Scope.SYSTEM, Scope.CONVERSATION)); + assertFalse(connector.isOptimizable(Scope.SYSTEM, Scope.REQUEST)); + assertFalse(connector.isOptimizable(Scope.SYSTEM, Scope.SESSION)); + assertFalse(connector.isOptimizable(Scope.SYSTEM, Scope.STATELESS)); + assertTrue(connector.isOptimizable(Scope.SYSTEM, Scope.SYSTEM)); + + assertFalse(connector.isOptimizable(Scope.UNDEFINED, Scope.COMPOSITE)); + assertFalse(connector.isOptimizable(Scope.UNDEFINED, Scope.CONVERSATION)); + assertFalse(connector.isOptimizable(Scope.UNDEFINED, Scope.REQUEST)); + assertFalse(connector.isOptimizable(Scope.UNDEFINED, Scope.SESSION)); + assertFalse(connector.isOptimizable(Scope.UNDEFINED, Scope.STATELESS)); + assertFalse(connector.isOptimizable(Scope.UNDEFINED, Scope.SYSTEM)); + + } + + public void testCreateSyncForwardWire() throws Exception { + ServiceContract contract = new ServiceContract() { + + }; + Operation operation = new Operation("operation", null, null, null); + Map> operations = new HashMap>(); + operations.put("operation", operation); + contract.setOperations(operations); + Wire wire = connector.createWire(URI.create("target"), URI.create("#ref"), contract, Wire.LOCAL_BINDING); + assertEquals(1, wire.getInvocationChains().size()); + InvocationChain chain = wire.getInvocationChains().get(operation); + Interceptor head = chain.getHeadInterceptor(); + assertTrue(head instanceof InvokerInterceptor); + } + + public void testCreateSyncCallbackWire() throws Exception { + ServiceContract contract = new ServiceContract() { + + }; + + Operation operation = new Operation("operation", null, null, null); + Map> operations = new HashMap>(); + operations.put("operation", operation); + contract.setOperations(operations); + + Operation callbackOperation = new Operation("operation", null, null, null); + Map> callbackOperations = new HashMap>(); + callbackOperations.put("operation", callbackOperation); + contract.setCallbackOperations(callbackOperations); + + Wire wire = connector.createWire(URI.create("target"), URI.create("#ref"), contract, Wire.LOCAL_BINDING); + assertEquals(1, wire.getCallbackInvocationChains().size()); + InvocationChain chain = wire.getCallbackInvocationChains().get(callbackOperation); + Interceptor head = chain.getHeadInterceptor(); + assertTrue(head instanceof InvokerInterceptor); + } + + public void testCreateNonBlockingForwardWire() throws Exception { + ServiceContract contract = new ServiceContract() { + + }; + Operation operation = new Operation("operation", null, null, null); + operation.setNonBlocking(true); + Map> operations = new HashMap>(); + operations.put("operation", operation); + contract.setOperations(operations); + Wire wire = connector.createWire(URI.create("target"), URI.create("#ref"), contract, Wire.LOCAL_BINDING); + assertEquals(1, wire.getInvocationChains().size()); + InvocationChain chain = wire.getInvocationChains().get(operation); + Interceptor head = chain.getHeadInterceptor(); + assertTrue(head instanceof NonBlockingInterceptor); + assertTrue(head.getNext() instanceof InvokerInterceptor); + } + + public void testCreateNonBlockingCallbackWire() throws Exception { + ServiceContract contract = new ServiceContract() { + + }; + + Operation operation = new Operation("operation", null, null, null); + operation.setNonBlocking(true); + Map> operations = new HashMap>(); + operations.put("operation", operation); + contract.setOperations(operations); + + Operation callbackOperation = new Operation("operation", null, null, null); + callbackOperation.setNonBlocking(true); + Map> callbackOperations = new HashMap>(); + callbackOperations.put("operation", callbackOperation); + contract.setCallbackOperations(callbackOperations); + + Wire wire = connector.createWire(URI.create("target"), URI.create("#ref"), contract, Wire.LOCAL_BINDING); + assertEquals(1, wire.getCallbackInvocationChains().size()); + InvocationChain chain = wire.getCallbackInvocationChains().get(callbackOperation); + Interceptor head = chain.getHeadInterceptor(); + assertTrue(head instanceof NonBlockingInterceptor); + assertTrue(head.getNext() instanceof InvokerInterceptor); + } + + protected void setUp() throws Exception { + super.setUp(); + manager = new ComponentManagerImpl(); + connector = new TestConnector(manager); + } + + private class TestConnector extends ConnectorImpl { + + public TestConnector(ComponentManager componentManager) { + super(componentManager); + } + + protected Wire createWire(URI sourceURI, URI targetUri, ServiceContract contract, QName bindingType) { + return super.createWire(sourceURI, targetUri, contract, bindingType); + } + + public boolean isOptimizable(Scope pReferrer, Scope pReferee) { + return super.isOptimizable(pReferrer, pReferee); + } + + } + +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/builder/IllegalCallbackExceptionTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/builder/IllegalCallbackExceptionTestCase.java new file mode 100644 index 0000000000..c6a9927db3 --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/builder/IllegalCallbackExceptionTestCase.java @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.builder; + +import java.net.URI; + +import junit.framework.TestCase; + +/** + * @version $Rev$ $Date$ + */ +public class IllegalCallbackExceptionTestCase extends TestCase { + + public void testInstantiation() throws Exception { + URI sourceUri = URI.create("source"); + URI targetUri = URI.create("target"); + IllegalCallbackException e = new IllegalCallbackException("message", "identifier", sourceUri, targetUri); + assertEquals("message", e.getMessage()); + assertEquals("identifier", e.getIdentifier()); + assertEquals(sourceUri, e.getSourceUri()); + assertEquals(targetUri, e.getTargetUri()); + + } +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/builder/IncompatibleInterfacesExceptionTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/builder/IncompatibleInterfacesExceptionTestCase.java new file mode 100644 index 0000000000..5d370fcfc5 --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/builder/IncompatibleInterfacesExceptionTestCase.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.builder; + +import java.net.URI; + +import junit.framework.TestCase; + +/** + * @version $Rev$ $Date$ + */ +public class IncompatibleInterfacesExceptionTestCase extends TestCase { + + public void testInstantiation() throws Exception { + URI sourceUri = URI.create("source"); + URI targetUri = URI.create("target"); + IncompatibleInterfacesException e = new IncompatibleInterfacesException(sourceUri, targetUri); + assertNotNull(e.getMessage()); + assertEquals("source", e.getSourceUri().toString()); + assertEquals("target", e.getTargetUri().toString()); + } +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/builder/InvalidSourceTypeExceptionTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/builder/InvalidSourceTypeExceptionTestCase.java new file mode 100644 index 0000000000..67ad003d58 --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/builder/InvalidSourceTypeExceptionTestCase.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.builder; + +import java.net.URI; + +import junit.framework.TestCase; + +/** + * @version $Rev$ $Date$ + */ +public class InvalidSourceTypeExceptionTestCase extends TestCase { + + public void testInstantiation() throws Exception { + URI sourceUri = URI.create("source"); + URI targetUri = URI.create("target"); + InvalidSourceTypeException e = new InvalidSourceTypeException("message", sourceUri, targetUri); + assertEquals("message", e.getMessage()); + assertEquals(sourceUri, e.getSourceUri()); + assertEquals(targetUri, e.getTargetUri()); + + } +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/builder/InvalidTargetTypeExceptionTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/builder/InvalidTargetTypeExceptionTestCase.java new file mode 100644 index 0000000000..61060293ce --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/builder/InvalidTargetTypeExceptionTestCase.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.builder; + +import java.net.URI; + +import junit.framework.TestCase; + +/** + * @version $Rev$ $Date$ + */ +public class InvalidTargetTypeExceptionTestCase extends TestCase { + + public void testInstantiation() throws Exception { + URI sourceUri = URI.create("source"); + URI targetUri = URI.create("target"); + InvalidTargetTypeException e = new InvalidTargetTypeException("message", sourceUri, targetUri); + assertEquals("message", e.getMessage()); + assertEquals(sourceUri, e.getSourceUri()); + assertEquals(targetUri, e.getTargetUri()); + + } +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/builder/TargetServiceNotFoundExceptionTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/builder/TargetServiceNotFoundExceptionTestCase.java new file mode 100644 index 0000000000..2d056ac964 --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/builder/TargetServiceNotFoundExceptionTestCase.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.builder; + +import java.net.URI; + +import junit.framework.TestCase; + +/** + * @version $Rev$ $Date$ + */ +public class TargetServiceNotFoundExceptionTestCase extends TestCase { + + public void testInstantiation() throws Exception { + URI sourceUri = URI.create("source"); + URI targetUri = URI.create("target"); + TargetServiceNotFoundException e = new TargetServiceNotFoundException("message", sourceUri, targetUri); + assertEquals("message", e.getMessage()); + assertEquals(sourceUri, e.getSourceUri()); + assertEquals(targetUri, e.getTargetUri()); + } +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/builder/WirePostProcessorRegistryImplTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/builder/WirePostProcessorRegistryImplTestCase.java new file mode 100644 index 0000000000..fcd5f03189 --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/builder/WirePostProcessorRegistryImplTestCase.java @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.builder; + +import org.apache.tuscany.spi.wire.Wire; +import org.apache.tuscany.spi.wire.WirePostProcessor; +import org.apache.tuscany.spi.wire.WirePostProcessorRegistry; + +import junit.framework.TestCase; +import org.easymock.EasyMock; +import static org.easymock.EasyMock.createMock; +import static org.easymock.EasyMock.verify; + +/** + * @version $Rev$ $Date$ + */ +public class WirePostProcessorRegistryImplTestCase extends TestCase { + + public void testRegisterUnregister() throws Exception { + WirePostProcessorRegistry registry = new WirePostProcessorRegistryImpl(); + Wire wire = EasyMock.createMock(Wire.class); + WirePostProcessor processor = createMock(WirePostProcessor.class); + processor.process(EasyMock.eq(wire)); + EasyMock.replay(processor); + registry.register(processor); + registry.process(wire); + registry.unregister(processor); + registry.process(wire); + verify(processor); + } + +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/builder/WiringExceptionFormatterTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/builder/WiringExceptionFormatterTestCase.java new file mode 100644 index 0000000000..e05a162d7a --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/builder/WiringExceptionFormatterTestCase.java @@ -0,0 +1,70 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.builder; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.net.URI; + +import org.apache.tuscany.spi.builder.WiringException; + +import junit.framework.TestCase; +import org.apache.tuscany.host.monitor.FormatterRegistry; +import org.easymock.EasyMock; + +/** + * @version $Rev$ $Date$ + */ +public class WiringExceptionFormatterTestCase extends TestCase { + WiringExceptionFormatter formatter = new WiringExceptionFormatter(EasyMock.createNiceMock(FormatterRegistry.class)); + + public void testFormat() throws Exception { + WiringException e = + new MockWiringException("message", "identifier", URI.create("source"), URI.create("target")); + StringWriter writer = new StringWriter(); + PrintWriter pw = new PrintWriter(writer); + formatter.write(pw, e); + String buffer = writer.toString(); + assertTrue(buffer.indexOf("message") >= 0); + assertTrue(buffer.indexOf("identifier") >= 0); + assertTrue(buffer.indexOf("source") >= 0); + assertTrue(buffer.indexOf("target") >= 0); + } + + + public void testFormatNulls() throws Exception { + WiringException e = new MockWiringException("message", + "identifier", + null, + null); + StringWriter writer = new StringWriter(); + PrintWriter pw = new PrintWriter(writer); + formatter.write(pw, e); + String buffer = writer.toString(); + assertTrue(buffer.indexOf("message") >= 0); + assertTrue(buffer.indexOf("identifier") >= 0); + } + + private class MockWiringException extends WiringException { + + public MockWiringException(String message, String identifier, URI source, URI reference) { + super(message, identifier, source, reference); + } + } +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/ComponentManagerImplTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/ComponentManagerImplTestCase.java new file mode 100644 index 0000000000..c1710e9b8e --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/ComponentManagerImplTestCase.java @@ -0,0 +1,90 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.component; + +import java.net.URI; + +import junit.framework.TestCase; +import org.easymock.EasyMock; + +import org.apache.tuscany.spi.component.Component; +import org.apache.tuscany.spi.component.DuplicateNameException; + +/** + * @version $Rev$ $Date$ + */ +public class ComponentManagerImplTestCase extends TestCase { + private static final URI DOMAIN = URI.create("sca://localhost/"); + private static final URI ROOT1 = DOMAIN.resolve("root1"); + private static final URI GRANDCHILD = DOMAIN.resolve("parent/child2/grandchild"); + + private ComponentManagerImpl manager; + + public void testRegister() throws Exception { + Component root = EasyMock.createMock(Component.class); + EasyMock.expect(root.getUri()).andReturn(ROOT1); + EasyMock.replay(root); + manager.register(root); + assertEquals(root, manager.getComponent(ROOT1)); + EasyMock.verify(root); + + EasyMock.reset(root); + EasyMock.expect(root.getUri()).andReturn(ROOT1); + EasyMock.replay(root); + manager.unregister(root); + EasyMock.verify(root); + assertEquals(null, manager.getComponent(ROOT1)); + } + + public void testRegisterGrandchild() throws Exception { + Component root = EasyMock.createMock(Component.class); + EasyMock.expect(root.getUri()).andReturn(GRANDCHILD); + EasyMock.replay(root); + manager.register(root); + assertEquals(root, manager.getComponent(GRANDCHILD)); + EasyMock.verify(root); + } + + public void testRegisterDuplicate() throws Exception { + Component root = EasyMock.createMock(Component.class); + EasyMock.expect(root.getUri()).andReturn(ROOT1); + EasyMock.replay(root); + + Component duplicate = EasyMock.createMock(Component.class); + EasyMock.expect(duplicate.getUri()).andReturn(ROOT1); + EasyMock.replay(duplicate); + + manager.register(root); + assertEquals(root, manager.getComponent(ROOT1)); + try { + manager.register(duplicate); + fail(); + } catch (DuplicateNameException e) { + // expected + } + assertEquals(root, manager.getComponent(ROOT1)); + EasyMock.verify(root); + EasyMock.verify(duplicate); + } + + protected void setUp() throws Exception { + super.setUp(); + manager = new ComponentManagerImpl(); + } +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/JavaObjectRegistrationTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/JavaObjectRegistrationTestCase.java new file mode 100644 index 0000000000..2d00a13716 --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/JavaObjectRegistrationTestCase.java @@ -0,0 +1,77 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.component; + +import java.net.URI; + +import org.apache.tuscany.spi.component.AtomicComponent; +import org.apache.tuscany.spi.component.Component; +import org.apache.tuscany.spi.component.ComponentManager; +import org.apache.tuscany.spi.component.DuplicateNameException; +import org.apache.tuscany.spi.idl.java.JavaServiceContract; + +import junit.framework.TestCase; + +/** + * @version $Rev$ $Date$ + */ +public class JavaObjectRegistrationTestCase extends TestCase { + private ComponentManager componentManager; + + public void testRegistration() throws Exception { + MockComponent instance = new MockComponent(); + URI uri = URI.create("foo"); + JavaServiceContract contract = new JavaServiceContract(MockComponent.class) { + }; + componentManager.registerJavaObject(uri, contract, instance); + Component component = componentManager.getComponent(URI.create("foo")); + assertTrue(component instanceof AtomicComponent); + MockComponent resolvedInstance = (MockComponent) ((AtomicComponent) component).getTargetInstance(); + assertSame(instance, resolvedInstance); + } + + public void testDuplicateRegistration() throws Exception { + MockComponent instance = new MockComponent(); + URI uri = URI.create("foo"); + JavaServiceContract contract = new JavaServiceContract(MockComponent.class) { + }; + componentManager.registerJavaObject(uri, contract, instance); + try { + componentManager.registerJavaObject(uri, contract, instance); + fail(); + } catch (DuplicateNameException e) { + // ok + } + } + + protected void setUp() throws Exception { + super.setUp(); + componentManager = new ComponentManagerImpl(); + } + + protected void tearDown() throws Exception { + super.tearDown(); + } + + private static class MockComponent { + public String hello(String message) { + return message; + } + } +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/SystemSingletonAtomicComponentTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/SystemSingletonAtomicComponentTestCase.java new file mode 100644 index 0000000000..fac45ebfb5 --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/SystemSingletonAtomicComponentTestCase.java @@ -0,0 +1,82 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.component; + +import java.net.URI; +import java.util.ArrayList; +import java.util.List; + +import org.apache.tuscany.spi.component.TargetException; +import org.apache.tuscany.spi.idl.java.JavaServiceContract; + +import junit.framework.TestCase; + +/** + * @version $Rev$ $Date$ + */ +public class SystemSingletonAtomicComponentTestCase extends TestCase { + + public void testGetInstance() throws TargetException { + JavaServiceContract contract = new JavaServiceContract(Foo.class) { + + }; + FooImpl foo = new FooImpl(); + SystemSingletonAtomicComponent component = + new SystemSingletonAtomicComponent(URI.create("foo"), contract, foo); + assertEquals(foo, component.getTargetInstance()); + } + + public void testGetInstanceMultipleServices() throws TargetException { + FooImpl foo = new FooImpl(); + List> services = new ArrayList>(); + services.add(new JavaServiceContract(Foo.class) { + }); + services.add(new JavaServiceContract(Bar.class) { + }); + SystemSingletonAtomicComponent component = + new SystemSingletonAtomicComponent(URI.create("foo"), services, foo); + assertEquals(foo, component.getTargetInstance()); + } + + public void testOptimizable() { + JavaServiceContract contract = new JavaServiceContract(Foo.class) { + }; + FooImpl foo = new FooImpl(); + SystemSingletonAtomicComponent component = + new SystemSingletonAtomicComponent(URI.create("foo"), contract, foo); + assertTrue(component.isOptimizable()); + } + + + protected void setUp() throws Exception { + super.setUp(); + } + + private interface Foo { + + } + + private interface Bar { + + } + + private class FooImpl implements Foo, Bar { + + } +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/event/EventTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/event/EventTestCase.java new file mode 100644 index 0000000000..93cb50ddcb --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/event/EventTestCase.java @@ -0,0 +1,69 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.component.event; + +import java.net.URI; + +import junit.framework.TestCase; + +/** + * @version $Rev$ $Date$ + */ +public class EventTestCase extends TestCase { + private URI uri = URI.create("foo"); + + public void testCompositeStart() { + ComponentStart event = new ComponentStart(this, uri); + assertEquals(uri, event.getComponentUri()); + } + + public void testCompositeStop() { + ComponentStop event = new ComponentStop(this, uri); + assertEquals(uri, event.getComponentUri()); + } + + public void testHttpSessionStart() { + Object id = new Object(); + HttpSessionEvent event = new HttpSessionStart(this, id); + assertEquals(this, event.getSource()); + assertEquals(id, event.getId()); + } + + public void testHttpSessionEnd() { + Object id = new Object(); + HttpSessionEvent event = new HttpSessionEnd(this, id); + assertEquals(this, event.getSource()); + assertEquals(id, event.getId()); + } + + public void testRequestStart() { + RequestStart event = new RequestStart(this); + assertEquals(this, event.getSource()); + } + + public void testReequestEnd() { + RequestEnd event = new RequestEnd(this); + assertEquals(this, event.getSource()); + } + + + protected void setUp() throws Exception { + super.setUp(); + } +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/AbstractScopeContainerTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/AbstractScopeContainerTestCase.java new file mode 100644 index 0000000000..a6e4de3c48 --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/AbstractScopeContainerTestCase.java @@ -0,0 +1,61 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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.component.scope; + +import java.net.URI; + +import junit.framework.TestCase; + +import org.apache.tuscany.spi.component.ScopeContainer; +import org.apache.tuscany.spi.component.AtomicComponent; +import org.apache.tuscany.spi.component.InstanceWrapper; + +import org.easymock.EasyMock; +import org.easymock.IMocksControl; + +/** + * @version $Rev$ $Date$ + */ +public abstract class AbstractScopeContainerTestCase extends TestCase { + protected IMocksControl control; + protected ScopeContainer scopeContainer; + protected URI groupId; + protected KEY contextId; + protected AtomicComponent component; + protected InstanceWrapper wrapper; + + @SuppressWarnings("unchecked") + protected void setUp() throws Exception { + super.setUp(); + control = EasyMock.createStrictControl(); + component = control.createMock(AtomicComponent.class); + wrapper = control.createMock(InstanceWrapper.class); + } + + protected void preRegisterComponent() throws Exception { + scopeContainer.start(); + scopeContainer.register(component, groupId); + EasyMock.expect(component.isEagerInit()).andStubReturn(false); + } + + protected void expectCreateWrapper() throws Exception { + EasyMock.expect(component.createInstanceWrapper()).andReturn(wrapper); + wrapper.start(); + } +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/BasicCompositeScopeTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/BasicCompositeScopeTestCase.java new file mode 100644 index 0000000000..cb66af27b0 --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/BasicCompositeScopeTestCase.java @@ -0,0 +1,143 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.component.scope; + +import java.net.URI; + +import junit.framework.TestCase; +import org.easymock.EasyMock; +import org.easymock.IMocksControl; + +import org.apache.tuscany.spi.component.AtomicComponent; +import org.apache.tuscany.spi.component.InstanceWrapper; +import org.apache.tuscany.spi.component.ScopeContainer; +import org.apache.tuscany.spi.component.TargetResolutionException; +import org.apache.tuscany.spi.model.Scope; + +/** + * @version $$Rev$$ $$Date$$ + */ +public class BasicCompositeScopeTestCase extends TestCase { + protected IMocksControl control; + protected ScopeContainer scopeContainer; + protected URI groupId; + protected URI contextId; + protected AtomicComponent component; + protected InstanceWrapper wrapper; + + public void testCorrectScope() { + assertEquals(Scope.COMPOSITE, scopeContainer.getScope()); + } + + public void testWrapperCreation() throws Exception { + EasyMock.expect(component.createInstanceWrapper()).andReturn(wrapper); + wrapper.start(); + control.replay(); + scopeContainer.register(component, groupId); + assertSame(wrapper, scopeContainer.getWrapper(component, contextId)); + assertSame(wrapper, scopeContainer.getWrapper(component, contextId)); + assertSame(wrapper, scopeContainer.getAssociatedWrapper(component, contextId)); + control.verify(); + } + + public void testGetAssociatedInstanceNonExistent() throws Exception { + URI uri = URI.create("oops"); + EasyMock.expect(component.getUri()).andReturn(uri); + control.replay(); + scopeContainer.register(component, groupId); + try { + scopeContainer.getAssociatedWrapper(component, contextId); + fail(); + } catch (TargetResolutionException e) { + assertEquals(uri.toString(), e.getMessage()); + } + control.verify(); + } + + /* + public void testLifecycleWithNoEagerInit() throws Exception { + EasyMock.expect(component.getInitLevel()).andReturn(0); + control.replay(); + scopeContainer.startContext(contextId, groupId); + scopeContainer.stopContext(contextId); + control.verify(); + } + + public void testLifecycleWithEagerInit() throws Exception { + EasyMock.expect(component.getInitLevel()).andReturn(1); + EasyMock.expect(component.createInstanceWrapper()).andReturn(wrapper); + wrapper.start(); + wrapper.stop(); + EasyMock.replay(component, wrapper); + scopeContainer.onEvent(new ComponentStart(this, null)); + scopeContainer.onEvent(new ComponentStop(this, null)); + EasyMock.verify(component, wrapper); + } + + public void testDestroyOrder() throws Exception { + scopeContainer = new CompositeScopeContainer(null); + scopeContainer.start(); + IMocksControl control = EasyMock.createStrictControl(); + InstanceWrapper wrapper1 = control.createMock(InstanceWrapper.class); + InstanceWrapper wrapper2 = control.createMock(InstanceWrapper.class); + InstanceWrapper wrapper3 = control.createMock(InstanceWrapper.class); + AtomicComponent component1 = control.createMock(AtomicComponent.class); + AtomicComponent component2 = control.createMock(AtomicComponent.class); + AtomicComponent component3 = control.createMock(AtomicComponent.class); + + EasyMock.expect(component1.getInitLevel()).andStubReturn(-1); + EasyMock.expect(component2.getInitLevel()).andStubReturn(1); + EasyMock.expect(component3.getInitLevel()).andStubReturn(-1); + + EasyMock.expect(component2.createInstanceWrapper()).andReturn(wrapper2); + wrapper2.start(); + EasyMock.expect(component1.createInstanceWrapper()).andReturn(wrapper1); + wrapper1.start(); + EasyMock.expect(component3.createInstanceWrapper()).andReturn(wrapper3); + wrapper3.start(); + wrapper3.stop(); + wrapper1.stop(); + wrapper2.stop(); + control.replay(); + + scopeContainer.register(component1, contextId); + scopeContainer.register(component2, contextId); + scopeContainer.register(component3, contextId); + scopeContainer.onEvent(new ComponentStart(this, null)); + assertSame(wrapper1, scopeContainer.getWrapper(component1)); + assertSame(wrapper2, scopeContainer.getWrapper(component2)); + assertSame(wrapper3, scopeContainer.getWrapper(component3)); + scopeContainer.onEvent(new ComponentStop(this, null)); + control.verify(); + } + */ + @SuppressWarnings("unchecked") + protected void setUp() throws Exception { + super.setUp(); + groupId = contextId = URI.create("compositeId"); + control = EasyMock.createStrictControl(); + component = control.createMock(AtomicComponent.class); + EasyMock.expect(component.isEagerInit()).andStubReturn(false); + wrapper = control.createMock(InstanceWrapper.class); + + scopeContainer = new CompositeScopeContainer(null); + scopeContainer.start(); + scopeContainer.startContext(contextId, groupId); + } +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/BasicConversationalScopeTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/BasicConversationalScopeTestCase.java new file mode 100644 index 0000000000..02f5540dea --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/BasicConversationalScopeTestCase.java @@ -0,0 +1,95 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.component.scope; + +import junit.framework.TestCase; + +import org.apache.tuscany.core.component.SimpleWorkContext; +import org.apache.tuscany.core.services.store.memory.MemoryStore; +import org.apache.tuscany.spi.component.AtomicComponent; +import org.apache.tuscany.spi.component.InstanceWrapper; +import org.apache.tuscany.spi.component.ScopeContainer; +import org.apache.tuscany.spi.component.WorkContext; +import org.apache.tuscany.spi.services.store.StoreMonitor; +import org.easymock.EasyMock; + +/** + * @version $$Rev: 471111 $$ $$Date: 2006-11-03 23:06:48 -0500 (Fri, 03 Nov 2006) $$ + */ +public class BasicConversationalScopeTestCase extends TestCase { + private AtomicComponent component; + private InstanceWrapper wrapper; + private ScopeContainer scopeContainer; + private WorkContext workContext; + +/* + public void testLifecycleManagement() throws Exception { + // start the request + String conversation = "conv"; + workContext.setIdentifier(Scope.CONVERSATION, conversation); + + EasyMock.expect(component.createInstanceWrapper()).andReturn(wrapper); + wrapper.start(); + // FIXME shouldn't stop be called when the component is removed? +// wrapper.stop(); + EasyMock.replay(component, wrapper); + assertSame(wrapper, scopeContainer.getWrapper(component)); + assertSame(wrapper, scopeContainer.getWrapper(component)); + scopeContainer.remove(component); + EasyMock.verify(component, wrapper); + } +*/ + +/* + public void testCoversationIsolation() throws Exception { + String conversation1 = "conv"; + String conversation2 = "conv2"; + + InstanceWrapper wrapper2 = EasyMock.createStrictMock(InstanceWrapper.class); + EasyMock.expect(component.createInstanceWrapper()).andReturn(wrapper); + wrapper.start(); + EasyMock.expect(component.createInstanceWrapper()).andReturn(wrapper2); + wrapper2.start(); + EasyMock.replay(component, wrapper, wrapper2); + workContext.setIdentifier(Scope.CONVERSATION, conversation1); + assertSame(wrapper, scopeContainer.getWrapper(component)); + workContext.setIdentifier(Scope.CONVERSATION, conversation2); + assertSame(wrapper2, scopeContainer.getWrapper(component)); + EasyMock.verify(component, wrapper); + } +*/ + public void testX() { +} + + protected void setUp() throws Exception { + super.setUp(); + component = EasyMock.createStrictMock(AtomicComponent.class); + EasyMock.expect(component.getMaxAge()).andStubReturn(-1); + EasyMock.expect(component.getMaxIdleTime()).andStubReturn(-1); + wrapper = EasyMock.createStrictMock(InstanceWrapper.class); + + StoreMonitor monitor = EasyMock.createMock(StoreMonitor.class); + monitor.start(EasyMock.isA(String.class)); + monitor.stop(EasyMock.isA(String.class)); + MemoryStore store = new MemoryStore(monitor); + workContext = new SimpleWorkContext(); + scopeContainer = new ConversationalScopeContainer(store, workContext, null); + scopeContainer.start(); + } +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/BasicHttpSessionScopeTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/BasicHttpSessionScopeTestCase.java new file mode 100644 index 0000000000..1f29c92c92 --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/BasicHttpSessionScopeTestCase.java @@ -0,0 +1,220 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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.component.scope; + +import junit.framework.TestCase; + +import org.apache.tuscany.core.component.SimpleWorkContext; +import org.apache.tuscany.spi.component.AtomicComponent; +import org.apache.tuscany.spi.component.InstanceWrapper; +import org.apache.tuscany.spi.component.ScopeContainer; +import org.apache.tuscany.spi.component.ScopeContainerMonitor; +import org.apache.tuscany.spi.component.WorkContext; +import org.easymock.EasyMock; + +/** + * @version $$Rev$$ $$Date$$ + */ +public abstract class BasicHttpSessionScopeTestCase extends TestCase { + private ScopeContainerMonitor monitor; + private ScopeContainer scopeContainer; + private AtomicComponent component; + private InstanceWrapper wrapper; + private WorkContext workContext; + + public void testLifecycleManagement() throws Exception { +/* + // start the request + Object session = new Object(); + workContext.setIdentifier(Scope.SESSION, session); + + EasyMock.expect(component.createInstanceWrapper()).andReturn(wrapper); + wrapper.start(); + wrapper.stop(); + EasyMock.replay(component, wrapper); + assertSame(wrapper, scopeContainer.getWrapper(component)); + assertSame(wrapper, scopeContainer.getWrapper(component)); + scopeContainer.onEvent(new HttpSessionEnd(this, session)); + EasyMock.verify(component, wrapper); +*/ + } + + public void testGetAssociatedInstance() throws Exception { +/* + // start the request + Object session = new Object(); + workContext.setIdentifier(Scope.SESSION, session); + + EasyMock.expect(component.createInstanceWrapper()).andReturn(wrapper); + wrapper.start(); + EasyMock.replay(component, wrapper); + assertSame(wrapper, scopeContainer.getWrapper(component)); + assertSame(wrapper, scopeContainer.getAssociatedWrapper(component)); + EasyMock.verify(component, wrapper); +*/ + } + + public void testGetAssociatedInstanceNonExistent() throws Exception { +/* + URI id = URI.create("oops"); + EasyMock.expect(component.getUri()).andReturn(id); + EasyMock.replay(component); + + // start the request + Object session = new Object(); + workContext.setIdentifier(Scope.SESSION, session); + try { + scopeContainer.getAssociatedWrapper(component); + fail(); + } catch (TargetNotFoundException e) { + assertEquals(id.toString(), e.getMessage()); + EasyMock.verify(component); + } +*/ + } + + public void testSessionIsolation() throws Exception { +/* + // start the request + Object session1 = new Object(); + Object session2 = new Object(); + + InstanceWrapper wrapper2 = EasyMock.createNiceMock(InstanceWrapper.class); + EasyMock.expect(component.createInstanceWrapper()).andReturn(wrapper); + wrapper.start(); + EasyMock.expect(component.createInstanceWrapper()).andReturn(wrapper2); + wrapper2.start(); + EasyMock.replay(component, wrapper); + workContext.setIdentifier(Scope.SESSION, session1); + assertSame(wrapper, scopeContainer.getWrapper(component)); + assertSame(wrapper, scopeContainer.getAssociatedWrapper(component)); + workContext.setIdentifier(Scope.SESSION, session2); + assertSame(wrapper2, scopeContainer.getWrapper(component)); + assertSame(wrapper2, scopeContainer.getAssociatedWrapper(component)); + workContext.setIdentifier(Scope.SESSION, session1); + assertSame(wrapper, scopeContainer.getWrapper(component)); + EasyMock.verify(component, wrapper); +*/ + } + + public void testDestroyErrorMonitor() throws Exception { +/* + TargetDestructionException ex = new TargetDestructionException("oops", "again"); + monitor.destructionError(ex); + EasyMock.expect(component.createInstanceWrapper()).andReturn(wrapper); + wrapper.start(); + wrapper.stop(); + EasyMock.expectLastCall().andThrow(ex); + EasyMock.replay(component, wrapper, monitor); + + Object id = new Object(); + scopeContainer.onEvent(new HttpSessionStart(this, id)); + workContext.setIdentifier(Scope.SESSION, id); + assertSame(wrapper, scopeContainer.getWrapper(component)); + scopeContainer.onEvent(new HttpSessionEnd(this, id)); + EasyMock.verify(component, wrapper, monitor); +*/ + } + + public void testDestroyOrder() throws Exception { +/* + Object session = new Object(); + workContext.setIdentifier(Scope.SESSION, session); + + IMocksControl control = EasyMock.createStrictControl(); + InstanceWrapper wrapper1 = control.createMock(InstanceWrapper.class); + InstanceWrapper wrapper2 = control.createMock(InstanceWrapper.class); + InstanceWrapper wrapper3 = control.createMock(InstanceWrapper.class); + AtomicComponent component1 = control.createMock(AtomicComponent.class); + AtomicComponent component2 = control.createMock(AtomicComponent.class); + AtomicComponent component3 = control.createMock(AtomicComponent.class); + + component1.addListener(scopeContainer); + component2.addListener(scopeContainer); + component3.addListener(scopeContainer); + EasyMock.expect(component1.createInstanceWrapper()).andReturn(wrapper1); + wrapper1.start(); + EasyMock.expect(component2.createInstanceWrapper()).andReturn(wrapper2); + wrapper2.start(); + EasyMock.expect(component3.createInstanceWrapper()).andReturn(wrapper3); + wrapper3.start(); + wrapper3.stop(); + wrapper2.stop(); + wrapper1.stop(); + control.replay(); + + scopeContainer.register(component1, null); + scopeContainer.register(component2, null); + scopeContainer.register(component3, null); + scopeContainer.onEvent(new HttpSessionStart(this, session)); + assertSame(wrapper1, scopeContainer.getWrapper(component1)); + assertSame(wrapper2, scopeContainer.getWrapper(component2)); + assertSame(wrapper3, scopeContainer.getWrapper(component3)); + scopeContainer.onEvent(new HttpSessionEnd(this, session)); + control.verify(); +*/ + } + + public void testReuseSession() throws Exception { +/* + Object session = new Object(); + workContext.setIdentifier(Scope.SESSION, session); + + IMocksControl control = EasyMock.createStrictControl(); + InstanceWrapper wrapper1 = control.createMock(InstanceWrapper.class); + InstanceWrapper wrapper2 = control.createMock(InstanceWrapper.class); + AtomicComponent component1 = control.createMock(AtomicComponent.class); + + component1.addListener(scopeContainer); + EasyMock.expect(component1.createInstanceWrapper()).andReturn(wrapper1); + wrapper1.start(); + wrapper1.stop(); + EasyMock.expect(component1.createInstanceWrapper()).andReturn(wrapper2); + wrapper2.start(); + wrapper2.stop(); + control.replay(); + + scopeContainer.register(component1, null); + scopeContainer.onEvent(new HttpSessionStart(this, session)); + assertSame(wrapper1, scopeContainer.getWrapper(component1)); + scopeContainer.onEvent(new HttpSessionEnd(this, session)); + + scopeContainer.onEvent(new HttpSessionStart(this, session)); + assertSame(wrapper2, scopeContainer.getWrapper(component1)); + scopeContainer.onEvent(new HttpSessionEnd(this, session)); + control.verify(); +*/ + } + + protected void setUp() throws Exception { + super.setUp(); + component = EasyMock.createStrictMock(AtomicComponent.class); + wrapper = EasyMock.createStrictMock(InstanceWrapper.class); + + workContext = new SimpleWorkContext(); + monitor = EasyMock.createStrictMock(ScopeContainerMonitor.class); + scopeContainer = new HttpSessionScopeContainer(workContext, monitor); + scopeContainer.start(); + + component.addListener(scopeContainer); + EasyMock.replay(component); + scopeContainer.register(component, null); + EasyMock.reset(component); + } +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/BasicRequestScopeTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/BasicRequestScopeTestCase.java new file mode 100644 index 0000000000..4aad2dc0c6 --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/BasicRequestScopeTestCase.java @@ -0,0 +1,167 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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.component.scope; + +import junit.framework.TestCase; +import org.easymock.EasyMock; + +import org.apache.tuscany.spi.component.AtomicComponent; +import org.apache.tuscany.spi.component.InstanceWrapper; +import org.apache.tuscany.spi.component.ScopeContainer; +import org.apache.tuscany.spi.component.ScopeContainerMonitor; + +/** + * @version $$Rev$$ $$Date$$ + */ +public abstract class BasicRequestScopeTestCase extends TestCase { + private ScopeContainerMonitor monitor; + private ScopeContainer scopeContainer; + private AtomicComponent component; + private InstanceWrapper wrapper; + + public void testLifecycleManagement() throws Exception { +/* + EasyMock.expect(component.createInstanceWrapper()).andReturn(wrapper); + wrapper.start(); + EasyMock.replay(component, wrapper); + assertSame(wrapper, scopeContainer.getWrapper(component)); + assertSame(wrapper, scopeContainer.getWrapper(component)); + EasyMock.verify(component, wrapper); +*/ + } + + public void testGetAssociatedInstance() throws Exception { +/* + EasyMock.expect(component.createInstanceWrapper()).andReturn(wrapper); + wrapper.start(); + EasyMock.replay(component, wrapper); + assertSame(wrapper, scopeContainer.getWrapper(component)); + assertSame(wrapper, scopeContainer.getAssociatedWrapper(component)); + EasyMock.verify(component, wrapper); +*/ + } + + public void testGetAssociatedInstanceNonExistent() throws Exception { +/* + URI id = URI.create("oops"); + EasyMock.expect(component.getUri()).andReturn(id); + EasyMock.replay(component); + + try { + scopeContainer.getAssociatedWrapper(component); + fail(); + } catch (TargetNotFoundException e) { + assertEquals(id.toString(), e.getMessage()); + EasyMock.verify(component); + } +*/ + } + + public void testRequestIsolation() throws Exception { +/* + IMocksControl control = EasyMock.createStrictControl(); + InstanceWrapper wrapper1 = control.createMock(InstanceWrapper.class); + InstanceWrapper wrapper2 = control.createMock(InstanceWrapper.class); + AtomicComponent component1 = control.createMock(AtomicComponent.class); + AtomicComponent component2 = control.createMock(AtomicComponent.class); + + EasyMock.expect(component1.createInstanceWrapper()).andReturn(wrapper1); + wrapper1.start(); + wrapper1.stop(); + EasyMock.expect(component2.createInstanceWrapper()).andReturn(wrapper2); + wrapper2.start(); + wrapper2.stop(); + control.replay(); + + scopeContainer.register(component1, null); + scopeContainer.register(component2, null); + scopeContainer.onEvent(new RequestStart(this)); + assertSame(wrapper1, scopeContainer.getWrapper(component1)); + scopeContainer.onEvent(new RequestEnd(this)); + scopeContainer.onEvent(new RequestStart(this)); + assertSame(wrapper2, scopeContainer.getWrapper(component2)); + scopeContainer.onEvent(new RequestEnd(this)); + control.verify(); +*/ + } + + public void testDestroyErrorMonitor() throws Exception { +/* + TargetDestructionException ex = new TargetDestructionException("oops", "again"); + monitor.destructionError(ex); + EasyMock.expect(component.createInstanceWrapper()).andReturn(wrapper); + wrapper.start(); + wrapper.stop(); + EasyMock.expectLastCall().andThrow(ex); + EasyMock.replay(component, wrapper, monitor); + + scopeContainer.onEvent(new RequestStart(this)); + assertSame(wrapper, scopeContainer.getWrapper(component)); + scopeContainer.onEvent(new RequestEnd(this)); + EasyMock.verify(component, wrapper, monitor); +*/ + } + + public void testDestroyOrder() throws Exception { +/* + IMocksControl control = EasyMock.createStrictControl(); + InstanceWrapper wrapper1 = control.createMock(InstanceWrapper.class); + InstanceWrapper wrapper2 = control.createMock(InstanceWrapper.class); + InstanceWrapper wrapper3 = control.createMock(InstanceWrapper.class); + AtomicComponent component1 = control.createMock(AtomicComponent.class); + AtomicComponent component2 = control.createMock(AtomicComponent.class); + AtomicComponent component3 = control.createMock(AtomicComponent.class); + + EasyMock.expect(component1.createInstanceWrapper()).andReturn(wrapper1); + wrapper1.start(); + EasyMock.expect(component2.createInstanceWrapper()).andReturn(wrapper2); + wrapper2.start(); + EasyMock.expect(component3.createInstanceWrapper()).andReturn(wrapper3); + wrapper3.start(); + wrapper3.stop(); + wrapper2.stop(); + wrapper1.stop(); + control.replay(); + + scopeContainer.register(component1, null); + scopeContainer.register(component2, null); + scopeContainer.register(component3, null); + scopeContainer.onEvent(new RequestStart(this)); + assertSame(wrapper1, scopeContainer.getWrapper(component1)); + assertSame(wrapper2, scopeContainer.getWrapper(component2)); + assertSame(wrapper3, scopeContainer.getWrapper(component3)); + scopeContainer.onEvent(new RequestEnd(this)); + control.verify(); +*/ + } + + protected void setUp() throws Exception { + super.setUp(); + component = EasyMock.createStrictMock(AtomicComponent.class); + wrapper = EasyMock.createStrictMock(InstanceWrapper.class); + monitor = EasyMock.createStrictMock(ScopeContainerMonitor.class); + scopeContainer = new RequestScopeContainer(monitor); + scopeContainer.start(); + + component.addListener(scopeContainer); + EasyMock.replay(component); + scopeContainer.register(component, null); + EasyMock.reset(component); + } +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/BasicStatelessScopeTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/BasicStatelessScopeTestCase.java new file mode 100644 index 0000000000..a7cab71ade --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/BasicStatelessScopeTestCase.java @@ -0,0 +1,89 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.component.scope; + +import junit.framework.TestCase; +import org.easymock.EasyMock; +import org.easymock.IMocksControl; + +import org.apache.tuscany.spi.component.AtomicComponent; +import org.apache.tuscany.spi.component.InstanceWrapper; +import org.apache.tuscany.spi.model.Scope; + +/** + * Unit tests for the composite scope container + * + * @version $Rev$ $Date$ + */ +public class BasicStatelessScopeTestCase extends TestCase { + private StatelessScopeContainer scopeContainer; + private String contextId; + private IMocksControl control; + private AtomicComponent component; + private InstanceWrapper wrapper; + + public void testCorrectScope() { + assertEquals(Scope.STATELESS, scopeContainer.getScope()); + } + + public void testInstanceCreation() throws Exception { + @SuppressWarnings("unchecked") + InstanceWrapper wrapper2 = control.createMock(InstanceWrapper.class); + + EasyMock.expect(component.createInstanceWrapper()).andReturn(wrapper); + wrapper.start(); + EasyMock.expect(component.createInstanceWrapper()).andReturn(wrapper2); + wrapper2.start(); + control.replay(); + + assertSame(wrapper, scopeContainer.getWrapper(component, contextId)); + assertSame(wrapper2, scopeContainer.getWrapper(component, contextId)); + control.verify(); + } + + public void testGetAssociatedInstance() throws Exception { + control.replay(); + try { + // always throws an exception, which is the semantic for stateless implementations + scopeContainer.getAssociatedWrapper(component, contextId); + fail(); + } catch (UnsupportedOperationException e) { + // ok + } + control.verify(); + } + + public void testReturnWrapper() throws Exception { + wrapper.stop(); + control.replay(); + scopeContainer.returnWrapper(component, wrapper, contextId); + control.verify(); + } + + @SuppressWarnings("unchecked") + protected void setUp() throws Exception { + super.setUp(); + scopeContainer = new StatelessScopeContainer(null); + contextId = "context"; + + control = EasyMock.createStrictControl(); + component = control.createMock(AtomicComponent.class); + wrapper = control.createMock(InstanceWrapper.class); + } +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/CompositeScopeInitDestroyErrorTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/CompositeScopeInitDestroyErrorTestCase.java new file mode 100644 index 0000000000..01c426e917 --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/CompositeScopeInitDestroyErrorTestCase.java @@ -0,0 +1,93 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.component.scope; + +import java.net.URI; + +import org.apache.tuscany.spi.ObjectCreationException; +import org.apache.tuscany.spi.component.AtomicComponent; +import org.apache.tuscany.spi.component.ScopeContainerMonitor; +import org.apache.tuscany.spi.component.TargetDestructionException; +import org.apache.tuscany.spi.component.InstanceWrapper; +import org.apache.tuscany.spi.component.TargetResolutionException; +import org.apache.tuscany.spi.component.GroupInitializationException; + +import junit.framework.TestCase; +import org.apache.tuscany.core.component.event.ComponentStart; +import org.apache.tuscany.core.component.event.ComponentStop; +import org.easymock.EasyMock; + +/** + * @version $Rev$ $Date$ + */ +public class CompositeScopeInitDestroyErrorTestCase extends TestCase { + private URI groupId; + + public void testInitializeError() throws Exception { + CompositeScopeContainer scope = new CompositeScopeContainer(null); + scope.start(); + + ObjectCreationException ex = new ObjectCreationException(""); + AtomicComponent component = EasyMock.createMock(AtomicComponent.class); + EasyMock.expect(component.createInstanceWrapper()).andThrow(ex); + EasyMock.expect(component.isEagerInit()).andStubReturn(true); + EasyMock.expect(component.getInitLevel()).andStubReturn(1); + EasyMock.replay(component); + scope.register(component, groupId); + try { + scope.startContext(groupId, groupId); + } catch (GroupInitializationException e) { + assertSame(ex, e.getCauses().get(0)); + } + EasyMock.verify(component); + } + + public void testDestroyErrorMonitor() throws Exception { + InstanceWrapper wrapper = EasyMock.createMock(InstanceWrapper.class); + wrapper.start(); + wrapper.stop(); + EasyMock.expectLastCall().andThrow(new TargetDestructionException("", "")); + EasyMock.replay(wrapper); + + ScopeContainerMonitor monitor; + monitor = EasyMock.createMock(ScopeContainerMonitor.class); + monitor.destructionError(EasyMock.isA(TargetDestructionException.class)); + EasyMock.replay(monitor); + CompositeScopeContainer scope = new CompositeScopeContainer(monitor); + scope.start(); + + AtomicComponent component = EasyMock.createMock(AtomicComponent.class); + EasyMock.expect(component.createInstanceWrapper()).andReturn(wrapper); + EasyMock.expect(component.isEagerInit()).andStubReturn(true); + EasyMock.expect(component.getInitLevel()).andStubReturn(1); + EasyMock.replay(component); + scope.register(component, groupId); + scope.startContext(groupId, groupId); + scope.stopContext(groupId); + EasyMock.verify(monitor); + EasyMock.verify(component); + EasyMock.verify(wrapper); + } + + + protected void setUp() throws Exception { + super.setUp(); + groupId = URI.create("composite"); + } +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainerDestroyOnExpirationTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainerDestroyOnExpirationTestCase.java new file mode 100644 index 0000000000..caf0c0cc5e --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainerDestroyOnExpirationTestCase.java @@ -0,0 +1,72 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.component.scope; + +import junit.framework.TestCase; + +import org.apache.tuscany.core.component.SimpleWorkContext; +import org.apache.tuscany.spi.component.AtomicComponent; +import org.apache.tuscany.spi.component.InstanceWrapper; +import org.apache.tuscany.spi.component.WorkContext; +import org.apache.tuscany.spi.event.RuntimeEventListener; +import org.apache.tuscany.spi.services.store.Store; +import org.apache.tuscany.spi.services.store.StoreExpirationEvent; +import org.easymock.EasyMock; +import org.easymock.IAnswer; + +/** + * @version $Rev$ $Date$ + */ +public class ConversationalScopeContainerDestroyOnExpirationTestCase extends TestCase { + private Store store; + private RuntimeEventListener listener; + private WorkContext context; + private InstanceWrapper wrapper; + private AtomicComponent component; + + /** + * Verifies the scope container registers a callback listener for component instance destroy events when a + * conversational instance expires + */ + public void testDestroyNotification() throws Exception { + store.addListener(EasyMock.isA(RuntimeEventListener.class)); + EasyMock.expectLastCall().andStubAnswer(new IAnswer(){ + public Object answer() throws Throwable { + listener = (RuntimeEventListener) EasyMock.getCurrentArguments()[0]; + return null; + } + }); + wrapper.stop(); + EasyMock.replay(store); + EasyMock.replay(wrapper); + + new ConversationalScopeContainer(store, context, null); + listener.onEvent(new StoreExpirationEvent(this, component, wrapper)); + EasyMock.verify(store); + EasyMock.verify(wrapper); + } + + protected void setUp() throws Exception { + super.setUp(); + store = EasyMock.createMock(Store.class); + wrapper = EasyMock.createMock(InstanceWrapper.class); + component = EasyMock.createMock(AtomicComponent.class); + context = new SimpleWorkContext(); + } +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainerMaxAgeTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainerMaxAgeTestCase.java new file mode 100644 index 0000000000..e896b410d0 --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainerMaxAgeTestCase.java @@ -0,0 +1,76 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.component.scope; + +import junit.framework.TestCase; + +import org.apache.tuscany.core.component.SimpleWorkContext; +import org.apache.tuscany.spi.component.AtomicComponent; +import org.apache.tuscany.spi.component.InstanceWrapper; +import org.apache.tuscany.spi.component.SCAObject; +import org.apache.tuscany.spi.component.ScopeContainer; +import org.apache.tuscany.spi.component.WorkContext; +import org.apache.tuscany.spi.event.RuntimeEventListener; +import org.apache.tuscany.spi.model.Scope; +import org.apache.tuscany.spi.services.store.Store; +import org.easymock.EasyMock; + +/** + * @version $Rev$ $Date$ + */ +public class ConversationalScopeContainerMaxAgeTestCase extends TestCase { + + private ScopeContainer container; + private WorkContext context; + private Store store; + private AtomicComponent component; + private InstanceWrapper wrapper; + + public void testMaxAgeUpdate() throws Exception { +/* + context.setIdentifier(Scope.CONVERSATION, "12345"); + assertSame(wrapper, container.getWrapper(component)); + EasyMock.verify(store); +*/ + } + + protected void setUp() throws Exception { + super.setUp(); + context = new SimpleWorkContext(); + component = EasyMock.createMock(AtomicComponent.class); + EasyMock.expect(component.getMaxIdleTime()).andReturn(-1L).atLeastOnce(); + EasyMock.expect(component.getMaxAge()).andReturn(600000L).atLeastOnce(); + EasyMock.replay(component); + + wrapper = EasyMock.createMock(InstanceWrapper.class); + + store = EasyMock.createMock(Store.class); + EasyMock.expect(store.readRecord(EasyMock.isA(SCAObject.class), EasyMock.isA(String.class))).andReturn(wrapper); + store.addListener(EasyMock.isA(RuntimeEventListener.class)); + EasyMock.replay(store); + container = new ConversationalScopeContainer(store, context, null); + container.start(); + } + + protected void tearDown() throws Exception { + super.tearDown(); + context.clearIdentifier(Scope.CONVERSATION); + container.stop(); + } +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainerMaxIdleTimeTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainerMaxIdleTimeTestCase.java new file mode 100644 index 0000000000..9ac97bff32 --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainerMaxIdleTimeTestCase.java @@ -0,0 +1,78 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.component.scope; + +import junit.framework.TestCase; + +import org.apache.tuscany.core.component.SimpleWorkContext; +import org.apache.tuscany.spi.component.AtomicComponent; +import org.apache.tuscany.spi.component.InstanceWrapper; +import org.apache.tuscany.spi.component.SCAObject; +import org.apache.tuscany.spi.component.ScopeContainer; +import org.apache.tuscany.spi.component.WorkContext; +import org.apache.tuscany.spi.event.RuntimeEventListener; +import org.apache.tuscany.spi.model.Scope; +import org.apache.tuscany.spi.services.store.Store; +import org.easymock.EasyMock; + +/** + * @version $Rev$ $Date$ + */ +public class ConversationalScopeContainerMaxIdleTimeTestCase extends TestCase { + + private ScopeContainer container; + private WorkContext context; + private Store store; + private AtomicComponent component; + private InstanceWrapper wrapper; + + public void testMaxIdleTimeUpdate() throws Exception { +/* + context.setIdentifier(Scope.CONVERSATION, "12345"); + assertSame(wrapper, container.getWrapper(component)); + EasyMock.verify(store); +*/ + } + + protected void setUp() throws Exception { + super.setUp(); + wrapper = EasyMock.createMock(InstanceWrapper.class); + context = new SimpleWorkContext(); + component = EasyMock.createMock(AtomicComponent.class); + EasyMock.expect(component.getMaxIdleTime()).andStubReturn(600000L); + EasyMock.replay(component); + store = EasyMock.createMock(Store.class); + EasyMock.expect(store.readRecord(EasyMock.isA(SCAObject.class), EasyMock.isA(String.class))).andReturn(wrapper); + store.addListener(EasyMock.isA(RuntimeEventListener.class)); + store.updateRecord(EasyMock.isA(SCAObject.class), + EasyMock.isA(String.class), + EasyMock.eq(wrapper), + EasyMock.anyLong()); + EasyMock.replay(store); + container = new ConversationalScopeContainer(store, context, null); + container.start(); + } + + protected void tearDown() throws Exception { + super.tearDown(); + context.clearIdentifier(Scope.CONVERSATION); + container.stop(); + } + +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainerPersistenceTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainerPersistenceTestCase.java new file mode 100644 index 0000000000..a8960c4575 --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainerPersistenceTestCase.java @@ -0,0 +1,189 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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.component.scope; + +import junit.framework.TestCase; + +import org.apache.tuscany.core.component.SimpleWorkContext; +import org.apache.tuscany.core.services.store.memory.MemoryStore; +import org.apache.tuscany.spi.component.WorkContext; +import org.apache.tuscany.spi.model.Scope; +import org.apache.tuscany.spi.services.store.Store; +import org.apache.tuscany.spi.services.store.StoreMonitor; +import org.easymock.EasyMock; + +/** + * @version $Rev$ $Date$ + */ +public abstract class ConversationalScopeContainerPersistenceTestCase extends TestCase { + private ConversationalScopeContainer container; + private WorkContext context; + + public void testNotYetPersistedInMemory() throws Exception { +/* + InstanceWrapper wrapper = EasyMock.createMock(InstanceWrapper.class); + wrapper.start(); + EasyMock.replay(wrapper); + + String id = UUID.randomUUID().toString(); + context.setIdentifier(Scope.CONVERSATION, id); + AtomicComponent component = EasyMock.createMock(AtomicComponent.class); + component.addListener(EasyMock.eq(container)); + EasyMock.expect(component.createInstanceWrapper()).andReturn(wrapper); + EasyMock.expect(component.getMaxAge()).andReturn(600000L).atLeastOnce(); + EasyMock.replay(component); + + container.register(component, null); + assertSame(wrapper, container.getWrapper(component)); + EasyMock.verify(component); + EasyMock.verify(wrapper); +*/ + } + + public void testPersistNewInMemory() throws Exception { +/* + String id = UUID.randomUUID().toString(); + String id2 = UUID.randomUUID().toString(); + context.setIdentifier(Scope.CONVERSATION, id); + AtomicComponent component = EasyMock.createMock(AtomicComponent.class); + component.addListener(EasyMock.eq(container)); + EasyMock.expect(component.getMaxIdleTime()).andReturn(-1L).atLeastOnce(); + EasyMock.replay(component); + container.register(component, null); + InstanceWrapper fooWrapper = EasyMock.createMock(InstanceWrapper.class); + InstanceWrapper fooWrapper2 = EasyMock.createMock(InstanceWrapper.class); + container.persistNew(component, id, fooWrapper, System.currentTimeMillis() + 100000); + assertEquals(fooWrapper, container.getWrapper(component)); + container.persistNew(component, id2, fooWrapper2, System.currentTimeMillis() + 100000); + context.setIdentifier(Scope.CONVERSATION, id2); + assertEquals(fooWrapper2, container.getWrapper(component)); + EasyMock.verify(component); +*/ + } + + public void testPersistInMemory() throws Exception { +/* + String id = UUID.randomUUID().toString(); + context.setIdentifier(Scope.CONVERSATION, id); + AtomicComponent component = EasyMock.createMock(AtomicComponent.class); + component.addListener(EasyMock.eq(container)); + EasyMock.expect(component.getMaxIdleTime()).andReturn(-1L).atLeastOnce(); + EasyMock.replay(component); + container.register(component, null); + InstanceWrapper fooWrapper = EasyMock.createMock(InstanceWrapper.class); + container.persistNew(component, id, fooWrapper, System.currentTimeMillis() + 100000); + assertEquals(fooWrapper, container.getWrapper(component)); + container.persist(component, id, fooWrapper, System.currentTimeMillis() + 100000); + assertEquals(fooWrapper, container.getWrapper(component)); + EasyMock.verify(component); +*/ + } + + public void testRemoveInMemory() throws Exception { +/* + String id = UUID.randomUUID().toString(); + context.setIdentifier(Scope.CONVERSATION, id); + AtomicComponent component = EasyMock.createMock(AtomicComponent.class); + component.addListener(EasyMock.eq(container)); + EasyMock.expect(component.getMaxIdleTime()).andReturn(-1L).atLeastOnce(); + EasyMock.expect(component.getUri()).andReturn(URI.create("foo")).atLeastOnce(); + EasyMock.replay(component); + container.register(component, null); + InstanceWrapper fooWrapper = EasyMock.createMock(InstanceWrapper.class); + container.persistNew(component, id, fooWrapper, System.currentTimeMillis() + 100000); + assertEquals(fooWrapper, container.getWrapper(component)); + container.remove(component); + try { + container.getAssociatedWrapper(component); + fail(); + } catch (TargetNotFoundException e) { + //expected + } + EasyMock.verify(component); +*/ + } + + public void testRecreateAfterRemoveInMemory() throws Exception { +/* + InstanceWrapper wrapper = EasyMock.createMock(InstanceWrapper.class); + wrapper.start(); + EasyMock.replay(wrapper); + + String id = UUID.randomUUID().toString(); + context.setIdentifier(Scope.CONVERSATION, id); + AtomicComponent component = EasyMock.createMock(AtomicComponent.class); + component.addListener(EasyMock.eq(container)); + EasyMock.expect(component.getMaxAge()).andReturn(600000L).atLeastOnce(); + EasyMock.expect(component.getMaxIdleTime()).andReturn(-1L).atLeastOnce(); + EasyMock.expect(component.createInstanceWrapper()).andReturn(wrapper); + EasyMock.replay(component); + + container.register(component, null); + InstanceWrapper fooWrapper = EasyMock.createMock(InstanceWrapper.class); + container.persistNew(component, id, fooWrapper, System.currentTimeMillis() + 100000); + assertEquals(fooWrapper, container.getWrapper(component)); + container.remove(component); + assertSame(wrapper, container.getWrapper(component)); + EasyMock.verify(component); +*/ + } + + public void testGetPersistedInstance() throws Exception { +/* + String id = UUID.randomUUID().toString(); + String id2 = UUID.randomUUID().toString(); + context.setIdentifier(Scope.CONVERSATION, id); + AtomicComponent component = EasyMock.createMock(AtomicComponent.class); + EasyMock.expect(component.getUri()).andReturn(URI.create("foo")).atLeastOnce(); + EasyMock.expect(component.getMaxIdleTime()).andReturn(-1L).atLeastOnce(); + component.addListener(EasyMock.eq(container)); + EasyMock.replay(component); + container.register(component, null); + + InstanceWrapper fooWrapper = EasyMock.createMock(InstanceWrapper.class); + container.persistNew(component, id, fooWrapper, System.currentTimeMillis() + 100000); + assertEquals(fooWrapper, container.getAssociatedWrapper(component)); + assertEquals(fooWrapper, container.getAssociatedWrapper(component)); + context.setIdentifier(Scope.CONVERSATION, id2); + try { + container.getAssociatedWrapper(component); + fail(); + } catch (TargetNotFoundException e) { + //expected + } + EasyMock.verify(component); +*/ + } + + protected void setUp() throws Exception { + super.setUp(); + context = new SimpleWorkContext(); + StoreMonitor mock = EasyMock.createNiceMock(StoreMonitor.class); + EasyMock.replay(mock); + Store store = new MemoryStore(mock); + container = new ConversationalScopeContainer(store, context, null); + container.start(); + } + + protected void tearDown() throws Exception { + super.tearDown(); + context.clearIdentifier(Scope.CONVERSATION); + container.stop(); + } +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/InstanceWrapperBaseTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/InstanceWrapperBaseTestCase.java new file mode 100644 index 0000000000..c583ff19c6 --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/InstanceWrapperBaseTestCase.java @@ -0,0 +1,64 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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.component.scope; + +import junit.framework.TestCase; + +/** + * @version $Rev$ $Date$ + */ +public class InstanceWrapperBaseTestCase extends TestCase { + private static final Object INSTANCE = new Object(); + private InstanceWrapperBase wrapper; + + public void testLifecycle() throws Exception { + assertFalse(wrapper.isStarted()); + try { + wrapper.getInstance(); + fail(); + } catch (AssertionError e) { + // expected + } + wrapper.start(); + assertTrue(wrapper.isStarted()); + assertSame(INSTANCE, wrapper.getInstance()); + wrapper.stop(); + assertFalse(wrapper.isStarted()); + try { + wrapper.getInstance(); + fail(); + } catch (AssertionError e) { + // expected + } + } + + public void testNullCheck() { + try { + new InstanceWrapperBase(null); + fail(); + } catch (AssertionError e) { + // expected + } + } + + protected void setUp() throws Exception { + super.setUp(); + wrapper = new InstanceWrapperBase(INSTANCE); + } +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/WorkContextTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/WorkContextTestCase.java new file mode 100644 index 0000000000..94feca05be --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/WorkContextTestCase.java @@ -0,0 +1,166 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.component.scope; + +import org.apache.tuscany.spi.component.AtomicComponent; +import org.apache.tuscany.spi.component.Component; +import org.apache.tuscany.spi.component.WorkContext; + +import junit.framework.TestCase; +import org.apache.tuscany.core.component.SimpleWorkContext; +import org.easymock.EasyMock; + +/** + * @version $Rev$ $Date$ + */ +public class WorkContextTestCase extends TestCase { + + public void testSetCurrentAtomicComponent() throws Exception { + WorkContext ctx = new SimpleWorkContext(); + AtomicComponent component = EasyMock.createNiceMock(AtomicComponent.class); + AtomicComponent component2 = EasyMock.createNiceMock(AtomicComponent.class); + ctx.setCurrentAtomicComponent(component); + assertEquals(component, ctx.getCurrentAtomicComponent()); + ctx.setCurrentAtomicComponent(component2); + assertEquals(component2, ctx.getCurrentAtomicComponent()); + } + + public void testNonSetCurrentAtomicComponent() throws Exception { + WorkContext ctx = new SimpleWorkContext(); + assertNull(ctx.getCurrentAtomicComponent()); + } + + public void testIndentifier() throws Exception { + WorkContext ctx = new SimpleWorkContext(); + Object id = new Object(); + ctx.setIdentifier(this, id); + assertEquals(id, ctx.getIdentifier(this)); + } + + public void testClearIndentifier() throws Exception { + WorkContext ctx = new SimpleWorkContext(); + Object id = new Object(); + ctx.setIdentifier(this, id); + ctx.clearIdentifier(this); + assertNull(ctx.getIdentifier(this)); + } + + public void testClearIndentifiers() throws Exception { + WorkContext ctx = new SimpleWorkContext(); + Object id = new Object(); + Object id2 = new Object(); + ctx.setIdentifier(id, id); + ctx.setIdentifier(id2, id2); + ctx.clearIdentifiers(); + assertNull(ctx.getIdentifier(id)); + assertNull(ctx.getIdentifier(id2)); + } + + public void testClearNonExistentIndentifier() throws Exception { + WorkContext ctx = new SimpleWorkContext(); + ctx.clearIdentifier(this); + } + + public void testNullIndentifier() throws Exception { + WorkContext ctx = new SimpleWorkContext(); + Object id = new Object(); + ctx.setIdentifier(this, id); + ctx.clearIdentifier(null); + assertEquals(id, ctx.getIdentifier(this)); + } + + public void testNoIndentifier() throws Exception { + WorkContext ctx = new SimpleWorkContext(); + assertNull(ctx.getIdentifier(this)); + } + + public void testSetGetCorrelationId() { + WorkContext context = new SimpleWorkContext(); + context.setCorrelationId("msg-005"); + assertEquals(context.getCorrelationId(), "msg-005"); + context.setCorrelationId(null); + assertNull(context.getCorrelationId()); + } + + public void testSetGetCorrelationIdInNewThread() throws InterruptedException { + WorkContext context = new SimpleWorkContext(); + context.setCorrelationId("msg-005"); + assertEquals(context.getCorrelationId(), "msg-005"); + context.setIdentifier("TX", "002"); + ChildThread t = new ChildThread(context); + t.start(); + t.join(); + assertTrue(t.passed); + context.setCorrelationId(null); + assertNull(context.getCorrelationId()); + } + + public void testCurrentAtomicComponentDoesNotPropagateToChildThread() throws InterruptedException { + // NOTE should behaviour be to propagate? + WorkContext context = new SimpleWorkContext(); + context.setCurrentAtomicComponent(EasyMock.createNiceMock(AtomicComponent.class)); + TestCurrentAtomicComponentChildThread t = new TestCurrentAtomicComponentChildThread(context); + t.start(); + t.join(); + assertTrue(t.passed); + context.setCurrentAtomicComponent(null); + assertNull(context.getCurrentAtomicComponent()); + } + + private static final class ChildThread extends Thread { + private WorkContext context; + private boolean passed = true; + + private ChildThread(WorkContext context) { + this.context = context; + } + + @Override + public void run() { + try { + assertNull(context.getCorrelationId()); + assertEquals("002", context.getIdentifier("TX")); + } catch (AssertionError e) { + passed = false; + } + } + + } + + private static final class TestCurrentAtomicComponentChildThread extends Thread { + private WorkContext context; + private boolean passed = true; + + private TestCurrentAtomicComponentChildThread(WorkContext context) { + this.context = context; + } + + @Override + public void run() { + try { + assertNull(context.getCurrentAtomicComponent()); + } catch (AssertionError e) { + passed = false; + } + } + + } + + +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeComponentImplTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeComponentImplTestCase.java new file mode 100644 index 0000000000..a5574c7f78 --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeComponentImplTestCase.java @@ -0,0 +1,79 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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.implementation.composite; + +import java.net.URI; + +import org.apache.tuscany.spi.component.Component; +import org.apache.tuscany.spi.component.Reference; +import org.apache.tuscany.spi.component.Service; +import org.apache.tuscany.spi.event.Event; +import org.apache.tuscany.spi.event.RuntimeEventListener; +import org.apache.tuscany.spi.model.Scope; + +import junit.framework.Assert; +import junit.framework.TestCase; +import org.easymock.EasyMock; +import static org.easymock.EasyMock.createMock; +import static org.easymock.EasyMock.eq; +import static org.easymock.EasyMock.expectLastCall; +import static org.easymock.EasyMock.replay; + +/** + * @version $Rev$ $Date$ + */ +public class CompositeComponentImplTestCase extends TestCase { + + public void testGetScope() { + Component composite = new CompositeComponentImpl(URI.create("parent")); + Assert.assertEquals(Scope.SYSTEM, composite.getScope()); + } + + public void testRegisterService() throws Exception { + Component composite = new CompositeComponentImpl(URI.create("parent")); + Service service = new ServiceImpl(URI.create("foo#service"), null); + composite.register(service); + assertNotNull(composite.getService("service")); + } + + public void testRegisterReference() throws Exception { + Component composite = new CompositeComponentImpl(URI.create("parent")); + Reference reference = new ReferenceImpl(URI.create("foo#reference"), null); + composite.register(reference); + assertNotNull(composite.getReference("reference")); + } + + public void testOnEvent() { + CompositeComponentImpl composite = new CompositeComponentImpl(URI.create("parent")); + Event event = new Event() { + public Object getSource() { + return null; + } + }; + RuntimeEventListener listener = createMock(RuntimeEventListener.class); + listener.onEvent(eq(event)); + expectLastCall(); + replay(listener); + composite.addListener(listener); + composite.start(); + composite.onEvent(event); + EasyMock.verify(listener); + } + +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/implementation/composite/DuplicateRegistrationTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/implementation/composite/DuplicateRegistrationTestCase.java new file mode 100644 index 0000000000..c3394c1043 --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/implementation/composite/DuplicateRegistrationTestCase.java @@ -0,0 +1,120 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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.implementation.composite; + +import java.net.URI; + +import org.apache.tuscany.spi.component.DuplicateNameException; +import org.apache.tuscany.spi.component.Service; +import org.apache.tuscany.spi.component.Reference; +import org.apache.tuscany.spi.component.Component; + +import junit.framework.TestCase; +import org.easymock.EasyMock; + +/** + * Verfies children with the same name cannot be registered in the same composite + * + * @version $Rev$ $Date$ + */ +public class DuplicateRegistrationTestCase extends TestCase { + + public void testDuplicateServiceRegistration() throws Exception { + Component parent = new CompositeComponentImpl(URI.create("parent")); + parent.start(); + + Service service1 = EasyMock.createMock(Service.class); + EasyMock.expect(service1.getUri()).andReturn(URI.create("#service")).atLeastOnce(); + service1.stop(); + EasyMock.replay(service1); + + Service service2 = EasyMock.createMock(Service.class); + EasyMock.expect(service2.getUri()).andReturn(URI.create("#service")).atLeastOnce(); + service2.stop(); + EasyMock.replay(service2); + + parent.register(service2); + try { + parent.register(service1); + fail(); + } catch (DuplicateNameException e) { + // ok + } + parent.stop(); + } + + public void testDuplicateReferenceRegistration() throws Exception { + Component parent = new CompositeComponentImpl(URI.create("parent")); + parent.start(); + + Reference reference1 = EasyMock.createMock(Reference.class); + EasyMock.expect(reference1.getUri()).andReturn(URI.create("#reference")).atLeastOnce(); + reference1.stop(); + EasyMock.replay(reference1); + + Reference reference2 = EasyMock.createMock(Reference.class); + EasyMock.expect(reference2.getUri()).andReturn(URI.create("#reference")).atLeastOnce(); + reference2.stop(); + EasyMock.replay(reference2); + + parent.register(reference2); + try { + parent.register(reference1); + fail(); + } catch (DuplicateNameException e) { + // ok + } + parent.stop(); + + } + + public void testDuplicateServiceReferenceRegistration() throws Exception { + Component parent = new CompositeComponentImpl(URI.create("parent")); + parent.start(); + + Service service1 = EasyMock.createMock(Service.class); + EasyMock.expect(service1.getUri()).andReturn(URI.create("#child")).atLeastOnce(); + service1.stop(); + EasyMock.replay(service1); + + Reference service2 = EasyMock.createMock(Reference.class); + EasyMock.expect(service2.getUri()).andReturn(URI.create("#child")).atLeastOnce(); + service2.stop(); + EasyMock.replay(service2); + + parent.register(service2); + try { + parent.register(service1); + fail(); + } catch (DuplicateNameException e) { + // ok + } + parent.stop(); + + } + + protected void setUp() throws Exception { + super.setUp(); + } + + protected void tearDown() throws Exception { + super.tearDown(); + } + +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/implementation/composite/ManagedRequestContextTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/implementation/composite/ManagedRequestContextTestCase.java new file mode 100644 index 0000000000..12299e762b --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/implementation/composite/ManagedRequestContextTestCase.java @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.implementation.composite; + +import org.osoa.sca.RequestContext; + +import org.apache.tuscany.spi.component.WorkContext; + +import junit.framework.TestCase; +import org.easymock.EasyMock; + +/** + * @version $Rev$ $Date$ + */ +public class ManagedRequestContextTestCase extends TestCase { + + public void testGetServiceName() { + WorkContext workContext = EasyMock.createMock(WorkContext.class); + EasyMock.expect(workContext.getCurrentServiceName()).andReturn("foo"); + EasyMock.replay(workContext); + RequestContext context = new ManagedRequestContext(workContext); + assertEquals("foo", context.getServiceName()); + EasyMock.verify(workContext); + } + +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/implementation/composite/ReferenceImplTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/implementation/composite/ReferenceImplTestCase.java new file mode 100644 index 0000000000..34d37469a7 --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/implementation/composite/ReferenceImplTestCase.java @@ -0,0 +1,55 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.implementation.composite; + +import java.net.URI; + +import org.apache.tuscany.spi.component.Reference; +import org.apache.tuscany.spi.component.ReferenceBinding; + +import junit.framework.TestCase; +import org.easymock.EasyMock; + +/** + * @version $Rev$ $Date$ + */ +public class ReferenceImplTestCase extends TestCase { + + public void testStart() { + ReferenceBinding binding = EasyMock.createMock(ReferenceBinding.class); + binding.start(); + EasyMock.replay(binding); + Reference reference = new ReferenceImpl(URI.create("ref"), null); + reference.addReferenceBinding(binding); + reference.start(); + EasyMock.verify(binding); + + } + + public void testStop() { + ReferenceBinding binding = EasyMock.createMock(ReferenceBinding.class); + binding.stop(); + EasyMock.replay(binding); + Reference reference = new ReferenceImpl(URI.create("ref"), null); + reference.addReferenceBinding(binding); + reference.stop(); + EasyMock.verify(binding); + + } +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/implementation/composite/ServiceImplTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/implementation/composite/ServiceImplTestCase.java new file mode 100644 index 0000000000..bb8ed020e0 --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/implementation/composite/ServiceImplTestCase.java @@ -0,0 +1,56 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.implementation.composite; + +import java.net.URI; + +import org.apache.tuscany.spi.component.Service; +import org.apache.tuscany.spi.component.ServiceBinding; + +import junit.framework.TestCase; +import org.easymock.EasyMock; + +/** + * @version $Rev$ $Date$ + */ +public class ServiceImplTestCase extends TestCase { + + public void testStart() { + ServiceBinding binding = EasyMock.createMock(ServiceBinding.class); + binding.start(); + EasyMock.replay(binding); + Service service = new ServiceImpl(URI.create("foo#bar"), null, null); + service.addServiceBinding(binding); + service.start(); + EasyMock.verify(binding); + + } + + public void testStop() { + ServiceBinding binding = EasyMock.createMock(ServiceBinding.class); + binding.stop(); + EasyMock.replay(binding); + Service service = new ServiceImpl(URI.create("foo#bar"), null, null); + service.addServiceBinding(binding); + service.stop(); + EasyMock.verify(binding); + + } + +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/injection/SingletonObjectFactoryTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/injection/SingletonObjectFactoryTestCase.java new file mode 100644 index 0000000000..876e68d5b3 --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/injection/SingletonObjectFactoryTestCase.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.injection; + +import junit.framework.TestCase; + +/** + * @version $Rev$ $Date$ + */ +public class SingletonObjectFactoryTestCase extends TestCase { + + public void testSingleton() throws Exception { + Object o = new Object(); + SingletonObjectFactory factory = new SingletonObjectFactory(o); + assertEquals(o, factory.getInstance()); + } +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/AsyncTarget.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/AsyncTarget.java new file mode 100644 index 0000000000..653d5d7335 --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/AsyncTarget.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.mock.component; + +import org.osoa.sca.annotations.OneWay; + +/** + * @version $Rev$ $Date$ + */ +public interface AsyncTarget { + @OneWay + void invoke(); + + int getCount(); +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/BadContextPojo.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/BadContextPojo.java new file mode 100644 index 0000000000..066acc346d --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/BadContextPojo.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.mock.component; + +import org.osoa.sca.annotations.Context; + +public class BadContextPojo { + + @Context + String context; + +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/BadNamePojo.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/BadNamePojo.java new file mode 100644 index 0000000000..77ec37f9e4 --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/BadNamePojo.java @@ -0,0 +1,26 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.mock.component; + +import org.osoa.sca.annotations.ComponentName; + +public class BadNamePojo { + @ComponentName + private int name; +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/BasicInterface.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/BasicInterface.java new file mode 100644 index 0000000000..b7921c248f --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/BasicInterface.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.mock.component; + +/** + * @version $Rev$ $Date$ + */ +public interface BasicInterface { + String returnsProperty(); + + BasicInterface returnsReference(); + + int returnsInt(); +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/BasicInterfaceImpl.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/BasicInterfaceImpl.java new file mode 100644 index 0000000000..f7d7bb38cf --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/BasicInterfaceImpl.java @@ -0,0 +1,66 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.mock.component; + +import org.osoa.sca.annotations.Property; +import org.osoa.sca.annotations.Reference; + +/** + * @version $Rev$ $Date$ + */ +public class BasicInterfaceImpl implements BasicInterface { + + @Property + public String publicProperty; + + @Reference (required = false) + public BasicInterface publicReference; + + @Property + protected String protectedProperty; + + @Reference (required = false) + protected BasicInterface protectedReference; + + private String privateProperty; + + private BasicInterface privateReference; + + @Property + public void setPrivateProperty(String privateProperty) { + this.privateProperty = privateProperty; + } + + @Reference (required = false) + public void setPrivateReference(BasicInterface privateReference) { + this.privateReference = privateReference; + } + + public String returnsProperty() { + return privateProperty; + } + + public BasicInterface returnsReference() { + return privateReference; + } + + public int returnsInt() { + return 0; + } +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/CompositeScopeComponent.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/CompositeScopeComponent.java new file mode 100644 index 0000000000..88b97216cd --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/CompositeScopeComponent.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.mock.component; + +import org.osoa.sca.annotations.Scope; + +/** + * @version $Rev$ $Date$ + */ +@Scope("COMPOSITE") +public interface CompositeScopeComponent { + + //public boolean isInit(); +} + diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/CompositeScopeComponentImpl.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/CompositeScopeComponentImpl.java new file mode 100644 index 0000000000..93ee1f707a --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/CompositeScopeComponentImpl.java @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.mock.component; + +import org.osoa.sca.annotations.Scope; + + +/** + * @version $Rev$ $Date$ + */ +@Scope("COMPOSITE") +public class CompositeScopeComponentImpl implements + CompositeScopeComponent { + + private String foo; + + public void setFoo(String foo) { + this.foo = foo; + } + + public String getFoo() { + return foo; + } +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/CompositeScopeDestroyOnlyComponent.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/CompositeScopeDestroyOnlyComponent.java new file mode 100644 index 0000000000..16ce3b5569 --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/CompositeScopeDestroyOnlyComponent.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.mock.component; + +import org.osoa.sca.annotations.Destroy; + +public class CompositeScopeDestroyOnlyComponent extends CompositeScopeComponentImpl { + + boolean destroyed; + + public boolean isDestroyed() { + return destroyed; + } + + @Destroy + public void destroy() { + destroyed = true; + } + +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/CompositeScopeInitDestroyComponent.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/CompositeScopeInitDestroyComponent.java new file mode 100644 index 0000000000..05b938a87c --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/CompositeScopeInitDestroyComponent.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.mock.component; + +import org.osoa.sca.annotations.Destroy; + +public class CompositeScopeInitDestroyComponent extends CompositeScopeInitOnlyComponent { + + boolean destroyed; + + public boolean isDestroyed() { + return destroyed; + } + + @Destroy + public void destroy() { + if (destroyed) { + throw new AssertionError("Destroy called more than once"); + } + destroyed = true; + } + +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/CompositeScopeInitOnlyComponent.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/CompositeScopeInitOnlyComponent.java new file mode 100644 index 0000000000..f9f80ca15c --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/CompositeScopeInitOnlyComponent.java @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.mock.component; + +import org.osoa.sca.annotations.Init; + +public class CompositeScopeInitOnlyComponent extends CompositeScopeComponentImpl { + + private boolean 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; + + public boolean isInitialized() { + return initialized; + } + + @Init + public void init() { + if (initialized) { + throw new AssertionError("Init called more than once"); + } + initialized = true; + } + +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/ConversationalScopeComponent.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/ConversationalScopeComponent.java new file mode 100644 index 0000000000..c71ac0586f --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/ConversationalScopeComponent.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.mock.component; + +import org.osoa.sca.annotations.Scope; + +/** + * @version $Rev: 430937 $ $Date: 2006-08-11 21:17:56 -0400 (Fri, 11 Aug 2006) $ + */ +@Scope("CONVERSATION") +public interface ConversationalScopeComponent { + +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/ConversationalScopeComponentImpl.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/ConversationalScopeComponentImpl.java new file mode 100644 index 0000000000..5ea7278e1f --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/ConversationalScopeComponentImpl.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.mock.component; + +import org.osoa.sca.annotations.Scope; + +/** + * @version $Rev: 430937 $ $Date: 2006-08-11 21:17:56 -0400 (Fri, 11 Aug 2006) $ + */ +@Scope("CONVERSATION") +public class ConversationalScopeComponentImpl implements ConversationalScopeComponent { + +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/ConversationalScopeDestroyOnlyComponent.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/ConversationalScopeDestroyOnlyComponent.java new file mode 100644 index 0000000000..8cea9efa49 --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/ConversationalScopeDestroyOnlyComponent.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.mock.component; + +import org.osoa.sca.annotations.Destroy; +import org.osoa.sca.annotations.Scope; + +@Scope("CONVERSATION") +public class ConversationalScopeDestroyOnlyComponent extends ConversationalScopeComponentImpl { + + boolean destroyed; + + public boolean isDestroyed() { + return destroyed; + } + + @Destroy + public void destroy() { + destroyed = true; + } +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/ConversationalScopeInitDestroyComponent.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/ConversationalScopeInitDestroyComponent.java new file mode 100644 index 0000000000..40dbfedf2c --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/ConversationalScopeInitDestroyComponent.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.mock.component; + +import org.osoa.sca.annotations.Destroy; +import org.osoa.sca.annotations.Scope; + +@Scope("CONVERSATION") +public class ConversationalScopeInitDestroyComponent + extends ConversationalScopeInitOnlyComponent { + + private boolean destroyed; + + public boolean isDestroyed() { + return destroyed; + } + + @Destroy + public void destroy() { + destroyed = true; + } +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/ConversationalScopeInitOnlyComponent.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/ConversationalScopeInitOnlyComponent.java new file mode 100644 index 0000000000..caaa0c39e7 --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/ConversationalScopeInitOnlyComponent.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.mock.component; + +import org.osoa.sca.annotations.Init; +import org.osoa.sca.annotations.Scope; + +@Scope("CONVERSATION") +public class ConversationalScopeInitOnlyComponent + extends ConversationalScopeComponentImpl { + + private boolean initialized; + + public boolean isInitialized() { + return initialized; + } + + @Init + public void init() { + initialized = true; + } +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/OrderException.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/OrderException.java new file mode 100644 index 0000000000..af257c226d --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/OrderException.java @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.mock.component; + +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/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/OrderedDependentPojo.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/OrderedDependentPojo.java new file mode 100644 index 0000000000..2033f0eca5 --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/OrderedDependentPojo.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.mock.component; + +/** + * @version $$Rev$$ $$Date$$ + */ +public interface OrderedDependentPojo extends OrderedInitPojo { + + OrderedInitPojo getPojo(); + + void setPojo(OrderedInitPojo pojo); +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/OrderedDependentPojoImpl.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/OrderedDependentPojoImpl.java new file mode 100644 index 0000000000..439c3d143c --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/OrderedDependentPojoImpl.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.mock.component; + +/** + * @version $$Rev$$ $$Date$$ + */ +public class OrderedDependentPojoImpl extends OrderedInitPojoImpl implements OrderedDependentPojo { + + private OrderedInitPojo pojo; + + public OrderedInitPojo getPojo() { + return pojo; + } + + public void setPojo(OrderedInitPojo pojo) { + this.pojo = pojo; + } + +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/OrderedEagerInitPojo.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/OrderedEagerInitPojo.java new file mode 100644 index 0000000000..1986952747 --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/OrderedEagerInitPojo.java @@ -0,0 +1,60 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.mock.component; + +import org.osoa.sca.annotations.Destroy; +import org.osoa.sca.annotations.Init; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.EagerInit; + +@Scope("COMPOSITE") +@EagerInit +public class OrderedEagerInitPojo { + + private static final 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/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/OrderedInitPojo.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/OrderedInitPojo.java new file mode 100644 index 0000000000..0b891cfa42 --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/OrderedInitPojo.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.mock.component; + +/** + * @version $$Rev$$ $$Date$$ + */ +public interface OrderedInitPojo { + int getNumberInstantiated(); + + int getInitOrder(); +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/OrderedInitPojoImpl.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/OrderedInitPojoImpl.java new file mode 100644 index 0000000000..a7063f6353 --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/OrderedInitPojoImpl.java @@ -0,0 +1,61 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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.Destroy; +import org.osoa.sca.annotations.Init; +import org.osoa.sca.annotations.Scope; + +@Scope("COMPOSITE") +public class OrderedInitPojoImpl implements OrderedInitPojo { + + private static final Object LOCK = new Object(); + private static int numberInstantied; + private int initOrder; + + public OrderedInitPojoImpl() { + } + + @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/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/OtherTarget.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/OtherTarget.java new file mode 100644 index 0000000000..0b897daa40 --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/OtherTarget.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.mock.component; + +/** + * Implementations are used in wiring tests + * + * @version $Rev$ $Date$ + */ +public interface OtherTarget { + + String getString(); + + void setString(String val); +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/OtherTargetImpl.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/OtherTargetImpl.java new file mode 100644 index 0000000000..a3b2bbf098 --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/OtherTargetImpl.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.mock.component; + +/** + * A target used for testing wires with a different source and target interface + * + * @version $Rev$ $Date$ + */ +public class OtherTargetImpl implements OtherTarget { + + private String theString; + + public String getString() { + return theString; + } + + public void setString(String val) { + theString = val; + } + + +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/RequestScopeComponent.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/RequestScopeComponent.java new file mode 100644 index 0000000000..8c7dc107ee --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/RequestScopeComponent.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.mock.component; + +import org.osoa.sca.annotations.Scope; + +/** + * @version $Rev$ $Date$ + */ +@Scope("REQUEST") +public interface RequestScopeComponent { + +} + diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/RequestScopeDestroyOnlyComponent.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/RequestScopeDestroyOnlyComponent.java new file mode 100644 index 0000000000..5224ceda5f --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/RequestScopeDestroyOnlyComponent.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.mock.component; + +import org.osoa.sca.annotations.Destroy; +import org.osoa.sca.annotations.Scope; + +@Scope("REQUEST") +public class RequestScopeDestroyOnlyComponent extends SessionScopeComponentImpl { + + boolean destroyed; + + public boolean isDestroyed() { + return destroyed; + } + + @Destroy + public void destroy() { + destroyed = true; + } + +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/RequestScopeInitDestroyComponent.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/RequestScopeInitDestroyComponent.java new file mode 100644 index 0000000000..38b188a4b5 --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/RequestScopeInitDestroyComponent.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.mock.component; + +import org.osoa.sca.annotations.Destroy; +import org.osoa.sca.annotations.Scope; + +@Scope("REQUEST") +public class RequestScopeInitDestroyComponent extends SessionScopeInitOnlyComponent { + + boolean destroyed; + + public boolean isDestroyed() { + return destroyed; + } + + @Destroy + public void destroy() { + destroyed = true; + } + +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/RequestScopeInitOnlyComponent.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/RequestScopeInitOnlyComponent.java new file mode 100644 index 0000000000..707f8ab50f --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/RequestScopeInitOnlyComponent.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.mock.component; + +import org.osoa.sca.annotations.Init; +import org.osoa.sca.annotations.Scope; + +@Scope("REQUEST") +public class RequestScopeInitOnlyComponent extends SessionScopeComponentImpl { + + private boolean initialized; + + public boolean isInitialized() { + return initialized; + } + + @Init + public void init() { + initialized = true; + } + + +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/SessionScopeComponent.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/SessionScopeComponent.java new file mode 100644 index 0000000000..827ba804f2 --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/SessionScopeComponent.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.mock.component; + +import org.osoa.sca.annotations.Scope; + +/** + * @version $Rev$ $Date$ + */ +@Scope("SESSION") +public interface SessionScopeComponent { + +} + diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/SessionScopeComponentImpl.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/SessionScopeComponentImpl.java new file mode 100644 index 0000000000..e547bf6113 --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/SessionScopeComponentImpl.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.mock.component; + +import org.osoa.sca.annotations.Scope; + +/** + * @version $Rev$ $Date$ + */ +@Scope("SESSION") +public class SessionScopeComponentImpl implements + SessionScopeComponent { + +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/SessionScopeInitDestroyComponent.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/SessionScopeInitDestroyComponent.java new file mode 100644 index 0000000000..c11bd1bd49 --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/SessionScopeInitDestroyComponent.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.mock.component; + +import org.osoa.sca.annotations.Destroy; + +public class SessionScopeInitDestroyComponent extends SessionScopeInitOnlyComponent { + + private boolean destroyed; + + public boolean isDestroyed() { + return destroyed; + } + + @Destroy + public void destroy() { + destroyed = true; + } + +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/SessionScopeInitOnlyComponent.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/SessionScopeInitOnlyComponent.java new file mode 100644 index 0000000000..095cc916ec --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/SessionScopeInitOnlyComponent.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.mock.component; + +import org.osoa.sca.annotations.Init; + +public class SessionScopeInitOnlyComponent extends SessionScopeComponentImpl { + + private boolean initialized; + + public boolean isInitialized() { + return initialized; + } + + @Init + public void init() { + initialized = true; + } + + +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/SimpleTarget.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/SimpleTarget.java new file mode 100644 index 0000000000..c78ba00a7a --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/SimpleTarget.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.mock.component; + +public interface SimpleTarget { + + String hello(String message) throws Exception; + + String goodbye(String message) throws Exception; + + String echo(String message) throws Exception; + +} + diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/SimpleTargetImpl.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/SimpleTargetImpl.java new file mode 100644 index 0000000000..634a07a401 --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/SimpleTargetImpl.java @@ -0,0 +1,41 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.mock.component; + +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/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/Source.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/Source.java new file mode 100644 index 0000000000..f7969f748b --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/Source.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.mock.component; + +import java.util.List; + +/** + * Implementations are used in wiring tests + * + * @version $Rev$ $Date$ + */ +public interface Source { + + Target getTarget(); + + List getTargets(); + + List getTargetsThroughField(); + +} + diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/SourceImpl.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/SourceImpl.java new file mode 100644 index 0000000000..187e33b2bd --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/SourceImpl.java @@ -0,0 +1,63 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.mock.component; + +import java.util.List; + +/** + * Mock system component implementation used in wiring tests + * + * @version $Rev$ $Date$ + */ +public class SourceImpl implements Source { + + private Target target; + private List targets; + private List targetsThroughField; + private Target[] targetsArray; + + public void setTarget(Target target) { + this.target = target; + } + + public Target getTarget() { + return target; + } + + public List getTargets() { + return targets; + } + + public void setTargets(List targets) { + this.targets = targets; + } + + public List getTargetsThroughField() { + return targetsThroughField; + } + + public Target[] getArrayOfTargets() { + return targetsArray; + } + + public void setArrayOfTargets(Target[] targets) { + targetsArray = targets; + } + +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/StatelessComponent.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/StatelessComponent.java new file mode 100644 index 0000000000..c16ac942a3 --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/StatelessComponent.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.mock.component; + +import org.osoa.sca.annotations.Scope; + +/** + * @version $Rev$ $Date$ + */ +@Scope("STATELESS") +public interface StatelessComponent { + +} + diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/StatelessComponentImpl.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/StatelessComponentImpl.java new file mode 100644 index 0000000000..64a23c12c8 --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/StatelessComponentImpl.java @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.mock.component; + +/** + * @version $Rev$ $Date$ + */ +public class StatelessComponentImpl implements + StatelessComponent { + +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/Target.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/Target.java new file mode 100644 index 0000000000..778c14665d --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/Target.java @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.mock.component; + +/** + * Implementations are used in wiring tests + * + * @version $Rev$ $Date$ + */ +public interface Target { + + String getString(); + + void setString(String val); +} + diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/TargetImpl.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/TargetImpl.java new file mode 100644 index 0000000000..037dd3a37c --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/TargetImpl.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.mock.component; + +/** + * Mock system component implementation used in wiring tests + * + * @version $Rev$ $Date$ + */ +public class TargetImpl implements Target { + + private String theString; + + public String getString() { + return theString; + } + + public void setString(String val) { + theString = val; + } + +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/wire/MockStaticInvoker.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/wire/MockStaticInvoker.java new file mode 100644 index 0000000000..98f5973f62 --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/wire/MockStaticInvoker.java @@ -0,0 +1,98 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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.wire; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +import org.apache.tuscany.spi.wire.Interceptor; +import org.apache.tuscany.spi.wire.InvocationRuntimeException; +import org.apache.tuscany.spi.wire.Message; +import org.apache.tuscany.spi.wire.TargetInvoker; +import org.apache.tuscany.spi.component.WorkContext; + +/** + * Caches component instances that do not need to be resolved for every wire, e.g. an wire originating from a lesser + * scope intended for a target with a wider scope + * + * @version $Rev$ $Date$ + */ +public class MockStaticInvoker implements TargetInvoker { + + private Object instance; + private Method operation; + private boolean cacheable; + + + public MockStaticInvoker(Method operation, Object instance) { + this.operation = operation; + this.instance = instance; + } + + public boolean isCacheable() { + return cacheable; + } + + public void setCacheable(boolean cacheable) { + this.cacheable = cacheable; + } + + public boolean isOptimizable() { + return isCacheable(); + } + + public Object invokeTarget(final Object payload, final short sequence, WorkContext workContext) 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) throws InvocationRuntimeException { + try { + Object resp = invokeTarget(msg.getBody(), TargetInvoker.NONE, null); + msg.setBody(resp); + } catch (InvocationTargetException e) { + msg.setBodyWithFault(e.getCause()); + } catch (Throwable e) { + msg.setBodyWithFault(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() throws CloneNotSupportedException { + 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/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/wire/MockSyncInterceptor.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/wire/MockSyncInterceptor.java new file mode 100644 index 0000000000..1fe2c027ab --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/wire/MockSyncInterceptor.java @@ -0,0 +1,55 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.mock.wire; + +import org.apache.tuscany.spi.wire.Interceptor; +import org.apache.tuscany.spi.wire.Message; + +public class MockSyncInterceptor implements Interceptor { + + private int count; + + private Interceptor next; + + public MockSyncInterceptor() { + } + + public Message invoke(Message msg) { + ++count; + return next.invoke(msg); + } + + public int getCount() { + return count; + } + + public void setNext(Interceptor next) { + this.next = next; + } + + public Interceptor getNext() { + return next; + } + + public boolean isOptimizable() { + return false; + } + +} + diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/wire/MockTargetInvoker.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/wire/MockTargetInvoker.java new file mode 100644 index 0000000000..3fcc75bdb4 --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/wire/MockTargetInvoker.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.mock.wire; + +import org.apache.tuscany.spi.wire.InvocationRuntimeException; +import org.apache.tuscany.spi.wire.Message; + +import org.apache.tuscany.core.binding.local.AbstractLocalTargetInvoker; + +/** + * @version $Rev$ $Date$ + */ +public class MockTargetInvoker extends AbstractLocalTargetInvoker { + public Message invoke(Message msg) throws InvocationRuntimeException { + return null; + } +} \ No newline at end of file diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/monitor/DefaultExceptionFormatterTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/monitor/DefaultExceptionFormatterTestCase.java new file mode 100644 index 0000000000..437e718206 --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/monitor/DefaultExceptionFormatterTestCase.java @@ -0,0 +1,59 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.monitor; + +import java.io.PrintWriter; +import java.io.StringWriter; + +import junit.framework.TestCase; +import org.apache.tuscany.api.TuscanyException; +import org.apache.tuscany.api.TuscanyRuntimeException; + +/** + * @version $Rev$ $Date$ + */ +public class DefaultExceptionFormatterTestCase extends TestCase { + private DefaultExceptionFormatter formatter = new DefaultExceptionFormatter(); + + public void testTuscanyExceptionFormat() throws Exception { + StringWriter writer = new StringWriter(); + PrintWriter pw = new PrintWriter(writer); + TuscanyException e = new TuscanyException("somemessage") { + }; + formatter.write(pw, e); + assertTrue(writer.toString().indexOf("somemessage") >= 0); + } + + public void testTuscanyRuntimeExceptionFormat() throws Exception { + StringWriter writer = new StringWriter(); + PrintWriter pw = new PrintWriter(writer); + TuscanyRuntimeException e = new TuscanyRuntimeException("somemessage") { + }; + formatter.write(pw, e); + assertTrue(writer.toString().indexOf("somemessage") >= 0); + } + + public void testNormalExceptionFormat() throws Exception { + StringWriter writer = new StringWriter(); + PrintWriter pw = new PrintWriter(writer); + Exception e = new Exception(); + formatter.write(pw, e); // just verify there are no errors since no formatting needs to be doen + } + +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/monitor/JavaLoggingTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/monitor/JavaLoggingTestCase.java new file mode 100644 index 0000000000..5fdf035c7a --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/monitor/JavaLoggingTestCase.java @@ -0,0 +1,153 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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.monitor; + +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 org.apache.tuscany.api.annotation.LogLevel; +import org.apache.tuscany.host.MonitorFactory; + +import junit.framework.TestCase; + +/** + * Test case for the JavaLoggingMonitorFactory. + * + * @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()); + } + + /** + * Test that no record is logged. + */ + public void testUnloggedEvent() { + Monitor mon = factory.getMonitor(Monitor.class); + mon.eventNotToLog(); + assertEquals(0, HANDLER.logs.size()); + } + + /** + * Test the correct record is written for an event with no arguments. + */ + 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()); + } + + /** + * Test the correct record is written for an event defined by annotation. + */ + 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()); + } + + /** + * Test the argument is logged. + */ + 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()); + } + + 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, "TestMessages"); + } + + protected void tearDown() throws Exception { + LOGGER.removeHandler(HANDLER); + HANDLER.flush(); + super.tearDown(); + } + + /** + * Mock log HANDLER to capture records. + */ + public static class MockHandler extends Handler { + List logs = new ArrayList(); + + public void publish(LogRecord record) { + logs.add(record); + } + + public void flush() { + logs.clear(); + } + + public void close() throws SecurityException { + } + } + + @SuppressWarnings({"JavaDoc"}) + public static interface Monitor { + void eventNotToLog(); + + @LogLevel("INFO") + void eventWithNoArgs(); + + @LogLevel("INFO") + void eventWithOneArg(String msg); + + @LogLevel("WARNING") + void eventWithThrowable(Exception e); + + @LogLevel("INFO") + void eventWithAnnotation(); + } +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/resolver/DefaultAutowireResolverTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/resolver/DefaultAutowireResolverTestCase.java new file mode 100644 index 0000000000..6d50489f18 --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/resolver/DefaultAutowireResolverTestCase.java @@ -0,0 +1,177 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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.resolver; + +import java.net.URI; + +import org.apache.tuscany.spi.model.AtomicImplementation; +import org.apache.tuscany.spi.model.ComponentDefinition; +import org.apache.tuscany.spi.model.ComponentType; +import org.apache.tuscany.spi.model.CompositeComponentType; +import org.apache.tuscany.spi.model.CompositeImplementation; +import org.apache.tuscany.spi.model.Property; +import org.apache.tuscany.spi.model.ReferenceDefinition; +import org.apache.tuscany.spi.model.ReferenceTarget; +import org.apache.tuscany.spi.model.ServiceContract; +import org.apache.tuscany.spi.model.ServiceDefinition; + +import junit.framework.TestCase; + +/** + * @version $Rev$ $Date$ + */ +public class DefaultAutowireResolverTestCase extends TestCase { + private static final URI REFERENCE_URI = URI.create("source#ref"); + private static final URI TARGET_URI = URI.create("target#service"); + private DefaultAutowireResolver resolver; + + public void testAutowireAtomicToAtomic() throws Exception { + ComponentDefinition composite = createComposite("composite"); + CompositeComponentType type = composite.getImplementation().getComponentType(); + ComponentDefinition source = createSourceAtomic(Foo.class); + type.add(source); + ComponentDefinition target = createTargetAtomic(Foo.class); + type.add(target); + resolver.resolve(null, composite); + ReferenceTarget refTarget = source.getReferenceTargets().get(REFERENCE_URI.getFragment()); + assertEquals(TARGET_URI, refTarget.getTargets().get(0)); + } + + public void testAutowireAtomicToAtomicRequiresSuperInterface() throws Exception { + ComponentDefinition composite = createComposite("composite"); + CompositeComponentType type = composite.getImplementation().getComponentType(); + ComponentDefinition source = createSourceAtomic(SuperFoo.class); + type.add(source); + ComponentDefinition target = createTargetAtomic(Foo.class); + type.add(target); + resolver.resolve(null, composite); + ReferenceTarget refTarget = source.getReferenceTargets().get(REFERENCE_URI.getFragment()); + assertEquals(TARGET_URI, refTarget.getTargets().get(0)); + } + + public void testAutowireAtomicToAtomicRequiresSubInterface() throws Exception { + ComponentDefinition composite = createComposite("composite"); + CompositeComponentType type = composite.getImplementation().getComponentType(); + ComponentDefinition source = createSourceAtomic(Foo.class); + type.add(source); + ComponentDefinition target = createTargetAtomic(SuperFoo.class); + type.add(target); + try { + resolver.resolve(null, composite); + fail(); + } catch (AutowireTargetNotFoundException e) { + // expected + } + } + + public void testAutowireAtomicToAtomicIncompatibleInterfaces() throws Exception { + ComponentDefinition composite = createComposite("composite"); + CompositeComponentType type = composite.getImplementation().getComponentType(); + ComponentDefinition source = createSourceAtomic(Foo.class); + type.add(source); + ComponentDefinition target = createTargetAtomic(String.class); + type.add(target); + try { + resolver.resolve(null, composite); + fail(); + } catch (AutowireTargetNotFoundException e) { + // expected + } + } + + public void testNestedAutowireAtomicToAtomic() throws Exception { + ComponentDefinition composite = createComposite("composite"); + CompositeComponentType type = composite.getImplementation().getComponentType(); + ComponentDefinition source = createSourceAtomic(Foo.class); + type.add(source); + ComponentDefinition target = createTargetAtomic(Foo.class); + type.add(target); + ComponentDefinition parent = createComposite("parent"); + parent.getImplementation().getComponentType().add(composite); + resolver.resolve(null, parent); + ReferenceTarget refTarget = source.getReferenceTargets().get(REFERENCE_URI.getFragment()); + assertEquals(TARGET_URI, refTarget.getTargets().get(0)); + } + + + protected void setUp() throws Exception { + super.setUp(); + resolver = new DefaultAutowireResolver(); + } + + private ComponentDefinition createComposite(String uri) { + URI parentUri = URI.create(uri); + CompositeComponentType> type = + new CompositeComponentType>(); + CompositeImplementation impl = new CompositeImplementation(); + impl.setComponentType(type); + return new ComponentDefinition(parentUri, impl); + } + + private ComponentDefinition createSourceAtomic(Class requiredInterface) { + URI uri = URI.create("source"); + ServiceContract contract = new ServiceContract() { + }; + contract.setInterfaceClass(requiredInterface); + ReferenceDefinition reference = new ReferenceDefinition(URI.create("#ref"), contract); + reference.setRequired(true); + MockComponentType type = new MockComponentType(); + type.add(reference); + MockAtomicImpl impl = new MockAtomicImpl(); + impl.setComponentType(type); + ComponentDefinition definition = new ComponentDefinition(uri, impl); + ReferenceTarget target = new ReferenceTarget(); + target.setReferenceName(REFERENCE_URI); + target.setAutowire(true); + definition.add(target); + return definition; + } + + private ComponentDefinition createTargetAtomic(Class serviceInterface) { + URI uri = URI.create("target"); + ServiceDefinition service = new ServiceDefinition(); + service.setUri(URI.create("#service")); + ServiceContract contract = new ServiceContract() { + }; + contract.setInterfaceClass(serviceInterface); + service.setServiceContract(contract); + MockComponentType type = new MockComponentType(); + type.add(service); + MockAtomicImpl impl = new MockAtomicImpl(); + impl.setComponentType(type); + return new ComponentDefinition(uri, impl); + } + + private class MockAtomicImpl extends AtomicImplementation { + + } + + private class MockComponentType extends ComponentType> { + + } + + private interface SuperFoo { + + } + + private interface Foo extends SuperFoo { + + } + +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/services/store/memory/MemoryStoreTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/services/store/memory/MemoryStoreTestCase.java new file mode 100644 index 0000000000..06ea7cf903 --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/services/store/memory/MemoryStoreTestCase.java @@ -0,0 +1,166 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.services.store.memory; + +import java.net.URI; +import java.util.UUID; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + +import org.apache.tuscany.spi.component.AtomicComponent; +import org.apache.tuscany.spi.event.RuntimeEventListener; +import org.apache.tuscany.spi.services.store.DuplicateRecordException; +import org.apache.tuscany.spi.services.store.Store; +import org.apache.tuscany.spi.services.store.StoreExpirationEvent; +import org.apache.tuscany.spi.services.store.StoreMonitor; + +import junit.framework.TestCase; +import org.easymock.EasyMock; +import org.easymock.IAnswer; + +/** + * @version $Rev$ $Date$ + */ +public class MemoryStoreTestCase extends TestCase { + private StoreMonitor monitor; + + public void testEviction() throws Exception { + MemoryStore store = new MemoryStore(monitor); + store.setReaperInterval(10); + store.init(); + AtomicComponent component = EasyMock.createNiceMock(AtomicComponent.class); + EasyMock.replay(component); + String id = UUID.randomUUID().toString(); + Object value = new Object(); + store.insertRecord(component, id, value, 1); + Thread.sleep(100); + assertNull(store.readRecord(component, id)); + store.destroy(); + } + + public void testNotifyOnEviction() throws Exception { + final CountDownLatch latch = new CountDownLatch(1); + RuntimeEventListener listener = EasyMock.createMock(RuntimeEventListener.class); + listener.onEvent(EasyMock.isA(StoreExpirationEvent.class)); + org.easymock.classextension.EasyMock.expectLastCall().andStubAnswer(new IAnswer() { + public Object answer() throws Throwable { + latch.countDown(); + return null; + } + }); + EasyMock.replay(listener); + MemoryStore store = new MemoryStore(monitor); + store.addListener(listener); + store.setReaperInterval(10); + store.init(); + AtomicComponent component = EasyMock.createNiceMock(AtomicComponent.class); + EasyMock.replay(component); + String id = UUID.randomUUID().toString(); + Object value = new Object(); + store.insertRecord(component, id, value, 1); + if (!latch.await(1000, TimeUnit.MILLISECONDS)) { + // failed to notify listener + fail(); + } + EasyMock.verify(listener); + } + + public void testNoEviction() throws Exception { + MemoryStore store = new MemoryStore(monitor); + store.setReaperInterval(10); + store.init(); + AtomicComponent component = EasyMock.createNiceMock(AtomicComponent.class); + EasyMock.replay(component); + String id = UUID.randomUUID().toString(); + Object value = new Object(); + store.insertRecord(component, id, value, Store.NEVER); + Thread.sleep(100); + assertNotNull(store.readRecord(component, id)); + store.destroy(); + } + + public void testInsertRecord() throws Exception { + MemoryStore store = new MemoryStore(monitor); + store.setReaperInterval(10); + store.init(); + AtomicComponent component = EasyMock.createNiceMock(AtomicComponent.class); + EasyMock.replay(component); + String id = UUID.randomUUID().toString(); + Object value = new Object(); + store.insertRecord(component, id, value, Store.NEVER); + store.destroy(); + } + + public void testInsertAlreadyExists() throws Exception { + MemoryStore store = new MemoryStore(monitor); + store.setReaperInterval(10); + store.init(); + AtomicComponent component = EasyMock.createMock(AtomicComponent.class); + EasyMock.expect(component.getUri()).andReturn(URI.create("component")); + EasyMock.replay(component); + String id = UUID.randomUUID().toString(); + Object value = new Object(); + store.insertRecord(component, id, value, Store.NEVER); + try { + store.insertRecord(component, id, value, Store.NEVER); + fail(); + } catch (DuplicateRecordException e) { + //expected + } + store.destroy(); + } + + public void testUpdateRecord() throws Exception { + MemoryStore store = new MemoryStore(monitor); + store.setReaperInterval(10); + store.init(); + AtomicComponent component = EasyMock.createNiceMock(AtomicComponent.class); + EasyMock.replay(component); + String id = UUID.randomUUID().toString(); + Object value = new Object(); + Object newValue = new Object(); + + store.insertRecord(component, id, value, Store.NEVER); + store.updateRecord(component, id, newValue, 1L); + assertEquals(newValue, store.readRecord(component, id)); + store.destroy(); + } + + public void testDeleteRecord() throws Exception { + MemoryStore store = new MemoryStore(monitor); + store.setReaperInterval(10); + store.init(); + AtomicComponent component = EasyMock.createNiceMock(AtomicComponent.class); + EasyMock.replay(component); + String id = UUID.randomUUID().toString(); + Object value = new Object(); + + store.insertRecord(component, id, value, Store.NEVER); + store.removeRecord(component, id); + assertNull(store.readRecord(component, id)); + store.destroy(); + } + + protected void setUp() throws Exception { + super.setUp(); + monitor = EasyMock.createNiceMock(StoreMonitor.class); + EasyMock.replay(monitor); + } + +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/util/Bean1.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/util/Bean1.java new file mode 100644 index 0000000000..79fad549aa --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/util/Bean1.java @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.util; + + +public class Bean1 extends SuperBean { + + public static final int ALL_BEAN1_FIELDS = 6 + ALL_SUPER_FIELDS; + public static final int ALL_BEAN1_PUBLIC_PROTECTED_FIELDS = 5 + ALL_SUPER_PUBLIC_PROTECTED_FIELDS; + public static final int ALL_BEAN1_METHODS = 4 + ALL_SUPER_METHODS - 1; + public String field3; + protected String field2; + 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/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/util/Bean2.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/util/Bean2.java new file mode 100644 index 0000000000..7f7f03da9e --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/util/Bean2.java @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.util; + +import java.util.List; + +import junit.framework.AssertionFailedError; + +public class Bean2 { + + private List methodList; + private List fieldList; + + public List getMethodList() { + return methodList; + } + + public void setMethodList(List list) { + methodList = list; + } + + public List getfieldList() { + return fieldList; + } + + public void setfieldList(List list) { + throw new AssertionFailedError("setter inadvertantly called"); + } + + +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/util/JavaIntrospectionHelperTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/util/JavaIntrospectionHelperTestCase.java new file mode 100644 index 0000000000..797b147b54 --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/util/JavaIntrospectionHelperTestCase.java @@ -0,0 +1,180 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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.util; + +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import junit.framework.TestCase; +import org.apache.tuscany.core.mock.component.Target; + +public class JavaIntrospectionHelperTestCase extends TestCase { + + private List testNoGenericsList; + private List testList; + private Map testMap; + private Target[] testArray; + private String[] testStringArray; + + public JavaIntrospectionHelperTestCase() { + super(); + } + + public JavaIntrospectionHelperTestCase(String arg0) { + super(arg0); + } + + public void testBean1AllPublicProtectedFields() throws Exception { + Set beanFields = JavaIntrospectionHelper.getAllPublicAndProtectedFields(Bean1.class); + assertEquals(4, beanFields.size()); //Bean1.ALL_BEAN1_PUBLIC_PROTECTED_FIELDS + } + + public void testGetSuperAllMethods() throws Exception { + Set superBeanMethods = JavaIntrospectionHelper.getAllUniquePublicProtectedMethods(SuperBean.class); + assertEquals(SuperBean.ALL_SUPER_METHODS, superBeanMethods.size()); + } + + public void testGetBean1AllMethods() throws Exception { + Set beanMethods = JavaIntrospectionHelper.getAllUniquePublicProtectedMethods(Bean1.class); + assertEquals(Bean1.ALL_BEAN1_METHODS, beanMethods.size()); + } + + public void testOverrideMethod() throws Exception { + Set beanFields = JavaIntrospectionHelper.getAllUniquePublicProtectedMethods(Bean1.class); + boolean invoked = false; + for (Method method : beanFields) { + if (method.getName().equals("override")) { + method.invoke(new Bean1(), "foo"); + invoked = true; + } + } + if (!invoked) { + throw new Exception("Override never invoked"); + } + } + + public void testNoOverrideMethod() throws Exception { + Set beanFields = JavaIntrospectionHelper.getAllUniquePublicProtectedMethods(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 testDefaultConstructor() throws Exception { + Constructor ctr = JavaIntrospectionHelper.getDefaultConstructor(Bean2.class); + assertEquals(ctr, Bean2.class.getConstructor()); + assertTrue(Bean2.class == ctr.newInstance((Object[]) null).getClass()); + } + + + public void testGetAllInterfaces() { + Set interfaces = JavaIntrospectionHelper.getAllInterfaces(Z.class); + assertEquals(2, interfaces.size()); + assertTrue(interfaces.contains(W.class)); + assertTrue(interfaces.contains(W2.class)); + } + + + public void testGetAllInterfacesObject() { + Set interfaces = JavaIntrospectionHelper.getAllInterfaces(Object.class); + assertEquals(0, interfaces.size()); + } + + public void testGetAllInterfacesNoInterfaces() { + Set interfaces = JavaIntrospectionHelper.getAllInterfaces(NoInterface.class); + assertEquals(0, interfaces.size()); + } + + /** + * Tests generics introspection capabilities + */ + public void testGenerics() throws Exception { + + List classes = JavaIntrospectionHelper.getGenerics(getClass().getDeclaredField("testList").getGenericType()); + assertEquals(1, classes.size()); + assertEquals(String.class, classes.get(0)); + + classes = + JavaIntrospectionHelper.getGenerics(getClass().getDeclaredField("testNoGenericsList").getGenericType()); + assertEquals(0, classes.size()); + + classes = JavaIntrospectionHelper.getGenerics(getClass().getDeclaredField("testMap").getGenericType()); + assertEquals(2, classes.size()); + assertEquals(String.class, classes.get(0)); + assertEquals(Bean1.class, classes.get(1)); + + classes = JavaIntrospectionHelper + .getGenerics(getClass().getDeclaredMethod("fooMethod", Map.class).getGenericParameterTypes()[0]); + assertEquals(2, classes.size()); + assertEquals(String.class, classes.get(0)); + assertEquals(Bean1.class, classes.get(1)); + + classes = JavaIntrospectionHelper + .getGenerics(getClass().getDeclaredMethod("fooMethod", List.class).getGenericParameterTypes()[0]); + assertEquals(1, classes.size()); + assertEquals(String.class, classes.get(0)); + + } + + private void fooMethod(List foo) { + + } + + private void fooMethod(Map foo) { + + } + + public void setTestArray(Target[] array) { + } + + private interface W { + + } + + private interface W2 { + + } + + private class X implements W { + + } + + private class Y extends X implements W, W2 { + + } + + private class Z extends Y { + + } + + private class NoInterface { + + } + +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/util/SuperBean.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/util/SuperBean.java new file mode 100644 index 0000000000..83aef7fb5e --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/util/SuperBean.java @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.util; + +/** + * @version $Rev$ $Date$ + */ +public class SuperBean { + + public static final int ALL_SUPER_FIELDS = 6; + public static final int ALL_SUPER_PUBLIC_PROTECTED_FIELDS = 5; + public static final int ALL_SUPER_METHODS = 4; + public String superField2; + + protected String superField3; + + 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/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/wire/CallbackInterfaceInterceptorTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/wire/CallbackInterfaceInterceptorTestCase.java new file mode 100644 index 0000000000..6c50cb406f --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/wire/CallbackInterfaceInterceptorTestCase.java @@ -0,0 +1,60 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.wire; + +import org.osoa.sca.NoRegisteredCallbackException; + +import org.apache.tuscany.spi.wire.Interceptor; +import org.apache.tuscany.spi.wire.Message; +import org.apache.tuscany.spi.wire.MessageImpl; + +import junit.framework.TestCase; +import org.easymock.EasyMock; + +/** + * @version $Rev$ $Date$ + */ +public class CallbackInterfaceInterceptorTestCase extends TestCase { + + public void testOptimize() throws Exception { + CallbackInterfaceInterceptor interceptor = new CallbackInterfaceInterceptor(true); + assertFalse(interceptor.isOptimizable()); + } + + public void testImplements() { + CallbackInterfaceInterceptor interceptor = new CallbackInterfaceInterceptor(true); + Interceptor next = EasyMock.createMock(Interceptor.class); + EasyMock.expect(next.invoke(EasyMock.isA(Message.class))).andReturn(null); + EasyMock.replay(next); + interceptor.setNext(next); + interceptor.invoke(new MessageImpl()); + EasyMock.verify(next); + } + + public void testDoesNotImplement() { + CallbackInterfaceInterceptor interceptor = new CallbackInterfaceInterceptor(false); + try { + interceptor.invoke(new MessageImpl()); + fail(); + } catch (NoRegisteredCallbackException e) { + // expected + } + } + +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/wire/ContractCompatibilityTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/wire/ContractCompatibilityTestCase.java new file mode 100644 index 0000000000..c955faf7b1 --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/wire/ContractCompatibilityTestCase.java @@ -0,0 +1,390 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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.wire; + +import java.lang.reflect.Method; +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.tuscany.spi.QualifiedName; +import org.apache.tuscany.spi.component.ReferenceBinding; +import org.apache.tuscany.spi.model.DataType; +import org.apache.tuscany.spi.model.Operation; +import static org.apache.tuscany.spi.model.Operation.NO_CONVERSATION; +import org.apache.tuscany.spi.model.ServiceContract; +import org.apache.tuscany.spi.wire.ChainHolder; +import org.apache.tuscany.spi.wire.IncompatibleServiceContractException; +import org.apache.tuscany.spi.wire.ProxyCreationException; +import org.apache.tuscany.spi.wire.Wire; +import org.apache.tuscany.spi.wire.ProxyService; +import org.apache.tuscany.spi.wire.InvocationChain; + +import junit.framework.TestCase; +import org.osoa.sca.CallableReference; + +/** + * TODO some tests commented out due to DataType.equals() needing to be strict + * + * @version $Rev$ $Date$ + */ +public class ContractCompatibilityTestCase extends TestCase { + + private ProxyService proxyService = new MockProxyService(); + + public void testNoOperation() throws Exception { + ServiceContract source = new MockContract("FooContract"); + ServiceContract target = new MockContract("FooContract"); + proxyService.checkCompatibility(source, target, false, false); + } + + public void testBasic() throws Exception { + ServiceContract source = new MockContract("FooContract"); + Operation opSource1 = new Operation("op1", null, null, null, false, null, NO_CONVERSATION); + Map> sourceOperations = new HashMap>(); + sourceOperations.put("op1", opSource1); + source.setOperations(sourceOperations); + ServiceContract target = new MockContract("FooContract"); + Operation opSource2 = new Operation("op1", null, null, null, false, null, NO_CONVERSATION); + Map> targetOperations = new HashMap>(); + targetOperations.put("op1", opSource2); + target.setOperations(targetOperations); + proxyService.checkCompatibility(source, target, false, false); + } + + public void testBasicIncompatibleOperationNames() throws Exception { + ServiceContract source = new MockContract("FooContract"); + Operation opSource1 = new Operation("op1", null, null, null, false, null, NO_CONVERSATION); + Map> sourceOperations = new HashMap>(); + sourceOperations.put("op1", opSource1); + source.setOperations(sourceOperations); + ServiceContract target = new MockContract("FooContract"); + Operation opSource2 = new Operation("op2", null, null, null, false, null, NO_CONVERSATION); + Map> targetOperations = new HashMap>(); + targetOperations.put("op2", opSource2); + target.setOperations(targetOperations); + try { + proxyService.checkCompatibility(source, target, false, false); + fail(); + } catch (IncompatibleServiceContractException e) { + //expected + } + } + + public void testInputTypes() throws Exception { + ServiceContract source = new MockContract("FooContract"); + List> sourceInputTypes = new ArrayList>(); + sourceInputTypes.add(new DataType(Object.class, Object.class)); + DataType>> inputType = new DataType>>(String.class, sourceInputTypes); + Operation opSource1 = new Operation("op1", inputType, null, null, false, null, NO_CONVERSATION); + Map> sourceOperations = new HashMap>(); + sourceOperations.put("op1", opSource1); + source.setOperations(sourceOperations); + + ServiceContract target = new MockContract("FooContract"); + List> targetInputTypes = new ArrayList>(); + targetInputTypes.add(new DataType(Object.class, Object.class)); + DataType>> targetInputType = + new DataType>>(String.class, targetInputTypes); + + Operation opTarget = + new Operation("op1", targetInputType, null, null, false, null, NO_CONVERSATION); + Map> targetOperations = new HashMap>(); + targetOperations.put("op1", opTarget); + target.setOperations(targetOperations); + proxyService.checkCompatibility(source, target, false, false); + } + + + public void testIncompatibleInputTypes() throws Exception { + ServiceContract source = new MockContract("FooContract"); + List> sourceInputTypes = new ArrayList>(); + sourceInputTypes.add(new DataType(Integer.class, Integer.class)); + DataType>> inputType = new DataType>>(String.class, sourceInputTypes); + Operation opSource1 = new Operation("op1", inputType, null, null, false, null, NO_CONVERSATION); + Map> sourceOperations = new HashMap>(); + sourceOperations.put("op1", opSource1); + source.setOperations(sourceOperations); + + ServiceContract target = new MockContract("FooContract"); + List> targetInputTypes = new ArrayList>(); + targetInputTypes.add(new DataType(String.class, String.class)); + DataType>> targetInputType = + new DataType>>(String.class, targetInputTypes); + + Operation opTarget = + new Operation("op1", targetInputType, null, null, false, null, NO_CONVERSATION); + Map> targetOperations = new HashMap>(); + targetOperations.put("op1", opTarget); + target.setOperations(targetOperations); + try { + proxyService.checkCompatibility(source, target, false, false); + fail(); + } catch (IncompatibleServiceContractException e) { + //expected + } + } + + /** + * Verfies source input types can be super types of the target + */ + public void testSourceSuperTypeInputCompatibility() throws Exception { +// ServiceContract source = new MockContract("FooContract"); +// List> sourceInputTypes = new ArrayList>(); +// sourceInputTypes.add(new DataType(Object.class, Object.class)); +// DataType>> inputType = new DataType>>(String.class, sourceInputTypes); +// Operation opSource1 = new Operation("op1", inputType, null, null, false, null); +// Map> sourceOperations = new HashMap>(); +// sourceOperations.put("op1", opSource1); +// source.setOperations(sourceOperations); +// +// ServiceContract target = new MockContract("FooContract"); +// List> targetInputTypes = new ArrayList>(); +// targetInputTypes.add(new DataType(String.class, String.class)); +// DataType>> targetInputType = +// new DataType>>(String.class, targetInputTypes); +// +// Operation opTarget = new Operation("op1", targetInputType, null, null, false, null); +// Map> targetOperations = new HashMap>(); +// targetOperations.put("op1", opTarget); +// target.setOperations(targetOperations); +// wireService.checkCompatibility(source, target, false); + } + + public void testOutputTypes() throws Exception { + ServiceContract source = new MockContract("FooContract"); + DataType sourceOutputType = new DataType(String.class, String.class); + Operation opSource1 = + new Operation("op1", null, sourceOutputType, null, false, null, NO_CONVERSATION); + Map> sourceOperations = new HashMap>(); + sourceOperations.put("op1", opSource1); + source.setOperations(sourceOperations); + + ServiceContract target = new MockContract("FooContract"); + DataType targetOutputType = new DataType(String.class, String.class); + Operation opTarget = + new Operation("op1", null, targetOutputType, null, false, null, NO_CONVERSATION); + Map> targetOperations = new HashMap>(); + targetOperations.put("op1", opTarget); + target.setOperations(targetOperations); + proxyService.checkCompatibility(source, target, false, false); + } + + /** + * Verfies a return type that is a supertype of of the target is compatible + */ + public void testSupertypeOutputTypes() throws Exception { +// ServiceContract source = new MockContract("FooContract"); +// DataType sourceOutputType = new DataType(Object.class, Object.class); +// Operation opSource1 = new Operation("op1", null, sourceOutputType, null, false, null); +// Map> sourceOperations = new HashMap>(); +// sourceOperations.put("op1", opSource1); +// source.setOperations(sourceOperations); +// +// ServiceContract target = new MockContract("FooContract"); +// DataType targetOutputType = new DataType(String.class, String.class); +// Operation opTarget = new Operation("op1", null, targetOutputType, null, false, null); +// Map> targetOperations = new HashMap>(); +// targetOperations.put("op1", opTarget); +// target.setOperations(targetOperations); +// wireService.checkCompatibility(source, target, false); + } + + public void testIncompatibleOutputTypes() throws Exception { + ServiceContract source = new MockContract("FooContract"); + DataType sourceOutputType = new DataType(String.class, String.class); + Operation opSource1 = + new Operation("op1", null, sourceOutputType, null, false, null, NO_CONVERSATION); + Map> sourceOperations = new HashMap>(); + sourceOperations.put("op1", opSource1); + source.setOperations(sourceOperations); + + ServiceContract target = new MockContract("FooContract"); + DataType targetOutputType = new DataType(Integer.class, Integer.class); + Operation opTarget = + new Operation("op1", null, targetOutputType, null, false, null, NO_CONVERSATION); + Map> targetOperations = new HashMap>(); + targetOperations.put("op1", opTarget); + target.setOperations(targetOperations); + try { + proxyService.checkCompatibility(source, target, false, false); + fail(); + } catch (IncompatibleServiceContractException e) { + //expected + } + } + + public void testFaultTypes() throws Exception { + ServiceContract source = new MockContract("FooContract"); + DataType sourceFaultType = new DataType(String.class, String.class); + List> sourceFaultTypes = new ArrayList>(); + sourceFaultTypes.add(0, sourceFaultType); + Operation opSource1 = + new Operation("op1", null, null, sourceFaultTypes, false, null, NO_CONVERSATION); + Map> sourceOperations = new HashMap>(); + sourceOperations.put("op1", opSource1); + source.setOperations(sourceOperations); + + ServiceContract target = new MockContract("FooContract"); + DataType targetFaultType = new DataType(String.class, String.class); + List> targetFaultTypes = new ArrayList>(); + targetFaultTypes.add(0, targetFaultType); + + Operation opTarget = + new Operation("op1", null, null, targetFaultTypes, false, null, NO_CONVERSATION); + Map> targetOperations = new HashMap>(); + targetOperations.put("op1", opTarget); + target.setOperations(targetOperations); + proxyService.checkCompatibility(source, target, false, false); + } + + public void testSourceFaultTargetNoFaultCompatibility() throws Exception { + ServiceContract source = new MockContract("FooContract"); + DataType sourceFaultType = new DataType(String.class, String.class); + List> sourceFaultTypes = new ArrayList>(); + sourceFaultTypes.add(0, sourceFaultType); + Operation opSource1 = + new Operation("op1", null, null, sourceFaultTypes, false, null, NO_CONVERSATION); + Map> sourceOperations = new HashMap>(); + sourceOperations.put("op1", opSource1); + source.setOperations(sourceOperations); + + ServiceContract target = new MockContract("FooContract"); + Operation opTarget = new Operation("op1", null, null, null, false, null, NO_CONVERSATION); + Map> targetOperations = new HashMap>(); + targetOperations.put("op1", opTarget); + target.setOperations(targetOperations); + proxyService.checkCompatibility(source, target, false, false); + } + + /** + * Verifies a source's fault which is a supertype of the target's fault are compatibile + * + * @throws Exception + */ + public void testFaultSuperTypes() throws Exception { +// ServiceContract source = new MockContract("FooContract"); +// DataType sourceFaultType = new DataType(Exception.class, Exception.class); +// List> sourceFaultTypes = new ArrayList>(); +// sourceFaultTypes.add(0, sourceFaultType); +// Operation opSource1 = new Operation("op1", null, null, sourceFaultTypes, false, null); +// Map> sourceOperations = new HashMap>(); +// sourceOperations.put("op1", opSource1); +// source.setOperations(sourceOperations); +// +// ServiceContract target = new MockContract("FooContract"); +// DataType targetFaultType = new DataType(TuscanyException.class, TuscanyException.class); +// List> targetFaultTypes = new ArrayList>(); +// targetFaultTypes.add(0, targetFaultType); +// +// Operation opTarget = new Operation("op1", null, null, targetFaultTypes, false, null); +// Map> targetOperations = new HashMap>(); +// targetOperations.put("op1", opTarget); +// target.setOperations(targetOperations); +// wireService.checkCompatibility(source, target, false); + } + + /** + * Verifies a source's faults which are supertypes and a superset of the target's faults are compatibile + */ + public void testFaultSuperTypesAndSuperset() throws Exception { +// ServiceContract source = new MockContract("FooContract"); +// DataType sourceFaultType = new DataType(Exception.class, Exception.class); +// DataType sourceFaultType2 = new DataType(RuntimeException.class, RuntimeException.class); +// List> sourceFaultTypes = new ArrayList>(); +// sourceFaultTypes.add(0, sourceFaultType); +// sourceFaultTypes.add(1, sourceFaultType2); +// Operation opSource1 = new Operation("op1", null, null, sourceFaultTypes, false, null); +// Map> sourceOperations = new HashMap>(); +// sourceOperations.put("op1", opSource1); +// source.setOperations(sourceOperations); +// +// ServiceContract target = new MockContract("FooContract"); +// DataType targetFaultType = new DataType(TuscanyException.class, TuscanyException.class); +// List> targetFaultTypes = new ArrayList>(); +// targetFaultTypes.add(0, targetFaultType); +// +// Operation opTarget = new Operation("op1", null, null, targetFaultTypes, false, null); +// Map> targetOperations = new HashMap>(); +// targetOperations.put("op1", opTarget); +// target.setOperations(targetOperations); +// wireService.checkCompatibility(source, target, false); + } + + private class MockContract extends ServiceContract { + public MockContract() { + } + + public MockContract(Class interfaceClass) { + super(interfaceClass); + } + + public MockContract(String interfaceName) { + super(interfaceName); + } + } + + private class MockProxyService extends ProxyServiceExtension { + public MockProxyService() { + super(null); + } + + public T createProxy(Class interfaze, Wire wire) throws ProxyCreationException { + throw new UnsupportedOperationException(); + } + + public T createProxy2(Class interfaze, boolean conversational, Wire wire) throws ProxyCreationException { + throw new UnsupportedOperationException(); + } + + public T createProxy2(Class interfaze, Wire wire) throws ProxyCreationException { + throw new UnsupportedOperationException(); + } + + public T createProxy(Class interfaze, Wire wire, Map mapping) + throws ProxyCreationException { + throw new UnsupportedOperationException(); + } + + public T createProxy2(Class interfaze, Wire wire, Map mapping) + throws ProxyCreationException { + throw new UnsupportedOperationException(); + } + + public Object createCallbackProxy(Class interfaze, List wires) throws ProxyCreationException { + throw new UnsupportedOperationException(); + } + + public Object createCallbackProxy(Class interfaze) throws ProxyCreationException { + throw new UnsupportedOperationException(); + } + + public void createWires(ReferenceBinding referenceBinding, ServiceContract contract, + QualifiedName targetName) { + throw new UnsupportedOperationException(); + } + + public > R cast(B target) throws IllegalArgumentException { + throw new UnsupportedOperationException(); + } + } + +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/wire/IncompatibleServiceContractExceptionFormatterTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/wire/IncompatibleServiceContractExceptionFormatterTestCase.java new file mode 100644 index 0000000000..a9f455bc62 --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/wire/IncompatibleServiceContractExceptionFormatterTestCase.java @@ -0,0 +1,82 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.wire; + +import java.io.PrintWriter; +import java.io.StringWriter; + +import org.apache.tuscany.spi.model.Operation; +import org.apache.tuscany.spi.model.ServiceContract; +import org.apache.tuscany.spi.wire.IncompatibleServiceContractException; + +import junit.framework.TestCase; +import org.apache.tuscany.host.monitor.FormatterRegistry; +import org.easymock.EasyMock; + +/** + * @version $Rev$ $Date$ + */ +public class IncompatibleServiceContractExceptionFormatterTestCase extends TestCase { + FormatterRegistry registry = EasyMock.createNiceMock(FormatterRegistry.class); + IncompatibleServiceContractExceptionFormatter formatter = + new IncompatibleServiceContractExceptionFormatter(registry); + + public void testFormat() throws Exception { + ServiceContract source = new ServiceContract() { + }; + source.setInterfaceName("sourceInterface"); + ServiceContract target = new ServiceContract() { + }; + target.setInterfaceName("targetInterface"); + Operation sourceOp = new Operation("sourceOp", null, null, null); + Operation targetOp = new Operation("targetOp", null, null, null); + + IncompatibleServiceContractException e = + new IncompatibleServiceContractException("message", source, target, sourceOp, targetOp); + StringWriter writer = new StringWriter(); + PrintWriter pw = new PrintWriter(writer); + formatter.write(pw, e); + String buffer = writer.toString(); + assertTrue(buffer.indexOf("message") >= 0); + assertTrue(buffer.indexOf("sourceInterface") >= 0); + assertTrue(buffer.indexOf("targetInterface") >= 0); + assertTrue(buffer.indexOf("sourceOp") >= 0); + assertTrue(buffer.indexOf("targetOp") >= 0); + } + + + public void testFormatNulls() throws Exception { + ServiceContract source = new ServiceContract() { + }; + source.setInterfaceName("sourceInterface"); + ServiceContract target = new ServiceContract() { + }; + target.setInterfaceName("targetInterface"); + + IncompatibleServiceContractException e = + new IncompatibleServiceContractException("message", source, target); + StringWriter writer = new StringWriter(); + PrintWriter pw = new PrintWriter(writer); + formatter.write(pw, e); + String buffer = writer.toString(); + assertTrue(buffer.indexOf("message") >= 0); + assertTrue(buffer.indexOf("sourceInterface") >= 0); + assertTrue(buffer.indexOf("targetInterface") >= 0); + } +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/wire/InvocationChainImplTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/wire/InvocationChainImplTestCase.java new file mode 100644 index 0000000000..9875058abb --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/wire/InvocationChainImplTestCase.java @@ -0,0 +1,84 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.wire; + +import java.lang.reflect.Type; + +import org.apache.tuscany.spi.model.Operation; +import org.apache.tuscany.spi.wire.Interceptor; +import org.apache.tuscany.spi.wire.Message; +import org.apache.tuscany.spi.wire.InvocationChain; + +import junit.framework.TestCase; + +/** + * @version $Rev$ $Date$ + */ +public class InvocationChainImplTestCase extends TestCase { + + public void testInsertAtPos() throws Exception { + InvocationChain chain = new InvocationChainImpl(new Operation("foo", null, null, null)); + Interceptor inter3 = new MockInterceptor(); + Interceptor inter2 = new MockInterceptor(); + Interceptor inter1 = new MockInterceptor(); + chain.addInterceptor(inter3); + chain.addInterceptor(0, inter1); + chain.addInterceptor(1, inter2); + Interceptor head = chain.getHeadInterceptor(); + assertEquals(inter1, head); + assertEquals(inter2, head.getNext()); + assertEquals(inter3, head.getNext().getNext()); + } + + public void testInsertAtEnd() throws Exception { + InvocationChain chain = new InvocationChainImpl(new Operation("foo", null, null, null)); + Interceptor inter2 = new MockInterceptor(); + Interceptor inter1 = new MockInterceptor(); + chain.addInterceptor(0, inter1); + chain.addInterceptor(1, inter2); + Interceptor head = chain.getHeadInterceptor(); + assertEquals(inter1, head); + assertEquals(inter2, head.getNext()); + assertEquals(inter2, chain.getTailInterceptor()); + + } + + private class MockInterceptor implements Interceptor { + + private Interceptor next; + + public Message invoke(Message msg) { + return null; + } + + public void setNext(Interceptor next) { + this.next = next; + } + + public Interceptor getNext() { + return next; + } + + public boolean isOptimizable() { + return false; + } + } + + +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/wire/NonBlockingInterceptorBuilderTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/wire/NonBlockingInterceptorBuilderTestCase.java new file mode 100644 index 0000000000..c563217306 --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/wire/NonBlockingInterceptorBuilderTestCase.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.wire; + +import static org.apache.tuscany.core.wire.NonBlockingInterceptorBuilder.QNAME; + +import org.apache.tuscany.spi.model.physical.PhysicalInterceptorDefinition; + +import junit.framework.TestCase; + +/** + * @version $Rev$ $Date$ + */ +public class NonBlockingInterceptorBuilderTestCase extends TestCase { + + public void testBuild() throws Exception { + NonBlockingInterceptorBuilder builder = new NonBlockingInterceptorBuilder(null, null); + PhysicalInterceptorDefinition definition = new PhysicalInterceptorDefinition(QNAME); + definition.setBuilder(QNAME); + assertTrue(builder.build(definition) instanceof NonBlockingInterceptor); + } +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/wire/NonBlockingInterceptorTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/wire/NonBlockingInterceptorTestCase.java new file mode 100644 index 0000000000..c08d1453db --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/wire/NonBlockingInterceptorTestCase.java @@ -0,0 +1,75 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.wire; + +import org.apache.tuscany.spi.component.WorkContext; +import org.apache.tuscany.spi.model.Scope; +import org.apache.tuscany.spi.services.work.WorkScheduler; +import org.apache.tuscany.spi.wire.Interceptor; +import org.apache.tuscany.spi.wire.Message; +import org.apache.tuscany.spi.wire.MessageImpl; + +import junit.framework.TestCase; +import org.easymock.EasyMock; +import static org.easymock.EasyMock.createMock; +import static org.easymock.EasyMock.expectLastCall; +import static org.easymock.EasyMock.getCurrentArguments; +import static org.easymock.EasyMock.isA; +import static org.easymock.EasyMock.replay; +import static org.easymock.EasyMock.verify; +import org.easymock.IAnswer; + +/** + * @version $Rev$ $Date$ + */ +public class NonBlockingInterceptorTestCase extends TestCase { + + public void testInvoke() throws Exception { + WorkScheduler scheduler = createMock(WorkScheduler.class); + scheduler.scheduleWork(isA(Runnable.class)); + expectLastCall().andStubAnswer(new IAnswer() { + public Object answer() throws Throwable { + Runnable runnable = (Runnable) getCurrentArguments()[0]; + runnable.run(); + return null; + } + }); + replay(scheduler); + WorkContext context = createMock(WorkContext.class); + String convID = "convID"; + EasyMock.expect(context.getIdentifier(Scope.CONVERSATION)).andReturn(convID); + context.setCorrelationId(null); + context.setIdentifier(Scope.CONVERSATION, convID); + EasyMock.replay(context); + Message msg = new MessageImpl(); + Interceptor next = EasyMock.createMock(Interceptor.class); + EasyMock.expect(next.invoke(EasyMock.eq(msg))).andReturn(msg); + EasyMock.replay(next); + Interceptor interceptor = new NonBlockingInterceptor(scheduler, context, next); + interceptor.invoke(msg); + verify(context); + verify(next); + } + + public void testOptimizable() { + NonBlockingInterceptor interceptor = new NonBlockingInterceptor(null, null); + assertFalse(interceptor.isOptimizable()); + } + +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/wire/OptimizedWireObjectFactoryTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/wire/OptimizedWireObjectFactoryTestCase.java new file mode 100644 index 0000000000..5293678d12 --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/wire/OptimizedWireObjectFactoryTestCase.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.wire; + +import org.apache.tuscany.spi.wire.Wire; + +import junit.framework.TestCase; +import org.easymock.EasyMock; + +/** + * @version $Rev$ $Date$ + */ +public class OptimizedWireObjectFactoryTestCase extends TestCase { + + public void testGetInstance() throws Exception { + Foo foo = new Foo(); + Wire wire = EasyMock.createMock(Wire.class); + EasyMock.expect(wire.getTargetInstance()).andReturn(foo); + EasyMock.replay(wire); + OptimizedWireObjectFactory factory = new OptimizedWireObjectFactory(Foo.class, wire); + assertEquals(foo, factory.getInstance()); + EasyMock.verify(wire); + } + + private class Foo { + + } +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/wire/WireImplTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/wire/WireImplTestCase.java new file mode 100644 index 0000000000..e337133523 --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/wire/WireImplTestCase.java @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.wire; + +import org.apache.tuscany.spi.component.AtomicComponent; +import org.apache.tuscany.spi.wire.Wire; + +import junit.framework.TestCase; +import org.easymock.EasyMock; + +/** + * @version $Rev$ $Date$ + */ +public class WireImplTestCase extends TestCase { + + /** + * Tests that the target wire returns null if there is no connected wire. This behavior is needed for optional + * autowires. + */ + public void testGetNonExistentTarget() throws Exception { + Wire wire = new WireImpl(); + assertNull(wire.getTargetInstance()); + } + + public void testTargetInstance() throws Exception { + Wire wire = new WireImpl(); + AtomicComponent component = EasyMock.createMock(AtomicComponent.class); + EasyMock.expect(component.getTargetInstance()).andReturn(new Object()); + EasyMock.replay(component); + wire.setTarget(component); + assertNotNull(wire.getTargetInstance()); + } + +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/wire/WireObjectFactoryTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/wire/WireObjectFactoryTestCase.java new file mode 100644 index 0000000000..9f21b9efdb --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/wire/WireObjectFactoryTestCase.java @@ -0,0 +1,138 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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.wire; + +import java.lang.reflect.Type; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + +import org.apache.tuscany.spi.idl.java.JavaServiceContract; +import org.apache.tuscany.spi.model.Operation; +import org.apache.tuscany.spi.model.ServiceContract; +import org.apache.tuscany.spi.wire.ProxyService; +import org.apache.tuscany.spi.wire.InvocationChain; +import org.apache.tuscany.spi.wire.Wire; + +import junit.framework.TestCase; +import org.easymock.EasyMock; + +/** + * @version $Rev$ $Date$ + */ +public class WireObjectFactoryTestCase extends TestCase { + + @SuppressWarnings({"unchecked"}) + public void testCreateInstance() throws Exception { + Operation op = new Operation("hello", null, null, null); + InvocationChain chain = new InvocationChainImpl(op); + Wire wire = EasyMock.createMock(Wire.class); + Map, InvocationChain> chains = new HashMap, InvocationChain>(); + chains.put(op, chain); + EasyMock.expect(wire.getInvocationChains()).andReturn(chains); + EasyMock.expect(wire.isOptimizable()).andReturn(false); + EasyMock.replay(wire); + ProxyService service = EasyMock.createMock(ProxyService.class); + service.createProxy(EasyMock.eq(Foo.class), EasyMock.eq(wire), EasyMock.isA(Map.class)); + EasyMock.expectLastCall().andReturn(new Foo() { + public void hello() { + + } + }); + EasyMock.replay(service); + + WireObjectFactory factory = new WireObjectFactory(Foo.class, wire, service); + factory.getInstance(); + EasyMock.verify(service); + EasyMock.verify(wire); + } + + @SuppressWarnings("unchecked") + public void testOptimizedCreateInstance() throws Exception { + ServiceContract contract = new JavaServiceContract(Foo.class); + Wire wire = EasyMock.createMock(Wire.class); + EasyMock.expect(wire.isOptimizable()).andReturn(true); + EasyMock.expect(wire.getSourceContract()).andReturn(contract).atLeastOnce(); + EasyMock.expect(wire.getInvocationChains()).andReturn((Map) Collections.emptyMap()); + EasyMock.expect(wire.getTargetInstance()).andReturn(new Foo() { + public void hello() { + } + }); + EasyMock.replay(wire); + WireObjectFactory factory = new WireObjectFactory(Foo.class, wire, null); + factory.getInstance(); + EasyMock.verify(wire); + + } + + /** + * Verifies that a proxy is created when the required client contract is different than the wire contract + */ + @SuppressWarnings("unchecked") + public void testCannotOptimizeDifferentContractsCreateInstance() throws Exception { + ServiceContract contract = new JavaServiceContract(Object.class); + Wire wire = EasyMock.createMock(Wire.class); + EasyMock.expect(wire.isOptimizable()).andReturn(true); + EasyMock.expect(wire.getSourceContract()).andReturn(contract).atLeastOnce(); + EasyMock.expect(wire.getInvocationChains()).andReturn((Map) Collections.emptyMap()); + EasyMock.replay(wire); + ProxyService service = EasyMock.createMock(ProxyService.class); + service.createProxy(EasyMock.eq(Foo.class), EasyMock.eq(wire), EasyMock.isA(Map.class)); + EasyMock.expectLastCall().andReturn(new Foo() { + public void hello() { + + } + }); + EasyMock.replay(service); + + WireObjectFactory factory = new WireObjectFactory(Foo.class, wire, service); + factory.getInstance(); + EasyMock.verify(service); + EasyMock.verify(wire); + } + + @SuppressWarnings("unchecked") + public void testNoJavaInterfaceCreateInstance() throws Exception { + ServiceContract contract = new JavaServiceContract(); + Wire wire = EasyMock.createMock(Wire.class); + EasyMock.expect(wire.isOptimizable()).andReturn(true); + EasyMock.expect(wire.getSourceContract()).andReturn(contract).atLeastOnce(); + EasyMock.expect(wire.getInvocationChains()).andReturn((Map) Collections.emptyMap()); + EasyMock.replay(wire); + ProxyService service = EasyMock.createMock(ProxyService.class); + service.createProxy(EasyMock.eq(Foo.class), EasyMock.eq(wire), EasyMock.isA(Map.class)); + EasyMock.expectLastCall().andReturn(new Foo() { + public void hello() { + + } + }); + EasyMock.replay(service); + + WireObjectFactory factory = new WireObjectFactory(Foo.class, wire, service); + factory.getInstance(); + EasyMock.verify(service); + EasyMock.verify(wire); + } + + private interface Foo { + void hello(); + } + + +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/wire/WireOptimizationTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/wire/WireOptimizationTestCase.java new file mode 100644 index 0000000000..1db3892471 --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/wire/WireOptimizationTestCase.java @@ -0,0 +1,113 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.wire; + +import java.lang.reflect.Type; + +import org.apache.tuscany.spi.component.AtomicComponent; +import org.apache.tuscany.spi.model.Operation; +import static org.apache.tuscany.spi.model.Operation.NO_CONVERSATION; +import org.apache.tuscany.spi.wire.Interceptor; +import org.apache.tuscany.spi.wire.InvocationChain; +import org.apache.tuscany.spi.wire.Message; +import org.apache.tuscany.spi.wire.Wire; + +import junit.framework.TestCase; +import org.easymock.EasyMock; + +/** + * Verifies wire optimization analysis + * + * @version $$Rev$$ $$Date$$ + */ +public class WireOptimizationTestCase extends TestCase { + private Operation operation; + + public void foo() { + } + + public void testWireInterceptorOptimization() throws Exception { + AtomicComponent component = EasyMock.createNiceMock(AtomicComponent.class); + EasyMock.replay(component); + Wire wire = new WireImpl(); + InvocationChain chain = new InvocationChainImpl(operation); + chain.addInterceptor(new OptimizableInterceptor()); + wire.addInvocationChain(operation, chain); + assertTrue(WireUtils.isOptimizable(wire)); + } + + public void testWireNonInterceptorOptimization() throws Exception { + AtomicComponent component = EasyMock.createNiceMock(AtomicComponent.class); + EasyMock.replay(component); + Wire wire = new WireImpl(); + InvocationChain chain = new InvocationChainImpl(operation); + chain.addInterceptor(new NonOptimizableInterceptor()); + wire.addInvocationChain(operation, chain); + assertFalse(WireUtils.isOptimizable(wire)); + } + + protected void tearDown() throws Exception { + super.tearDown(); + } + + protected void setUp() throws Exception { + super.setUp(); + operation = new Operation("foo", null, null, null, false, null, NO_CONVERSATION); + + } + + private class OptimizableInterceptor implements Interceptor { + + public Message invoke(Message msg) { + return null; + } + + public void setNext(Interceptor next) { + + } + + public Interceptor getNext() { + return null; + } + + public boolean isOptimizable() { + return true; + } + } + + private class NonOptimizableInterceptor implements Interceptor { + + public Message invoke(Message msg) { + return null; + } + + public void setNext(Interceptor next) { + + } + + public Interceptor getNext() { + return null; + } + + public boolean isOptimizable() { + return false; + } + } + +} diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/wire/WireUtilsTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/wire/WireUtilsTestCase.java new file mode 100644 index 0000000000..a9da65e0ba --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/wire/WireUtilsTestCase.java @@ -0,0 +1,69 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.wire; + +import java.lang.reflect.Method; +import java.lang.reflect.Type; +import java.util.Map; + +import org.apache.tuscany.spi.model.Operation; +import org.apache.tuscany.spi.wire.ChainHolder; +import org.apache.tuscany.spi.wire.InvocationChain; +import org.apache.tuscany.spi.wire.Wire; + +import junit.framework.TestCase; + +/** + * @version $Rev$ $Date$ + */ +public class WireUtilsTestCase extends TestCase { + private Method m; + + public void testCreateInterfaceToWireMapping() throws Exception { + Wire wire = new WireImpl(); + Operation op = new Operation("hello", null, null, null); + InvocationChain chain = new InvocationChainImpl(op); + wire.addInvocationChain(op, chain); + Map chains = WireUtils.createInterfaceToWireMapping(Foo.class, wire); + assertEquals(1, chains.size()); + assertNotNull(chains.get(m)); + } + + public void testCreateInterfaceToWireMappingNoOperation() throws Exception { + Wire wire = new WireImpl(); + Operation op = new Operation("goodbye", null, null, null); + InvocationChain chain = new InvocationChainImpl(op); + wire.addInvocationChain(op, chain); + try { + WireUtils.createInterfaceToWireMapping(Foo.class, wire); + fail(); + } catch (NoMethodForOperationException e) { + // expected + } + } + + protected void setUp() throws Exception { + super.setUp(); + m = Foo.class.getMethod("hello"); + } + + private interface Foo { + void hello(); + } +} diff --git a/sandbox/rfeng/minicore/src/test/resources/deployables/sample-calculator.jar b/sandbox/rfeng/minicore/src/test/resources/deployables/sample-calculator.jar new file mode 100644 index 0000000000..0ca3a1b781 Binary files /dev/null and b/sandbox/rfeng/minicore/src/test/resources/deployables/sample-calculator.jar differ diff --git a/sandbox/rfeng/minicore/src/test/resources/marshall/javaChangeSet.xml b/sandbox/rfeng/minicore/src/test/resources/marshall/javaChangeSet.xml new file mode 100644 index 0000000000..2ac4c6932e --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/resources/marshall/javaChangeSet.xml @@ -0,0 +1,72 @@ + + + + + + + #123 + + AB12345 + + + + + + #123 + + com.acme.Foo + init + destroy + java.lang.String + java.lang.Long + + + + + + + + + + + + + java.lang.String + java.lang.Long + java.lang.Object + + + + + + + + + java.lang.String + java.lang.Long + java.lang.Object + + + + \ No newline at end of file diff --git a/sandbox/rfeng/minicore/src/test/resources/org/apache/tuscany/core/deployer/boot1-include.scdl b/sandbox/rfeng/minicore/src/test/resources/org/apache/tuscany/core/deployer/boot1-include.scdl new file mode 100644 index 0000000000..838dbf6a9c --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/resources/org/apache/tuscany/core/deployer/boot1-include.scdl @@ -0,0 +1,32 @@ + + + + + + + + + + + + + diff --git a/sandbox/rfeng/minicore/src/test/resources/org/apache/tuscany/core/deployer/boot1.scdl b/sandbox/rfeng/minicore/src/test/resources/org/apache/tuscany/core/deployer/boot1.scdl new file mode 100644 index 0000000000..8a71aa5698 --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/resources/org/apache/tuscany/core/deployer/boot1.scdl @@ -0,0 +1,34 @@ + + + + + + + + + + propval + + + + + diff --git a/sandbox/rfeng/minicore/src/test/resources/org/apache/tuscany/core/deployer/boot2.scdl b/sandbox/rfeng/minicore/src/test/resources/org/apache/tuscany/core/deployer/boot2.scdl new file mode 100644 index 0000000000..a4f5ecf1e9 --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/resources/org/apache/tuscany/core/deployer/boot2.scdl @@ -0,0 +1,160 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + .m2/repository + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/rfeng/minicore/src/test/resources/org/apache/tuscany/core/loader/TestPolicy.scdl b/sandbox/rfeng/minicore/src/test/resources/org/apache/tuscany/core/loader/TestPolicy.scdl new file mode 100644 index 0000000000..ee75ea23f0 --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/resources/org/apache/tuscany/core/loader/TestPolicy.scdl @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sandbox/rfeng/minicore/src/test/resources/org/apache/tuscany/core/loader/test-include.scdl b/sandbox/rfeng/minicore/src/test/resources/org/apache/tuscany/core/loader/test-include.scdl new file mode 100644 index 0000000000..584846504b --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/resources/org/apache/tuscany/core/loader/test-include.scdl @@ -0,0 +1,22 @@ + + + + This file just needs to exist + \ No newline at end of file diff --git a/sandbox/rfeng/minicore/src/test/resources/org/apache/tuscany/core/policy/PolicySet.scdl b/sandbox/rfeng/minicore/src/test/resources/org/apache/tuscany/core/policy/PolicySet.scdl new file mode 100644 index 0000000000..0860855d9d --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/resources/org/apache/tuscany/core/policy/PolicySet.scdl @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sandbox/rfeng/minicore/src/test/resources/org/apache/tuscany/core/property/ipo.xml b/sandbox/rfeng/minicore/src/test/resources/org/apache/tuscany/core/property/ipo.xml new file mode 100644 index 0000000000..5bef464cf7 --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/resources/org/apache/tuscany/core/property/ipo.xml @@ -0,0 +1,51 @@ + + + + + + Helen Zoe + 47 Eden Street + Cambridge + CB1 1JR + + + + Robert Smith + 8 Oak Avenue + Old Town + PA + 95819 + + + + + Lapis necklace + 1 + 99.95 + Want this for the holidays + 1999-12-05 + + + + diff --git a/sandbox/rfeng/minicore/src/test/resources/org/apache/tuscany/core/services/deployment/test.ext b/sandbox/rfeng/minicore/src/test/resources/org/apache/tuscany/core/services/deployment/test.ext new file mode 100644 index 0000000000..042f3ce1f3 --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/resources/org/apache/tuscany/core/services/deployment/test.ext @@ -0,0 +1,18 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ diff --git a/sandbox/rfeng/minicore/src/test/resources/org/apache/tuscany/core/services/deployment/test.scdl b/sandbox/rfeng/minicore/src/test/resources/org/apache/tuscany/core/services/deployment/test.scdl new file mode 100644 index 0000000000..1e09549194 --- /dev/null +++ b/sandbox/rfeng/minicore/src/test/resources/org/apache/tuscany/core/services/deployment/test.scdl @@ -0,0 +1,22 @@ + + + + This file just needs to exist + \ No newline at end of file diff --git a/sandbox/rfeng/minicore/src/test/resources/repository/sample-calculator.jar b/sandbox/rfeng/minicore/src/test/resources/repository/sample-calculator.jar new file mode 100644 index 0000000000..0ca3a1b781 Binary files /dev/null and b/sandbox/rfeng/minicore/src/test/resources/repository/sample-calculator.jar differ diff --git a/sandbox/rfeng/runtime/embedded/.checkstyle b/sandbox/rfeng/runtime/embedded/.checkstyle new file mode 100644 index 0000000000..ea05637a07 --- /dev/null +++ b/sandbox/rfeng/runtime/embedded/.checkstyle @@ -0,0 +1,24 @@ + + + + + + + diff --git a/sandbox/rfeng/runtime/embedded/.pmd b/sandbox/rfeng/runtime/embedded/.pmd new file mode 100644 index 0000000000..3493a9e386 --- /dev/null +++ b/sandbox/rfeng/runtime/embedded/.pmd @@ -0,0 +1,20 @@ + + +truefalse \ No newline at end of file diff --git a/sandbox/rfeng/runtime/embedded/.ruleset b/sandbox/rfeng/runtime/embedded/.ruleset new file mode 100644 index 0000000000..a7ff3be272 --- /dev/null +++ b/sandbox/rfeng/runtime/embedded/.ruleset @@ -0,0 +1,190 @@ + + + + PMD Plugin preferences rule set + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/rfeng/runtime/embedded/LICENSE.txt b/sandbox/rfeng/runtime/embedded/LICENSE.txt new file mode 100644 index 0000000000..0084319535 --- /dev/null +++ b/sandbox/rfeng/runtime/embedded/LICENSE.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, serviceDefinition marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/sandbox/rfeng/runtime/embedded/NOTICE.txt b/sandbox/rfeng/runtime/embedded/NOTICE.txt new file mode 100644 index 0000000000..d83ebbe236 --- /dev/null +++ b/sandbox/rfeng/runtime/embedded/NOTICE.txt @@ -0,0 +1,14 @@ +${pom.name} +Copyright (c) 2005 - 2006 The Apache Software Foundation + +Apache Tuscany is an effort undergoing incubation at The Apache Software +Foundation (ASF), sponsored by the Apache Web Services PMC. Incubation is +required of all newly accepted projects until a further review indicates that +the infrastructure, communications, and decision making process have stabilized +in a manner consistent with other successful ASF projects. While incubation +status is not necessarily a reflection of the completeness or stability of the +code, it does indicate that the project has yet to be fully endorsed by the ASF. + +This product includes software developed by +The Apache Software Foundation (http://www.apache.org/). + diff --git a/sandbox/rfeng/runtime/embedded/pom.xml b/sandbox/rfeng/runtime/embedded/pom.xml new file mode 100644 index 0000000000..a51ff50160 --- /dev/null +++ b/sandbox/rfeng/runtime/embedded/pom.xml @@ -0,0 +1,47 @@ + + + + + org.apache.tuscany.sca + runtime + 2.0-alpha2-incubating-SNAPSHOT + + 4.0.0 + org.apache.tuscany.sca.runtime.embedded + embedded-host + jar + Apache Tuscany Embedded Runtime Host + Host code to support an embedded runtime + + + + org.apache.tuscany.sca.kernel + tuscany-core + 2.0-alpha2-incubating-SNAPSHOT + compile + + + junit + junit + 4.2 + test + + + diff --git a/sandbox/rfeng/runtime/embedded/src/main/java/org/apache/tuscany/api/SCARuntime.java b/sandbox/rfeng/runtime/embedded/src/main/java/org/apache/tuscany/api/SCARuntime.java new file mode 100644 index 0000000000..8fb945a28a --- /dev/null +++ b/sandbox/rfeng/runtime/embedded/src/main/java/org/apache/tuscany/api/SCARuntime.java @@ -0,0 +1,249 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.api; + +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 org.osoa.sca.ComponentContext; + +/** + * SCARuntime is used to start a Tuscany SCA runtime. + */ +public abstract class SCARuntime { + + private static SCARuntime instance; + + /** + * Read the service name from a configuration file + * + * @param classLoader + * @param name The name of the service class + * @return A class name which extends/implements the service class + * @throws IOException + */ + private static String getServiceName(ClassLoader classLoader, String name) throws IOException { + InputStream is = classLoader.getResourceAsStream("META-INF/services/" + name); + if (is == null) { + return null; + } + BufferedReader reader = null; + try { + reader = new BufferedReader(new InputStreamReader(is)); + while (true) { + String line = reader.readLine(); + if (line == null) { + break; + } else if (!line.startsWith("#")) { + return line.trim(); + } + } + } finally { + if (reader != null) { + reader.close(); + } + } + return null; + } + + /** + * Returns a SCARuntime instance. If the system property + * "org.apache.tuscany.api.SCARuntime" is set, its value is used as the name + * of the implementation class. Otherwise, if the resource + * "META-INF/services/org.apache.tuscany.api.SCARuntime" can be loaded from + * the supplied classloader. Otherwise, it will use + * "org.apache.tuscany.runtime.embedded.DefaultSCARuntime" as the default. + * The named class is loaded from the supplied classloader and instantiated + * using its default (no-arg) constructor. + * + * @return + */ + private static SCARuntime newInstance(final ClassLoader classLoader) { + + try { + final String name = SCARuntime.class.getName(); + String className = AccessController.doPrivileged(new PrivilegedAction() { + public String run() { + return System.getProperty(name); + } + }); + + if (className == null) { + className = getServiceName(classLoader, name); + } + if (className == null) { + className = "org.apache.tuscany.runtime.embedded.DefaultSCARuntime"; + } + Class cls = Class.forName(className, true, classLoader); + return (SCARuntime)cls.newInstance(); // NOPMD lresende + } catch (Exception e) { + throw new IllegalStateException(e); + } + } + + /** + * Get an instance of SCA Runtime + * + * @return The instance + */ + public static synchronized SCARuntime getInstance() { // NOPMD + if (instance != null) { + return instance; + } + ClassLoader classLoader = SCARuntime.class.getClassLoader(); + instance = newInstance(classLoader); + return instance; + } + + /** + * Start the Tuscany runtime using default SCDLs + */ + public static void start() { + try { + getInstance().startup(null, null, null, null); + } catch (Exception e) { + throw new IllegalStateException(e); + } + } + + /** + * Start the SCA Runtime with the given SCDLs + * + * @param system The URL for the system SCDL + * @param extensions An array of URLs for extensions + * @param application The URL for the application SCDL + */ + public static void start(URL system, URL[] extensions, URL application, String compositePath) { + try { + getInstance().startup(system, extensions, application, compositePath); + } catch (Exception e) { + throw new IllegalStateException(e); + } + } + + /** + * Start the SCA Runtime with the given SCDL + * + * @param application The URL for the application SCDL + */ + public static void start(URL application, String compositePath) { + try { + getInstance().startup(null, null, application, compositePath); + } catch (Exception e) { + throw new IllegalStateException(e); + } + } + + /** + * Start the SCA Runtime with the given SCDL + * + * @param compositePath The path of the application SCDL + */ + public static void start(String compositePath) { + try { + ClassLoader cl = Thread.currentThread().getContextClassLoader(); + URL applicationURL = cl.getResource(compositePath); + getInstance().startup(null, null, applicationURL, compositePath); + } catch (Exception e) { + throw new IllegalStateException(e); + } + } + + /** + * Start the SCA Runtime with the given SCDL + * + * @param compositePath The path of the system SCDL + * @param compositePath The path of the application SCDL + */ + public static void start(String system, String compositePath) { + try { + ClassLoader cl = Thread.currentThread().getContextClassLoader(); + URL systemURL = cl.getResource(system); + URL applicationURL = cl.getResource(compositePath); + getInstance().startup(systemURL, null, applicationURL, compositePath); + } catch (Exception e) { + throw new IllegalStateException(e); + } + } + + /** + * Get the ComponentContext by name + * + * @param componentName + * @return + */ + public static ComponentContext getComponentContext(String componentName) { + return getInstance().getContext(componentName); + } + + /** + * Get access to a system service + * + * @param serviceName + * @return + */ + protected abstract Object getSystemService(String serviceName); + + /** + * Stop the SCA Runtime + */ + public static void stop() { + try { + getInstance().shutdown(); + } catch (Exception e) { + throw new IllegalStateException(e); + } finally { + instance = null; + } + } + + /** + * Look up the ComponentContext by name + * + * @param componentName + * @return + */ + protected abstract ComponentContext getContext(String componentName); + + /** + * Start up the runtime + * + * @param system The URL of the SCDL for tuscany system composite + * @param extensions The URLs of the SCDLs for tuscany extension composites + * @param application The URL of the SCDL for the application composite + * @param compositePath The path of the application composite relative to + * the application URL + * @throws Exception + */ + protected abstract void startup(URL system, URL[] extensions, URL application, String compositePath) + throws Exception; + + /** + * Shutdown the runtime + * + * @throws Exception + */ + protected abstract void shutdown() throws Exception; +} diff --git a/sandbox/rfeng/runtime/embedded/src/main/java/org/apache/tuscany/runtime/embedded/DefaultSCARuntime.java b/sandbox/rfeng/runtime/embedded/src/main/java/org/apache/tuscany/runtime/embedded/DefaultSCARuntime.java new file mode 100644 index 0000000000..1a6ab28cf4 --- /dev/null +++ b/sandbox/rfeng/runtime/embedded/src/main/java/org/apache/tuscany/runtime/embedded/DefaultSCARuntime.java @@ -0,0 +1,75 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.runtime.embedded; + +import java.net.URI; +import java.net.URL; +import java.util.Arrays; +import java.util.List; + +import org.apache.tuscany.api.SCARuntime; +import org.apache.tuscany.api.TuscanyException; +import org.apache.tuscany.spi.component.TargetResolutionException; +import org.osoa.sca.ComponentContext; +import org.osoa.sca.ServiceUnavailableException; + +/** + * Default implementation of SCARuntime. + * + * @version $Rev$ $Date$ + */ +@SuppressWarnings("deprecation") +public class DefaultSCARuntime extends SCARuntime { + + protected SimpleRuntime runtime; + + protected void startup(URL system, URL[] exts, URL applicationSCDL, String compositePath) throws Exception { + ClassLoader cl = Thread.currentThread().getContextClassLoader(); + List extensions = exts == null ? null : Arrays.asList(exts); + URI contributionURI = URI.create("/default"); + SimpleRuntimeInfo runtimeInfo = new SimpleRuntimeInfoImpl(cl, system, extensions, contributionURI, + applicationSCDL, compositePath); + runtime = new SimpleRuntimeImpl(runtimeInfo); + + try { + runtime.start(); + } catch (TuscanyException e) { + throw e; + } + + } + + protected void shutdown() throws Exception { + runtime.destroy(); + } + + @Override + protected ComponentContext getContext(String componentName) { + return runtime.getComponentContext(URI.create(SimpleRuntimeInfo.DEFAULT_COMPOSITE + "/" + componentName)); + } + + @Override + public Object getSystemService(String serviceName) { + try { + return runtime.getSystemService(Object.class, serviceName); + } catch (TargetResolutionException e) { + throw new ServiceUnavailableException(e); + } + } +} diff --git a/sandbox/rfeng/runtime/embedded/src/main/java/org/apache/tuscany/runtime/embedded/SimpleRuntime.java b/sandbox/rfeng/runtime/embedded/src/main/java/org/apache/tuscany/runtime/embedded/SimpleRuntime.java new file mode 100644 index 0000000000..676d42a3af --- /dev/null +++ b/sandbox/rfeng/runtime/embedded/src/main/java/org/apache/tuscany/runtime/embedded/SimpleRuntime.java @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.runtime.embedded; + +import org.apache.tuscany.host.runtime.TuscanyRuntime; +import org.apache.tuscany.spi.component.Component; +import org.apache.tuscany.spi.component.TargetResolutionException; + +/** + * A simple runtime to host both Tuscany and application code on the same classpath + * + * @version $Rev$ $Date$ + */ +public interface SimpleRuntime extends TuscanyRuntime { + /** + * Start the embedded Tuscany + * @return + * @throws Exception + */ + Component start() throws Exception; + + /** + * Look up system services by name + * @param + * @param type + * @param name + * @return + * @throws TargetResolutionException + */ + T getSystemService(Class type, String name) throws TargetResolutionException; +} diff --git a/sandbox/rfeng/runtime/embedded/src/main/java/org/apache/tuscany/runtime/embedded/SimpleRuntimeImpl.java b/sandbox/rfeng/runtime/embedded/src/main/java/org/apache/tuscany/runtime/embedded/SimpleRuntimeImpl.java new file mode 100644 index 0000000000..990fa0107f --- /dev/null +++ b/sandbox/rfeng/runtime/embedded/src/main/java/org/apache/tuscany/runtime/embedded/SimpleRuntimeImpl.java @@ -0,0 +1,136 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.runtime.embedded; + +import static org.apache.tuscany.runtime.embedded.SimpleRuntimeInfo.DEFAULT_COMPOSITE; + +import java.net.URI; +import java.net.URL; +import java.util.Collection; + +import org.apache.tuscany.api.annotation.LogLevel; +import org.apache.tuscany.core.component.SimpleWorkContext; +import org.apache.tuscany.core.implementation.PojoWorkContextTunnel; +import org.apache.tuscany.core.implementation.system.model.SystemCompositeImplementation; +import org.apache.tuscany.core.runtime.AbstractRuntime; +import org.apache.tuscany.spi.builder.BuilderException; +import org.apache.tuscany.spi.component.AtomicComponent; +import org.apache.tuscany.spi.component.Component; +import org.apache.tuscany.spi.component.ComponentException; +import org.apache.tuscany.spi.component.SCAObject; +import org.apache.tuscany.spi.component.ScopeContainer; +import org.apache.tuscany.spi.component.ScopeRegistry; +import org.apache.tuscany.spi.component.TargetResolutionException; +import org.apache.tuscany.spi.component.WorkContext; +import org.apache.tuscany.spi.loader.LoaderException; +import org.apache.tuscany.spi.model.ComponentDefinition; +import org.apache.tuscany.spi.model.CompositeImplementation; +import org.apache.tuscany.spi.model.Scope; +import org.apache.tuscany.spi.resolver.ResolutionException; + +/** + * @version $Rev$ $Date$ + */ +public class SimpleRuntimeImpl extends AbstractRuntime implements SimpleRuntime { + private ScopeContainer container; + + public SimpleRuntimeImpl(SimpleRuntimeInfo runtimeInfo) { + super(SimpleRuntimeInfo.class); + ClassLoader hostClassLoader = ClassLoader.getSystemClassLoader(); + setHostClassLoader(hostClassLoader); + setApplicationScdl(runtimeInfo.getApplicationSCDL()); + setSystemScdl(runtimeInfo.getSystemSCDL()); + setRuntimeInfo(runtimeInfo); + } + + public interface SimpleMonitor { + @LogLevel("SEVERE") + void runError(Exception e); + } + + protected Collection deployExtension(Component parent, + URI name, + URL extensionSCDL, + ClassLoader systemClassLoader) throws LoaderException, + BuilderException, ComponentException, ResolutionException { + + SystemCompositeImplementation impl = new SystemCompositeImplementation(); + impl.setScdlLocation(extensionSCDL); + impl.setClassLoader(systemClassLoader); + ComponentDefinition definition + = new ComponentDefinition(name, impl); + + Collection components = getDeployer().deploy(parent, definition); + for (Component component : components) { + component.start(); + } + return components; + } + + @SuppressWarnings("unchecked") + public Component start() throws Exception { + initialize(); + + ScopeRegistry scopeRegistry = getScopeRegistry(); + container = scopeRegistry.getScopeContainer(Scope.COMPOSITE); + + /* + int i = 0; + for (URL ext : runtimeInfo.getExtensionSCDLs()) { + URI uri = URI.create("/extensions/extension" + (i++)); + deployExtension(null, uri, ext, runtimeInfo.getClassLoader()); + } + */ + + CompositeImplementation impl = new CompositeImplementation(); + impl.setScdlLocation(applicationScdl); + impl.setClassLoader(runtimeInfo.getClassLoader()); + + ComponentDefinition definition + = new ComponentDefinition(DEFAULT_COMPOSITE, impl); + Collection components = getDeployer().deploy(null, definition); + for (Component component : components) { + component.start(); + } + container.startContext(DEFAULT_COMPOSITE, DEFAULT_COMPOSITE); + getWorkContext().setIdentifier(Scope.COMPOSITE, DEFAULT_COMPOSITE); + WorkContext workContext = new SimpleWorkContext(); + workContext.setIdentifier(Scope.COMPOSITE, DEFAULT_COMPOSITE); + PojoWorkContextTunnel.setThreadWorkContext(workContext); + return componentManager.getComponent(definition.getUri()); + } + + @SuppressWarnings("deprecation") + public T getSystemService(Class type, String name) throws TargetResolutionException { + SCAObject child = componentManager.getComponent(URI.create(name)); + if (child == null) { + return null; + } + AtomicComponent service = (AtomicComponent)child; + return type.cast(service.getTargetInstance()); + } + + @Override + public void destroy() { + container.stopContext(DEFAULT_COMPOSITE); + getWorkContext().setIdentifier(Scope.COMPOSITE, null); + super.destroy(); + } + +} diff --git a/sandbox/rfeng/runtime/embedded/src/main/java/org/apache/tuscany/runtime/embedded/SimpleRuntimeInfo.java b/sandbox/rfeng/runtime/embedded/src/main/java/org/apache/tuscany/runtime/embedded/SimpleRuntimeInfo.java new file mode 100644 index 0000000000..740c51a3a3 --- /dev/null +++ b/sandbox/rfeng/runtime/embedded/src/main/java/org/apache/tuscany/runtime/embedded/SimpleRuntimeInfo.java @@ -0,0 +1,56 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.runtime.embedded; + +import java.net.URI; +import java.net.URL; +import java.util.List; + +import org.apache.tuscany.host.RuntimeInfo; +import org.apache.tuscany.spi.bootstrap.ComponentNames; + +/** + * @version $Rev$ $Date$ + */ +public interface SimpleRuntimeInfo extends RuntimeInfo { + URI DEFAULT_COMPOSITE = ComponentNames.TUSCANY_APPLICATION_ROOT.resolve("default"); + + String DEFAULT_SYSTEM_SCDL = "META-INF/tuscany/default-system.composite"; + String SYSTEM_SCDL = "system.composite"; + String EXTENSION_SCDL = "META-INF/sca/extension.composite"; + String SERVICE_SCDL = "META-INF/sca/service.composite"; + String META_APPLICATION_SCDL = "META-INF/sca/application.composite"; + String APPLICATION_SCDL = "application.composite"; + + ClassLoader getClassLoader(); + + String getCompositePath(); + + URL getSystemSCDL(); + + URL getApplicationSCDL(); + + List getExtensionSCDLs(); + + URL getContributionRoot(); + + URI getContributionURI(); + +} diff --git a/sandbox/rfeng/runtime/embedded/src/main/java/org/apache/tuscany/runtime/embedded/SimpleRuntimeInfoImpl.java b/sandbox/rfeng/runtime/embedded/src/main/java/org/apache/tuscany/runtime/embedded/SimpleRuntimeInfoImpl.java new file mode 100644 index 0000000000..6839eefc93 --- /dev/null +++ b/sandbox/rfeng/runtime/embedded/src/main/java/org/apache/tuscany/runtime/embedded/SimpleRuntimeInfoImpl.java @@ -0,0 +1,182 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.runtime.embedded; + +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URI; +import java.net.URL; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Enumeration; +import java.util.List; + +import org.apache.tuscany.core.util.FileHelper; +import org.apache.tuscany.host.AbstractRuntimeInfo; + +/** + * @version $Rev$ $Date$ + */ +public class SimpleRuntimeInfoImpl extends AbstractRuntimeInfo implements SimpleRuntimeInfo { + private ClassLoader classLoader; + private String compositePath; + + private List extensions; + private URL applicationSCDL; + private URL systemSCDL; + + private URL contributionURL; + private URI contributionURI; + + /** + * @param classLoader + * @param compositePath + * @param extensions + * @param applicationSCDL + * @param systemSCDL + */ + public SimpleRuntimeInfoImpl(ClassLoader classLoader, + URL systemSCDL, + List extensions, + URI contributionURI, + URL applicationSCDL, + String compositePath) { + this(classLoader, compositePath); + this.extensions = extensions; + this.applicationSCDL = applicationSCDL; + this.systemSCDL = systemSCDL; + this.contributionURI = contributionURI; + } + + public SimpleRuntimeInfoImpl(ClassLoader classLoader, String compositePath) { + // super(domain, applicationRootDirectory, baseUrl, online, runtimeId); + super(URI.create("sca://domain/local"), null, null, false, "simple"); + if (classLoader != null) { + this.classLoader = classLoader; + } else { + classLoader = Thread.currentThread().getContextClassLoader(); + } + this.compositePath = compositePath != null ? compositePath : APPLICATION_SCDL; + getApplicationSCDL(); + this.contributionURI = URI.create("/default"); + } + + public ClassLoader getClassLoader() { + return classLoader; + } + + public String getCompositePath() { + return compositePath; + } + + public final URL getApplicationSCDL() { + if (applicationSCDL == null) { + applicationSCDL = classLoader.getResource(compositePath); + if (applicationSCDL == null) { + applicationSCDL = classLoader.getResource(APPLICATION_SCDL); + if (applicationSCDL == null) { + applicationSCDL = classLoader.getResource(META_APPLICATION_SCDL); + if (applicationSCDL != null) { + compositePath = META_APPLICATION_SCDL; + } + } else { + if (compositePath == null) { + compositePath = APPLICATION_SCDL; + } + } + if (applicationSCDL == null) { + throw new IllegalArgumentException("application SCDL not found: " + APPLICATION_SCDL); + } + } + } + return applicationSCDL; + } + + public URL getContributionRoot() { + if (contributionURL == null) { + contributionURL = getContributionLocation(getApplicationSCDL(), compositePath); + } + return contributionURL; + } + + public List getExtensionSCDLs() { + if (extensions == null) { + try { + List extensionURLs = new ArrayList(); + Enumeration urls = classLoader.getResources(SERVICE_SCDL); + extensionURLs.addAll(Collections.list(urls)); + urls = classLoader.getResources(EXTENSION_SCDL); + extensionURLs.addAll(Collections.list(urls)); + if (extensions != null) { + for (URL ext : extensions) { + if (!extensionURLs.contains(ext)) { + extensionURLs.add(ext); + } + } + } + extensions = extensionURLs; + } catch (IOException e) { + throw new IllegalArgumentException(e); + } + } + return extensions; + } + + public URL getSystemSCDL() { + if (systemSCDL == null) { + systemSCDL = classLoader.getResource(SYSTEM_SCDL); + if (systemSCDL == null) { + systemSCDL = classLoader.getResource(DEFAULT_SYSTEM_SCDL); + } + } + return systemSCDL; + } + + private static URL getContributionLocation(URL applicationSCDL, String compositePath) { + URL root = null; + // "jar:file://....../something.jar!/a/b/c/app.composite" + try { + String scdlUrl = applicationSCDL.toExternalForm(); + String protocol = applicationSCDL.getProtocol(); + if ("file".equals(protocol)) { + // directory contribution + if (scdlUrl.endsWith(compositePath)) { + String location = scdlUrl.substring(0, scdlUrl.lastIndexOf(compositePath)); + // workaround from evil url/uri form maven + root = FileHelper.toFile(new URL(location)).toURI().toURL(); + } + + } else if ("jar".equals(protocol)) { + // jar contribution + String location = scdlUrl.substring(4, scdlUrl.lastIndexOf("!/")); + // workaround from evil url/uri form maven + root = FileHelper.toFile(new URL(location)).toURI().toURL(); + } + } catch (MalformedURLException mfe) { + throw new IllegalArgumentException(mfe); + } + + return root; + } + + public URI getContributionURI() { + return contributionURI; + } +} diff --git a/sandbox/rfeng/runtime/embedded/src/test/java/calculator/AddService.java b/sandbox/rfeng/runtime/embedded/src/test/java/calculator/AddService.java new file mode 100644 index 0000000000..4eeb30a9c2 --- /dev/null +++ b/sandbox/rfeng/runtime/embedded/src/test/java/calculator/AddService.java @@ -0,0 +1,25 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +public interface AddService { + + double add(double n1, double n2); + +} diff --git a/sandbox/rfeng/runtime/embedded/src/test/java/calculator/AddServiceImpl.java b/sandbox/rfeng/runtime/embedded/src/test/java/calculator/AddServiceImpl.java new file mode 100644 index 0000000000..8b6fe066a6 --- /dev/null +++ b/sandbox/rfeng/runtime/embedded/src/test/java/calculator/AddServiceImpl.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +/** + * An implementation of the Add service + */ +public class AddServiceImpl implements AddService { + + public double add(double n1, double n2) { + return n1 + n2; + } + +} diff --git a/sandbox/rfeng/runtime/embedded/src/test/java/calculator/CalculatorClient.java b/sandbox/rfeng/runtime/embedded/src/test/java/calculator/CalculatorClient.java new file mode 100644 index 0000000000..37231e53fe --- /dev/null +++ b/sandbox/rfeng/runtime/embedded/src/test/java/calculator/CalculatorClient.java @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package calculator; + +import org.apache.tuscany.api.SCARuntime; +import org.osoa.sca.ComponentContext; +import org.osoa.sca.ServiceReference; + +/** + * @version $Rev$ $Date$ + */ +public class CalculatorClient { + + public CalculatorClient() { + super(); + } + + public static void main(String[] args) { + // Start the embedded SCA runtime + SCARuntime.start(); + + // Look up the ComponentContext by name + ComponentContext context = SCARuntime.getComponentContext("CalculatorServiceComponent"); + ServiceReference self = context.createSelfReference(CalculatorService.class); + CalculatorService calculatorService = self.getService(); + System.out.println("1.0 x 2.0 = " + calculatorService.multiply(1.0, 2.0)); + AddService addService = context.getService(AddService.class, "addService"); + System.out.println("1.0 + 2.0 = " + addService.add(1.0, 2.0)); + + // Stop the SCA embedded runtime + SCARuntime.stop(); + } + +} diff --git a/sandbox/rfeng/runtime/embedded/src/test/java/calculator/CalculatorService.java b/sandbox/rfeng/runtime/embedded/src/test/java/calculator/CalculatorService.java new file mode 100644 index 0000000000..031fa8b912 --- /dev/null +++ b/sandbox/rfeng/runtime/embedded/src/test/java/calculator/CalculatorService.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + + +/** + * The Calculator service interface. + */ +public interface CalculatorService { + + double add(double n1, double n2); + + double subtract(double n1, double n2); + + double multiply(double n1, double n2); + + double divide(double n1, double n2); + +} diff --git a/sandbox/rfeng/runtime/embedded/src/test/java/calculator/CalculatorServiceImpl.java b/sandbox/rfeng/runtime/embedded/src/test/java/calculator/CalculatorServiceImpl.java new file mode 100644 index 0000000000..3d861f2018 --- /dev/null +++ b/sandbox/rfeng/runtime/embedded/src/test/java/calculator/CalculatorServiceImpl.java @@ -0,0 +1,70 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import org.osoa.sca.annotations.Reference; + + +/** + * An implementation of the Calculator service. + */ +public class CalculatorServiceImpl implements CalculatorService { + + private AddService addService; + private SubtractService subtractService; + private MultiplyService multiplyService; + private DivideService divideService; + + @Reference + public void setAddService(AddService addService) { + this.addService = addService; + } + + @Reference + public void setSubtractService(SubtractService subtractService) { + this.subtractService = subtractService; + } + + @Reference + public void setDivideService(DivideService divideService) { + this.divideService = divideService; + } + + @Reference + public void setMultiplyService(MultiplyService multiplyService) { + this.multiplyService = multiplyService; + } + + public double add(double n1, double n2) { + return addService.add(n1, n2); + } + + public double subtract(double n1, double n2) { + return subtractService.subtract(n1, n2); + } + + public double multiply(double n1, double n2) { + return multiplyService.multiply(n1, n2); + } + + public double divide(double n1, double n2) { + return divideService.divide(n1, n2); + } + +} diff --git a/sandbox/rfeng/runtime/embedded/src/test/java/calculator/DivideService.java b/sandbox/rfeng/runtime/embedded/src/test/java/calculator/DivideService.java new file mode 100644 index 0000000000..131c5a8014 --- /dev/null +++ b/sandbox/rfeng/runtime/embedded/src/test/java/calculator/DivideService.java @@ -0,0 +1,25 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +public interface DivideService { + + double divide(double n1, double n2); + +} diff --git a/sandbox/rfeng/runtime/embedded/src/test/java/calculator/DivideServiceImpl.java b/sandbox/rfeng/runtime/embedded/src/test/java/calculator/DivideServiceImpl.java new file mode 100644 index 0000000000..f7ac0b7287 --- /dev/null +++ b/sandbox/rfeng/runtime/embedded/src/test/java/calculator/DivideServiceImpl.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +/** + * An implementation of the Divide service. + */ +public class DivideServiceImpl implements DivideService { + + public double divide(double n1, double n2) { + return n1 / n2; + } + +} diff --git a/sandbox/rfeng/runtime/embedded/src/test/java/calculator/MultiplyService.java b/sandbox/rfeng/runtime/embedded/src/test/java/calculator/MultiplyService.java new file mode 100644 index 0000000000..a917896aeb --- /dev/null +++ b/sandbox/rfeng/runtime/embedded/src/test/java/calculator/MultiplyService.java @@ -0,0 +1,25 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +public interface MultiplyService { + + double multiply(double n1, double n2); + +} diff --git a/sandbox/rfeng/runtime/embedded/src/test/java/calculator/MultiplyServiceImpl.java b/sandbox/rfeng/runtime/embedded/src/test/java/calculator/MultiplyServiceImpl.java new file mode 100644 index 0000000000..b7dca792b2 --- /dev/null +++ b/sandbox/rfeng/runtime/embedded/src/test/java/calculator/MultiplyServiceImpl.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +/** + * An implementation of the Multiply service. + */ +public class MultiplyServiceImpl implements MultiplyService { + + public double multiply(double n1, double n2) { + return n1 * n2; + } + +} diff --git a/sandbox/rfeng/runtime/embedded/src/test/java/calculator/SubtractService.java b/sandbox/rfeng/runtime/embedded/src/test/java/calculator/SubtractService.java new file mode 100644 index 0000000000..e328f024ea --- /dev/null +++ b/sandbox/rfeng/runtime/embedded/src/test/java/calculator/SubtractService.java @@ -0,0 +1,25 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +public interface SubtractService { + + double subtract(double n1, double n2); + +} diff --git a/sandbox/rfeng/runtime/embedded/src/test/java/calculator/SubtractServiceImpl.java b/sandbox/rfeng/runtime/embedded/src/test/java/calculator/SubtractServiceImpl.java new file mode 100644 index 0000000000..77b128ab8d --- /dev/null +++ b/sandbox/rfeng/runtime/embedded/src/test/java/calculator/SubtractServiceImpl.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +/** + * An implementation of the subtract service. + */ +public class SubtractServiceImpl implements SubtractService { + + public double subtract(double n1, double n2) { + return n1 - n2; + } + +} diff --git a/sandbox/rfeng/runtime/embedded/src/test/java/org/apache/tuscany/api/SCARuntimeTestCase.java b/sandbox/rfeng/runtime/embedded/src/test/java/org/apache/tuscany/api/SCARuntimeTestCase.java new file mode 100644 index 0000000000..cacbb7162c --- /dev/null +++ b/sandbox/rfeng/runtime/embedded/src/test/java/org/apache/tuscany/api/SCARuntimeTestCase.java @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.api; + +import junit.framework.TestCase; + +import org.osoa.sca.ComponentContext; +import org.osoa.sca.ServiceReference; + +import calculator.AddService; +import calculator.CalculatorService; + +/** + * @version $Rev$ $Date$ + */ +public class SCARuntimeTestCase extends TestCase { + /** + * @throws java.lang.Exception + */ + protected void setUp() throws Exception { + SCARuntime.start(); + } + + public void testStart() throws Exception { + ComponentContext context = SCARuntime.getComponentContext("CalculatorServiceComponent"); + assertNotNull(context); + ServiceReference self = context.createSelfReference(CalculatorService.class); + assertEquals(2.0, self.getService().multiply(1.0, 2.0)); + AddService service = context.getService(AddService.class, "addService"); + assertEquals(3.0, service.add(1.0, 2.0)); + } + + /** + * @throws java.lang.Exception + */ + protected void tearDown() throws Exception { + SCARuntime.stop(); + } + +} diff --git a/sandbox/rfeng/runtime/embedded/src/test/java/org/apache/tuscany/runtime/embedded/SimpleRuntimeImplTestCase.java b/sandbox/rfeng/runtime/embedded/src/test/java/org/apache/tuscany/runtime/embedded/SimpleRuntimeImplTestCase.java new file mode 100644 index 0000000000..1c4b04600d --- /dev/null +++ b/sandbox/rfeng/runtime/embedded/src/test/java/org/apache/tuscany/runtime/embedded/SimpleRuntimeImplTestCase.java @@ -0,0 +1,60 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.runtime.embedded; + +import java.net.URI; + +import junit.framework.TestCase; + +import org.osoa.sca.ComponentContext; + +import calculator.AddService; + +/** + * @version $Rev$ $Date$ + */ +public class SimpleRuntimeImplTestCase extends TestCase { + private SimpleRuntime runtime; + + /** + * @throws java.lang.Exception + */ + protected void setUp() throws Exception { + SimpleRuntimeInfo runtimeInfo = new SimpleRuntimeInfoImpl(getClass().getClassLoader(), "application.composite"); + runtime = new SimpleRuntimeImpl(runtimeInfo); + runtime.start(); + } + + public void testStart() throws Exception { + ComponentContext context = runtime.getComponentContext(URI + .create("sca://root.application/default/CalculatorServiceComponent")); + assertNotNull(context); + AddService service = context.getService(AddService.class, "addService"); + assertEquals(3.0, service.add(1.0, 2.0)); + } + + /** + * @throws java.lang.Exception + */ + protected void tearDown() throws Exception { + runtime.destroy(); + } + +} diff --git a/sandbox/rfeng/runtime/embedded/src/test/resources/application.composite b/sandbox/rfeng/runtime/embedded/src/test/resources/application.composite new file mode 100644 index 0000000000..55d4ca889b --- /dev/null +++ b/sandbox/rfeng/runtime/embedded/src/test/resources/application.composite @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/rfeng/runtime/embedded/src/test/resources/system.composite b/sandbox/rfeng/runtime/embedded/src/test/resources/system.composite new file mode 100644 index 0000000000..3974e06dd1 --- /dev/null +++ b/sandbox/rfeng/runtime/embedded/src/test/resources/system.composite @@ -0,0 +1,349 @@ + + + + + + + + + 10 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + .m2/repository + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sandbox/rfeng/samples.M2/creditws-axis2/.classpath b/sandbox/rfeng/samples.M2/creditws-axis2/.classpath new file mode 100644 index 0000000000..f505a311e9 --- /dev/null +++ b/sandbox/rfeng/samples.M2/creditws-axis2/.classpath @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/rfeng/samples.M2/creditws-axis2/.project b/sandbox/rfeng/samples.M2/creditws-axis2/.project new file mode 100644 index 0000000000..9ddadde0d1 --- /dev/null +++ b/sandbox/rfeng/samples.M2/creditws-axis2/.project @@ -0,0 +1,17 @@ + + + sample-creditws-axis2 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/sandbox/rfeng/samples.M2/creditws-axis2/build.xml b/sandbox/rfeng/samples.M2/creditws-axis2/build.xml new file mode 100644 index 0000000000..82852e02de --- /dev/null +++ b/sandbox/rfeng/samples.M2/creditws-axis2/build.xml @@ -0,0 +1,109 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/rfeng/samples.M2/creditws-axis2/build/lib/CreditCheckService.aar b/sandbox/rfeng/samples.M2/creditws-axis2/build/lib/CreditCheckService.aar new file mode 100644 index 0000000000..8515a8d835 Binary files /dev/null and b/sandbox/rfeng/samples.M2/creditws-axis2/build/lib/CreditCheckService.aar differ diff --git a/sandbox/rfeng/samples.M2/creditws-axis2/resources/CreditCheckService.wsdl b/sandbox/rfeng/samples.M2/creditws-axis2/resources/CreditCheckService.wsdl new file mode 100644 index 0000000000..2b488cca41 --- /dev/null +++ b/sandbox/rfeng/samples.M2/creditws-axis2/resources/CreditCheckService.wsdl @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sandbox/rfeng/samples.M2/creditws-axis2/resources/services.xml b/sandbox/rfeng/samples.M2/creditws-axis2/resources/services.xml new file mode 100644 index 0000000000..f883fbdd1d --- /dev/null +++ b/sandbox/rfeng/samples.M2/creditws-axis2/resources/services.xml @@ -0,0 +1,14 @@ + + + + + + + +credit.CreditCheckServiceSkeleton + +http://credit/CreditCheck/getCreditScoreRequest +http://credit/CreditCheck/getCreditScoreResponse + + + diff --git a/sandbox/rfeng/samples.M2/creditws-axis2/src/credit/CreditCheckServiceMessageReceiverInOut.java b/sandbox/rfeng/samples.M2/creditws-axis2/src/credit/CreditCheckServiceMessageReceiverInOut.java new file mode 100644 index 0000000000..498351f85d --- /dev/null +++ b/sandbox/rfeng/samples.M2/creditws-axis2/src/credit/CreditCheckServiceMessageReceiverInOut.java @@ -0,0 +1,144 @@ + +/** + * CreditCheckServiceMessageReceiverInOut.java + * + * This file was auto-generated from WSDL + * by the Apache Axis2 version: 1.1-RC2 Nov 02, 2006 (02:37:50 LKT) + */ +package credit; + +/** + * CreditCheckServiceMessageReceiverInOut message receiver + */ + +public class CreditCheckServiceMessageReceiverInOut extends + org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver { + + public void invokeBusinessLogic(org.apache.axis2.context.MessageContext msgContext, + org.apache.axis2.context.MessageContext newMsgContext) + throws org.apache.axis2.AxisFault { + + try { + + // get the implementation class for the Web Service + Object obj = getTheImplementationObject(msgContext); + + CreditCheckServiceSkeleton skel = (CreditCheckServiceSkeleton)obj; + // Out Envelop + org.apache.axiom.soap.SOAPEnvelope envelope = null; + // Find the axisOperation that has been set by the Dispatch phase. + org.apache.axis2.description.AxisOperation op = + msgContext.getOperationContext().getAxisOperation(); + if (op == null) { + throw new org.apache.axis2.AxisFault( + "Operation is not located, if this is doclit style the SOAP-ACTION should specified via the SOAP Action to use the RawXMLProvider"); + } + + java.lang.String methodName; + if (op.getName() != null & (methodName = op.getName().getLocalPart()) != null) { + + if ("getCreditScore".equals(methodName)) { + + credit.GetCreditScoreResponse param11 = null; + + // doc style + credit.GetCreditScore wrappedParam = + (credit.GetCreditScore)fromOM(msgContext.getEnvelope().getBody().getFirstElement(), + credit.GetCreditScore.class, + getEnvelopeNamespaces(msgContext.getEnvelope())); + + param11 = skel.getCreditScore(wrappedParam); + + envelope = toEnvelope(getSOAPFactory(msgContext), param11, false); + + } + + newMsgContext.setEnvelope(envelope); + } + } catch (Exception e) { + throw org.apache.axis2.AxisFault.makeFault(e); + } + } + + // + private org.apache.axiom.om.OMElement toOM(credit.GetCreditScore param, boolean optimizeContent) { + + return param.getOMElement(credit.GetCreditScore.MY_QNAME, org.apache.axiom.om.OMAbstractFactory + .getOMFactory()); + + } + + private org.apache.axiom.om.OMElement toOM(credit.GetCreditScoreResponse param, boolean optimizeContent) { + + return param.getOMElement(credit.GetCreditScoreResponse.MY_QNAME, + org.apache.axiom.om.OMAbstractFactory.getOMFactory()); + + } + + private org.apache.axiom.soap.SOAPEnvelope toEnvelope(org.apache.axiom.soap.SOAPFactory factory, + credit.GetCreditScoreResponse param, + boolean optimizeContent) { + org.apache.axiom.soap.SOAPEnvelope emptyEnvelope = factory.getDefaultEnvelope(); + + emptyEnvelope.getBody().addChild(param.getOMElement(credit.GetCreditScoreResponse.MY_QNAME, factory)); + + return emptyEnvelope; + } + + /** + * get the default envelope + */ + private org.apache.axiom.soap.SOAPEnvelope toEnvelope(org.apache.axiom.soap.SOAPFactory factory) { + return factory.getDefaultEnvelope(); + } + + private java.lang.Object fromOM(org.apache.axiom.om.OMElement param, + java.lang.Class type, + java.util.Map extraNamespaces) { + + try { + + if (credit.GetCreditScore.class.equals(type)) { + + return credit.GetCreditScore.Factory.parse(param.getXMLStreamReaderWithoutCaching()); + + } + + if (credit.GetCreditScoreResponse.class.equals(type)) { + + return credit.GetCreditScoreResponse.Factory.parse(param.getXMLStreamReaderWithoutCaching()); + + } + + } catch (Exception e) { + throw new RuntimeException(e); + } + return null; + } + + /** + * A utility method that copies the namepaces from the SOAPEnvelope + */ + private java.util.Map getEnvelopeNamespaces(org.apache.axiom.soap.SOAPEnvelope env) { + java.util.Map returnMap = new java.util.HashMap(); + java.util.Iterator namespaceIterator = env.getAllDeclaredNamespaces(); + while (namespaceIterator.hasNext()) { + org.apache.axiom.om.OMNamespace ns = (org.apache.axiom.om.OMNamespace)namespaceIterator.next(); + returnMap.put(ns.getPrefix(), ns.getNamespaceURI()); + } + return returnMap; + } + + private org.apache.axis2.AxisFault createAxisFault(java.lang.Exception e) { + org.apache.axis2.AxisFault f; + Throwable cause = e.getCause(); + if (cause != null) { + f = new org.apache.axis2.AxisFault(e.getMessage(), cause); + } else { + f = new org.apache.axis2.AxisFault(e.getMessage()); + } + + return f; + } + +}// end of class diff --git a/sandbox/rfeng/samples.M2/creditws-axis2/src/credit/CreditCheckServiceSkeleton.java b/sandbox/rfeng/samples.M2/creditws-axis2/src/credit/CreditCheckServiceSkeleton.java new file mode 100644 index 0000000000..d114baab4e --- /dev/null +++ b/sandbox/rfeng/samples.M2/creditws-axis2/src/credit/CreditCheckServiceSkeleton.java @@ -0,0 +1,29 @@ +/** + * CreditCheckServiceSkeleton.java + * + * This file was auto-generated from WSDL + * by the Apache Axis2 version: 1.0 May 05, 2006 (12:31:13 IST) + */ +package credit; + +/** + * CreditCheckServiceSkeleton java skeleton for the axisService + */ +public class CreditCheckServiceSkeleton { + + /** + * Auto generated method signature + * + * @param request + */ + public credit.GetCreditScoreResponse getCreditScore(credit.GetCreditScore request) { + System.out.println("Checking credit for " + request.getSsn()); + GetCreditScoreResponse response = new GetCreditScoreResponse(); + int score = (int)(650 + (Math.random() - 0.5) * 100); + response.setScore(score); + System.out.println("Credit score is " + score); + return response; + + } + +} diff --git a/sandbox/rfeng/samples.M2/creditws-axis2/src/credit/ExtensionMapper.java b/sandbox/rfeng/samples.M2/creditws-axis2/src/credit/ExtensionMapper.java new file mode 100644 index 0000000000..744fb4c98c --- /dev/null +++ b/sandbox/rfeng/samples.M2/creditws-axis2/src/credit/ExtensionMapper.java @@ -0,0 +1,24 @@ +/** + * ExtensionMapper.java + * + * This file was auto-generated from WSDL + * by the Apache Axis2 version: #axisVersion# #today# + */ + +package credit; + +/** + * ExtensionMapper class + */ + +public class ExtensionMapper { + + public static java.lang.Object getTypeObject(java.lang.String namespaceURI, + java.lang.String typeName, + javax.xml.stream.XMLStreamReader reader) + throws java.lang.Exception { + + throw new java.lang.RuntimeException("Unsupported type " + namespaceURI + " " + typeName); + } + +} diff --git a/sandbox/rfeng/samples.M2/creditws-axis2/src/credit/GetCreditScore.java b/sandbox/rfeng/samples.M2/creditws-axis2/src/credit/GetCreditScore.java new file mode 100644 index 0000000000..59130c00d7 --- /dev/null +++ b/sandbox/rfeng/samples.M2/creditws-axis2/src/credit/GetCreditScore.java @@ -0,0 +1,301 @@ +/** + * GetCreditScore.java + * + * This file was auto-generated from WSDL + * by the Apache Axis2 version: #axisVersion# #today# + */ + +package credit; + +/** + * GetCreditScore bean class + */ + +public class GetCreditScore implements org.apache.axis2.databinding.ADBBean { + + public static final javax.xml.namespace.QName MY_QNAME = + new javax.xml.namespace.QName("http://credit", "getCreditScore", "ns1"); + + /** + * field for Ssn + */ + + protected java.lang.String localSsn; + + /** + * Auto generated getter method + * + * @return java.lang.String + */ + public java.lang.String getSsn() { + return localSsn; + } + + /** + * Auto generated setter method + * + * @param param Ssn + */ + public void setSsn(java.lang.String param) { + + this.localSsn = param; + + } + + /** + * @param parentQName + * @param factory + * @return org.apache.axiom.om.OMElement + */ + public org.apache.axiom.om.OMElement getOMElement(final javax.xml.namespace.QName parentQName, + final org.apache.axiom.om.OMFactory factory) { + + org.apache.axiom.om.OMDataSource dataSource = + new org.apache.axis2.databinding.ADBDataSource(this, parentQName) { + + public void serialize(javax.xml.stream.XMLStreamWriter xmlWriter) + throws javax.xml.stream.XMLStreamException { + + java.lang.String prefix = parentQName.getPrefix(); + java.lang.String namespace = parentQName.getNamespaceURI(); + + if (namespace != null) { + java.lang.String writerPrefix = xmlWriter.getPrefix(namespace); + if (writerPrefix != null) { + xmlWriter.writeStartElement(namespace, parentQName.getLocalPart()); + } else { + if (prefix == null) { + prefix = org.apache.axis2.databinding.utils.BeanUtil.getUniquePrefix(); + } + + xmlWriter.writeStartElement(prefix, parentQName.getLocalPart(), namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } + } else { + xmlWriter.writeStartElement(parentQName.getLocalPart()); + } + + namespace = "http://credit"; + if (!namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = org.apache.axis2.databinding.utils.BeanUtil.getUniquePrefix(); + + xmlWriter.writeStartElement(prefix, "ssn", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace, "ssn"); + } + + } else { + xmlWriter.writeStartElement("ssn"); + } + + if (localSsn == null) { + // write the nil attribute + + throw new RuntimeException("ssn cannot be null!!"); + + } else { + + xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil + .convertToString(localSsn)); + + } + + xmlWriter.writeEndElement(); + + xmlWriter.writeEndElement(); + + } + + /** + * Util method to write an attribute with the ns prefix + */ + private void writeAttribute(java.lang.String prefix, + java.lang.String namespace, + java.lang.String attName, + java.lang.String attValue, + javax.xml.stream.XMLStreamWriter xmlWriter) + throws javax.xml.stream.XMLStreamException { + if (xmlWriter.getPrefix(namespace) == null) { + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } + + xmlWriter.writeAttribute(namespace, attName, attValue); + + } + + /** + * Util method to write an attribute without the ns prefix + */ + private void writeAttribute(java.lang.String namespace, + java.lang.String attName, + java.lang.String attValue, + javax.xml.stream.XMLStreamWriter xmlWriter) + throws javax.xml.stream.XMLStreamException { + if (namespace.equals("")) { + xmlWriter.writeAttribute(attName, attValue); + } else { + registerPrefix(xmlWriter, namespace); + xmlWriter.writeAttribute(namespace, attName, attValue); + } + } + + /** + * Register a namespace prefix + */ + private java.lang.String registerPrefix(javax.xml.stream.XMLStreamWriter xmlWriter, + java.lang.String namespace) + throws javax.xml.stream.XMLStreamException { + java.lang.String prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = createPrefix(); + + while (xmlWriter.getNamespaceContext().getNamespaceURI(prefix) != null) { + prefix = createPrefix(); + } + + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } + + return prefix; + } + + /** + * Create a prefix + */ + private java.lang.String createPrefix() { + return "ns" + (int)Math.random(); + } + }; + + return new org.apache.axiom.om.impl.llom.OMSourcedElementImpl(MY_QNAME, factory, dataSource); + + } + + /** + * databinding method to get an XML representation of this object + */ + public javax.xml.stream.XMLStreamReader getPullParser(javax.xml.namespace.QName qName) { + + java.util.ArrayList elementList = new java.util.ArrayList(); + java.util.ArrayList attribList = new java.util.ArrayList(); + + elementList.add(new javax.xml.namespace.QName("http://credit", "ssn")); + + if (localSsn != null) { + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localSsn)); + } else { + throw new RuntimeException("ssn cannot be null!!"); + } + + return new org.apache.axis2.databinding.utils.reader.ADBXMLStreamReaderImpl(qName, elementList + .toArray(), attribList.toArray()); + + } + + /** + * Factory class that keeps the parse method + */ + public static class Factory { + + /** + * static method to create the object Precondition: If this object is an + * element, the current or next start element starts this object and any + * intervening reader events are ignorable If this object is not an + * element, it is a complex type and the reader is at the event just + * after the outer start element Postcondition: If this object is an + * element, the reader is positioned at its end element If this object + * is a complex type, the reader is positioned at the end element of its + * outer element + */ + public static GetCreditScore parse(javax.xml.stream.XMLStreamReader reader) + throws java.lang.Exception { + GetCreditScore object = new GetCreditScore(); + int event; + try { + + while (!reader.isStartElement() && !reader.isEndElement()) + reader.next(); + + if (reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance", "type") != null) { + java.lang.String fullTypeName = + reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance", "type"); + if (fullTypeName != null) { + java.lang.String nsPrefix = fullTypeName.substring(0, fullTypeName.indexOf(":")); + nsPrefix = nsPrefix == null ? "" : nsPrefix; + + java.lang.String type = fullTypeName.substring(fullTypeName.indexOf(":") + 1); + if (!"getCreditScore".equals(type)) { + // find namespace for the prefix + java.lang.String nsUri = reader.getNamespaceContext().getNamespaceURI(nsPrefix); + return (GetCreditScore)credit.ExtensionMapper.getTypeObject(nsUri, type, reader); + } + + } + + } + + // Note all attributes that were handled. Used to differ normal + // attributes + // from anyAttributes. + java.util.Vector handledAttributes = new java.util.Vector(); + + boolean isReaderMTOMAware = false; + + try { + isReaderMTOMAware = + java.lang.Boolean.TRUE.equals(reader + .getProperty(org.apache.axiom.om.OMConstants.IS_DATA_HANDLERS_AWARE)); + } catch (java.lang.IllegalArgumentException e) { + isReaderMTOMAware = false; + } + + reader.next(); + + while (!reader.isStartElement() && !reader.isEndElement()) + reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("http://credit", "ssn") + .equals(reader.getName())) { + + java.lang.String content = reader.getElementText(); + + object.setSsn(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + // A start element we are not expecting indicates an invalid + // parameter was passed + throw new java.lang.RuntimeException("Unexpected subelement " + reader.getLocalName()); + } + + while (!reader.isStartElement() && !reader.isEndElement()) + reader.next(); + if (reader.isStartElement()) + // A start element we are not expecting indicates a trailing + // invalid property + throw new java.lang.RuntimeException("Unexpected subelement " + reader.getLocalName()); + + } catch (javax.xml.stream.XMLStreamException e) { + throw new java.lang.Exception(e); + } + + return object; + } + + }// end of factory class + +} diff --git a/sandbox/rfeng/samples.M2/creditws-axis2/src/credit/GetCreditScoreResponse.java b/sandbox/rfeng/samples.M2/creditws-axis2/src/credit/GetCreditScoreResponse.java new file mode 100644 index 0000000000..5d5981b177 --- /dev/null +++ b/sandbox/rfeng/samples.M2/creditws-axis2/src/credit/GetCreditScoreResponse.java @@ -0,0 +1,290 @@ +/** + * GetCreditScoreResponse.java + * + * This file was auto-generated from WSDL + * by the Apache Axis2 version: #axisVersion# #today# + */ + +package credit; + +/** + * GetCreditScoreResponse bean class + */ + +public class GetCreditScoreResponse implements org.apache.axis2.databinding.ADBBean { + + public static final javax.xml.namespace.QName MY_QNAME = + new javax.xml.namespace.QName("http://credit", "getCreditScoreResponse", "ns1"); + + /** + * field for Score + */ + + protected int localScore; + + /** + * Auto generated getter method + * + * @return int + */ + public int getScore() { + return localScore; + } + + /** + * Auto generated setter method + * + * @param param Score + */ + public void setScore(int param) { + + this.localScore = param; + + } + + /** + * @param parentQName + * @param factory + * @return org.apache.axiom.om.OMElement + */ + public org.apache.axiom.om.OMElement getOMElement(final javax.xml.namespace.QName parentQName, + final org.apache.axiom.om.OMFactory factory) { + + org.apache.axiom.om.OMDataSource dataSource = + new org.apache.axis2.databinding.ADBDataSource(this, parentQName) { + + public void serialize(javax.xml.stream.XMLStreamWriter xmlWriter) + throws javax.xml.stream.XMLStreamException { + + java.lang.String prefix = parentQName.getPrefix(); + java.lang.String namespace = parentQName.getNamespaceURI(); + + if (namespace != null) { + java.lang.String writerPrefix = xmlWriter.getPrefix(namespace); + if (writerPrefix != null) { + xmlWriter.writeStartElement(namespace, parentQName.getLocalPart()); + } else { + if (prefix == null) { + prefix = org.apache.axis2.databinding.utils.BeanUtil.getUniquePrefix(); + } + + xmlWriter.writeStartElement(prefix, parentQName.getLocalPart(), namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } + } else { + xmlWriter.writeStartElement(parentQName.getLocalPart()); + } + + namespace = "http://credit"; + if (!namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = org.apache.axis2.databinding.utils.BeanUtil.getUniquePrefix(); + + xmlWriter.writeStartElement(prefix, "score", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace, "score"); + } + + } else { + xmlWriter.writeStartElement("score"); + } + + xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil + .convertToString(localScore)); + + xmlWriter.writeEndElement(); + + xmlWriter.writeEndElement(); + + } + + /** + * Util method to write an attribute with the ns prefix + */ + private void writeAttribute(java.lang.String prefix, + java.lang.String namespace, + java.lang.String attName, + java.lang.String attValue, + javax.xml.stream.XMLStreamWriter xmlWriter) + throws javax.xml.stream.XMLStreamException { + if (xmlWriter.getPrefix(namespace) == null) { + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } + + xmlWriter.writeAttribute(namespace, attName, attValue); + + } + + /** + * Util method to write an attribute without the ns prefix + */ + private void writeAttribute(java.lang.String namespace, + java.lang.String attName, + java.lang.String attValue, + javax.xml.stream.XMLStreamWriter xmlWriter) + throws javax.xml.stream.XMLStreamException { + if (namespace.equals("")) { + xmlWriter.writeAttribute(attName, attValue); + } else { + registerPrefix(xmlWriter, namespace); + xmlWriter.writeAttribute(namespace, attName, attValue); + } + } + + /** + * Register a namespace prefix + */ + private java.lang.String registerPrefix(javax.xml.stream.XMLStreamWriter xmlWriter, + java.lang.String namespace) + throws javax.xml.stream.XMLStreamException { + java.lang.String prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = createPrefix(); + + while (xmlWriter.getNamespaceContext().getNamespaceURI(prefix) != null) { + prefix = createPrefix(); + } + + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } + + return prefix; + } + + /** + * Create a prefix + */ + private java.lang.String createPrefix() { + return "ns" + (int)Math.random(); + } + }; + + return new org.apache.axiom.om.impl.llom.OMSourcedElementImpl(MY_QNAME, factory, dataSource); + + } + + /** + * databinding method to get an XML representation of this object + */ + public javax.xml.stream.XMLStreamReader getPullParser(javax.xml.namespace.QName qName) { + + java.util.ArrayList elementList = new java.util.ArrayList(); + java.util.ArrayList attribList = new java.util.ArrayList(); + + elementList.add(new javax.xml.namespace.QName("http://credit", "score")); + + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localScore)); + + return new org.apache.axis2.databinding.utils.reader.ADBXMLStreamReaderImpl(qName, elementList + .toArray(), attribList.toArray()); + + } + + /** + * Factory class that keeps the parse method + */ + public static class Factory { + + /** + * static method to create the object Precondition: If this object is an + * element, the current or next start element starts this object and any + * intervening reader events are ignorable If this object is not an + * element, it is a complex type and the reader is at the event just + * after the outer start element Postcondition: If this object is an + * element, the reader is positioned at its end element If this object + * is a complex type, the reader is positioned at the end element of its + * outer element + */ + public static GetCreditScoreResponse parse(javax.xml.stream.XMLStreamReader reader) + throws java.lang.Exception { + GetCreditScoreResponse object = new GetCreditScoreResponse(); + int event; + try { + + while (!reader.isStartElement() && !reader.isEndElement()) + reader.next(); + + if (reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance", "type") != null) { + java.lang.String fullTypeName = + reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance", "type"); + if (fullTypeName != null) { + java.lang.String nsPrefix = fullTypeName.substring(0, fullTypeName.indexOf(":")); + nsPrefix = nsPrefix == null ? "" : nsPrefix; + + java.lang.String type = fullTypeName.substring(fullTypeName.indexOf(":") + 1); + if (!"getCreditScoreResponse".equals(type)) { + // find namespace for the prefix + java.lang.String nsUri = reader.getNamespaceContext().getNamespaceURI(nsPrefix); + return (GetCreditScoreResponse)credit.ExtensionMapper.getTypeObject(nsUri, + type, + reader); + } + + } + + } + + // Note all attributes that were handled. Used to differ normal + // attributes + // from anyAttributes. + java.util.Vector handledAttributes = new java.util.Vector(); + + boolean isReaderMTOMAware = false; + + try { + isReaderMTOMAware = + java.lang.Boolean.TRUE.equals(reader + .getProperty(org.apache.axiom.om.OMConstants.IS_DATA_HANDLERS_AWARE)); + } catch (java.lang.IllegalArgumentException e) { + isReaderMTOMAware = false; + } + + reader.next(); + + while (!reader.isStartElement() && !reader.isEndElement()) + reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("http://credit", "score") + .equals(reader.getName())) { + + java.lang.String content = reader.getElementText(); + + object.setScore(org.apache.axis2.databinding.utils.ConverterUtil.convertToInt(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + // A start element we are not expecting indicates an invalid + // parameter was passed + throw new java.lang.RuntimeException("Unexpected subelement " + reader.getLocalName()); + } + + while (!reader.isStartElement() && !reader.isEndElement()) + reader.next(); + if (reader.isStartElement()) + // A start element we are not expecting indicates a trailing + // invalid property + throw new java.lang.RuntimeException("Unexpected subelement " + reader.getLocalName()); + + } catch (javax.xml.stream.XMLStreamException e) { + throw new java.lang.Exception(e); + } + + return object; + } + + }// end of factory class + +} diff --git a/sandbox/rfeng/samples.M2/creditws-axis2/wsdl/credit.wsdl b/sandbox/rfeng/samples.M2/creditws-axis2/wsdl/credit.wsdl new file mode 100644 index 0000000000..d484a5e90c --- /dev/null +++ b/sandbox/rfeng/samples.M2/creditws-axis2/wsdl/credit.wsdl @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/rfeng/samples.M2/creditws/.ruleset b/sandbox/rfeng/samples.M2/creditws/.ruleset new file mode 100644 index 0000000000..2a06794776 --- /dev/null +++ b/sandbox/rfeng/samples.M2/creditws/.ruleset @@ -0,0 +1,172 @@ + + + PMD Plugin preferences rule set + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/rfeng/samples.M2/creditws/pom.xml b/sandbox/rfeng/samples.M2/creditws/pom.xml new file mode 100644 index 0000000000..a4f46d23da --- /dev/null +++ b/sandbox/rfeng/samples.M2/creditws/pom.xml @@ -0,0 +1,102 @@ + + + + + org.apache.tuscany.sca.samples + parent + 1.0-incubator-M2-SNAPSHOT + + 4.0.0 + sample-creditws + war + Tuscany credit Web Service Sample + A sample credit Web Service. + + + axis2 + + + + + + + org.osoa + sca-api-r0.95 + ${scaImplVersion} + compile + + + + + org.apache.tuscany.sca.kernel + tuscany-api + ${scaImplVersion} + compile + + + + + org.apache.tuscany.sca.runtime + webapp + ${scaImplVersion} + runtime + + + + + junit + junit + 3.8.1 + test + + + + + + install + credit + + + org.apache.tuscany.sca.plugins + tuscany-war-plugin + + + tuscany-war + + tuscany-war + + + + + + + false + + + org.apache.tuscany.sca.services.bindings + axis2 + ${scaImplVersion} + + + + + + + diff --git a/sandbox/rfeng/samples.M2/creditws/src/main/java/credit/CreditCheck.java b/sandbox/rfeng/samples.M2/creditws/src/main/java/credit/CreditCheck.java new file mode 100644 index 0000000000..ec95a60227 --- /dev/null +++ b/sandbox/rfeng/samples.M2/creditws/src/main/java/credit/CreditCheck.java @@ -0,0 +1,26 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package credit; + +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface CreditCheck { + int getCreditScore(String ssn); +} diff --git a/sandbox/rfeng/samples.M2/creditws/src/main/java/credit/CreditCheckImpl.java b/sandbox/rfeng/samples.M2/creditws/src/main/java/credit/CreditCheckImpl.java new file mode 100644 index 0000000000..24747cf993 --- /dev/null +++ b/sandbox/rfeng/samples.M2/creditws/src/main/java/credit/CreditCheckImpl.java @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package credit; + +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; + +/** + * An implementation of the CreditReportService service + */ +@Scope("MODULE") +@Service(CreditCheck.class) +public class CreditCheckImpl implements CreditCheck { + + public int getCreditScore(String ssn) { + return (int) (700 + (Math.random() - 0.5) * 100); + } +} diff --git a/sandbox/rfeng/samples.M2/creditws/src/main/resources/META-INF/LICENSE.txt b/sandbox/rfeng/samples.M2/creditws/src/main/resources/META-INF/LICENSE.txt new file mode 100644 index 0000000000..25d78feeac --- /dev/null +++ b/sandbox/rfeng/samples.M2/creditws/src/main/resources/META-INF/LICENSE.txt @@ -0,0 +1,1277 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + +APACHE TUSCANY SUBCOMPONENTS: + +The Apache Tuscany distribution includes a number of subcomponents with +separate copyright notices and license terms. Your use of the source +code for the these subcomponents is subject to the terms and +conditions of the following licenses. + +=============================================================================== + +For the Eclipse Modeling Framework component and the Celtix binding: + +Eclipse Public License - v 1.0 + +THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE +PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF +THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. + +1. DEFINITIONS + +"Contribution" means: + +a) in the case of the initial Contributor, the initial code and +documentation distributed under this Agreement, and +b) in the case of each subsequent Contributor: + +i) changes to the Program, and + +ii) additions to the Program; + +where such changes and/or additions to the Program originate from and +are distributed by that particular Contributor. A Contribution +'originates' from a Contributor if it was added to the Program by such +Contributor itself or anyone acting on such Contributor's behalf. +Contributions do not include additions to the Program which: (i) are +separate modules of software distributed in conjunction with the +Program under their own license agreement, and (ii) are not derivative +works of the Program. + +"Contributor" means any person or entity that distributes the Program. + +"Licensed Patents " mean patent claims licensable by a Contributor +which are necessarily infringed by the use or sale of its Contribution +alone or when combined with the Program. + +"Program" means the Contributions distributed in accordance with this +Agreement. + +"Recipient" means anyone who receives the Program under this +Agreement, including all Contributors. + +2. GRANT OF RIGHTS + +a) Subject to the terms of this Agreement, each Contributor hereby +grants Recipient a non-exclusive, worldwide, royalty-free copyright +license to reproduce, prepare derivative works of, publicly display, +publicly perform, distribute and sublicense the Contribution of such +Contributor, if any, and such derivative works, in source code and +object code form. + +b) Subject to the terms of this Agreement, each Contributor hereby +grants Recipient a non-exclusive, worldwide, royalty-free patent +license under Licensed Patents to make, use, sell, offer to sell, +import and otherwise transfer the Contribution of such Contributor, if +any, in source code and object code form. This patent license shall +apply to the combination of the Contribution and the Program if, at +the time the Contribution is added by the Contributor, such addition +of the Contribution causes such combination to be covered by the +Licensed Patents. The patent license shall not apply to any other +combinations which include the Contribution. No hardware per se is +licensed hereunder. + +c) Recipient understands that although each Contributor grants the +licenses to its Contributions set forth herein, no assurances are +provided by any Contributor that the Program does not infringe the +patent or other intellectual property rights of any other entity. Each +Contributor disclaims any liability to Recipient for claims brought by +any other entity based on infringement of intellectual property rights +or otherwise. As a condition to exercising the rights and licenses +granted hereunder, each Recipient hereby assumes sole responsibility +to secure any other intellectual property rights needed, if any. For +example, if a third party patent license is required to allow +Recipient to distribute the Program, it is Recipient's responsibility +to acquire that license before distributing the Program. + +d) Each Contributor represents that to its knowledge it has sufficient +copyright rights in its Contribution, if any, to grant the copyright +license set forth in this Agreement. + +3. REQUIREMENTS + +A Contributor may choose to distribute the Program in object code form +under its own license agreement, provided that: + +a) it complies with the terms and conditions of this Agreement; and + +b) its license agreement: + +i) effectively disclaims on behalf of all Contributors all warranties +and conditions, express and implied, including warranties or +conditions of title and non-infringement, and implied warranties or +conditions of merchantability and fitness for a particular purpose; + +ii) effectively excludes on behalf of all Contributors all liability +for damages, including direct, indirect, special, incidental and +consequential damages, such as lost profits; + +iii) states that any provisions which differ from this Agreement are +offered by that Contributor alone and not by any other party; and + +iv) states that source code for the Program is available from such +Contributor, and informs licensees how to obtain it in a reasonable +manner on or through a medium customarily used for software exchange. + +When the Program is made available in source code form: + +a) it must be made available under this Agreement; and + +b) a copy of this Agreement must be included with each copy of the +Program. + +Contributors may not remove or alter any copyright notices contained +within the Program. + +Each Contributor must identify itself as the originator of its +Contribution, if any, in a manner that reasonably allows subsequent +Recipients to identify the originator of the Contribution. + +4. COMMERCIAL DISTRIBUTION + +Commercial distributors of software may accept certain +responsibilities with respect to end users, business partners and the +like. While this license is intended to facilitate the commercial use +of the Program, the Contributor who includes the Program in a +commercial product offering should do so in a manner which does not +create potential liability for other Contributors. Therefore, if a +Contributor includes the Program in a commercial product offering, +such Contributor ("Commercial Contributor") hereby agrees to defend +and indemnify every other Contributor ("Indemnified Contributor") +against any losses, damages and costs (collectively "Losses") arising +from claims, lawsuits and other legal actions brought by a third party +against the Indemnified Contributor to the extent caused by the acts +or omissions of such Commercial Contributor in connection with its +distribution of the Program in a commercial product offering. The +obligations in this section do not apply to any claims or Losses +relating to any actual or alleged intellectual property infringement. +In order to qualify, an Indemnified Contributor must: a) promptly +notify the Commercial Contributor in writing of such claim, and b) +allow the Commercial Contributor to control, and cooperate with the +Commercial Contributor in, the defense and any related settlement +negotiations. The Indemnified Contributor may participate in any such +claim at its own expense. + +For example, a Contributor might include the Program in a commercial +product offering, Product X. That Contributor is then a Commercial +Contributor. If that Commercial Contributor then makes performance +claims, or offers warranties related to Product X, those performance +claims and warranties are such Commercial Contributor's responsibility +alone. Under this section, the Commercial Contributor would have to +defend claims against the other Contributors related to those +performance claims and warranties, and if a court requires any other +Contributor to pay any damages as a result, the Commercial Contributor +must pay those damages. + +5. NO WARRANTY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS +PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY +WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY +OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely +responsible for determining the appropriateness of using and +distributing the Program and assumes all risks associated with its +exercise of rights under this Agreement , including but not limited to +the risks and costs of program errors, compliance with applicable +laws, damage to or loss of data, programs or equipment, and +unavailability or interruption of operations. + +6. DISCLAIMER OF LIABILITY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR +ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING +WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR +DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED +HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +7. GENERAL + +If any provision of this Agreement is invalid or unenforceable under +applicable law, it shall not affect the validity or enforceability of +the remainder of the terms of this Agreement, and without further +action by the parties hereto, such provision shall be reformed to the +minimum extent necessary to make such provision valid and enforceable. + +If Recipient institutes patent litigation against any entity +(including a cross-claim or counterclaim in a lawsuit) alleging that +the Program itself (excluding combinations of the Program with other +software or hardware) infringes such Recipient's patent(s), then such +Recipient's rights granted under Section 2(b) shall terminate as of +the date such litigation is filed. + +All Recipient's rights under this Agreement shall terminate if it +fails to comply with any of the material terms or conditions of this +Agreement and does not cure such failure in a reasonable period of +time after becoming aware of such noncompliance. If all Recipient's +rights under this Agreement terminate, Recipient agrees to cease use +and distribution of the Program as soon as reasonably practicable. +However, Recipient's obligations under this Agreement and any licenses +granted by Recipient relating to the Program shall continue and +survive. + +Everyone is permitted to copy and distribute copies of this Agreement, +but in order to avoid inconsistency the Agreement is copyrighted and +may only be modified in the following manner. The Agreement Steward +reserves the right to publish new versions (including revisions) of +this Agreement from time to time. No one other than the Agreement +Steward has the right to modify this Agreement. The Eclipse Foundation +is the initial Agreement Steward. The Eclipse Foundation may assign +the responsibility to serve as the Agreement Steward to a suitable +separate entity. Each new version of the Agreement will be given a +distinguishing version number. The Program (including Contributions) +may always be distributed subject to the version of the Agreement +under which it was received. In addition, after a new version of the +Agreement is published, Contributor may elect to distribute the +Program (including its Contributions) under the new version. Except as +expressly stated in Sections 2(a) and 2(b) above, Recipient receives +no rights or licenses to the intellectual property of any Contributor +under this Agreement, whether expressly, by implication, estoppel or +otherwise. All rights in the Program not expressly granted under this +Agreement are reserved. + +This Agreement is governed by the laws of the State of New York and +the intellectual property laws of the United States of America. No +party to this Agreement will bring a legal action under this Agreement +more than one year after the cause of action arose. Each party waives +its rights to a jury trial in any resulting litigation. + +=============================================================================== + +For the Rhino JavaScript container component: + +Mozilla Public License 1.1 (MPL 1.1) + +1. Definitions. + + 1.0.1. "Commercial Use" means distribution or otherwise making the +Covered Code available to a third party. + + 1.1. "Contributor" means each entity that creates or contributes to +the creation of Modifications. + + 1.2. "Contributor Version" means the combination of the Original Code, +prior Modifications used by a Contributor, and the Modifications made by that +particular Contributor. + + 1.3. "Covered Code" means the Original Code or Modifications or the +combination of the Original Code and Modifications, in each case including +portions thereof. + + 1.4. "Electronic Distribution Mechanism" means a mechanism generally +accepted in the software development community for the electronic transfer of +data. + + 1.5. "Executable" means Covered Code in any form other than Source +Code. + + 1.6. "Initial Developer" means the individual or entity identified as +the Initial Developer in the Source Code notice required by Exhibit A. + + 1.7. "Larger Work" means a work which combines Covered Code or +portions thereof with code not governed by the terms of this License. + + 1.8. "License" means this document. + + 1.8.1. "Licensable" means having the right to grant, to the maximum +extent possible, whether at the time of the initial grant or subsequently +acquired, any and all of the rights conveyed herein. + + 1.9. "Modifications" means any addition to or deletion from the +substance or structure of either the Original Code or any previous +Modifications. When Covered Code is released as a series of files, a +Modification is: + A. Any addition to or deletion from the contents of a file +containing Original Code or previous Modifications. + + B. Any new file that contains any part of the Original Code or +previous Modifications. + + 1.10. "Original Code" means Source Code of computer software code +which is described in the Source Code notice required by Exhibit A as Original +Code, and which, at the time of its release under this License is not already +Covered Code governed by this License. + + 1.10.1. "Patent Claims" means any patent claim(s), now owned or +hereafter acquired, including without limitation, method, process, and +apparatus claims, in any patent Licensable by grantor. + + 1.11. "Source Code" means the preferred form of the Covered Code for +making modifications to it, including all modules it contains, plus any +associated interface definition files, scripts used to control compilation and +installation of an Executable, or source code differential comparisons against +either the Original Code or another well known, available Covered Code of the +Contributor's choice. The Source Code can be in a compressed or archival form, +provided the appropriate decompression or de-archiving software is widely +available for no charge. + + 1.12. "You" (or "Your") means an individual or a legal entity +exercising rights under, and complying with all of the terms of, this License +or a future version of this License issued under Section 6.1. For legal +entities, "You" includes any entity which controls, is controlled by, or is +under common control with You. For purposes of this definition, "control" +means (a) the power, direct or indirect, to cause the direction or management +of such entity, whether by contract or otherwise, or (b) ownership of more +than fifty percent (50%) of the outstanding shares or beneficial ownership of +such entity. + +2. Source Code License. + + 2.1. The Initial Developer Grant. + The Initial Developer hereby grants You a world-wide, royalty-free, +non-exclusive license, subject to third party intellectual property claims: + (a) under intellectual property rights (other than patent or +trademark) Licensable by Initial Developer to use, reproduce, modify, display, +perform, sublicense and distribute the Original Code (or portions thereof) +with or without Modifications, and/or as part of a Larger Work; and + + (b) under Patents Claims infringed by the making, using or selling +of Original Code, to make, have made, use, practice, sell, and offer for sale, +and/or otherwise dispose of the Original Code (or portions thereof). + (c) the licenses granted in this Section 2.1(a) and +(b) are effective on the date Initial Developer first distributes Original +Code under the terms of this License. + + (d) Notwithstanding Section 2.1(b) above, no patent license is +granted: 1) for code that You delete from the Original Code; 2) separate from +the Original Code; or 3) for infringements caused by: i) the modification of +the Original Code or ii) the combination of the Original Code with other +software or devices. + + 2.2. Contributor Grant. + Subject to third party intellectual property claims, each Contributor +hereby grants You a world-wide, royalty-free, non-exclusive license + + (a) under intellectual property rights (other than patent or +trademark) Licensable by Contributor, to use, reproduce, modify, display, +perform, sublicense and distribute the Modifications created by such +Contributor (or portions thereof) either on an unmodified basis, with other +Modifications, as Covered Code and/or as part of a Larger Work; and + + (b) under Patent Claims infringed by the making, using, or selling +of Modifications made by that Contributor either alone and/or in combination +with its Contributor Version (or portions of such combination), to make, use, +sell, offer for sale, have made, and/or otherwise dispose of: 1) Modifications +made by that Contributor (or portions thereof); and 2) the combination of +Modifications made by that Contributor with its Contributor Version (or +portions of such combination). + + (c) the licenses granted in Sections 2.2(a) and 2.2(b) are +effective on the date Contributor first makes Commercial Use of the Covered +Code. + + (d) Notwithstanding Section 2.2(b) above, no patent license is +granted: 1) for any code that Contributor has deleted from the Contributor +Version; 2) separate from the Contributor Version; 3) for infringements +caused by: i) third party modifications of Contributor Version or ii) the +combination of Modifications made by that Contributor with other software +(except as part of the Contributor Version) or other devices; or 4) under +Patent Claims infringed by Covered Code in the absence of Modifications made +by that Contributor. + + +3. Distribution Obligations. + + 3.1. Application of License. + The Modifications which You create or to which You contribute are +governed by the terms of this License, including without limitation Section +2.2. The Source Code version of Covered Code may be distributed only under the +terms of this License or a future version of this License released under +Section 6.1, and You must include a copy of this License with every copy of +the Source Code You distribute. You may not offer or impose any terms on any +Source Code version that alters or restricts the applicable version of this +License or the recipients' rights hereunder. However, You may include an +additional document offering the additional rights described in Section 3.5. + + 3.2. Availability of Source Code. + Any Modification which You create or to which You contribute must be +made available in Source Code form under the terms of this License either on +the same media as an Executable version or via an accepted Electronic +Distribution Mechanism to anyone to whom you made an Executable version +available; and if made available via Electronic Distribution Mechanism, must +remain available for at least twelve (12) months after the date it initially +became available, or at least six (6) months after a subsequent version of +that particular Modification has been made available to such recipients. You +are responsible for ensuring that the Source Code version remains available +even if the Electronic Distribution Mechanism is maintained by a third party. + + 3.3. Description of Modifications. + You must cause all Covered Code to which You contribute to contain a +file documenting the changes You made to create that Covered Code and the date +of any change. You must include a prominent statement that the Modification is +derived, directly or indirectly, from Original Code provided by the Initial +Developer and including the name of the Initial Developer in (a) the Source +Code, and (b) in any notice in an Executable version or related documentation +in which You describe the origin or ownership of the Covered Code. + + 3.4. Intellectual Property Matters + (a) Third Party Claims. + If Contributor has knowledge that a license under a third party's +intellectual property rights is required to exercise the rights granted by +such Contributor under Sections 2.1 or 2.2, Contributor must include a text +file with the Source Code distribution titled "LEGAL" which describes the +claim and the party making the claim in sufficient detail that a recipient +will know whom to contact. If Contributor obtains such knowledge after the +Modification is made available as described in Section 3.2, Contributor shall +promptly modify the LEGAL file in all copies Contributor makes available +thereafter and shall take other steps (such as notifying appropriate mailing +lists or newsgroups) reasonably calculated to inform those who received the +Covered Code that new knowledge has been obtained. + + (b) Contributor APIs. + If Contributor's Modifications include an application programming +interface and Contributor has knowledge of patent licenses which are +reasonably necessary to implement that API, Contributor must also include this +information in the LEGAL file. + + (c) Representations. + Contributor represents that, except as disclosed pursuant to +Section 3.4(a) above, Contributor believes that Contributor's Modifications +are Contributor's original creation(s) and/or Contributor has sufficient +rights to grant the rights conveyed by this License. + + + 3.5. Required Notices. + You must duplicate the notice in Exhibit A in each file of the Source +Code. If it is not possible to put such notice in a particular Source Code +file due to its structure, then You must include such notice in a location +(such as a relevant directory) where a user would be likely to look for such a +notice. If You created one or more Modification(s) You may add your name as a +Contributor to the notice described in Exhibit A. You must also duplicate +this License in any documentation for the Source Code where You describe +recipients' rights or ownership rights relating to Covered Code. You may +choose to offer, and to charge a fee for, warranty, support, indemnity or +liability obligations to one or more recipients of Covered Code. However, You +may do so only on Your own behalf, and not on behalf of the Initial Developer +or any Contributor. You must make it absolutely clear than any such warranty, +support, indemnity or liability obligation is offered by You alone, and You +hereby agree to indemnify the Initial Developer and every Contributor for any +liability incurred by the Initial Developer or such Contributor as a result of +warranty, support, indemnity or liability terms You offer. + + 3.6. Distribution of Executable Versions. + You may distribute Covered Code in Executable form only if the +requirements of Section 3.1-3.5 have been met for that Covered Code, and if +You include a notice stating that the Source Code version of the Covered Code +is available under the terms of this License, including a description of how +and where You have fulfilled the obligations of Section 3.2. The notice must +be conspicuously included in any notice in an Executable version, related +documentation or collateral in which You describe recipients' rights relating +to the Covered Code. You may distribute the Executable version of Covered Code +or ownership rights under a license of Your choice, which may contain terms +different from this License, provided that You are in compliance with the +terms of this License and that the license for the Executable version does not +attempt to limit or alter the recipient's rights in the Source Code version +from the rights set forth in this License. If You distribute the Executable +version under a different license You must make it absolutely clear that any +terms which differ from this License are offered by You alone, not by the +Initial Developer or any Contributor. You hereby agree to indemnify the +Initial Developer and every Contributor for any liability incurred by the +Initial Developer or such Contributor as a result of any such terms You offer. + + 3.7. Larger Works. + You may create a Larger Work by combining Covered Code with other code +not governed by the terms of this License and distribute the Larger Work as a +single product. In such a case, You must make sure the requirements of this +License are fulfilled for the Covered Code. + +4. Inability to Comply Due to Statute or Regulation. + + If it is impossible for You to comply with any of the terms of this +License with respect to some or all of the Covered Code due to statute, +judicial order, or regulation then You must: (a) comply with the terms of this +License to the maximum extent possible; and (b) describe the limitations and +the code they affect. Such description must be included in the LEGAL file +described in Section 3.4 and must be included with all distributions of the +Source Code. Except to the extent prohibited by statute or regulation, such +description must be sufficiently detailed for a recipient of ordinary skill to +be able to understand it. + +5. Application of this License. + + This License applies to code to which the Initial Developer has attached +the notice in Exhibit A and to related Covered Code. + +6. Versions of the License. + + 6.1. New Versions. + Netscape Communications Corporation ("Netscape") may publish revised +and/or new versions of the License from time to time. Each version will be +given a distinguishing version number. + + 6.2. Effect of New Versions. + Once Covered Code has been published under a particular version of the +License, You may always continue to use it under the terms of that version. +You may also choose to use such Covered Code under the terms of any subsequent +version of the License published by Netscape. No one other than Netscape has +the right to modify the terms applicable to Covered Code created under this +License. + + 6.3. Derivative Works. + If You create or use a modified version of this License (which you may +only do in order to apply it to code which is not already Covered Code +governed by this License), You must (a) rename Your license so that the +phrases "Mozilla", "MOZILLAPL", "MOZPL", "Netscape", "MPL", "NPL" or +any confusingly similar phrase do not appear in your license (except to note +that your license differs from this License) and (b) otherwise make it clear +that Your version of the license contains terms which differ from the Mozilla +Public License and Netscape Public License. (Filling in the name of the +Initial Developer, Original Code or Contributor in the notice described in +Exhibit A shall not of themselves be deemed to be modifications of this +License.) + +7. DISCLAIMER OF WARRANTY. + + COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT +LIMITATION, WARRANTIES THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, +FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE +QUALITY AND PERFORMANCE OF THE COVERED CODE IS WITH YOU. SHOULD ANY COVERED +CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE INITIAL DEVELOPER OR ANY +OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY SERVICING, REPAIR OR +CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS +LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS +DISCLAIMER. + +8. TERMINATION. + + 8.1. This License and the rights granted hereunder will terminate +automatically if You fail to comply with terms herein and fail to cure such +breach within 30 days of becoming aware of the breach. All sublicenses to the +Covered Code which are properly granted shall survive any termination of this +License. Provisions which, by their nature, must remain in effect beyond the +termination of this License shall survive. + + 8.2. If You initiate litigation by asserting a patent infringement +claim (excluding declatory judgment actions) against Initial Developer or a +Contributor (the Initial Developer or Contributor against whom You file such +action is referred to as "Participant") alleging that: + + (a) such Participant's Contributor Version directly or indirectly +infringes any patent, then any and all rights granted by such Participant to +You under Sections 2.1 and/or 2.2 of this License shall, upon 60 days notice +from Participant terminate prospectively, unless if within 60 days after +receipt of notice You either: (i) agree in writing to pay Participant a +mutually agreeable reasonable royalty for Your past and future use of +Modifications made by such Participant, or (ii) withdraw Your litigation claim +with respect to the Contributor Version against such Participant. If within +60 days of notice, a reasonable royalty and payment arrangement are not +mutually agreed upon in writing by the parties or the litigation claim is not +withdrawn, the rights granted by Participant to You under Sections 2.1 and/or +2.2 automatically terminate at the expiration of the 60 day notice period +specified above. + + (b) any software, hardware, or device, other than such Participant's +Contributor Version, directly or indirectly infringes any patent, then any +rights granted to You by such Participant under Sections 2.1(b) and 2.2(b) are +revoked effective as of the date You first made, used, sold, distributed, or +had made, Modifications made by that Participant. + + 8.3. If You assert a patent infringement claim against Participant +alleging that such Participant's Contributor Version directly or indirectly +infringes any patent where such claim is resolved (such as by license or +settlement) prior to the initiation of patent infringement litigation, then +the reasonable value of the licenses granted by such Participant under +Sections 2.1 or 2.2 shall be taken into account in determining the amount or +value of any payment or license. + + 8.4. In the event of termination under Sections 8.1 or 8.2 above, all +end user license agreements (excluding distributors and resellers) which have +been validly granted by You or any distributor hereunder prior to termination +shall survive termination. + +9. LIMITATION OF LIABILITY. + + UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT +(INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL +DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED CODE, OR ANY +SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR ANY INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, +WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL, WORK STOPPAGE, COMPUTER +FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL DAMAGES OR LOSSES, +EVEN IF SUCH PARTY SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF SUCH +DAMAGES. THIS LIMITATION OF LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH +OR PERSONAL INJURY RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT +APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE +EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THIS +EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU. + +10. U.S. GOVERNMENT END USERS. + + The Covered Code is a "commercial item," as that term is defined in 48 +C.F.R. 2.101 (Oct. 1995), consisting of "commercial computer software" and +"commercial computer software documentation," as such terms are used in 48 +C.F.R. 12.212 (Sept. 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. +227.7202-1 through 227.7202-4 (June 1995), all U.S. Government End Users +acquire Covered Code with only those rights set forth herein. + +11. MISCELLANEOUS. + + This License represents the complete agreement concerning subject matter +hereof. If any provision of this License is held to be unenforceable, such +provision shall be reformed only to the extent necessary to make it +enforceable. This License shall be governed by California law provisions +(except to the extent applicable law, if any, provides otherwise), excluding +its conflict-of-law provisions. With respect to disputes in which at least one +party is a citizen of, or an entity chartered or registered to do business in +the United States of America, any litigation relating to this License shall be +subject to the jurisdiction of the Federal Courts of the Northern District of +California, with venue lying in Santa Clara County, California, with the +losing party responsible for costs, including without limitation, court costs +and reasonable attorneys' fees and expenses. The application of the United +Nations Convention on Contracts for the International Sale of Goods is +expressly excluded. Any law or regulation which provides that the language of +a contract shall be construed against the drafter shall not apply to this +License. + +12. RESPONSIBILITY FOR CLAIMS. + + As between Initial Developer and the Contributors, each party is +responsible for claims and damages arising, directly or indirectly, out of its +utilization of rights under this License and You agree to work with Initial +Developer and Contributors to distribute such responsibility on an equitable +basis. Nothing herein is intended or shall be deemed to constitute any +admission of liability. + +13. MULTIPLE-LICENSED CODE. + + Initial Developer may designate portions of the Covered Code as +Multiple-Licensed. Multiple-Licensed means that the Initial Developer permits +you to utilize portions of the Covered Code under Your choice of the MPL or +the alternative licenses, if any, specified by the Initial Developer in the +file described in Exhibit A. + + +EXHIBIT A -Mozilla Public License. + + ``The contents of this file are subject to the Mozilla Public License +Version 1.1 (the "License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + http://www.mozilla.org/MPL/ + + Software distributed under the License is distributed on an "AS IS" +basis, WITHOUT WARRANTY OF + ANY KIND, either express or implied. See the License for the specific +language governing rights and + limitations under the License. + + The Original Code is ______________________________________. + + The Initial Developer of the Original Code is ________________________. +Portions created by + ______________________ are Copyright (C) ______ +_______________________. All Rights + Reserved. + + Contributor(s): ______________________________________. + + Alternatively, the contents of this file may be used under the terms of +the _____ license (the [___] License), in which case the provisions of +[______] License are applicable instead of those above. If you wish to allow +use of your version of this file only under the terms of the [____] License +and not to allow others to use your version of this file under the MPL, +indicate your decision by deleting the provisions above and replace them +with the notice and other provisions required by the [___] License. If you do +not delete the provisions above, a recipient may use your version of this file +under either the MPL or the [___] License." + + [NOTE: The text of this Exhibit A may differ slightly from the text of +the notices in the Source Code files of the Original Code. You should use the +text of this Exhibit A rather than the text found in the Original Code Source +Code for Your Modifications.] + + +=============================================================================== + +For the JAX-WS Reference Implementation component: + +COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 + + + 1. Definitions. + + 1.1. "Contributor" means each individual or entity that + creates or contributes to the creation of Modifications. + + 1.2. "Contributor Version" means the combination of the + Original Software, prior Modifications used by a + Contributor (if any), and the Modifications made by that + particular Contributor. + + 1.3. "Covered Software" means (a) the Original Software, or + (b) Modifications, or (c) the combination of files + containing Original Software with files containing + Modifications, in each case including portions thereof. + + 1.4. "Executable" means the Covered Software in any form + other than Source Code. + + 1.5. "Initial Developer" means the individual or entity + that first makes Original Software available under this + License. + + 1.6. "Larger Work" means a work which combines Covered + Software or portions thereof with code not governed by the + terms of this License. + + 1.7. "License" means this document. + + 1.8. "Licensable" means having the right to grant, to the + maximum extent possible, whether at the time of the initial + grant or subsequently acquired, any and all of the rights + conveyed herein. + + 1.9. "Modifications" means the Source Code and Executable + form of any of the following: + + A. Any file that results from an addition to, + deletion from or modification of the contents of a + file containing Original Software or previous + Modifications; + + B. Any new file that contains any part of the + Original Software or previous Modification; or + + C. Any new file that is contributed or otherwise made + available under the terms of this License. + + 1.10. "Original Software" means the Source Code and + Executable form of computer software code that is + originally released under this License. + + 1.11. "Patent Claims" means any patent claim(s), now owned + or hereafter acquired, including without limitation, + method, process, and apparatus claims, in any patent + Licensable by grantor. + + 1.12. "Source Code" means (a) the common form of computer + software code in which modifications are made and (b) + associated documentation included in or with such code. + + 1.13. "You" (or "Your") means an individual or a legal + entity exercising rights under, and complying with all of + the terms of, this License. For legal entities, "You" + includes any entity which controls, is controlled by, or is + under common control with You. For purposes of this + definition, "control" means (a) the power, direct or + indirect, to cause the direction or management of such + entity, whether by contract or otherwise, or (b) ownership + of more than fifty percent (50%) of the outstanding shares + or beneficial ownership of such entity. + + 2. License Grants. + + 2.1. The Initial Developer Grant. + + Conditioned upon Your compliance with Section 3.1 below and + subject to third party intellectual property claims, the + Initial Developer hereby grants You a world-wide, + royalty-free, non-exclusive license: + + (a) under intellectual property rights (other than + patent or trademark) Licensable by Initial Developer, + to use, reproduce, modify, display, perform, + sublicense and distribute the Original Software (or + portions thereof), with or without Modifications, + and/or as part of a Larger Work; and + + (b) under Patent Claims infringed by the making, + using or selling of Original Software, to make, have + made, use, practice, sell, and offer for sale, and/or + otherwise dispose of the Original Software (or + portions thereof). + + (c) The licenses granted in Sections 2.1(a) and (b) + are effective on the date Initial Developer first + distributes or otherwise makes the Original Software + available to a third party under the terms of this + License. + + (d) Notwithstanding Section 2.1(b) above, no patent + license is granted: (1) for code that You delete from + the Original Software, or (2) for infringements + caused by: (i) the modification of the Original + Software, or (ii) the combination of the Original + Software with other software or devices. + + 2.2. Contributor Grant. + + Conditioned upon Your compliance with Section 3.1 below and + subject to third party intellectual property claims, each + Contributor hereby grants You a world-wide, royalty-free, + non-exclusive license: + + (a) under intellectual property rights (other than + patent or trademark) Licensable by Contributor to + use, reproduce, modify, display, perform, sublicense + and distribute the Modifications created by such + Contributor (or portions thereof), either on an + unmodified basis, with other Modifications, as + Covered Software and/or as part of a Larger Work; and + + + (b) under Patent Claims infringed by the making, + using, or selling of Modifications made by that + Contributor either alone and/or in combination with + its Contributor Version (or portions of such + combination), to make, use, sell, offer for sale, + have made, and/or otherwise dispose of: (1) + Modifications made by that Contributor (or portions + thereof); and (2) the combination of Modifications + made by that Contributor with its Contributor Version + (or portions of such combination). + + (c) The licenses granted in Sections 2.2(a) and + 2.2(b) are effective on the date Contributor first + distributes or otherwise makes the Modifications + available to a third party. + + (d) Notwithstanding Section 2.2(b) above, no patent + license is granted: (1) for any code that Contributor + has deleted from the Contributor Version; (2) for + infringements caused by: (i) third party + modifications of Contributor Version, or (ii) the + combination of Modifications made by that Contributor + with other software (except as part of the + Contributor Version) or other devices; or (3) under + Patent Claims infringed by Covered Software in the + absence of Modifications made by that Contributor. + + 3. Distribution Obligations. + + 3.1. Availability of Source Code. + + Any Covered Software that You distribute or otherwise make + available in Executable form must also be made available in + Source Code form and that Source Code form must be + distributed only under the terms of this License. You must + include a copy of this License with every copy of the + Source Code form of the Covered Software You distribute or + otherwise make available. You must inform recipients of any + such Covered Software in Executable form as to how they can + obtain such Covered Software in Source Code form in a + reasonable manner on or through a medium customarily used + for software exchange. + + 3.2. Modifications. + + The Modifications that You create or to which You + contribute are governed by the terms of this License. You + represent that You believe Your Modifications are Your + original creation(s) and/or You have sufficient rights to + grant the rights conveyed by this License. + + 3.3. Required Notices. + + You must include a notice in each of Your Modifications + that identifies You as the Contributor of the Modification. + You may not remove or alter any copyright, patent or + trademark notices contained within the Covered Software, or + any notices of licensing or any descriptive text giving + attribution to any Contributor or the Initial Developer. + + 3.4. Application of Additional Terms. + + You may not offer or impose any terms on any Covered + Software in Source Code form that alters or restricts the + applicable version of this License or the recipients' + rights hereunder. You may choose to offer, and to charge a + fee for, warranty, support, indemnity or liability + obligations to one or more recipients of Covered Software. + However, you may do so only on Your own behalf, and not on + behalf of the Initial Developer or any Contributor. You + must make it absolutely clear that any such warranty, + support, indemnity or liability obligation is offered by + You alone, and You hereby agree to indemnify the Initial + Developer and every Contributor for any liability incurred + by the Initial Developer or such Contributor as a result of + warranty, support, indemnity or liability terms You offer. + + + 3.5. Distribution of Executable Versions. + + You may distribute the Executable form of the Covered + Software under the terms of this License or under the terms + of a license of Your choice, which may contain terms + different from this License, provided that You are in + compliance with the terms of this License and that the + license for the Executable form does not attempt to limit + or alter the recipient's rights in the Source Code form + from the rights set forth in this License. If You + distribute the Covered Software in Executable form under a + different license, You must make it absolutely clear that + any terms which differ from this License are offered by You + alone, not by the Initial Developer or Contributor. You + hereby agree to indemnify the Initial Developer and every + Contributor for any liability incurred by the Initial + Developer or such Contributor as a result of any such terms + You offer. + + 3.6. Larger Works. + + You may create a Larger Work by combining Covered Software + with other code not governed by the terms of this License + and distribute the Larger Work as a single product. In such + a case, You must make sure the requirements of this License + are fulfilled for the Covered Software. + + 4. Versions of the License. + + 4.1. New Versions. + + Sun Microsystems, Inc. is the initial license steward and + may publish revised and/or new versions of this License + from time to time. Each version will be given a + distinguishing version number. Except as provided in + Section 4.3, no one other than the license steward has the + right to modify this License. + + 4.2. Effect of New Versions. + + You may always continue to use, distribute or otherwise + make the Covered Software available under the terms of the + version of the License under which You originally received + the Covered Software. If the Initial Developer includes a + notice in the Original Software prohibiting it from being + distributed or otherwise made available under any + subsequent version of the License, You must distribute and + make the Covered Software available under the terms of the + version of the License under which You originally received + the Covered Software. Otherwise, You may also choose to + use, distribute or otherwise make the Covered Software + available under the terms of any subsequent version of the + License published by the license steward. + + 4.3. Modified Versions. + + When You are an Initial Developer and You want to create a + new license for Your Original Software, You may create and + use a modified version of this License if You: (a) rename + the license and remove any references to the name of the + license steward (except to note that the license differs + from this License); and (b) otherwise make it clear that + the license contains terms which differ from this License. + + + 5. DISCLAIMER OF WARRANTY. + + COVERED SOFTWARE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" + BASIS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, + INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE COVERED + SOFTWARE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR + PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND + PERFORMANCE OF THE COVERED SOFTWARE IS WITH YOU. SHOULD ANY + COVERED SOFTWARE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE + INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF + ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF + WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF + ANY COVERED SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS + DISCLAIMER. + + 6. TERMINATION. + + 6.1. This License and the rights granted hereunder will + terminate automatically if You fail to comply with terms + herein and fail to cure such breach within 30 days of + becoming aware of the breach. Provisions which, by their + nature, must remain in effect beyond the termination of + this License shall survive. + + 6.2. If You assert a patent infringement claim (excluding + declaratory judgment actions) against Initial Developer or + a Contributor (the Initial Developer or Contributor against + whom You assert such claim is referred to as "Participant") + alleging that the Participant Software (meaning the + Contributor Version where the Participant is a Contributor + or the Original Software where the Participant is the + Initial Developer) directly or indirectly infringes any + patent, then any and all rights granted directly or + indirectly to You by such Participant, the Initial + Developer (if the Initial Developer is not the Participant) + and all Contributors under Sections 2.1 and/or 2.2 of this + License shall, upon 60 days notice from Participant + terminate prospectively and automatically at the expiration + of such 60 day notice period, unless if within such 60 day + period You withdraw Your claim with respect to the + Participant Software against such Participant either + unilaterally or pursuant to a written agreement with + Participant. + + 6.3. In the event of termination under Sections 6.1 or 6.2 + above, all end user licenses that have been validly granted + by You or any distributor hereunder prior to termination + (excluding licenses granted to You by any distributor) + shall survive termination. + + 7. LIMITATION OF LIABILITY. + + UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT + (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE + INITIAL DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF + COVERED SOFTWARE, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE + LIABLE TO ANY PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR + CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT + LIMITATION, DAMAGES FOR LOST PROFITS, LOSS OF GOODWILL, WORK + STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER + COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN + INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF + LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL + INJURY RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT + APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO + NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR + CONSEQUENTIAL DAMAGES, SO THIS EXCLUSION AND LIMITATION MAY NOT + APPLY TO YOU. + + 8. U.S. GOVERNMENT END USERS. + + The Covered Software is a "commercial item," as that term is + defined in 48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial + computer software" (as that term is defined at 48 C.F.R. + 252.227-7014(a)(1)) and "commercial computer software + documentation" as such terms are used in 48 C.F.R. 12.212 (Sept. + 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1 + through 227.7202-4 (June 1995), all U.S. Government End Users + acquire Covered Software with only those rights set forth herein. + This U.S. Government Rights clause is in lieu of, and supersedes, + any other FAR, DFAR, or other clause or provision that addresses + Government rights in computer software under this License. + + 9. MISCELLANEOUS. + + This License represents the complete agreement concerning subject + matter hereof. If any provision of this License is held to be + unenforceable, such provision shall be reformed only to the + extent necessary to make it enforceable. This License shall be + governed by the law of the jurisdiction specified in a notice + contained within the Original Software (except to the extent + applicable law, if any, provides otherwise), excluding such + jurisdiction's conflict-of-law provisions. Any litigation + relating to this License shall be subject to the jurisdiction of + the courts located in the jurisdiction and venue specified in a + notice contained within the Original Software, with the losing + party responsible for costs, including, without limitation, court + costs and reasonable attorneys' fees and expenses. The + application of the United Nations Convention on Contracts for the + International Sale of Goods is expressly excluded. Any law or + regulation which provides that the language of a contract shall + be construed against the drafter shall not apply to this License. + You agree that You alone are responsible for compliance with the + United States export administration regulations (and the export + control laws and regulation of any other countries) when You use, + distribute or otherwise make available any Covered Software. + + 10. RESPONSIBILITY FOR CLAIMS. + + As between Initial Developer and the Contributors, each party is + responsible for claims and damages arising, directly or + indirectly, out of its utilization of rights under this License + and You agree to work with Initial Developer and Contributors to + distribute such responsibility on an equitable basis. Nothing + herein is intended or shall be deemed to constitute any admission + of liability. + diff --git a/sandbox/rfeng/samples.M2/creditws/src/main/resources/META-INF/NOTICE b/sandbox/rfeng/samples.M2/creditws/src/main/resources/META-INF/NOTICE new file mode 100644 index 0000000000..11c564eb19 --- /dev/null +++ b/sandbox/rfeng/samples.M2/creditws/src/main/resources/META-INF/NOTICE @@ -0,0 +1,18 @@ +========================================================================= +== NOTICE file corresponding to the section 4 d of == +== the Apache License, Version 2.0, == +== in this case for the Apache Tuscany distribution. == +========================================================================= + +This product includes software developed by the Apache Software Foundation +(http://www.apache.org/). + +This product also includes software developed by: +- the Eclipse Modeling Framework project (http://www.eclipse.org/emf/) +- the Celtix project (http://celtix.objectweb.org/) +- the Mozilla Rhino project (http://www.mozilla.org/rhino/) +- the GlassFish JAX-WS project (https://jax-ws.dev.java.net/) + +Please read the LICENSE.txt file present in the root directory of this +distribution. + diff --git a/sandbox/rfeng/samples.M2/creditws/src/main/resources/META-INF/README.txt b/sandbox/rfeng/samples.M2/creditws/src/main/resources/META-INF/README.txt new file mode 100644 index 0000000000..9b26d1690a --- /dev/null +++ b/sandbox/rfeng/samples.M2/creditws/src/main/resources/META-INF/README.txt @@ -0,0 +1,35 @@ +Apache Tuscany M1 build (May, 2006) +=================================== + +http://incubator.apache.org/tuscany/ + +Tuscany is an effort undergoing incubation at the Apache Software Foundation +(ASF), sponsored by the Web Services PMC. + +Incubation is required of all newly accepted projects until a further review +indicates that the infrastructure, communications, and decision making process +have stabilized in a manner consistent with other successful ASF projects. + +While incubation status is not necessarily a reflection of the completeness or +stability of the code, it does indicate that the project has yet to be fully +endorsed by the ASF. + + +Support +------- + +Any problem with this release can be reported to the Tuscany mailing list +or in the JIRA issue tracker. + +Mailing list subscription: + tuscany-dev-subscribe@ws.apache.org + +Jira: + http://issues.apache.org/jira/browse/Tuscany + + +Thank you for using Tuscany! + + +The Tuscany Team. + diff --git a/sandbox/rfeng/samples.M2/creditws/src/main/resources/wsdl/credit.wsdl b/sandbox/rfeng/samples.M2/creditws/src/main/resources/wsdl/credit.wsdl new file mode 100644 index 0000000000..d484a5e90c --- /dev/null +++ b/sandbox/rfeng/samples.M2/creditws/src/main/resources/wsdl/credit.wsdl @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/rfeng/samples.M2/creditws/src/main/webapp/META-INF/tuscany/webapp.scdl b/sandbox/rfeng/samples.M2/creditws/src/main/webapp/META-INF/tuscany/webapp.scdl new file mode 100644 index 0000000000..50688615a6 --- /dev/null +++ b/sandbox/rfeng/samples.M2/creditws/src/main/webapp/META-INF/tuscany/webapp.scdl @@ -0,0 +1,139 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 10 + + + + + + + + + + + + + + + + + + + + + + http://repo1.maven.org/maven2/,http://people.apache.org/repo/m2-snapshot-repository,http://people.apache.org/repo/m2-incubating-repository/,http://people.apache.org/repo/m1-snapshot-repository/ + + + + + /WEB-INF/tuscany/extensions/ + + diff --git a/sandbox/rfeng/samples.M2/creditws/src/main/webapp/WEB-INF/default.scdl b/sandbox/rfeng/samples.M2/creditws/src/main/webapp/WEB-INF/default.scdl new file mode 100644 index 0000000000..95d7dbc6de --- /dev/null +++ b/sandbox/rfeng/samples.M2/creditws/src/main/webapp/WEB-INF/default.scdl @@ -0,0 +1,35 @@ + + + + + + + + + CreditCheckServiceComponent + + + + + + + diff --git a/sandbox/rfeng/samples.M2/creditws/src/main/webapp/WEB-INF/web.xml b/sandbox/rfeng/samples.M2/creditws/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..22d4a55a4c --- /dev/null +++ b/sandbox/rfeng/samples.M2/creditws/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,41 @@ + + + + + + Tuscany Credit Check Web Service Sample + + + org.apache.tuscany.runtime.webapp.TuscanyContextListener + + + + TuscanyServlet + Tuscany Servlet + org.apache.tuscany.runtime.webapp.TuscanyServlet + + + + TuscanyServlet + /services/* + + + diff --git a/sandbox/rfeng/samples.M2/mortgage/pom.xml b/sandbox/rfeng/samples.M2/mortgage/pom.xml new file mode 100644 index 0000000000..809fade52a --- /dev/null +++ b/sandbox/rfeng/samples.M2/mortgage/pom.xml @@ -0,0 +1,79 @@ + + + + + org.apache.tuscany.sca.samples + parent + 1.0-incubator-M2-SNAPSHOT + + 4.0.0 + sample-mortgage + jar + Tuscany Mortgage Sample + A sample Mortgage application made of several SCA components wired together. + + + + org.osoa + sca-api-r0.95 + + + org.apache.tuscany.sca + test + test + + + org.apache.tuscany.sca.services.containers + javascript + ${scaImplVersion} + runtime + + + org.apache.tuscany.sca.services.bindings + axis2 + ${scaImplVersion} + runtime + + + org.apache.tuscany.sca.services.databinding + databinding-axiom + ${scaImplVersion} + runtime + + + + + install + ${artifactId} + + + org.apache.maven.plugins + maven-jar-plugin + + + + mortgage.MortgageClient + + + + + + + diff --git a/sandbox/rfeng/samples.M2/mortgage/src/main/java/mortgage/CreditCheck.java b/sandbox/rfeng/samples.M2/mortgage/src/main/java/mortgage/CreditCheck.java new file mode 100644 index 0000000000..c5787b7819 --- /dev/null +++ b/sandbox/rfeng/samples.M2/mortgage/src/main/java/mortgage/CreditCheck.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package mortgage; + +import org.osoa.sca.annotations.Remotable; + +/** + * CreditCheck interface + */ +@Remotable +public interface CreditCheck { + int getCreditScore(String ssn); +} diff --git a/sandbox/rfeng/samples.M2/mortgage/src/main/java/mortgage/CreditCheckImpl.java b/sandbox/rfeng/samples.M2/mortgage/src/main/java/mortgage/CreditCheckImpl.java new file mode 100644 index 0000000000..86fe88b417 --- /dev/null +++ b/sandbox/rfeng/samples.M2/mortgage/src/main/java/mortgage/CreditCheckImpl.java @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package mortgage; + +import org.osoa.sca.annotations.Service; + +/** + * A pojo implementation of the CreditCheck service + */ +@Service(CreditCheck.class) +public class CreditCheckImpl implements CreditCheck { + + public int getCreditScore(String ssn) { + return (int) (700 + (Math.random() - 0.5) * 100); + } +} diff --git a/sandbox/rfeng/samples.M2/mortgage/src/main/java/mortgage/Customer.java b/sandbox/rfeng/samples.M2/mortgage/src/main/java/mortgage/Customer.java new file mode 100644 index 0000000000..a8b23c6019 --- /dev/null +++ b/sandbox/rfeng/samples.M2/mortgage/src/main/java/mortgage/Customer.java @@ -0,0 +1,75 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package mortgage; + +/** + * A simple Customer object + */ +public class Customer { + private String ssn; + private String firstName; + private String lastName; + private double monthlyIncome; + private String state; + + public double getMonthlyIncome() { + return monthlyIncome; + } + + public void setMonthlyIncome(double monthlyIncome) { + this.monthlyIncome = monthlyIncome; + } + + public String getState() { + return state; + } + + public void setState(String state) { + this.state = state; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public String getSsn() { + return ssn; + } + + public void setSsn(String ssn) { + this.ssn = ssn; + } + + public String toString() { + return firstName + " " + lastName + "[" + ssn + "]"; + } +} diff --git a/sandbox/rfeng/samples.M2/mortgage/src/main/java/mortgage/InterestRateQuote.java b/sandbox/rfeng/samples.M2/mortgage/src/main/java/mortgage/InterestRateQuote.java new file mode 100644 index 0000000000..b5bafeb204 --- /dev/null +++ b/sandbox/rfeng/samples.M2/mortgage/src/main/java/mortgage/InterestRateQuote.java @@ -0,0 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package mortgage; + +public interface InterestRateQuote { + public float getRate(String state, double loanAmount, int termInYears); +} diff --git a/sandbox/rfeng/samples.M2/mortgage/src/main/java/mortgage/InterestRateQuoteImpl.java b/sandbox/rfeng/samples.M2/mortgage/src/main/java/mortgage/InterestRateQuoteImpl.java new file mode 100644 index 0000000000..93054a2491 --- /dev/null +++ b/sandbox/rfeng/samples.M2/mortgage/src/main/java/mortgage/InterestRateQuoteImpl.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package mortgage; + +import org.osoa.sca.annotations.Service; + +@Service(InterestRateQuote.class) +public class InterestRateQuoteImpl implements InterestRateQuote { + public float getRate(String state, double loanAmount, int termInYears) { + if (termInYears == 5) + return 5.5f; + else + return 6.5f; + } +} diff --git a/sandbox/rfeng/samples.M2/mortgage/src/main/java/mortgage/LoanApproval.java b/sandbox/rfeng/samples.M2/mortgage/src/main/java/mortgage/LoanApproval.java new file mode 100644 index 0000000000..dcdad18496 --- /dev/null +++ b/sandbox/rfeng/samples.M2/mortgage/src/main/java/mortgage/LoanApproval.java @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package mortgage; + +/** + * Loan Approval interface + */ +public interface LoanApproval { + public boolean approve(Customer customer, double loanAmount, int years); +} diff --git a/sandbox/rfeng/samples.M2/mortgage/src/main/java/mortgage/LoanApprovalImpl.java b/sandbox/rfeng/samples.M2/mortgage/src/main/java/mortgage/LoanApprovalImpl.java new file mode 100644 index 0000000000..12212b61f0 --- /dev/null +++ b/sandbox/rfeng/samples.M2/mortgage/src/main/java/mortgage/LoanApprovalImpl.java @@ -0,0 +1,78 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package mortgage; + +import org.osoa.sca.annotations.Property; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; + +/** + * An implementation of the LoanApproval service. + */ +@Scope("MODULE") +@Service(LoanApproval.class) +public class LoanApprovalImpl implements LoanApproval { + + private CreditCheck creditCheck; + private RiskAssessment riskAssessment; + private MortgageCalculator mortgageCalculator; + private InterestRateQuote interestRateQuote; + + private int minimumCreditScore = 650; + + @Property(name = "minimumCreditScore") + public void setMinimumCreditScore(int minimumCreditScore) { + this.minimumCreditScore = minimumCreditScore; + } + + @Reference + public void setCreditCheck(CreditCheck creditCheck) { + this.creditCheck = creditCheck; + } + + @Reference + public void setInterestRateQuote(InterestRateQuote interestRateQuote) { + this.interestRateQuote = interestRateQuote; + } + + @Reference + public void setMortgageCalculator(MortgageCalculator mortgageCalculator) { + this.mortgageCalculator = mortgageCalculator; + } + + @Reference + public void setRiskAssessment(RiskAssessment riskAssessment) { + this.riskAssessment = riskAssessment; + } + + /** + * @see mortgage.LoanApproval#approve(mortgage.Customer, double, int) + */ + public boolean approve(Customer customer, double loanAmount, int years) { + int score = creditCheck.getCreditScore(customer.getSsn()); + if (score < minimumCreditScore) { + return false; + } + float rate = interestRateQuote.getRate(customer.getState(), loanAmount, years); + double monthlyPayment = mortgageCalculator.getMonthlyPayment(loanAmount, years, rate); + double ratio = monthlyPayment/customer.getMonthlyIncome(); + return riskAssessment.assess(score, ratio); + } +} diff --git a/sandbox/rfeng/samples.M2/mortgage/src/main/java/mortgage/MortgageCalculator.java b/sandbox/rfeng/samples.M2/mortgage/src/main/java/mortgage/MortgageCalculator.java new file mode 100644 index 0000000000..cacd8694de --- /dev/null +++ b/sandbox/rfeng/samples.M2/mortgage/src/main/java/mortgage/MortgageCalculator.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package mortgage; + +import org.osoa.sca.annotations.Remotable; + +/** + * The Mortgage Calculator service interface. + */ +@Remotable +public interface MortgageCalculator { + public double getMonthlyPayment(double principal, int years, float interestRate); +} diff --git a/sandbox/rfeng/samples.M2/mortgage/src/main/java/mortgage/MortgageCalculatorImpl.java b/sandbox/rfeng/samples.M2/mortgage/src/main/java/mortgage/MortgageCalculatorImpl.java new file mode 100644 index 0000000000..c89830ca84 --- /dev/null +++ b/sandbox/rfeng/samples.M2/mortgage/src/main/java/mortgage/MortgageCalculatorImpl.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package mortgage; + +import org.osoa.sca.annotations.Service; + +/** + * An implementation of the Calculator service. + */ +@Service(MortgageCalculator.class) +public class MortgageCalculatorImpl implements MortgageCalculator { + + public double getMonthlyPayment(double principal, int years, float interestRate) { + double monthlyRate = interestRate / 12.0 / 100.0; + double p = Math.pow(1 + monthlyRate, years * 12); + double q = p / (p - 1); + double monthlyPayment = principal * monthlyRate * q; + return monthlyPayment; + } + +} diff --git a/sandbox/rfeng/samples.M2/mortgage/src/main/java/mortgage/MortgageClient.java b/sandbox/rfeng/samples.M2/mortgage/src/main/java/mortgage/MortgageClient.java new file mode 100644 index 0000000000..d548f638c0 --- /dev/null +++ b/sandbox/rfeng/samples.M2/mortgage/src/main/java/mortgage/MortgageClient.java @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package mortgage; + +import org.osoa.sca.CompositeContext; +import org.osoa.sca.CurrentCompositeContext; + +/** + * This client program to invoke the Mortgage LoanApproval service + */ +public class MortgageClient { + public static void main(String[] args) throws Exception { + + CompositeContext context = CurrentCompositeContext.getContext(); + LoanApproval loanApplication = context.locateService(LoanApproval.class, "LoanApprovalComponent"); + + Customer customer = new Customer(); + customer.setSsn("111-22-3333"); + customer.setFirstName("John"); + customer.setLastName("Smith"); + customer.setMonthlyIncome(5000.0d); + customer.setState("CA"); + + boolean result = loanApplication.approve(customer, 200000d, 30); + System.out.println((result ? "Approved: " : "Rejected: ") + customer); + } +} diff --git a/sandbox/rfeng/samples.M2/mortgage/src/main/java/mortgage/RiskAssessment.java b/sandbox/rfeng/samples.M2/mortgage/src/main/java/mortgage/RiskAssessment.java new file mode 100644 index 0000000000..23c9589e85 --- /dev/null +++ b/sandbox/rfeng/samples.M2/mortgage/src/main/java/mortgage/RiskAssessment.java @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package mortgage; + +/** + * Risk Assessment interface + */ +public interface RiskAssessment { + public boolean assess(int creditScore, double ratio); +} diff --git a/sandbox/rfeng/samples.M2/mortgage/src/main/java/mortgage/RiskAssessmentImpl.java b/sandbox/rfeng/samples.M2/mortgage/src/main/java/mortgage/RiskAssessmentImpl.java new file mode 100644 index 0000000000..8144ef2a7d --- /dev/null +++ b/sandbox/rfeng/samples.M2/mortgage/src/main/java/mortgage/RiskAssessmentImpl.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package mortgage; + +import org.osoa.sca.annotations.Service; + +/** + * A pojo implementation of RiskAssessment service + */ +@Service(RiskAssessment.class) +public class RiskAssessmentImpl implements RiskAssessment { + public boolean assess(int creditScore, double ratio) { + if (creditScore >= 750) + return ratio < 0.35; + else if (creditScore >= 700) + return ratio < 0.30; + else + return ratio < 0.25; + } +} diff --git a/sandbox/rfeng/samples.M2/mortgage/src/main/resources/META-INF/LICENSE.txt b/sandbox/rfeng/samples.M2/mortgage/src/main/resources/META-INF/LICENSE.txt new file mode 100644 index 0000000000..25d78feeac --- /dev/null +++ b/sandbox/rfeng/samples.M2/mortgage/src/main/resources/META-INF/LICENSE.txt @@ -0,0 +1,1277 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + +APACHE TUSCANY SUBCOMPONENTS: + +The Apache Tuscany distribution includes a number of subcomponents with +separate copyright notices and license terms. Your use of the source +code for the these subcomponents is subject to the terms and +conditions of the following licenses. + +=============================================================================== + +For the Eclipse Modeling Framework component and the Celtix binding: + +Eclipse Public License - v 1.0 + +THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE +PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF +THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. + +1. DEFINITIONS + +"Contribution" means: + +a) in the case of the initial Contributor, the initial code and +documentation distributed under this Agreement, and +b) in the case of each subsequent Contributor: + +i) changes to the Program, and + +ii) additions to the Program; + +where such changes and/or additions to the Program originate from and +are distributed by that particular Contributor. A Contribution +'originates' from a Contributor if it was added to the Program by such +Contributor itself or anyone acting on such Contributor's behalf. +Contributions do not include additions to the Program which: (i) are +separate modules of software distributed in conjunction with the +Program under their own license agreement, and (ii) are not derivative +works of the Program. + +"Contributor" means any person or entity that distributes the Program. + +"Licensed Patents " mean patent claims licensable by a Contributor +which are necessarily infringed by the use or sale of its Contribution +alone or when combined with the Program. + +"Program" means the Contributions distributed in accordance with this +Agreement. + +"Recipient" means anyone who receives the Program under this +Agreement, including all Contributors. + +2. GRANT OF RIGHTS + +a) Subject to the terms of this Agreement, each Contributor hereby +grants Recipient a non-exclusive, worldwide, royalty-free copyright +license to reproduce, prepare derivative works of, publicly display, +publicly perform, distribute and sublicense the Contribution of such +Contributor, if any, and such derivative works, in source code and +object code form. + +b) Subject to the terms of this Agreement, each Contributor hereby +grants Recipient a non-exclusive, worldwide, royalty-free patent +license under Licensed Patents to make, use, sell, offer to sell, +import and otherwise transfer the Contribution of such Contributor, if +any, in source code and object code form. This patent license shall +apply to the combination of the Contribution and the Program if, at +the time the Contribution is added by the Contributor, such addition +of the Contribution causes such combination to be covered by the +Licensed Patents. The patent license shall not apply to any other +combinations which include the Contribution. No hardware per se is +licensed hereunder. + +c) Recipient understands that although each Contributor grants the +licenses to its Contributions set forth herein, no assurances are +provided by any Contributor that the Program does not infringe the +patent or other intellectual property rights of any other entity. Each +Contributor disclaims any liability to Recipient for claims brought by +any other entity based on infringement of intellectual property rights +or otherwise. As a condition to exercising the rights and licenses +granted hereunder, each Recipient hereby assumes sole responsibility +to secure any other intellectual property rights needed, if any. For +example, if a third party patent license is required to allow +Recipient to distribute the Program, it is Recipient's responsibility +to acquire that license before distributing the Program. + +d) Each Contributor represents that to its knowledge it has sufficient +copyright rights in its Contribution, if any, to grant the copyright +license set forth in this Agreement. + +3. REQUIREMENTS + +A Contributor may choose to distribute the Program in object code form +under its own license agreement, provided that: + +a) it complies with the terms and conditions of this Agreement; and + +b) its license agreement: + +i) effectively disclaims on behalf of all Contributors all warranties +and conditions, express and implied, including warranties or +conditions of title and non-infringement, and implied warranties or +conditions of merchantability and fitness for a particular purpose; + +ii) effectively excludes on behalf of all Contributors all liability +for damages, including direct, indirect, special, incidental and +consequential damages, such as lost profits; + +iii) states that any provisions which differ from this Agreement are +offered by that Contributor alone and not by any other party; and + +iv) states that source code for the Program is available from such +Contributor, and informs licensees how to obtain it in a reasonable +manner on or through a medium customarily used for software exchange. + +When the Program is made available in source code form: + +a) it must be made available under this Agreement; and + +b) a copy of this Agreement must be included with each copy of the +Program. + +Contributors may not remove or alter any copyright notices contained +within the Program. + +Each Contributor must identify itself as the originator of its +Contribution, if any, in a manner that reasonably allows subsequent +Recipients to identify the originator of the Contribution. + +4. COMMERCIAL DISTRIBUTION + +Commercial distributors of software may accept certain +responsibilities with respect to end users, business partners and the +like. While this license is intended to facilitate the commercial use +of the Program, the Contributor who includes the Program in a +commercial product offering should do so in a manner which does not +create potential liability for other Contributors. Therefore, if a +Contributor includes the Program in a commercial product offering, +such Contributor ("Commercial Contributor") hereby agrees to defend +and indemnify every other Contributor ("Indemnified Contributor") +against any losses, damages and costs (collectively "Losses") arising +from claims, lawsuits and other legal actions brought by a third party +against the Indemnified Contributor to the extent caused by the acts +or omissions of such Commercial Contributor in connection with its +distribution of the Program in a commercial product offering. The +obligations in this section do not apply to any claims or Losses +relating to any actual or alleged intellectual property infringement. +In order to qualify, an Indemnified Contributor must: a) promptly +notify the Commercial Contributor in writing of such claim, and b) +allow the Commercial Contributor to control, and cooperate with the +Commercial Contributor in, the defense and any related settlement +negotiations. The Indemnified Contributor may participate in any such +claim at its own expense. + +For example, a Contributor might include the Program in a commercial +product offering, Product X. That Contributor is then a Commercial +Contributor. If that Commercial Contributor then makes performance +claims, or offers warranties related to Product X, those performance +claims and warranties are such Commercial Contributor's responsibility +alone. Under this section, the Commercial Contributor would have to +defend claims against the other Contributors related to those +performance claims and warranties, and if a court requires any other +Contributor to pay any damages as a result, the Commercial Contributor +must pay those damages. + +5. NO WARRANTY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS +PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY +WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY +OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely +responsible for determining the appropriateness of using and +distributing the Program and assumes all risks associated with its +exercise of rights under this Agreement , including but not limited to +the risks and costs of program errors, compliance with applicable +laws, damage to or loss of data, programs or equipment, and +unavailability or interruption of operations. + +6. DISCLAIMER OF LIABILITY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR +ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING +WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR +DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED +HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +7. GENERAL + +If any provision of this Agreement is invalid or unenforceable under +applicable law, it shall not affect the validity or enforceability of +the remainder of the terms of this Agreement, and without further +action by the parties hereto, such provision shall be reformed to the +minimum extent necessary to make such provision valid and enforceable. + +If Recipient institutes patent litigation against any entity +(including a cross-claim or counterclaim in a lawsuit) alleging that +the Program itself (excluding combinations of the Program with other +software or hardware) infringes such Recipient's patent(s), then such +Recipient's rights granted under Section 2(b) shall terminate as of +the date such litigation is filed. + +All Recipient's rights under this Agreement shall terminate if it +fails to comply with any of the material terms or conditions of this +Agreement and does not cure such failure in a reasonable period of +time after becoming aware of such noncompliance. If all Recipient's +rights under this Agreement terminate, Recipient agrees to cease use +and distribution of the Program as soon as reasonably practicable. +However, Recipient's obligations under this Agreement and any licenses +granted by Recipient relating to the Program shall continue and +survive. + +Everyone is permitted to copy and distribute copies of this Agreement, +but in order to avoid inconsistency the Agreement is copyrighted and +may only be modified in the following manner. The Agreement Steward +reserves the right to publish new versions (including revisions) of +this Agreement from time to time. No one other than the Agreement +Steward has the right to modify this Agreement. The Eclipse Foundation +is the initial Agreement Steward. The Eclipse Foundation may assign +the responsibility to serve as the Agreement Steward to a suitable +separate entity. Each new version of the Agreement will be given a +distinguishing version number. The Program (including Contributions) +may always be distributed subject to the version of the Agreement +under which it was received. In addition, after a new version of the +Agreement is published, Contributor may elect to distribute the +Program (including its Contributions) under the new version. Except as +expressly stated in Sections 2(a) and 2(b) above, Recipient receives +no rights or licenses to the intellectual property of any Contributor +under this Agreement, whether expressly, by implication, estoppel or +otherwise. All rights in the Program not expressly granted under this +Agreement are reserved. + +This Agreement is governed by the laws of the State of New York and +the intellectual property laws of the United States of America. No +party to this Agreement will bring a legal action under this Agreement +more than one year after the cause of action arose. Each party waives +its rights to a jury trial in any resulting litigation. + +=============================================================================== + +For the Rhino JavaScript container component: + +Mozilla Public License 1.1 (MPL 1.1) + +1. Definitions. + + 1.0.1. "Commercial Use" means distribution or otherwise making the +Covered Code available to a third party. + + 1.1. "Contributor" means each entity that creates or contributes to +the creation of Modifications. + + 1.2. "Contributor Version" means the combination of the Original Code, +prior Modifications used by a Contributor, and the Modifications made by that +particular Contributor. + + 1.3. "Covered Code" means the Original Code or Modifications or the +combination of the Original Code and Modifications, in each case including +portions thereof. + + 1.4. "Electronic Distribution Mechanism" means a mechanism generally +accepted in the software development community for the electronic transfer of +data. + + 1.5. "Executable" means Covered Code in any form other than Source +Code. + + 1.6. "Initial Developer" means the individual or entity identified as +the Initial Developer in the Source Code notice required by Exhibit A. + + 1.7. "Larger Work" means a work which combines Covered Code or +portions thereof with code not governed by the terms of this License. + + 1.8. "License" means this document. + + 1.8.1. "Licensable" means having the right to grant, to the maximum +extent possible, whether at the time of the initial grant or subsequently +acquired, any and all of the rights conveyed herein. + + 1.9. "Modifications" means any addition to or deletion from the +substance or structure of either the Original Code or any previous +Modifications. When Covered Code is released as a series of files, a +Modification is: + A. Any addition to or deletion from the contents of a file +containing Original Code or previous Modifications. + + B. Any new file that contains any part of the Original Code or +previous Modifications. + + 1.10. "Original Code" means Source Code of computer software code +which is described in the Source Code notice required by Exhibit A as Original +Code, and which, at the time of its release under this License is not already +Covered Code governed by this License. + + 1.10.1. "Patent Claims" means any patent claim(s), now owned or +hereafter acquired, including without limitation, method, process, and +apparatus claims, in any patent Licensable by grantor. + + 1.11. "Source Code" means the preferred form of the Covered Code for +making modifications to it, including all modules it contains, plus any +associated interface definition files, scripts used to control compilation and +installation of an Executable, or source code differential comparisons against +either the Original Code or another well known, available Covered Code of the +Contributor's choice. The Source Code can be in a compressed or archival form, +provided the appropriate decompression or de-archiving software is widely +available for no charge. + + 1.12. "You" (or "Your") means an individual or a legal entity +exercising rights under, and complying with all of the terms of, this License +or a future version of this License issued under Section 6.1. For legal +entities, "You" includes any entity which controls, is controlled by, or is +under common control with You. For purposes of this definition, "control" +means (a) the power, direct or indirect, to cause the direction or management +of such entity, whether by contract or otherwise, or (b) ownership of more +than fifty percent (50%) of the outstanding shares or beneficial ownership of +such entity. + +2. Source Code License. + + 2.1. The Initial Developer Grant. + The Initial Developer hereby grants You a world-wide, royalty-free, +non-exclusive license, subject to third party intellectual property claims: + (a) under intellectual property rights (other than patent or +trademark) Licensable by Initial Developer to use, reproduce, modify, display, +perform, sublicense and distribute the Original Code (or portions thereof) +with or without Modifications, and/or as part of a Larger Work; and + + (b) under Patents Claims infringed by the making, using or selling +of Original Code, to make, have made, use, practice, sell, and offer for sale, +and/or otherwise dispose of the Original Code (or portions thereof). + (c) the licenses granted in this Section 2.1(a) and +(b) are effective on the date Initial Developer first distributes Original +Code under the terms of this License. + + (d) Notwithstanding Section 2.1(b) above, no patent license is +granted: 1) for code that You delete from the Original Code; 2) separate from +the Original Code; or 3) for infringements caused by: i) the modification of +the Original Code or ii) the combination of the Original Code with other +software or devices. + + 2.2. Contributor Grant. + Subject to third party intellectual property claims, each Contributor +hereby grants You a world-wide, royalty-free, non-exclusive license + + (a) under intellectual property rights (other than patent or +trademark) Licensable by Contributor, to use, reproduce, modify, display, +perform, sublicense and distribute the Modifications created by such +Contributor (or portions thereof) either on an unmodified basis, with other +Modifications, as Covered Code and/or as part of a Larger Work; and + + (b) under Patent Claims infringed by the making, using, or selling +of Modifications made by that Contributor either alone and/or in combination +with its Contributor Version (or portions of such combination), to make, use, +sell, offer for sale, have made, and/or otherwise dispose of: 1) Modifications +made by that Contributor (or portions thereof); and 2) the combination of +Modifications made by that Contributor with its Contributor Version (or +portions of such combination). + + (c) the licenses granted in Sections 2.2(a) and 2.2(b) are +effective on the date Contributor first makes Commercial Use of the Covered +Code. + + (d) Notwithstanding Section 2.2(b) above, no patent license is +granted: 1) for any code that Contributor has deleted from the Contributor +Version; 2) separate from the Contributor Version; 3) for infringements +caused by: i) third party modifications of Contributor Version or ii) the +combination of Modifications made by that Contributor with other software +(except as part of the Contributor Version) or other devices; or 4) under +Patent Claims infringed by Covered Code in the absence of Modifications made +by that Contributor. + + +3. Distribution Obligations. + + 3.1. Application of License. + The Modifications which You create or to which You contribute are +governed by the terms of this License, including without limitation Section +2.2. The Source Code version of Covered Code may be distributed only under the +terms of this License or a future version of this License released under +Section 6.1, and You must include a copy of this License with every copy of +the Source Code You distribute. You may not offer or impose any terms on any +Source Code version that alters or restricts the applicable version of this +License or the recipients' rights hereunder. However, You may include an +additional document offering the additional rights described in Section 3.5. + + 3.2. Availability of Source Code. + Any Modification which You create or to which You contribute must be +made available in Source Code form under the terms of this License either on +the same media as an Executable version or via an accepted Electronic +Distribution Mechanism to anyone to whom you made an Executable version +available; and if made available via Electronic Distribution Mechanism, must +remain available for at least twelve (12) months after the date it initially +became available, or at least six (6) months after a subsequent version of +that particular Modification has been made available to such recipients. You +are responsible for ensuring that the Source Code version remains available +even if the Electronic Distribution Mechanism is maintained by a third party. + + 3.3. Description of Modifications. + You must cause all Covered Code to which You contribute to contain a +file documenting the changes You made to create that Covered Code and the date +of any change. You must include a prominent statement that the Modification is +derived, directly or indirectly, from Original Code provided by the Initial +Developer and including the name of the Initial Developer in (a) the Source +Code, and (b) in any notice in an Executable version or related documentation +in which You describe the origin or ownership of the Covered Code. + + 3.4. Intellectual Property Matters + (a) Third Party Claims. + If Contributor has knowledge that a license under a third party's +intellectual property rights is required to exercise the rights granted by +such Contributor under Sections 2.1 or 2.2, Contributor must include a text +file with the Source Code distribution titled "LEGAL" which describes the +claim and the party making the claim in sufficient detail that a recipient +will know whom to contact. If Contributor obtains such knowledge after the +Modification is made available as described in Section 3.2, Contributor shall +promptly modify the LEGAL file in all copies Contributor makes available +thereafter and shall take other steps (such as notifying appropriate mailing +lists or newsgroups) reasonably calculated to inform those who received the +Covered Code that new knowledge has been obtained. + + (b) Contributor APIs. + If Contributor's Modifications include an application programming +interface and Contributor has knowledge of patent licenses which are +reasonably necessary to implement that API, Contributor must also include this +information in the LEGAL file. + + (c) Representations. + Contributor represents that, except as disclosed pursuant to +Section 3.4(a) above, Contributor believes that Contributor's Modifications +are Contributor's original creation(s) and/or Contributor has sufficient +rights to grant the rights conveyed by this License. + + + 3.5. Required Notices. + You must duplicate the notice in Exhibit A in each file of the Source +Code. If it is not possible to put such notice in a particular Source Code +file due to its structure, then You must include such notice in a location +(such as a relevant directory) where a user would be likely to look for such a +notice. If You created one or more Modification(s) You may add your name as a +Contributor to the notice described in Exhibit A. You must also duplicate +this License in any documentation for the Source Code where You describe +recipients' rights or ownership rights relating to Covered Code. You may +choose to offer, and to charge a fee for, warranty, support, indemnity or +liability obligations to one or more recipients of Covered Code. However, You +may do so only on Your own behalf, and not on behalf of the Initial Developer +or any Contributor. You must make it absolutely clear than any such warranty, +support, indemnity or liability obligation is offered by You alone, and You +hereby agree to indemnify the Initial Developer and every Contributor for any +liability incurred by the Initial Developer or such Contributor as a result of +warranty, support, indemnity or liability terms You offer. + + 3.6. Distribution of Executable Versions. + You may distribute Covered Code in Executable form only if the +requirements of Section 3.1-3.5 have been met for that Covered Code, and if +You include a notice stating that the Source Code version of the Covered Code +is available under the terms of this License, including a description of how +and where You have fulfilled the obligations of Section 3.2. The notice must +be conspicuously included in any notice in an Executable version, related +documentation or collateral in which You describe recipients' rights relating +to the Covered Code. You may distribute the Executable version of Covered Code +or ownership rights under a license of Your choice, which may contain terms +different from this License, provided that You are in compliance with the +terms of this License and that the license for the Executable version does not +attempt to limit or alter the recipient's rights in the Source Code version +from the rights set forth in this License. If You distribute the Executable +version under a different license You must make it absolutely clear that any +terms which differ from this License are offered by You alone, not by the +Initial Developer or any Contributor. You hereby agree to indemnify the +Initial Developer and every Contributor for any liability incurred by the +Initial Developer or such Contributor as a result of any such terms You offer. + + 3.7. Larger Works. + You may create a Larger Work by combining Covered Code with other code +not governed by the terms of this License and distribute the Larger Work as a +single product. In such a case, You must make sure the requirements of this +License are fulfilled for the Covered Code. + +4. Inability to Comply Due to Statute or Regulation. + + If it is impossible for You to comply with any of the terms of this +License with respect to some or all of the Covered Code due to statute, +judicial order, or regulation then You must: (a) comply with the terms of this +License to the maximum extent possible; and (b) describe the limitations and +the code they affect. Such description must be included in the LEGAL file +described in Section 3.4 and must be included with all distributions of the +Source Code. Except to the extent prohibited by statute or regulation, such +description must be sufficiently detailed for a recipient of ordinary skill to +be able to understand it. + +5. Application of this License. + + This License applies to code to which the Initial Developer has attached +the notice in Exhibit A and to related Covered Code. + +6. Versions of the License. + + 6.1. New Versions. + Netscape Communications Corporation ("Netscape") may publish revised +and/or new versions of the License from time to time. Each version will be +given a distinguishing version number. + + 6.2. Effect of New Versions. + Once Covered Code has been published under a particular version of the +License, You may always continue to use it under the terms of that version. +You may also choose to use such Covered Code under the terms of any subsequent +version of the License published by Netscape. No one other than Netscape has +the right to modify the terms applicable to Covered Code created under this +License. + + 6.3. Derivative Works. + If You create or use a modified version of this License (which you may +only do in order to apply it to code which is not already Covered Code +governed by this License), You must (a) rename Your license so that the +phrases "Mozilla", "MOZILLAPL", "MOZPL", "Netscape", "MPL", "NPL" or +any confusingly similar phrase do not appear in your license (except to note +that your license differs from this License) and (b) otherwise make it clear +that Your version of the license contains terms which differ from the Mozilla +Public License and Netscape Public License. (Filling in the name of the +Initial Developer, Original Code or Contributor in the notice described in +Exhibit A shall not of themselves be deemed to be modifications of this +License.) + +7. DISCLAIMER OF WARRANTY. + + COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT +LIMITATION, WARRANTIES THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, +FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE +QUALITY AND PERFORMANCE OF THE COVERED CODE IS WITH YOU. SHOULD ANY COVERED +CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE INITIAL DEVELOPER OR ANY +OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY SERVICING, REPAIR OR +CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS +LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS +DISCLAIMER. + +8. TERMINATION. + + 8.1. This License and the rights granted hereunder will terminate +automatically if You fail to comply with terms herein and fail to cure such +breach within 30 days of becoming aware of the breach. All sublicenses to the +Covered Code which are properly granted shall survive any termination of this +License. Provisions which, by their nature, must remain in effect beyond the +termination of this License shall survive. + + 8.2. If You initiate litigation by asserting a patent infringement +claim (excluding declatory judgment actions) against Initial Developer or a +Contributor (the Initial Developer or Contributor against whom You file such +action is referred to as "Participant") alleging that: + + (a) such Participant's Contributor Version directly or indirectly +infringes any patent, then any and all rights granted by such Participant to +You under Sections 2.1 and/or 2.2 of this License shall, upon 60 days notice +from Participant terminate prospectively, unless if within 60 days after +receipt of notice You either: (i) agree in writing to pay Participant a +mutually agreeable reasonable royalty for Your past and future use of +Modifications made by such Participant, or (ii) withdraw Your litigation claim +with respect to the Contributor Version against such Participant. If within +60 days of notice, a reasonable royalty and payment arrangement are not +mutually agreed upon in writing by the parties or the litigation claim is not +withdrawn, the rights granted by Participant to You under Sections 2.1 and/or +2.2 automatically terminate at the expiration of the 60 day notice period +specified above. + + (b) any software, hardware, or device, other than such Participant's +Contributor Version, directly or indirectly infringes any patent, then any +rights granted to You by such Participant under Sections 2.1(b) and 2.2(b) are +revoked effective as of the date You first made, used, sold, distributed, or +had made, Modifications made by that Participant. + + 8.3. If You assert a patent infringement claim against Participant +alleging that such Participant's Contributor Version directly or indirectly +infringes any patent where such claim is resolved (such as by license or +settlement) prior to the initiation of patent infringement litigation, then +the reasonable value of the licenses granted by such Participant under +Sections 2.1 or 2.2 shall be taken into account in determining the amount or +value of any payment or license. + + 8.4. In the event of termination under Sections 8.1 or 8.2 above, all +end user license agreements (excluding distributors and resellers) which have +been validly granted by You or any distributor hereunder prior to termination +shall survive termination. + +9. LIMITATION OF LIABILITY. + + UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT +(INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL +DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED CODE, OR ANY +SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR ANY INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, +WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL, WORK STOPPAGE, COMPUTER +FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL DAMAGES OR LOSSES, +EVEN IF SUCH PARTY SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF SUCH +DAMAGES. THIS LIMITATION OF LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH +OR PERSONAL INJURY RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT +APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE +EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THIS +EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU. + +10. U.S. GOVERNMENT END USERS. + + The Covered Code is a "commercial item," as that term is defined in 48 +C.F.R. 2.101 (Oct. 1995), consisting of "commercial computer software" and +"commercial computer software documentation," as such terms are used in 48 +C.F.R. 12.212 (Sept. 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. +227.7202-1 through 227.7202-4 (June 1995), all U.S. Government End Users +acquire Covered Code with only those rights set forth herein. + +11. MISCELLANEOUS. + + This License represents the complete agreement concerning subject matter +hereof. If any provision of this License is held to be unenforceable, such +provision shall be reformed only to the extent necessary to make it +enforceable. This License shall be governed by California law provisions +(except to the extent applicable law, if any, provides otherwise), excluding +its conflict-of-law provisions. With respect to disputes in which at least one +party is a citizen of, or an entity chartered or registered to do business in +the United States of America, any litigation relating to this License shall be +subject to the jurisdiction of the Federal Courts of the Northern District of +California, with venue lying in Santa Clara County, California, with the +losing party responsible for costs, including without limitation, court costs +and reasonable attorneys' fees and expenses. The application of the United +Nations Convention on Contracts for the International Sale of Goods is +expressly excluded. Any law or regulation which provides that the language of +a contract shall be construed against the drafter shall not apply to this +License. + +12. RESPONSIBILITY FOR CLAIMS. + + As between Initial Developer and the Contributors, each party is +responsible for claims and damages arising, directly or indirectly, out of its +utilization of rights under this License and You agree to work with Initial +Developer and Contributors to distribute such responsibility on an equitable +basis. Nothing herein is intended or shall be deemed to constitute any +admission of liability. + +13. MULTIPLE-LICENSED CODE. + + Initial Developer may designate portions of the Covered Code as +Multiple-Licensed. Multiple-Licensed means that the Initial Developer permits +you to utilize portions of the Covered Code under Your choice of the MPL or +the alternative licenses, if any, specified by the Initial Developer in the +file described in Exhibit A. + + +EXHIBIT A -Mozilla Public License. + + ``The contents of this file are subject to the Mozilla Public License +Version 1.1 (the "License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + http://www.mozilla.org/MPL/ + + Software distributed under the License is distributed on an "AS IS" +basis, WITHOUT WARRANTY OF + ANY KIND, either express or implied. See the License for the specific +language governing rights and + limitations under the License. + + The Original Code is ______________________________________. + + The Initial Developer of the Original Code is ________________________. +Portions created by + ______________________ are Copyright (C) ______ +_______________________. All Rights + Reserved. + + Contributor(s): ______________________________________. + + Alternatively, the contents of this file may be used under the terms of +the _____ license (the [___] License), in which case the provisions of +[______] License are applicable instead of those above. If you wish to allow +use of your version of this file only under the terms of the [____] License +and not to allow others to use your version of this file under the MPL, +indicate your decision by deleting the provisions above and replace them +with the notice and other provisions required by the [___] License. If you do +not delete the provisions above, a recipient may use your version of this file +under either the MPL or the [___] License." + + [NOTE: The text of this Exhibit A may differ slightly from the text of +the notices in the Source Code files of the Original Code. You should use the +text of this Exhibit A rather than the text found in the Original Code Source +Code for Your Modifications.] + + +=============================================================================== + +For the JAX-WS Reference Implementation component: + +COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 + + + 1. Definitions. + + 1.1. "Contributor" means each individual or entity that + creates or contributes to the creation of Modifications. + + 1.2. "Contributor Version" means the combination of the + Original Software, prior Modifications used by a + Contributor (if any), and the Modifications made by that + particular Contributor. + + 1.3. "Covered Software" means (a) the Original Software, or + (b) Modifications, or (c) the combination of files + containing Original Software with files containing + Modifications, in each case including portions thereof. + + 1.4. "Executable" means the Covered Software in any form + other than Source Code. + + 1.5. "Initial Developer" means the individual or entity + that first makes Original Software available under this + License. + + 1.6. "Larger Work" means a work which combines Covered + Software or portions thereof with code not governed by the + terms of this License. + + 1.7. "License" means this document. + + 1.8. "Licensable" means having the right to grant, to the + maximum extent possible, whether at the time of the initial + grant or subsequently acquired, any and all of the rights + conveyed herein. + + 1.9. "Modifications" means the Source Code and Executable + form of any of the following: + + A. Any file that results from an addition to, + deletion from or modification of the contents of a + file containing Original Software or previous + Modifications; + + B. Any new file that contains any part of the + Original Software or previous Modification; or + + C. Any new file that is contributed or otherwise made + available under the terms of this License. + + 1.10. "Original Software" means the Source Code and + Executable form of computer software code that is + originally released under this License. + + 1.11. "Patent Claims" means any patent claim(s), now owned + or hereafter acquired, including without limitation, + method, process, and apparatus claims, in any patent + Licensable by grantor. + + 1.12. "Source Code" means (a) the common form of computer + software code in which modifications are made and (b) + associated documentation included in or with such code. + + 1.13. "You" (or "Your") means an individual or a legal + entity exercising rights under, and complying with all of + the terms of, this License. For legal entities, "You" + includes any entity which controls, is controlled by, or is + under common control with You. For purposes of this + definition, "control" means (a) the power, direct or + indirect, to cause the direction or management of such + entity, whether by contract or otherwise, or (b) ownership + of more than fifty percent (50%) of the outstanding shares + or beneficial ownership of such entity. + + 2. License Grants. + + 2.1. The Initial Developer Grant. + + Conditioned upon Your compliance with Section 3.1 below and + subject to third party intellectual property claims, the + Initial Developer hereby grants You a world-wide, + royalty-free, non-exclusive license: + + (a) under intellectual property rights (other than + patent or trademark) Licensable by Initial Developer, + to use, reproduce, modify, display, perform, + sublicense and distribute the Original Software (or + portions thereof), with or without Modifications, + and/or as part of a Larger Work; and + + (b) under Patent Claims infringed by the making, + using or selling of Original Software, to make, have + made, use, practice, sell, and offer for sale, and/or + otherwise dispose of the Original Software (or + portions thereof). + + (c) The licenses granted in Sections 2.1(a) and (b) + are effective on the date Initial Developer first + distributes or otherwise makes the Original Software + available to a third party under the terms of this + License. + + (d) Notwithstanding Section 2.1(b) above, no patent + license is granted: (1) for code that You delete from + the Original Software, or (2) for infringements + caused by: (i) the modification of the Original + Software, or (ii) the combination of the Original + Software with other software or devices. + + 2.2. Contributor Grant. + + Conditioned upon Your compliance with Section 3.1 below and + subject to third party intellectual property claims, each + Contributor hereby grants You a world-wide, royalty-free, + non-exclusive license: + + (a) under intellectual property rights (other than + patent or trademark) Licensable by Contributor to + use, reproduce, modify, display, perform, sublicense + and distribute the Modifications created by such + Contributor (or portions thereof), either on an + unmodified basis, with other Modifications, as + Covered Software and/or as part of a Larger Work; and + + + (b) under Patent Claims infringed by the making, + using, or selling of Modifications made by that + Contributor either alone and/or in combination with + its Contributor Version (or portions of such + combination), to make, use, sell, offer for sale, + have made, and/or otherwise dispose of: (1) + Modifications made by that Contributor (or portions + thereof); and (2) the combination of Modifications + made by that Contributor with its Contributor Version + (or portions of such combination). + + (c) The licenses granted in Sections 2.2(a) and + 2.2(b) are effective on the date Contributor first + distributes or otherwise makes the Modifications + available to a third party. + + (d) Notwithstanding Section 2.2(b) above, no patent + license is granted: (1) for any code that Contributor + has deleted from the Contributor Version; (2) for + infringements caused by: (i) third party + modifications of Contributor Version, or (ii) the + combination of Modifications made by that Contributor + with other software (except as part of the + Contributor Version) or other devices; or (3) under + Patent Claims infringed by Covered Software in the + absence of Modifications made by that Contributor. + + 3. Distribution Obligations. + + 3.1. Availability of Source Code. + + Any Covered Software that You distribute or otherwise make + available in Executable form must also be made available in + Source Code form and that Source Code form must be + distributed only under the terms of this License. You must + include a copy of this License with every copy of the + Source Code form of the Covered Software You distribute or + otherwise make available. You must inform recipients of any + such Covered Software in Executable form as to how they can + obtain such Covered Software in Source Code form in a + reasonable manner on or through a medium customarily used + for software exchange. + + 3.2. Modifications. + + The Modifications that You create or to which You + contribute are governed by the terms of this License. You + represent that You believe Your Modifications are Your + original creation(s) and/or You have sufficient rights to + grant the rights conveyed by this License. + + 3.3. Required Notices. + + You must include a notice in each of Your Modifications + that identifies You as the Contributor of the Modification. + You may not remove or alter any copyright, patent or + trademark notices contained within the Covered Software, or + any notices of licensing or any descriptive text giving + attribution to any Contributor or the Initial Developer. + + 3.4. Application of Additional Terms. + + You may not offer or impose any terms on any Covered + Software in Source Code form that alters or restricts the + applicable version of this License or the recipients' + rights hereunder. You may choose to offer, and to charge a + fee for, warranty, support, indemnity or liability + obligations to one or more recipients of Covered Software. + However, you may do so only on Your own behalf, and not on + behalf of the Initial Developer or any Contributor. You + must make it absolutely clear that any such warranty, + support, indemnity or liability obligation is offered by + You alone, and You hereby agree to indemnify the Initial + Developer and every Contributor for any liability incurred + by the Initial Developer or such Contributor as a result of + warranty, support, indemnity or liability terms You offer. + + + 3.5. Distribution of Executable Versions. + + You may distribute the Executable form of the Covered + Software under the terms of this License or under the terms + of a license of Your choice, which may contain terms + different from this License, provided that You are in + compliance with the terms of this License and that the + license for the Executable form does not attempt to limit + or alter the recipient's rights in the Source Code form + from the rights set forth in this License. If You + distribute the Covered Software in Executable form under a + different license, You must make it absolutely clear that + any terms which differ from this License are offered by You + alone, not by the Initial Developer or Contributor. You + hereby agree to indemnify the Initial Developer and every + Contributor for any liability incurred by the Initial + Developer or such Contributor as a result of any such terms + You offer. + + 3.6. Larger Works. + + You may create a Larger Work by combining Covered Software + with other code not governed by the terms of this License + and distribute the Larger Work as a single product. In such + a case, You must make sure the requirements of this License + are fulfilled for the Covered Software. + + 4. Versions of the License. + + 4.1. New Versions. + + Sun Microsystems, Inc. is the initial license steward and + may publish revised and/or new versions of this License + from time to time. Each version will be given a + distinguishing version number. Except as provided in + Section 4.3, no one other than the license steward has the + right to modify this License. + + 4.2. Effect of New Versions. + + You may always continue to use, distribute or otherwise + make the Covered Software available under the terms of the + version of the License under which You originally received + the Covered Software. If the Initial Developer includes a + notice in the Original Software prohibiting it from being + distributed or otherwise made available under any + subsequent version of the License, You must distribute and + make the Covered Software available under the terms of the + version of the License under which You originally received + the Covered Software. Otherwise, You may also choose to + use, distribute or otherwise make the Covered Software + available under the terms of any subsequent version of the + License published by the license steward. + + 4.3. Modified Versions. + + When You are an Initial Developer and You want to create a + new license for Your Original Software, You may create and + use a modified version of this License if You: (a) rename + the license and remove any references to the name of the + license steward (except to note that the license differs + from this License); and (b) otherwise make it clear that + the license contains terms which differ from this License. + + + 5. DISCLAIMER OF WARRANTY. + + COVERED SOFTWARE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" + BASIS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, + INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE COVERED + SOFTWARE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR + PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND + PERFORMANCE OF THE COVERED SOFTWARE IS WITH YOU. SHOULD ANY + COVERED SOFTWARE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE + INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF + ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF + WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF + ANY COVERED SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS + DISCLAIMER. + + 6. TERMINATION. + + 6.1. This License and the rights granted hereunder will + terminate automatically if You fail to comply with terms + herein and fail to cure such breach within 30 days of + becoming aware of the breach. Provisions which, by their + nature, must remain in effect beyond the termination of + this License shall survive. + + 6.2. If You assert a patent infringement claim (excluding + declaratory judgment actions) against Initial Developer or + a Contributor (the Initial Developer or Contributor against + whom You assert such claim is referred to as "Participant") + alleging that the Participant Software (meaning the + Contributor Version where the Participant is a Contributor + or the Original Software where the Participant is the + Initial Developer) directly or indirectly infringes any + patent, then any and all rights granted directly or + indirectly to You by such Participant, the Initial + Developer (if the Initial Developer is not the Participant) + and all Contributors under Sections 2.1 and/or 2.2 of this + License shall, upon 60 days notice from Participant + terminate prospectively and automatically at the expiration + of such 60 day notice period, unless if within such 60 day + period You withdraw Your claim with respect to the + Participant Software against such Participant either + unilaterally or pursuant to a written agreement with + Participant. + + 6.3. In the event of termination under Sections 6.1 or 6.2 + above, all end user licenses that have been validly granted + by You or any distributor hereunder prior to termination + (excluding licenses granted to You by any distributor) + shall survive termination. + + 7. LIMITATION OF LIABILITY. + + UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT + (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE + INITIAL DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF + COVERED SOFTWARE, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE + LIABLE TO ANY PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR + CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT + LIMITATION, DAMAGES FOR LOST PROFITS, LOSS OF GOODWILL, WORK + STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER + COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN + INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF + LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL + INJURY RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT + APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO + NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR + CONSEQUENTIAL DAMAGES, SO THIS EXCLUSION AND LIMITATION MAY NOT + APPLY TO YOU. + + 8. U.S. GOVERNMENT END USERS. + + The Covered Software is a "commercial item," as that term is + defined in 48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial + computer software" (as that term is defined at 48 C.F.R. + 252.227-7014(a)(1)) and "commercial computer software + documentation" as such terms are used in 48 C.F.R. 12.212 (Sept. + 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1 + through 227.7202-4 (June 1995), all U.S. Government End Users + acquire Covered Software with only those rights set forth herein. + This U.S. Government Rights clause is in lieu of, and supersedes, + any other FAR, DFAR, or other clause or provision that addresses + Government rights in computer software under this License. + + 9. MISCELLANEOUS. + + This License represents the complete agreement concerning subject + matter hereof. If any provision of this License is held to be + unenforceable, such provision shall be reformed only to the + extent necessary to make it enforceable. This License shall be + governed by the law of the jurisdiction specified in a notice + contained within the Original Software (except to the extent + applicable law, if any, provides otherwise), excluding such + jurisdiction's conflict-of-law provisions. Any litigation + relating to this License shall be subject to the jurisdiction of + the courts located in the jurisdiction and venue specified in a + notice contained within the Original Software, with the losing + party responsible for costs, including, without limitation, court + costs and reasonable attorneys' fees and expenses. The + application of the United Nations Convention on Contracts for the + International Sale of Goods is expressly excluded. Any law or + regulation which provides that the language of a contract shall + be construed against the drafter shall not apply to this License. + You agree that You alone are responsible for compliance with the + United States export administration regulations (and the export + control laws and regulation of any other countries) when You use, + distribute or otherwise make available any Covered Software. + + 10. RESPONSIBILITY FOR CLAIMS. + + As between Initial Developer and the Contributors, each party is + responsible for claims and damages arising, directly or + indirectly, out of its utilization of rights under this License + and You agree to work with Initial Developer and Contributors to + distribute such responsibility on an equitable basis. Nothing + herein is intended or shall be deemed to constitute any admission + of liability. + diff --git a/sandbox/rfeng/samples.M2/mortgage/src/main/resources/META-INF/NOTICE b/sandbox/rfeng/samples.M2/mortgage/src/main/resources/META-INF/NOTICE new file mode 100644 index 0000000000..11c564eb19 --- /dev/null +++ b/sandbox/rfeng/samples.M2/mortgage/src/main/resources/META-INF/NOTICE @@ -0,0 +1,18 @@ +========================================================================= +== NOTICE file corresponding to the section 4 d of == +== the Apache License, Version 2.0, == +== in this case for the Apache Tuscany distribution. == +========================================================================= + +This product includes software developed by the Apache Software Foundation +(http://www.apache.org/). + +This product also includes software developed by: +- the Eclipse Modeling Framework project (http://www.eclipse.org/emf/) +- the Celtix project (http://celtix.objectweb.org/) +- the Mozilla Rhino project (http://www.mozilla.org/rhino/) +- the GlassFish JAX-WS project (https://jax-ws.dev.java.net/) + +Please read the LICENSE.txt file present in the root directory of this +distribution. + diff --git a/sandbox/rfeng/samples.M2/mortgage/src/main/resources/META-INF/sca/default.scdl b/sandbox/rfeng/samples.M2/mortgage/src/main/resources/META-INF/sca/default.scdl new file mode 100644 index 0000000000..ff0c75ea9d --- /dev/null +++ b/sandbox/rfeng/samples.M2/mortgage/src/main/resources/META-INF/sca/default.scdl @@ -0,0 +1,47 @@ + + + + + + + 600 + CreditCheckComponent + InterestRateQuoteComponent + RiskAssessmentComponent + MortgageCalculatorComponent + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/rfeng/samples.M2/mortgage/src/main/resources/META-INF/sca/default1.scdl b/sandbox/rfeng/samples.M2/mortgage/src/main/resources/META-INF/sca/default1.scdl new file mode 100644 index 0000000000..bfb687be5d --- /dev/null +++ b/sandbox/rfeng/samples.M2/mortgage/src/main/resources/META-INF/sca/default1.scdl @@ -0,0 +1,50 @@ + + + + + + + 600 + CreditCheckReference + InterestRateQuoteComponent + RiskAssessmentComponent + MortgageCalculatorJSComponent + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/rfeng/samples.M2/mortgage/src/main/resources/META-INF/sca/default2.scdl b/sandbox/rfeng/samples.M2/mortgage/src/main/resources/META-INF/sca/default2.scdl new file mode 100644 index 0000000000..fc8bdeec0b --- /dev/null +++ b/sandbox/rfeng/samples.M2/mortgage/src/main/resources/META-INF/sca/default2.scdl @@ -0,0 +1,50 @@ + + + + + + + 600 + CreditCheckReference1 + InterestRateQuoteComponent + RiskAssessmentComponent + MortgageCalculatorJSComponent + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/rfeng/samples.M2/mortgage/src/main/resources/MortgageCalculator.componentType b/sandbox/rfeng/samples.M2/mortgage/src/main/resources/MortgageCalculator.componentType new file mode 100644 index 0000000000..bf7b10e0f7 --- /dev/null +++ b/sandbox/rfeng/samples.M2/mortgage/src/main/resources/MortgageCalculator.componentType @@ -0,0 +1,27 @@ + + + + + + + + + + diff --git a/sandbox/rfeng/samples.M2/mortgage/src/main/resources/MortgageCalculator.js b/sandbox/rfeng/samples.M2/mortgage/src/main/resources/MortgageCalculator.js new file mode 100644 index 0000000000..b25af1d039 --- /dev/null +++ b/sandbox/rfeng/samples.M2/mortgage/src/main/resources/MortgageCalculator.js @@ -0,0 +1,25 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +function getMonthlyPayment(principal, years, interestRate) { + var monthlyRate = interestRate / 12.0 / 100.0; + var p = Math.pow(1 + monthlyRate, years * 12); + var q = p / (p - 1); + var monthlyPayment = principal * monthlyRate * q; + return monthlyPayment; +} diff --git a/sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/credit_composite.jpg b/sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/credit_composite.jpg new file mode 100644 index 0000000000..e28ed63cfb Binary files /dev/null and b/sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/credit_composite.jpg differ diff --git a/sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/credit_composite.png b/sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/credit_composite.png new file mode 100644 index 0000000000..0bfce0078d Binary files /dev/null and b/sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/credit_composite.png differ diff --git a/sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/loan_approval.jpg b/sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/loan_approval.jpg new file mode 100644 index 0000000000..3f00557c7f Binary files /dev/null and b/sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/loan_approval.jpg differ diff --git a/sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/loan_approval.png b/sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/loan_approval.png new file mode 100644 index 0000000000..9d5f829fe5 Binary files /dev/null and b/sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/loan_approval.png differ diff --git a/sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/mortgage_assembly0.jpg b/sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/mortgage_assembly0.jpg new file mode 100644 index 0000000000..515b6ecde7 Binary files /dev/null and b/sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/mortgage_assembly0.jpg differ diff --git a/sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/mortgage_assembly0.png b/sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/mortgage_assembly0.png new file mode 100644 index 0000000000..4b815a4b82 Binary files /dev/null and b/sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/mortgage_assembly0.png differ diff --git a/sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/mortgage_assembly1.jpg b/sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/mortgage_assembly1.jpg new file mode 100644 index 0000000000..01a7c55a14 Binary files /dev/null and b/sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/mortgage_assembly1.jpg differ diff --git a/sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/mortgage_assembly1.png b/sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/mortgage_assembly1.png new file mode 100644 index 0000000000..07422c4f45 Binary files /dev/null and b/sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/mortgage_assembly1.png differ diff --git a/sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/mortgage_assembly2.jpg b/sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/mortgage_assembly2.jpg new file mode 100644 index 0000000000..992c048684 Binary files /dev/null and b/sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/mortgage_assembly2.jpg differ diff --git a/sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/mortgage_assembly2.png b/sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/mortgage_assembly2.png new file mode 100644 index 0000000000..4667956ed0 Binary files /dev/null and b/sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/mortgage_assembly2.png differ diff --git a/sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/mortgage_composite.jpg b/sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/mortgage_composite.jpg new file mode 100644 index 0000000000..5021f6a317 Binary files /dev/null and b/sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/mortgage_composite.jpg differ diff --git a/sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/mortgage_composite.png b/sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/mortgage_composite.png new file mode 100644 index 0000000000..1398c50ded Binary files /dev/null and b/sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/mortgage_composite.png differ diff --git a/sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/mortgage_diagrams.doc b/sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/mortgage_diagrams.doc new file mode 100644 index 0000000000..00d45e1084 Binary files /dev/null and b/sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/mortgage_diagrams.doc differ diff --git a/sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/mortgage_package1.jpg b/sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/mortgage_package1.jpg new file mode 100644 index 0000000000..e91c5f1bbd Binary files /dev/null and b/sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/mortgage_package1.jpg differ diff --git a/sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/mortgage_package1.png b/sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/mortgage_package1.png new file mode 100644 index 0000000000..db304a4c28 Binary files /dev/null and b/sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/mortgage_package1.png differ diff --git a/sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/mortgage_package2.jpg b/sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/mortgage_package2.jpg new file mode 100644 index 0000000000..e8c2865e4a Binary files /dev/null and b/sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/mortgage_package2.jpg differ diff --git a/sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/mortgage_package2.png b/sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/mortgage_package2.png new file mode 100644 index 0000000000..502e538e94 Binary files /dev/null and b/sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/mortgage_package2.png differ diff --git a/sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/mortgage_scenario.jpg b/sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/mortgage_scenario.jpg new file mode 100644 index 0000000000..30a903089c Binary files /dev/null and b/sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/mortgage_scenario.jpg differ diff --git a/sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/mortgage_scenario.png b/sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/mortgage_scenario.png new file mode 100644 index 0000000000..b8f42ad318 Binary files /dev/null and b/sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/mortgage_scenario.png differ diff --git a/sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/readme.html b/sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/readme.html new file mode 100644 index 0000000000..bee954a198 --- /dev/null +++ b/sandbox/rfeng/samples.M2/mortgage/src/main/resources/doc/readme.html @@ -0,0 +1,136 @@ + + + + + + + + +Mortgage Sample + + + +

Mortgage Sample

+ +

Overview

+ +

The Tuscany Web services client Helloworld sample shows how to +call a remote Web service by wiring an SCA component to a reference +which uses a Web service binding.

+ +

Prerequisites

+ +

Obtain the following prerequisites and install according to their +documentation.

+ + + +

The business scenario

+The "loan approval" application accepts a mortgage request including the +customer's details and the requested loan amount. It first checks the +credit of the customer to make sure the credit score meets the minimum +requirement. The interest rate is determined based on the principal +requested, the term for the loan and the customers home state. It then +uses a mortgage calculator to calculate the ratio by dividing potential +monthly payment by the customer's income. The ratio and credit score are +passed to perform the risk assessment which makes the final decision. +

+

Packaging structure

+ + +

Building

+ +

To build the sample  issue :

+
+mvn
+
+ +

The result after executing is in the target subdirectory the sample-mortgage.jar

+ +

Setup

+ +

Set up the Tuscany standalone runtime environment using the +following command:

+
+mvn dependency:unpack 
+
+ +

After completion there should be a target\distribution subdirectory +created that has the Tuscany standalone runtime.

+ +

The Tuscany Web servivces binding requires the Axis2 and SDO +databinding extensions so copy these to the standalone launcher +extensions directory:

+
+copy target\distribution\contrib\axis2-1.0-incubator-M2.jar target\distribution\extensions
+copy target\distribution\contrib\databinding-sdo-1.0-incubator-M2.jar target\distribution\extensions
+
+ +

Running

+ +

Execute the following command: (cut +and paste to command line)

+
+java -jar target/distribution/bin/launcher.jar target/sample-mortgage.jar
+
+ +

Results

+ +

The sample when run should simply display to the standard output:
+
+Approved: John Smith[111-22-3333]

+ +We have two versions of the CreditCheck web service implementation in this sample application: +
    +
  • a web service developed with Apache axis2 1.1 release. It's packaged as an Axis2 aar. +
  • a SCA component exposed as a web service. It's packaged as a WAR. +
+ +

Deploy the Axis2 CreditCheck web service to Tomcat

+
    +
  1. Download the WAR (Web Archive) ditribution from Apache + Axis2 1.1 release download site. +
  2. Copy axis2.war to <tomcat_home>\webapps. +
  3. Start Tomcat so that axis2.war get deployed to + <tomcat_home>\webapps\axis2. +
  4. Copy creditws-axis2\build\lib\CreditCheckService.aar to + <tomcat_home>\webapps\axis2\WEB-INF\services. +
+ +

Deploy the CreditComposite to Tomcat

+
    +
  1. Copy credit.war to <tomcat_home>\webapps. +
  2. Start Tomcat so that credit.war get deployed to + <tomcat_home>\webapps\credit. The CreditCheck web serivice will + be up and running. +
+ + + diff --git a/sandbox/rfeng/samples.M2/mortgage/src/main/resources/wsdl/credit.wsdl b/sandbox/rfeng/samples.M2/mortgage/src/main/resources/wsdl/credit.wsdl new file mode 100644 index 0000000000..4779f9ab4d --- /dev/null +++ b/sandbox/rfeng/samples.M2/mortgage/src/main/resources/wsdl/credit.wsdl @@ -0,0 +1,84 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/rfeng/samples.M2/mortgage/src/test/java/mortgage/MortgageClientTestCase.java b/sandbox/rfeng/samples.M2/mortgage/src/test/java/mortgage/MortgageClientTestCase.java new file mode 100644 index 0000000000..b45885b544 --- /dev/null +++ b/sandbox/rfeng/samples.M2/mortgage/src/test/java/mortgage/MortgageClientTestCase.java @@ -0,0 +1,61 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package mortgage; + +import mortgage.Customer; +import mortgage.LoanApproval; + +import org.apache.tuscany.test.SCATestCase; +import org.osoa.sca.CompositeContext; +import org.osoa.sca.CurrentCompositeContext; + +/** + * This shows how to test the Calculator service component. + */ +public class MortgageClientTestCase extends SCATestCase { + + private LoanApproval loanApproval; + + protected void setUp() throws Exception { + // version 1: One composite with local components + setApplicationSCDL(LoanApproval.class, "META-INF/sca/default.scdl"); + // version 2: two composites, one for mortgage and the other for credit + // setApplicationSCDL(LoanApproval.class, "META-INF/sca/default1.scdl"); + // version 3: one composite and an external web service for credit + // setApplicationSCDL(LoanApproval.class, "META-INF/sca/default2.scdl"); + ClassLoader classLoader = getClass().getClassLoader(); + addExtension("binding.axis2", classLoader.getResource("META-INF/sca/binding.axis2.scdl")); + addExtension("container.js", classLoader.getResource("META-INF/sca/js.system.scdl")); + super.setUp(); + CompositeContext context = CurrentCompositeContext.getContext(); + loanApproval = context.locateService(LoanApproval.class, "LoanApprovalComponent"); + } + + public void testApprove() throws Exception { + Customer customer = new Customer(); + customer.setSsn("111-22-3333"); + customer.setFirstName("John"); + customer.setLastName("Smith"); + customer.setMonthlyIncome(5000.0d); + customer.setState("CA"); + + boolean approved = loanApproval.approve(customer, 200000d, 30); + System.out.println(approved ? "Approved" : "Rejected"); + } +} diff --git a/sandbox/rfeng/samples/calculatorws/.ruleset b/sandbox/rfeng/samples/calculatorws/.ruleset new file mode 100644 index 0000000000..2a06794776 --- /dev/null +++ b/sandbox/rfeng/samples/calculatorws/.ruleset @@ -0,0 +1,172 @@ + + + PMD Plugin preferences rule set + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/rfeng/samples/calculatorws/pom.xml b/sandbox/rfeng/samples/calculatorws/pom.xml new file mode 100644 index 0000000000..067698e01a --- /dev/null +++ b/sandbox/rfeng/samples/calculatorws/pom.xml @@ -0,0 +1,130 @@ + + + + + org.apache.tuscany.samples.sca + parent + 1.0-incubator-M2-SNAPSHOT + + 4.0.0 + sample-helloworldws + war + Tuscany HelloWorld Web Service Sample + A sample HelloWorld Web Service. + + + axis2 + + + + + org.osoa + sca-api-r0.95 + 1.0-incubator-M2-SNAPSHOT + compile + + + org.apache.tuscany.sca.kernel + tuscany-api + ${pom.version} + compile + + + + commonj + sdo-api-r2.0.1 + 1.0-incubator-M2-SNAPSHOT + compile + + + org.apache.tuscany.sca.kernel + core + ${pom.version} + runtime + + + javax.servlet + servlet-api + 2.4 + provided + + + org.apache.tuscany.sca.services.bindings + axis2 + ${pom.version} + runtime + + + org.apache.tuscany.sca.services.databinding + databinding-axiom + ${pom.version} + runtime + + + org.apache.tuscany.sca.runtime + webapp + ${pom.version} + runtime + + + org.apache.tuscany.sca.runtime + webapp-host + ${pom.version} + runtime + + + org.apache.ws.commons.axiom + axiom-api + 1.1 + compile + + + org.apache.ws.commons.axiom + axiom-impl + 1.1 + runtime + + + junit + junit + 3.8.1 + test + + + + + + calculator + + + org.apache.tuscany.sca.plugins + tuscany-war-plugin + + + tuscany-war + + tuscany-war + + + + + + + diff --git a/sandbox/rfeng/samples/calculatorws/src/main/java/calculator/AddService.java b/sandbox/rfeng/samples/calculatorws/src/main/java/calculator/AddService.java new file mode 100644 index 0000000000..4eeb30a9c2 --- /dev/null +++ b/sandbox/rfeng/samples/calculatorws/src/main/java/calculator/AddService.java @@ -0,0 +1,25 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +public interface AddService { + + double add(double n1, double n2); + +} diff --git a/sandbox/rfeng/samples/calculatorws/src/main/java/calculator/AddServiceImpl.java b/sandbox/rfeng/samples/calculatorws/src/main/java/calculator/AddServiceImpl.java new file mode 100644 index 0000000000..da6a530052 --- /dev/null +++ b/sandbox/rfeng/samples/calculatorws/src/main/java/calculator/AddServiceImpl.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import org.osoa.sca.annotations.Scope; + +/** + * An implementation of the Add service + */ +@Scope("MODULE") +public class AddServiceImpl implements AddService { + + public double add(double n1, double n2) { + return n1 + n2; + } + +} diff --git a/sandbox/rfeng/samples/calculatorws/src/main/java/calculator/CalculatorClient.java b/sandbox/rfeng/samples/calculatorws/src/main/java/calculator/CalculatorClient.java new file mode 100644 index 0000000000..cb4edeac7e --- /dev/null +++ b/sandbox/rfeng/samples/calculatorws/src/main/java/calculator/CalculatorClient.java @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import org.osoa.sca.CompositeContext; +import org.osoa.sca.CurrentCompositeContext; + +/** + * This client program shows how to create an SCA runtime, start it, + * locate the Calculator service and invoke it. + */ +public class CalculatorClient { + public static void main(String[] args) throws Exception { + + CompositeContext context = CurrentCompositeContext.getContext(); + CalculatorService calculatorService = + context.locateService(CalculatorService.class, "CalculatorServiceComponent"); + + // Calculate + System.out.println("3 + 2=" + calculatorService.add(3, 2)); + System.out.println("3 - 2=" + calculatorService.subtract(3, 2)); + System.out.println("3 * 2=" + calculatorService.multiply(3, 2)); + System.out.println("3 / 2=" + calculatorService.divide(3, 2)); + + } +} diff --git a/sandbox/rfeng/samples/calculatorws/src/main/java/calculator/CalculatorService.java b/sandbox/rfeng/samples/calculatorws/src/main/java/calculator/CalculatorService.java new file mode 100644 index 0000000000..5fbd3a3f6b --- /dev/null +++ b/sandbox/rfeng/samples/calculatorws/src/main/java/calculator/CalculatorService.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import org.osoa.sca.annotations.Remotable; + + +/** + * The Calculator service interface. + */ +@Remotable +public interface CalculatorService { + + double add(double n1, double n2); + + double subtract(double n1, double n2); + + double multiply(double n1, double n2); + + double divide(double n1, double n2); + +} diff --git a/sandbox/rfeng/samples/calculatorws/src/main/java/calculator/CalculatorServiceImpl.java b/sandbox/rfeng/samples/calculatorws/src/main/java/calculator/CalculatorServiceImpl.java new file mode 100644 index 0000000000..efb49ead63 --- /dev/null +++ b/sandbox/rfeng/samples/calculatorws/src/main/java/calculator/CalculatorServiceImpl.java @@ -0,0 +1,72 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Scope; + + +/** + * An implementation of the Calculator service. + */ +@Scope("MODULE") +public class CalculatorServiceImpl implements CalculatorService { + + private AddService addService; + private SubtractService subtractService; + private MultiplyService multiplyService; + private DivideService divideService; + + @Reference + public void setAddService(AddService addService) { + this.addService = addService; + } + + @Reference + public void setSubtractService(SubtractService subtractService) { + this.subtractService = subtractService; + } + + @Reference + public void setDivideService(DivideService divideService) { + this.divideService = divideService; + } + + @Reference + public void setMultiplyService(MultiplyService multiplyService) { + this.multiplyService = multiplyService; + } + + public double add(double n1, double n2) { + return addService.add(n1, n2); + } + + public double subtract(double n1, double n2) { + return subtractService.subtract(n1, n2); + } + + public double multiply(double n1, double n2) { + return multiplyService.multiply(n1, n2); + } + + public double divide(double n1, double n2) { + return divideService.divide(n1, n2); + } + +} diff --git a/sandbox/rfeng/samples/calculatorws/src/main/java/calculator/DivideService.java b/sandbox/rfeng/samples/calculatorws/src/main/java/calculator/DivideService.java new file mode 100644 index 0000000000..131c5a8014 --- /dev/null +++ b/sandbox/rfeng/samples/calculatorws/src/main/java/calculator/DivideService.java @@ -0,0 +1,25 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +public interface DivideService { + + double divide(double n1, double n2); + +} diff --git a/sandbox/rfeng/samples/calculatorws/src/main/java/calculator/DivideServiceImpl.java b/sandbox/rfeng/samples/calculatorws/src/main/java/calculator/DivideServiceImpl.java new file mode 100644 index 0000000000..535298d31d --- /dev/null +++ b/sandbox/rfeng/samples/calculatorws/src/main/java/calculator/DivideServiceImpl.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import org.osoa.sca.annotations.Scope; + +/** + * An implementation of the Divide service. + */ +@Scope("MODULE") +public class DivideServiceImpl implements DivideService { + + public double divide(double n1, double n2) { + return n1 / n2; + } + +} diff --git a/sandbox/rfeng/samples/calculatorws/src/main/java/calculator/MultiplyService.java b/sandbox/rfeng/samples/calculatorws/src/main/java/calculator/MultiplyService.java new file mode 100644 index 0000000000..a917896aeb --- /dev/null +++ b/sandbox/rfeng/samples/calculatorws/src/main/java/calculator/MultiplyService.java @@ -0,0 +1,25 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +public interface MultiplyService { + + double multiply(double n1, double n2); + +} diff --git a/sandbox/rfeng/samples/calculatorws/src/main/java/calculator/MultiplyServiceImpl.java b/sandbox/rfeng/samples/calculatorws/src/main/java/calculator/MultiplyServiceImpl.java new file mode 100644 index 0000000000..e1d491beee --- /dev/null +++ b/sandbox/rfeng/samples/calculatorws/src/main/java/calculator/MultiplyServiceImpl.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import org.osoa.sca.annotations.Scope; + +/** + * An implementation of the Multiply service. + */ +@Scope("MODULE") +public class MultiplyServiceImpl implements MultiplyService { + + public double multiply(double n1, double n2) { + return n1 * n2; + } + +} diff --git a/sandbox/rfeng/samples/calculatorws/src/main/java/calculator/SubtractService.java b/sandbox/rfeng/samples/calculatorws/src/main/java/calculator/SubtractService.java new file mode 100644 index 0000000000..e328f024ea --- /dev/null +++ b/sandbox/rfeng/samples/calculatorws/src/main/java/calculator/SubtractService.java @@ -0,0 +1,25 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +public interface SubtractService { + + double subtract(double n1, double n2); + +} diff --git a/sandbox/rfeng/samples/calculatorws/src/main/java/calculator/SubtractServiceImpl.java b/sandbox/rfeng/samples/calculatorws/src/main/java/calculator/SubtractServiceImpl.java new file mode 100644 index 0000000000..053f323627 --- /dev/null +++ b/sandbox/rfeng/samples/calculatorws/src/main/java/calculator/SubtractServiceImpl.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import org.osoa.sca.annotations.Scope; + +/** + * An implementation of the subtract service. + */ +@Scope("MODULE") +public class SubtractServiceImpl implements SubtractService { + + public double subtract(double n1, double n2) { + return n1 - n2; + } + +} diff --git a/sandbox/rfeng/samples/calculatorws/src/main/resources/META-INF/LICENSE.txt b/sandbox/rfeng/samples/calculatorws/src/main/resources/META-INF/LICENSE.txt new file mode 100644 index 0000000000..25d78feeac --- /dev/null +++ b/sandbox/rfeng/samples/calculatorws/src/main/resources/META-INF/LICENSE.txt @@ -0,0 +1,1277 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + +APACHE TUSCANY SUBCOMPONENTS: + +The Apache Tuscany distribution includes a number of subcomponents with +separate copyright notices and license terms. Your use of the source +code for the these subcomponents is subject to the terms and +conditions of the following licenses. + +=============================================================================== + +For the Eclipse Modeling Framework component and the Celtix binding: + +Eclipse Public License - v 1.0 + +THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE +PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF +THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. + +1. DEFINITIONS + +"Contribution" means: + +a) in the case of the initial Contributor, the initial code and +documentation distributed under this Agreement, and +b) in the case of each subsequent Contributor: + +i) changes to the Program, and + +ii) additions to the Program; + +where such changes and/or additions to the Program originate from and +are distributed by that particular Contributor. A Contribution +'originates' from a Contributor if it was added to the Program by such +Contributor itself or anyone acting on such Contributor's behalf. +Contributions do not include additions to the Program which: (i) are +separate modules of software distributed in conjunction with the +Program under their own license agreement, and (ii) are not derivative +works of the Program. + +"Contributor" means any person or entity that distributes the Program. + +"Licensed Patents " mean patent claims licensable by a Contributor +which are necessarily infringed by the use or sale of its Contribution +alone or when combined with the Program. + +"Program" means the Contributions distributed in accordance with this +Agreement. + +"Recipient" means anyone who receives the Program under this +Agreement, including all Contributors. + +2. GRANT OF RIGHTS + +a) Subject to the terms of this Agreement, each Contributor hereby +grants Recipient a non-exclusive, worldwide, royalty-free copyright +license to reproduce, prepare derivative works of, publicly display, +publicly perform, distribute and sublicense the Contribution of such +Contributor, if any, and such derivative works, in source code and +object code form. + +b) Subject to the terms of this Agreement, each Contributor hereby +grants Recipient a non-exclusive, worldwide, royalty-free patent +license under Licensed Patents to make, use, sell, offer to sell, +import and otherwise transfer the Contribution of such Contributor, if +any, in source code and object code form. This patent license shall +apply to the combination of the Contribution and the Program if, at +the time the Contribution is added by the Contributor, such addition +of the Contribution causes such combination to be covered by the +Licensed Patents. The patent license shall not apply to any other +combinations which include the Contribution. No hardware per se is +licensed hereunder. + +c) Recipient understands that although each Contributor grants the +licenses to its Contributions set forth herein, no assurances are +provided by any Contributor that the Program does not infringe the +patent or other intellectual property rights of any other entity. Each +Contributor disclaims any liability to Recipient for claims brought by +any other entity based on infringement of intellectual property rights +or otherwise. As a condition to exercising the rights and licenses +granted hereunder, each Recipient hereby assumes sole responsibility +to secure any other intellectual property rights needed, if any. For +example, if a third party patent license is required to allow +Recipient to distribute the Program, it is Recipient's responsibility +to acquire that license before distributing the Program. + +d) Each Contributor represents that to its knowledge it has sufficient +copyright rights in its Contribution, if any, to grant the copyright +license set forth in this Agreement. + +3. REQUIREMENTS + +A Contributor may choose to distribute the Program in object code form +under its own license agreement, provided that: + +a) it complies with the terms and conditions of this Agreement; and + +b) its license agreement: + +i) effectively disclaims on behalf of all Contributors all warranties +and conditions, express and implied, including warranties or +conditions of title and non-infringement, and implied warranties or +conditions of merchantability and fitness for a particular purpose; + +ii) effectively excludes on behalf of all Contributors all liability +for damages, including direct, indirect, special, incidental and +consequential damages, such as lost profits; + +iii) states that any provisions which differ from this Agreement are +offered by that Contributor alone and not by any other party; and + +iv) states that source code for the Program is available from such +Contributor, and informs licensees how to obtain it in a reasonable +manner on or through a medium customarily used for software exchange. + +When the Program is made available in source code form: + +a) it must be made available under this Agreement; and + +b) a copy of this Agreement must be included with each copy of the +Program. + +Contributors may not remove or alter any copyright notices contained +within the Program. + +Each Contributor must identify itself as the originator of its +Contribution, if any, in a manner that reasonably allows subsequent +Recipients to identify the originator of the Contribution. + +4. COMMERCIAL DISTRIBUTION + +Commercial distributors of software may accept certain +responsibilities with respect to end users, business partners and the +like. While this license is intended to facilitate the commercial use +of the Program, the Contributor who includes the Program in a +commercial product offering should do so in a manner which does not +create potential liability for other Contributors. Therefore, if a +Contributor includes the Program in a commercial product offering, +such Contributor ("Commercial Contributor") hereby agrees to defend +and indemnify every other Contributor ("Indemnified Contributor") +against any losses, damages and costs (collectively "Losses") arising +from claims, lawsuits and other legal actions brought by a third party +against the Indemnified Contributor to the extent caused by the acts +or omissions of such Commercial Contributor in connection with its +distribution of the Program in a commercial product offering. The +obligations in this section do not apply to any claims or Losses +relating to any actual or alleged intellectual property infringement. +In order to qualify, an Indemnified Contributor must: a) promptly +notify the Commercial Contributor in writing of such claim, and b) +allow the Commercial Contributor to control, and cooperate with the +Commercial Contributor in, the defense and any related settlement +negotiations. The Indemnified Contributor may participate in any such +claim at its own expense. + +For example, a Contributor might include the Program in a commercial +product offering, Product X. That Contributor is then a Commercial +Contributor. If that Commercial Contributor then makes performance +claims, or offers warranties related to Product X, those performance +claims and warranties are such Commercial Contributor's responsibility +alone. Under this section, the Commercial Contributor would have to +defend claims against the other Contributors related to those +performance claims and warranties, and if a court requires any other +Contributor to pay any damages as a result, the Commercial Contributor +must pay those damages. + +5. NO WARRANTY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS +PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY +WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY +OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely +responsible for determining the appropriateness of using and +distributing the Program and assumes all risks associated with its +exercise of rights under this Agreement , including but not limited to +the risks and costs of program errors, compliance with applicable +laws, damage to or loss of data, programs or equipment, and +unavailability or interruption of operations. + +6. DISCLAIMER OF LIABILITY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR +ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING +WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR +DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED +HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +7. GENERAL + +If any provision of this Agreement is invalid or unenforceable under +applicable law, it shall not affect the validity or enforceability of +the remainder of the terms of this Agreement, and without further +action by the parties hereto, such provision shall be reformed to the +minimum extent necessary to make such provision valid and enforceable. + +If Recipient institutes patent litigation against any entity +(including a cross-claim or counterclaim in a lawsuit) alleging that +the Program itself (excluding combinations of the Program with other +software or hardware) infringes such Recipient's patent(s), then such +Recipient's rights granted under Section 2(b) shall terminate as of +the date such litigation is filed. + +All Recipient's rights under this Agreement shall terminate if it +fails to comply with any of the material terms or conditions of this +Agreement and does not cure such failure in a reasonable period of +time after becoming aware of such noncompliance. If all Recipient's +rights under this Agreement terminate, Recipient agrees to cease use +and distribution of the Program as soon as reasonably practicable. +However, Recipient's obligations under this Agreement and any licenses +granted by Recipient relating to the Program shall continue and +survive. + +Everyone is permitted to copy and distribute copies of this Agreement, +but in order to avoid inconsistency the Agreement is copyrighted and +may only be modified in the following manner. The Agreement Steward +reserves the right to publish new versions (including revisions) of +this Agreement from time to time. No one other than the Agreement +Steward has the right to modify this Agreement. The Eclipse Foundation +is the initial Agreement Steward. The Eclipse Foundation may assign +the responsibility to serve as the Agreement Steward to a suitable +separate entity. Each new version of the Agreement will be given a +distinguishing version number. The Program (including Contributions) +may always be distributed subject to the version of the Agreement +under which it was received. In addition, after a new version of the +Agreement is published, Contributor may elect to distribute the +Program (including its Contributions) under the new version. Except as +expressly stated in Sections 2(a) and 2(b) above, Recipient receives +no rights or licenses to the intellectual property of any Contributor +under this Agreement, whether expressly, by implication, estoppel or +otherwise. All rights in the Program not expressly granted under this +Agreement are reserved. + +This Agreement is governed by the laws of the State of New York and +the intellectual property laws of the United States of America. No +party to this Agreement will bring a legal action under this Agreement +more than one year after the cause of action arose. Each party waives +its rights to a jury trial in any resulting litigation. + +=============================================================================== + +For the Rhino JavaScript container component: + +Mozilla Public License 1.1 (MPL 1.1) + +1. Definitions. + + 1.0.1. "Commercial Use" means distribution or otherwise making the +Covered Code available to a third party. + + 1.1. "Contributor" means each entity that creates or contributes to +the creation of Modifications. + + 1.2. "Contributor Version" means the combination of the Original Code, +prior Modifications used by a Contributor, and the Modifications made by that +particular Contributor. + + 1.3. "Covered Code" means the Original Code or Modifications or the +combination of the Original Code and Modifications, in each case including +portions thereof. + + 1.4. "Electronic Distribution Mechanism" means a mechanism generally +accepted in the software development community for the electronic transfer of +data. + + 1.5. "Executable" means Covered Code in any form other than Source +Code. + + 1.6. "Initial Developer" means the individual or entity identified as +the Initial Developer in the Source Code notice required by Exhibit A. + + 1.7. "Larger Work" means a work which combines Covered Code or +portions thereof with code not governed by the terms of this License. + + 1.8. "License" means this document. + + 1.8.1. "Licensable" means having the right to grant, to the maximum +extent possible, whether at the time of the initial grant or subsequently +acquired, any and all of the rights conveyed herein. + + 1.9. "Modifications" means any addition to or deletion from the +substance or structure of either the Original Code or any previous +Modifications. When Covered Code is released as a series of files, a +Modification is: + A. Any addition to or deletion from the contents of a file +containing Original Code or previous Modifications. + + B. Any new file that contains any part of the Original Code or +previous Modifications. + + 1.10. "Original Code" means Source Code of computer software code +which is described in the Source Code notice required by Exhibit A as Original +Code, and which, at the time of its release under this License is not already +Covered Code governed by this License. + + 1.10.1. "Patent Claims" means any patent claim(s), now owned or +hereafter acquired, including without limitation, method, process, and +apparatus claims, in any patent Licensable by grantor. + + 1.11. "Source Code" means the preferred form of the Covered Code for +making modifications to it, including all modules it contains, plus any +associated interface definition files, scripts used to control compilation and +installation of an Executable, or source code differential comparisons against +either the Original Code or another well known, available Covered Code of the +Contributor's choice. The Source Code can be in a compressed or archival form, +provided the appropriate decompression or de-archiving software is widely +available for no charge. + + 1.12. "You" (or "Your") means an individual or a legal entity +exercising rights under, and complying with all of the terms of, this License +or a future version of this License issued under Section 6.1. For legal +entities, "You" includes any entity which controls, is controlled by, or is +under common control with You. For purposes of this definition, "control" +means (a) the power, direct or indirect, to cause the direction or management +of such entity, whether by contract or otherwise, or (b) ownership of more +than fifty percent (50%) of the outstanding shares or beneficial ownership of +such entity. + +2. Source Code License. + + 2.1. The Initial Developer Grant. + The Initial Developer hereby grants You a world-wide, royalty-free, +non-exclusive license, subject to third party intellectual property claims: + (a) under intellectual property rights (other than patent or +trademark) Licensable by Initial Developer to use, reproduce, modify, display, +perform, sublicense and distribute the Original Code (or portions thereof) +with or without Modifications, and/or as part of a Larger Work; and + + (b) under Patents Claims infringed by the making, using or selling +of Original Code, to make, have made, use, practice, sell, and offer for sale, +and/or otherwise dispose of the Original Code (or portions thereof). + (c) the licenses granted in this Section 2.1(a) and +(b) are effective on the date Initial Developer first distributes Original +Code under the terms of this License. + + (d) Notwithstanding Section 2.1(b) above, no patent license is +granted: 1) for code that You delete from the Original Code; 2) separate from +the Original Code; or 3) for infringements caused by: i) the modification of +the Original Code or ii) the combination of the Original Code with other +software or devices. + + 2.2. Contributor Grant. + Subject to third party intellectual property claims, each Contributor +hereby grants You a world-wide, royalty-free, non-exclusive license + + (a) under intellectual property rights (other than patent or +trademark) Licensable by Contributor, to use, reproduce, modify, display, +perform, sublicense and distribute the Modifications created by such +Contributor (or portions thereof) either on an unmodified basis, with other +Modifications, as Covered Code and/or as part of a Larger Work; and + + (b) under Patent Claims infringed by the making, using, or selling +of Modifications made by that Contributor either alone and/or in combination +with its Contributor Version (or portions of such combination), to make, use, +sell, offer for sale, have made, and/or otherwise dispose of: 1) Modifications +made by that Contributor (or portions thereof); and 2) the combination of +Modifications made by that Contributor with its Contributor Version (or +portions of such combination). + + (c) the licenses granted in Sections 2.2(a) and 2.2(b) are +effective on the date Contributor first makes Commercial Use of the Covered +Code. + + (d) Notwithstanding Section 2.2(b) above, no patent license is +granted: 1) for any code that Contributor has deleted from the Contributor +Version; 2) separate from the Contributor Version; 3) for infringements +caused by: i) third party modifications of Contributor Version or ii) the +combination of Modifications made by that Contributor with other software +(except as part of the Contributor Version) or other devices; or 4) under +Patent Claims infringed by Covered Code in the absence of Modifications made +by that Contributor. + + +3. Distribution Obligations. + + 3.1. Application of License. + The Modifications which You create or to which You contribute are +governed by the terms of this License, including without limitation Section +2.2. The Source Code version of Covered Code may be distributed only under the +terms of this License or a future version of this License released under +Section 6.1, and You must include a copy of this License with every copy of +the Source Code You distribute. You may not offer or impose any terms on any +Source Code version that alters or restricts the applicable version of this +License or the recipients' rights hereunder. However, You may include an +additional document offering the additional rights described in Section 3.5. + + 3.2. Availability of Source Code. + Any Modification which You create or to which You contribute must be +made available in Source Code form under the terms of this License either on +the same media as an Executable version or via an accepted Electronic +Distribution Mechanism to anyone to whom you made an Executable version +available; and if made available via Electronic Distribution Mechanism, must +remain available for at least twelve (12) months after the date it initially +became available, or at least six (6) months after a subsequent version of +that particular Modification has been made available to such recipients. You +are responsible for ensuring that the Source Code version remains available +even if the Electronic Distribution Mechanism is maintained by a third party. + + 3.3. Description of Modifications. + You must cause all Covered Code to which You contribute to contain a +file documenting the changes You made to create that Covered Code and the date +of any change. You must include a prominent statement that the Modification is +derived, directly or indirectly, from Original Code provided by the Initial +Developer and including the name of the Initial Developer in (a) the Source +Code, and (b) in any notice in an Executable version or related documentation +in which You describe the origin or ownership of the Covered Code. + + 3.4. Intellectual Property Matters + (a) Third Party Claims. + If Contributor has knowledge that a license under a third party's +intellectual property rights is required to exercise the rights granted by +such Contributor under Sections 2.1 or 2.2, Contributor must include a text +file with the Source Code distribution titled "LEGAL" which describes the +claim and the party making the claim in sufficient detail that a recipient +will know whom to contact. If Contributor obtains such knowledge after the +Modification is made available as described in Section 3.2, Contributor shall +promptly modify the LEGAL file in all copies Contributor makes available +thereafter and shall take other steps (such as notifying appropriate mailing +lists or newsgroups) reasonably calculated to inform those who received the +Covered Code that new knowledge has been obtained. + + (b) Contributor APIs. + If Contributor's Modifications include an application programming +interface and Contributor has knowledge of patent licenses which are +reasonably necessary to implement that API, Contributor must also include this +information in the LEGAL file. + + (c) Representations. + Contributor represents that, except as disclosed pursuant to +Section 3.4(a) above, Contributor believes that Contributor's Modifications +are Contributor's original creation(s) and/or Contributor has sufficient +rights to grant the rights conveyed by this License. + + + 3.5. Required Notices. + You must duplicate the notice in Exhibit A in each file of the Source +Code. If it is not possible to put such notice in a particular Source Code +file due to its structure, then You must include such notice in a location +(such as a relevant directory) where a user would be likely to look for such a +notice. If You created one or more Modification(s) You may add your name as a +Contributor to the notice described in Exhibit A. You must also duplicate +this License in any documentation for the Source Code where You describe +recipients' rights or ownership rights relating to Covered Code. You may +choose to offer, and to charge a fee for, warranty, support, indemnity or +liability obligations to one or more recipients of Covered Code. However, You +may do so only on Your own behalf, and not on behalf of the Initial Developer +or any Contributor. You must make it absolutely clear than any such warranty, +support, indemnity or liability obligation is offered by You alone, and You +hereby agree to indemnify the Initial Developer and every Contributor for any +liability incurred by the Initial Developer or such Contributor as a result of +warranty, support, indemnity or liability terms You offer. + + 3.6. Distribution of Executable Versions. + You may distribute Covered Code in Executable form only if the +requirements of Section 3.1-3.5 have been met for that Covered Code, and if +You include a notice stating that the Source Code version of the Covered Code +is available under the terms of this License, including a description of how +and where You have fulfilled the obligations of Section 3.2. The notice must +be conspicuously included in any notice in an Executable version, related +documentation or collateral in which You describe recipients' rights relating +to the Covered Code. You may distribute the Executable version of Covered Code +or ownership rights under a license of Your choice, which may contain terms +different from this License, provided that You are in compliance with the +terms of this License and that the license for the Executable version does not +attempt to limit or alter the recipient's rights in the Source Code version +from the rights set forth in this License. If You distribute the Executable +version under a different license You must make it absolutely clear that any +terms which differ from this License are offered by You alone, not by the +Initial Developer or any Contributor. You hereby agree to indemnify the +Initial Developer and every Contributor for any liability incurred by the +Initial Developer or such Contributor as a result of any such terms You offer. + + 3.7. Larger Works. + You may create a Larger Work by combining Covered Code with other code +not governed by the terms of this License and distribute the Larger Work as a +single product. In such a case, You must make sure the requirements of this +License are fulfilled for the Covered Code. + +4. Inability to Comply Due to Statute or Regulation. + + If it is impossible for You to comply with any of the terms of this +License with respect to some or all of the Covered Code due to statute, +judicial order, or regulation then You must: (a) comply with the terms of this +License to the maximum extent possible; and (b) describe the limitations and +the code they affect. Such description must be included in the LEGAL file +described in Section 3.4 and must be included with all distributions of the +Source Code. Except to the extent prohibited by statute or regulation, such +description must be sufficiently detailed for a recipient of ordinary skill to +be able to understand it. + +5. Application of this License. + + This License applies to code to which the Initial Developer has attached +the notice in Exhibit A and to related Covered Code. + +6. Versions of the License. + + 6.1. New Versions. + Netscape Communications Corporation ("Netscape") may publish revised +and/or new versions of the License from time to time. Each version will be +given a distinguishing version number. + + 6.2. Effect of New Versions. + Once Covered Code has been published under a particular version of the +License, You may always continue to use it under the terms of that version. +You may also choose to use such Covered Code under the terms of any subsequent +version of the License published by Netscape. No one other than Netscape has +the right to modify the terms applicable to Covered Code created under this +License. + + 6.3. Derivative Works. + If You create or use a modified version of this License (which you may +only do in order to apply it to code which is not already Covered Code +governed by this License), You must (a) rename Your license so that the +phrases "Mozilla", "MOZILLAPL", "MOZPL", "Netscape", "MPL", "NPL" or +any confusingly similar phrase do not appear in your license (except to note +that your license differs from this License) and (b) otherwise make it clear +that Your version of the license contains terms which differ from the Mozilla +Public License and Netscape Public License. (Filling in the name of the +Initial Developer, Original Code or Contributor in the notice described in +Exhibit A shall not of themselves be deemed to be modifications of this +License.) + +7. DISCLAIMER OF WARRANTY. + + COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT +LIMITATION, WARRANTIES THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, +FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE +QUALITY AND PERFORMANCE OF THE COVERED CODE IS WITH YOU. SHOULD ANY COVERED +CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE INITIAL DEVELOPER OR ANY +OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY SERVICING, REPAIR OR +CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS +LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS +DISCLAIMER. + +8. TERMINATION. + + 8.1. This License and the rights granted hereunder will terminate +automatically if You fail to comply with terms herein and fail to cure such +breach within 30 days of becoming aware of the breach. All sublicenses to the +Covered Code which are properly granted shall survive any termination of this +License. Provisions which, by their nature, must remain in effect beyond the +termination of this License shall survive. + + 8.2. If You initiate litigation by asserting a patent infringement +claim (excluding declatory judgment actions) against Initial Developer or a +Contributor (the Initial Developer or Contributor against whom You file such +action is referred to as "Participant") alleging that: + + (a) such Participant's Contributor Version directly or indirectly +infringes any patent, then any and all rights granted by such Participant to +You under Sections 2.1 and/or 2.2 of this License shall, upon 60 days notice +from Participant terminate prospectively, unless if within 60 days after +receipt of notice You either: (i) agree in writing to pay Participant a +mutually agreeable reasonable royalty for Your past and future use of +Modifications made by such Participant, or (ii) withdraw Your litigation claim +with respect to the Contributor Version against such Participant. If within +60 days of notice, a reasonable royalty and payment arrangement are not +mutually agreed upon in writing by the parties or the litigation claim is not +withdrawn, the rights granted by Participant to You under Sections 2.1 and/or +2.2 automatically terminate at the expiration of the 60 day notice period +specified above. + + (b) any software, hardware, or device, other than such Participant's +Contributor Version, directly or indirectly infringes any patent, then any +rights granted to You by such Participant under Sections 2.1(b) and 2.2(b) are +revoked effective as of the date You first made, used, sold, distributed, or +had made, Modifications made by that Participant. + + 8.3. If You assert a patent infringement claim against Participant +alleging that such Participant's Contributor Version directly or indirectly +infringes any patent where such claim is resolved (such as by license or +settlement) prior to the initiation of patent infringement litigation, then +the reasonable value of the licenses granted by such Participant under +Sections 2.1 or 2.2 shall be taken into account in determining the amount or +value of any payment or license. + + 8.4. In the event of termination under Sections 8.1 or 8.2 above, all +end user license agreements (excluding distributors and resellers) which have +been validly granted by You or any distributor hereunder prior to termination +shall survive termination. + +9. LIMITATION OF LIABILITY. + + UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT +(INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL +DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED CODE, OR ANY +SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR ANY INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, +WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL, WORK STOPPAGE, COMPUTER +FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL DAMAGES OR LOSSES, +EVEN IF SUCH PARTY SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF SUCH +DAMAGES. THIS LIMITATION OF LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH +OR PERSONAL INJURY RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT +APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE +EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THIS +EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU. + +10. U.S. GOVERNMENT END USERS. + + The Covered Code is a "commercial item," as that term is defined in 48 +C.F.R. 2.101 (Oct. 1995), consisting of "commercial computer software" and +"commercial computer software documentation," as such terms are used in 48 +C.F.R. 12.212 (Sept. 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. +227.7202-1 through 227.7202-4 (June 1995), all U.S. Government End Users +acquire Covered Code with only those rights set forth herein. + +11. MISCELLANEOUS. + + This License represents the complete agreement concerning subject matter +hereof. If any provision of this License is held to be unenforceable, such +provision shall be reformed only to the extent necessary to make it +enforceable. This License shall be governed by California law provisions +(except to the extent applicable law, if any, provides otherwise), excluding +its conflict-of-law provisions. With respect to disputes in which at least one +party is a citizen of, or an entity chartered or registered to do business in +the United States of America, any litigation relating to this License shall be +subject to the jurisdiction of the Federal Courts of the Northern District of +California, with venue lying in Santa Clara County, California, with the +losing party responsible for costs, including without limitation, court costs +and reasonable attorneys' fees and expenses. The application of the United +Nations Convention on Contracts for the International Sale of Goods is +expressly excluded. Any law or regulation which provides that the language of +a contract shall be construed against the drafter shall not apply to this +License. + +12. RESPONSIBILITY FOR CLAIMS. + + As between Initial Developer and the Contributors, each party is +responsible for claims and damages arising, directly or indirectly, out of its +utilization of rights under this License and You agree to work with Initial +Developer and Contributors to distribute such responsibility on an equitable +basis. Nothing herein is intended or shall be deemed to constitute any +admission of liability. + +13. MULTIPLE-LICENSED CODE. + + Initial Developer may designate portions of the Covered Code as +Multiple-Licensed. Multiple-Licensed means that the Initial Developer permits +you to utilize portions of the Covered Code under Your choice of the MPL or +the alternative licenses, if any, specified by the Initial Developer in the +file described in Exhibit A. + + +EXHIBIT A -Mozilla Public License. + + ``The contents of this file are subject to the Mozilla Public License +Version 1.1 (the "License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + http://www.mozilla.org/MPL/ + + Software distributed under the License is distributed on an "AS IS" +basis, WITHOUT WARRANTY OF + ANY KIND, either express or implied. See the License for the specific +language governing rights and + limitations under the License. + + The Original Code is ______________________________________. + + The Initial Developer of the Original Code is ________________________. +Portions created by + ______________________ are Copyright (C) ______ +_______________________. All Rights + Reserved. + + Contributor(s): ______________________________________. + + Alternatively, the contents of this file may be used under the terms of +the _____ license (the [___] License), in which case the provisions of +[______] License are applicable instead of those above. If you wish to allow +use of your version of this file only under the terms of the [____] License +and not to allow others to use your version of this file under the MPL, +indicate your decision by deleting the provisions above and replace them +with the notice and other provisions required by the [___] License. If you do +not delete the provisions above, a recipient may use your version of this file +under either the MPL or the [___] License." + + [NOTE: The text of this Exhibit A may differ slightly from the text of +the notices in the Source Code files of the Original Code. You should use the +text of this Exhibit A rather than the text found in the Original Code Source +Code for Your Modifications.] + + +=============================================================================== + +For the JAX-WS Reference Implementation component: + +COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 + + + 1. Definitions. + + 1.1. "Contributor" means each individual or entity that + creates or contributes to the creation of Modifications. + + 1.2. "Contributor Version" means the combination of the + Original Software, prior Modifications used by a + Contributor (if any), and the Modifications made by that + particular Contributor. + + 1.3. "Covered Software" means (a) the Original Software, or + (b) Modifications, or (c) the combination of files + containing Original Software with files containing + Modifications, in each case including portions thereof. + + 1.4. "Executable" means the Covered Software in any form + other than Source Code. + + 1.5. "Initial Developer" means the individual or entity + that first makes Original Software available under this + License. + + 1.6. "Larger Work" means a work which combines Covered + Software or portions thereof with code not governed by the + terms of this License. + + 1.7. "License" means this document. + + 1.8. "Licensable" means having the right to grant, to the + maximum extent possible, whether at the time of the initial + grant or subsequently acquired, any and all of the rights + conveyed herein. + + 1.9. "Modifications" means the Source Code and Executable + form of any of the following: + + A. Any file that results from an addition to, + deletion from or modification of the contents of a + file containing Original Software or previous + Modifications; + + B. Any new file that contains any part of the + Original Software or previous Modification; or + + C. Any new file that is contributed or otherwise made + available under the terms of this License. + + 1.10. "Original Software" means the Source Code and + Executable form of computer software code that is + originally released under this License. + + 1.11. "Patent Claims" means any patent claim(s), now owned + or hereafter acquired, including without limitation, + method, process, and apparatus claims, in any patent + Licensable by grantor. + + 1.12. "Source Code" means (a) the common form of computer + software code in which modifications are made and (b) + associated documentation included in or with such code. + + 1.13. "You" (or "Your") means an individual or a legal + entity exercising rights under, and complying with all of + the terms of, this License. For legal entities, "You" + includes any entity which controls, is controlled by, or is + under common control with You. For purposes of this + definition, "control" means (a) the power, direct or + indirect, to cause the direction or management of such + entity, whether by contract or otherwise, or (b) ownership + of more than fifty percent (50%) of the outstanding shares + or beneficial ownership of such entity. + + 2. License Grants. + + 2.1. The Initial Developer Grant. + + Conditioned upon Your compliance with Section 3.1 below and + subject to third party intellectual property claims, the + Initial Developer hereby grants You a world-wide, + royalty-free, non-exclusive license: + + (a) under intellectual property rights (other than + patent or trademark) Licensable by Initial Developer, + to use, reproduce, modify, display, perform, + sublicense and distribute the Original Software (or + portions thereof), with or without Modifications, + and/or as part of a Larger Work; and + + (b) under Patent Claims infringed by the making, + using or selling of Original Software, to make, have + made, use, practice, sell, and offer for sale, and/or + otherwise dispose of the Original Software (or + portions thereof). + + (c) The licenses granted in Sections 2.1(a) and (b) + are effective on the date Initial Developer first + distributes or otherwise makes the Original Software + available to a third party under the terms of this + License. + + (d) Notwithstanding Section 2.1(b) above, no patent + license is granted: (1) for code that You delete from + the Original Software, or (2) for infringements + caused by: (i) the modification of the Original + Software, or (ii) the combination of the Original + Software with other software or devices. + + 2.2. Contributor Grant. + + Conditioned upon Your compliance with Section 3.1 below and + subject to third party intellectual property claims, each + Contributor hereby grants You a world-wide, royalty-free, + non-exclusive license: + + (a) under intellectual property rights (other than + patent or trademark) Licensable by Contributor to + use, reproduce, modify, display, perform, sublicense + and distribute the Modifications created by such + Contributor (or portions thereof), either on an + unmodified basis, with other Modifications, as + Covered Software and/or as part of a Larger Work; and + + + (b) under Patent Claims infringed by the making, + using, or selling of Modifications made by that + Contributor either alone and/or in combination with + its Contributor Version (or portions of such + combination), to make, use, sell, offer for sale, + have made, and/or otherwise dispose of: (1) + Modifications made by that Contributor (or portions + thereof); and (2) the combination of Modifications + made by that Contributor with its Contributor Version + (or portions of such combination). + + (c) The licenses granted in Sections 2.2(a) and + 2.2(b) are effective on the date Contributor first + distributes or otherwise makes the Modifications + available to a third party. + + (d) Notwithstanding Section 2.2(b) above, no patent + license is granted: (1) for any code that Contributor + has deleted from the Contributor Version; (2) for + infringements caused by: (i) third party + modifications of Contributor Version, or (ii) the + combination of Modifications made by that Contributor + with other software (except as part of the + Contributor Version) or other devices; or (3) under + Patent Claims infringed by Covered Software in the + absence of Modifications made by that Contributor. + + 3. Distribution Obligations. + + 3.1. Availability of Source Code. + + Any Covered Software that You distribute or otherwise make + available in Executable form must also be made available in + Source Code form and that Source Code form must be + distributed only under the terms of this License. You must + include a copy of this License with every copy of the + Source Code form of the Covered Software You distribute or + otherwise make available. You must inform recipients of any + such Covered Software in Executable form as to how they can + obtain such Covered Software in Source Code form in a + reasonable manner on or through a medium customarily used + for software exchange. + + 3.2. Modifications. + + The Modifications that You create or to which You + contribute are governed by the terms of this License. You + represent that You believe Your Modifications are Your + original creation(s) and/or You have sufficient rights to + grant the rights conveyed by this License. + + 3.3. Required Notices. + + You must include a notice in each of Your Modifications + that identifies You as the Contributor of the Modification. + You may not remove or alter any copyright, patent or + trademark notices contained within the Covered Software, or + any notices of licensing or any descriptive text giving + attribution to any Contributor or the Initial Developer. + + 3.4. Application of Additional Terms. + + You may not offer or impose any terms on any Covered + Software in Source Code form that alters or restricts the + applicable version of this License or the recipients' + rights hereunder. You may choose to offer, and to charge a + fee for, warranty, support, indemnity or liability + obligations to one or more recipients of Covered Software. + However, you may do so only on Your own behalf, and not on + behalf of the Initial Developer or any Contributor. You + must make it absolutely clear that any such warranty, + support, indemnity or liability obligation is offered by + You alone, and You hereby agree to indemnify the Initial + Developer and every Contributor for any liability incurred + by the Initial Developer or such Contributor as a result of + warranty, support, indemnity or liability terms You offer. + + + 3.5. Distribution of Executable Versions. + + You may distribute the Executable form of the Covered + Software under the terms of this License or under the terms + of a license of Your choice, which may contain terms + different from this License, provided that You are in + compliance with the terms of this License and that the + license for the Executable form does not attempt to limit + or alter the recipient's rights in the Source Code form + from the rights set forth in this License. If You + distribute the Covered Software in Executable form under a + different license, You must make it absolutely clear that + any terms which differ from this License are offered by You + alone, not by the Initial Developer or Contributor. You + hereby agree to indemnify the Initial Developer and every + Contributor for any liability incurred by the Initial + Developer or such Contributor as a result of any such terms + You offer. + + 3.6. Larger Works. + + You may create a Larger Work by combining Covered Software + with other code not governed by the terms of this License + and distribute the Larger Work as a single product. In such + a case, You must make sure the requirements of this License + are fulfilled for the Covered Software. + + 4. Versions of the License. + + 4.1. New Versions. + + Sun Microsystems, Inc. is the initial license steward and + may publish revised and/or new versions of this License + from time to time. Each version will be given a + distinguishing version number. Except as provided in + Section 4.3, no one other than the license steward has the + right to modify this License. + + 4.2. Effect of New Versions. + + You may always continue to use, distribute or otherwise + make the Covered Software available under the terms of the + version of the License under which You originally received + the Covered Software. If the Initial Developer includes a + notice in the Original Software prohibiting it from being + distributed or otherwise made available under any + subsequent version of the License, You must distribute and + make the Covered Software available under the terms of the + version of the License under which You originally received + the Covered Software. Otherwise, You may also choose to + use, distribute or otherwise make the Covered Software + available under the terms of any subsequent version of the + License published by the license steward. + + 4.3. Modified Versions. + + When You are an Initial Developer and You want to create a + new license for Your Original Software, You may create and + use a modified version of this License if You: (a) rename + the license and remove any references to the name of the + license steward (except to note that the license differs + from this License); and (b) otherwise make it clear that + the license contains terms which differ from this License. + + + 5. DISCLAIMER OF WARRANTY. + + COVERED SOFTWARE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" + BASIS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, + INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE COVERED + SOFTWARE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR + PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND + PERFORMANCE OF THE COVERED SOFTWARE IS WITH YOU. SHOULD ANY + COVERED SOFTWARE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE + INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF + ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF + WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF + ANY COVERED SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS + DISCLAIMER. + + 6. TERMINATION. + + 6.1. This License and the rights granted hereunder will + terminate automatically if You fail to comply with terms + herein and fail to cure such breach within 30 days of + becoming aware of the breach. Provisions which, by their + nature, must remain in effect beyond the termination of + this License shall survive. + + 6.2. If You assert a patent infringement claim (excluding + declaratory judgment actions) against Initial Developer or + a Contributor (the Initial Developer or Contributor against + whom You assert such claim is referred to as "Participant") + alleging that the Participant Software (meaning the + Contributor Version where the Participant is a Contributor + or the Original Software where the Participant is the + Initial Developer) directly or indirectly infringes any + patent, then any and all rights granted directly or + indirectly to You by such Participant, the Initial + Developer (if the Initial Developer is not the Participant) + and all Contributors under Sections 2.1 and/or 2.2 of this + License shall, upon 60 days notice from Participant + terminate prospectively and automatically at the expiration + of such 60 day notice period, unless if within such 60 day + period You withdraw Your claim with respect to the + Participant Software against such Participant either + unilaterally or pursuant to a written agreement with + Participant. + + 6.3. In the event of termination under Sections 6.1 or 6.2 + above, all end user licenses that have been validly granted + by You or any distributor hereunder prior to termination + (excluding licenses granted to You by any distributor) + shall survive termination. + + 7. LIMITATION OF LIABILITY. + + UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT + (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE + INITIAL DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF + COVERED SOFTWARE, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE + LIABLE TO ANY PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR + CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT + LIMITATION, DAMAGES FOR LOST PROFITS, LOSS OF GOODWILL, WORK + STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER + COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN + INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF + LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL + INJURY RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT + APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO + NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR + CONSEQUENTIAL DAMAGES, SO THIS EXCLUSION AND LIMITATION MAY NOT + APPLY TO YOU. + + 8. U.S. GOVERNMENT END USERS. + + The Covered Software is a "commercial item," as that term is + defined in 48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial + computer software" (as that term is defined at 48 C.F.R. + 252.227-7014(a)(1)) and "commercial computer software + documentation" as such terms are used in 48 C.F.R. 12.212 (Sept. + 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1 + through 227.7202-4 (June 1995), all U.S. Government End Users + acquire Covered Software with only those rights set forth herein. + This U.S. Government Rights clause is in lieu of, and supersedes, + any other FAR, DFAR, or other clause or provision that addresses + Government rights in computer software under this License. + + 9. MISCELLANEOUS. + + This License represents the complete agreement concerning subject + matter hereof. If any provision of this License is held to be + unenforceable, such provision shall be reformed only to the + extent necessary to make it enforceable. This License shall be + governed by the law of the jurisdiction specified in a notice + contained within the Original Software (except to the extent + applicable law, if any, provides otherwise), excluding such + jurisdiction's conflict-of-law provisions. Any litigation + relating to this License shall be subject to the jurisdiction of + the courts located in the jurisdiction and venue specified in a + notice contained within the Original Software, with the losing + party responsible for costs, including, without limitation, court + costs and reasonable attorneys' fees and expenses. The + application of the United Nations Convention on Contracts for the + International Sale of Goods is expressly excluded. Any law or + regulation which provides that the language of a contract shall + be construed against the drafter shall not apply to this License. + You agree that You alone are responsible for compliance with the + United States export administration regulations (and the export + control laws and regulation of any other countries) when You use, + distribute or otherwise make available any Covered Software. + + 10. RESPONSIBILITY FOR CLAIMS. + + As between Initial Developer and the Contributors, each party is + responsible for claims and damages arising, directly or + indirectly, out of its utilization of rights under this License + and You agree to work with Initial Developer and Contributors to + distribute such responsibility on an equitable basis. Nothing + herein is intended or shall be deemed to constitute any admission + of liability. + diff --git a/sandbox/rfeng/samples/calculatorws/src/main/resources/META-INF/NOTICE b/sandbox/rfeng/samples/calculatorws/src/main/resources/META-INF/NOTICE new file mode 100644 index 0000000000..11c564eb19 --- /dev/null +++ b/sandbox/rfeng/samples/calculatorws/src/main/resources/META-INF/NOTICE @@ -0,0 +1,18 @@ +========================================================================= +== NOTICE file corresponding to the section 4 d of == +== the Apache License, Version 2.0, == +== in this case for the Apache Tuscany distribution. == +========================================================================= + +This product includes software developed by the Apache Software Foundation +(http://www.apache.org/). + +This product also includes software developed by: +- the Eclipse Modeling Framework project (http://www.eclipse.org/emf/) +- the Celtix project (http://celtix.objectweb.org/) +- the Mozilla Rhino project (http://www.mozilla.org/rhino/) +- the GlassFish JAX-WS project (https://jax-ws.dev.java.net/) + +Please read the LICENSE.txt file present in the root directory of this +distribution. + diff --git a/sandbox/rfeng/samples/calculatorws/src/main/resources/META-INF/README.txt b/sandbox/rfeng/samples/calculatorws/src/main/resources/META-INF/README.txt new file mode 100644 index 0000000000..9b26d1690a --- /dev/null +++ b/sandbox/rfeng/samples/calculatorws/src/main/resources/META-INF/README.txt @@ -0,0 +1,35 @@ +Apache Tuscany M1 build (May, 2006) +=================================== + +http://incubator.apache.org/tuscany/ + +Tuscany is an effort undergoing incubation at the Apache Software Foundation +(ASF), sponsored by the Web Services PMC. + +Incubation is required of all newly accepted projects until a further review +indicates that the infrastructure, communications, and decision making process +have stabilized in a manner consistent with other successful ASF projects. + +While incubation status is not necessarily a reflection of the completeness or +stability of the code, it does indicate that the project has yet to be fully +endorsed by the ASF. + + +Support +------- + +Any problem with this release can be reported to the Tuscany mailing list +or in the JIRA issue tracker. + +Mailing list subscription: + tuscany-dev-subscribe@ws.apache.org + +Jira: + http://issues.apache.org/jira/browse/Tuscany + + +Thank you for using Tuscany! + + +The Tuscany Team. + diff --git a/sandbox/rfeng/samples/calculatorws/src/main/resources/wsdl/calculator.wsdl b/sandbox/rfeng/samples/calculatorws/src/main/resources/wsdl/calculator.wsdl new file mode 100644 index 0000000000..9f7573160e --- /dev/null +++ b/sandbox/rfeng/samples/calculatorws/src/main/resources/wsdl/calculator.wsdl @@ -0,0 +1,155 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/rfeng/samples/calculatorws/src/main/webapp/META-INF/sca/default.scdl b/sandbox/rfeng/samples/calculatorws/src/main/webapp/META-INF/sca/default.scdl new file mode 100644 index 0000000000..29fdcd4715 --- /dev/null +++ b/sandbox/rfeng/samples/calculatorws/src/main/webapp/META-INF/sca/default.scdl @@ -0,0 +1,57 @@ + + + + + + + + + + + CalculatorServiceComponent + + + + + AddServiceComponent + SubtractServiceComponent + MultiplyServiceComponent + DivideServiceComponent + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/rfeng/samples/calculatorws/src/main/webapp/META-INF/tuscany/binding.axis2.scdl b/sandbox/rfeng/samples/calculatorws/src/main/webapp/META-INF/tuscany/binding.axis2.scdl new file mode 100644 index 0000000000..852f36e10d --- /dev/null +++ b/sandbox/rfeng/samples/calculatorws/src/main/webapp/META-INF/tuscany/binding.axis2.scdl @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + diff --git a/sandbox/rfeng/samples/calculatorws/src/main/webapp/META-INF/tuscany/databinding.axiom.scdl b/sandbox/rfeng/samples/calculatorws/src/main/webapp/META-INF/tuscany/databinding.axiom.scdl new file mode 100644 index 0000000000..0dcd226418 --- /dev/null +++ b/sandbox/rfeng/samples/calculatorws/src/main/webapp/META-INF/tuscany/databinding.axiom.scdl @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sandbox/rfeng/samples/calculatorws/src/main/webapp/META-INF/tuscany/databinding.sdo.scdl b/sandbox/rfeng/samples/calculatorws/src/main/webapp/META-INF/tuscany/databinding.sdo.scdl new file mode 100644 index 0000000000..8c1c36d466 --- /dev/null +++ b/sandbox/rfeng/samples/calculatorws/src/main/webapp/META-INF/tuscany/databinding.sdo.scdl @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/rfeng/samples/calculatorws/src/main/webapp/META-INF/tuscany/interface.wsdl.scdl b/sandbox/rfeng/samples/calculatorws/src/main/webapp/META-INF/tuscany/interface.wsdl.scdl new file mode 100644 index 0000000000..9a15675f9f --- /dev/null +++ b/sandbox/rfeng/samples/calculatorws/src/main/webapp/META-INF/tuscany/interface.wsdl.scdl @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sandbox/rfeng/samples/calculatorws/src/main/webapp/META-INF/tuscany/webapp.scdl b/sandbox/rfeng/samples/calculatorws/src/main/webapp/META-INF/tuscany/webapp.scdl new file mode 100644 index 0000000000..3111557013 --- /dev/null +++ b/sandbox/rfeng/samples/calculatorws/src/main/webapp/META-INF/tuscany/webapp.scdl @@ -0,0 +1,138 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 10 + + + + + + + + + + + + + + + + + + + + + + + . + + + + + + + + + diff --git a/sandbox/rfeng/samples/calculatorws/src/main/webapp/WEB-INF/web.xml b/sandbox/rfeng/samples/calculatorws/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..f97dc95e23 --- /dev/null +++ b/sandbox/rfeng/samples/calculatorws/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,51 @@ + + + + + + Tuscany HelloWorld Web Service Sample + + + tuscany.systemScdlPath + /META-INF/tuscany/webapp.scdl + + + + tuscany.applicationScdlPath + /META-INF/sca/default.scdl + + + + org.apache.tuscany.runtime.webapp.TuscanyContextListener + + + + TuscanyServlet + Tuscany Servlet + org.apache.tuscany.runtime.webapp.TuscanyServlet + + + + TuscanyServlet + /services/* + + + diff --git a/sandbox/rfeng/samples/creditws/.ruleset b/sandbox/rfeng/samples/creditws/.ruleset new file mode 100644 index 0000000000..2a06794776 --- /dev/null +++ b/sandbox/rfeng/samples/creditws/.ruleset @@ -0,0 +1,172 @@ + + + PMD Plugin preferences rule set + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/rfeng/samples/creditws/pom.xml b/sandbox/rfeng/samples/creditws/pom.xml new file mode 100644 index 0000000000..3f4c4b18b2 --- /dev/null +++ b/sandbox/rfeng/samples/creditws/pom.xml @@ -0,0 +1,103 @@ + + + + + org.apache.tuscany.samples.sca + parent + 1.0-incubator-SNAPSHOT + + 4.0.0 + sample-creditws + war + Tuscany credit Web Service Sample + A sample credit Web Service. + + + axis2 + + + + + + + org.osoa + sca-api-r0.95 + ${tuscanyVersion} + compile + + + + + org.apache.tuscany.sca.kernel + tuscany-api + ${tuscanyVersion} + compile + + + + + org.apache.tuscany.sca.runtime + webapp + ${tuscanyVersion} + runtime + + + + + junit + junit + 3.8.1 + test + + + + + + install + credit + + + org.apache.tuscany.sca.plugins + tuscany-war-plugin + ${tuscanyVersion} + + + tuscany-war + + tuscany-war + + + + + + + false + + + org.apache.tuscany.sca.services.bindings + axis2 + ${tuscanyVersion} + + + + + + + diff --git a/sandbox/rfeng/samples/creditws/src/main/java/credit/CreditCheck.java b/sandbox/rfeng/samples/creditws/src/main/java/credit/CreditCheck.java new file mode 100644 index 0000000000..ec95a60227 --- /dev/null +++ b/sandbox/rfeng/samples/creditws/src/main/java/credit/CreditCheck.java @@ -0,0 +1,26 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package credit; + +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface CreditCheck { + int getCreditScore(String ssn); +} diff --git a/sandbox/rfeng/samples/creditws/src/main/java/credit/CreditCheckImpl.java b/sandbox/rfeng/samples/creditws/src/main/java/credit/CreditCheckImpl.java new file mode 100644 index 0000000000..24747cf993 --- /dev/null +++ b/sandbox/rfeng/samples/creditws/src/main/java/credit/CreditCheckImpl.java @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package credit; + +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; + +/** + * An implementation of the CreditReportService service + */ +@Scope("MODULE") +@Service(CreditCheck.class) +public class CreditCheckImpl implements CreditCheck { + + public int getCreditScore(String ssn) { + return (int) (700 + (Math.random() - 0.5) * 100); + } +} diff --git a/sandbox/rfeng/samples/creditws/src/main/resources/META-INF/LICENSE.txt b/sandbox/rfeng/samples/creditws/src/main/resources/META-INF/LICENSE.txt new file mode 100644 index 0000000000..25d78feeac --- /dev/null +++ b/sandbox/rfeng/samples/creditws/src/main/resources/META-INF/LICENSE.txt @@ -0,0 +1,1277 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + +APACHE TUSCANY SUBCOMPONENTS: + +The Apache Tuscany distribution includes a number of subcomponents with +separate copyright notices and license terms. Your use of the source +code for the these subcomponents is subject to the terms and +conditions of the following licenses. + +=============================================================================== + +For the Eclipse Modeling Framework component and the Celtix binding: + +Eclipse Public License - v 1.0 + +THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE +PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF +THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. + +1. DEFINITIONS + +"Contribution" means: + +a) in the case of the initial Contributor, the initial code and +documentation distributed under this Agreement, and +b) in the case of each subsequent Contributor: + +i) changes to the Program, and + +ii) additions to the Program; + +where such changes and/or additions to the Program originate from and +are distributed by that particular Contributor. A Contribution +'originates' from a Contributor if it was added to the Program by such +Contributor itself or anyone acting on such Contributor's behalf. +Contributions do not include additions to the Program which: (i) are +separate modules of software distributed in conjunction with the +Program under their own license agreement, and (ii) are not derivative +works of the Program. + +"Contributor" means any person or entity that distributes the Program. + +"Licensed Patents " mean patent claims licensable by a Contributor +which are necessarily infringed by the use or sale of its Contribution +alone or when combined with the Program. + +"Program" means the Contributions distributed in accordance with this +Agreement. + +"Recipient" means anyone who receives the Program under this +Agreement, including all Contributors. + +2. GRANT OF RIGHTS + +a) Subject to the terms of this Agreement, each Contributor hereby +grants Recipient a non-exclusive, worldwide, royalty-free copyright +license to reproduce, prepare derivative works of, publicly display, +publicly perform, distribute and sublicense the Contribution of such +Contributor, if any, and such derivative works, in source code and +object code form. + +b) Subject to the terms of this Agreement, each Contributor hereby +grants Recipient a non-exclusive, worldwide, royalty-free patent +license under Licensed Patents to make, use, sell, offer to sell, +import and otherwise transfer the Contribution of such Contributor, if +any, in source code and object code form. This patent license shall +apply to the combination of the Contribution and the Program if, at +the time the Contribution is added by the Contributor, such addition +of the Contribution causes such combination to be covered by the +Licensed Patents. The patent license shall not apply to any other +combinations which include the Contribution. No hardware per se is +licensed hereunder. + +c) Recipient understands that although each Contributor grants the +licenses to its Contributions set forth herein, no assurances are +provided by any Contributor that the Program does not infringe the +patent or other intellectual property rights of any other entity. Each +Contributor disclaims any liability to Recipient for claims brought by +any other entity based on infringement of intellectual property rights +or otherwise. As a condition to exercising the rights and licenses +granted hereunder, each Recipient hereby assumes sole responsibility +to secure any other intellectual property rights needed, if any. For +example, if a third party patent license is required to allow +Recipient to distribute the Program, it is Recipient's responsibility +to acquire that license before distributing the Program. + +d) Each Contributor represents that to its knowledge it has sufficient +copyright rights in its Contribution, if any, to grant the copyright +license set forth in this Agreement. + +3. REQUIREMENTS + +A Contributor may choose to distribute the Program in object code form +under its own license agreement, provided that: + +a) it complies with the terms and conditions of this Agreement; and + +b) its license agreement: + +i) effectively disclaims on behalf of all Contributors all warranties +and conditions, express and implied, including warranties or +conditions of title and non-infringement, and implied warranties or +conditions of merchantability and fitness for a particular purpose; + +ii) effectively excludes on behalf of all Contributors all liability +for damages, including direct, indirect, special, incidental and +consequential damages, such as lost profits; + +iii) states that any provisions which differ from this Agreement are +offered by that Contributor alone and not by any other party; and + +iv) states that source code for the Program is available from such +Contributor, and informs licensees how to obtain it in a reasonable +manner on or through a medium customarily used for software exchange. + +When the Program is made available in source code form: + +a) it must be made available under this Agreement; and + +b) a copy of this Agreement must be included with each copy of the +Program. + +Contributors may not remove or alter any copyright notices contained +within the Program. + +Each Contributor must identify itself as the originator of its +Contribution, if any, in a manner that reasonably allows subsequent +Recipients to identify the originator of the Contribution. + +4. COMMERCIAL DISTRIBUTION + +Commercial distributors of software may accept certain +responsibilities with respect to end users, business partners and the +like. While this license is intended to facilitate the commercial use +of the Program, the Contributor who includes the Program in a +commercial product offering should do so in a manner which does not +create potential liability for other Contributors. Therefore, if a +Contributor includes the Program in a commercial product offering, +such Contributor ("Commercial Contributor") hereby agrees to defend +and indemnify every other Contributor ("Indemnified Contributor") +against any losses, damages and costs (collectively "Losses") arising +from claims, lawsuits and other legal actions brought by a third party +against the Indemnified Contributor to the extent caused by the acts +or omissions of such Commercial Contributor in connection with its +distribution of the Program in a commercial product offering. The +obligations in this section do not apply to any claims or Losses +relating to any actual or alleged intellectual property infringement. +In order to qualify, an Indemnified Contributor must: a) promptly +notify the Commercial Contributor in writing of such claim, and b) +allow the Commercial Contributor to control, and cooperate with the +Commercial Contributor in, the defense and any related settlement +negotiations. The Indemnified Contributor may participate in any such +claim at its own expense. + +For example, a Contributor might include the Program in a commercial +product offering, Product X. That Contributor is then a Commercial +Contributor. If that Commercial Contributor then makes performance +claims, or offers warranties related to Product X, those performance +claims and warranties are such Commercial Contributor's responsibility +alone. Under this section, the Commercial Contributor would have to +defend claims against the other Contributors related to those +performance claims and warranties, and if a court requires any other +Contributor to pay any damages as a result, the Commercial Contributor +must pay those damages. + +5. NO WARRANTY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS +PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY +WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY +OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely +responsible for determining the appropriateness of using and +distributing the Program and assumes all risks associated with its +exercise of rights under this Agreement , including but not limited to +the risks and costs of program errors, compliance with applicable +laws, damage to or loss of data, programs or equipment, and +unavailability or interruption of operations. + +6. DISCLAIMER OF LIABILITY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR +ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING +WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR +DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED +HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +7. GENERAL + +If any provision of this Agreement is invalid or unenforceable under +applicable law, it shall not affect the validity or enforceability of +the remainder of the terms of this Agreement, and without further +action by the parties hereto, such provision shall be reformed to the +minimum extent necessary to make such provision valid and enforceable. + +If Recipient institutes patent litigation against any entity +(including a cross-claim or counterclaim in a lawsuit) alleging that +the Program itself (excluding combinations of the Program with other +software or hardware) infringes such Recipient's patent(s), then such +Recipient's rights granted under Section 2(b) shall terminate as of +the date such litigation is filed. + +All Recipient's rights under this Agreement shall terminate if it +fails to comply with any of the material terms or conditions of this +Agreement and does not cure such failure in a reasonable period of +time after becoming aware of such noncompliance. If all Recipient's +rights under this Agreement terminate, Recipient agrees to cease use +and distribution of the Program as soon as reasonably practicable. +However, Recipient's obligations under this Agreement and any licenses +granted by Recipient relating to the Program shall continue and +survive. + +Everyone is permitted to copy and distribute copies of this Agreement, +but in order to avoid inconsistency the Agreement is copyrighted and +may only be modified in the following manner. The Agreement Steward +reserves the right to publish new versions (including revisions) of +this Agreement from time to time. No one other than the Agreement +Steward has the right to modify this Agreement. The Eclipse Foundation +is the initial Agreement Steward. The Eclipse Foundation may assign +the responsibility to serve as the Agreement Steward to a suitable +separate entity. Each new version of the Agreement will be given a +distinguishing version number. The Program (including Contributions) +may always be distributed subject to the version of the Agreement +under which it was received. In addition, after a new version of the +Agreement is published, Contributor may elect to distribute the +Program (including its Contributions) under the new version. Except as +expressly stated in Sections 2(a) and 2(b) above, Recipient receives +no rights or licenses to the intellectual property of any Contributor +under this Agreement, whether expressly, by implication, estoppel or +otherwise. All rights in the Program not expressly granted under this +Agreement are reserved. + +This Agreement is governed by the laws of the State of New York and +the intellectual property laws of the United States of America. No +party to this Agreement will bring a legal action under this Agreement +more than one year after the cause of action arose. Each party waives +its rights to a jury trial in any resulting litigation. + +=============================================================================== + +For the Rhino JavaScript container component: + +Mozilla Public License 1.1 (MPL 1.1) + +1. Definitions. + + 1.0.1. "Commercial Use" means distribution or otherwise making the +Covered Code available to a third party. + + 1.1. "Contributor" means each entity that creates or contributes to +the creation of Modifications. + + 1.2. "Contributor Version" means the combination of the Original Code, +prior Modifications used by a Contributor, and the Modifications made by that +particular Contributor. + + 1.3. "Covered Code" means the Original Code or Modifications or the +combination of the Original Code and Modifications, in each case including +portions thereof. + + 1.4. "Electronic Distribution Mechanism" means a mechanism generally +accepted in the software development community for the electronic transfer of +data. + + 1.5. "Executable" means Covered Code in any form other than Source +Code. + + 1.6. "Initial Developer" means the individual or entity identified as +the Initial Developer in the Source Code notice required by Exhibit A. + + 1.7. "Larger Work" means a work which combines Covered Code or +portions thereof with code not governed by the terms of this License. + + 1.8. "License" means this document. + + 1.8.1. "Licensable" means having the right to grant, to the maximum +extent possible, whether at the time of the initial grant or subsequently +acquired, any and all of the rights conveyed herein. + + 1.9. "Modifications" means any addition to or deletion from the +substance or structure of either the Original Code or any previous +Modifications. When Covered Code is released as a series of files, a +Modification is: + A. Any addition to or deletion from the contents of a file +containing Original Code or previous Modifications. + + B. Any new file that contains any part of the Original Code or +previous Modifications. + + 1.10. "Original Code" means Source Code of computer software code +which is described in the Source Code notice required by Exhibit A as Original +Code, and which, at the time of its release under this License is not already +Covered Code governed by this License. + + 1.10.1. "Patent Claims" means any patent claim(s), now owned or +hereafter acquired, including without limitation, method, process, and +apparatus claims, in any patent Licensable by grantor. + + 1.11. "Source Code" means the preferred form of the Covered Code for +making modifications to it, including all modules it contains, plus any +associated interface definition files, scripts used to control compilation and +installation of an Executable, or source code differential comparisons against +either the Original Code or another well known, available Covered Code of the +Contributor's choice. The Source Code can be in a compressed or archival form, +provided the appropriate decompression or de-archiving software is widely +available for no charge. + + 1.12. "You" (or "Your") means an individual or a legal entity +exercising rights under, and complying with all of the terms of, this License +or a future version of this License issued under Section 6.1. For legal +entities, "You" includes any entity which controls, is controlled by, or is +under common control with You. For purposes of this definition, "control" +means (a) the power, direct or indirect, to cause the direction or management +of such entity, whether by contract or otherwise, or (b) ownership of more +than fifty percent (50%) of the outstanding shares or beneficial ownership of +such entity. + +2. Source Code License. + + 2.1. The Initial Developer Grant. + The Initial Developer hereby grants You a world-wide, royalty-free, +non-exclusive license, subject to third party intellectual property claims: + (a) under intellectual property rights (other than patent or +trademark) Licensable by Initial Developer to use, reproduce, modify, display, +perform, sublicense and distribute the Original Code (or portions thereof) +with or without Modifications, and/or as part of a Larger Work; and + + (b) under Patents Claims infringed by the making, using or selling +of Original Code, to make, have made, use, practice, sell, and offer for sale, +and/or otherwise dispose of the Original Code (or portions thereof). + (c) the licenses granted in this Section 2.1(a) and +(b) are effective on the date Initial Developer first distributes Original +Code under the terms of this License. + + (d) Notwithstanding Section 2.1(b) above, no patent license is +granted: 1) for code that You delete from the Original Code; 2) separate from +the Original Code; or 3) for infringements caused by: i) the modification of +the Original Code or ii) the combination of the Original Code with other +software or devices. + + 2.2. Contributor Grant. + Subject to third party intellectual property claims, each Contributor +hereby grants You a world-wide, royalty-free, non-exclusive license + + (a) under intellectual property rights (other than patent or +trademark) Licensable by Contributor, to use, reproduce, modify, display, +perform, sublicense and distribute the Modifications created by such +Contributor (or portions thereof) either on an unmodified basis, with other +Modifications, as Covered Code and/or as part of a Larger Work; and + + (b) under Patent Claims infringed by the making, using, or selling +of Modifications made by that Contributor either alone and/or in combination +with its Contributor Version (or portions of such combination), to make, use, +sell, offer for sale, have made, and/or otherwise dispose of: 1) Modifications +made by that Contributor (or portions thereof); and 2) the combination of +Modifications made by that Contributor with its Contributor Version (or +portions of such combination). + + (c) the licenses granted in Sections 2.2(a) and 2.2(b) are +effective on the date Contributor first makes Commercial Use of the Covered +Code. + + (d) Notwithstanding Section 2.2(b) above, no patent license is +granted: 1) for any code that Contributor has deleted from the Contributor +Version; 2) separate from the Contributor Version; 3) for infringements +caused by: i) third party modifications of Contributor Version or ii) the +combination of Modifications made by that Contributor with other software +(except as part of the Contributor Version) or other devices; or 4) under +Patent Claims infringed by Covered Code in the absence of Modifications made +by that Contributor. + + +3. Distribution Obligations. + + 3.1. Application of License. + The Modifications which You create or to which You contribute are +governed by the terms of this License, including without limitation Section +2.2. The Source Code version of Covered Code may be distributed only under the +terms of this License or a future version of this License released under +Section 6.1, and You must include a copy of this License with every copy of +the Source Code You distribute. You may not offer or impose any terms on any +Source Code version that alters or restricts the applicable version of this +License or the recipients' rights hereunder. However, You may include an +additional document offering the additional rights described in Section 3.5. + + 3.2. Availability of Source Code. + Any Modification which You create or to which You contribute must be +made available in Source Code form under the terms of this License either on +the same media as an Executable version or via an accepted Electronic +Distribution Mechanism to anyone to whom you made an Executable version +available; and if made available via Electronic Distribution Mechanism, must +remain available for at least twelve (12) months after the date it initially +became available, or at least six (6) months after a subsequent version of +that particular Modification has been made available to such recipients. You +are responsible for ensuring that the Source Code version remains available +even if the Electronic Distribution Mechanism is maintained by a third party. + + 3.3. Description of Modifications. + You must cause all Covered Code to which You contribute to contain a +file documenting the changes You made to create that Covered Code and the date +of any change. You must include a prominent statement that the Modification is +derived, directly or indirectly, from Original Code provided by the Initial +Developer and including the name of the Initial Developer in (a) the Source +Code, and (b) in any notice in an Executable version or related documentation +in which You describe the origin or ownership of the Covered Code. + + 3.4. Intellectual Property Matters + (a) Third Party Claims. + If Contributor has knowledge that a license under a third party's +intellectual property rights is required to exercise the rights granted by +such Contributor under Sections 2.1 or 2.2, Contributor must include a text +file with the Source Code distribution titled "LEGAL" which describes the +claim and the party making the claim in sufficient detail that a recipient +will know whom to contact. If Contributor obtains such knowledge after the +Modification is made available as described in Section 3.2, Contributor shall +promptly modify the LEGAL file in all copies Contributor makes available +thereafter and shall take other steps (such as notifying appropriate mailing +lists or newsgroups) reasonably calculated to inform those who received the +Covered Code that new knowledge has been obtained. + + (b) Contributor APIs. + If Contributor's Modifications include an application programming +interface and Contributor has knowledge of patent licenses which are +reasonably necessary to implement that API, Contributor must also include this +information in the LEGAL file. + + (c) Representations. + Contributor represents that, except as disclosed pursuant to +Section 3.4(a) above, Contributor believes that Contributor's Modifications +are Contributor's original creation(s) and/or Contributor has sufficient +rights to grant the rights conveyed by this License. + + + 3.5. Required Notices. + You must duplicate the notice in Exhibit A in each file of the Source +Code. If it is not possible to put such notice in a particular Source Code +file due to its structure, then You must include such notice in a location +(such as a relevant directory) where a user would be likely to look for such a +notice. If You created one or more Modification(s) You may add your name as a +Contributor to the notice described in Exhibit A. You must also duplicate +this License in any documentation for the Source Code where You describe +recipients' rights or ownership rights relating to Covered Code. You may +choose to offer, and to charge a fee for, warranty, support, indemnity or +liability obligations to one or more recipients of Covered Code. However, You +may do so only on Your own behalf, and not on behalf of the Initial Developer +or any Contributor. You must make it absolutely clear than any such warranty, +support, indemnity or liability obligation is offered by You alone, and You +hereby agree to indemnify the Initial Developer and every Contributor for any +liability incurred by the Initial Developer or such Contributor as a result of +warranty, support, indemnity or liability terms You offer. + + 3.6. Distribution of Executable Versions. + You may distribute Covered Code in Executable form only if the +requirements of Section 3.1-3.5 have been met for that Covered Code, and if +You include a notice stating that the Source Code version of the Covered Code +is available under the terms of this License, including a description of how +and where You have fulfilled the obligations of Section 3.2. The notice must +be conspicuously included in any notice in an Executable version, related +documentation or collateral in which You describe recipients' rights relating +to the Covered Code. You may distribute the Executable version of Covered Code +or ownership rights under a license of Your choice, which may contain terms +different from this License, provided that You are in compliance with the +terms of this License and that the license for the Executable version does not +attempt to limit or alter the recipient's rights in the Source Code version +from the rights set forth in this License. If You distribute the Executable +version under a different license You must make it absolutely clear that any +terms which differ from this License are offered by You alone, not by the +Initial Developer or any Contributor. You hereby agree to indemnify the +Initial Developer and every Contributor for any liability incurred by the +Initial Developer or such Contributor as a result of any such terms You offer. + + 3.7. Larger Works. + You may create a Larger Work by combining Covered Code with other code +not governed by the terms of this License and distribute the Larger Work as a +single product. In such a case, You must make sure the requirements of this +License are fulfilled for the Covered Code. + +4. Inability to Comply Due to Statute or Regulation. + + If it is impossible for You to comply with any of the terms of this +License with respect to some or all of the Covered Code due to statute, +judicial order, or regulation then You must: (a) comply with the terms of this +License to the maximum extent possible; and (b) describe the limitations and +the code they affect. Such description must be included in the LEGAL file +described in Section 3.4 and must be included with all distributions of the +Source Code. Except to the extent prohibited by statute or regulation, such +description must be sufficiently detailed for a recipient of ordinary skill to +be able to understand it. + +5. Application of this License. + + This License applies to code to which the Initial Developer has attached +the notice in Exhibit A and to related Covered Code. + +6. Versions of the License. + + 6.1. New Versions. + Netscape Communications Corporation ("Netscape") may publish revised +and/or new versions of the License from time to time. Each version will be +given a distinguishing version number. + + 6.2. Effect of New Versions. + Once Covered Code has been published under a particular version of the +License, You may always continue to use it under the terms of that version. +You may also choose to use such Covered Code under the terms of any subsequent +version of the License published by Netscape. No one other than Netscape has +the right to modify the terms applicable to Covered Code created under this +License. + + 6.3. Derivative Works. + If You create or use a modified version of this License (which you may +only do in order to apply it to code which is not already Covered Code +governed by this License), You must (a) rename Your license so that the +phrases "Mozilla", "MOZILLAPL", "MOZPL", "Netscape", "MPL", "NPL" or +any confusingly similar phrase do not appear in your license (except to note +that your license differs from this License) and (b) otherwise make it clear +that Your version of the license contains terms which differ from the Mozilla +Public License and Netscape Public License. (Filling in the name of the +Initial Developer, Original Code or Contributor in the notice described in +Exhibit A shall not of themselves be deemed to be modifications of this +License.) + +7. DISCLAIMER OF WARRANTY. + + COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT +LIMITATION, WARRANTIES THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, +FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE +QUALITY AND PERFORMANCE OF THE COVERED CODE IS WITH YOU. SHOULD ANY COVERED +CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE INITIAL DEVELOPER OR ANY +OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY SERVICING, REPAIR OR +CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS +LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS +DISCLAIMER. + +8. TERMINATION. + + 8.1. This License and the rights granted hereunder will terminate +automatically if You fail to comply with terms herein and fail to cure such +breach within 30 days of becoming aware of the breach. All sublicenses to the +Covered Code which are properly granted shall survive any termination of this +License. Provisions which, by their nature, must remain in effect beyond the +termination of this License shall survive. + + 8.2. If You initiate litigation by asserting a patent infringement +claim (excluding declatory judgment actions) against Initial Developer or a +Contributor (the Initial Developer or Contributor against whom You file such +action is referred to as "Participant") alleging that: + + (a) such Participant's Contributor Version directly or indirectly +infringes any patent, then any and all rights granted by such Participant to +You under Sections 2.1 and/or 2.2 of this License shall, upon 60 days notice +from Participant terminate prospectively, unless if within 60 days after +receipt of notice You either: (i) agree in writing to pay Participant a +mutually agreeable reasonable royalty for Your past and future use of +Modifications made by such Participant, or (ii) withdraw Your litigation claim +with respect to the Contributor Version against such Participant. If within +60 days of notice, a reasonable royalty and payment arrangement are not +mutually agreed upon in writing by the parties or the litigation claim is not +withdrawn, the rights granted by Participant to You under Sections 2.1 and/or +2.2 automatically terminate at the expiration of the 60 day notice period +specified above. + + (b) any software, hardware, or device, other than such Participant's +Contributor Version, directly or indirectly infringes any patent, then any +rights granted to You by such Participant under Sections 2.1(b) and 2.2(b) are +revoked effective as of the date You first made, used, sold, distributed, or +had made, Modifications made by that Participant. + + 8.3. If You assert a patent infringement claim against Participant +alleging that such Participant's Contributor Version directly or indirectly +infringes any patent where such claim is resolved (such as by license or +settlement) prior to the initiation of patent infringement litigation, then +the reasonable value of the licenses granted by such Participant under +Sections 2.1 or 2.2 shall be taken into account in determining the amount or +value of any payment or license. + + 8.4. In the event of termination under Sections 8.1 or 8.2 above, all +end user license agreements (excluding distributors and resellers) which have +been validly granted by You or any distributor hereunder prior to termination +shall survive termination. + +9. LIMITATION OF LIABILITY. + + UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT +(INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL +DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED CODE, OR ANY +SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR ANY INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, +WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL, WORK STOPPAGE, COMPUTER +FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL DAMAGES OR LOSSES, +EVEN IF SUCH PARTY SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF SUCH +DAMAGES. THIS LIMITATION OF LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH +OR PERSONAL INJURY RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT +APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE +EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THIS +EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU. + +10. U.S. GOVERNMENT END USERS. + + The Covered Code is a "commercial item," as that term is defined in 48 +C.F.R. 2.101 (Oct. 1995), consisting of "commercial computer software" and +"commercial computer software documentation," as such terms are used in 48 +C.F.R. 12.212 (Sept. 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. +227.7202-1 through 227.7202-4 (June 1995), all U.S. Government End Users +acquire Covered Code with only those rights set forth herein. + +11. MISCELLANEOUS. + + This License represents the complete agreement concerning subject matter +hereof. If any provision of this License is held to be unenforceable, such +provision shall be reformed only to the extent necessary to make it +enforceable. This License shall be governed by California law provisions +(except to the extent applicable law, if any, provides otherwise), excluding +its conflict-of-law provisions. With respect to disputes in which at least one +party is a citizen of, or an entity chartered or registered to do business in +the United States of America, any litigation relating to this License shall be +subject to the jurisdiction of the Federal Courts of the Northern District of +California, with venue lying in Santa Clara County, California, with the +losing party responsible for costs, including without limitation, court costs +and reasonable attorneys' fees and expenses. The application of the United +Nations Convention on Contracts for the International Sale of Goods is +expressly excluded. Any law or regulation which provides that the language of +a contract shall be construed against the drafter shall not apply to this +License. + +12. RESPONSIBILITY FOR CLAIMS. + + As between Initial Developer and the Contributors, each party is +responsible for claims and damages arising, directly or indirectly, out of its +utilization of rights under this License and You agree to work with Initial +Developer and Contributors to distribute such responsibility on an equitable +basis. Nothing herein is intended or shall be deemed to constitute any +admission of liability. + +13. MULTIPLE-LICENSED CODE. + + Initial Developer may designate portions of the Covered Code as +Multiple-Licensed. Multiple-Licensed means that the Initial Developer permits +you to utilize portions of the Covered Code under Your choice of the MPL or +the alternative licenses, if any, specified by the Initial Developer in the +file described in Exhibit A. + + +EXHIBIT A -Mozilla Public License. + + ``The contents of this file are subject to the Mozilla Public License +Version 1.1 (the "License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + http://www.mozilla.org/MPL/ + + Software distributed under the License is distributed on an "AS IS" +basis, WITHOUT WARRANTY OF + ANY KIND, either express or implied. See the License for the specific +language governing rights and + limitations under the License. + + The Original Code is ______________________________________. + + The Initial Developer of the Original Code is ________________________. +Portions created by + ______________________ are Copyright (C) ______ +_______________________. All Rights + Reserved. + + Contributor(s): ______________________________________. + + Alternatively, the contents of this file may be used under the terms of +the _____ license (the [___] License), in which case the provisions of +[______] License are applicable instead of those above. If you wish to allow +use of your version of this file only under the terms of the [____] License +and not to allow others to use your version of this file under the MPL, +indicate your decision by deleting the provisions above and replace them +with the notice and other provisions required by the [___] License. If you do +not delete the provisions above, a recipient may use your version of this file +under either the MPL or the [___] License." + + [NOTE: The text of this Exhibit A may differ slightly from the text of +the notices in the Source Code files of the Original Code. You should use the +text of this Exhibit A rather than the text found in the Original Code Source +Code for Your Modifications.] + + +=============================================================================== + +For the JAX-WS Reference Implementation component: + +COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 + + + 1. Definitions. + + 1.1. "Contributor" means each individual or entity that + creates or contributes to the creation of Modifications. + + 1.2. "Contributor Version" means the combination of the + Original Software, prior Modifications used by a + Contributor (if any), and the Modifications made by that + particular Contributor. + + 1.3. "Covered Software" means (a) the Original Software, or + (b) Modifications, or (c) the combination of files + containing Original Software with files containing + Modifications, in each case including portions thereof. + + 1.4. "Executable" means the Covered Software in any form + other than Source Code. + + 1.5. "Initial Developer" means the individual or entity + that first makes Original Software available under this + License. + + 1.6. "Larger Work" means a work which combines Covered + Software or portions thereof with code not governed by the + terms of this License. + + 1.7. "License" means this document. + + 1.8. "Licensable" means having the right to grant, to the + maximum extent possible, whether at the time of the initial + grant or subsequently acquired, any and all of the rights + conveyed herein. + + 1.9. "Modifications" means the Source Code and Executable + form of any of the following: + + A. Any file that results from an addition to, + deletion from or modification of the contents of a + file containing Original Software or previous + Modifications; + + B. Any new file that contains any part of the + Original Software or previous Modification; or + + C. Any new file that is contributed or otherwise made + available under the terms of this License. + + 1.10. "Original Software" means the Source Code and + Executable form of computer software code that is + originally released under this License. + + 1.11. "Patent Claims" means any patent claim(s), now owned + or hereafter acquired, including without limitation, + method, process, and apparatus claims, in any patent + Licensable by grantor. + + 1.12. "Source Code" means (a) the common form of computer + software code in which modifications are made and (b) + associated documentation included in or with such code. + + 1.13. "You" (or "Your") means an individual or a legal + entity exercising rights under, and complying with all of + the terms of, this License. For legal entities, "You" + includes any entity which controls, is controlled by, or is + under common control with You. For purposes of this + definition, "control" means (a) the power, direct or + indirect, to cause the direction or management of such + entity, whether by contract or otherwise, or (b) ownership + of more than fifty percent (50%) of the outstanding shares + or beneficial ownership of such entity. + + 2. License Grants. + + 2.1. The Initial Developer Grant. + + Conditioned upon Your compliance with Section 3.1 below and + subject to third party intellectual property claims, the + Initial Developer hereby grants You a world-wide, + royalty-free, non-exclusive license: + + (a) under intellectual property rights (other than + patent or trademark) Licensable by Initial Developer, + to use, reproduce, modify, display, perform, + sublicense and distribute the Original Software (or + portions thereof), with or without Modifications, + and/or as part of a Larger Work; and + + (b) under Patent Claims infringed by the making, + using or selling of Original Software, to make, have + made, use, practice, sell, and offer for sale, and/or + otherwise dispose of the Original Software (or + portions thereof). + + (c) The licenses granted in Sections 2.1(a) and (b) + are effective on the date Initial Developer first + distributes or otherwise makes the Original Software + available to a third party under the terms of this + License. + + (d) Notwithstanding Section 2.1(b) above, no patent + license is granted: (1) for code that You delete from + the Original Software, or (2) for infringements + caused by: (i) the modification of the Original + Software, or (ii) the combination of the Original + Software with other software or devices. + + 2.2. Contributor Grant. + + Conditioned upon Your compliance with Section 3.1 below and + subject to third party intellectual property claims, each + Contributor hereby grants You a world-wide, royalty-free, + non-exclusive license: + + (a) under intellectual property rights (other than + patent or trademark) Licensable by Contributor to + use, reproduce, modify, display, perform, sublicense + and distribute the Modifications created by such + Contributor (or portions thereof), either on an + unmodified basis, with other Modifications, as + Covered Software and/or as part of a Larger Work; and + + + (b) under Patent Claims infringed by the making, + using, or selling of Modifications made by that + Contributor either alone and/or in combination with + its Contributor Version (or portions of such + combination), to make, use, sell, offer for sale, + have made, and/or otherwise dispose of: (1) + Modifications made by that Contributor (or portions + thereof); and (2) the combination of Modifications + made by that Contributor with its Contributor Version + (or portions of such combination). + + (c) The licenses granted in Sections 2.2(a) and + 2.2(b) are effective on the date Contributor first + distributes or otherwise makes the Modifications + available to a third party. + + (d) Notwithstanding Section 2.2(b) above, no patent + license is granted: (1) for any code that Contributor + has deleted from the Contributor Version; (2) for + infringements caused by: (i) third party + modifications of Contributor Version, or (ii) the + combination of Modifications made by that Contributor + with other software (except as part of the + Contributor Version) or other devices; or (3) under + Patent Claims infringed by Covered Software in the + absence of Modifications made by that Contributor. + + 3. Distribution Obligations. + + 3.1. Availability of Source Code. + + Any Covered Software that You distribute or otherwise make + available in Executable form must also be made available in + Source Code form and that Source Code form must be + distributed only under the terms of this License. You must + include a copy of this License with every copy of the + Source Code form of the Covered Software You distribute or + otherwise make available. You must inform recipients of any + such Covered Software in Executable form as to how they can + obtain such Covered Software in Source Code form in a + reasonable manner on or through a medium customarily used + for software exchange. + + 3.2. Modifications. + + The Modifications that You create or to which You + contribute are governed by the terms of this License. You + represent that You believe Your Modifications are Your + original creation(s) and/or You have sufficient rights to + grant the rights conveyed by this License. + + 3.3. Required Notices. + + You must include a notice in each of Your Modifications + that identifies You as the Contributor of the Modification. + You may not remove or alter any copyright, patent or + trademark notices contained within the Covered Software, or + any notices of licensing or any descriptive text giving + attribution to any Contributor or the Initial Developer. + + 3.4. Application of Additional Terms. + + You may not offer or impose any terms on any Covered + Software in Source Code form that alters or restricts the + applicable version of this License or the recipients' + rights hereunder. You may choose to offer, and to charge a + fee for, warranty, support, indemnity or liability + obligations to one or more recipients of Covered Software. + However, you may do so only on Your own behalf, and not on + behalf of the Initial Developer or any Contributor. You + must make it absolutely clear that any such warranty, + support, indemnity or liability obligation is offered by + You alone, and You hereby agree to indemnify the Initial + Developer and every Contributor for any liability incurred + by the Initial Developer or such Contributor as a result of + warranty, support, indemnity or liability terms You offer. + + + 3.5. Distribution of Executable Versions. + + You may distribute the Executable form of the Covered + Software under the terms of this License or under the terms + of a license of Your choice, which may contain terms + different from this License, provided that You are in + compliance with the terms of this License and that the + license for the Executable form does not attempt to limit + or alter the recipient's rights in the Source Code form + from the rights set forth in this License. If You + distribute the Covered Software in Executable form under a + different license, You must make it absolutely clear that + any terms which differ from this License are offered by You + alone, not by the Initial Developer or Contributor. You + hereby agree to indemnify the Initial Developer and every + Contributor for any liability incurred by the Initial + Developer or such Contributor as a result of any such terms + You offer. + + 3.6. Larger Works. + + You may create a Larger Work by combining Covered Software + with other code not governed by the terms of this License + and distribute the Larger Work as a single product. In such + a case, You must make sure the requirements of this License + are fulfilled for the Covered Software. + + 4. Versions of the License. + + 4.1. New Versions. + + Sun Microsystems, Inc. is the initial license steward and + may publish revised and/or new versions of this License + from time to time. Each version will be given a + distinguishing version number. Except as provided in + Section 4.3, no one other than the license steward has the + right to modify this License. + + 4.2. Effect of New Versions. + + You may always continue to use, distribute or otherwise + make the Covered Software available under the terms of the + version of the License under which You originally received + the Covered Software. If the Initial Developer includes a + notice in the Original Software prohibiting it from being + distributed or otherwise made available under any + subsequent version of the License, You must distribute and + make the Covered Software available under the terms of the + version of the License under which You originally received + the Covered Software. Otherwise, You may also choose to + use, distribute or otherwise make the Covered Software + available under the terms of any subsequent version of the + License published by the license steward. + + 4.3. Modified Versions. + + When You are an Initial Developer and You want to create a + new license for Your Original Software, You may create and + use a modified version of this License if You: (a) rename + the license and remove any references to the name of the + license steward (except to note that the license differs + from this License); and (b) otherwise make it clear that + the license contains terms which differ from this License. + + + 5. DISCLAIMER OF WARRANTY. + + COVERED SOFTWARE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" + BASIS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, + INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE COVERED + SOFTWARE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR + PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND + PERFORMANCE OF THE COVERED SOFTWARE IS WITH YOU. SHOULD ANY + COVERED SOFTWARE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE + INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF + ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF + WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF + ANY COVERED SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS + DISCLAIMER. + + 6. TERMINATION. + + 6.1. This License and the rights granted hereunder will + terminate automatically if You fail to comply with terms + herein and fail to cure such breach within 30 days of + becoming aware of the breach. Provisions which, by their + nature, must remain in effect beyond the termination of + this License shall survive. + + 6.2. If You assert a patent infringement claim (excluding + declaratory judgment actions) against Initial Developer or + a Contributor (the Initial Developer or Contributor against + whom You assert such claim is referred to as "Participant") + alleging that the Participant Software (meaning the + Contributor Version where the Participant is a Contributor + or the Original Software where the Participant is the + Initial Developer) directly or indirectly infringes any + patent, then any and all rights granted directly or + indirectly to You by such Participant, the Initial + Developer (if the Initial Developer is not the Participant) + and all Contributors under Sections 2.1 and/or 2.2 of this + License shall, upon 60 days notice from Participant + terminate prospectively and automatically at the expiration + of such 60 day notice period, unless if within such 60 day + period You withdraw Your claim with respect to the + Participant Software against such Participant either + unilaterally or pursuant to a written agreement with + Participant. + + 6.3. In the event of termination under Sections 6.1 or 6.2 + above, all end user licenses that have been validly granted + by You or any distributor hereunder prior to termination + (excluding licenses granted to You by any distributor) + shall survive termination. + + 7. LIMITATION OF LIABILITY. + + UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT + (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE + INITIAL DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF + COVERED SOFTWARE, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE + LIABLE TO ANY PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR + CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT + LIMITATION, DAMAGES FOR LOST PROFITS, LOSS OF GOODWILL, WORK + STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER + COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN + INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF + LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL + INJURY RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT + APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO + NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR + CONSEQUENTIAL DAMAGES, SO THIS EXCLUSION AND LIMITATION MAY NOT + APPLY TO YOU. + + 8. U.S. GOVERNMENT END USERS. + + The Covered Software is a "commercial item," as that term is + defined in 48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial + computer software" (as that term is defined at 48 C.F.R. + 252.227-7014(a)(1)) and "commercial computer software + documentation" as such terms are used in 48 C.F.R. 12.212 (Sept. + 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1 + through 227.7202-4 (June 1995), all U.S. Government End Users + acquire Covered Software with only those rights set forth herein. + This U.S. Government Rights clause is in lieu of, and supersedes, + any other FAR, DFAR, or other clause or provision that addresses + Government rights in computer software under this License. + + 9. MISCELLANEOUS. + + This License represents the complete agreement concerning subject + matter hereof. If any provision of this License is held to be + unenforceable, such provision shall be reformed only to the + extent necessary to make it enforceable. This License shall be + governed by the law of the jurisdiction specified in a notice + contained within the Original Software (except to the extent + applicable law, if any, provides otherwise), excluding such + jurisdiction's conflict-of-law provisions. Any litigation + relating to this License shall be subject to the jurisdiction of + the courts located in the jurisdiction and venue specified in a + notice contained within the Original Software, with the losing + party responsible for costs, including, without limitation, court + costs and reasonable attorneys' fees and expenses. The + application of the United Nations Convention on Contracts for the + International Sale of Goods is expressly excluded. Any law or + regulation which provides that the language of a contract shall + be construed against the drafter shall not apply to this License. + You agree that You alone are responsible for compliance with the + United States export administration regulations (and the export + control laws and regulation of any other countries) when You use, + distribute or otherwise make available any Covered Software. + + 10. RESPONSIBILITY FOR CLAIMS. + + As between Initial Developer and the Contributors, each party is + responsible for claims and damages arising, directly or + indirectly, out of its utilization of rights under this License + and You agree to work with Initial Developer and Contributors to + distribute such responsibility on an equitable basis. Nothing + herein is intended or shall be deemed to constitute any admission + of liability. + diff --git a/sandbox/rfeng/samples/creditws/src/main/resources/META-INF/NOTICE b/sandbox/rfeng/samples/creditws/src/main/resources/META-INF/NOTICE new file mode 100644 index 0000000000..11c564eb19 --- /dev/null +++ b/sandbox/rfeng/samples/creditws/src/main/resources/META-INF/NOTICE @@ -0,0 +1,18 @@ +========================================================================= +== NOTICE file corresponding to the section 4 d of == +== the Apache License, Version 2.0, == +== in this case for the Apache Tuscany distribution. == +========================================================================= + +This product includes software developed by the Apache Software Foundation +(http://www.apache.org/). + +This product also includes software developed by: +- the Eclipse Modeling Framework project (http://www.eclipse.org/emf/) +- the Celtix project (http://celtix.objectweb.org/) +- the Mozilla Rhino project (http://www.mozilla.org/rhino/) +- the GlassFish JAX-WS project (https://jax-ws.dev.java.net/) + +Please read the LICENSE.txt file present in the root directory of this +distribution. + diff --git a/sandbox/rfeng/samples/creditws/src/main/resources/META-INF/README.txt b/sandbox/rfeng/samples/creditws/src/main/resources/META-INF/README.txt new file mode 100644 index 0000000000..9b26d1690a --- /dev/null +++ b/sandbox/rfeng/samples/creditws/src/main/resources/META-INF/README.txt @@ -0,0 +1,35 @@ +Apache Tuscany M1 build (May, 2006) +=================================== + +http://incubator.apache.org/tuscany/ + +Tuscany is an effort undergoing incubation at the Apache Software Foundation +(ASF), sponsored by the Web Services PMC. + +Incubation is required of all newly accepted projects until a further review +indicates that the infrastructure, communications, and decision making process +have stabilized in a manner consistent with other successful ASF projects. + +While incubation status is not necessarily a reflection of the completeness or +stability of the code, it does indicate that the project has yet to be fully +endorsed by the ASF. + + +Support +------- + +Any problem with this release can be reported to the Tuscany mailing list +or in the JIRA issue tracker. + +Mailing list subscription: + tuscany-dev-subscribe@ws.apache.org + +Jira: + http://issues.apache.org/jira/browse/Tuscany + + +Thank you for using Tuscany! + + +The Tuscany Team. + diff --git a/sandbox/rfeng/samples/creditws/src/main/resources/wsdl/credit.wsdl b/sandbox/rfeng/samples/creditws/src/main/resources/wsdl/credit.wsdl new file mode 100644 index 0000000000..d484a5e90c --- /dev/null +++ b/sandbox/rfeng/samples/creditws/src/main/resources/wsdl/credit.wsdl @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/rfeng/samples/creditws/src/main/webapp/META-INF/tuscany/webapp.scdl b/sandbox/rfeng/samples/creditws/src/main/webapp/META-INF/tuscany/webapp.scdl new file mode 100644 index 0000000000..50688615a6 --- /dev/null +++ b/sandbox/rfeng/samples/creditws/src/main/webapp/META-INF/tuscany/webapp.scdl @@ -0,0 +1,139 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 10 + + + + + + + + + + + + + + + + + + + + + + http://repo1.maven.org/maven2/,http://people.apache.org/repo/m2-snapshot-repository,http://people.apache.org/repo/m2-incubating-repository/,http://people.apache.org/repo/m1-snapshot-repository/ + + + + + /WEB-INF/tuscany/extensions/ + + diff --git a/sandbox/rfeng/samples/creditws/src/main/webapp/WEB-INF/default.scdl b/sandbox/rfeng/samples/creditws/src/main/webapp/WEB-INF/default.scdl new file mode 100644 index 0000000000..5f01cb534e --- /dev/null +++ b/sandbox/rfeng/samples/creditws/src/main/webapp/WEB-INF/default.scdl @@ -0,0 +1,35 @@ + + + + + + + + + CreditCheckServiceComponent + + + + + + + diff --git a/sandbox/rfeng/samples/creditws/src/main/webapp/WEB-INF/web.xml b/sandbox/rfeng/samples/creditws/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..22d4a55a4c --- /dev/null +++ b/sandbox/rfeng/samples/creditws/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,41 @@ + + + + + + Tuscany Credit Check Web Service Sample + + + org.apache.tuscany.runtime.webapp.TuscanyContextListener + + + + TuscanyServlet + Tuscany Servlet + org.apache.tuscany.runtime.webapp.TuscanyServlet + + + + TuscanyServlet + /services/* + + + diff --git a/sandbox/rfeng/samples/echo.databinding/.ruleset b/sandbox/rfeng/samples/echo.databinding/.ruleset new file mode 100644 index 0000000000..42a6f1be38 --- /dev/null +++ b/sandbox/rfeng/samples/echo.databinding/.ruleset @@ -0,0 +1,190 @@ + + + + PMD Plugin preferences rule set + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/rfeng/samples/echo.databinding/NOTICE.txt b/sandbox/rfeng/samples/echo.databinding/NOTICE.txt new file mode 100644 index 0000000000..d83ebbe236 --- /dev/null +++ b/sandbox/rfeng/samples/echo.databinding/NOTICE.txt @@ -0,0 +1,14 @@ +${pom.name} +Copyright (c) 2005 - 2006 The Apache Software Foundation + +Apache Tuscany is an effort undergoing incubation at The Apache Software +Foundation (ASF), sponsored by the Apache Web Services PMC. Incubation is +required of all newly accepted projects until a further review indicates that +the infrastructure, communications, and decision making process have stabilized +in a manner consistent with other successful ASF projects. While incubation +status is not necessarily a reflection of the completeness or stability of the +code, it does indicate that the project has yet to be fully endorsed by the ASF. + +This product includes software developed by +The Apache Software Foundation (http://www.apache.org/). + diff --git a/sandbox/rfeng/samples/echo.databinding/pom.xml b/sandbox/rfeng/samples/echo.databinding/pom.xml new file mode 100644 index 0000000000..c8f7ab71ed --- /dev/null +++ b/sandbox/rfeng/samples/echo.databinding/pom.xml @@ -0,0 +1,112 @@ + + + + + org.apache.tuscany.sca + integration-test + 1.0-incubating-SNAPSHOT + ../pom.xml + + + 4.0.0 + org.apache.tuscany.samples.sca + sample-echo-databinding + 1.0-incubating-SNAPSHOT + Echo DataBinding + A Sample for DataBinding + + + + org.osoa + sca-api + 1.0-incubating-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-assembly + 1.0-incubating-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-interface-wsdl + 1.0-incubating-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-core-databinding + 1.0-incubating-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-core-spi + 1.0-incubating-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.0-incubating-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.0-incubating-SNAPSHOT + runtime + + + + org.apache.ws.commons.axiom + axiom-api + 1.2.2 + compile + + + + org.apache.ws.commons.axiom + axiom-impl + 1.2.2 + runtime + + + org.codehaus.woodstox + wstx-asl + 3.2.0 + runtime + + + junit + junit + 4.2 + test + + + commons-logging + commons-logging + 1.1 + runtime + + + + diff --git a/sandbox/rfeng/samples/echo.databinding/src/main/resources/META-INF/sca/binding.echo.scdl b/sandbox/rfeng/samples/echo.databinding/src/main/resources/META-INF/sca/binding.echo.scdl new file mode 100644 index 0000000000..39f56b48ad --- /dev/null +++ b/sandbox/rfeng/samples/echo.databinding/src/main/resources/META-INF/sca/binding.echo.scdl @@ -0,0 +1,31 @@ + + + + + + + + + + + + + diff --git a/sandbox/rfeng/samples/echo.databinding/src/test/java/echo/ComponentAImpl.java b/sandbox/rfeng/samples/echo.databinding/src/test/java/echo/ComponentAImpl.java new file mode 100644 index 0000000000..84466f90d0 --- /dev/null +++ b/sandbox/rfeng/samples/echo.databinding/src/test/java/echo/ComponentAImpl.java @@ -0,0 +1,94 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package echo; + +import org.apache.axiom.om.OMElement; +import org.osoa.sca.annotations.Constructor; +import org.osoa.sca.annotations.Property; +import org.osoa.sca.annotations.Reference; + +/** + * @version $Rev$ $Date$ + */ +public class ComponentAImpl implements Interface1 { + + private Interface1 componentBReference; + + private String prefix; + + private String prefix1; + + private String bar; + + private OMElement omProperty; + + @Constructor + public ComponentAImpl(@Reference(name = "componentBReference", required = true) + Interface1 componentBReference) { + this.componentBReference = componentBReference; + } + + public Object call(Object msg) { + String request = msg + " [" + msg.getClass().getName() + "]"; + System.out.println("ComponentA --> Received message: " + request); + Object ret = componentBReference.call(msg); + String response = ret + " [" + ret.getClass().getName() + "]"; + System.out.println("ComponentA --> Returned message: " + response); + return ret; + } + + public Object call1(Object msg) { + String request = msg + " [" + msg.getClass().getName() + "]"; + System.out.println("ComponentA --> Received message: " + request); + Object ret = componentBReference.call1(msg); + String response = ret + " [" + ret.getClass().getName() + "]"; + System.out.println("ComponentA --> Returned message: " + response); + return ret; + } + + @Property(name="prefix") + public void setPrefix(String prefix) { + System.out.println("[Property] prefix: " + prefix); + this.prefix = prefix; + } + + @Property(name="prefix1") + public void setPrefix1(String prefix1) { + System.out.println("[Property] prefix1: " + prefix1); + this.prefix1 = prefix1; + } + + /** + * @param bar the bar to set + */ + @Property(name="bar") + public void setBar(String bar) { + System.out.println("[Property] bar: " + bar); + this.bar = bar; + } + + /** + * @param omProperty the omProperty to set + */ + @Property(name="omProperty") + public void setOmProperty(OMElement omProperty) { + this.omProperty = omProperty; + } + +} diff --git a/sandbox/rfeng/samples/echo.databinding/src/test/java/echo/ComponentBImpl.java b/sandbox/rfeng/samples/echo.databinding/src/test/java/echo/ComponentBImpl.java new file mode 100644 index 0000000000..f8783d39e9 --- /dev/null +++ b/sandbox/rfeng/samples/echo.databinding/src/test/java/echo/ComponentBImpl.java @@ -0,0 +1,59 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package echo; + +import javax.xml.stream.XMLStreamReader; + +import org.osoa.sca.annotations.AllowsPassByReference; +import org.osoa.sca.annotations.Constructor; +import org.osoa.sca.annotations.Reference; +import org.w3c.dom.Node; + +/** + * @version $Rev$ $Date$ + */ +@AllowsPassByReference +public class ComponentBImpl implements Interface2 { + + private Echo echoReference; + + @Constructor + public ComponentBImpl(@Reference(name = "echoReference", required = true) + Echo echoReference) { + this.echoReference = echoReference; + } + + public Node call(Node msg) { + String request = msg + " [" + msg.getClass().getName() + "]"; + System.out.println("ComponentB --> Received message: " + request); + Node ret = (Node) echoReference.echo(msg); + String response = ret + " [" + ret.getClass().getName() + "]"; + System.out.println("ComponentB --> Returned message: " + response); + return ret; + } + + public XMLStreamReader call1(XMLStreamReader msg) { + String request = msg + " [" + msg.getClass().getName() + "]"; + System.out.println("ComponentB --> Received message: " + request); +// XMLStreamReader ret = (XMLStreamReader) echoReference.echo(msg); + String response = request; + System.out.println("ComponentB --> Returned message: " + response); + return msg; + } +} diff --git a/sandbox/rfeng/samples/echo.databinding/src/test/java/echo/DataBindingITest.java b/sandbox/rfeng/samples/echo.databinding/src/test/java/echo/DataBindingITest.java new file mode 100644 index 0000000000..0be318fe07 --- /dev/null +++ b/sandbox/rfeng/samples/echo.databinding/src/test/java/echo/DataBindingITest.java @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package echo; + +import junit.framework.TestCase; + +import org.apache.tuscany.api.SCARuntime; +import org.osoa.sca.ComponentContext; +import org.osoa.sca.ServiceReference; + +/** + * @version $Rev$ $Date$ + */ +public class DataBindingITest extends TestCase { + + @Override + protected void setUp() throws Exception { + SCARuntime.start(); + } + + @Override + protected void tearDown() throws Exception { + SCARuntime.stop(); + } + + protected Interface1 componentA; + + public void testTransform() { + ComponentContext context = SCARuntime.getComponentContext("ComponentA"); + ServiceReference ref = context.createSelfReference(Interface1.class); + componentA = ref.getService(); + componentA.call("123"); + componentA.call1("123"); + } +} diff --git a/sandbox/rfeng/samples/echo.databinding/src/test/java/echo/Echo.java b/sandbox/rfeng/samples/echo.databinding/src/test/java/echo/Echo.java new file mode 100644 index 0000000000..434b7371a8 --- /dev/null +++ b/sandbox/rfeng/samples/echo.databinding/src/test/java/echo/Echo.java @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package echo; + +import org.apache.tuscany.databinding.annotation.DataBinding; +import org.osoa.sca.annotations.Remotable; + +/** + * @version $Rev$ $Date$ + */ +// @DataType(name="org.apache.axiom.om.OMElement") +@DataBinding("org.w3c.dom.Node") +@Remotable +public interface Echo { + Object echo(Object msg); +} diff --git a/sandbox/rfeng/samples/echo.databinding/src/test/java/echo/Interface1.java b/sandbox/rfeng/samples/echo.databinding/src/test/java/echo/Interface1.java new file mode 100644 index 0000000000..b48213060c --- /dev/null +++ b/sandbox/rfeng/samples/echo.databinding/src/test/java/echo/Interface1.java @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package echo; + +import org.apache.tuscany.databinding.annotation.DataBinding; +import org.osoa.sca.annotations.Remotable; + +/** + * @version $Rev$ $Date$ + */ +@DataBinding("java.lang.String") +@Remotable +public interface Interface1 { + Object call(Object msg); + Object call1(Object msg); +} diff --git a/sandbox/rfeng/samples/echo.databinding/src/test/java/echo/Interface2.java b/sandbox/rfeng/samples/echo.databinding/src/test/java/echo/Interface2.java new file mode 100644 index 0000000000..293b613f44 --- /dev/null +++ b/sandbox/rfeng/samples/echo.databinding/src/test/java/echo/Interface2.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package echo; + +import javax.xml.stream.XMLStreamReader; + +import org.apache.tuscany.databinding.annotation.DataBinding; +import org.osoa.sca.annotations.Remotable; +import org.w3c.dom.Node; + +/** + * @version $Rev$ $Date$ + */ +@DataBinding("org.w3c.dom.Node") +@Remotable +public interface Interface2 { + Node call(Node msg); + @DataBinding("javax.xml.stream.XMLStreamReader") + XMLStreamReader call1(XMLStreamReader msg); +} diff --git a/sandbox/rfeng/samples/echo.databinding/src/test/resources/wsdl/echo.wsdl b/sandbox/rfeng/samples/echo.databinding/src/test/resources/wsdl/echo.wsdl new file mode 100644 index 0000000000..5749bd8aff --- /dev/null +++ b/sandbox/rfeng/samples/echo.databinding/src/test/resources/wsdl/echo.wsdl @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sandbox/rfeng/samples/mortgage/pom.xml b/sandbox/rfeng/samples/mortgage/pom.xml new file mode 100644 index 0000000000..f64d39f120 --- /dev/null +++ b/sandbox/rfeng/samples/mortgage/pom.xml @@ -0,0 +1,142 @@ + + + + + org.apache.tuscany.samples.sca + parent + 1.0-incubator-SNAPSHOT + + 4.0.0 + sample-mortgage + jar + Tuscany Mortgage Sample + A sample Mortgage application made of several SCA components wired together. + + + 1.0-incubator-SNAPSHOT + + + + + org.osoa + sca-api-r0.95 + ${tuscanyVersion} + + + org.apache.tuscany.sca + test + ${tuscanyVersion} + test + + + org.apache.tuscany.sca.services.containers + javascript + ${tuscanyVersion} + runtime + + + org.apache.tuscany.sca.services.bindings + axis2 + ${tuscanyVersion} + runtime + + + org.apache.tuscany.sca.services.databinding + databinding-axiom + ${tuscanyVersion} + runtime + + + org.apache.tuscany.samples.sca + sample-creditws + ${tuscanyVersion} + war + provided + + + + + install + ${artifactId} + + + org.apache.maven.plugins + maven-jar-plugin + + + + mortgage.MortgageClient + + + + + + org.codehaus.cargo + cargo-maven2-plugin + + + start-container + pre-integration-test + + start + + + + stop-container + post-integration-test + + stop + + + + + + false + + + + tomcat5x + C:/Apache/apache-tomcat-5.5.20 + + + + + + + ${project.build.directory}/tomcat5x + + + org.apache.tuscany.samples.sca + sample-creditws + war + + + + + + + + + diff --git a/sandbox/rfeng/samples/mortgage/src/main/java/mortgage/CreditCheck.java b/sandbox/rfeng/samples/mortgage/src/main/java/mortgage/CreditCheck.java new file mode 100644 index 0000000000..c5787b7819 --- /dev/null +++ b/sandbox/rfeng/samples/mortgage/src/main/java/mortgage/CreditCheck.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package mortgage; + +import org.osoa.sca.annotations.Remotable; + +/** + * CreditCheck interface + */ +@Remotable +public interface CreditCheck { + int getCreditScore(String ssn); +} diff --git a/sandbox/rfeng/samples/mortgage/src/main/java/mortgage/CreditCheckImpl.java b/sandbox/rfeng/samples/mortgage/src/main/java/mortgage/CreditCheckImpl.java new file mode 100644 index 0000000000..86fe88b417 --- /dev/null +++ b/sandbox/rfeng/samples/mortgage/src/main/java/mortgage/CreditCheckImpl.java @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package mortgage; + +import org.osoa.sca.annotations.Service; + +/** + * A pojo implementation of the CreditCheck service + */ +@Service(CreditCheck.class) +public class CreditCheckImpl implements CreditCheck { + + public int getCreditScore(String ssn) { + return (int) (700 + (Math.random() - 0.5) * 100); + } +} diff --git a/sandbox/rfeng/samples/mortgage/src/main/java/mortgage/Customer.java b/sandbox/rfeng/samples/mortgage/src/main/java/mortgage/Customer.java new file mode 100644 index 0000000000..a8b23c6019 --- /dev/null +++ b/sandbox/rfeng/samples/mortgage/src/main/java/mortgage/Customer.java @@ -0,0 +1,75 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package mortgage; + +/** + * A simple Customer object + */ +public class Customer { + private String ssn; + private String firstName; + private String lastName; + private double monthlyIncome; + private String state; + + public double getMonthlyIncome() { + return monthlyIncome; + } + + public void setMonthlyIncome(double monthlyIncome) { + this.monthlyIncome = monthlyIncome; + } + + public String getState() { + return state; + } + + public void setState(String state) { + this.state = state; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public String getSsn() { + return ssn; + } + + public void setSsn(String ssn) { + this.ssn = ssn; + } + + public String toString() { + return firstName + " " + lastName + "[" + ssn + "]"; + } +} diff --git a/sandbox/rfeng/samples/mortgage/src/main/java/mortgage/InterestRateQuote.java b/sandbox/rfeng/samples/mortgage/src/main/java/mortgage/InterestRateQuote.java new file mode 100644 index 0000000000..b5bafeb204 --- /dev/null +++ b/sandbox/rfeng/samples/mortgage/src/main/java/mortgage/InterestRateQuote.java @@ -0,0 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package mortgage; + +public interface InterestRateQuote { + public float getRate(String state, double loanAmount, int termInYears); +} diff --git a/sandbox/rfeng/samples/mortgage/src/main/java/mortgage/InterestRateQuoteImpl.java b/sandbox/rfeng/samples/mortgage/src/main/java/mortgage/InterestRateQuoteImpl.java new file mode 100644 index 0000000000..93054a2491 --- /dev/null +++ b/sandbox/rfeng/samples/mortgage/src/main/java/mortgage/InterestRateQuoteImpl.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package mortgage; + +import org.osoa.sca.annotations.Service; + +@Service(InterestRateQuote.class) +public class InterestRateQuoteImpl implements InterestRateQuote { + public float getRate(String state, double loanAmount, int termInYears) { + if (termInYears == 5) + return 5.5f; + else + return 6.5f; + } +} diff --git a/sandbox/rfeng/samples/mortgage/src/main/java/mortgage/LoanApproval.java b/sandbox/rfeng/samples/mortgage/src/main/java/mortgage/LoanApproval.java new file mode 100644 index 0000000000..dcdad18496 --- /dev/null +++ b/sandbox/rfeng/samples/mortgage/src/main/java/mortgage/LoanApproval.java @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package mortgage; + +/** + * Loan Approval interface + */ +public interface LoanApproval { + public boolean approve(Customer customer, double loanAmount, int years); +} diff --git a/sandbox/rfeng/samples/mortgage/src/main/java/mortgage/LoanApprovalImpl.java b/sandbox/rfeng/samples/mortgage/src/main/java/mortgage/LoanApprovalImpl.java new file mode 100644 index 0000000000..0283e5826d --- /dev/null +++ b/sandbox/rfeng/samples/mortgage/src/main/java/mortgage/LoanApprovalImpl.java @@ -0,0 +1,72 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package mortgage; + +import org.osoa.sca.annotations.Property; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Service; + +/** + * An implementation of the LoanApproval service. + */ +@Service(LoanApproval.class) // Service declaration +public class LoanApprovalImpl implements LoanApproval { + private CreditCheck[] creditCheck; + private MortgageCalculator mortgageCalculator; + private InterestRateQuote interestRateQuote; + + // Reference declaration using a protected or public field + @Reference + public RiskAssessment riskAssessment; + + private int minimumCreditScore = 650; + + // Property declaration using a setter method + @Property(name = "minimumCreditScore", override = "may") + public void setMinimumCreditScore(int minimumCreditScore) { + this.minimumCreditScore = minimumCreditScore; + } + + // Reference declaration using a setter method + @Reference + public void setCreditCheck(CreditCheck[] creditCheck) { + this.creditCheck = creditCheck; + } + + @Reference + public void setInterestRateQuote(InterestRateQuote interestRateQuote) { + this.interestRateQuote = interestRateQuote; + } + + @Reference + public void setMortgageCalculator(MortgageCalculator mortgageCalculator) { + this.mortgageCalculator = mortgageCalculator; + } + + public boolean approve(Customer customer, double loanAmount, int years) { + int score = creditCheck[0].getCreditScore(customer.getSsn()); + if (score < minimumCreditScore) { + return false; + } + float rate = interestRateQuote.getRate(customer.getState(), loanAmount, years); + double monthlyPayment = mortgageCalculator.getMonthlyPayment(loanAmount, years, rate); + double ratio = monthlyPayment / customer.getMonthlyIncome(); + return riskAssessment.assess(score, ratio); + } +} diff --git a/sandbox/rfeng/samples/mortgage/src/main/java/mortgage/MortgageCalculator.java b/sandbox/rfeng/samples/mortgage/src/main/java/mortgage/MortgageCalculator.java new file mode 100644 index 0000000000..cacd8694de --- /dev/null +++ b/sandbox/rfeng/samples/mortgage/src/main/java/mortgage/MortgageCalculator.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package mortgage; + +import org.osoa.sca.annotations.Remotable; + +/** + * The Mortgage Calculator service interface. + */ +@Remotable +public interface MortgageCalculator { + public double getMonthlyPayment(double principal, int years, float interestRate); +} diff --git a/sandbox/rfeng/samples/mortgage/src/main/java/mortgage/MortgageCalculatorImpl.java b/sandbox/rfeng/samples/mortgage/src/main/java/mortgage/MortgageCalculatorImpl.java new file mode 100644 index 0000000000..c89830ca84 --- /dev/null +++ b/sandbox/rfeng/samples/mortgage/src/main/java/mortgage/MortgageCalculatorImpl.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package mortgage; + +import org.osoa.sca.annotations.Service; + +/** + * An implementation of the Calculator service. + */ +@Service(MortgageCalculator.class) +public class MortgageCalculatorImpl implements MortgageCalculator { + + public double getMonthlyPayment(double principal, int years, float interestRate) { + double monthlyRate = interestRate / 12.0 / 100.0; + double p = Math.pow(1 + monthlyRate, years * 12); + double q = p / (p - 1); + double monthlyPayment = principal * monthlyRate * q; + return monthlyPayment; + } + +} diff --git a/sandbox/rfeng/samples/mortgage/src/main/java/mortgage/MortgageClient.java b/sandbox/rfeng/samples/mortgage/src/main/java/mortgage/MortgageClient.java new file mode 100644 index 0000000000..7e89ffeab6 --- /dev/null +++ b/sandbox/rfeng/samples/mortgage/src/main/java/mortgage/MortgageClient.java @@ -0,0 +1,46 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package mortgage; + +import org.osoa.sca.CompositeContext; +import org.osoa.sca.CurrentCompositeContext; + +/** + * This client program to invoke the Mortgage LoanApproval service + */ +public class MortgageClient { + public static void main(String[] args) throws Exception { + + // Locate the service using SCA APIs + CompositeContext context = CurrentCompositeContext.getContext(); + LoanApproval loanApplication = context.locateService(LoanApproval.class, "LoanApprovalComponent"); + + // Create the customer + Customer customer = new Customer(); + customer.setSsn("111-22-3333"); + customer.setFirstName("John"); + customer.setLastName("Smith"); + customer.setMonthlyIncome(5000.0d); + customer.setState("CA"); + + // Invoke the service + boolean result = loanApplication.approve(customer, 200000d, 30); + System.out.println((result ? "Approved: " : "Rejected: ") + customer); + } +} diff --git a/sandbox/rfeng/samples/mortgage/src/main/java/mortgage/RiskAssessment.java b/sandbox/rfeng/samples/mortgage/src/main/java/mortgage/RiskAssessment.java new file mode 100644 index 0000000000..23c9589e85 --- /dev/null +++ b/sandbox/rfeng/samples/mortgage/src/main/java/mortgage/RiskAssessment.java @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package mortgage; + +/** + * Risk Assessment interface + */ +public interface RiskAssessment { + public boolean assess(int creditScore, double ratio); +} diff --git a/sandbox/rfeng/samples/mortgage/src/main/java/mortgage/RiskAssessmentImpl.java b/sandbox/rfeng/samples/mortgage/src/main/java/mortgage/RiskAssessmentImpl.java new file mode 100644 index 0000000000..8144ef2a7d --- /dev/null +++ b/sandbox/rfeng/samples/mortgage/src/main/java/mortgage/RiskAssessmentImpl.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package mortgage; + +import org.osoa.sca.annotations.Service; + +/** + * A pojo implementation of RiskAssessment service + */ +@Service(RiskAssessment.class) +public class RiskAssessmentImpl implements RiskAssessment { + public boolean assess(int creditScore, double ratio) { + if (creditScore >= 750) + return ratio < 0.35; + else if (creditScore >= 700) + return ratio < 0.30; + else + return ratio < 0.25; + } +} diff --git a/sandbox/rfeng/samples/mortgage/src/main/resources/META-INF/LICENSE.txt b/sandbox/rfeng/samples/mortgage/src/main/resources/META-INF/LICENSE.txt new file mode 100644 index 0000000000..25d78feeac --- /dev/null +++ b/sandbox/rfeng/samples/mortgage/src/main/resources/META-INF/LICENSE.txt @@ -0,0 +1,1277 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + +APACHE TUSCANY SUBCOMPONENTS: + +The Apache Tuscany distribution includes a number of subcomponents with +separate copyright notices and license terms. Your use of the source +code for the these subcomponents is subject to the terms and +conditions of the following licenses. + +=============================================================================== + +For the Eclipse Modeling Framework component and the Celtix binding: + +Eclipse Public License - v 1.0 + +THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE +PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF +THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. + +1. DEFINITIONS + +"Contribution" means: + +a) in the case of the initial Contributor, the initial code and +documentation distributed under this Agreement, and +b) in the case of each subsequent Contributor: + +i) changes to the Program, and + +ii) additions to the Program; + +where such changes and/or additions to the Program originate from and +are distributed by that particular Contributor. A Contribution +'originates' from a Contributor if it was added to the Program by such +Contributor itself or anyone acting on such Contributor's behalf. +Contributions do not include additions to the Program which: (i) are +separate modules of software distributed in conjunction with the +Program under their own license agreement, and (ii) are not derivative +works of the Program. + +"Contributor" means any person or entity that distributes the Program. + +"Licensed Patents " mean patent claims licensable by a Contributor +which are necessarily infringed by the use or sale of its Contribution +alone or when combined with the Program. + +"Program" means the Contributions distributed in accordance with this +Agreement. + +"Recipient" means anyone who receives the Program under this +Agreement, including all Contributors. + +2. GRANT OF RIGHTS + +a) Subject to the terms of this Agreement, each Contributor hereby +grants Recipient a non-exclusive, worldwide, royalty-free copyright +license to reproduce, prepare derivative works of, publicly display, +publicly perform, distribute and sublicense the Contribution of such +Contributor, if any, and such derivative works, in source code and +object code form. + +b) Subject to the terms of this Agreement, each Contributor hereby +grants Recipient a non-exclusive, worldwide, royalty-free patent +license under Licensed Patents to make, use, sell, offer to sell, +import and otherwise transfer the Contribution of such Contributor, if +any, in source code and object code form. This patent license shall +apply to the combination of the Contribution and the Program if, at +the time the Contribution is added by the Contributor, such addition +of the Contribution causes such combination to be covered by the +Licensed Patents. The patent license shall not apply to any other +combinations which include the Contribution. No hardware per se is +licensed hereunder. + +c) Recipient understands that although each Contributor grants the +licenses to its Contributions set forth herein, no assurances are +provided by any Contributor that the Program does not infringe the +patent or other intellectual property rights of any other entity. Each +Contributor disclaims any liability to Recipient for claims brought by +any other entity based on infringement of intellectual property rights +or otherwise. As a condition to exercising the rights and licenses +granted hereunder, each Recipient hereby assumes sole responsibility +to secure any other intellectual property rights needed, if any. For +example, if a third party patent license is required to allow +Recipient to distribute the Program, it is Recipient's responsibility +to acquire that license before distributing the Program. + +d) Each Contributor represents that to its knowledge it has sufficient +copyright rights in its Contribution, if any, to grant the copyright +license set forth in this Agreement. + +3. REQUIREMENTS + +A Contributor may choose to distribute the Program in object code form +under its own license agreement, provided that: + +a) it complies with the terms and conditions of this Agreement; and + +b) its license agreement: + +i) effectively disclaims on behalf of all Contributors all warranties +and conditions, express and implied, including warranties or +conditions of title and non-infringement, and implied warranties or +conditions of merchantability and fitness for a particular purpose; + +ii) effectively excludes on behalf of all Contributors all liability +for damages, including direct, indirect, special, incidental and +consequential damages, such as lost profits; + +iii) states that any provisions which differ from this Agreement are +offered by that Contributor alone and not by any other party; and + +iv) states that source code for the Program is available from such +Contributor, and informs licensees how to obtain it in a reasonable +manner on or through a medium customarily used for software exchange. + +When the Program is made available in source code form: + +a) it must be made available under this Agreement; and + +b) a copy of this Agreement must be included with each copy of the +Program. + +Contributors may not remove or alter any copyright notices contained +within the Program. + +Each Contributor must identify itself as the originator of its +Contribution, if any, in a manner that reasonably allows subsequent +Recipients to identify the originator of the Contribution. + +4. COMMERCIAL DISTRIBUTION + +Commercial distributors of software may accept certain +responsibilities with respect to end users, business partners and the +like. While this license is intended to facilitate the commercial use +of the Program, the Contributor who includes the Program in a +commercial product offering should do so in a manner which does not +create potential liability for other Contributors. Therefore, if a +Contributor includes the Program in a commercial product offering, +such Contributor ("Commercial Contributor") hereby agrees to defend +and indemnify every other Contributor ("Indemnified Contributor") +against any losses, damages and costs (collectively "Losses") arising +from claims, lawsuits and other legal actions brought by a third party +against the Indemnified Contributor to the extent caused by the acts +or omissions of such Commercial Contributor in connection with its +distribution of the Program in a commercial product offering. The +obligations in this section do not apply to any claims or Losses +relating to any actual or alleged intellectual property infringement. +In order to qualify, an Indemnified Contributor must: a) promptly +notify the Commercial Contributor in writing of such claim, and b) +allow the Commercial Contributor to control, and cooperate with the +Commercial Contributor in, the defense and any related settlement +negotiations. The Indemnified Contributor may participate in any such +claim at its own expense. + +For example, a Contributor might include the Program in a commercial +product offering, Product X. That Contributor is then a Commercial +Contributor. If that Commercial Contributor then makes performance +claims, or offers warranties related to Product X, those performance +claims and warranties are such Commercial Contributor's responsibility +alone. Under this section, the Commercial Contributor would have to +defend claims against the other Contributors related to those +performance claims and warranties, and if a court requires any other +Contributor to pay any damages as a result, the Commercial Contributor +must pay those damages. + +5. NO WARRANTY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS +PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY +WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY +OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely +responsible for determining the appropriateness of using and +distributing the Program and assumes all risks associated with its +exercise of rights under this Agreement , including but not limited to +the risks and costs of program errors, compliance with applicable +laws, damage to or loss of data, programs or equipment, and +unavailability or interruption of operations. + +6. DISCLAIMER OF LIABILITY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR +ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING +WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR +DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED +HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +7. GENERAL + +If any provision of this Agreement is invalid or unenforceable under +applicable law, it shall not affect the validity or enforceability of +the remainder of the terms of this Agreement, and without further +action by the parties hereto, such provision shall be reformed to the +minimum extent necessary to make such provision valid and enforceable. + +If Recipient institutes patent litigation against any entity +(including a cross-claim or counterclaim in a lawsuit) alleging that +the Program itself (excluding combinations of the Program with other +software or hardware) infringes such Recipient's patent(s), then such +Recipient's rights granted under Section 2(b) shall terminate as of +the date such litigation is filed. + +All Recipient's rights under this Agreement shall terminate if it +fails to comply with any of the material terms or conditions of this +Agreement and does not cure such failure in a reasonable period of +time after becoming aware of such noncompliance. If all Recipient's +rights under this Agreement terminate, Recipient agrees to cease use +and distribution of the Program as soon as reasonably practicable. +However, Recipient's obligations under this Agreement and any licenses +granted by Recipient relating to the Program shall continue and +survive. + +Everyone is permitted to copy and distribute copies of this Agreement, +but in order to avoid inconsistency the Agreement is copyrighted and +may only be modified in the following manner. The Agreement Steward +reserves the right to publish new versions (including revisions) of +this Agreement from time to time. No one other than the Agreement +Steward has the right to modify this Agreement. The Eclipse Foundation +is the initial Agreement Steward. The Eclipse Foundation may assign +the responsibility to serve as the Agreement Steward to a suitable +separate entity. Each new version of the Agreement will be given a +distinguishing version number. The Program (including Contributions) +may always be distributed subject to the version of the Agreement +under which it was received. In addition, after a new version of the +Agreement is published, Contributor may elect to distribute the +Program (including its Contributions) under the new version. Except as +expressly stated in Sections 2(a) and 2(b) above, Recipient receives +no rights or licenses to the intellectual property of any Contributor +under this Agreement, whether expressly, by implication, estoppel or +otherwise. All rights in the Program not expressly granted under this +Agreement are reserved. + +This Agreement is governed by the laws of the State of New York and +the intellectual property laws of the United States of America. No +party to this Agreement will bring a legal action under this Agreement +more than one year after the cause of action arose. Each party waives +its rights to a jury trial in any resulting litigation. + +=============================================================================== + +For the Rhino JavaScript container component: + +Mozilla Public License 1.1 (MPL 1.1) + +1. Definitions. + + 1.0.1. "Commercial Use" means distribution or otherwise making the +Covered Code available to a third party. + + 1.1. "Contributor" means each entity that creates or contributes to +the creation of Modifications. + + 1.2. "Contributor Version" means the combination of the Original Code, +prior Modifications used by a Contributor, and the Modifications made by that +particular Contributor. + + 1.3. "Covered Code" means the Original Code or Modifications or the +combination of the Original Code and Modifications, in each case including +portions thereof. + + 1.4. "Electronic Distribution Mechanism" means a mechanism generally +accepted in the software development community for the electronic transfer of +data. + + 1.5. "Executable" means Covered Code in any form other than Source +Code. + + 1.6. "Initial Developer" means the individual or entity identified as +the Initial Developer in the Source Code notice required by Exhibit A. + + 1.7. "Larger Work" means a work which combines Covered Code or +portions thereof with code not governed by the terms of this License. + + 1.8. "License" means this document. + + 1.8.1. "Licensable" means having the right to grant, to the maximum +extent possible, whether at the time of the initial grant or subsequently +acquired, any and all of the rights conveyed herein. + + 1.9. "Modifications" means any addition to or deletion from the +substance or structure of either the Original Code or any previous +Modifications. When Covered Code is released as a series of files, a +Modification is: + A. Any addition to or deletion from the contents of a file +containing Original Code or previous Modifications. + + B. Any new file that contains any part of the Original Code or +previous Modifications. + + 1.10. "Original Code" means Source Code of computer software code +which is described in the Source Code notice required by Exhibit A as Original +Code, and which, at the time of its release under this License is not already +Covered Code governed by this License. + + 1.10.1. "Patent Claims" means any patent claim(s), now owned or +hereafter acquired, including without limitation, method, process, and +apparatus claims, in any patent Licensable by grantor. + + 1.11. "Source Code" means the preferred form of the Covered Code for +making modifications to it, including all modules it contains, plus any +associated interface definition files, scripts used to control compilation and +installation of an Executable, or source code differential comparisons against +either the Original Code or another well known, available Covered Code of the +Contributor's choice. The Source Code can be in a compressed or archival form, +provided the appropriate decompression or de-archiving software is widely +available for no charge. + + 1.12. "You" (or "Your") means an individual or a legal entity +exercising rights under, and complying with all of the terms of, this License +or a future version of this License issued under Section 6.1. For legal +entities, "You" includes any entity which controls, is controlled by, or is +under common control with You. For purposes of this definition, "control" +means (a) the power, direct or indirect, to cause the direction or management +of such entity, whether by contract or otherwise, or (b) ownership of more +than fifty percent (50%) of the outstanding shares or beneficial ownership of +such entity. + +2. Source Code License. + + 2.1. The Initial Developer Grant. + The Initial Developer hereby grants You a world-wide, royalty-free, +non-exclusive license, subject to third party intellectual property claims: + (a) under intellectual property rights (other than patent or +trademark) Licensable by Initial Developer to use, reproduce, modify, display, +perform, sublicense and distribute the Original Code (or portions thereof) +with or without Modifications, and/or as part of a Larger Work; and + + (b) under Patents Claims infringed by the making, using or selling +of Original Code, to make, have made, use, practice, sell, and offer for sale, +and/or otherwise dispose of the Original Code (or portions thereof). + (c) the licenses granted in this Section 2.1(a) and +(b) are effective on the date Initial Developer first distributes Original +Code under the terms of this License. + + (d) Notwithstanding Section 2.1(b) above, no patent license is +granted: 1) for code that You delete from the Original Code; 2) separate from +the Original Code; or 3) for infringements caused by: i) the modification of +the Original Code or ii) the combination of the Original Code with other +software or devices. + + 2.2. Contributor Grant. + Subject to third party intellectual property claims, each Contributor +hereby grants You a world-wide, royalty-free, non-exclusive license + + (a) under intellectual property rights (other than patent or +trademark) Licensable by Contributor, to use, reproduce, modify, display, +perform, sublicense and distribute the Modifications created by such +Contributor (or portions thereof) either on an unmodified basis, with other +Modifications, as Covered Code and/or as part of a Larger Work; and + + (b) under Patent Claims infringed by the making, using, or selling +of Modifications made by that Contributor either alone and/or in combination +with its Contributor Version (or portions of such combination), to make, use, +sell, offer for sale, have made, and/or otherwise dispose of: 1) Modifications +made by that Contributor (or portions thereof); and 2) the combination of +Modifications made by that Contributor with its Contributor Version (or +portions of such combination). + + (c) the licenses granted in Sections 2.2(a) and 2.2(b) are +effective on the date Contributor first makes Commercial Use of the Covered +Code. + + (d) Notwithstanding Section 2.2(b) above, no patent license is +granted: 1) for any code that Contributor has deleted from the Contributor +Version; 2) separate from the Contributor Version; 3) for infringements +caused by: i) third party modifications of Contributor Version or ii) the +combination of Modifications made by that Contributor with other software +(except as part of the Contributor Version) or other devices; or 4) under +Patent Claims infringed by Covered Code in the absence of Modifications made +by that Contributor. + + +3. Distribution Obligations. + + 3.1. Application of License. + The Modifications which You create or to which You contribute are +governed by the terms of this License, including without limitation Section +2.2. The Source Code version of Covered Code may be distributed only under the +terms of this License or a future version of this License released under +Section 6.1, and You must include a copy of this License with every copy of +the Source Code You distribute. You may not offer or impose any terms on any +Source Code version that alters or restricts the applicable version of this +License or the recipients' rights hereunder. However, You may include an +additional document offering the additional rights described in Section 3.5. + + 3.2. Availability of Source Code. + Any Modification which You create or to which You contribute must be +made available in Source Code form under the terms of this License either on +the same media as an Executable version or via an accepted Electronic +Distribution Mechanism to anyone to whom you made an Executable version +available; and if made available via Electronic Distribution Mechanism, must +remain available for at least twelve (12) months after the date it initially +became available, or at least six (6) months after a subsequent version of +that particular Modification has been made available to such recipients. You +are responsible for ensuring that the Source Code version remains available +even if the Electronic Distribution Mechanism is maintained by a third party. + + 3.3. Description of Modifications. + You must cause all Covered Code to which You contribute to contain a +file documenting the changes You made to create that Covered Code and the date +of any change. You must include a prominent statement that the Modification is +derived, directly or indirectly, from Original Code provided by the Initial +Developer and including the name of the Initial Developer in (a) the Source +Code, and (b) in any notice in an Executable version or related documentation +in which You describe the origin or ownership of the Covered Code. + + 3.4. Intellectual Property Matters + (a) Third Party Claims. + If Contributor has knowledge that a license under a third party's +intellectual property rights is required to exercise the rights granted by +such Contributor under Sections 2.1 or 2.2, Contributor must include a text +file with the Source Code distribution titled "LEGAL" which describes the +claim and the party making the claim in sufficient detail that a recipient +will know whom to contact. If Contributor obtains such knowledge after the +Modification is made available as described in Section 3.2, Contributor shall +promptly modify the LEGAL file in all copies Contributor makes available +thereafter and shall take other steps (such as notifying appropriate mailing +lists or newsgroups) reasonably calculated to inform those who received the +Covered Code that new knowledge has been obtained. + + (b) Contributor APIs. + If Contributor's Modifications include an application programming +interface and Contributor has knowledge of patent licenses which are +reasonably necessary to implement that API, Contributor must also include this +information in the LEGAL file. + + (c) Representations. + Contributor represents that, except as disclosed pursuant to +Section 3.4(a) above, Contributor believes that Contributor's Modifications +are Contributor's original creation(s) and/or Contributor has sufficient +rights to grant the rights conveyed by this License. + + + 3.5. Required Notices. + You must duplicate the notice in Exhibit A in each file of the Source +Code. If it is not possible to put such notice in a particular Source Code +file due to its structure, then You must include such notice in a location +(such as a relevant directory) where a user would be likely to look for such a +notice. If You created one or more Modification(s) You may add your name as a +Contributor to the notice described in Exhibit A. You must also duplicate +this License in any documentation for the Source Code where You describe +recipients' rights or ownership rights relating to Covered Code. You may +choose to offer, and to charge a fee for, warranty, support, indemnity or +liability obligations to one or more recipients of Covered Code. However, You +may do so only on Your own behalf, and not on behalf of the Initial Developer +or any Contributor. You must make it absolutely clear than any such warranty, +support, indemnity or liability obligation is offered by You alone, and You +hereby agree to indemnify the Initial Developer and every Contributor for any +liability incurred by the Initial Developer or such Contributor as a result of +warranty, support, indemnity or liability terms You offer. + + 3.6. Distribution of Executable Versions. + You may distribute Covered Code in Executable form only if the +requirements of Section 3.1-3.5 have been met for that Covered Code, and if +You include a notice stating that the Source Code version of the Covered Code +is available under the terms of this License, including a description of how +and where You have fulfilled the obligations of Section 3.2. The notice must +be conspicuously included in any notice in an Executable version, related +documentation or collateral in which You describe recipients' rights relating +to the Covered Code. You may distribute the Executable version of Covered Code +or ownership rights under a license of Your choice, which may contain terms +different from this License, provided that You are in compliance with the +terms of this License and that the license for the Executable version does not +attempt to limit or alter the recipient's rights in the Source Code version +from the rights set forth in this License. If You distribute the Executable +version under a different license You must make it absolutely clear that any +terms which differ from this License are offered by You alone, not by the +Initial Developer or any Contributor. You hereby agree to indemnify the +Initial Developer and every Contributor for any liability incurred by the +Initial Developer or such Contributor as a result of any such terms You offer. + + 3.7. Larger Works. + You may create a Larger Work by combining Covered Code with other code +not governed by the terms of this License and distribute the Larger Work as a +single product. In such a case, You must make sure the requirements of this +License are fulfilled for the Covered Code. + +4. Inability to Comply Due to Statute or Regulation. + + If it is impossible for You to comply with any of the terms of this +License with respect to some or all of the Covered Code due to statute, +judicial order, or regulation then You must: (a) comply with the terms of this +License to the maximum extent possible; and (b) describe the limitations and +the code they affect. Such description must be included in the LEGAL file +described in Section 3.4 and must be included with all distributions of the +Source Code. Except to the extent prohibited by statute or regulation, such +description must be sufficiently detailed for a recipient of ordinary skill to +be able to understand it. + +5. Application of this License. + + This License applies to code to which the Initial Developer has attached +the notice in Exhibit A and to related Covered Code. + +6. Versions of the License. + + 6.1. New Versions. + Netscape Communications Corporation ("Netscape") may publish revised +and/or new versions of the License from time to time. Each version will be +given a distinguishing version number. + + 6.2. Effect of New Versions. + Once Covered Code has been published under a particular version of the +License, You may always continue to use it under the terms of that version. +You may also choose to use such Covered Code under the terms of any subsequent +version of the License published by Netscape. No one other than Netscape has +the right to modify the terms applicable to Covered Code created under this +License. + + 6.3. Derivative Works. + If You create or use a modified version of this License (which you may +only do in order to apply it to code which is not already Covered Code +governed by this License), You must (a) rename Your license so that the +phrases "Mozilla", "MOZILLAPL", "MOZPL", "Netscape", "MPL", "NPL" or +any confusingly similar phrase do not appear in your license (except to note +that your license differs from this License) and (b) otherwise make it clear +that Your version of the license contains terms which differ from the Mozilla +Public License and Netscape Public License. (Filling in the name of the +Initial Developer, Original Code or Contributor in the notice described in +Exhibit A shall not of themselves be deemed to be modifications of this +License.) + +7. DISCLAIMER OF WARRANTY. + + COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT +LIMITATION, WARRANTIES THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, +FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE +QUALITY AND PERFORMANCE OF THE COVERED CODE IS WITH YOU. SHOULD ANY COVERED +CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE INITIAL DEVELOPER OR ANY +OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY SERVICING, REPAIR OR +CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS +LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS +DISCLAIMER. + +8. TERMINATION. + + 8.1. This License and the rights granted hereunder will terminate +automatically if You fail to comply with terms herein and fail to cure such +breach within 30 days of becoming aware of the breach. All sublicenses to the +Covered Code which are properly granted shall survive any termination of this +License. Provisions which, by their nature, must remain in effect beyond the +termination of this License shall survive. + + 8.2. If You initiate litigation by asserting a patent infringement +claim (excluding declatory judgment actions) against Initial Developer or a +Contributor (the Initial Developer or Contributor against whom You file such +action is referred to as "Participant") alleging that: + + (a) such Participant's Contributor Version directly or indirectly +infringes any patent, then any and all rights granted by such Participant to +You under Sections 2.1 and/or 2.2 of this License shall, upon 60 days notice +from Participant terminate prospectively, unless if within 60 days after +receipt of notice You either: (i) agree in writing to pay Participant a +mutually agreeable reasonable royalty for Your past and future use of +Modifications made by such Participant, or (ii) withdraw Your litigation claim +with respect to the Contributor Version against such Participant. If within +60 days of notice, a reasonable royalty and payment arrangement are not +mutually agreed upon in writing by the parties or the litigation claim is not +withdrawn, the rights granted by Participant to You under Sections 2.1 and/or +2.2 automatically terminate at the expiration of the 60 day notice period +specified above. + + (b) any software, hardware, or device, other than such Participant's +Contributor Version, directly or indirectly infringes any patent, then any +rights granted to You by such Participant under Sections 2.1(b) and 2.2(b) are +revoked effective as of the date You first made, used, sold, distributed, or +had made, Modifications made by that Participant. + + 8.3. If You assert a patent infringement claim against Participant +alleging that such Participant's Contributor Version directly or indirectly +infringes any patent where such claim is resolved (such as by license or +settlement) prior to the initiation of patent infringement litigation, then +the reasonable value of the licenses granted by such Participant under +Sections 2.1 or 2.2 shall be taken into account in determining the amount or +value of any payment or license. + + 8.4. In the event of termination under Sections 8.1 or 8.2 above, all +end user license agreements (excluding distributors and resellers) which have +been validly granted by You or any distributor hereunder prior to termination +shall survive termination. + +9. LIMITATION OF LIABILITY. + + UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT +(INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL +DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED CODE, OR ANY +SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR ANY INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, +WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL, WORK STOPPAGE, COMPUTER +FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL DAMAGES OR LOSSES, +EVEN IF SUCH PARTY SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF SUCH +DAMAGES. THIS LIMITATION OF LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH +OR PERSONAL INJURY RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT +APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE +EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THIS +EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU. + +10. U.S. GOVERNMENT END USERS. + + The Covered Code is a "commercial item," as that term is defined in 48 +C.F.R. 2.101 (Oct. 1995), consisting of "commercial computer software" and +"commercial computer software documentation," as such terms are used in 48 +C.F.R. 12.212 (Sept. 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. +227.7202-1 through 227.7202-4 (June 1995), all U.S. Government End Users +acquire Covered Code with only those rights set forth herein. + +11. MISCELLANEOUS. + + This License represents the complete agreement concerning subject matter +hereof. If any provision of this License is held to be unenforceable, such +provision shall be reformed only to the extent necessary to make it +enforceable. This License shall be governed by California law provisions +(except to the extent applicable law, if any, provides otherwise), excluding +its conflict-of-law provisions. With respect to disputes in which at least one +party is a citizen of, or an entity chartered or registered to do business in +the United States of America, any litigation relating to this License shall be +subject to the jurisdiction of the Federal Courts of the Northern District of +California, with venue lying in Santa Clara County, California, with the +losing party responsible for costs, including without limitation, court costs +and reasonable attorneys' fees and expenses. The application of the United +Nations Convention on Contracts for the International Sale of Goods is +expressly excluded. Any law or regulation which provides that the language of +a contract shall be construed against the drafter shall not apply to this +License. + +12. RESPONSIBILITY FOR CLAIMS. + + As between Initial Developer and the Contributors, each party is +responsible for claims and damages arising, directly or indirectly, out of its +utilization of rights under this License and You agree to work with Initial +Developer and Contributors to distribute such responsibility on an equitable +basis. Nothing herein is intended or shall be deemed to constitute any +admission of liability. + +13. MULTIPLE-LICENSED CODE. + + Initial Developer may designate portions of the Covered Code as +Multiple-Licensed. Multiple-Licensed means that the Initial Developer permits +you to utilize portions of the Covered Code under Your choice of the MPL or +the alternative licenses, if any, specified by the Initial Developer in the +file described in Exhibit A. + + +EXHIBIT A -Mozilla Public License. + + ``The contents of this file are subject to the Mozilla Public License +Version 1.1 (the "License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + http://www.mozilla.org/MPL/ + + Software distributed under the License is distributed on an "AS IS" +basis, WITHOUT WARRANTY OF + ANY KIND, either express or implied. See the License for the specific +language governing rights and + limitations under the License. + + The Original Code is ______________________________________. + + The Initial Developer of the Original Code is ________________________. +Portions created by + ______________________ are Copyright (C) ______ +_______________________. All Rights + Reserved. + + Contributor(s): ______________________________________. + + Alternatively, the contents of this file may be used under the terms of +the _____ license (the [___] License), in which case the provisions of +[______] License are applicable instead of those above. If you wish to allow +use of your version of this file only under the terms of the [____] License +and not to allow others to use your version of this file under the MPL, +indicate your decision by deleting the provisions above and replace them +with the notice and other provisions required by the [___] License. If you do +not delete the provisions above, a recipient may use your version of this file +under either the MPL or the [___] License." + + [NOTE: The text of this Exhibit A may differ slightly from the text of +the notices in the Source Code files of the Original Code. You should use the +text of this Exhibit A rather than the text found in the Original Code Source +Code for Your Modifications.] + + +=============================================================================== + +For the JAX-WS Reference Implementation component: + +COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 + + + 1. Definitions. + + 1.1. "Contributor" means each individual or entity that + creates or contributes to the creation of Modifications. + + 1.2. "Contributor Version" means the combination of the + Original Software, prior Modifications used by a + Contributor (if any), and the Modifications made by that + particular Contributor. + + 1.3. "Covered Software" means (a) the Original Software, or + (b) Modifications, or (c) the combination of files + containing Original Software with files containing + Modifications, in each case including portions thereof. + + 1.4. "Executable" means the Covered Software in any form + other than Source Code. + + 1.5. "Initial Developer" means the individual or entity + that first makes Original Software available under this + License. + + 1.6. "Larger Work" means a work which combines Covered + Software or portions thereof with code not governed by the + terms of this License. + + 1.7. "License" means this document. + + 1.8. "Licensable" means having the right to grant, to the + maximum extent possible, whether at the time of the initial + grant or subsequently acquired, any and all of the rights + conveyed herein. + + 1.9. "Modifications" means the Source Code and Executable + form of any of the following: + + A. Any file that results from an addition to, + deletion from or modification of the contents of a + file containing Original Software or previous + Modifications; + + B. Any new file that contains any part of the + Original Software or previous Modification; or + + C. Any new file that is contributed or otherwise made + available under the terms of this License. + + 1.10. "Original Software" means the Source Code and + Executable form of computer software code that is + originally released under this License. + + 1.11. "Patent Claims" means any patent claim(s), now owned + or hereafter acquired, including without limitation, + method, process, and apparatus claims, in any patent + Licensable by grantor. + + 1.12. "Source Code" means (a) the common form of computer + software code in which modifications are made and (b) + associated documentation included in or with such code. + + 1.13. "You" (or "Your") means an individual or a legal + entity exercising rights under, and complying with all of + the terms of, this License. For legal entities, "You" + includes any entity which controls, is controlled by, or is + under common control with You. For purposes of this + definition, "control" means (a) the power, direct or + indirect, to cause the direction or management of such + entity, whether by contract or otherwise, or (b) ownership + of more than fifty percent (50%) of the outstanding shares + or beneficial ownership of such entity. + + 2. License Grants. + + 2.1. The Initial Developer Grant. + + Conditioned upon Your compliance with Section 3.1 below and + subject to third party intellectual property claims, the + Initial Developer hereby grants You a world-wide, + royalty-free, non-exclusive license: + + (a) under intellectual property rights (other than + patent or trademark) Licensable by Initial Developer, + to use, reproduce, modify, display, perform, + sublicense and distribute the Original Software (or + portions thereof), with or without Modifications, + and/or as part of a Larger Work; and + + (b) under Patent Claims infringed by the making, + using or selling of Original Software, to make, have + made, use, practice, sell, and offer for sale, and/or + otherwise dispose of the Original Software (or + portions thereof). + + (c) The licenses granted in Sections 2.1(a) and (b) + are effective on the date Initial Developer first + distributes or otherwise makes the Original Software + available to a third party under the terms of this + License. + + (d) Notwithstanding Section 2.1(b) above, no patent + license is granted: (1) for code that You delete from + the Original Software, or (2) for infringements + caused by: (i) the modification of the Original + Software, or (ii) the combination of the Original + Software with other software or devices. + + 2.2. Contributor Grant. + + Conditioned upon Your compliance with Section 3.1 below and + subject to third party intellectual property claims, each + Contributor hereby grants You a world-wide, royalty-free, + non-exclusive license: + + (a) under intellectual property rights (other than + patent or trademark) Licensable by Contributor to + use, reproduce, modify, display, perform, sublicense + and distribute the Modifications created by such + Contributor (or portions thereof), either on an + unmodified basis, with other Modifications, as + Covered Software and/or as part of a Larger Work; and + + + (b) under Patent Claims infringed by the making, + using, or selling of Modifications made by that + Contributor either alone and/or in combination with + its Contributor Version (or portions of such + combination), to make, use, sell, offer for sale, + have made, and/or otherwise dispose of: (1) + Modifications made by that Contributor (or portions + thereof); and (2) the combination of Modifications + made by that Contributor with its Contributor Version + (or portions of such combination). + + (c) The licenses granted in Sections 2.2(a) and + 2.2(b) are effective on the date Contributor first + distributes or otherwise makes the Modifications + available to a third party. + + (d) Notwithstanding Section 2.2(b) above, no patent + license is granted: (1) for any code that Contributor + has deleted from the Contributor Version; (2) for + infringements caused by: (i) third party + modifications of Contributor Version, or (ii) the + combination of Modifications made by that Contributor + with other software (except as part of the + Contributor Version) or other devices; or (3) under + Patent Claims infringed by Covered Software in the + absence of Modifications made by that Contributor. + + 3. Distribution Obligations. + + 3.1. Availability of Source Code. + + Any Covered Software that You distribute or otherwise make + available in Executable form must also be made available in + Source Code form and that Source Code form must be + distributed only under the terms of this License. You must + include a copy of this License with every copy of the + Source Code form of the Covered Software You distribute or + otherwise make available. You must inform recipients of any + such Covered Software in Executable form as to how they can + obtain such Covered Software in Source Code form in a + reasonable manner on or through a medium customarily used + for software exchange. + + 3.2. Modifications. + + The Modifications that You create or to which You + contribute are governed by the terms of this License. You + represent that You believe Your Modifications are Your + original creation(s) and/or You have sufficient rights to + grant the rights conveyed by this License. + + 3.3. Required Notices. + + You must include a notice in each of Your Modifications + that identifies You as the Contributor of the Modification. + You may not remove or alter any copyright, patent or + trademark notices contained within the Covered Software, or + any notices of licensing or any descriptive text giving + attribution to any Contributor or the Initial Developer. + + 3.4. Application of Additional Terms. + + You may not offer or impose any terms on any Covered + Software in Source Code form that alters or restricts the + applicable version of this License or the recipients' + rights hereunder. You may choose to offer, and to charge a + fee for, warranty, support, indemnity or liability + obligations to one or more recipients of Covered Software. + However, you may do so only on Your own behalf, and not on + behalf of the Initial Developer or any Contributor. You + must make it absolutely clear that any such warranty, + support, indemnity or liability obligation is offered by + You alone, and You hereby agree to indemnify the Initial + Developer and every Contributor for any liability incurred + by the Initial Developer or such Contributor as a result of + warranty, support, indemnity or liability terms You offer. + + + 3.5. Distribution of Executable Versions. + + You may distribute the Executable form of the Covered + Software under the terms of this License or under the terms + of a license of Your choice, which may contain terms + different from this License, provided that You are in + compliance with the terms of this License and that the + license for the Executable form does not attempt to limit + or alter the recipient's rights in the Source Code form + from the rights set forth in this License. If You + distribute the Covered Software in Executable form under a + different license, You must make it absolutely clear that + any terms which differ from this License are offered by You + alone, not by the Initial Developer or Contributor. You + hereby agree to indemnify the Initial Developer and every + Contributor for any liability incurred by the Initial + Developer or such Contributor as a result of any such terms + You offer. + + 3.6. Larger Works. + + You may create a Larger Work by combining Covered Software + with other code not governed by the terms of this License + and distribute the Larger Work as a single product. In such + a case, You must make sure the requirements of this License + are fulfilled for the Covered Software. + + 4. Versions of the License. + + 4.1. New Versions. + + Sun Microsystems, Inc. is the initial license steward and + may publish revised and/or new versions of this License + from time to time. Each version will be given a + distinguishing version number. Except as provided in + Section 4.3, no one other than the license steward has the + right to modify this License. + + 4.2. Effect of New Versions. + + You may always continue to use, distribute or otherwise + make the Covered Software available under the terms of the + version of the License under which You originally received + the Covered Software. If the Initial Developer includes a + notice in the Original Software prohibiting it from being + distributed or otherwise made available under any + subsequent version of the License, You must distribute and + make the Covered Software available under the terms of the + version of the License under which You originally received + the Covered Software. Otherwise, You may also choose to + use, distribute or otherwise make the Covered Software + available under the terms of any subsequent version of the + License published by the license steward. + + 4.3. Modified Versions. + + When You are an Initial Developer and You want to create a + new license for Your Original Software, You may create and + use a modified version of this License if You: (a) rename + the license and remove any references to the name of the + license steward (except to note that the license differs + from this License); and (b) otherwise make it clear that + the license contains terms which differ from this License. + + + 5. DISCLAIMER OF WARRANTY. + + COVERED SOFTWARE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" + BASIS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, + INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE COVERED + SOFTWARE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR + PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND + PERFORMANCE OF THE COVERED SOFTWARE IS WITH YOU. SHOULD ANY + COVERED SOFTWARE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE + INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF + ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF + WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF + ANY COVERED SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS + DISCLAIMER. + + 6. TERMINATION. + + 6.1. This License and the rights granted hereunder will + terminate automatically if You fail to comply with terms + herein and fail to cure such breach within 30 days of + becoming aware of the breach. Provisions which, by their + nature, must remain in effect beyond the termination of + this License shall survive. + + 6.2. If You assert a patent infringement claim (excluding + declaratory judgment actions) against Initial Developer or + a Contributor (the Initial Developer or Contributor against + whom You assert such claim is referred to as "Participant") + alleging that the Participant Software (meaning the + Contributor Version where the Participant is a Contributor + or the Original Software where the Participant is the + Initial Developer) directly or indirectly infringes any + patent, then any and all rights granted directly or + indirectly to You by such Participant, the Initial + Developer (if the Initial Developer is not the Participant) + and all Contributors under Sections 2.1 and/or 2.2 of this + License shall, upon 60 days notice from Participant + terminate prospectively and automatically at the expiration + of such 60 day notice period, unless if within such 60 day + period You withdraw Your claim with respect to the + Participant Software against such Participant either + unilaterally or pursuant to a written agreement with + Participant. + + 6.3. In the event of termination under Sections 6.1 or 6.2 + above, all end user licenses that have been validly granted + by You or any distributor hereunder prior to termination + (excluding licenses granted to You by any distributor) + shall survive termination. + + 7. LIMITATION OF LIABILITY. + + UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT + (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE + INITIAL DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF + COVERED SOFTWARE, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE + LIABLE TO ANY PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR + CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT + LIMITATION, DAMAGES FOR LOST PROFITS, LOSS OF GOODWILL, WORK + STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER + COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN + INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF + LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL + INJURY RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT + APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO + NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR + CONSEQUENTIAL DAMAGES, SO THIS EXCLUSION AND LIMITATION MAY NOT + APPLY TO YOU. + + 8. U.S. GOVERNMENT END USERS. + + The Covered Software is a "commercial item," as that term is + defined in 48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial + computer software" (as that term is defined at 48 C.F.R. + 252.227-7014(a)(1)) and "commercial computer software + documentation" as such terms are used in 48 C.F.R. 12.212 (Sept. + 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1 + through 227.7202-4 (June 1995), all U.S. Government End Users + acquire Covered Software with only those rights set forth herein. + This U.S. Government Rights clause is in lieu of, and supersedes, + any other FAR, DFAR, or other clause or provision that addresses + Government rights in computer software under this License. + + 9. MISCELLANEOUS. + + This License represents the complete agreement concerning subject + matter hereof. If any provision of this License is held to be + unenforceable, such provision shall be reformed only to the + extent necessary to make it enforceable. This License shall be + governed by the law of the jurisdiction specified in a notice + contained within the Original Software (except to the extent + applicable law, if any, provides otherwise), excluding such + jurisdiction's conflict-of-law provisions. Any litigation + relating to this License shall be subject to the jurisdiction of + the courts located in the jurisdiction and venue specified in a + notice contained within the Original Software, with the losing + party responsible for costs, including, without limitation, court + costs and reasonable attorneys' fees and expenses. The + application of the United Nations Convention on Contracts for the + International Sale of Goods is expressly excluded. Any law or + regulation which provides that the language of a contract shall + be construed against the drafter shall not apply to this License. + You agree that You alone are responsible for compliance with the + United States export administration regulations (and the export + control laws and regulation of any other countries) when You use, + distribute or otherwise make available any Covered Software. + + 10. RESPONSIBILITY FOR CLAIMS. + + As between Initial Developer and the Contributors, each party is + responsible for claims and damages arising, directly or + indirectly, out of its utilization of rights under this License + and You agree to work with Initial Developer and Contributors to + distribute such responsibility on an equitable basis. Nothing + herein is intended or shall be deemed to constitute any admission + of liability. + diff --git a/sandbox/rfeng/samples/mortgage/src/main/resources/META-INF/NOTICE b/sandbox/rfeng/samples/mortgage/src/main/resources/META-INF/NOTICE new file mode 100644 index 0000000000..11c564eb19 --- /dev/null +++ b/sandbox/rfeng/samples/mortgage/src/main/resources/META-INF/NOTICE @@ -0,0 +1,18 @@ +========================================================================= +== NOTICE file corresponding to the section 4 d of == +== the Apache License, Version 2.0, == +== in this case for the Apache Tuscany distribution. == +========================================================================= + +This product includes software developed by the Apache Software Foundation +(http://www.apache.org/). + +This product also includes software developed by: +- the Eclipse Modeling Framework project (http://www.eclipse.org/emf/) +- the Celtix project (http://celtix.objectweb.org/) +- the Mozilla Rhino project (http://www.mozilla.org/rhino/) +- the GlassFish JAX-WS project (https://jax-ws.dev.java.net/) + +Please read the LICENSE.txt file present in the root directory of this +distribution. + diff --git a/sandbox/rfeng/samples/mortgage/src/main/resources/META-INF/sca/default.scdl b/sandbox/rfeng/samples/mortgage/src/main/resources/META-INF/sca/default.scdl new file mode 100644 index 0000000000..e44911c13c --- /dev/null +++ b/sandbox/rfeng/samples/mortgage/src/main/resources/META-INF/sca/default.scdl @@ -0,0 +1,48 @@ + + + + + + + 600 + CreditCheckComponent + CreditCheckComponent + InterestRateQuoteComponent + RiskAssessmentComponent + MortgageCalculatorComponent + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/rfeng/samples/mortgage/src/main/resources/META-INF/sca/default1.scdl b/sandbox/rfeng/samples/mortgage/src/main/resources/META-INF/sca/default1.scdl new file mode 100644 index 0000000000..bfb687be5d --- /dev/null +++ b/sandbox/rfeng/samples/mortgage/src/main/resources/META-INF/sca/default1.scdl @@ -0,0 +1,50 @@ + + + + + + + 600 + CreditCheckReference + InterestRateQuoteComponent + RiskAssessmentComponent + MortgageCalculatorJSComponent + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/rfeng/samples/mortgage/src/main/resources/META-INF/sca/default2.scdl b/sandbox/rfeng/samples/mortgage/src/main/resources/META-INF/sca/default2.scdl new file mode 100644 index 0000000000..fc8bdeec0b --- /dev/null +++ b/sandbox/rfeng/samples/mortgage/src/main/resources/META-INF/sca/default2.scdl @@ -0,0 +1,50 @@ + + + + + + + 600 + CreditCheckReference1 + InterestRateQuoteComponent + RiskAssessmentComponent + MortgageCalculatorJSComponent + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/rfeng/samples/mortgage/src/main/resources/MortgageCalculator.componentType b/sandbox/rfeng/samples/mortgage/src/main/resources/MortgageCalculator.componentType new file mode 100644 index 0000000000..bf7b10e0f7 --- /dev/null +++ b/sandbox/rfeng/samples/mortgage/src/main/resources/MortgageCalculator.componentType @@ -0,0 +1,27 @@ + + + + + + + + + + diff --git a/sandbox/rfeng/samples/mortgage/src/main/resources/MortgageCalculator.js b/sandbox/rfeng/samples/mortgage/src/main/resources/MortgageCalculator.js new file mode 100644 index 0000000000..b25af1d039 --- /dev/null +++ b/sandbox/rfeng/samples/mortgage/src/main/resources/MortgageCalculator.js @@ -0,0 +1,25 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +function getMonthlyPayment(principal, years, interestRate) { + var monthlyRate = interestRate / 12.0 / 100.0; + var p = Math.pow(1 + monthlyRate, years * 12); + var q = p / (p - 1); + var monthlyPayment = principal * monthlyRate * q; + return monthlyPayment; +} diff --git a/sandbox/rfeng/samples/mortgage/src/main/resources/doc/credit_composite.jpg b/sandbox/rfeng/samples/mortgage/src/main/resources/doc/credit_composite.jpg new file mode 100644 index 0000000000..e28ed63cfb Binary files /dev/null and b/sandbox/rfeng/samples/mortgage/src/main/resources/doc/credit_composite.jpg differ diff --git a/sandbox/rfeng/samples/mortgage/src/main/resources/doc/credit_composite.png b/sandbox/rfeng/samples/mortgage/src/main/resources/doc/credit_composite.png new file mode 100644 index 0000000000..0bfce0078d Binary files /dev/null and b/sandbox/rfeng/samples/mortgage/src/main/resources/doc/credit_composite.png differ diff --git a/sandbox/rfeng/samples/mortgage/src/main/resources/doc/loan_approval.jpg b/sandbox/rfeng/samples/mortgage/src/main/resources/doc/loan_approval.jpg new file mode 100644 index 0000000000..3f00557c7f Binary files /dev/null and b/sandbox/rfeng/samples/mortgage/src/main/resources/doc/loan_approval.jpg differ diff --git a/sandbox/rfeng/samples/mortgage/src/main/resources/doc/loan_approval.png b/sandbox/rfeng/samples/mortgage/src/main/resources/doc/loan_approval.png new file mode 100644 index 0000000000..9d5f829fe5 Binary files /dev/null and b/sandbox/rfeng/samples/mortgage/src/main/resources/doc/loan_approval.png differ diff --git a/sandbox/rfeng/samples/mortgage/src/main/resources/doc/mortgage_assembly0.jpg b/sandbox/rfeng/samples/mortgage/src/main/resources/doc/mortgage_assembly0.jpg new file mode 100644 index 0000000000..515b6ecde7 Binary files /dev/null and b/sandbox/rfeng/samples/mortgage/src/main/resources/doc/mortgage_assembly0.jpg differ diff --git a/sandbox/rfeng/samples/mortgage/src/main/resources/doc/mortgage_assembly0.png b/sandbox/rfeng/samples/mortgage/src/main/resources/doc/mortgage_assembly0.png new file mode 100644 index 0000000000..4b815a4b82 Binary files /dev/null and b/sandbox/rfeng/samples/mortgage/src/main/resources/doc/mortgage_assembly0.png differ diff --git a/sandbox/rfeng/samples/mortgage/src/main/resources/doc/mortgage_assembly1.jpg b/sandbox/rfeng/samples/mortgage/src/main/resources/doc/mortgage_assembly1.jpg new file mode 100644 index 0000000000..01a7c55a14 Binary files /dev/null and b/sandbox/rfeng/samples/mortgage/src/main/resources/doc/mortgage_assembly1.jpg differ diff --git a/sandbox/rfeng/samples/mortgage/src/main/resources/doc/mortgage_assembly1.png b/sandbox/rfeng/samples/mortgage/src/main/resources/doc/mortgage_assembly1.png new file mode 100644 index 0000000000..07422c4f45 Binary files /dev/null and b/sandbox/rfeng/samples/mortgage/src/main/resources/doc/mortgage_assembly1.png differ diff --git a/sandbox/rfeng/samples/mortgage/src/main/resources/doc/mortgage_assembly2.jpg b/sandbox/rfeng/samples/mortgage/src/main/resources/doc/mortgage_assembly2.jpg new file mode 100644 index 0000000000..992c048684 Binary files /dev/null and b/sandbox/rfeng/samples/mortgage/src/main/resources/doc/mortgage_assembly2.jpg differ diff --git a/sandbox/rfeng/samples/mortgage/src/main/resources/doc/mortgage_assembly2.png b/sandbox/rfeng/samples/mortgage/src/main/resources/doc/mortgage_assembly2.png new file mode 100644 index 0000000000..4667956ed0 Binary files /dev/null and b/sandbox/rfeng/samples/mortgage/src/main/resources/doc/mortgage_assembly2.png differ diff --git a/sandbox/rfeng/samples/mortgage/src/main/resources/doc/mortgage_composite.jpg b/sandbox/rfeng/samples/mortgage/src/main/resources/doc/mortgage_composite.jpg new file mode 100644 index 0000000000..5021f6a317 Binary files /dev/null and b/sandbox/rfeng/samples/mortgage/src/main/resources/doc/mortgage_composite.jpg differ diff --git a/sandbox/rfeng/samples/mortgage/src/main/resources/doc/mortgage_composite.png b/sandbox/rfeng/samples/mortgage/src/main/resources/doc/mortgage_composite.png new file mode 100644 index 0000000000..1398c50ded Binary files /dev/null and b/sandbox/rfeng/samples/mortgage/src/main/resources/doc/mortgage_composite.png differ diff --git a/sandbox/rfeng/samples/mortgage/src/main/resources/doc/mortgage_diagrams.doc b/sandbox/rfeng/samples/mortgage/src/main/resources/doc/mortgage_diagrams.doc new file mode 100644 index 0000000000..00d45e1084 Binary files /dev/null and b/sandbox/rfeng/samples/mortgage/src/main/resources/doc/mortgage_diagrams.doc differ diff --git a/sandbox/rfeng/samples/mortgage/src/main/resources/doc/mortgage_package1.jpg b/sandbox/rfeng/samples/mortgage/src/main/resources/doc/mortgage_package1.jpg new file mode 100644 index 0000000000..e91c5f1bbd Binary files /dev/null and b/sandbox/rfeng/samples/mortgage/src/main/resources/doc/mortgage_package1.jpg differ diff --git a/sandbox/rfeng/samples/mortgage/src/main/resources/doc/mortgage_package1.png b/sandbox/rfeng/samples/mortgage/src/main/resources/doc/mortgage_package1.png new file mode 100644 index 0000000000..db304a4c28 Binary files /dev/null and b/sandbox/rfeng/samples/mortgage/src/main/resources/doc/mortgage_package1.png differ diff --git a/sandbox/rfeng/samples/mortgage/src/main/resources/doc/mortgage_package2.jpg b/sandbox/rfeng/samples/mortgage/src/main/resources/doc/mortgage_package2.jpg new file mode 100644 index 0000000000..e8c2865e4a Binary files /dev/null and b/sandbox/rfeng/samples/mortgage/src/main/resources/doc/mortgage_package2.jpg differ diff --git a/sandbox/rfeng/samples/mortgage/src/main/resources/doc/mortgage_package2.png b/sandbox/rfeng/samples/mortgage/src/main/resources/doc/mortgage_package2.png new file mode 100644 index 0000000000..502e538e94 Binary files /dev/null and b/sandbox/rfeng/samples/mortgage/src/main/resources/doc/mortgage_package2.png differ diff --git a/sandbox/rfeng/samples/mortgage/src/main/resources/doc/mortgage_scenario.jpg b/sandbox/rfeng/samples/mortgage/src/main/resources/doc/mortgage_scenario.jpg new file mode 100644 index 0000000000..fccf2e35c3 Binary files /dev/null and b/sandbox/rfeng/samples/mortgage/src/main/resources/doc/mortgage_scenario.jpg differ diff --git a/sandbox/rfeng/samples/mortgage/src/main/resources/doc/mortgage_scenario.png b/sandbox/rfeng/samples/mortgage/src/main/resources/doc/mortgage_scenario.png new file mode 100644 index 0000000000..b8f42ad318 Binary files /dev/null and b/sandbox/rfeng/samples/mortgage/src/main/resources/doc/mortgage_scenario.png differ diff --git a/sandbox/rfeng/samples/mortgage/src/main/resources/doc/readme.html b/sandbox/rfeng/samples/mortgage/src/main/resources/doc/readme.html new file mode 100644 index 0000000000..bee954a198 --- /dev/null +++ b/sandbox/rfeng/samples/mortgage/src/main/resources/doc/readme.html @@ -0,0 +1,136 @@ + + + + + + + + +Mortgage Sample + + + +

Mortgage Sample

+ +

Overview

+ +

The Tuscany Web services client Helloworld sample shows how to +call a remote Web service by wiring an SCA component to a reference +which uses a Web service binding.

+ +

Prerequisites

+ +

Obtain the following prerequisites and install according to their +documentation.

+ + + +

The business scenario

+The "loan approval" application accepts a mortgage request including the +customer's details and the requested loan amount. It first checks the +credit of the customer to make sure the credit score meets the minimum +requirement. The interest rate is determined based on the principal +requested, the term for the loan and the customers home state. It then +uses a mortgage calculator to calculate the ratio by dividing potential +monthly payment by the customer's income. The ratio and credit score are +passed to perform the risk assessment which makes the final decision. +

+

Packaging structure

+ + +

Building

+ +

To build the sample  issue :

+
+mvn
+
+ +

The result after executing is in the target subdirectory the sample-mortgage.jar

+ +

Setup

+ +

Set up the Tuscany standalone runtime environment using the +following command:

+
+mvn dependency:unpack 
+
+ +

After completion there should be a target\distribution subdirectory +created that has the Tuscany standalone runtime.

+ +

The Tuscany Web servivces binding requires the Axis2 and SDO +databinding extensions so copy these to the standalone launcher +extensions directory:

+
+copy target\distribution\contrib\axis2-1.0-incubator-M2.jar target\distribution\extensions
+copy target\distribution\contrib\databinding-sdo-1.0-incubator-M2.jar target\distribution\extensions
+
+ +

Running

+ +

Execute the following command: (cut +and paste to command line)

+
+java -jar target/distribution/bin/launcher.jar target/sample-mortgage.jar
+
+ +

Results

+ +

The sample when run should simply display to the standard output:
+
+Approved: John Smith[111-22-3333]

+ +We have two versions of the CreditCheck web service implementation in this sample application: +
    +
  • a web service developed with Apache axis2 1.1 release. It's packaged as an Axis2 aar. +
  • a SCA component exposed as a web service. It's packaged as a WAR. +
+ +

Deploy the Axis2 CreditCheck web service to Tomcat

+
    +
  1. Download the WAR (Web Archive) ditribution from Apache + Axis2 1.1 release download site. +
  2. Copy axis2.war to <tomcat_home>\webapps. +
  3. Start Tomcat so that axis2.war get deployed to + <tomcat_home>\webapps\axis2. +
  4. Copy creditws-axis2\build\lib\CreditCheckService.aar to + <tomcat_home>\webapps\axis2\WEB-INF\services. +
+ +

Deploy the CreditComposite to Tomcat

+
    +
  1. Copy credit.war to <tomcat_home>\webapps. +
  2. Start Tomcat so that credit.war get deployed to + <tomcat_home>\webapps\credit. The CreditCheck web serivice will + be up and running. +
+ + + diff --git a/sandbox/rfeng/samples/mortgage/src/main/resources/wsdl/credit.wsdl b/sandbox/rfeng/samples/mortgage/src/main/resources/wsdl/credit.wsdl new file mode 100644 index 0000000000..4779f9ab4d --- /dev/null +++ b/sandbox/rfeng/samples/mortgage/src/main/resources/wsdl/credit.wsdl @@ -0,0 +1,84 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/rfeng/samples/mortgage/src/test/java/mortgage/MortgageClientTestCase.java b/sandbox/rfeng/samples/mortgage/src/test/java/mortgage/MortgageClientTestCase.java new file mode 100644 index 0000000000..b30df0cf2d --- /dev/null +++ b/sandbox/rfeng/samples/mortgage/src/test/java/mortgage/MortgageClientTestCase.java @@ -0,0 +1,61 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package mortgage; + +import mortgage.Customer; +import mortgage.LoanApproval; + +import org.apache.tuscany.test.SCATestCase; +import org.osoa.sca.CompositeContext; +import org.osoa.sca.CurrentCompositeContext; + +/** + * This shows how to test the Calculator service component. + */ +public class MortgageClientTestCase extends SCATestCase { + + private LoanApproval loanApproval; + + protected void setUp() throws Exception { + // version 1: One composite with local components + setApplicationSCDL(LoanApproval.class, "META-INF/sca/default.scdl"); + // version 2: two composites, one for mortgage and the other for credit + // setApplicationSCDL(LoanApproval.class, "META-INF/sca/default1.scdl"); + // version 3: one composite and an external web service for credit + // setApplicationSCDL(LoanApproval.class, "META-INF/sca/default2.scdl"); + ClassLoader classLoader = getClass().getClassLoader(); + // addExtension("binding.axis2", classLoader.getResource("META-INF/sca/binding.axis2.scdl")); + // addExtension("container.js", classLoader.getResource("META-INF/sca/js.system.scdl")); + super.setUp(); + CompositeContext context = CurrentCompositeContext.getContext(); + loanApproval = context.locateService(LoanApproval.class, "LoanApprovalComponent"); + } + + public void testApprove() throws Exception { + Customer customer = new Customer(); + customer.setSsn("111-22-3333"); + customer.setFirstName("John"); + customer.setLastName("Smith"); + customer.setMonthlyIncome(5000.0d); + customer.setState("CA"); + + boolean approved = loanApproval.approve(customer, 200000d, 30); + System.out.println((approved ? "Approved: " : "Rejected: ") + customer); + } +} diff --git a/sandbox/rfeng/samples/pom.xml b/sandbox/rfeng/samples/pom.xml new file mode 100644 index 0000000000..18ec781b20 --- /dev/null +++ b/sandbox/rfeng/samples/pom.xml @@ -0,0 +1,38 @@ + + + 4.0.0 + org.apache.tuscany.samples.sca + rfeng + pom + Tuscany SCA Samples + 1.0-incubator-SNAPSHOT + + + creditws + mortgage + helloworld + helloworldws + + + + install + + + \ No newline at end of file -- cgit v1.2.3