From 75c4045c9663debea932437ed12954e74e7e27bd Mon Sep 17 00:00:00 2001 From: rfeng Date: Mon, 23 Jun 2008 21:21:18 +0000 Subject: Delete obsolete contents git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@670762 13f79535-47bb-0310-9956-ffa450edef68 --- 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 26901 -> 0 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 26901 -> 0 bytes 243 files changed, 20324 deletions(-) delete mode 100644 sandbox/rfeng/minicore/.checkstyle delete mode 100644 sandbox/rfeng/minicore/.pmd delete mode 100644 sandbox/rfeng/minicore/.ruleset delete mode 100644 sandbox/rfeng/minicore/LICENSE.txt delete mode 100644 sandbox/rfeng/minicore/NOTICE.txt delete mode 100644 sandbox/rfeng/minicore/pom.xml delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/AbstractLocalTargetInvoker.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/LocalBindingBuilder.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/LocalBindingDefinition.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/LocalBindingLoader.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/LocalCallbackTargetInvoker.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/LocalReferenceBinding.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/LocalServiceBinding.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/LocalTargetInvoker.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/bootstrap/Bootstrapper.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/bootstrap/DefaultBootstrapper.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/bootstrap/ExtensionActivator.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/BuilderRegistryImpl.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/ComponentNotFoundException.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/ConnectorImpl.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/IllegalCallbackException.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/IncompatibleInterfacesException.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/InvalidSourceTypeException.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/InvalidTargetTypeException.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/NoBindingException.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/NoCompatibleBindingsException.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/NoConversationalContractException.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/NoRegisteredBuilderException.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/SourceServiceNotFoundException.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/TargetServiceNotFoundException.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/WireCreationException.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/WirePostProcessorRegistryImpl.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/WiringExceptionFormatter.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/CallableReferenceImpl.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/CallbackReferenceImpl.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/ComponentContextImpl.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/ComponentContextProvider.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/ComponentManagerImpl.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/ScopeIdentifier.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/ServiceReferenceImpl.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/SimpleWorkContext.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/SystemSingletonAtomicComponent.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/WorkContextImpl.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/AbstractEvent.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/AbstractRequestEvent.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/ComponentEvent.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/ComponentStart.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/ComponentStop.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/ConversationEnd.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/ConversationStart.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/ConversationalEvent.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/HttpRequestEnded.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/HttpRequestStart.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/HttpSessionEnd.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/HttpSessionEvent.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/HttpSessionStart.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/RequestEnd.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/RequestEvent.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/RequestStart.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/scope/AbstractScopeContainer.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/scope/CompositeScopeContainer.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainer.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/scope/HttpSessionScopeContainer.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/scope/InstanceWrapperBase.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/scope/RequestScopeContainer.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/scope/ScopeRegistryImpl.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/scope/StatelessScopeContainer.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/deployer/AbstractDeploymentContext.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/deployer/ChildDeploymentContext.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/deployer/DeployerImpl.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/deployer/RootDeploymentContext.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/implementation/PojoWorkContextTunnel.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/implementation/composite/AbstractCompositeBuilder.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/implementation/composite/ComponentTimeoutException.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeBuilder.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeComponentImpl.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeComponentTypeLoader.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeLoader.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/implementation/composite/ManagedRequestContext.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/implementation/composite/ReferenceImpl.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/implementation/composite/ServiceImpl.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/injection/SingletonObjectFactory.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/loader/ComponentLoader.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/loader/ComponentTypeElementLoader.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/loader/IncludeLoader.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/loader/LoaderExceptionFormatter.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/loader/LoaderRegistryImpl.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/loader/PolicySetLoader.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/loader/PropertyLoader.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/loader/PropertyUtils.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/loader/ReferenceLoader.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/loader/ServiceLoader.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/loader/StringParserPropertyFactory.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/loader/WireLoader.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/monitor/DefaultExceptionFormatter.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/monitor/InvalidLevelException.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/monitor/JavaLoggingMonitorFactory.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/monitor/MonitorFactoryUtil.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/monitor/NullMonitorFactory.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/monitor/ProxyMonitorFactory.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/resolver/AutowireResolver.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/resolver/AutowireTargetNotFoundException.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/resolver/DefaultAutowireResolver.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/runtime/AbstractRuntime.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/services/classloading/ClassLoaderRegistryImpl.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/services/store/memory/MemoryStore.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/util/FileHelper.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/util/IOHelper.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/util/JavaIntrospectionHelper.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/CallbackInterfaceInterceptor.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/IncompatibleServiceContractExceptionFormatter.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/InvocationChainImpl.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/InvokerInterceptor.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/NoMethodForOperationException.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/NonBlockingInterceptor.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/NonBlockingInterceptorBuilder.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/OptimizedWireObjectFactory.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/ProxyServiceExtension.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/WireImpl.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/WireObjectFactory.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/WireObjectFactory2.java delete mode 100644 sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/WireUtils.java delete mode 100644 sandbox/rfeng/minicore/src/main/resources/org/apache/tuscany/core/composite.scdl delete mode 100644 sandbox/rfeng/minicore/src/main/resources/org/apache/tuscany/core/deployment.scdl delete mode 100644 sandbox/rfeng/minicore/src/main/resources/org/apache/tuscany/core/formatters.scdl delete mode 100644 sandbox/rfeng/minicore/src/main/resources/org/apache/tuscany/core/implementation.scdl delete mode 100644 sandbox/rfeng/minicore/src/main/resources/org/apache/tuscany/core/interfaceJava.scdl delete mode 100644 sandbox/rfeng/minicore/src/main/resources/org/apache/tuscany/core/javaImplementation.scdl delete mode 100644 sandbox/rfeng/minicore/src/main/resources/org/apache/tuscany/core/loader.scdl delete mode 100644 sandbox/rfeng/minicore/src/main/resources/org/apache/tuscany/core/systemImplementation.scdl delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/binding/local/AbstractLocalTargetInvokerTestCase.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/binding/local/LocalBindingBuilderTestCase.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/binding/local/LocalBindingLoaderTestCase.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/binding/local/LocalCallbackTargetInvokerInvocationExceptionTestCase.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/binding/local/LocalCallbackTargetInvokerTestCase.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/binding/local/LocalCallbackTargetInvokerThrowableTestCase.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/binding/local/LocalTargetInvokerTestCase.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/builder/BuilderRegistryNoBindingsTestCase.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/builder/BuilderRegistryTestCase.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/builder/ConnectorImplTestCase.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/builder/IllegalCallbackExceptionTestCase.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/builder/IncompatibleInterfacesExceptionTestCase.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/builder/InvalidSourceTypeExceptionTestCase.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/builder/InvalidTargetTypeExceptionTestCase.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/builder/TargetServiceNotFoundExceptionTestCase.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/builder/WirePostProcessorRegistryImplTestCase.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/builder/WiringExceptionFormatterTestCase.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/ComponentManagerImplTestCase.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/JavaObjectRegistrationTestCase.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/SystemSingletonAtomicComponentTestCase.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/event/EventTestCase.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/AbstractScopeContainerTestCase.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/BasicCompositeScopeTestCase.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/BasicConversationalScopeTestCase.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/BasicHttpSessionScopeTestCase.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/BasicRequestScopeTestCase.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/BasicStatelessScopeTestCase.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/CompositeScopeInitDestroyErrorTestCase.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainerDestroyOnExpirationTestCase.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainerMaxAgeTestCase.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainerMaxIdleTimeTestCase.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainerPersistenceTestCase.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/InstanceWrapperBaseTestCase.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/WorkContextTestCase.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeComponentImplTestCase.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/implementation/composite/DuplicateRegistrationTestCase.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/implementation/composite/ManagedRequestContextTestCase.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/implementation/composite/ReferenceImplTestCase.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/implementation/composite/ServiceImplTestCase.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/injection/SingletonObjectFactoryTestCase.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/AsyncTarget.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/BadContextPojo.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/BadNamePojo.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/BasicInterface.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/BasicInterfaceImpl.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/CompositeScopeComponent.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/CompositeScopeComponentImpl.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/CompositeScopeDestroyOnlyComponent.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/CompositeScopeInitDestroyComponent.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/CompositeScopeInitOnlyComponent.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/ConversationalScopeComponent.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/ConversationalScopeComponentImpl.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/ConversationalScopeDestroyOnlyComponent.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/ConversationalScopeInitDestroyComponent.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/ConversationalScopeInitOnlyComponent.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/OrderException.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/OrderedDependentPojo.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/OrderedDependentPojoImpl.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/OrderedEagerInitPojo.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/OrderedInitPojo.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/OrderedInitPojoImpl.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/OtherTarget.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/OtherTargetImpl.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/RequestScopeComponent.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/RequestScopeDestroyOnlyComponent.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/RequestScopeInitDestroyComponent.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/RequestScopeInitOnlyComponent.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/SessionScopeComponent.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/SessionScopeComponentImpl.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/SessionScopeInitDestroyComponent.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/SessionScopeInitOnlyComponent.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/SimpleTarget.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/SimpleTargetImpl.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/Source.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/SourceImpl.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/StatelessComponent.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/StatelessComponentImpl.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/Target.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/TargetImpl.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/wire/MockStaticInvoker.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/wire/MockSyncInterceptor.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/wire/MockTargetInvoker.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/monitor/DefaultExceptionFormatterTestCase.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/monitor/JavaLoggingTestCase.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/resolver/DefaultAutowireResolverTestCase.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/services/store/memory/MemoryStoreTestCase.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/util/Bean1.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/util/Bean2.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/util/JavaIntrospectionHelperTestCase.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/util/SuperBean.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/wire/CallbackInterfaceInterceptorTestCase.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/wire/ContractCompatibilityTestCase.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/wire/IncompatibleServiceContractExceptionFormatterTestCase.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/wire/InvocationChainImplTestCase.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/wire/NonBlockingInterceptorBuilderTestCase.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/wire/NonBlockingInterceptorTestCase.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/wire/OptimizedWireObjectFactoryTestCase.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/wire/WireImplTestCase.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/wire/WireObjectFactoryTestCase.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/wire/WireOptimizationTestCase.java delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/wire/WireUtilsTestCase.java delete mode 100644 sandbox/rfeng/minicore/src/test/resources/deployables/sample-calculator.jar delete mode 100644 sandbox/rfeng/minicore/src/test/resources/marshall/javaChangeSet.xml delete mode 100644 sandbox/rfeng/minicore/src/test/resources/org/apache/tuscany/core/deployer/boot1-include.scdl delete mode 100644 sandbox/rfeng/minicore/src/test/resources/org/apache/tuscany/core/deployer/boot1.scdl delete mode 100644 sandbox/rfeng/minicore/src/test/resources/org/apache/tuscany/core/deployer/boot2.scdl delete mode 100644 sandbox/rfeng/minicore/src/test/resources/org/apache/tuscany/core/loader/TestPolicy.scdl delete mode 100644 sandbox/rfeng/minicore/src/test/resources/org/apache/tuscany/core/loader/test-include.scdl delete mode 100644 sandbox/rfeng/minicore/src/test/resources/org/apache/tuscany/core/policy/PolicySet.scdl delete mode 100644 sandbox/rfeng/minicore/src/test/resources/org/apache/tuscany/core/property/ipo.xml delete mode 100644 sandbox/rfeng/minicore/src/test/resources/org/apache/tuscany/core/services/deployment/test.ext delete mode 100644 sandbox/rfeng/minicore/src/test/resources/org/apache/tuscany/core/services/deployment/test.scdl delete mode 100644 sandbox/rfeng/minicore/src/test/resources/repository/sample-calculator.jar (limited to 'sandbox/rfeng/minicore') diff --git a/sandbox/rfeng/minicore/.checkstyle b/sandbox/rfeng/minicore/.checkstyle deleted file mode 100644 index 3e57539570..0000000000 --- a/sandbox/rfeng/minicore/.checkstyle +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - diff --git a/sandbox/rfeng/minicore/.pmd b/sandbox/rfeng/minicore/.pmd deleted file mode 100644 index ffc4fe2bbb..0000000000 --- a/sandbox/rfeng/minicore/.pmd +++ /dev/null @@ -1,20 +0,0 @@ - - -true diff --git a/sandbox/rfeng/minicore/.ruleset b/sandbox/rfeng/minicore/.ruleset deleted file mode 100644 index ba9b5ce886..0000000000 --- a/sandbox/rfeng/minicore/.ruleset +++ /dev/null @@ -1,190 +0,0 @@ - - - - PMD Plugin preferences rule set - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/sandbox/rfeng/minicore/LICENSE.txt b/sandbox/rfeng/minicore/LICENSE.txt deleted file mode 100644 index 0084319535..0000000000 --- a/sandbox/rfeng/minicore/LICENSE.txt +++ /dev/null @@ -1,202 +0,0 @@ - - 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 deleted file mode 100644 index d83ebbe236..0000000000 --- a/sandbox/rfeng/minicore/NOTICE.txt +++ /dev/null @@ -1,14 +0,0 @@ -${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 deleted file mode 100644 index eb0895a4b8..0000000000 --- a/sandbox/rfeng/minicore/pom.xml +++ /dev/null @@ -1,74 +0,0 @@ - - - - - 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 deleted file mode 100644 index 4a06bc8c74..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/AbstractLocalTargetInvoker.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 63a9147b29..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/LocalBindingBuilder.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 9317a47457..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/LocalBindingDefinition.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 3442f1ca4c..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/LocalBindingLoader.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index c505ee99ab..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/LocalCallbackTargetInvoker.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index b70df0e23a..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/LocalReferenceBinding.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 543a0f53b4..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/LocalServiceBinding.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index b89a70a9e0..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/LocalTargetInvoker.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index a52e8e2f83..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/bootstrap/Bootstrapper.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index db6cba72f9..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/bootstrap/DefaultBootstrapper.java +++ /dev/null @@ -1,224 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 92f526dd8b..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/bootstrap/ExtensionActivator.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -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 deleted file mode 100644 index 33dd2175f9..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/BuilderRegistryImpl.java +++ /dev/null @@ -1,185 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index a46e038cb9..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/ComponentNotFoundException.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 6923fb6837..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/ConnectorImpl.java +++ /dev/null @@ -1,385 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 183ccea1b8..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/IllegalCallbackException.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 1a9c74aa3b..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/IncompatibleInterfacesException.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index d9df445530..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/InvalidSourceTypeException.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index e3c26c75d2..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/InvalidTargetTypeException.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index c351013297..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/NoBindingException.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 3c49767333..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/NoCompatibleBindingsException.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 71eb9ebd26..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/NoConversationalContractException.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 340a20f239..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/NoRegisteredBuilderException.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 7d3d49b937..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/SourceServiceNotFoundException.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index f22b421aa7..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/TargetServiceNotFoundException.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 117bb23180..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/WireCreationException.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 6f611956be..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/WirePostProcessorRegistryImpl.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 661dc8bfea..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/builder/WiringExceptionFormatter.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index e674112a89..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/CallableReferenceImpl.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 532a8b2bad..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/CallbackReferenceImpl.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index c8047abdab..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/ComponentContextImpl.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 4237d8b09f..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/ComponentContextProvider.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 76958c88ff..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/ComponentManagerImpl.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 35125b85ef..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/ScopeIdentifier.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 4d57d3efe0..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/ServiceReferenceImpl.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 7e978f6f35..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/SimpleWorkContext.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 872853506e..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/SystemSingletonAtomicComponent.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 3eb6e9d3eb..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/WorkContextImpl.java +++ /dev/null @@ -1,214 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 6d026ca08c..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/AbstractEvent.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 762b917600..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/AbstractRequestEvent.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 7de32a56d0..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/ComponentEvent.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 6be1c88d3f..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/ComponentStart.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index ac0a7fd5c0..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/ComponentStop.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 4a51d970c3..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/ConversationEnd.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 5725369bf6..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/ConversationStart.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index a75086e745..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/ConversationalEvent.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 01bd769031..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/HttpRequestEnded.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 9d0ff80dd7..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/HttpRequestStart.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 7f2bebe94a..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/HttpSessionEnd.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index ed245d0930..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/HttpSessionEvent.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 7f9c0fadea..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/HttpSessionStart.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 25856e86f8..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/RequestEnd.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 9a6d767236..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/RequestEvent.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 466f52551a..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/event/RequestStart.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 7fa8765426..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/scope/AbstractScopeContainer.java +++ /dev/null @@ -1,265 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 1a5dbcdcd4..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/scope/CompositeScopeContainer.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 2d9d3d938c..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainer.java +++ /dev/null @@ -1,190 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 5a398e921e..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/scope/HttpSessionScopeContainer.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index def862fa7c..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/scope/InstanceWrapperBase.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index d40277dc23..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/scope/RequestScopeContainer.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index bcf05982eb..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/scope/ScopeRegistryImpl.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 0e1d5cab6a..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/scope/StatelessScopeContainer.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 8d24047781..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/deployer/AbstractDeploymentContext.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index c2f8ae07fc..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/deployer/ChildDeploymentContext.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 18f078e4f6..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/deployer/DeployerImpl.java +++ /dev/null @@ -1,197 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index a523dadbf4..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/deployer/RootDeploymentContext.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index cef6675f05..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/implementation/PojoWorkContextTunnel.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index d12b407ea7..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/implementation/composite/AbstractCompositeBuilder.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index ed64cb1236..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/implementation/composite/ComponentTimeoutException.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 51d360ec39..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeBuilder.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 8df05048c8..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeComponentImpl.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 6cb31a8e20..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeComponentTypeLoader.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 008ee59de8..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeLoader.java +++ /dev/null @@ -1,224 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index f2a8109ee3..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/implementation/composite/ManagedRequestContext.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index f824980f29..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/implementation/composite/ReferenceImpl.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index b8b9b00b49..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/implementation/composite/ServiceImpl.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 713c1ae54f..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/injection/SingletonObjectFactory.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index b289e74a9b..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/loader/ComponentLoader.java +++ /dev/null @@ -1,360 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index beb0bc2731..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/loader/ComponentTypeElementLoader.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index e10a93bbc0..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/loader/IncludeLoader.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 26ec72ecb6..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/loader/LoaderExceptionFormatter.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 57fd1da870..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/loader/LoaderRegistryImpl.java +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 66d2a87593..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/loader/PolicySetLoader.java +++ /dev/null @@ -1,195 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index ac39c135d9..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/loader/PropertyLoader.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 57c1e1b5f4..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/loader/PropertyUtils.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 54183d1c72..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/loader/ReferenceLoader.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index c5be797cda..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/loader/ServiceLoader.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index eda09d6f11..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/loader/StringParserPropertyFactory.java +++ /dev/null @@ -1,191 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 9c60790111..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/loader/WireLoader.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 14468061e3..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/monitor/DefaultExceptionFormatter.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index cf07b0f914..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/monitor/InvalidLevelException.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 4adff1b0db..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/monitor/JavaLoggingMonitorFactory.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 92224d469f..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/monitor/MonitorFactoryUtil.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 46c52e38f6..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/monitor/NullMonitorFactory.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index d9ca9e6cfc..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/monitor/ProxyMonitorFactory.java +++ /dev/null @@ -1,234 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 8502f8d5f8..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/resolver/AutowireResolver.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 1526724ca9..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/resolver/AutowireTargetNotFoundException.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index eab78e25d9..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/resolver/DefaultAutowireResolver.java +++ /dev/null @@ -1,181 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 4a9cbb1ff5..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/runtime/AbstractRuntime.java +++ /dev/null @@ -1,379 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index afa7f64246..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/services/classloading/ClassLoaderRegistryImpl.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index a48cd5a2d7..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/services/store/memory/MemoryStore.java +++ /dev/null @@ -1,198 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 2544c90846..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/util/FileHelper.java +++ /dev/null @@ -1,704 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -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 deleted file mode 100644 index 62a007bd05..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/util/IOHelper.java +++ /dev/null @@ -1,182 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -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 deleted file mode 100644 index 6b11725481..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/util/JavaIntrospectionHelper.java +++ /dev/null @@ -1,439 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index c0bf7780f5..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/CallbackInterfaceInterceptor.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index d5fca62e1b..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/IncompatibleServiceContractExceptionFormatter.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 921b4e37fa..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/InvocationChainImpl.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 10cc254451..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/InvokerInterceptor.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index aec281d190..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/NoMethodForOperationException.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index d4848cde71..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/NonBlockingInterceptor.java +++ /dev/null @@ -1,193 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 8afcf8f6ad..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/NonBlockingInterceptorBuilder.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index ab958234bd..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/OptimizedWireObjectFactory.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 7c8cf0db3a..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/ProxyServiceExtension.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 7f748a15db..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/WireImpl.java +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 3d14138d56..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/WireObjectFactory.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index b5fab62d2f..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/WireObjectFactory2.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 8b839dc8df..0000000000 --- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/WireUtils.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 8cdf0ac2a8..0000000000 --- a/sandbox/rfeng/minicore/src/main/resources/org/apache/tuscany/core/composite.scdl +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - 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 deleted file mode 100644 index 804bd0bead..0000000000 --- a/sandbox/rfeng/minicore/src/main/resources/org/apache/tuscany/core/deployment.scdl +++ /dev/null @@ -1,62 +0,0 @@ - - - - - - - - - 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 deleted file mode 100644 index 5d2c0db012..0000000000 --- a/sandbox/rfeng/minicore/src/main/resources/org/apache/tuscany/core/formatters.scdl +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - - - - - - - - - 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 deleted file mode 100644 index c81115aafa..0000000000 --- a/sandbox/rfeng/minicore/src/main/resources/org/apache/tuscany/core/implementation.scdl +++ /dev/null @@ -1,79 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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 deleted file mode 100644 index b0664dc67a..0000000000 --- a/sandbox/rfeng/minicore/src/main/resources/org/apache/tuscany/core/interfaceJava.scdl +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - 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 deleted file mode 100644 index 69110ec05c..0000000000 --- a/sandbox/rfeng/minicore/src/main/resources/org/apache/tuscany/core/javaImplementation.scdl +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - 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 deleted file mode 100644 index b22f5d05f1..0000000000 --- a/sandbox/rfeng/minicore/src/main/resources/org/apache/tuscany/core/loader.scdl +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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 deleted file mode 100644 index 9a4178118f..0000000000 --- a/sandbox/rfeng/minicore/src/main/resources/org/apache/tuscany/core/systemImplementation.scdl +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - 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 deleted file mode 100644 index dfda132671..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/binding/local/AbstractLocalTargetInvokerTestCase.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index e628df47e2..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/binding/local/LocalBindingBuilderTestCase.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 0c35ae9a09..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/binding/local/LocalBindingLoaderTestCase.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 9b83d95918..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/binding/local/LocalCallbackTargetInvokerInvocationExceptionTestCase.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index d922ec8033..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/binding/local/LocalCallbackTargetInvokerTestCase.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 0c06842a60..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/binding/local/LocalCallbackTargetInvokerThrowableTestCase.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index e49447164d..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/binding/local/LocalTargetInvokerTestCase.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index f13ed3367d..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/builder/BuilderRegistryNoBindingsTestCase.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 34173154b8..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/builder/BuilderRegistryTestCase.java +++ /dev/null @@ -1,190 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 4c4e1a32b0..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/builder/ConnectorImplTestCase.java +++ /dev/null @@ -1,320 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index c6a9927db3..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/builder/IllegalCallbackExceptionTestCase.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 5d370fcfc5..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/builder/IncompatibleInterfacesExceptionTestCase.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 67ad003d58..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/builder/InvalidSourceTypeExceptionTestCase.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 61060293ce..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/builder/InvalidTargetTypeExceptionTestCase.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 2d056ac964..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/builder/TargetServiceNotFoundExceptionTestCase.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index fcd5f03189..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/builder/WirePostProcessorRegistryImplTestCase.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index e05a162d7a..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/builder/WiringExceptionFormatterTestCase.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index c1710e9b8e..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/ComponentManagerImplTestCase.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 2d00a13716..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/JavaObjectRegistrationTestCase.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index fac45ebfb5..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/SystemSingletonAtomicComponentTestCase.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 93cb50ddcb..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/event/EventTestCase.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index a6e4de3c48..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/AbstractScopeContainerTestCase.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index cb66af27b0..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/BasicCompositeScopeTestCase.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 02f5540dea..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/BasicConversationalScopeTestCase.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 1f29c92c92..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/BasicHttpSessionScopeTestCase.java +++ /dev/null @@ -1,220 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 4aad2dc0c6..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/BasicRequestScopeTestCase.java +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index a7cab71ade..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/BasicStatelessScopeTestCase.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 01c426e917..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/CompositeScopeInitDestroyErrorTestCase.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index caf0c0cc5e..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainerDestroyOnExpirationTestCase.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index e896b410d0..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainerMaxAgeTestCase.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 9ac97bff32..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainerMaxIdleTimeTestCase.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index a8960c4575..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainerPersistenceTestCase.java +++ /dev/null @@ -1,189 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index c583ff19c6..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/InstanceWrapperBaseTestCase.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 94feca05be..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/WorkContextTestCase.java +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index a5574c7f78..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeComponentImplTestCase.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index c3394c1043..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/implementation/composite/DuplicateRegistrationTestCase.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 12299e762b..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/implementation/composite/ManagedRequestContextTestCase.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 34d37469a7..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/implementation/composite/ReferenceImplTestCase.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index bb8ed020e0..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/implementation/composite/ServiceImplTestCase.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 876e68d5b3..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/injection/SingletonObjectFactoryTestCase.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 653d5d7335..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/AsyncTarget.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 066acc346d..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/BadContextPojo.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 77ec37f9e4..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/BadNamePojo.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index b7921c248f..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/BasicInterface.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index f7d7bb38cf..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/BasicInterfaceImpl.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 88b97216cd..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/CompositeScopeComponent.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 93ee1f707a..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/CompositeScopeComponentImpl.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 16ce3b5569..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/CompositeScopeDestroyOnlyComponent.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 05b938a87c..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/CompositeScopeInitDestroyComponent.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index f9f80ca15c..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/CompositeScopeInitOnlyComponent.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index c71ac0586f..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/ConversationalScopeComponent.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 5ea7278e1f..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/ConversationalScopeComponentImpl.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 8cea9efa49..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/ConversationalScopeDestroyOnlyComponent.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 40dbfedf2c..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/ConversationalScopeInitDestroyComponent.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index caaa0c39e7..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/ConversationalScopeInitOnlyComponent.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index af257c226d..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/OrderException.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 2033f0eca5..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/OrderedDependentPojo.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 439c3d143c..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/OrderedDependentPojoImpl.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 1986952747..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/OrderedEagerInitPojo.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 0b891cfa42..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/OrderedInitPojo.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index a7063f6353..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/OrderedInitPojoImpl.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 0b897daa40..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/OtherTarget.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index a3b2bbf098..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/OtherTargetImpl.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 8c7dc107ee..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/RequestScopeComponent.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 5224ceda5f..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/RequestScopeDestroyOnlyComponent.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 38b188a4b5..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/RequestScopeInitDestroyComponent.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 707f8ab50f..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/RequestScopeInitOnlyComponent.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 827ba804f2..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/SessionScopeComponent.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index e547bf6113..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/SessionScopeComponentImpl.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index c11bd1bd49..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/SessionScopeInitDestroyComponent.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 095cc916ec..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/SessionScopeInitOnlyComponent.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index c78ba00a7a..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/SimpleTarget.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 634a07a401..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/SimpleTargetImpl.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index f7969f748b..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/Source.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 187e33b2bd..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/SourceImpl.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index c16ac942a3..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/StatelessComponent.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 64a23c12c8..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/StatelessComponentImpl.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 778c14665d..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/Target.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 037dd3a37c..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/component/TargetImpl.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 98f5973f62..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/wire/MockStaticInvoker.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 1fe2c027ab..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/wire/MockSyncInterceptor.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 3fcc75bdb4..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/mock/wire/MockTargetInvoker.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 437e718206..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/monitor/DefaultExceptionFormatterTestCase.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 5fdf035c7a..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/monitor/JavaLoggingTestCase.java +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 6d50489f18..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/resolver/DefaultAutowireResolverTestCase.java +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 06ea7cf903..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/services/store/memory/MemoryStoreTestCase.java +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 79fad549aa..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/util/Bean1.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 7f7f03da9e..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/util/Bean2.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 797b147b54..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/util/JavaIntrospectionHelperTestCase.java +++ /dev/null @@ -1,180 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 83aef7fb5e..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/util/SuperBean.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 6c50cb406f..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/wire/CallbackInterfaceInterceptorTestCase.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index c955faf7b1..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/wire/ContractCompatibilityTestCase.java +++ /dev/null @@ -1,390 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index a9f455bc62..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/wire/IncompatibleServiceContractExceptionFormatterTestCase.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 9875058abb..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/wire/InvocationChainImplTestCase.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index c563217306..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/wire/NonBlockingInterceptorBuilderTestCase.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index c08d1453db..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/wire/NonBlockingInterceptorTestCase.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 5293678d12..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/wire/OptimizedWireObjectFactoryTestCase.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index e337133523..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/wire/WireImplTestCase.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 9f21b9efdb..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/wire/WireObjectFactoryTestCase.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 1db3892471..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/wire/WireOptimizationTestCase.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index a9da65e0ba..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/wire/WireUtilsTestCase.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -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 deleted file mode 100644 index 0ca3a1b781..0000000000 Binary files a/sandbox/rfeng/minicore/src/test/resources/deployables/sample-calculator.jar and /dev/null differ diff --git a/sandbox/rfeng/minicore/src/test/resources/marshall/javaChangeSet.xml b/sandbox/rfeng/minicore/src/test/resources/marshall/javaChangeSet.xml deleted file mode 100644 index 2ac4c6932e..0000000000 --- a/sandbox/rfeng/minicore/src/test/resources/marshall/javaChangeSet.xml +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - - #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 deleted file mode 100644 index 838dbf6a9c..0000000000 --- a/sandbox/rfeng/minicore/src/test/resources/org/apache/tuscany/core/deployer/boot1-include.scdl +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - - 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 deleted file mode 100644 index 8a71aa5698..0000000000 --- a/sandbox/rfeng/minicore/src/test/resources/org/apache/tuscany/core/deployer/boot1.scdl +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - 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 deleted file mode 100644 index a4f5ecf1e9..0000000000 --- a/sandbox/rfeng/minicore/src/test/resources/org/apache/tuscany/core/deployer/boot2.scdl +++ /dev/null @@ -1,160 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - .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 deleted file mode 100644 index ee75ea23f0..0000000000 --- a/sandbox/rfeng/minicore/src/test/resources/org/apache/tuscany/core/loader/TestPolicy.scdl +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - \ 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 deleted file mode 100644 index 584846504b..0000000000 --- a/sandbox/rfeng/minicore/src/test/resources/org/apache/tuscany/core/loader/test-include.scdl +++ /dev/null @@ -1,22 +0,0 @@ - - - - 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 deleted file mode 100644 index 0860855d9d..0000000000 --- a/sandbox/rfeng/minicore/src/test/resources/org/apache/tuscany/core/policy/PolicySet.scdl +++ /dev/null @@ -1,66 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ 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 deleted file mode 100644 index 5bef464cf7..0000000000 --- a/sandbox/rfeng/minicore/src/test/resources/org/apache/tuscany/core/property/ipo.xml +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - 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 deleted file mode 100644 index 042f3ce1f3..0000000000 --- a/sandbox/rfeng/minicore/src/test/resources/org/apache/tuscany/core/services/deployment/test.ext +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ 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 deleted file mode 100644 index 1e09549194..0000000000 --- a/sandbox/rfeng/minicore/src/test/resources/org/apache/tuscany/core/services/deployment/test.scdl +++ /dev/null @@ -1,22 +0,0 @@ - - - - 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 deleted file mode 100644 index 0ca3a1b781..0000000000 Binary files a/sandbox/rfeng/minicore/src/test/resources/repository/sample-calculator.jar and /dev/null differ -- cgit v1.2.3