From 9bed5ae38c581999db465b42b504026a7097af95 Mon Sep 17 00:00:00 2001 From: lresende Date: Wed, 11 Nov 2009 23:11:56 +0000 Subject: Moving 1.x branches git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@835141 13f79535-47bb-0310-9956-ffa450edef68 --- branches/pre-spec-changes/kernel/api/.checkstyle | 24 - branches/pre-spec-changes/kernel/api/.pmd | 20 - branches/pre-spec-changes/kernel/api/.ruleset | 190 --- branches/pre-spec-changes/kernel/api/LICENSE.txt | 202 --- branches/pre-spec-changes/kernel/api/NOTICE.txt | 14 - branches/pre-spec-changes/kernel/api/pom.xml | 42 - .../org/apache/tuscany/api/TuscanyException.java | 164 --- .../tuscany/api/TuscanyRuntimeException.java | 168 --- .../apache/tuscany/api/annotation/DataContext.java | 42 - .../apache/tuscany/api/annotation/DataType.java | 60 - .../apache/tuscany/api/annotation/LogLevel.java | 40 - .../org/apache/tuscany/api/annotation/Monitor.java | 34 - .../tuscany/api/TuscanyExceptionTestCase.java | 164 --- .../api/TuscanyRuntimeExceptionTestCase.java | 142 -- branches/pre-spec-changes/kernel/core/.pmd | 20 - branches/pre-spec-changes/kernel/core/.ruleset | 190 --- branches/pre-spec-changes/kernel/core/LICENSE.txt | 202 --- branches/pre-spec-changes/kernel/core/NOTICE.txt | 14 - branches/pre-spec-changes/kernel/core/pom.xml | 93 -- .../binding/local/AbstractLocalTargetInvoker.java | 77 -- .../core/binding/local/LocalBindingBuilder.java | 56 - .../core/binding/local/LocalBindingDefinition.java | 39 - .../core/binding/local/LocalBindingLoader.java | 70 - .../binding/local/LocalCallbackTargetInvoker.java | 74 - .../core/binding/local/LocalReferenceBinding.java | 61 - .../core/binding/local/LocalServiceBinding.java | 55 - .../core/binding/local/LocalTargetInvoker.java | 73 - .../tuscany/core/bootstrap/Bootstrapper.java | 88 -- .../core/bootstrap/DefaultBootstrapper.java | 262 ---- .../tuscany/core/bootstrap/DefaultRuntime.java | 83 -- .../tuscany/core/builder/BuilderRegistryImpl.java | 241 ---- .../apache/tuscany/core/builder/ConnectorImpl.java | 609 --------- .../core/builder/IllegalCallbackException.java | 54 - .../builder/IncompatibleInterfacesException.java | 93 -- .../core/builder/InvalidTargetTypeException.java | 41 - .../builder/NoCompatibleBindingsException.java | 36 - .../builder/NoConversationalContractException.java | 37 - .../core/builder/NoRegisteredBuilderException.java | 38 - .../builder/TargetServiceNotFoundException.java | 42 - .../tuscany/core/builder/WireConnectException.java | 58 - .../builder/WirePostProcessorRegistryImpl.java | 57 - .../core/builder/WiringExceptionFormatter.java | 72 - .../tuscany/core/component/ScopeIdentifier.java | 35 - .../tuscany/core/component/WorkContextImpl.java | 211 --- .../core/component/event/AbstractEvent.java | 39 - .../core/component/event/AbstractRequestEvent.java | 38 - .../core/component/event/CompositeEvent.java | 33 - .../core/component/event/CompositeStart.java | 47 - .../core/component/event/CompositeStop.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 | 158 --- .../component/scope/CompositeScopeContainer.java | 189 --- .../scope/CompositeScopeObjectFactory.java | 50 - .../scope/ConversationalScopeContainer.java | 217 --- .../scope/ConversationalScopeObjectFactory.java | 58 - .../component/scope/HttpSessionScopeContainer.java | 135 -- .../scope/HttpSessionScopeObjectFactory.java | 54 - .../core/component/scope/InstanceWrapper.java | 41 - .../core/component/scope/InstanceWrapperImpl.java | 63 - .../component/scope/RequestScopeContainer.java | 126 -- .../component/scope/RequestScopeObjectFactory.java | 47 - .../core/component/scope/ScopeRegistryImpl.java | 63 - .../component/scope/StatelessScopeContainer.java | 75 -- .../scope/StatelessScopeObjectFactory.java | 54 - .../databinding/impl/DataBindingInteceptor.java | 130 -- .../impl/DataBindingJavaInterfaceProcessor.java | 121 -- .../databinding/impl/DataBindingRegistryImpl.java | 80 -- .../impl/DataBindingWirePostProcessor.java | 157 --- .../core/databinding/impl/DataTypeLoader.java | 67 - .../core/databinding/impl/DirectedGraph.java | 357 ----- .../databinding/impl/Input2InputTransformer.java | 217 --- .../core/databinding/impl/MediatorImpl.java | 171 --- .../databinding/impl/Output2OutputTransformer.java | 201 --- .../databinding/impl/PassByValueInterceptor.java | 244 ---- .../impl/PassByValueWirePostProcessor.java | 190 --- .../core/databinding/impl/PipedTransformer.java | 66 - .../core/databinding/impl/SimpleDataBinding.java | 61 - .../impl/TransformationContextImpl.java | 83 -- .../databinding/impl/TransformerRegistryImpl.java | 73 - .../core/databinding/xml/DOMDataBinding.java | 56 - .../core/databinding/xml/DOMWrapperHandler.java | 79 -- .../core/databinding/xml/DOMXMLStreamReader.java | 1415 -------------------- .../core/databinding/xml/InputSource2Node.java | 65 - .../core/databinding/xml/InputSource2SAX.java | 63 - .../core/databinding/xml/InputStream2Node.java | 67 - .../core/databinding/xml/InputStream2SAX.java | 62 - .../tuscany/core/databinding/xml/Node2Object.java | 49 - .../core/databinding/xml/Node2OutputStream.java | 66 - .../tuscany/core/databinding/xml/Node2String.java | 59 - .../tuscany/core/databinding/xml/Node2Writer.java | 65 - .../core/databinding/xml/Node2XMLStreamReader.java | 60 - .../tuscany/core/databinding/xml/Object2Node.java | 62 - .../tuscany/core/databinding/xml/Reader2Node.java | 65 - .../tuscany/core/databinding/xml/Reader2SAX.java | 58 - .../tuscany/core/databinding/xml/SAX2DOM.java | 244 ---- .../tuscany/core/databinding/xml/SAX2DOMPipe.java | 67 - .../databinding/xml/Source2ResultTransformer.java | 60 - .../core/databinding/xml/StAX2SAXAdapter.java | 256 ---- .../tuscany/core/databinding/xml/StAXHelper.java | 806 ----------- .../core/databinding/xml/StreamDataPipe.java | 57 - .../tuscany/core/databinding/xml/String2Node.java | 60 - .../tuscany/core/databinding/xml/String2SAX.java | 59 - .../databinding/xml/String2XMLStreamReader.java | 55 - .../databinding/xml/Writer2ReaderDataPipe.java | 56 - .../core/databinding/xml/XMLStreamReader2Node.java | 62 - .../core/databinding/xml/XMLStreamReader2SAX.java | 73 - .../databinding/xml/XMLStreamReader2String.java | 55 - .../core/databinding/xml/XMLStringDataBinding.java | 33 - .../core/deployer/AbstractDeploymentContext.java | 61 - .../core/deployer/ChildDeploymentContext.java | 60 - .../apache/tuscany/core/deployer/DeployerImpl.java | 145 -- .../core/deployer/RootDeploymentContext.java | 65 - .../core/idl/java/IllegalCallbackException.java | 34 - .../tuscany/core/idl/java/InterfaceJavaLoader.java | 118 -- .../java/JavaInterfaceProcessorRegistryImpl.java | 162 --- .../implementation/IntrospectionRegistryImpl.java | 135 -- .../core/implementation/PojoAtomicComponent.java | 282 ---- .../core/implementation/PojoConfiguration.java | 232 ---- .../composite/AbstractCompositeBuilder.java | 71 - .../composite/AbstractCompositeComponent.java | 151 --- .../composite/AbstractCompositeContext.java | 120 -- .../composite/ComponentTimeoutException.java | 33 - .../implementation/composite/CompositeBuilder.java | 50 - .../composite/CompositeComponentImpl.java | 114 -- .../composite/CompositeComponentTypeLoader.java | 67 - .../implementation/composite/CompositeLoader.java | 235 ---- .../core/implementation/composite/Dependency.java | 39 - .../composite/ImplementationCompositeLoader.java | 126 -- .../composite/ManagedCompositeContext.java | 80 -- .../composite/ManagedRequestContext.java | 49 - .../implementation/composite/ReferenceImpl.java | 90 -- .../core/implementation/composite/ServiceImpl.java | 98 -- .../composite/SystemCompositeBuilder.java | 67 - .../composite/SystemSingletonAtomicComponent.java | 161 --- .../implementation/java/JavaAtomicComponent.java | 100 -- .../implementation/java/JavaComponentBuilder.java | 198 --- .../java/JavaComponentTypeLoader.java | 90 -- .../implementation/java/JavaImplementation.java | 37 - .../java/JavaImplementationLoader.java | 63 - .../implementation/java/JavaTargetInvoker.java | 144 -- .../processor/AllowsPassByReferenceProcessor.java | 51 - .../processor/AmbiguousConstructorException.java | 41 - .../processor/ConstructorProcessor.java | 106 -- .../implementation/processor/ContextProcessor.java | 124 -- .../processor/ConversationProcessor.java | 142 -- .../implementation/processor/DestroyProcessor.java | 62 - .../processor/DuplicateConstructorException.java | 38 - .../processor/DuplicateDestructorException.java | 37 - .../processor/DuplicateInitException.java | 37 - .../processor/DuplicateReferenceException.java | 38 - .../processor/DuplicateResourceException.java | 37 - .../processor/EagerInitProcessor.java | 59 - .../processor/HeuristicPojoProcessor.java | 546 -------- .../IllegalCallbackReferenceException.java | 37 - .../processor/IllegalContextException.java | 37 - .../processor/IllegalDestructorException.java | 37 - .../processor/IllegalInitException.java | 36 - .../processor/IllegalReferenceException.java | 37 - .../processor/IllegalResourceException.java | 37 - .../IllegalServiceDefinitionException.java | 37 - .../ImplementationProcessorServiceImpl.java | 410 ------ .../implementation/processor/InitProcessor.java | 62 - .../processor/InvalidAutowireException.java | 34 - .../processor/InvalidConstructorException.java | 39 - .../InvalidConversationalImplementation.java | 45 - .../processor/InvalidPropertyException.java | 34 - .../processor/InvalidReferenceException.java | 41 - .../processor/InvalidResourceException.java | 33 - .../processor/InvalidServiceType.java | 34 - .../implementation/processor/MonitorProcessor.java | 57 - .../processor/NoConstructorException.java | 36 - .../processor/PropertyProcessor.java | 78 -- .../processor/ReferenceProcessor.java | 150 --- .../processor/ResourceProcessor.java | 115 -- .../implementation/processor/ScopeProcessor.java | 64 - .../implementation/processor/ServiceProcessor.java | 156 --- .../processor/ServiceTypeNotFoundException.java | 34 - .../processor/UnknownContextTypeException.java | 32 - .../system/builder/SystemComponentBuilder.java | 184 --- .../component/SystemAtomicComponentImpl.java | 55 - .../system/loader/SystemComponentTypeLoader.java | 101 -- .../loader/SystemCompositeComponentTypeLoader.java | 70 - .../system/loader/SystemImplementationLoader.java | 75 -- .../model/SystemCompositeImplementation.java | 57 - .../system/model/SystemImplementation.java | 51 - .../injection/ArrayMultiplicityObjectFactory.java | 54 - .../core/injection/CallbackWireObjectFactory.java | 47 - .../injection/CompositeContextObjectFactory.java | 50 - .../tuscany/core/injection/ContextInjector.java | 32 - .../injection/ConversationIDObjectFactory.java | 36 - .../tuscany/core/injection/EventInvoker.java | 34 - .../tuscany/core/injection/FieldInjector.java | 57 - .../core/injection/InjectionRuntimeException.java | 55 - .../apache/tuscany/core/injection/Injector.java | 35 - .../core/injection/InvalidAccessorException.java | 34 - .../injection/InvalidResourceTypeException.java | 33 - .../tuscany/core/injection/JNDIObjectFactory.java | 50 - .../injection/ListMultiplicityObjectFactory.java | 50 - .../tuscany/core/injection/MethodEventInvoker.java | 55 - .../tuscany/core/injection/MethodInjector.java | 55 - .../core/injection/NoAccessorException.java | 39 - .../injection/NoMultiplicityTypeException.java | 29 - .../core/injection/ObjectCallbackException.java | 48 - .../tuscany/core/injection/PojoObjectFactory.java | 119 -- .../injection/RequestContextObjectFactory.java | 26 - .../core/injection/ResourceNotFoundException.java | 34 - .../core/injection/ResourceObjectFactory.java | 146 -- .../core/injection/SingletonObjectFactory.java | 39 - .../core/launcher/CompositeContextImpl.java | 60 - .../tuscany/core/launcher/LaunchException.java | 49 - .../apache/tuscany/core/launcher/LauncherImpl.java | 250 ---- .../tuscany/core/launcher/LauncherRuntimeInfo.java | 96 -- .../tuscany/core/loader/ComponentLoader.java | 315 ----- .../core/loader/ComponentTypeElementLoader.java | 89 -- .../tuscany/core/loader/DependencyLoader.java | 88 -- .../apache/tuscany/core/loader/IncludeLoader.java | 111 -- .../tuscany/core/loader/JNDIPropertyFactory.java | 52 - .../core/loader/LoaderExceptionFormatter.java | 50 - .../tuscany/core/loader/LoaderRegistryImpl.java | 181 --- .../tuscany/core/loader/PolicySetLoader.java | 196 --- .../apache/tuscany/core/loader/PropertyLoader.java | 103 -- .../tuscany/core/loader/ReferenceLoader.java | 98 -- .../apache/tuscany/core/loader/ServiceLoader.java | 118 -- .../org/apache/tuscany/core/loader/StAXUtil.java | 159 --- .../core/loader/StringParserPropertyFactory.java | 191 --- .../org/apache/tuscany/core/loader/WireLoader.java | 112 -- .../core/monitor/DefaultExceptionFormatter.java | 54 - .../core/monitor/InvalidLevelException.java | 64 - .../core/monitor/JavaLoggingMonitorFactory.java | 321 ----- .../tuscany/core/monitor/MonitorFactoryUtil.java | 78 -- .../tuscany/core/monitor/NullMonitorFactory.java | 58 - .../tuscany/core/policy/IntentRegistryImpl.java | 167 --- .../core/policy/PolicyBuilderRegistryImpl.java | 79 -- .../tuscany/core/policy/PolicyEngineImpl.java | 297 ---- .../apache/tuscany/core/policy/PolicyHelper.java | 65 - .../tuscany/core/property/PropertyHelper.java | 197 --- .../core/property/PropertyObjectFactoryImpl.java | 96 -- .../core/property/SimplePropertyObjectFactory.java | 63 - .../tuscany/core/runtime/AbstractRuntime.java | 311 ----- .../services/artifact/LocalMavenRepository.java | 100 -- .../services/deployment/AssemblyServiceImpl.java | 83 -- .../deployment/ContributionServiceImpl.java | 90 -- .../deployment/InvalidDocumentException.java | 32 - .../services/deployment/XMLChangeSetHandler.java | 132 -- .../extension/AbstractExtensionDeployer.java | 122 -- .../host/DelegatingResourceHostRegistry.java | 142 -- .../core/services/store/memory/MemoryStore.java | 198 --- .../core/services/work/jca/JcaWorkScheduler.java | 206 --- .../services/work/jsr237/Jsr237WorkScheduler.java | 217 --- .../work/jsr237/workmanager/DefaultWorkEvent.java | 73 - .../work/jsr237/workmanager/DefaultWorkItem.java | 166 --- .../jsr237/workmanager/ThreadPoolWorkManager.java | 220 --- .../tuscany/core/util/ClassLoaderHelper.java | 93 -- .../tuscany/core/util/JavaIntrospectionHelper.java | 439 ------ .../tuscany/core/wire/BridgingInterceptor.java | 29 - .../core/wire/CallbackInterfaceInterceptor.java | 60 - .../core/wire/InboundInvocationChainImpl.java | 41 - .../apache/tuscany/core/wire/InboundWireImpl.java | 166 --- ...ompatibleServiceContractExceptionFormatter.java | 95 -- .../tuscany/core/wire/InvocationChainImpl.java | 107 -- .../tuscany/core/wire/InvokerInterceptor.java | 59 - .../org/apache/tuscany/core/wire/LoopBackWire.java | 33 - .../core/wire/NoMethodForOperationException.java | 42 - .../core/wire/NonBlockingBridgingInterceptor.java | 189 --- .../core/wire/OptimizedWireObjectFactory.java | 47 - .../core/wire/OutboundInvocationChainImpl.java | 53 - .../apache/tuscany/core/wire/OutboundWireImpl.java | 176 --- .../core/wire/SynchronousBridgingInterceptor.java | 55 - .../tuscany/core/wire/WireObjectFactory.java | 84 -- .../tuscany/core/wire/WireServiceExtension.java | 287 ---- .../org/apache/tuscany/core/wire/WireUtils.java | 146 -- .../wire/jdk/JDKCallbackInvocationHandler.java | 137 -- .../core/wire/jdk/JDKInboundInvocationHandler.java | 173 --- .../wire/jdk/JDKOutboundInvocationHandler.java | 249 ---- .../tuscany/core/wire/jdk/JDKWireService.java | 114 -- .../org/apache/tuscany/core/composite.scdl | 45 - .../org/apache/tuscany/core/databinding.scdl | 157 --- .../org/apache/tuscany/core/formatters.scdl | 43 - .../org/apache/tuscany/core/implementation.scdl | 78 -- .../org/apache/tuscany/core/interfaceJava.scdl | 35 - .../apache/tuscany/core/javaImplementation.scdl | 39 - .../resources/org/apache/tuscany/core/loader.scdl | 52 - .../apache/tuscany/core/systemImplementation.scdl | 46 - .../local/AbstractLocalTargetInvokerTestCase.java | 72 - .../binding/local/LocalBindingBuilderTestCase.java | 38 - .../binding/local/LocalBindingLoaderTestCase.java | 70 - ...ckTargetInvokerInvocationExceptionTestCase.java | 86 -- .../local/LocalCallbackTargetInvokerTestCase.java | 82 -- ...ocalCallbackTargetInvokerThrowableTestCase.java | 98 -- .../binding/local/LocalTargetInvokerTestCase.java | 127 -- .../core/bootstrap/BootstrapperTestCase.java | 42 - .../builder/AbstractConnectorImplTestCase.java | 306 ----- .../core/builder/AtomicConnectorTestCase.java | 125 -- .../builder/BuilderRegistryNoBindingsTestCase.java | 84 -- .../core/builder/BuilderRegistryTestCase.java | 217 --- .../core/builder/ConnectorImplTestCase.java | 322 ----- .../core/builder/ConnectorPostProcessTestCase.java | 104 -- .../builder/IllegalCallbackExceptionTestCase.java | 43 - .../builder/InboundtoOutboundConnectTestCase.java | 168 --- .../IncompatibleInterfacesExceptionTestCase.java | 41 - .../InvalidTargetTypeExceptionTestCase.java | 41 - .../core/builder/LocalReferenceWiringTestCase.java | 236 ---- ...rwardNonBlockingCallbackConnectionTestCase.java | 172 --- ...ckingForwardSyncCallbackConnectionTestCase.java | 171 --- .../builder/OutboundToInboundConnectTestCase.java | 184 --- .../core/builder/ReferenceConnectorTestCase.java | 168 --- .../core/builder/ServiceConnectorTestCase.java | 171 --- ...nchronousForwardCallbackConnectionTestCase.java | 256 ---- .../TargetServiceNotFoundExceptionTestCase.java | 41 - .../WirePostProcessorRegistryImplTestCase.java | 63 - .../builder/WiringExceptionFormatterTestCase.java | 88 -- .../core/component/WorkContextImplTestCase.java | 65 - .../core/component/event/EventTestCase.java | 72 - .../scope/AbstractScopeContainerTestCase.java | 126 -- .../scope/BasicCompositeScopeTestCase.java | 127 -- .../scope/BasicConversationalScopeTestCase.java | 129 -- .../scope/BasicHttpSessionScopeTestCase.java | 145 -- .../component/scope/BasicRequestScopeTestCase.java | 128 -- .../scope/BasicStatelessScopeTestCase.java | 120 -- .../CompositeScopeInitDestroyErrorTestCase.java | 78 -- .../CompositeScopeInstanceLifecycleTestCase.java | 186 --- .../scope/CompositeScopeObjectFactoryTestCase.java | 38 - .../scope/CompositeScopeRestartTestCase.java | 99 -- ...lScopeContainerDestroyOnExpirationTestCase.java | 121 -- ...ConversationalScopeContainerMaxAgeTestCase.java | 76 -- ...rsationalScopeContainerMaxIdleTimeTestCase.java | 79 -- ...rsationalScopeContainerPersistenceTestCase.java | 181 --- ...nversationalScopeInstanceLifecycleTestCase.java | 70 - .../scope/ConversationalScopeRestartTestCase.java | 112 -- .../scope/DependencyLifecycleTestCase.java | 170 --- .../HttpSessionScopeInitDestroyErrorTestCase.java | 69 - .../HttpSessionScopeInstanceLifecycleTestCase.java | 136 -- .../scope/HttpSessionScopeRestartTestCase.java | 105 -- .../component/scope/InstanceWrapperTestCase.java | 66 - .../tuscany/core/component/scope/MockFactory.java | 137 -- .../RequestScopeInitDestroyErrorTestCase.java | 63 - .../RequestScopeInstanceLifecycleTestCase.java | 129 -- .../scope/RequestScopeRestartTestCase.java | 99 -- .../component/scope/ScopeRegistryTestCase.java | 80 -- .../scope/StatelessScopeContainerTestCase.java | 48 - .../scope/StatelessScopeObjectFactoryTestCase.java | 37 - .../core/component/scope/WorkContextTestCase.java | 212 --- .../impl/DataBindingInterceptorTestCase.java | 131 -- .../DataBindingJavaInterfaceProcessorTestCase.java | 79 -- .../impl/DataBindingLoaderTestCase.java | 79 -- .../impl/DataBindingRegistryImplTestCase.java | 86 -- .../core/databinding/impl/DataBindingTestCase.java | 49 - ...ndingWirePostProcessorOptimizationTestCase.java | 111 -- .../impl/DataBindingWirePostProcessorTestCase.java | 231 ---- .../databinding/impl/DirectedGraphTestCase.java | 89 -- .../databinding/impl/IDLTransformerTestCase.java | 219 --- .../databinding/impl/MediatorImplTestCase.java | 118 -- .../impl/PassByValueInterceptorTestCase.java | 69 - .../impl/PassByValueWirePostProcessorTestCase.java | 177 --- .../impl/TransformerRegistryImplTestCase.java | 106 -- .../core/databinding/xml/DOM2StAXTestCase.java | 76 -- .../core/databinding/xml/DataPipeTestCase.java | 89 -- .../core/databinding/xml/Node2StringTestCase.java | 35 - .../xml/PushTransformationTestCase.java | 81 -- .../core/databinding/xml/StAXHelperTestCase.java | 47 - .../databinding/xml/TraxTransformerTestCase.java | 99 -- .../core/deployer/BootstrapDeployerTestCase.java | 168 --- .../java/ConversationalIntrospectionTestCase.java | 82 -- ...JavaInterfaceProcessorRegistryImplTestCase.java | 100 -- .../IntrospectionRegistryTestCase.java | 124 -- .../PojoAtomicComponentTestCase.java | 159 --- .../tuscany/core/implementation/TestUtils.java | 74 - .../AbstractCompositeContextTestCase.java | 348 ----- .../composite/AutowireResolutionTestCase.java | 86 -- .../implementation/composite/AutowireTestCase.java | 230 ---- .../composite/CompositeBuilderTestCase.java | 208 --- .../CompositeComponentImplBasicTestCase.java | 119 -- .../CompositeComponentImplSystemWireTestCase.java | 170 --- .../composite/CompositeComponentImplTestCase.java | 179 --- .../CompositeComponentResolutionTestCase.java | 84 -- .../composite/CompositeLifecycleTestCase.java | 120 -- .../CompositeLoaderWireResolutionTestCase.java | 227 ---- .../composite/CompositePropagationTestCase.java | 95 -- .../composite/DuplicateRegistrationTestCase.java | 105 -- .../ImplementationCompositeLoaderTestCase.java | 194 --- .../composite/JavaObjectRegistrationTestCase.java | 88 -- .../composite/ManagedRequestContextTestCase.java | 42 - .../composite/ReferenceImplTestCase.java | 61 - .../composite/ServiceImplTestCase.java | 61 - .../composite/SystemComponentBuilderTestCase.java | 180 --- .../SystemSingletonAtomicComponentTestCase.java | 61 - ...vaAtomicComponentMetadataInjectionTestCase.java | 37 - ...avaAtomicComponentNegativeMetadataTestCase.java | 49 - .../java/JavaBuilderPropertyTestCase.java | 139 -- ...JavaComponentBuilderConversationIDTestCase.java | 82 -- .../java/JavaComponentBuilderMetadataTestCase.java | 114 -- .../JavaComponentBuilderReferenceTestCase.java | 151 --- .../java/JavaComponentBuilderResourceTestCase.java | 83 -- .../java/JavaComponentTypeLoaderTestCase.java | 78 -- .../java/JavaReferenceWireTestCase.java | 153 --- .../JavaTargetInvokerBasicInvocationTestCase.java | 188 --- .../java/JavaTargetInvokerMediationTestCase.java | 61 - ...TargetInvokerNonBlockingInvocationTestCase.java | 229 ---- .../java/JavaTargetInvokerSequenceTestCase.java | 117 -- .../JavaTargetInvokerStatelessDestroyTestCase.java | 54 - .../java/JavaTargetInvokerTestCase.java | 53 - .../implementation/java/MultiplicityTestCase.java | 34 - .../java/ResourceInjectionTestCase.java | 111 -- .../integration/CallbackInvocationTestCase.java | 390 ------ .../integration/OutboundWireToJavaTestCase.java | 233 ---- .../AllowsPassByReferenceProcessorTestCase.java | 59 - .../processor/ConstructorAutowireTestCase.java | 154 --- .../ConstructorProcessorExtensibilityTestCase.java | 82 -- .../processor/ConstructorProcessorTestCase.java | 148 -- .../processor/ConstructorPropertyTestCase.java | 171 --- .../processor/ConstructorReferenceTestCase.java | 173 --- .../processor/ConstructorResourceTestCase.java | 166 --- .../processor/ContextProcessorTestCase.java | 192 --- .../processor/ConversationProcessorTestCase.java | 152 --- .../processor/ConvertTimeMillisTestCase.java | 110 -- .../processor/DestroyProcessorTestCase.java | 100 -- .../processor/EagerInitProcessorTestCase.java | 54 - .../processor/HeuristicAndPropertyTestCase.java | 70 - .../processor/HeuristicConstructorTestCase.java | 330 ----- .../processor/HeuristicPojoProcessorTestCase.java | 395 ------ .../HeutisticExtensibleConstructorTestCase.java | 129 -- .../ImplementationProcessorServiceTestCase.java | 108 -- ...plementationProcessorServiceUniqueTestCase.java | 67 - .../processor/InitProcessorTestCase.java | 98 -- .../processor/MonitorProcessorTestCase.java | 180 --- .../processor/PropertyProcessorTestCase.java | 156 --- .../processor/ReferenceProcessorTestCase.java | 173 --- .../processor/ResourceProcessorTestCase.java | 99 -- .../processor/ScopeProcessorTestCase.java | 128 -- .../processor/ServiceCallbackTestCase.java | 166 --- .../processor/ServiceProcessorTestCase.java | 136 -- .../SystemComponentBuilderResourceTestCase.java | 75 -- .../component/SystemAtomicComponentTestCase.java | 124 -- ...ystemAtomicComponentWireInvocationTestCase.java | 60 - .../loader/SystemComponentTypeLoaderTestCase.java | 82 -- .../loader/SystemImplementationLoaderTestCase.java | 106 -- .../CallbackWireObjectFactoryTestCase.java | 47 - .../injection/ContextObjectFactoryTestCase.java | 38 - .../core/injection/FieldInjectorTestCase.java | 48 - .../core/injection/JNDIObjectFactoryTestCase.java | 61 - .../core/injection/MethodEventInvokerTestCase.java | 72 - .../core/injection/MethodInjectorTestCase.java | 79 -- .../core/injection/PojoObjectFactoryTestCase.java | 64 - .../RequestContextObjectFactoryTestCase.java | 37 - .../injection/ResourceObjectFactoryTestCase.java | 152 --- .../injection/SingletonObjectFactoryTestCase.java | 33 - .../conversation/AbstractConversationTestCase.java | 62 - .../ConversationIdleExpireTestCase.java | 142 -- .../ConversationMaxAgeExpireTestCase.java | 143 -- .../ConversationStartStopEndTestCase.java | 142 -- .../IntrospectionRegistryIntegrationTestCase.java | 131 -- .../builder/SystemBuilderPropertyTestCase.java | 88 -- .../tuscany/core/integration/mock/MockFactory.java | 278 ---- .../integration/scope/ScopeReferenceTestCase.java | 781 ----------- .../wire/DifferentInterfaceWireTestCase.java | 137 -- .../wire/ReferenceInjectionTestCase.java | 72 - .../oneway/OneWayWireToJavaInvocationTestCase.java | 130 -- .../loader/ComponentLoaderNoBindingTestCase.java | 91 -- .../loader/ComponentLoaderPropertyTestCase.java | 83 -- .../loader/ComponentLoaderReferenceTestCase.java | 85 -- .../core/loader/ComponentLoaderTestCase.java | 191 --- .../loader/ComponentLoaderValidationTestCase.java | 105 -- .../loader/ComponentTypeElementLoaderTestCase.java | 89 -- .../core/loader/DependencyLoaderTestCase.java | 124 -- .../tuscany/core/loader/IncludeLoaderTestCase.java | 169 --- .../core/loader/JNDIPropertyFactoryTestCase.java | 63 - .../loader/LoaderExceptionFormatterTestCase.java | 47 - .../core/loader/PolicySetLoaderTestCase.java | 71 - .../core/loader/PropertyParsingTestCase.java | 76 -- .../core/loader/ReferenceLoaderTestCase.java | 130 -- .../tuscany/core/loader/ServiceLoaderTestCase.java | 163 --- .../loader/StAXLoaderRegistryImplTestCase.java | 131 -- .../StringParserPropertyFactoryTestCase.java | 128 -- .../tuscany/core/loader/WireLoaderTestCase.java | 159 --- .../core/mock/binding/MockServiceBinding.java | 82 -- .../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 | 97 -- .../core/mock/wire/MockSyncInterceptor.java | 55 - .../tuscany/core/mock/wire/MockTargetInvoker.java | 33 - .../monitor/DefaultExceptionFormatterTestCase.java | 63 - .../tuscany/core/monitor/JavaLoggingTestCase.java | 153 --- .../core/policy/IntentRegistryImplTestCase.java | 152 --- .../core/policy/PolicyEngineImplTestCase.java | 140 -- .../core/property/PropertyHelperTestCase.java | 107 -- .../SimplePropertyObjectFactoryTestCase.java | 107 -- .../artifact/LocalMavenRepositoryTestCase.java | 82 -- .../deployment/AssemblyServiceImplTestCase.java | 107 -- .../DelegatingResourceHostRegistryTestCase.java | 147 -- .../services/store/memory/MemoryStoreTestCase.java | 164 --- .../work/jsr237/Jsr237WorkSchedulerTest.java | 81 -- .../work/jsr237/Jsr237WorkSchedulerTestCase.java | 100 -- .../workmanager/ThreadPoolWorkManagerTestCase.java | 132 -- .../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 - .../BasicReferenceInvocationHandlerTestCase.java | 69 - .../wire/CallbackInterfaceInterceptorTestCase.java | 60 - .../core/wire/ContractCompatibilityTestCase.java | 401 ------ .../core/wire/InboundInvocationErrorTestCase.java | 166 --- ...eServiceContractExceptionFormatterTestCase.java | 82 -- .../core/wire/InvocationChainImplTestCase.java | 94 -- .../wire/InvocationConfigurationErrorTestCase.java | 95 -- .../core/wire/InvocationConfigurationTestCase.java | 95 -- .../NonBlockingBridgingInterceptorTestCase.java | 75 -- .../wire/OptimizedWireObjectFactoryTestCase.java | 44 - .../core/wire/OutboundInvocationErrorTestCase.java | 133 -- .../wire/OutboundInvocationHandlerTestCase.java | 132 -- .../tuscany/core/wire/OutboundWireTestCase.java | 38 - .../SynchronousBridgingInterceptorTestCase.java | 44 - .../core/wire/WireObjectFactoryTestCase.java | 138 -- .../core/wire/WireOptimizationTestCase.java | 154 --- .../core/wire/WireServiceExtensionTestCase.java | 307 ----- .../tuscany/core/wire/WireUtilsTestCase.java | 94 -- ...backInvocationHandlerSerializationTestCase.java | 54 - .../jdk/JDKCallbackInvocationHandlerTestCase.java | 54 - ...oundInvocationHandlerSerializationTestCase.java | 110 -- .../jdk/JDKInboundInvocationHandlerTestCase.java | 162 --- .../JDKOutboundInvocationHandlerProxyTestCase.java | 80 -- ...oundInvocationHandlerSerializationTestCase.java | 132 -- .../jdk/JDKOutboundInvocationHandlerTestCase.java | 176 --- .../tuscany/core/wire/jdk/JDKProxyTestCase.java | 61 - .../apache/tuscany/core/databinding/impl/ipo.xsd | 136 -- .../tuscany/core/databinding/impl/order.wsdl | 76 -- .../apache/tuscany/core/databinding/xml/foo.xml | 22 - .../tuscany/core/deployer/boot1-include.scdl | 33 - .../org/apache/tuscany/core/deployer/boot1.scdl | 35 - .../org/apache/tuscany/core/deployer/boot2.scdl | 136 -- .../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 | 33 - .../pre-spec-changes/kernel/host-api/.checkstyle | 24 - branches/pre-spec-changes/kernel/host-api/.pmd | 20 - branches/pre-spec-changes/kernel/host-api/.ruleset | 190 --- .../pre-spec-changes/kernel/host-api/LICENSE.txt | 202 --- .../pre-spec-changes/kernel/host-api/NOTICE.txt | 14 - branches/pre-spec-changes/kernel/host-api/pom.xml | 49 - .../apache/tuscany/host/AbstractRuntimeInfo.java | 125 -- .../java/org/apache/tuscany/host/Launcher.java | 57 - .../org/apache/tuscany/host/MonitorFactory.java | 49 - .../java/org/apache/tuscany/host/RuntimeInfo.java | 72 - .../tuscany/host/deployment/AssemblyService.java | 52 - .../tuscany/host/deployment/ContentTypes.java | 35 - .../host/deployment/ContributionService.java | 58 - .../host/deployment/DeploymentException.java | 51 - .../UnsupportedContentTypeException.java | 48 - .../tuscany/host/management/ManagementService.java | 35 - .../tuscany/host/monitor/ExceptionFormatter.java | 34 - .../tuscany/host/monitor/FormatterRegistry.java | 42 - .../java/org/apache/tuscany/host/rmi/RMIHost.java | 49 - .../org/apache/tuscany/host/rmi/RMIHostAdmin.java | 39 - .../apache/tuscany/host/rmi/RMIHostException.java | 45 - .../tuscany/host/rmi/RMIHostRuntimeException.java | 45 - .../host/runtime/InitializationException.java | 37 - .../tuscany/host/runtime/ShutdownException.java | 33 - .../tuscany/host/runtime/TuscanyRuntime.java | 179 --- .../host/servlet/ServletRequestInjector.java | 41 - .../tuscany/host/rmi/RMIHostExceptionTestCase.java | 54 - .../host/rmi/RMIHostRuntimeExceptionTestCase.java | 54 - branches/pre-spec-changes/kernel/pom.xml | 97 -- branches/pre-spec-changes/kernel/spi/.checkstyle | 24 - branches/pre-spec-changes/kernel/spi/.pmd | 20 - branches/pre-spec-changes/kernel/spi/.ruleset | 190 --- branches/pre-spec-changes/kernel/spi/LICENSE.txt | 202 --- branches/pre-spec-changes/kernel/spi/NOTICE.txt | 14 - branches/pre-spec-changes/kernel/spi/pom.xml | 58 - .../kernel/spi/src/doc/Context Model.emx | 673 ---------- .../org/apache/tuscany/spi/AbstractLifecycle.java | 77 -- .../apache/tuscany/spi/CoreRuntimeException.java | 55 - .../apache/tuscany/spi/InvalidNameException.java | 45 - .../java/org/apache/tuscany/spi/Lifecycle.java | 69 - .../tuscany/spi/ObjectCreationException.java | 56 - .../java/org/apache/tuscany/spi/ObjectFactory.java | 35 - .../java/org/apache/tuscany/spi/QualifiedName.java | 96 -- .../apache/tuscany/spi/annotation/Autowire.java | 46 - .../tuscany/spi/bootstrap/ComponentNames.java | 60 - .../tuscany/spi/bootstrap/RuntimeComponent.java | 55 - .../apache/tuscany/spi/builder/BindingBuilder.java | 57 - .../org/apache/tuscany/spi/builder/Builder.java | 74 - .../spi/builder/BuilderConfigException.java | 48 - .../tuscany/spi/builder/BuilderException.java | 55 - .../spi/builder/BuilderInstantiationException.java | 39 - .../tuscany/spi/builder/BuilderRegistry.java | 55 - .../tuscany/spi/builder/ComponentBuilder.java | 36 - .../org/apache/tuscany/spi/builder/Connector.java | 52 - .../builder/InvalidServiceInterfaceException.java | 35 - .../spi/builder/MissingWireTargetException.java | 36 - .../spi/builder/ScopeNotFoundException.java | 29 - .../tuscany/spi/builder/WiringException.java | 124 -- .../tuscany/spi/component/AbstractSCAObject.java | 134 -- .../tuscany/spi/component/AtomicComponent.java | 126 -- .../apache/tuscany/spi/component/Component.java | 100 -- .../tuscany/spi/component/ComponentException.java | 52 - .../component/ComponentRegistrationException.java | 45 - .../spi/component/ComponentRuntimeException.java | 54 - .../tuscany/spi/component/CompositeComponent.java | 156 --- .../spi/component/DuplicateNameException.java | 36 - .../spi/component/IllegalTargetException.java | 33 - .../spi/component/InvalidAutowireInterface.java | 31 - .../InvalidConversationSequenceException.java | 31 - .../spi/component/PersistenceException.java | 41 - .../tuscany/spi/component/PrepareException.java | 35 - .../spi/component/ReactivationException.java | 45 - .../apache/tuscany/spi/component/Reference.java | 34 - .../tuscany/spi/component/ReferenceBinding.java | 88 -- .../tuscany/spi/component/SCAExternalizable.java | 43 - .../apache/tuscany/spi/component/SCAObject.java | 73 - .../spi/component/SCAObjectStartException.java | 33 - .../spi/component/SCAObjectStopException.java | 33 - .../tuscany/spi/component/ScopeContainer.java | 87 -- .../spi/component/ScopeContainerMonitor.java | 36 - .../tuscany/spi/component/ScopeRegistry.java | 43 - .../org/apache/tuscany/spi/component/Service.java | 52 - .../tuscany/spi/component/ServiceBinding.java | 95 -- .../spi/component/TargetDestructionException.java | 40 - .../tuscany/spi/component/TargetException.java | 50 - .../component/TargetInitializationException.java | 39 - .../spi/component/TargetInvocationException.java | 43 - .../component/TargetInvokerCreationException.java | 50 - .../spi/component/TargetNotFoundException.java | 36 - .../spi/component/TargetResolutionException.java | 43 - .../apache/tuscany/spi/component/WorkContext.java | 116 -- .../tuscany/spi/databinding/DataBinding.java | 63 - .../spi/databinding/DataBindingRegistry.java | 67 - .../apache/tuscany/spi/databinding/DataPipe.java | 44 - .../apache/tuscany/spi/databinding/Mediator.java | 56 - .../tuscany/spi/databinding/PullTransformer.java | 36 - .../tuscany/spi/databinding/PushTransformer.java | 34 - .../tuscany/spi/databinding/SimpleTypeMapper.java | 44 - .../spi/databinding/TransformationContext.java | 72 - .../spi/databinding/TransformationException.java | 46 - .../tuscany/spi/databinding/Transformer.java | 49 - .../spi/databinding/TransformerRegistry.java | 75 -- .../tuscany/spi/databinding/WrapperHandler.java | 56 - .../spi/databinding/extension/DOMHelper.java | 69 - .../extension/DataBindingExtension.java | 174 --- .../extension/Java2SimpleTypeTransformer.java | 61 - .../extension/SimpleType2JavaTransformer.java | 69 - .../extension/SimpleTypeMapperExtension.java | 391 ------ .../extension/TransformerExtension.java | 73 - .../extension/XSDDataTypeConverter.java | 940 ------------- .../tuscany/spi/deployer/ChangeSetHandler.java | 48 - .../spi/deployer/ChangeSetHandlerRegistry.java | 28 - .../tuscany/spi/deployer/CompositeClassLoader.java | 52 - .../spi/deployer/ContributionProcessor.java | 33 - .../deployer/ContributionProcessorRegistry.java | 26 - .../org/apache/tuscany/spi/deployer/Deployer.java | 48 - .../tuscany/spi/deployer/DeploymentContext.java | 84 -- .../tuscany/spi/deployer/DeploymentMonitor.java | 20 - .../tuscany/spi/event/AbstractEventPublisher.java | 83 -- .../java/org/apache/tuscany/spi/event/Event.java | 33 - .../org/apache/tuscany/spi/event/EventFilter.java | 33 - .../apache/tuscany/spi/event/EventPublisher.java | 50 - .../tuscany/spi/event/RuntimeEventListener.java | 31 - .../org/apache/tuscany/spi/event/TrueFilter.java | 31 - .../spi/extension/AbstractComponentExtension.java | 65 - .../spi/extension/AtomicComponentExtension.java | 216 --- .../spi/extension/BindingBuilderExtension.java | 79 -- .../spi/extension/ComponentBuilderExtension.java | 100 -- .../extension/ComponentTypeLoaderExtension.java | 63 - .../spi/extension/CompositeComponentExtension.java | 557 -------- .../tuscany/spi/extension/ExecutionMonitor.java | 33 - .../tuscany/spi/extension/LoaderExtension.java | 79 -- .../spi/extension/ReferenceBindingExtension.java | 78 -- .../spi/extension/ServiceBindingExtension.java | 87 -- .../extension/SystemAtomicComponentExtension.java | 45 - .../spi/extension/TargetInvokerExtension.java | 96 -- .../org/apache/tuscany/spi/host/ResourceHost.java | 46 - .../tuscany/spi/host/ResourceHostRegistry.java | 72 - .../spi/host/ResourceResolutionException.java | 32 - .../org/apache/tuscany/spi/host/ServletHost.java | 58 - .../org/apache/tuscany/spi/idl/ElementInfo.java | 54 - .../InvalidConversationalOperationException.java | 40 - .../spi/idl/InvalidServiceContractException.java | 50 - .../spi/idl/OverloadedOperationException.java | 41 - .../java/org/apache/tuscany/spi/idl/TypeInfo.java | 66 - .../spi/idl/java/InterfaceJavaIntrospector.java | 46 - .../apache/tuscany/spi/idl/java/JavaIDLUtils.java | 96 -- .../spi/idl/java/JavaInterfaceProcessor.java | 34 - .../idl/java/JavaInterfaceProcessorExtension.java | 47 - .../idl/java/JavaInterfaceProcessorRegistry.java | 39 - .../tuscany/spi/idl/java/JavaServiceContract.java | 39 - .../java/AbstractPropertyProcessor.java | 159 --- .../implementation/java/ConstructorDefinition.java | 51 - .../java/DuplicatePropertyException.java | 35 - .../java/IllegalPropertyException.java | 36 - .../java/ImplementationProcessor.java | 128 -- .../java/ImplementationProcessorExtension.java | 93 -- .../java/ImplementationProcessorService.java | 89 -- .../implementation/java/IntrospectionRegistry.java | 38 - .../spi/implementation/java/Introspector.java | 47 - .../java/JavaMappedComponentType.java | 61 - .../implementation/java/JavaMappedProperty.java | 64 - .../implementation/java/JavaMappedReference.java | 60 - .../spi/implementation/java/JavaMappedService.java | 91 -- .../spi/implementation/java/PojoComponentType.java | 110 -- .../implementation/java/ProcessingException.java | 65 - .../tuscany/spi/implementation/java/Resource.java | 138 -- .../tuscany/spi/loader/ComponentTypeLoader.java | 45 - .../spi/loader/InvalidConfigurationException.java | 36 - .../spi/loader/InvalidReferenceException.java | 38 - .../spi/loader/InvalidServiceException.java | 30 - .../tuscany/spi/loader/InvalidValueException.java | 40 - .../tuscany/spi/loader/InvalidWireException.java | 45 - .../java/org/apache/tuscany/spi/loader/Loader.java | 92 -- .../apache/tuscany/spi/loader/LoaderException.java | 92 -- .../apache/tuscany/spi/loader/LoaderRegistry.java | 69 - .../org/apache/tuscany/spi/loader/LoaderUtil.java | 78 -- .../spi/loader/MissingImplementationException.java | 35 - .../spi/loader/MissingIncludeException.java | 32 - .../MissingMustOverridePropertyException.java | 30 - .../spi/loader/MissingReferenceException.java | 32 - .../spi/loader/MissingResourceException.java | 67 - .../loader/NotOverridablePropertyException.java | 30 - .../tuscany/spi/loader/PropertyObjectFactory.java | 44 - .../tuscany/spi/loader/StAXElementLoader.java | 48 - .../spi/loader/UndefinedPropertyException.java | 28 - .../spi/loader/UndefinedReferenceException.java | 10 - .../loader/UnrecognizedComponentTypeException.java | 42 - .../spi/loader/UnrecognizedElementException.java | 46 - .../tuscany/spi/model/AtomicImplementation.java | 33 - .../tuscany/spi/model/BindingDefinition.java | 45 - .../spi/model/BoundReferenceDefinition.java | 53 - .../tuscany/spi/model/BoundServiceDefinition.java | 65 - .../tuscany/spi/model/ComponentDefinition.java | 154 --- .../apache/tuscany/spi/model/ComponentType.java | 178 --- .../tuscany/spi/model/CompositeComponentType.java | 174 --- .../tuscany/spi/model/CompositeImplementation.java | 56 - .../org/apache/tuscany/spi/model/DataType.java | 242 ---- .../apache/tuscany/spi/model/Implementation.java | 43 - .../java/org/apache/tuscany/spi/model/Include.java | 80 -- .../java/org/apache/tuscany/spi/model/Intent.java | 92 -- .../org/apache/tuscany/spi/model/IntentMap.java | 64 - .../org/apache/tuscany/spi/model/IntentName.java | 140 -- .../apache/tuscany/spi/model/InteractionScope.java | 29 - .../org/apache/tuscany/spi/model/ModelObject.java | 38 - .../org/apache/tuscany/spi/model/Multiplicity.java | 47 - .../org/apache/tuscany/spi/model/Operation.java | 408 ------ .../apache/tuscany/spi/model/OverrideOptions.java | 34 - .../apache/tuscany/spi/model/PolicyAttachable.java | 21 - .../tuscany/spi/model/PolicyAttachableModel.java | 49 - .../tuscany/spi/model/PolicyContentModel.java | 45 - .../org/apache/tuscany/spi/model/PolicyModel.java | 29 - .../org/apache/tuscany/spi/model/PolicySet.java | 99 -- .../tuscany/spi/model/PolicySetReference.java | 38 - .../org/apache/tuscany/spi/model/Property.java | 105 -- .../apache/tuscany/spi/model/PropertyValue.java | 128 -- .../org/apache/tuscany/spi/model/Qualifier.java | 51 - .../tuscany/spi/model/ReferenceDefinition.java | 80 -- .../apache/tuscany/spi/model/ReferenceTarget.java | 50 - .../java/org/apache/tuscany/spi/model/Scope.java | 61 - .../apache/tuscany/spi/model/ServiceContract.java | 275 ---- .../tuscany/spi/model/ServiceDefinition.java | 87 -- .../tuscany/spi/model/WSPolicyAttachment.java | 35 - .../apache/tuscany/spi/model/WireDefinition.java | 47 - .../org/apache/tuscany/spi/model/WrapperInfo.java | 111 -- .../apache/tuscany/spi/policy/IntentRegistry.java | 83 -- .../tuscany/spi/policy/PolicyBuilderRegistry.java | 70 - .../apache/tuscany/spi/policy/PolicyEngine.java | 42 - .../tuscany/spi/policy/PolicySetContainer.java | 46 - .../apache/tuscany/spi/policy/SCATypeManager.java | 29 - .../tuscany/spi/policy/SourcePolicyBuilder.java | 41 - .../spi/policy/SourcePolicyBuilderExtension.java | 53 - .../tuscany/spi/policy/TargetPolicyBuilder.java | 41 - .../spi/policy/TargetPolicyBuilderExtension.java | 53 - .../apache/tuscany/spi/services/VoidService.java | 33 - .../tuscany/spi/services/artifact/Artifact.java | 197 --- .../spi/services/artifact/ArtifactRepository.java | 45 - .../discovery/AbstractDiscoveryService.java | 128 -- .../spi/services/discovery/DiscoveryService.java | 51 - .../spi/services/discovery/MessageListener.java | 37 - .../management/TuscanyManagementService.java | 40 - .../services/store/DuplicateRecordException.java | 31 - .../spi/services/store/RecoveryListener.java | 46 - .../apache/tuscany/spi/services/store/Store.java | 96 -- .../tuscany/spi/services/store/StoreException.java | 54 - .../spi/services/store/StoreExpirationEvent.java | 71 - .../tuscany/spi/services/store/StoreMonitor.java | 74 - .../spi/services/store/StoreReadException.java | 41 - .../spi/services/store/StoreWriteException.java | 43 - .../spi/services/work/NotificationListener.java | 66 - .../tuscany/spi/services/work/WorkScheduler.java | 52 - .../spi/services/work/WorkSchedulerException.java | 36 - .../tuscany/spi/util/SCAObjectInputStream.java | 60 - .../spi/wire/AbstractInboundInvocationHandler.java | 54 - .../wire/AbstractOutboundInvocationHandler.java | 104 -- .../tuscany/spi/wire/InboundInvocationChain.java | 29 - .../org/apache/tuscany/spi/wire/InboundWire.java | 89 -- .../wire/IncompatibleServiceContractException.java | 74 - .../org/apache/tuscany/spi/wire/Interceptor.java | 50 - .../apache/tuscany/spi/wire/InvocationChain.java | 95 -- .../spi/wire/InvocationRuntimeException.java | 46 - .../java/org/apache/tuscany/spi/wire/Message.java | 120 -- .../org/apache/tuscany/spi/wire/MessageId.java | 56 - .../org/apache/tuscany/spi/wire/MessageImpl.java | 116 -- .../tuscany/spi/wire/OutboundChainHolder.java | 38 - .../tuscany/spi/wire/OutboundInvocationChain.java | 28 - .../org/apache/tuscany/spi/wire/OutboundWire.java | 106 -- .../tuscany/spi/wire/ProxyCreationException.java | 51 - .../org/apache/tuscany/spi/wire/TargetInvoker.java | 79 -- .../java/org/apache/tuscany/spi/wire/Wire.java | 82 -- .../tuscany/spi/wire/WireInvocationHandler.java | 32 - .../apache/tuscany/spi/wire/WirePostProcessor.java | 40 - .../spi/wire/WirePostProcessorExtension.java | 44 - .../spi/wire/WirePostProcessorRegistry.java | 44 - .../org/apache/tuscany/spi/wire/WireService.java | 157 --- .../org/apache/tuscany/spi/AssertionTestCase.java | 38 - .../apache/tuscany/spi/QualifiedNameTestCase.java | 67 - .../spi/TuscanyRuntimeExceptionTestCase.java | 69 - .../spi/annotation/ConstructorAnnotationTest.java | 60 - .../spi/component/AbstractSCAObjectTestCase.java | 128 -- .../databinding/extension/DOMHelperTestCase.java | 55 - .../extension/DataBindingExtensionTestCase.java | 80 -- .../SimpleTypeMapperExtensionTestCase.java | 114 -- .../extension/TransformerExtensionTestCase.java | 74 - .../extension/XSDDataTypeConverterTestCase.java | 60 - .../spi/event/AbstractEventPublisherTestCase.java | 92 -- .../AtomicComponentExtensionTestCase.java | 148 -- .../ComponentTypeLoaderExtensionTestCase.java | 60 - ...ompositeComponentExtensionAutowireTestCase.java | 302 ----- .../CompositeComponentExtensionTestCase.java | 332 ----- .../spi/extension/LoaderExtensionTestCase.java | 71 - .../ReferenceBindingExtensionTestCase.java | 67 - .../tuscany/spi/extension/ReferenceTestCase.java | 94 -- .../extension/ServiceBindingExtensionTestCase.java | 87 -- .../TargetInvokerExtensionSequenceTestCase.java | 169 --- .../extension/TargetInvokerExtensionTestCase.java | 82 -- .../tuscany/spi/idl/java/JavaIDLUtilsTestCase.java | 178 --- .../java/AbstractPropertyProcessorTestCase.java | 176 --- .../spi/loader/LoaderExceptionTestCase.java | 33 - .../spi/model/CompositeComponentTypeTestCase.java | 43 - .../tuscany/spi/model/IntentNameTestCase.java | 16 - .../tuscany/spi/model/OperationTestCase.java | 52 - .../apache/tuscany/spi/model/ScopeTestCase.java | 59 - .../tuscany/spi/model/ServiceContractTestCase.java | 76 -- .../SourcePolicyBuilderExtensionTestCase.java | 50 - .../TargetPolicyBuilderExtensionTestCase.java | 50 - .../tuscany/spi/util/MockSCAExternalizable.java | 52 - .../apache/tuscany/spi/util/MockSerializable.java | 42 - .../spi/util/SCAObjectInputStreamTestCase.java | 51 - .../AbstractInboundInvocationHandlerTestCase.java | 55 - .../AbstractOutboundInvocationHandlerTestCase.java | 102 -- .../spi/wire/OutboundChainHolderTestCase.java | 35 - 892 files changed, 84613 deletions(-) delete mode 100644 branches/pre-spec-changes/kernel/api/.checkstyle delete mode 100644 branches/pre-spec-changes/kernel/api/.pmd delete mode 100644 branches/pre-spec-changes/kernel/api/.ruleset delete mode 100644 branches/pre-spec-changes/kernel/api/LICENSE.txt delete mode 100644 branches/pre-spec-changes/kernel/api/NOTICE.txt delete mode 100644 branches/pre-spec-changes/kernel/api/pom.xml delete mode 100644 branches/pre-spec-changes/kernel/api/src/main/java/org/apache/tuscany/api/TuscanyException.java delete mode 100644 branches/pre-spec-changes/kernel/api/src/main/java/org/apache/tuscany/api/TuscanyRuntimeException.java delete mode 100644 branches/pre-spec-changes/kernel/api/src/main/java/org/apache/tuscany/api/annotation/DataContext.java delete mode 100644 branches/pre-spec-changes/kernel/api/src/main/java/org/apache/tuscany/api/annotation/DataType.java delete mode 100644 branches/pre-spec-changes/kernel/api/src/main/java/org/apache/tuscany/api/annotation/LogLevel.java delete mode 100644 branches/pre-spec-changes/kernel/api/src/main/java/org/apache/tuscany/api/annotation/Monitor.java delete mode 100644 branches/pre-spec-changes/kernel/api/src/test/java/org/apache/tuscany/api/TuscanyExceptionTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/api/src/test/java/org/apache/tuscany/api/TuscanyRuntimeExceptionTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/.pmd delete mode 100644 branches/pre-spec-changes/kernel/core/.ruleset delete mode 100644 branches/pre-spec-changes/kernel/core/LICENSE.txt delete mode 100644 branches/pre-spec-changes/kernel/core/NOTICE.txt delete mode 100644 branches/pre-spec-changes/kernel/core/pom.xml delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/binding/local/AbstractLocalTargetInvoker.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/binding/local/LocalBindingBuilder.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/binding/local/LocalBindingDefinition.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/binding/local/LocalBindingLoader.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/binding/local/LocalCallbackTargetInvoker.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/binding/local/LocalReferenceBinding.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/binding/local/LocalServiceBinding.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/binding/local/LocalTargetInvoker.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/bootstrap/Bootstrapper.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/bootstrap/DefaultBootstrapper.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/bootstrap/DefaultRuntime.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/builder/BuilderRegistryImpl.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/builder/ConnectorImpl.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/builder/IllegalCallbackException.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/builder/IncompatibleInterfacesException.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/builder/InvalidTargetTypeException.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/builder/NoCompatibleBindingsException.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/builder/NoConversationalContractException.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/builder/NoRegisteredBuilderException.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/builder/TargetServiceNotFoundException.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/builder/WireConnectException.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/builder/WirePostProcessorRegistryImpl.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/builder/WiringExceptionFormatter.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/ScopeIdentifier.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/WorkContextImpl.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/event/AbstractEvent.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/event/AbstractRequestEvent.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/event/CompositeEvent.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/event/CompositeStart.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/event/CompositeStop.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/event/ConversationEnd.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/event/ConversationStart.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/event/ConversationalEvent.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/event/HttpRequestEnded.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/event/HttpRequestStart.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/event/HttpSessionEnd.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/event/HttpSessionEvent.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/event/HttpSessionStart.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/event/RequestEnd.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/event/RequestEvent.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/event/RequestStart.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/AbstractScopeContainer.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/CompositeScopeContainer.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/CompositeScopeObjectFactory.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainer.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/ConversationalScopeObjectFactory.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/HttpSessionScopeContainer.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/HttpSessionScopeObjectFactory.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/InstanceWrapper.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/InstanceWrapperImpl.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/RequestScopeContainer.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/RequestScopeObjectFactory.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/ScopeRegistryImpl.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/StatelessScopeContainer.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/StatelessScopeObjectFactory.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/DataBindingInteceptor.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/DataBindingJavaInterfaceProcessor.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/DataBindingRegistryImpl.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/DataBindingWirePostProcessor.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/DataTypeLoader.java delete mode 100755 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/DirectedGraph.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/Input2InputTransformer.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/MediatorImpl.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/Output2OutputTransformer.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/PassByValueInterceptor.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/PassByValueWirePostProcessor.java delete mode 100755 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/PipedTransformer.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/SimpleDataBinding.java delete mode 100755 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/TransformationContextImpl.java delete mode 100755 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/TransformerRegistryImpl.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/DOMDataBinding.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/DOMWrapperHandler.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/DOMXMLStreamReader.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/InputSource2Node.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/InputSource2SAX.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/InputStream2Node.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/InputStream2SAX.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Node2Object.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Node2OutputStream.java delete mode 100755 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Node2String.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Node2Writer.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Node2XMLStreamReader.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Object2Node.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Reader2Node.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Reader2SAX.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/SAX2DOM.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/SAX2DOMPipe.java delete mode 100755 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Source2ResultTransformer.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/StAX2SAXAdapter.java delete mode 100755 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/StAXHelper.java delete mode 100755 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/StreamDataPipe.java delete mode 100755 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/String2Node.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/String2SAX.java delete mode 100755 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/String2XMLStreamReader.java delete mode 100755 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Writer2ReaderDataPipe.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/XMLStreamReader2Node.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/XMLStreamReader2SAX.java delete mode 100755 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/XMLStreamReader2String.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/XMLStringDataBinding.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/deployer/AbstractDeploymentContext.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/deployer/ChildDeploymentContext.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/deployer/DeployerImpl.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/deployer/RootDeploymentContext.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/idl/java/IllegalCallbackException.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/idl/java/InterfaceJavaLoader.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/idl/java/JavaInterfaceProcessorRegistryImpl.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/IntrospectionRegistryImpl.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/PojoAtomicComponent.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/PojoConfiguration.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/AbstractCompositeBuilder.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/AbstractCompositeComponent.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/AbstractCompositeContext.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/ComponentTimeoutException.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeBuilder.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeComponentImpl.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeComponentTypeLoader.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeLoader.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/Dependency.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/ImplementationCompositeLoader.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/ManagedCompositeContext.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/ManagedRequestContext.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/ReferenceImpl.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/ServiceImpl.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/SystemCompositeBuilder.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/SystemSingletonAtomicComponent.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/JavaAtomicComponent.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/JavaComponentBuilder.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/JavaComponentTypeLoader.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/JavaImplementation.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/JavaImplementationLoader.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/JavaTargetInvoker.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/AllowsPassByReferenceProcessor.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/AmbiguousConstructorException.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ConstructorProcessor.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ContextProcessor.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ConversationProcessor.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/DestroyProcessor.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/DuplicateConstructorException.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/DuplicateDestructorException.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/DuplicateInitException.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/DuplicateReferenceException.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/DuplicateResourceException.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/EagerInitProcessor.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/HeuristicPojoProcessor.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/IllegalCallbackReferenceException.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/IllegalContextException.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/IllegalDestructorException.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/IllegalInitException.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/IllegalReferenceException.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/IllegalResourceException.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/IllegalServiceDefinitionException.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ImplementationProcessorServiceImpl.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/InitProcessor.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/InvalidAutowireException.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/InvalidConstructorException.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/InvalidConversationalImplementation.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/InvalidPropertyException.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/InvalidReferenceException.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/InvalidResourceException.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/InvalidServiceType.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/MonitorProcessor.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/NoConstructorException.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/PropertyProcessor.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ReferenceProcessor.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ResourceProcessor.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ScopeProcessor.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ServiceProcessor.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ServiceTypeNotFoundException.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/UnknownContextTypeException.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/builder/SystemComponentBuilder.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/component/SystemAtomicComponentImpl.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/loader/SystemComponentTypeLoader.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/loader/SystemCompositeComponentTypeLoader.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/loader/SystemImplementationLoader.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/model/SystemCompositeImplementation.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/model/SystemImplementation.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/ArrayMultiplicityObjectFactory.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/CallbackWireObjectFactory.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/CompositeContextObjectFactory.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/ContextInjector.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/ConversationIDObjectFactory.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/EventInvoker.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/FieldInjector.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/InjectionRuntimeException.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/Injector.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/InvalidAccessorException.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/InvalidResourceTypeException.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/JNDIObjectFactory.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/ListMultiplicityObjectFactory.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/MethodEventInvoker.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/MethodInjector.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/NoAccessorException.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/NoMultiplicityTypeException.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/ObjectCallbackException.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/PojoObjectFactory.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/RequestContextObjectFactory.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/ResourceNotFoundException.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/ResourceObjectFactory.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/SingletonObjectFactory.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/launcher/CompositeContextImpl.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/launcher/LaunchException.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/launcher/LauncherImpl.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/launcher/LauncherRuntimeInfo.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/loader/ComponentLoader.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/loader/ComponentTypeElementLoader.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/loader/DependencyLoader.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/loader/IncludeLoader.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/loader/JNDIPropertyFactory.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/loader/LoaderExceptionFormatter.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/loader/LoaderRegistryImpl.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/loader/PolicySetLoader.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/loader/PropertyLoader.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/loader/ReferenceLoader.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/loader/ServiceLoader.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/loader/StAXUtil.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/loader/StringParserPropertyFactory.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/loader/WireLoader.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/monitor/DefaultExceptionFormatter.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/monitor/InvalidLevelException.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/monitor/JavaLoggingMonitorFactory.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/monitor/MonitorFactoryUtil.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/monitor/NullMonitorFactory.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/policy/IntentRegistryImpl.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/policy/PolicyBuilderRegistryImpl.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/policy/PolicyEngineImpl.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/policy/PolicyHelper.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/property/PropertyHelper.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/property/PropertyObjectFactoryImpl.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/property/SimplePropertyObjectFactory.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/runtime/AbstractRuntime.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/services/artifact/LocalMavenRepository.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/AssemblyServiceImpl.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/ContributionServiceImpl.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/InvalidDocumentException.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/XMLChangeSetHandler.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/services/extension/AbstractExtensionDeployer.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/services/host/DelegatingResourceHostRegistry.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/services/store/memory/MemoryStore.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/services/work/jca/JcaWorkScheduler.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/services/work/jsr237/Jsr237WorkScheduler.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/services/work/jsr237/workmanager/DefaultWorkEvent.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/services/work/jsr237/workmanager/DefaultWorkItem.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/services/work/jsr237/workmanager/ThreadPoolWorkManager.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/util/ClassLoaderHelper.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/util/JavaIntrospectionHelper.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/BridgingInterceptor.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/CallbackInterfaceInterceptor.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/InboundInvocationChainImpl.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/InboundWireImpl.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/IncompatibleServiceContractExceptionFormatter.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/InvocationChainImpl.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/InvokerInterceptor.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/LoopBackWire.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/NoMethodForOperationException.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/NonBlockingBridgingInterceptor.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/OptimizedWireObjectFactory.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/OutboundInvocationChainImpl.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/OutboundWireImpl.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/SynchronousBridgingInterceptor.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/WireObjectFactory.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/WireServiceExtension.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/WireUtils.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKCallbackInvocationHandler.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKInboundInvocationHandler.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKOutboundInvocationHandler.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKWireService.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/resources/org/apache/tuscany/core/composite.scdl delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/resources/org/apache/tuscany/core/databinding.scdl delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/resources/org/apache/tuscany/core/formatters.scdl delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/resources/org/apache/tuscany/core/implementation.scdl delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/resources/org/apache/tuscany/core/interfaceJava.scdl delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/resources/org/apache/tuscany/core/javaImplementation.scdl delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/resources/org/apache/tuscany/core/loader.scdl delete mode 100644 branches/pre-spec-changes/kernel/core/src/main/resources/org/apache/tuscany/core/systemImplementation.scdl delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/binding/local/AbstractLocalTargetInvokerTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/binding/local/LocalBindingBuilderTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/binding/local/LocalBindingLoaderTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/binding/local/LocalCallbackTargetInvokerInvocationExceptionTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/binding/local/LocalCallbackTargetInvokerTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/binding/local/LocalCallbackTargetInvokerThrowableTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/binding/local/LocalTargetInvokerTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/bootstrap/BootstrapperTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/AbstractConnectorImplTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/AtomicConnectorTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/BuilderRegistryNoBindingsTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/BuilderRegistryTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/ConnectorImplTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/ConnectorPostProcessTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/IllegalCallbackExceptionTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/InboundtoOutboundConnectTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/IncompatibleInterfacesExceptionTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/InvalidTargetTypeExceptionTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/LocalReferenceWiringTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/NonBlockingForwardNonBlockingCallbackConnectionTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/NonBlockingForwardSyncCallbackConnectionTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/OutboundToInboundConnectTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/ReferenceConnectorTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/ServiceConnectorTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/SynchronousForwardCallbackConnectionTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/TargetServiceNotFoundExceptionTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/WirePostProcessorRegistryImplTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/WiringExceptionFormatterTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/WorkContextImplTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/event/EventTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/AbstractScopeContainerTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/BasicCompositeScopeTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/BasicConversationalScopeTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/BasicHttpSessionScopeTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/BasicRequestScopeTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/BasicStatelessScopeTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/CompositeScopeInitDestroyErrorTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/CompositeScopeInstanceLifecycleTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/CompositeScopeObjectFactoryTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/CompositeScopeRestartTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainerDestroyOnExpirationTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainerMaxAgeTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainerMaxIdleTimeTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainerPersistenceTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeInstanceLifecycleTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeRestartTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/DependencyLifecycleTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/HttpSessionScopeInitDestroyErrorTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/HttpSessionScopeInstanceLifecycleTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/HttpSessionScopeRestartTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/InstanceWrapperTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/MockFactory.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/RequestScopeInitDestroyErrorTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/RequestScopeInstanceLifecycleTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/RequestScopeRestartTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/ScopeRegistryTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/StatelessScopeContainerTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/StatelessScopeObjectFactoryTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/WorkContextTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DataBindingInterceptorTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DataBindingJavaInterfaceProcessorTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DataBindingLoaderTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DataBindingRegistryImplTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DataBindingTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DataBindingWirePostProcessorOptimizationTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DataBindingWirePostProcessorTestCase.java delete mode 100755 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DirectedGraphTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/IDLTransformerTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/MediatorImplTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/PassByValueInterceptorTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/PassByValueWirePostProcessorTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/TransformerRegistryImplTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/xml/DOM2StAXTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/xml/DataPipeTestCase.java delete mode 100755 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/xml/Node2StringTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/xml/PushTransformationTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/xml/StAXHelperTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/xml/TraxTransformerTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/deployer/BootstrapDeployerTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/idl/java/ConversationalIntrospectionTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/idl/java/JavaInterfaceProcessorRegistryImplTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/IntrospectionRegistryTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/PojoAtomicComponentTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/TestUtils.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/AbstractCompositeContextTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/AutowireResolutionTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/AutowireTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeBuilderTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeComponentImplBasicTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeComponentImplSystemWireTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeComponentImplTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeComponentResolutionTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeLifecycleTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeLoaderWireResolutionTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositePropagationTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/DuplicateRegistrationTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/ImplementationCompositeLoaderTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/JavaObjectRegistrationTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/ManagedRequestContextTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/ReferenceImplTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/ServiceImplTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/SystemComponentBuilderTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/SystemSingletonAtomicComponentTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaAtomicComponentMetadataInjectionTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaAtomicComponentNegativeMetadataTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaBuilderPropertyTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaComponentBuilderConversationIDTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaComponentBuilderMetadataTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaComponentBuilderReferenceTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaComponentBuilderResourceTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaComponentTypeLoaderTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaReferenceWireTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaTargetInvokerBasicInvocationTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaTargetInvokerMediationTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaTargetInvokerNonBlockingInvocationTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaTargetInvokerSequenceTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaTargetInvokerStatelessDestroyTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaTargetInvokerTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/MultiplicityTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/ResourceInjectionTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/integration/CallbackInvocationTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/integration/OutboundWireToJavaTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/AllowsPassByReferenceProcessorTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConstructorAutowireTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConstructorProcessorExtensibilityTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConstructorProcessorTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConstructorPropertyTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConstructorReferenceTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConstructorResourceTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ContextProcessorTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConversationProcessorTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConvertTimeMillisTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/DestroyProcessorTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/EagerInitProcessorTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/HeuristicAndPropertyTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/HeuristicConstructorTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/HeuristicPojoProcessorTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/HeutisticExtensibleConstructorTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ImplementationProcessorServiceTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ImplementationProcessorServiceUniqueTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/InitProcessorTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/MonitorProcessorTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/PropertyProcessorTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ReferenceProcessorTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ResourceProcessorTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ScopeProcessorTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ServiceCallbackTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ServiceProcessorTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/system/builder/SystemComponentBuilderResourceTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/system/component/SystemAtomicComponentTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/system/component/SystemAtomicComponentWireInvocationTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/system/loader/SystemComponentTypeLoaderTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/system/loader/SystemImplementationLoaderTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/injection/CallbackWireObjectFactoryTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/injection/ContextObjectFactoryTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/injection/FieldInjectorTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/injection/JNDIObjectFactoryTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/injection/MethodEventInvokerTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/injection/MethodInjectorTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/injection/PojoObjectFactoryTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/injection/RequestContextObjectFactoryTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/injection/ResourceObjectFactoryTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/injection/SingletonObjectFactoryTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/integration/conversation/AbstractConversationTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/integration/conversation/ConversationIdleExpireTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/integration/conversation/ConversationMaxAgeExpireTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/integration/conversation/ConversationStartStopEndTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/integration/implementation/IntrospectionRegistryIntegrationTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/integration/implementation/system/builder/SystemBuilderPropertyTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/integration/mock/MockFactory.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/integration/scope/ScopeReferenceTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/integration/wire/DifferentInterfaceWireTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/integration/wire/ReferenceInjectionTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/integration/wire/oneway/OneWayWireToJavaInvocationTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/loader/ComponentLoaderNoBindingTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/loader/ComponentLoaderPropertyTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/loader/ComponentLoaderReferenceTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/loader/ComponentLoaderTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/loader/ComponentLoaderValidationTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/loader/ComponentTypeElementLoaderTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/loader/DependencyLoaderTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/loader/IncludeLoaderTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/loader/JNDIPropertyFactoryTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/loader/LoaderExceptionFormatterTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/loader/PolicySetLoaderTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/loader/PropertyParsingTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/loader/ReferenceLoaderTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/loader/ServiceLoaderTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/loader/StAXLoaderRegistryImplTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/loader/StringParserPropertyFactoryTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/loader/WireLoaderTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/binding/MockServiceBinding.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/AsyncTarget.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/BadContextPojo.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/BadNamePojo.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/BasicInterface.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/BasicInterfaceImpl.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/CompositeScopeComponent.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/CompositeScopeComponentImpl.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/CompositeScopeDestroyOnlyComponent.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/CompositeScopeInitDestroyComponent.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/CompositeScopeInitOnlyComponent.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/ConversationalScopeComponent.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/ConversationalScopeComponentImpl.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/ConversationalScopeDestroyOnlyComponent.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/ConversationalScopeInitDestroyComponent.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/ConversationalScopeInitOnlyComponent.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/OrderException.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/OrderedDependentPojo.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/OrderedDependentPojoImpl.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/OrderedEagerInitPojo.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/OrderedInitPojo.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/OrderedInitPojoImpl.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/OtherTarget.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/OtherTargetImpl.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/RequestScopeComponent.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/RequestScopeDestroyOnlyComponent.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/RequestScopeInitDestroyComponent.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/RequestScopeInitOnlyComponent.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/SessionScopeComponent.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/SessionScopeComponentImpl.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/SessionScopeInitDestroyComponent.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/SessionScopeInitOnlyComponent.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/SimpleTarget.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/SimpleTargetImpl.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/Source.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/SourceImpl.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/StatelessComponent.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/StatelessComponentImpl.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/Target.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/TargetImpl.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/wire/MockStaticInvoker.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/wire/MockSyncInterceptor.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/wire/MockTargetInvoker.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/monitor/DefaultExceptionFormatterTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/monitor/JavaLoggingTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/policy/IntentRegistryImplTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/policy/PolicyEngineImplTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/property/PropertyHelperTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/property/SimplePropertyObjectFactoryTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/services/artifact/LocalMavenRepositoryTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/services/deployment/AssemblyServiceImplTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/services/host/DelegatingResourceHostRegistryTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/services/store/memory/MemoryStoreTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/services/work/jsr237/Jsr237WorkSchedulerTest.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/services/work/jsr237/Jsr237WorkSchedulerTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/services/work/jsr237/workmanager/ThreadPoolWorkManagerTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/util/Bean1.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/util/Bean2.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/util/JavaIntrospectionHelperTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/util/SuperBean.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/BasicReferenceInvocationHandlerTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/CallbackInterfaceInterceptorTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/ContractCompatibilityTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/InboundInvocationErrorTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/IncompatibleServiceContractExceptionFormatterTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/InvocationChainImplTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/InvocationConfigurationErrorTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/InvocationConfigurationTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/NonBlockingBridgingInterceptorTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/OptimizedWireObjectFactoryTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/OutboundInvocationErrorTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/OutboundInvocationHandlerTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/OutboundWireTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/SynchronousBridgingInterceptorTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/WireObjectFactoryTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/WireOptimizationTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/WireServiceExtensionTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/WireUtilsTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/jdk/JDKCallbackInvocationHandlerSerializationTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/jdk/JDKCallbackInvocationHandlerTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/jdk/JDKInboundInvocationHandlerSerializationTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/jdk/JDKInboundInvocationHandlerTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/jdk/JDKOutboundInvocationHandlerProxyTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/jdk/JDKOutboundInvocationHandlerSerializationTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/jdk/JDKOutboundInvocationHandlerTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/jdk/JDKProxyTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/resources/org/apache/tuscany/core/databinding/impl/ipo.xsd delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/resources/org/apache/tuscany/core/databinding/impl/order.wsdl delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/resources/org/apache/tuscany/core/databinding/xml/foo.xml delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/resources/org/apache/tuscany/core/deployer/boot1-include.scdl delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/resources/org/apache/tuscany/core/deployer/boot1.scdl delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/resources/org/apache/tuscany/core/deployer/boot2.scdl delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/resources/org/apache/tuscany/core/loader/TestPolicy.scdl delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/resources/org/apache/tuscany/core/loader/test-include.scdl delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/resources/org/apache/tuscany/core/policy/PolicySet.scdl delete mode 100644 branches/pre-spec-changes/kernel/core/src/test/resources/org/apache/tuscany/core/property/ipo.xml delete mode 100644 branches/pre-spec-changes/kernel/host-api/.checkstyle delete mode 100644 branches/pre-spec-changes/kernel/host-api/.pmd delete mode 100644 branches/pre-spec-changes/kernel/host-api/.ruleset delete mode 100644 branches/pre-spec-changes/kernel/host-api/LICENSE.txt delete mode 100644 branches/pre-spec-changes/kernel/host-api/NOTICE.txt delete mode 100644 branches/pre-spec-changes/kernel/host-api/pom.xml delete mode 100644 branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/AbstractRuntimeInfo.java delete mode 100644 branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/Launcher.java delete mode 100644 branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/MonitorFactory.java delete mode 100644 branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/RuntimeInfo.java delete mode 100644 branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/deployment/AssemblyService.java delete mode 100644 branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/deployment/ContentTypes.java delete mode 100644 branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/deployment/ContributionService.java delete mode 100644 branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/deployment/DeploymentException.java delete mode 100644 branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/deployment/UnsupportedContentTypeException.java delete mode 100644 branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/management/ManagementService.java delete mode 100644 branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/monitor/ExceptionFormatter.java delete mode 100644 branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/monitor/FormatterRegistry.java delete mode 100644 branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/rmi/RMIHost.java delete mode 100644 branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/rmi/RMIHostAdmin.java delete mode 100644 branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/rmi/RMIHostException.java delete mode 100644 branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/rmi/RMIHostRuntimeException.java delete mode 100644 branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/runtime/InitializationException.java delete mode 100644 branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/runtime/ShutdownException.java delete mode 100644 branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/runtime/TuscanyRuntime.java delete mode 100644 branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/servlet/ServletRequestInjector.java delete mode 100644 branches/pre-spec-changes/kernel/host-api/src/test/java/org/apache/tuscany/host/rmi/RMIHostExceptionTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/host-api/src/test/java/org/apache/tuscany/host/rmi/RMIHostRuntimeExceptionTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/pom.xml delete mode 100644 branches/pre-spec-changes/kernel/spi/.checkstyle delete mode 100644 branches/pre-spec-changes/kernel/spi/.pmd delete mode 100644 branches/pre-spec-changes/kernel/spi/.ruleset delete mode 100644 branches/pre-spec-changes/kernel/spi/LICENSE.txt delete mode 100644 branches/pre-spec-changes/kernel/spi/NOTICE.txt delete mode 100644 branches/pre-spec-changes/kernel/spi/pom.xml delete mode 100644 branches/pre-spec-changes/kernel/spi/src/doc/Context Model.emx delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/AbstractLifecycle.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/CoreRuntimeException.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/InvalidNameException.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/Lifecycle.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/ObjectCreationException.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/ObjectFactory.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/QualifiedName.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/annotation/Autowire.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/bootstrap/ComponentNames.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/bootstrap/RuntimeComponent.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/BindingBuilder.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/Builder.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/BuilderConfigException.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/BuilderException.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/BuilderInstantiationException.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/BuilderRegistry.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/ComponentBuilder.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/Connector.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/InvalidServiceInterfaceException.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/MissingWireTargetException.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/ScopeNotFoundException.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/WiringException.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/AbstractSCAObject.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/AtomicComponent.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/Component.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ComponentException.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ComponentRegistrationException.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ComponentRuntimeException.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/CompositeComponent.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/DuplicateNameException.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/IllegalTargetException.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/InvalidAutowireInterface.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/InvalidConversationSequenceException.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/PersistenceException.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/PrepareException.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ReactivationException.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/Reference.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ReferenceBinding.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/SCAExternalizable.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/SCAObject.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/SCAObjectStartException.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/SCAObjectStopException.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ScopeContainer.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ScopeContainerMonitor.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ScopeRegistry.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/Service.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ServiceBinding.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/TargetDestructionException.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/TargetException.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/TargetInitializationException.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/TargetInvocationException.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/TargetInvokerCreationException.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/TargetNotFoundException.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/TargetResolutionException.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/WorkContext.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/DataBinding.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/DataBindingRegistry.java delete mode 100755 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/DataPipe.java delete mode 100755 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/Mediator.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/PullTransformer.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/PushTransformer.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/SimpleTypeMapper.java delete mode 100755 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/TransformationContext.java delete mode 100755 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/TransformationException.java delete mode 100755 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/Transformer.java delete mode 100755 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/TransformerRegistry.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/WrapperHandler.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/DOMHelper.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/DataBindingExtension.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/Java2SimpleTypeTransformer.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/SimpleType2JavaTransformer.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/SimpleTypeMapperExtension.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/TransformerExtension.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/XSDDataTypeConverter.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/ChangeSetHandler.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/ChangeSetHandlerRegistry.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/CompositeClassLoader.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/ContributionProcessor.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/ContributionProcessorRegistry.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/Deployer.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/DeploymentContext.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/DeploymentMonitor.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/event/AbstractEventPublisher.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/event/Event.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/event/EventFilter.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/event/EventPublisher.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/event/RuntimeEventListener.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/event/TrueFilter.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/AbstractComponentExtension.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/AtomicComponentExtension.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/BindingBuilderExtension.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/ComponentBuilderExtension.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/ComponentTypeLoaderExtension.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/CompositeComponentExtension.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/ExecutionMonitor.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/LoaderExtension.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/ReferenceBindingExtension.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/ServiceBindingExtension.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/SystemAtomicComponentExtension.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/TargetInvokerExtension.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/host/ResourceHost.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/host/ResourceHostRegistry.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/host/ResourceResolutionException.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/host/ServletHost.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/ElementInfo.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/InvalidConversationalOperationException.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/InvalidServiceContractException.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/OverloadedOperationException.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/TypeInfo.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/java/InterfaceJavaIntrospector.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/java/JavaIDLUtils.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/java/JavaInterfaceProcessor.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/java/JavaInterfaceProcessorExtension.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/java/JavaInterfaceProcessorRegistry.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/java/JavaServiceContract.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/AbstractPropertyProcessor.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/ConstructorDefinition.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/DuplicatePropertyException.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/IllegalPropertyException.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/ImplementationProcessor.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/ImplementationProcessorExtension.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/ImplementationProcessorService.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/IntrospectionRegistry.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/Introspector.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/JavaMappedComponentType.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/JavaMappedProperty.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/JavaMappedReference.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/JavaMappedService.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/PojoComponentType.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/ProcessingException.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/Resource.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/ComponentTypeLoader.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/InvalidConfigurationException.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/InvalidReferenceException.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/InvalidServiceException.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/InvalidValueException.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/InvalidWireException.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/Loader.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/LoaderException.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/LoaderRegistry.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/LoaderUtil.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/MissingImplementationException.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/MissingIncludeException.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/MissingMustOverridePropertyException.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/MissingReferenceException.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/MissingResourceException.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/NotOverridablePropertyException.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/PropertyObjectFactory.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/StAXElementLoader.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/UndefinedPropertyException.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/UndefinedReferenceException.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/UnrecognizedComponentTypeException.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/UnrecognizedElementException.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/AtomicImplementation.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/BindingDefinition.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/BoundReferenceDefinition.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/BoundServiceDefinition.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ComponentDefinition.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ComponentType.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/CompositeComponentType.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/CompositeImplementation.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/DataType.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Implementation.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Include.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Intent.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/IntentMap.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/IntentName.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/InteractionScope.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ModelObject.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Multiplicity.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Operation.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/OverrideOptions.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/PolicyAttachable.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/PolicyAttachableModel.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/PolicyContentModel.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/PolicyModel.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/PolicySet.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/PolicySetReference.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Property.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/PropertyValue.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Qualifier.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ReferenceDefinition.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ReferenceTarget.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Scope.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ServiceContract.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ServiceDefinition.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/WSPolicyAttachment.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/WireDefinition.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/WrapperInfo.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/policy/IntentRegistry.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/policy/PolicyBuilderRegistry.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/policy/PolicyEngine.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/policy/PolicySetContainer.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/policy/SCATypeManager.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/policy/SourcePolicyBuilder.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/policy/SourcePolicyBuilderExtension.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/policy/TargetPolicyBuilder.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/policy/TargetPolicyBuilderExtension.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/services/VoidService.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/services/artifact/Artifact.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/services/artifact/ArtifactRepository.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/services/discovery/AbstractDiscoveryService.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/services/discovery/DiscoveryService.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/services/discovery/MessageListener.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/services/management/TuscanyManagementService.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/services/store/DuplicateRecordException.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/services/store/RecoveryListener.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/services/store/Store.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/services/store/StoreException.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/services/store/StoreExpirationEvent.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/services/store/StoreMonitor.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/services/store/StoreReadException.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/services/store/StoreWriteException.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/services/work/NotificationListener.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/services/work/WorkScheduler.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/services/work/WorkSchedulerException.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/util/SCAObjectInputStream.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/AbstractInboundInvocationHandler.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/AbstractOutboundInvocationHandler.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/InboundInvocationChain.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/InboundWire.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/IncompatibleServiceContractException.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/Interceptor.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/InvocationChain.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/InvocationRuntimeException.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/Message.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/MessageId.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/MessageImpl.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/OutboundChainHolder.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/OutboundInvocationChain.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/OutboundWire.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/ProxyCreationException.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/TargetInvoker.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/Wire.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/WireInvocationHandler.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/WirePostProcessor.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/WirePostProcessorExtension.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/WirePostProcessorRegistry.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/WireService.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/AssertionTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/QualifiedNameTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/TuscanyRuntimeExceptionTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/annotation/ConstructorAnnotationTest.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/component/AbstractSCAObjectTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/databinding/extension/DOMHelperTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/databinding/extension/DataBindingExtensionTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/databinding/extension/SimpleTypeMapperExtensionTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/databinding/extension/TransformerExtensionTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/databinding/extension/XSDDataTypeConverterTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/event/AbstractEventPublisherTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/AtomicComponentExtensionTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/ComponentTypeLoaderExtensionTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/CompositeComponentExtensionAutowireTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/CompositeComponentExtensionTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/LoaderExtensionTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/ReferenceBindingExtensionTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/ReferenceTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/ServiceBindingExtensionTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/TargetInvokerExtensionSequenceTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/TargetInvokerExtensionTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/idl/java/JavaIDLUtilsTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/implementation/java/AbstractPropertyProcessorTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/loader/LoaderExceptionTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/model/CompositeComponentTypeTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/model/IntentNameTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/model/OperationTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/model/ScopeTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/model/ServiceContractTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/policy/SourcePolicyBuilderExtensionTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/policy/TargetPolicyBuilderExtensionTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/util/MockSCAExternalizable.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/util/MockSerializable.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/util/SCAObjectInputStreamTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/wire/AbstractInboundInvocationHandlerTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/wire/AbstractOutboundInvocationHandlerTestCase.java delete mode 100644 branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/wire/OutboundChainHolderTestCase.java (limited to 'branches/pre-spec-changes/kernel') diff --git a/branches/pre-spec-changes/kernel/api/.checkstyle b/branches/pre-spec-changes/kernel/api/.checkstyle deleted file mode 100644 index 3e57539570..0000000000 --- a/branches/pre-spec-changes/kernel/api/.checkstyle +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - diff --git a/branches/pre-spec-changes/kernel/api/.pmd b/branches/pre-spec-changes/kernel/api/.pmd deleted file mode 100644 index ffc4fe2bbb..0000000000 --- a/branches/pre-spec-changes/kernel/api/.pmd +++ /dev/null @@ -1,20 +0,0 @@ - - -true diff --git a/branches/pre-spec-changes/kernel/api/.ruleset b/branches/pre-spec-changes/kernel/api/.ruleset deleted file mode 100644 index 3886f07f2d..0000000000 --- a/branches/pre-spec-changes/kernel/api/.ruleset +++ /dev/null @@ -1,190 +0,0 @@ - - - - PMD Plugin preferences rule set - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/branches/pre-spec-changes/kernel/api/LICENSE.txt b/branches/pre-spec-changes/kernel/api/LICENSE.txt deleted file mode 100644 index 0084319535..0000000000 --- a/branches/pre-spec-changes/kernel/api/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/branches/pre-spec-changes/kernel/api/NOTICE.txt b/branches/pre-spec-changes/kernel/api/NOTICE.txt deleted file mode 100644 index d83ebbe236..0000000000 --- a/branches/pre-spec-changes/kernel/api/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/branches/pre-spec-changes/kernel/api/pom.xml b/branches/pre-spec-changes/kernel/api/pom.xml deleted file mode 100644 index ee41db6947..0000000000 --- a/branches/pre-spec-changes/kernel/api/pom.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - - org.apache.tuscany.sca.kernel - parent - 0.1-pre-spec-SNAPSHOT - - 4.0.0 - tuscany-api - jar - Apache Tuscany SCA API - Tuscany Application Programming Interfaces. - - - - org.osoa - sca-api-r0.95 - - - junit - junit - - - diff --git a/branches/pre-spec-changes/kernel/api/src/main/java/org/apache/tuscany/api/TuscanyException.java b/branches/pre-spec-changes/kernel/api/src/main/java/org/apache/tuscany/api/TuscanyException.java deleted file mode 100644 index ad649d716f..0000000000 --- a/branches/pre-spec-changes/kernel/api/src/main/java/org/apache/tuscany/api/TuscanyException.java +++ /dev/null @@ -1,164 +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.api; - -import java.util.ArrayList; -import java.util.List; -import java.util.Collections; -import java.io.PrintWriter; - -/** - * The root checked exception for the Tuscany runtime. - * - * @version $Rev$ $Date$ - */ -public abstract class TuscanyException extends Exception { - private static final long serialVersionUID = -7847121698339635268L; - private List contextStack; - private final String identifier; - - /** - * Override constructor from Exception. - * - * @see Exception - */ - public TuscanyException() { - super(); - this.identifier = null; - } - - /** - * Override constructor from Exception. - * - * @param message passed to Exception - * @see Exception - */ - public TuscanyException(String message) { - super(message); - this.identifier = null; - } - - /** - * Override constructor from Exception. - * - * @param message passed to Exception - * @param identifier additional error information referred to in the error message - * @see Exception - */ - public TuscanyException(String message, String identifier) { - super(message); - this.identifier = identifier; - } - - /** - * Override constructor from Exception. - * - * @param message passed to Exception - * @param cause passed to Exception - * @see Exception - */ - public TuscanyException(String message, Throwable cause) { - super(message, cause); - this.identifier = null; - } - - /** - * Override constructor from Exception. - * - * @param message passed to Exception - * @param identifier additional error information referred to in the error message - * @param cause passed to Exception - * @see Exception - */ - public TuscanyException(String message, String identifier, Throwable cause) { - super(message, cause); - this.identifier = identifier; - } - - /** - * Override constructor from Exception. - * - * @param cause passed to Exception - * @see Exception - */ - public TuscanyException(Throwable cause) { - super(cause); - this.identifier = null; - } - - /** - * Returns a collection of names representing the context call stack where the error occured. The top of the stack - * is the first element in the collection. - * - * @return a collection of names representing the context call stack - */ - public List returnContextNames() { - if (contextStack == null) { - contextStack = new ArrayList(); - } - return Collections.unmodifiableList(contextStack); - } - - /** - * Pushes a context name where an error occured onto the call stack. - * - * @param name the name of a context to push on the stack - */ - public void addContextName(String name) { - if (contextStack == null) { - contextStack = new ArrayList(); - } - contextStack.add(name); - } - - /** - * Returns a string representing additional error information referred to in the error message. - * - * @return additional error information - */ - public String getIdentifier() { - return identifier; - } - - public PrintWriter appendBaseMessage(PrintWriter writer) { - if (identifier == null && contextStack == null) { - if (super.getMessage() == null) { - return writer; - } - return writer.append(super.getMessage()); - } - if (super.getMessage() != null) { - writer.append(super.getMessage()); - } - if (identifier != null) { - writer.append(" [").append(identifier).append(']'); - } - return writer; - } - - public PrintWriter appendContextStack(PrintWriter writer) { - if (contextStack != null) { - writer.append("\nContext stack trace: "); - for (int i = contextStack.size() - 1; i >= 0; i--) { - writer.append('[').append(contextStack.get(i)).append(']'); - } - } - return writer; - } -} diff --git a/branches/pre-spec-changes/kernel/api/src/main/java/org/apache/tuscany/api/TuscanyRuntimeException.java b/branches/pre-spec-changes/kernel/api/src/main/java/org/apache/tuscany/api/TuscanyRuntimeException.java deleted file mode 100644 index fc92c57fa0..0000000000 --- a/branches/pre-spec-changes/kernel/api/src/main/java/org/apache/tuscany/api/TuscanyRuntimeException.java +++ /dev/null @@ -1,168 +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.api; - -import java.util.ArrayList; -import java.util.List; -import java.util.Collections; -import java.io.PrintWriter; - -/** - * The root unchecked exception for the Tuscany runtime. - * - * @version $Rev$ $Date$ - */ - -public abstract class TuscanyRuntimeException extends RuntimeException { - private static final long serialVersionUID = -759677431966121786L; - private List contextStack; - private final String identifier; - - /** - * Override constructor from RuntimeException. - * - * @see RuntimeException - */ - public TuscanyRuntimeException() { - super(); - this.identifier = null; - } - - /** - * Override constructor from RuntimeException. - * - * @param message passed to RuntimeException - * @see RuntimeException - */ - public TuscanyRuntimeException(String message) { - super(message); - this.identifier = null; - } - - - /** - * Override constructor from Exception. - * - * @param message passed to Exception - * @param identifier additional error information referred to in the error message - * @see Exception - */ - protected TuscanyRuntimeException(String message, String identifier) { - super(message); - this.identifier = identifier; - } - - /** - * Override constructor from RuntimeException. - * - * @param message passed to RuntimeException - * @param cause passed to RuntimeException - * @see RuntimeException - */ - public TuscanyRuntimeException(String message, Throwable cause) { - super(message, cause); - this.identifier = null; - } - - - /** - * Override constructor from Exception. - * - * @param message passed to Exception - * @param identifier additional error information referred to in the error message - * @param cause passed to RuntimeException - * @see Exception - */ - protected TuscanyRuntimeException(String message, String identifier, Throwable cause) { - super(message, cause); - this.identifier = identifier; - } - - /** - * Override constructor from RuntimeException. - * - * @param cause passed to RuntimeException - * @see RuntimeException - */ - public TuscanyRuntimeException(Throwable cause) { - super(cause); - this.identifier = null; - } - - /** - * Returns a collection of names representing the context call stack where the error occured. The top of the stack - * is the first element in the collection. - * - * @return a collection of names representing the context call stack - */ - public List returnContextNames() { - if (contextStack == null) { - contextStack = new ArrayList(); - } - return Collections.unmodifiableList(contextStack); - } - - /** - * Pushes a context name where an error occured onto the call stack. - * - * @param name the name of a context to push on the stack - */ - public void addContextName(String name) { - if (contextStack == null) { - contextStack = new ArrayList(); - } - contextStack.add(name); - } - - /** - * Returns a string representing additional error information referred to in the error message. - * - * @return additional error information - */ - public String getIdentifier() { - return identifier; - } - - public PrintWriter appendBaseMessage(PrintWriter writer) { - if (identifier == null && contextStack == null) { - if (super.getMessage() == null) { - return writer; - } - return writer.append(super.getMessage()); - } - if (super.getMessage() != null) { - writer.append(super.getMessage()); - } - if (identifier != null) { - writer.append(" [").append(identifier).append(']'); - } - return writer; - } - - public PrintWriter appendContextStack(PrintWriter writer) { - if (contextStack != null) { - writer.append("Context stack trace: "); - for (int i = contextStack.size() - 1; i >= 0; i--) { - writer.append('[').append(contextStack.get(i)).append(']'); - } - } - return writer; - } - -} diff --git a/branches/pre-spec-changes/kernel/api/src/main/java/org/apache/tuscany/api/annotation/DataContext.java b/branches/pre-spec-changes/kernel/api/src/main/java/org/apache/tuscany/api/annotation/DataContext.java deleted file mode 100644 index ab74ba9e5c..0000000000 --- a/branches/pre-spec-changes/kernel/api/src/main/java/org/apache/tuscany/api/annotation/DataContext.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.api.annotation; - -import static java.lang.annotation.ElementType.ANNOTATION_TYPE; -import java.lang.annotation.Retention; -import static java.lang.annotation.RetentionPolicy.RUNTIME; -import java.lang.annotation.Target; - -/** - * A key/value pair to represent information pertaining to a {@link DataType} - */ -@Target(ANNOTATION_TYPE) -@Retention(RUNTIME) -public @interface DataContext { - /** - * @return key for the context entry - */ - String key(); - - /** - * @return key for the context value - */ - String value(); - -} diff --git a/branches/pre-spec-changes/kernel/api/src/main/java/org/apache/tuscany/api/annotation/DataType.java b/branches/pre-spec-changes/kernel/api/src/main/java/org/apache/tuscany/api/annotation/DataType.java deleted file mode 100644 index 439aa837d2..0000000000 --- a/branches/pre-spec-changes/kernel/api/src/main/java/org/apache/tuscany/api/annotation/DataType.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.api.annotation; - -import static java.lang.annotation.ElementType.METHOD; -import static java.lang.annotation.ElementType.TYPE; -import java.lang.annotation.Retention; -import static java.lang.annotation.RetentionPolicy.RUNTIME; -import java.lang.annotation.Target; - -/** - * Used to demarcate expected data types for an operation - * - * @version $Rev$ $Date$ - */ -@Target({TYPE, METHOD}) -@Retention(RUNTIME) -public @interface DataType { - - /** - * Returns the unique name of the data binding - * @return the unique name of the data binding - */ - String name(); - - /** - * Returns the logical data type - * @return the logical data type - */ - Class logicalType() default Object.class; - - /** - * Returns the physical data type - * @return the physical data type - */ - Class physicalType() default Object.class; - - /** - * Returns an array of extensibility elements - * @return an array of extensibility elements - */ - DataContext[] context() default {}; - -} diff --git a/branches/pre-spec-changes/kernel/api/src/main/java/org/apache/tuscany/api/annotation/LogLevel.java b/branches/pre-spec-changes/kernel/api/src/main/java/org/apache/tuscany/api/annotation/LogLevel.java deleted file mode 100644 index 83c5df26d9..0000000000 --- a/branches/pre-spec-changes/kernel/api/src/main/java/org/apache/tuscany/api/annotation/LogLevel.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.api.annotation; - -import static java.lang.annotation.ElementType.METHOD; -import java.lang.annotation.Retention; -import static java.lang.annotation.RetentionPolicy.RUNTIME; -import java.lang.annotation.Target; - -/** - * Annotation that can be applied to methods in a monitoring interface to indicate to logging frameworks the severity of - * the event. - * - * @version $Rev$ $Date$ - */ -@Target({METHOD}) -@Retention(RUNTIME) -public @interface LogLevel { - - /** - * The log level as specified by {@link java.util.logging.Level}. - */ - @SuppressWarnings({"JavaDoc"}) String value(); -} diff --git a/branches/pre-spec-changes/kernel/api/src/main/java/org/apache/tuscany/api/annotation/Monitor.java b/branches/pre-spec-changes/kernel/api/src/main/java/org/apache/tuscany/api/annotation/Monitor.java deleted file mode 100644 index dea9489e5b..0000000000 --- a/branches/pre-spec-changes/kernel/api/src/main/java/org/apache/tuscany/api/annotation/Monitor.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.api.annotation; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * A system annotation to inject a monitor - * - * @version $Rev$ $Date$ - */ -@Target({ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER}) -@Retention(RetentionPolicy.RUNTIME) -public @interface Monitor { -} diff --git a/branches/pre-spec-changes/kernel/api/src/test/java/org/apache/tuscany/api/TuscanyExceptionTestCase.java b/branches/pre-spec-changes/kernel/api/src/test/java/org/apache/tuscany/api/TuscanyExceptionTestCase.java deleted file mode 100644 index 9f0674238f..0000000000 --- a/branches/pre-spec-changes/kernel/api/src/test/java/org/apache/tuscany/api/TuscanyExceptionTestCase.java +++ /dev/null @@ -1,164 +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.api; - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.util.ArrayList; -import java.util.List; - -import junit.framework.TestCase; - -/** - * @version $Rev$ $Date$ - */ -public class TuscanyExceptionTestCase extends TestCase { - private static final Throwable CAUSE = new Throwable("Cause"); - private static final String IDENTIFIER = "IDENTIFIER"; - private static final String MESSAGE = "Message"; - private static final String CONTEXT1 = "CONTEXT1"; - private static final String CONTEXT2 = "CONTEXT2"; - - public void testNoArgConstructor() { - TuscanyException ex = new DummyException(); - assertNull(ex.getMessage()); - assertNull(ex.getCause()); - assertNull(ex.getIdentifier()); - assertTrue(ex.returnContextNames().isEmpty()); - } - - public void testMessageConstructor() { - TuscanyException ex = new DummyException(MESSAGE); - assertEquals(MESSAGE, ex.getMessage()); - assertNull(ex.getCause()); - assertNull(ex.getIdentifier()); - assertTrue(ex.returnContextNames().isEmpty()); - } - - public void testAppendBaseMessage() { - TuscanyException ex = new DummyException(MESSAGE, IDENTIFIER); - StringWriter writer = new StringWriter(); - PrintWriter pw = new PrintWriter(writer); - ex.appendBaseMessage(pw); - assertEquals("Message [IDENTIFIER]", writer.toString()); - } - - public void testAppendBaseMessageNoIdentifier() { - TuscanyException ex = new DummyException(MESSAGE); - StringWriter writer = new StringWriter(); - PrintWriter pw = new PrintWriter(writer); - ex.appendBaseMessage(pw); - assertEquals("Message", writer.toString()); - } - - public void testThrowableConstructor() { - TuscanyException ex = new DummyException(CAUSE); - assertEquals(CAUSE.getClass().getName() + ": " + CAUSE.getMessage(), ex.getMessage()); - assertEquals(CAUSE, ex.getCause()); - assertNull(ex.getIdentifier()); - assertTrue(ex.returnContextNames().isEmpty()); - } - - public void testMessageThrowableConstructor() { - TuscanyException ex = new DummyException(MESSAGE, CAUSE); - assertEquals(MESSAGE, ex.getMessage()); - assertEquals(CAUSE, ex.getCause()); - assertNull(ex.getIdentifier()); - assertTrue(ex.returnContextNames().isEmpty()); - } - - public void testContextStack() { - TuscanyException ex = new DummyException(MESSAGE); - List contexts = new ArrayList(); - contexts.add(CONTEXT1); - ex.addContextName(CONTEXT1); - assertEquals(contexts, ex.returnContextNames()); - contexts.add(CONTEXT2); - ex.addContextName(CONTEXT2); - assertEquals(contexts, ex.returnContextNames()); - } - - public void testAppendContextMessage() { - TuscanyException ex = new DummyException(MESSAGE); - ex.addContextName(CONTEXT1); - ex.addContextName(CONTEXT2); - StringWriter writer = new StringWriter(); - PrintWriter pw = new PrintWriter(writer); - ex.appendContextStack(pw); - assertEquals("\nContext stack trace: [CONTEXT2][CONTEXT1]", writer.toString()); - } - - public void testAddContext() throws Exception { - TuscanyException e = new DummyException(); - e.addContextName("foo"); - e.addContextName("bar"); - assertEquals("foo", e.returnContextNames().get(0)); - assertEquals("bar", e.returnContextNames().get(1)); - } - - public void testEmptyContext() throws Exception { - TuscanyException e = new DummyException(); - assertEquals(0, e.returnContextNames().size()); - } - - public void testGetMessage() throws Exception { - TuscanyException e = new DummyException(); - e.getMessage(); - } - - public void testFullMessage() throws Exception { - TuscanyException e = new DummyException("message", "foo"); - e.addContextName("foo"); - e.getMessage(); - } - - public void testImmutableContextNames() { - TuscanyException e = new DummyException("message", "foo"); - try { - e.returnContextNames().add("foo"); - fail(); - } catch (UnsupportedOperationException e1) { - // expected - } - } - - - public static class DummyException extends TuscanyException { - - public DummyException() { - } - - public DummyException(String message) { - super(message); - } - - - public DummyException(String message, String identifier) { - super(message, identifier); - } - - public DummyException(String message, Throwable cause) { - super(message, cause); - } - - public DummyException(Throwable cause) { - super(cause); - } - } -} diff --git a/branches/pre-spec-changes/kernel/api/src/test/java/org/apache/tuscany/api/TuscanyRuntimeExceptionTestCase.java b/branches/pre-spec-changes/kernel/api/src/test/java/org/apache/tuscany/api/TuscanyRuntimeExceptionTestCase.java deleted file mode 100644 index 4addd5ab38..0000000000 --- a/branches/pre-spec-changes/kernel/api/src/test/java/org/apache/tuscany/api/TuscanyRuntimeExceptionTestCase.java +++ /dev/null @@ -1,142 +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.api; - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.util.ArrayList; -import java.util.List; - -import junit.framework.TestCase; - -/** - * @version $Rev$ $Date$ - */ -public class TuscanyRuntimeExceptionTestCase extends TestCase { - private static final Throwable CAUSE = new Throwable("Cause"); - private static final String MESSAGE = "Message"; - private static final String IDENTIFIER = "IDENTIFIER"; - private static final String CONTEXT1 = "CONTEXT1"; - private static final String CONTEXT2 = "CONTEXT2"; - - public void testNoArgConstructor() { - TuscanyRuntimeException ex = new DummyException(); - assertNull(ex.getMessage()); - assertNull(ex.getCause()); - assertNull(ex.getIdentifier()); - assertTrue(ex.returnContextNames().isEmpty()); - } - - public void testMessageConstructor() { - TuscanyRuntimeException ex = new DummyException(MESSAGE); - assertSame(MESSAGE, ex.getMessage()); - assertNull(ex.getCause()); - assertNull(ex.getIdentifier()); - assertTrue(ex.returnContextNames().isEmpty()); - } - - public void testThrowableConstructor() { - TuscanyRuntimeException ex = new DummyException(CAUSE); - assertEquals(CAUSE.getClass().getName() + ": " + CAUSE.getMessage(), ex.getMessage()); - assertSame(CAUSE, ex.getCause()); - assertNull(ex.getIdentifier()); - assertTrue(ex.returnContextNames().isEmpty()); - } - - public void testMessageThrowableConstructor() { - TuscanyRuntimeException ex = new DummyException(MESSAGE, CAUSE); - assertSame(MESSAGE, ex.getMessage()); - assertSame(CAUSE, ex.getCause()); - assertNull(ex.getIdentifier()); - assertTrue(ex.returnContextNames().isEmpty()); - } - - public void testIdentifier() { - TuscanyRuntimeException ex = new DummyException(MESSAGE, IDENTIFIER); - assertEquals(IDENTIFIER, ex.getIdentifier()); - } - - public void testContextStack() { - TuscanyRuntimeException ex = new DummyException(MESSAGE); - List contexts = new ArrayList(); - contexts.add(CONTEXT1); - ex.addContextName(CONTEXT1); - assertEquals(contexts, ex.returnContextNames()); - contexts.add(CONTEXT2); - ex.addContextName(CONTEXT2); - assertEquals(contexts, ex.returnContextNames()); - } - - public void testAppendContextMessage() { - TuscanyRuntimeException ex = new DummyException(MESSAGE); - ex.addContextName(CONTEXT1); - ex.addContextName(CONTEXT2); - StringWriter writer = new StringWriter(); - PrintWriter pw = new PrintWriter(writer); - ex.appendContextStack(pw); - assertEquals("Context stack trace: [CONTEXT2][CONTEXT1]", writer.toString()); - } - - public void testAppendBaseMessage() { - TuscanyRuntimeException ex = new DummyException(MESSAGE, IDENTIFIER); - StringWriter writer = new StringWriter(); - PrintWriter pw = new PrintWriter(writer); - ex.appendBaseMessage(pw); - assertEquals("Message [IDENTIFIER]", writer.toString()); - } - - public void testAppendBaseMessageNoIdentifier() { - TuscanyRuntimeException ex = new DummyException(MESSAGE); - StringWriter writer = new StringWriter(); - PrintWriter pw = new PrintWriter(writer); - ex.appendBaseMessage(pw); - assertEquals("Message", writer.toString()); - } - - public void testImmutableContextNames() { - TuscanyRuntimeException e = new DummyException("message", "foo"); - try { - e.returnContextNames().add("foo"); - fail(); - } catch (UnsupportedOperationException e1) { - // expected - } - } - - public static class DummyException extends TuscanyRuntimeException { - public DummyException() { - } - - public DummyException(String message) { - super(message); - } - - public DummyException(String message, String identifier) { - super(message, identifier); - } - - public DummyException(String message, Throwable cause) { - super(message, cause); - } - - public DummyException(Throwable cause) { - super(cause); - } - } -} diff --git a/branches/pre-spec-changes/kernel/core/.pmd b/branches/pre-spec-changes/kernel/core/.pmd deleted file mode 100644 index ffc4fe2bbb..0000000000 --- a/branches/pre-spec-changes/kernel/core/.pmd +++ /dev/null @@ -1,20 +0,0 @@ - - -true diff --git a/branches/pre-spec-changes/kernel/core/.ruleset b/branches/pre-spec-changes/kernel/core/.ruleset deleted file mode 100644 index ba9b5ce886..0000000000 --- a/branches/pre-spec-changes/kernel/core/.ruleset +++ /dev/null @@ -1,190 +0,0 @@ - - - - PMD Plugin preferences rule set - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/branches/pre-spec-changes/kernel/core/LICENSE.txt b/branches/pre-spec-changes/kernel/core/LICENSE.txt deleted file mode 100644 index 0084319535..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/NOTICE.txt b/branches/pre-spec-changes/kernel/core/NOTICE.txt deleted file mode 100644 index d83ebbe236..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/pom.xml b/branches/pre-spec-changes/kernel/core/pom.xml deleted file mode 100644 index e0875d933d..0000000000 --- a/branches/pre-spec-changes/kernel/core/pom.xml +++ /dev/null @@ -1,93 +0,0 @@ - - - - - org.apache.tuscany.sca.kernel - parent - 0.1-pre-spec-SNAPSHOT - - 4.0.0 - core - jar - Apache Tuscany SCA Core - Core Tuscany runtime. - - - - org.apache.tuscany.sca.kernel - tuscany-spi - ${pom.version} - compile - - - org.apache.tuscany.sca.kernel - tuscany-host-api - ${sca.version} - compile - - - org.apache.tuscany - commonj-api_r1.1 - - - - woodstox - wstx-asl - - - - javax.servlet - servlet-api - - - - org.apache.geronimo.specs - geronimo-j2ee-connector_1.5_spec - 1.0.1 - - - - junit - junit - - - org.easymock - easymockclassextension - - - - - - - src/main/resources - true - - - ${notice.dir} - META-INF - true - - LICENSE.txt - NOTICE.txt - - - - - diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/binding/local/AbstractLocalTargetInvoker.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/binding/local/AbstractLocalTargetInvoker.java deleted file mode 100644 index 7727759a88..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/binding/local/AbstractLocalTargetInvoker.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.binding.local; - -import java.lang.reflect.InvocationTargetException; - -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.OutboundInvocationChain; -import org.apache.tuscany.spi.wire.TargetInvoker; - -/** - * 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) throws InvocationTargetException { - throw new InvocationTargetException(new UnsupportedOperationException()); - } - - protected Message invoke(OutboundInvocationChain 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/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/binding/local/LocalBindingBuilder.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/binding/local/LocalBindingBuilder.java deleted file mode 100644 index 1841af679e..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/binding/local/LocalBindingBuilder.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.binding.local; - -import org.apache.tuscany.spi.builder.BuilderException; -import org.apache.tuscany.spi.component.CompositeComponent; -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.BoundReferenceDefinition; -import org.apache.tuscany.spi.model.BoundServiceDefinition; - -/** - * Creates runtime artifacts for the local binding - * - * @version $Rev$ $Date$ - */ -public class LocalBindingBuilder extends BindingBuilderExtension { - - protected Class getBindingType() { - return LocalBindingDefinition.class; - } - - public ServiceBinding build(CompositeComponent parent, - BoundServiceDefinition boundServiceDefinition, - LocalBindingDefinition bindingDefinition, - DeploymentContext deploymentContext) - throws BuilderException { - return new LocalServiceBinding(boundServiceDefinition.getName(), parent); - } - - - public ReferenceBinding build(CompositeComponent parent, - BoundReferenceDefinition boundReferenceDefinition, - LocalBindingDefinition bindingDefinition, - DeploymentContext deploymentContext) throws BuilderException { - return new LocalReferenceBinding(boundReferenceDefinition.getName(), parent); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/binding/local/LocalBindingDefinition.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/binding/local/LocalBindingDefinition.java deleted file mode 100644 index 9317a47457..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/binding/local/LocalBindingLoader.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/binding/local/LocalBindingLoader.java deleted file mode 100644 index 777beeb00e..0000000000 --- a/branches/pre-spec-changes/kernel/core/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.apache.tuscany.spi.annotation.Autowire; -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.deployer.DeploymentContext; -import org.apache.tuscany.spi.extension.LoaderExtension; -import org.apache.tuscany.spi.loader.LoaderException; -import org.apache.tuscany.spi.loader.LoaderRegistry; -import org.apache.tuscany.spi.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(@Autowire LoaderRegistry registry) { - super(registry); - } - - public QName getXMLType() { - return Wire.LOCAL_BINDING; - } - - public LocalBindingDefinition load(CompositeComponent parent, - 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/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/binding/local/LocalCallbackTargetInvoker.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/binding/local/LocalCallbackTargetInvoker.java deleted file mode 100644 index 03f42ca99c..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/binding/local/LocalCallbackTargetInvoker.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.binding.local; - -import java.util.Map; - -import org.apache.tuscany.spi.model.Operation; -import org.apache.tuscany.spi.wire.InboundWire; -import org.apache.tuscany.spi.wire.InvocationRuntimeException; -import org.apache.tuscany.spi.wire.Message; -import org.apache.tuscany.spi.wire.MessageImpl; -import org.apache.tuscany.spi.wire.OutboundInvocationChain; -import org.apache.tuscany.spi.wire.TargetInvoker; - -/** - * Dispatches a callback invocation to the callback instance - * - * @version $Rev$ $Date$ - */ -public class LocalCallbackTargetInvoker extends AbstractLocalTargetInvoker { - private Operation operation; - private InboundWire inboundWire; - - public LocalCallbackTargetInvoker(Operation operation, InboundWire inboundWire) { - assert operation != null : "Operation method cannot be null"; - this.operation = operation; - this.inboundWire = inboundWire; - } - - 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 { - Object targetAddress = msg.popFromAddress(); - if (targetAddress == null) { - throw new AssertionError("Popped a null from address from message"); - } - //TODO optimize as this is slow in local invocations - Map, OutboundInvocationChain> sourceCallbackInvocationChains = - inboundWire.getSourceCallbackInvocationChains(targetAddress); - OutboundInvocationChain chain = sourceCallbackInvocationChains.get(operation); - TargetInvoker invoker = chain.getTargetInvoker(); - return invoke(chain, invoker, msg); - } - - @Override - public LocalCallbackTargetInvoker clone() throws CloneNotSupportedException { - return (LocalCallbackTargetInvoker) super.clone(); - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/binding/local/LocalReferenceBinding.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/binding/local/LocalReferenceBinding.java deleted file mode 100644 index 9117fe903e..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/binding/local/LocalReferenceBinding.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.binding.local; - -import javax.xml.namespace.QName; - -import org.apache.tuscany.spi.CoreRuntimeException; -import org.apache.tuscany.spi.component.CompositeComponent; -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.ServiceContract; -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$ - */ -public class LocalReferenceBinding extends ReferenceBindingExtension { - - public LocalReferenceBinding(String name, CompositeComponent parent) throws CoreRuntimeException { - super(name, parent); - } - - public QName getBindingType() { - return Wire.LOCAL_BINDING; - } - - public TargetInvoker createTargetInvoker(ServiceContract contract, Operation operation) - throws TargetInvokerCreationException { - if (operation.isCallback()) { - return new LocalCallbackTargetInvoker(operation, inboundWire); - } else { - return new LocalTargetInvoker(operation, outboundWire); - } - } - - public TargetInvoker createCallbackTargetInvoker(ServiceContract contract, Operation operation) - throws TargetInvokerCreationException { - return new LocalCallbackTargetInvoker(operation, inboundWire); - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/binding/local/LocalServiceBinding.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/binding/local/LocalServiceBinding.java deleted file mode 100644 index 6205172d7b..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/binding/local/LocalServiceBinding.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.binding.local; - -import javax.xml.namespace.QName; - -import org.apache.tuscany.spi.CoreRuntimeException; -import org.apache.tuscany.spi.component.CompositeComponent; -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.ServiceContract; -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(String name, CompositeComponent parent) throws CoreRuntimeException { - super(name, parent); - } - - public QName getBindingType() { - return Wire.LOCAL_BINDING; - } - - public TargetInvoker createTargetInvoker(ServiceContract contract, Operation operation) - throws TargetInvokerCreationException { - if (operation.isCallback()) { - return new LocalCallbackTargetInvoker(operation, getInboundWire()); - } else { - return new LocalTargetInvoker(operation, outboundWire); - } - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/binding/local/LocalTargetInvoker.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/binding/local/LocalTargetInvoker.java deleted file mode 100644 index 5b564c93b8..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/binding/local/LocalTargetInvoker.java +++ /dev/null @@ -1,73 +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.model.Operation; -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.OutboundInvocationChain; -import org.apache.tuscany.spi.wire.OutboundWire; -import org.apache.tuscany.spi.wire.TargetInvoker; - -/** - * Dispatches an invocation through a composite service or reference using the local binding - * - * @version $Rev$ $Date$ - */ -public class LocalTargetInvoker extends AbstractLocalTargetInvoker { - private OutboundInvocationChain chain; - private Object fromAddress; - private boolean contractHasCallback; - - public LocalTargetInvoker(Operation operation, OutboundWire outboundWire) { - assert operation != null; - chain = outboundWire.getInvocationChains().get(operation); - assert chain != null; - fromAddress = (outboundWire.getContainer() == null) ? null : outboundWire.getContainer().getName(); - contractHasCallback = outboundWire.getServiceContract().getCallbackClass() != null; - } - - @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) { - msg.pushFromAddress(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/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/bootstrap/Bootstrapper.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/bootstrap/Bootstrapper.java deleted file mode 100644 index 0f6b4a2c92..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/bootstrap/Bootstrapper.java +++ /dev/null @@ -1,88 +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.host.MonitorFactory; -import org.apache.tuscany.spi.bootstrap.RuntimeComponent; -import org.apache.tuscany.spi.builder.Connector; -import org.apache.tuscany.spi.component.ScopeRegistry; -import org.apache.tuscany.spi.component.WorkContext; -import org.apache.tuscany.spi.deployer.Deployer; -import org.apache.tuscany.spi.implementation.java.Introspector; -import org.apache.tuscany.spi.loader.Loader; -import org.apache.tuscany.spi.loader.PropertyObjectFactory; - -/** - * 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 the RuntimeComponent that forms the fundamental root of the component assembly. This component has two - * children: a {@link org.apache.tuscany.spi.component.CompositeComponent} that is the root for all system - * components, and a {@link org.apache.tuscany.spi.component.CompositeComponent} that is the root for all - * application components. - * - * @return a new RuntimeComponent; basically a new Tuscany instance - */ - RuntimeComponent createRuntime(); - - /** - * 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 Loader for parsing a system definition represented as a XML SCDL file. - * - * @param propertyFactory the StAXPropertyFactory to be used to parse property values - * @param introspector the introspector to be used to extract component type information from a Java class - * @return a new prmordial Loader - */ - Loader createLoader(PropertyObjectFactory propertyFactory, Introspector introspector); - - /** - * Create a ScopeRegistry that supports the Scopes supported for primordial components - * - * @param workContext the WorkContext the Scopes should use - * @return a new primordial ScopeRegistry - */ - ScopeRegistry createScopeRegistry(WorkContext workContext); - - /** - * Create a Connector that can wire together primordial components. - * - * @return a new primordial Connector - */ - Connector createConnector(); -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/bootstrap/DefaultBootstrapper.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/bootstrap/DefaultBootstrapper.java deleted file mode 100644 index 762568eb01..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/bootstrap/DefaultBootstrapper.java +++ /dev/null @@ -1,262 +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.spi.bootstrap.ComponentNames; -import org.apache.tuscany.spi.bootstrap.RuntimeComponent; -import org.apache.tuscany.spi.builder.Builder; -import org.apache.tuscany.spi.builder.Connector; -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.component.ScopeContainerMonitor; -import org.apache.tuscany.spi.component.ScopeRegistry; -import org.apache.tuscany.spi.component.WorkContext; -import org.apache.tuscany.spi.deployer.Deployer; -import org.apache.tuscany.spi.extension.LoaderExtension; -import org.apache.tuscany.spi.idl.java.JavaInterfaceProcessorRegistry; -import org.apache.tuscany.spi.implementation.java.ImplementationProcessorService; -import org.apache.tuscany.spi.implementation.java.Introspector; -import org.apache.tuscany.spi.loader.LoaderRegistry; -import org.apache.tuscany.spi.loader.PropertyObjectFactory; -import org.apache.tuscany.spi.services.management.TuscanyManagementService; - -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.builder.ConnectorImpl; -import org.apache.tuscany.core.component.WorkContextImpl; -import org.apache.tuscany.core.component.scope.CompositeScopeObjectFactory; -import org.apache.tuscany.core.component.scope.ScopeRegistryImpl; -import org.apache.tuscany.core.deployer.DeployerImpl; -import org.apache.tuscany.core.idl.java.InterfaceJavaLoader; -import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl; -import org.apache.tuscany.core.implementation.IntrospectionRegistryImpl; -import org.apache.tuscany.core.implementation.composite.CompositeComponentImpl; -import org.apache.tuscany.core.implementation.composite.CompositeLoader; -import org.apache.tuscany.core.implementation.processor.ConstructorProcessor; -import org.apache.tuscany.core.implementation.processor.DestroyProcessor; -import org.apache.tuscany.core.implementation.processor.EagerInitProcessor; -import org.apache.tuscany.core.implementation.processor.HeuristicPojoProcessor; -import org.apache.tuscany.core.implementation.processor.ImplementationProcessorServiceImpl; -import org.apache.tuscany.core.implementation.processor.InitProcessor; -import org.apache.tuscany.core.implementation.processor.MonitorProcessor; -import org.apache.tuscany.core.implementation.processor.PropertyProcessor; -import org.apache.tuscany.core.implementation.processor.ReferenceProcessor; -import org.apache.tuscany.core.implementation.processor.ResourceProcessor; -import org.apache.tuscany.core.implementation.processor.ScopeProcessor; -import org.apache.tuscany.core.implementation.processor.ServiceProcessor; -import org.apache.tuscany.core.implementation.system.builder.SystemComponentBuilder; -import org.apache.tuscany.core.implementation.composite.SystemCompositeBuilder; -import org.apache.tuscany.core.implementation.system.loader.SystemComponentTypeLoader; -import org.apache.tuscany.core.implementation.system.loader.SystemCompositeComponentTypeLoader; -import org.apache.tuscany.core.implementation.system.loader.SystemImplementationLoader; -import org.apache.tuscany.core.implementation.system.model.SystemCompositeImplementation; -import org.apache.tuscany.core.implementation.system.model.SystemImplementation; -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.property.PropertyObjectFactoryImpl; -import org.apache.tuscany.core.wire.jdk.JDKWireService; -import org.apache.tuscany.host.MonitorFactory; - -/** - * 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 TuscanyManagementService managementService; - - /** - * 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 managementService management service used by the runtime. - */ - public DefaultBootstrapper(MonitorFactory monitorFactory, - XMLInputFactory xmlFactory, - TuscanyManagementService managementService) { - this.monitorFactory = monitorFactory; - this.xmlFactory = xmlFactory; - this.managementService = managementService; - } - - /** - * Returns the MonitorFactory being used by this bootstrapper. - * - * @return the MonitorFactory being used by this bootstrapper - */ - public MonitorFactory getMonitorFactory() { - return monitorFactory; - } - - /** - * Create the RuntimeComponent that will form the root of the component tree. Returns an new instance of a {@link - * DefaultRuntime} with the system and application root components initialized with default composite components. - * - * @return a newly created root for the component tree - */ - public RuntimeComponent createRuntime() { - DefaultRuntime runtime = new DefaultRuntime(); - CompositeComponent systemComponent = - new CompositeComponentImpl(ComponentNames.TUSCANY_SYSTEM_ROOT, runtime, null, true); - runtime.setSystemComponent(systemComponent); - CompositeComponent rootComponent = - new CompositeComponentImpl(ComponentNames.TUSCANY_APPLICATION_ROOT, runtime, null, null); - runtime.setRootComponent(rootComponent); - return runtime; - } - - /** - * Create primordial deployer that can be used to load the system definition. - * - * @return the primordial deployer - */ - public Deployer createDeployer() { - ScopeRegistry scopeRegistry = createScopeRegistry(new WorkContextImpl()); - Builder builder = createBuilder(scopeRegistry); - JavaInterfaceProcessorRegistry interfaceIntrospector = new JavaInterfaceProcessorRegistryImpl(); - Introspector introspector = createIntrospector(interfaceIntrospector); - LoaderRegistry loader = createLoader(new PropertyObjectFactoryImpl(), introspector); - DeployerImpl deployer = new DeployerImpl(xmlFactory, loader, builder); - deployer.setMonitor(getMonitorFactory().getMonitor(ScopeContainerMonitor.class)); - 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. - * - * @param workContext the WorkContext the scopes should use - * @return a new ScopeRegistry - */ - public ScopeRegistry createScopeRegistry(WorkContext workContext) { - ScopeRegistry scopeRegistry = new ScopeRegistryImpl(); - new CompositeScopeObjectFactory(scopeRegistry, monitorFactory.getMonitor(ScopeContainerMonitor.class)); - return scopeRegistry; - } - - /** - * Create a Loader that can be used to parse an XML file containing the SCDL for the system definition. The - * following Implementation types are supported:
  • SystemImplementation
  • - *
  • SystemCompositeImplementation
and the following SCDL elements are supported:
    - *
  • composite
  • component
  • componentType
  • interface.java
  • property
  • - *
  • reference
  • service
  • implementation.system
Note the Java component type and the - * WSDL interface type are not supported. - * - * @param propertyFactory the StAXPropertyFactory to be used for parsing Property values - * @param introspector the Introspector to be used to inspect component implementations - * @return a new StAX XML loader - */ - public LoaderRegistry createLoader(PropertyObjectFactory propertyFactory, Introspector introspector) { - LoaderRegistryImpl loaderRegistry = - new LoaderRegistryImpl(monitorFactory.getMonitor(LoaderRegistryImpl.Monitor.class)); - - // register component type loaders - loaderRegistry.registerLoader(SystemImplementation.class, new SystemComponentTypeLoader(introspector)); - loaderRegistry.registerLoader(SystemCompositeImplementation.class, - new SystemCompositeComponentTypeLoader(loaderRegistry)); - - // 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)); - JavaInterfaceProcessorRegistryImpl processorRegistry = new JavaInterfaceProcessorRegistryImpl(); - registerLoader(loaderRegistry, new InterfaceJavaLoader(loaderRegistry, processorRegistry)); - registerLoader(loaderRegistry, new PropertyLoader(loaderRegistry)); - registerLoader(loaderRegistry, new ReferenceLoader(loaderRegistry)); - registerLoader(loaderRegistry, new ServiceLoader(loaderRegistry)); - registerLoader(loaderRegistry, new SystemImplementationLoader(loaderRegistry)); - registerLoader(loaderRegistry, new LocalBindingLoader(loaderRegistry)); - return loaderRegistry; - } - - /** - * Create new Introspector for extracting a ComponentType definition from a Java class. - * - * @return a new Introspector - */ - public Introspector createIntrospector(JavaInterfaceProcessorRegistry registry) { - ImplementationProcessorService service = new ImplementationProcessorServiceImpl(registry); - IntrospectionRegistryImpl.Monitor monitor = monitorFactory.getMonitor(IntrospectionRegistryImpl.Monitor.class); - IntrospectionRegistryImpl introspectionRegistry = new IntrospectionRegistryImpl(monitor); - introspectionRegistry.registerProcessor(new ConstructorProcessor(service)); - introspectionRegistry.registerProcessor(new DestroyProcessor()); - introspectionRegistry.registerProcessor(new InitProcessor()); - introspectionRegistry.registerProcessor(new EagerInitProcessor()); - introspectionRegistry.registerProcessor(new ScopeProcessor()); - introspectionRegistry.registerProcessor(new PropertyProcessor(service)); - introspectionRegistry.registerProcessor(new ReferenceProcessor(registry)); - introspectionRegistry.registerProcessor(new ResourceProcessor()); - introspectionRegistry.registerProcessor(new ServiceProcessor(service)); - introspectionRegistry.registerProcessor(new HeuristicPojoProcessor(service)); - introspectionRegistry.registerProcessor(new MonitorProcessor(monitorFactory, service)); - return introspectionRegistry; - } - - /** - * Create a new Connector that can be used to wire primordial components together. - * - * @return a new Connector - */ - public Connector createConnector() { - return new ConnectorImpl(); - } - - /** - * 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); - } - - /** - * 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, new JDKWireService()); - SystemCompositeBuilder builder = - new SystemCompositeBuilder(builderRegistry, createConnector(), managementService); - builderRegistry.register(SystemCompositeImplementation.class, builder); - builderRegistry.register(SystemImplementation.class, new SystemComponentBuilder()); - builderRegistry.register(LocalBindingDefinition.class, new LocalBindingBuilder()); - return builderRegistry; - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/bootstrap/DefaultRuntime.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/bootstrap/DefaultRuntime.java deleted file mode 100644 index 978d10fc37..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/bootstrap/DefaultRuntime.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.bootstrap; - -import java.util.HashMap; -import java.util.Map; - -import org.w3c.dom.Document; - -import org.apache.tuscany.spi.bootstrap.ComponentNames; -import org.apache.tuscany.spi.bootstrap.RuntimeComponent; -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.component.TargetResolutionException; -import org.apache.tuscany.spi.deployer.Deployer; -import org.apache.tuscany.spi.wire.InboundWire; - -import org.apache.tuscany.core.implementation.composite.CompositeComponentImpl; - -/** - * The default implementation of the Tuscany runtime component - * - * @version $Rev$ $Date$ - */ -public class DefaultRuntime extends CompositeComponentImpl implements RuntimeComponent { - private CompositeComponent rootComponent; - private CompositeComponent systemComponent; - - /** - * Initialize a default runtime with an empty set of Property values. - */ - public DefaultRuntime() { - this(new HashMap()); - } - - /** - * Initialize a runtime with the a set of properties - * - * @param runtimeProperties Property values for the runtime itself - */ - public DefaultRuntime(Map runtimeProperties) { - super(ComponentNames.TUSCANY_RUNTIME, null, null, runtimeProperties); - } - - protected void setRootComponent(CompositeComponent rootComponent) { - this.rootComponent = rootComponent; - } - - protected void setSystemComponent(CompositeComponent systemComponent) { - this.systemComponent = systemComponent; - } - - public CompositeComponent getRootComponent() { - return rootComponent; - } - - public CompositeComponent getSystemComponent() { - return systemComponent; - } - - public Deployer getDeployer() throws TargetResolutionException { - InboundWire wire = systemComponent.resolveExternalAutowire(Deployer.class); - if (wire != null) { - return (Deployer) wire.getTargetService(); - } - return null; - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/builder/BuilderRegistryImpl.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/builder/BuilderRegistryImpl.java deleted file mode 100644 index 3a1501c98d..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/builder/BuilderRegistryImpl.java +++ /dev/null @@ -1,241 +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.QualifiedName; -import org.apache.tuscany.spi.annotation.Autowire; -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.MissingWireTargetException; -import org.apache.tuscany.spi.builder.ScopeNotFoundException; -import org.apache.tuscany.spi.component.AtomicComponent; -import org.apache.tuscany.spi.component.Component; -import org.apache.tuscany.spi.component.CompositeComponent; -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.BoundReferenceDefinition; -import org.apache.tuscany.spi.model.BoundServiceDefinition; -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.InteractionScope; -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.spi.wire.WireService; - -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 { - protected WireService wireService; - protected ScopeRegistry scopeRegistry; - - private final Map>, ComponentBuilder>> - componentBuilders = - new HashMap>, ComponentBuilder>>(); - private final Map, BindingBuilder> bindingBuilders = - new HashMap, BindingBuilder>(); - - public BuilderRegistryImpl(@Autowire - ScopeRegistry scopeRegistry, @Autowire - WireService wireService) { - this.scopeRegistry = scopeRegistry; - this.wireService = wireService; - } - - 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(CompositeComponent parent, - ComponentDefinition componentDefinition, - DeploymentContext context) throws BuilderException { - Class implClass = componentDefinition.getImplementation().getClass(); - // noinspection SuspiciousMethodCalls - ComponentBuilder componentBuilder = (ComponentBuilder) componentBuilders.get(implClass); - try { - if (componentBuilder == null) { - String name = implClass.getName(); - throw new NoRegisteredBuilderException("No builder registered for implementation", name); - } - - Component component = componentBuilder.build(parent, componentDefinition, context); - if (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()) { - InteractionScope intScope = serviceDef.getServiceContract().getInteractionScope(); - if (intScope == InteractionScope.CONVERSATIONAL) { - hasConversationalContract = true; - break; - } - } - if (!hasConversationalContract) { - Map references = componentType.getReferences(); - for (ReferenceDefinition refDef : references.values()) { - // TODO check for a conversational callback contract - // refDef.getServiceContract() ... - } - } - 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); - } - } - ComponentType componentType = componentDefinition.getImplementation().getComponentType(); - assert componentType != null : "Component type must be set"; - // create wires for the component - if (wireService != null && component instanceof AtomicComponent) { - wireService.createWires((AtomicComponent) component, componentDefinition); - } - return component; - } catch (BuilderException e) { - e.addContextName(componentDefinition.getName()); - throw e; - } - } - - @SuppressWarnings({"unchecked"}) - public Service build(CompositeComponent parent, - BoundServiceDefinition boundServiceDefinition, - DeploymentContext deploymentContext) throws BuilderException { - String name = boundServiceDefinition.getName(); - ServiceContract serviceContract = boundServiceDefinition.getServiceContract(); - if (boundServiceDefinition.getBindings().isEmpty()) { - // if no bindings are configured, default to the local binding. - // this should be changed to allow runtime selection - if (boundServiceDefinition.getBindings().isEmpty()) { - // TODO JFM implement capability for the runtime to choose a binding - boundServiceDefinition.addBinding(new LocalBindingDefinition()); - } - } - boolean system = parent.isSystem(); - URI targetUri = boundServiceDefinition.getTarget(); - Service service = new ServiceImpl(name, parent, serviceContract, targetUri, system); - for (BindingDefinition definition : boundServiceDefinition.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(parent, boundServiceDefinition, definition, deploymentContext); - if (wireService != null) { - URI uri = boundServiceDefinition.getTarget(); - if (uri == null) { - throw new MissingWireTargetException("Service uri not specified"); - } - String path = uri.getPath(); - ServiceContract contract = boundServiceDefinition.getServiceContract(); - wireService.createWires(binding, contract, path); - } - service.addServiceBinding(binding); - } - return service; - } - - @SuppressWarnings("unchecked") - public Reference build(CompositeComponent parent, - BoundReferenceDefinition referenceDefinition, - DeploymentContext context) throws BuilderException { - String name = referenceDefinition.getName(); - 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(name, parent, contract); - for (BindingDefinition bindingDefinition : referenceDefinition.getBindings()) { - Class bindingClass = bindingDefinition.getClass(); - // noinspection SuspiciousMethodCalls - BindingBuilder bindingBuilder = bindingBuilders.get(bindingClass); - ReferenceBinding binding = bindingBuilder.build(parent, referenceDefinition, bindingDefinition, context); - // create wires for the component - if (wireService != null) { - URI targetUri = bindingDefinition.getTargetUri(); - // it is possible for a binding to not have a URI - QualifiedName targetName = null; - if (targetUri != null) { - targetName = new QualifiedName(targetUri.getPath()); - } - wireService.createWires(binding, contract, targetName); - - } - reference.addReferenceBinding(binding); - - } - return reference; - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/builder/ConnectorImpl.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/builder/ConnectorImpl.java deleted file mode 100644 index 1fb5c9f0f5..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/builder/ConnectorImpl.java +++ /dev/null @@ -1,609 +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.List; -import java.util.Map; - -import org.osoa.sca.annotations.Constructor; - -import org.apache.tuscany.spi.QualifiedName; -import org.apache.tuscany.spi.annotation.Autowire; -import org.apache.tuscany.spi.builder.Connector; -import org.apache.tuscany.spi.builder.MissingWireTargetException; -import org.apache.tuscany.spi.builder.WiringException; -import org.apache.tuscany.spi.component.Component; -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.component.Reference; -import org.apache.tuscany.spi.component.ReferenceBinding; -import org.apache.tuscany.spi.component.SCAObject; -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.TargetResolutionException; -import org.apache.tuscany.spi.component.WorkContext; -import org.apache.tuscany.spi.idl.java.JavaServiceContract; -import org.apache.tuscany.spi.model.Operation; -import org.apache.tuscany.spi.model.Scope; -import org.apache.tuscany.spi.model.ServiceContract; -import org.apache.tuscany.spi.services.work.WorkScheduler; -import org.apache.tuscany.spi.wire.InboundInvocationChain; -import org.apache.tuscany.spi.wire.InboundWire; -import org.apache.tuscany.spi.wire.IncompatibleServiceContractException; -import org.apache.tuscany.spi.wire.Interceptor; -import org.apache.tuscany.spi.wire.OutboundInvocationChain; -import org.apache.tuscany.spi.wire.OutboundWire; -import org.apache.tuscany.spi.wire.TargetInvoker; -import org.apache.tuscany.spi.wire.WirePostProcessorRegistry; -import org.apache.tuscany.spi.wire.WireService; - -import org.apache.tuscany.core.wire.LoopBackWire; -import org.apache.tuscany.core.wire.NonBlockingBridgingInterceptor; -import org.apache.tuscany.core.wire.SynchronousBridgingInterceptor; -import org.apache.tuscany.core.wire.WireUtils; - -/** - * The default connector implmentation - * - * @version $$Rev$$ $$Date$$ - */ -public class ConnectorImpl implements Connector { - private WirePostProcessorRegistry postProcessorRegistry; - private WireService wireService; - private WorkContext workContext; - private WorkScheduler scheduler; - - public ConnectorImpl() { - } - - @Constructor - public ConnectorImpl(@Autowire WireService wireService, - @Autowire WirePostProcessorRegistry processorRegistry, - @Autowire WorkScheduler scheduler, - @Autowire WorkContext workContext) { - this.postProcessorRegistry = processorRegistry; - this.wireService = wireService; - this.scheduler = scheduler; - this.workContext = workContext; - } - - public void connect(SCAObject source) throws WiringException { - if (source instanceof Component) { - handleComponent((Component) source); - } else if (source instanceof Reference) { - handleReference((Reference) source); - } else if (source instanceof Service) { - handleService((Service) source); - } else { - throw new AssertionError("Invalid source type"); - } - } - - public void connect(InboundWire sourceWire, OutboundWire targetWire, boolean optimizable) - throws WiringException { - Map, OutboundInvocationChain> targetChains = targetWire.getInvocationChains(); - if (sourceWire.getContainer() != null && sourceWire.getContainer().isSystem()) { - sourceWire.setTargetWire(targetWire); - // system services do not need to have their chains processed, return - return; - } - for (InboundInvocationChain inboundChain : sourceWire.getInvocationChains().values()) { - // match invocation chains - OutboundInvocationChain outboundChain = targetChains.get(inboundChain.getOperation()); - if (outboundChain == null) { - throw new IncompatibleInterfacesException(sourceWire, targetWire); - } - connect(inboundChain, outboundChain); - } - if (postProcessorRegistry != null) { - // run wire post-processors - postProcessorRegistry.process(sourceWire, targetWire); - } - if (optimizable && WireUtils.isOptimizable(sourceWire) && WireUtils.isOptimizable(targetWire)) { - sourceWire.setOptimizable(true); - sourceWire.setTargetWire(targetWire); - } - } - - /** - * Connects the source outbound wire to a corresponding target inbound wire - * - * @param sourceWire the source wire to connect - * @param targetWire the target wire to connect to - * @param optimizable true if the wire connection can be optimized - * @throws WiringException - */ - public void connect(OutboundWire sourceWire, InboundWire targetWire, boolean optimizable) - throws WiringException { - SCAObject source = sourceWire.getContainer(); - assert source != null; - SCAObject target = targetWire.getContainer(); - assert target != null; - Map, InboundInvocationChain> targetChains = targetWire.getInvocationChains(); - if (sourceWire.getContainer() != null && sourceWire.getContainer().isSystem()) { - sourceWire.setTargetWire(targetWire); - // system services do not need to have their chains processed, return - return; - } - // match outbound to inbound chains - for (OutboundInvocationChain outboundChain : sourceWire.getInvocationChains().values()) { - Operation operation = outboundChain.getOperation(); - InboundInvocationChain inboundChain = targetChains.get(operation); - if (inboundChain == null) { - throw new IncompatibleInterfacesException(sourceWire, targetWire); - } - Operation inboundOperation = inboundChain.getOperation(); - boolean isOneWayOperation = operation.isNonBlocking(); - TargetInvoker invoker; - if (target instanceof Component) { - Component component = (Component) target; - QualifiedName wireTargetName = sourceWire.getTargetName(); - String portName = null; - if (wireTargetName != null) { - portName = wireTargetName.getPortName(); - } - try { - invoker = component.createTargetInvoker(portName, inboundOperation, targetWire); - } catch (TargetInvokerCreationException e) { - throw new WireConnectException("Error connecting source and target", sourceWire, targetWire, e); - } - } else if (target instanceof ReferenceBinding) { - ReferenceBinding referenceBinding = (ReferenceBinding) target; - try { - invoker = referenceBinding.createTargetInvoker(targetWire.getServiceContract(), inboundOperation); - } catch (TargetInvokerCreationException e) { - String targetName = targetWire.getContainer().getName(); - throw new WireConnectException("Error processing inbound wire", null, null, targetName, null, e); - } - } else if (target instanceof ServiceBinding) { - ServiceBinding binding = (ServiceBinding) target; - try { - invoker = binding.createTargetInvoker(targetWire.getServiceContract(), inboundChain.getOperation()); - } catch (TargetInvokerCreationException e) { - String targetName = targetWire.getContainer().getName(); - throw new WireConnectException("Error processing inbound wire", null, null, targetName, null, e); - } - } else { - throw new AssertionError(); - } - - if (source instanceof ServiceBinding) { - // services are a special case: invoker must go on the inbound and outbound chains - if (target instanceof Component && isOneWayOperation) { - // if the target is a component and the operation is non-blocking - connect(outboundChain, inboundChain, invoker, true); - } else { - connect(outboundChain, inboundChain, invoker, false); - } - ServiceBinding binding = (ServiceBinding) source; - InboundInvocationChain chain = binding.getInboundWire().getInvocationChains().get(operation); - chain.setTargetInvoker(invoker); - } else { - if (target instanceof Component && isOneWayOperation) { - // if the target is a component and the operation is non-blocking - connect(outboundChain, inboundChain, invoker, true); - } else { - connect(outboundChain, inboundChain, invoker, false); - } - } - } - - // create source callback chains and connect them if target callback chains exist - Map, OutboundInvocationChain> sourceCallbackChains = - targetWire.getSourceCallbackInvocationChains(source.getName()); - for (InboundInvocationChain inboundChain : sourceWire.getTargetCallbackInvocationChains().values()) { - Operation operation = inboundChain.getOperation(); - if (sourceCallbackChains != null && sourceCallbackChains.get(operation) != null) { - String opName = operation.getName(); - throw new IllegalCallbackException("Source callback chain should not exist for operation", - opName, - sourceWire, - targetWire); - } - - ServiceContract targetContract = targetWire.getServiceContract(); - assert targetContract != null; - String opName = operation.getName(); - assert opName != null; - Operation targetOp = targetContract.getCallbackOperations().get(opName); - OutboundInvocationChain outboundChain = wireService.createOutboundChain(targetOp); - targetWire.addSourceCallbackInvocationChain(source.getName(), targetOp, outboundChain); - if (source instanceof Component) { - Component component = (Component) source; - TargetInvoker invoker; - try { - invoker = component.createTargetInvoker(targetOp.getName(), operation, null); - } catch (TargetInvokerCreationException e) { - throw new WireConnectException("Error connecting source and target", sourceWire, targetWire, e); - } - boolean isOneWayOperation = targetOp.isNonBlocking(); - if (target instanceof Component && isOneWayOperation) { - // if the target is a component and the operation is non-blocking - connect(outboundChain, inboundChain, invoker, true); - } else { - connect(outboundChain, inboundChain, invoker, false); - } - } else if (source instanceof ReferenceBinding) { - ReferenceBinding binding = (ReferenceBinding) source; - ServiceContract sourceContract = sourceWire.getServiceContract(); - TargetInvoker invoker; - try { - invoker = binding.createTargetInvoker(sourceContract, operation); - } catch (TargetInvokerCreationException e) { - throw new WireConnectException("Error connecting source and target", sourceWire, targetWire, e); - } - connect(outboundChain, inboundChain, invoker, false); - } else if (source instanceof ServiceBinding) { - ServiceBinding binding = (ServiceBinding) source; - ServiceContract sourceContract = sourceWire.getServiceContract(); - TargetInvoker invoker; - try { - invoker = binding.createTargetInvoker(sourceContract, operation); - } catch (TargetInvokerCreationException e) { - String targetName = sourceWire.getContainer().getName(); - throw new WireConnectException("Error processing callback wire", null, null, targetName, null, e); - } - connect(outboundChain, inboundChain, invoker, false); - } else { - throw new AssertionError(); - } - } - if (postProcessorRegistry != null) { - // run wire post-processors - postProcessorRegistry.process(sourceWire, targetWire); - } - // perform optimization, if possible - if (optimizable && WireUtils.isOptimizable(sourceWire) && WireUtils.isOptimizable(targetWire)) { - sourceWire.setOptimizable(true); - sourceWire.setTargetWire(targetWire); - } - } - - /** - * Connects a source to target chain - * - * @param sourceChain the source chain - * @param targetChain the target chain - * @param invoker the invoker to place on the source chain for dispatching invocations - * @param nonBlocking true if the operation is non-blocking - */ - protected void connect(OutboundInvocationChain sourceChain, - InboundInvocationChain targetChain, - TargetInvoker invoker, - boolean nonBlocking) throws WireConnectException { - Interceptor head = targetChain.getHeadInterceptor(); - if (head == null) { - throw new WireConnectException("Inbound chain must contain at least one interceptor"); - } - if (nonBlocking) { - sourceChain.setTargetInterceptor(new NonBlockingBridgingInterceptor(scheduler, workContext, head)); - } else { - sourceChain.setTargetInterceptor(new SynchronousBridgingInterceptor(head)); - } - sourceChain.prepare(); - sourceChain.setTargetInvoker(invoker); - } - - - /** - * Connects an inbound source chain to an outbound target chain - * - * @param sourceChain the source chain to connect - * @param targetChain the target chain to connect - */ - protected void connect(InboundInvocationChain sourceChain, OutboundInvocationChain targetChain) - throws WireConnectException { - Interceptor head = targetChain.getHeadInterceptor(); - if (head == null) { - throw new WireConnectException("Outbound chain must contain at least one interceptor"); - } - // invocations from inbound to outbound chains are always synchronous as they occur in services and references - sourceChain.addInterceptor(new SynchronousBridgingInterceptor(head)); - } - - /** - * Connects an outbound wire to its target in a composite. - * - * @param sourceWire the source wire to connect - * @throws WiringException - */ - protected void connect(SCAObject source, OutboundWire sourceWire, SCAObject target) throws WiringException { - assert sourceWire.getTargetName() != null; - QualifiedName targetName = sourceWire.getTargetName(); - if (target instanceof Component) { - connect(source, sourceWire, (Component) target); - } else if (target instanceof Reference) { - connect(source, sourceWire, (Reference) target); - } else if (target instanceof Service) { - connect(source, sourceWire, (Service) target); - } else if (target == null) { - String sourceName = sourceWire.getContainer().getName(); - String sourceReference = sourceWire.getReferenceName(); - throw new TargetServiceNotFoundException("Target service not found", - sourceName, - sourceReference, - targetName.getPartName(), - targetName.getPortName()); - } else { - String sourceName = sourceWire.getContainer().getName(); - String sourceRef = sourceWire.getReferenceName(); - String partName = targetName.getPartName(); - String portName = targetName.getPortName(); - throw new InvalidTargetTypeException("Invalid target type", sourceName, sourceRef, partName, portName); - } - } - - protected void connect(SCAObject source, OutboundWire sourceWire, Reference target) throws WiringException { - assert sourceWire.getTargetName() != null; - QualifiedName targetName = sourceWire.getTargetName(); - InboundWire targetWire = null; - for (ReferenceBinding binding : target.getReferenceBindings()) { - InboundWire candidate = binding.getInboundWire(); - if (sourceWire.getBindingType().equals(candidate.getBindingType())) { - targetWire = candidate; - break; - } - } - if (targetWire == null) { - if (target.getReferenceBindings().size() > 0 && source instanceof Component) { - // TODO create a pluggable algorithm for selecting the binding type - targetWire = target.getReferenceBindings().get(0).getInboundWire(); - } - if (targetWire == null) { - throw new NoCompatibleBindingsException(source.getName(), - targetName.getPartName(), - targetName.getPortName()); - } - } - checkIfWireable(sourceWire, targetWire); - boolean optimizable = isOptimizable(source.getScope(), target.getScope()); - connect(sourceWire, targetWire, optimizable); - } - - protected void connect(SCAObject source, OutboundWire sourceWire, Service target) throws WiringException { - assert sourceWire.getTargetName() != null; - QualifiedName targetName = sourceWire.getTargetName(); - InboundWire targetWire = null; - for (ServiceBinding binding : target.getServiceBindings()) { - InboundWire candidate = binding.getInboundWire(); - if (sourceWire.getBindingType().equals(candidate.getBindingType())) { - targetWire = candidate; - break; - } - } - if (targetWire == null) { - throw new NoCompatibleBindingsException(source.getName(), - targetName.getPartName(), - targetName.getPortName()); - } - checkIfWireable(sourceWire, targetWire); - boolean optimizable = isOptimizable(source.getScope(), target.getScope()); - connect(sourceWire, targetWire, optimizable); - } - - protected void connect(SCAObject source, OutboundWire sourceWire, Component target) - throws WiringException { - assert sourceWire.getTargetName() != null; - QualifiedName targetName = sourceWire.getTargetName(); - InboundWire targetWire; - // FIXME JFM should we move getInboundSystemWire up to Component? - if (target instanceof CompositeComponent && source.isSystem()) { - targetWire = ((CompositeComponent) target).getInboundSystemWire(targetName.getPortName()); - } else { - targetWire = target.getInboundWire(targetName.getPortName()); - } - if (targetWire == null) { - String sourceName = sourceWire.getContainer().getName(); - String sourceReference = sourceWire.getReferenceName(); - throw new TargetServiceNotFoundException("Target service does not exist or is not configured with a " - + "local binding", - sourceName, - sourceReference, - targetName.getPartName(), - targetName.getPortName()); - } - checkIfWireable(sourceWire, targetWire); - boolean optimizable = isOptimizable(source.getScope(), target.getScope()); - connect(sourceWire, targetWire, optimizable); - } - - protected void autowire(OutboundWire outboundWire, CompositeComponent parent) - throws WiringException { - // JFM FIXME test coverage for this method - InboundWire targetWire; - try { - Class interfaze = outboundWire.getServiceContract().getInterfaceClass(); - if (CompositeComponent.class.equals(interfaze)) { - JavaServiceContract contract = new JavaServiceContract(CompositeComponent.class); - targetWire = new LoopBackWire(); - targetWire.setServiceContract(contract); - targetWire.setContainer(parent); - outboundWire.setTargetWire(targetWire); - return; - } - if (outboundWire.getContainer().isSystem()) { - targetWire = parent.resolveSystemAutowire(interfaze); - } else { - targetWire = parent.resolveAutowire(interfaze); - } - } catch (TargetResolutionException e) { - String sourceReference = outboundWire.getReferenceName(); - String sourceName = outboundWire.getContainer().getName(); - throw new WireConnectException("Error resolving autowire target", - sourceName, - sourceReference, - null, - null, - e); - } - if (targetWire == null) { - // autowire may return null if it is optional. The client must decide if an error should be thrown - return; - } - Scope sourceScope = outboundWire.getContainer().getScope(); - Scope targetScope = targetWire.getContainer().getScope(); - boolean optimizable = isOptimizable(sourceScope, targetScope); - connect(outboundWire, targetWire, optimizable); - } - - protected void checkIfWireable(OutboundWire sourceWire, InboundWire targetWire) - throws IncompatibleInterfacesException { - if (wireService == null) { - Class sourceInterface = sourceWire.getServiceContract().getInterfaceClass(); - Class targetInterface = targetWire.getServiceContract().getInterfaceClass(); - if (!sourceInterface.isAssignableFrom(targetInterface)) { - throw new IncompatibleInterfacesException(sourceWire, targetWire); - } - } else { - try { - ServiceContract sourceContract = sourceWire.getServiceContract(); - ServiceContract targetContract = targetWire.getServiceContract(); - wireService.checkCompatibility(sourceContract, targetContract, false); - } catch (IncompatibleServiceContractException e) { - throw new IncompatibleInterfacesException(sourceWire, targetWire, e); - } - } - } - - 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; - } - } - - /** - * Connects wires from a service to a target - * - * @param service the service - * @throws WiringException if an exception connecting the service wires is encountered - */ - private void handleService(Service service) throws WiringException { - CompositeComponent parent = service.getParent(); - assert parent != null; - for (ServiceBinding binding : service.getServiceBindings()) { - InboundWire inboundWire = binding.getInboundWire(); - OutboundWire outboundWire = binding.getOutboundWire(); - // For a composite reference only, since its outbound wire comes from its parent composite, - // the corresponding target would not lie in its parent but rather in its parent's parent - SCAObject target; - if (service.isSystem()) { - target = parent.getSystemChild(outboundWire.getTargetName().getPartName()); - } else { - target = parent.getChild(outboundWire.getTargetName().getPartName()); - } - // connect the outbound service wire to the target - connect(binding, outboundWire, target); - // NB: this connect must be done after the outbound service chain is connected to its target above - connect(inboundWire, outboundWire, true); - } - } - - private void handleReference(Reference reference) throws WiringException { - CompositeComponent parent = reference.getParent(); - assert parent != null; - for (ReferenceBinding binding : reference.getReferenceBindings()) { - InboundWire inboundWire = binding.getInboundWire(); - Map, InboundInvocationChain> inboundChains = inboundWire.getInvocationChains(); - for (InboundInvocationChain chain : inboundChains.values()) { - // add target invoker on inbound side - ServiceContract contract = inboundWire.getServiceContract(); - Operation operation = chain.getOperation(); - TargetInvoker invoker; - try { - invoker = binding.createTargetInvoker(contract, operation); - } catch (TargetInvokerCreationException e) { - String targetName = inboundWire.getContainer().getName(); - throw new WireConnectException("Error processing inbound wire", - null, - null, - targetName, - null, - e); - } - chain.setTargetInvoker(invoker); - chain.prepare(); - } - OutboundWire outboundWire = binding.getOutboundWire(); - // connect the reference's inbound and outbound wires - connect(inboundWire, outboundWire, true); - } - } - - private void handleComponent(Component component) throws WiringException { - CompositeComponent parent = component.getParent(); - assert parent != null; - // connect outbound wires for component references to their targets - for (List referenceWires : component.getOutboundWires().values()) { - for (OutboundWire outboundWire : referenceWires) { - try { - if (component.isSystem()) { - if (outboundWire.isAutowire()) { - autowire(outboundWire, parent); - - } else { - SCAObject target = parent.getSystemChild(outboundWire.getTargetName().getPartName()); - connect(component, outboundWire, target); - } - } else { - if (outboundWire.isAutowire()) { - autowire(outboundWire, parent); - } else { - if (outboundWire.getTargetName() == null) { - String referenceName = outboundWire.getReferenceName(); - throw new MissingWireTargetException("Target name was null", referenceName); - } - SCAObject target = parent.getChild(outboundWire.getTargetName().getPartName()); - connect(component, outboundWire, target); - } - } - } catch (WiringException e) { - e.addContextName(component.getName()); - e.addContextName(parent.getName()); - throw e; - } - } - } - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/builder/IllegalCallbackException.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/builder/IllegalCallbackException.java deleted file mode 100644 index 5ca843e198..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/builder/IllegalCallbackException.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.builder; - -import org.apache.tuscany.spi.builder.WiringException; -import org.apache.tuscany.spi.wire.InboundWire; -import org.apache.tuscany.spi.wire.OutboundWire; - -/** - * Denotes an illegal callback - * - * @version $Rev$ $Date$ - */ -public class IllegalCallbackException extends WiringException { - - public IllegalCallbackException(String message, - String identifier, - String sourceName, - String referenceName, - String targetName, - String serviceName) { - super(message, identifier); - setSourceName(sourceName); - setReferenceName(referenceName); - setTargetName(targetName); - setTargetServiceName(serviceName); - } - - - public IllegalCallbackException(String message, String identifier, OutboundWire source, InboundWire target) { - super(message, identifier); - setSourceName(source.getContainer().getName()); - setReferenceName(source.getReferenceName()); - setTargetName(target.getContainer().getName()); - setTargetServiceName(target.getServiceName()); - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/builder/IncompatibleInterfacesException.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/builder/IncompatibleInterfacesException.java deleted file mode 100644 index 4b94983c34..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/builder/IncompatibleInterfacesException.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.builder; - -import org.apache.tuscany.spi.builder.WiringException; -import org.apache.tuscany.spi.wire.InboundWire; -import org.apache.tuscany.spi.wire.OutboundWire; - -/** - * Denotes an attempt to wire incompatible interfaces - * - * @version $Rev$ $Date$ - */ -public class IncompatibleInterfacesException extends WiringException { - - - public IncompatibleInterfacesException(String message, - String sourceName, - String referenceName, - String targetName, - String targetServiceName) { - super(message); - setSourceName(sourceName); - setReferenceName(referenceName); - setTargetName(targetName); - setTargetServiceName(targetServiceName); - } - - public IncompatibleInterfacesException(String message, String sourceName, - String referenceName, - String targetName, - String serviceName, - Throwable cause) { - super(message, cause); - setSourceName(sourceName); - setReferenceName(referenceName); - setTargetName(targetName); - setTargetServiceName(serviceName); - } - - public IncompatibleInterfacesException(InboundWire source, OutboundWire target) { - super("Incompatible source and target interfaces"); - setTargetServiceName(source.getServiceName()); - if (source.getContainer() != null) { - setSourceName(source.getContainer().getName()); - } - setReferenceName(target.getReferenceName()); - if (target.getContainer() != null) { - setTargetName(target.getContainer().getName()); - } - } - - public IncompatibleInterfacesException(OutboundWire source, InboundWire target) { - super("Incompatible source and target interfaces"); - setTargetServiceName(target.getServiceName()); - if (source.getContainer() != null) { - setSourceName(source.getContainer().getName()); - } - setReferenceName(source.getReferenceName()); - if (target.getContainer() != null) { - setTargetName(target.getContainer().getName()); - } - } - - public IncompatibleInterfacesException(OutboundWire source, InboundWire target, Throwable throwable) { - super("Incompatible source and target interfaces", throwable); - setTargetServiceName(target.getServiceName()); - if (source.getContainer() != null) { - setSourceName(source.getContainer().getName()); - } - setReferenceName(source.getReferenceName()); - if (target.getContainer() != null) { - setTargetName(target.getContainer().getName()); - } - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/builder/InvalidTargetTypeException.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/builder/InvalidTargetTypeException.java deleted file mode 100644 index e96fb764a0..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/builder/InvalidTargetTypeException.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.builder; - -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, - String sourceName, - String referenceName, - String targetName, - String serviceName) { - super(message); - setSourceName(sourceName); - setReferenceName(referenceName); - setTargetName(targetName); - setTargetServiceName(serviceName); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/builder/NoCompatibleBindingsException.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/builder/NoCompatibleBindingsException.java deleted file mode 100644 index 620fbf6694..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/builder/NoCompatibleBindingsException.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 org.apache.tuscany.spi.builder.WiringException; - -/** - * @version $Rev$ $Date$ - */ -public class NoCompatibleBindingsException extends WiringException { - public NoCompatibleBindingsException(String sourceName, - String targetName, - String serviceName) { - super("No compatible bindings for source and target"); - setSourceName(sourceName); - setTargetName(targetName); - setTargetServiceName(serviceName); - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/builder/NoConversationalContractException.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/builder/NoConversationalContractException.java deleted file mode 100644 index 71eb9ebd26..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/builder/NoRegisteredBuilderException.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/builder/NoRegisteredBuilderException.java deleted file mode 100644 index 340a20f239..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/builder/TargetServiceNotFoundException.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/builder/TargetServiceNotFoundException.java deleted file mode 100644 index 873bf619b0..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/builder/TargetServiceNotFoundException.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.builder; - -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, - String sourceName, - String referenceName, - String targetName, - String serviceName) { - super(message); - setSourceName(sourceName); - setReferenceName(referenceName); - setTargetName(targetName); - setTargetServiceName(serviceName); - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/builder/WireConnectException.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/builder/WireConnectException.java deleted file mode 100644 index 89105d27b4..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/builder/WireConnectException.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.builder; - -import org.apache.tuscany.spi.builder.WiringException; -import org.apache.tuscany.spi.wire.InboundWire; -import org.apache.tuscany.spi.wire.OutboundWire; - -/** - * Denotes a general error connecting two wires - * - * @version $Rev$ $Date$ - */ -public class WireConnectException extends WiringException { - - public WireConnectException(String message) { - super(message); - } - - public WireConnectException(String message, - String sourceName, - String referenceName, - String targetName, - String serviceName, - Throwable throwable) { - super(message, throwable); - setSourceName(sourceName); - setReferenceName(referenceName); - setTargetName(targetName); - setTargetServiceName(serviceName); - } - - - public WireConnectException(String message, OutboundWire source, InboundWire target, Throwable throwable) { - super(message, throwable); - setSourceName(source.getContainer().getName()); - setReferenceName(source.getReferenceName()); - setTargetName(target.getContainer().getName()); - setTargetServiceName(target.getServiceName()); - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/builder/WirePostProcessorRegistryImpl.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/builder/WirePostProcessorRegistryImpl.java deleted file mode 100644 index 3bc617066a..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/builder/WirePostProcessorRegistryImpl.java +++ /dev/null @@ -1,57 +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.WirePostProcessor; -import org.apache.tuscany.spi.wire.WirePostProcessorRegistry; -import org.apache.tuscany.spi.wire.InboundWire; -import org.apache.tuscany.spi.wire.OutboundWire; - -/** - * The default implementation of a WirePostProcessor - * - * @version $Rev$ $Date$ - */ -public class WirePostProcessorRegistryImpl implements WirePostProcessorRegistry { - - private final List processors = new ArrayList(); - - public void process(OutboundWire source, InboundWire target) { - for (WirePostProcessor processor : processors) { - processor.process(source, target); - } - } - - public void process(InboundWire source, OutboundWire target) { - for (WirePostProcessor processor : processors) { - processor.process(source, target); - } - } - - public void register(WirePostProcessor processor) { - processors.add(processor); - } - - public void unregister(WirePostProcessor processor) { - processors.remove(processor); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/builder/WiringExceptionFormatter.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/builder/WiringExceptionFormatter.java deleted file mode 100644 index 16cf27048a..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/builder/WiringExceptionFormatter.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.builder; - -import java.io.PrintWriter; - -import org.osoa.sca.annotations.Destroy; -import org.osoa.sca.annotations.EagerInit; - -import org.apache.tuscany.spi.annotation.Autowire; -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(@Autowire 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.getSourceName() != null && e.getReferenceName() != null) { - writer.write("\nSource : " + e.getSourceName() + "/" + e.getReferenceName()); - } else if (e.getSourceName() != null) { - writer.write("\nSource : " + e.getSourceName()); - } - if (e.getTargetName() != null && e.getTargetServiceName() != null) { - writer.write("\nTarget : " + e.getTargetName() + "/" + e.getTargetServiceName()); - } else if (e.getTargetName() != null) { - writer.write("\nTarget : " + e.getTargetName()); - } - e.appendContextStack(writer).append("\n"); - return writer; - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/ScopeIdentifier.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/ScopeIdentifier.java deleted file mode 100644 index 35125b85ef..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/WorkContextImpl.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/WorkContextImpl.java deleted file mode 100644 index 8d2afc35d9..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/WorkContextImpl.java +++ /dev/null @@ -1,211 +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.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.CompositeComponent; -import org.apache.tuscany.spi.component.WorkContext; - -/** - * 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 REMOTE_CONTEXT = new Object(); - private static final Object CORRELATION_ID = new Object(); - private static final Object CALLBACK_ROUTING_CHAIN = new Object(); - private static final Object CURRENT_ATOMIC = new Object(); - private static final Object CURRENT_SERVICE_NAMES = 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 getCurrentCorrelationId() { - Map map = workContext.get(); - if (map == null) { - return null; - } - return map.get(CORRELATION_ID); - } - - public void setCurrentCorrelationId(Object correlationId) { - Map map = getWorkContextMap(); - map.put(CORRELATION_ID, correlationId); - } - - 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 getCurrentCallbackRoutingChain() { - Map map = workContext.get(); - if (map == null) { - return null; - } - return (LinkedList) map.get(CALLBACK_ROUTING_CHAIN); - } - - public void setCurrentCallbackRoutingChain(LinkedList callbackRoutingChain) { - Map map = getWorkContextMap(); - map.put(CALLBACK_ROUTING_CHAIN, callbackRoutingChain); - } - - public CompositeComponent getRemoteComponent() { - Map map = workContext.get(); - if (map == null) { - return null; - } - return (CompositeComponent) map.get(REMOTE_CONTEXT); - } - - - public void setRemoteComponent(CompositeComponent component) { - Map map = getWorkContextMap(); - map.put(REMOTE_CONTEXT, component); - } - - 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/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/event/AbstractEvent.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/event/AbstractEvent.java deleted file mode 100644 index 6d026ca08c..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/event/AbstractRequestEvent.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/event/AbstractRequestEvent.java deleted file mode 100644 index 762b917600..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/event/CompositeEvent.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/event/CompositeEvent.java deleted file mode 100644 index ce058404da..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/event/CompositeEvent.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.event; - -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.event.Event; - -/** - * Implemented by runtime events associated with a composite, e.g. lifecycle events - * - * @version $$Rev$$ $$Date$$ - */ -public interface CompositeEvent extends Event { - - CompositeComponent getComposite(); - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/event/CompositeStart.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/event/CompositeStart.java deleted file mode 100644 index fba36feaf6..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/event/CompositeStart.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 org.apache.tuscany.spi.component.CompositeComponent; - -/** - * Propagated when a composite starts - * - * @version $$Rev$$ $$Date$$ - */ -public class CompositeStart extends AbstractEvent implements CompositeEvent { - - private CompositeComponent component; - - /** - * Creates a composite stop event - * - * @param source the source of the event - * @param component the composite component associated the composite being stopped - */ - public CompositeStart(Object source, CompositeComponent component) { - super(source); - this.component = component; - } - - public CompositeComponent getComposite() { - return component; - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/event/CompositeStop.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/event/CompositeStop.java deleted file mode 100644 index 6b3e37f619..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/event/CompositeStop.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 org.apache.tuscany.spi.component.CompositeComponent; - -/** - * Propagated when a composite stops - * - * @version $$Rev$$ $$Date$$ - */ -public class CompositeStop extends AbstractEvent implements CompositeEvent { - - private CompositeComponent component; - - /** - * Creates a composite stop event - * - * @param source the source of the event - * @param component the composite component associated the composite being stopped - */ - public CompositeStop(Object source, CompositeComponent component) { - super(source); - this.component = component; - } - - public CompositeComponent getComposite() { - return component; - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/event/ConversationEnd.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/event/ConversationEnd.java deleted file mode 100644 index 4a51d970c3..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/event/ConversationStart.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/event/ConversationStart.java deleted file mode 100644 index 5725369bf6..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/event/ConversationalEvent.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/event/ConversationalEvent.java deleted file mode 100644 index a75086e745..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/event/HttpRequestEnded.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/event/HttpRequestEnded.java deleted file mode 100644 index 01bd769031..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/event/HttpRequestStart.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/event/HttpRequestStart.java deleted file mode 100644 index 9d0ff80dd7..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/event/HttpSessionEnd.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/event/HttpSessionEnd.java deleted file mode 100644 index 7f2bebe94a..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/event/HttpSessionEvent.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/event/HttpSessionEvent.java deleted file mode 100644 index ed245d0930..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/event/HttpSessionStart.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/event/HttpSessionStart.java deleted file mode 100644 index 7f9c0fadea..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/event/RequestEnd.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/event/RequestEnd.java deleted file mode 100644 index 25856e86f8..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/event/RequestEvent.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/event/RequestEvent.java deleted file mode 100644 index 9a6d767236..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/event/RequestStart.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/event/RequestStart.java deleted file mode 100644 index 466f52551a..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/AbstractScopeContainer.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/AbstractScopeContainer.java deleted file mode 100644 index cde61eaa5a..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/AbstractScopeContainer.java +++ /dev/null @@ -1,158 +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.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.CopyOnWriteArrayList; - -import org.apache.tuscany.spi.AbstractLifecycle; -import org.apache.tuscany.spi.component.AtomicComponent; -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.TargetNotFoundException; -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.EventFilter; -import org.apache.tuscany.spi.event.RuntimeEventListener; -import org.apache.tuscany.spi.event.TrueFilter; - -/** - * Implements functionality common to scope contexts. - * - * @version $Rev$ $Date$ - */ -public abstract class AbstractScopeContainer extends AbstractLifecycle implements ScopeContainer { - private static final EventFilter TRUE_FILTER = new TrueFilter(); - - protected WorkContext workContext; - protected ScopeContainerMonitor monitor; - private Map> listeners; - - public AbstractScopeContainer(WorkContext workContext, ScopeContainerMonitor monitor) { - this.workContext = workContext; - this.monitor = monitor; - } - - public void addListener(RuntimeEventListener listener) { - addListener(TRUE_FILTER, listener); - } - - public void removeListener(RuntimeEventListener listener) { - assert listener != null; - synchronized (getListeners()) { - for (List currentList : getListeners().values()) { - for (RuntimeEventListener current : currentList) { - if (current == listener) { - currentList.remove(current); - return; - } - } - } - } - } - - public void addListener(EventFilter filter, RuntimeEventListener listener) { - assert listener != null; - synchronized (getListeners()) { - List list = getListeners().get(filter); - if (list == null) { - list = new CopyOnWriteArrayList(); - listeners.put(filter, list); - } - list.add(listener); - } - } - - public void publish(Event event) { - assert event != null; - for (Map.Entry> entry : getListeners().entrySet()) { - if (entry.getKey().match(event)) { - for (RuntimeEventListener listener : entry.getValue()) { - listener.onEvent(event); - } - } - } - } - - public Object getInstance(AtomicComponent component) throws TargetResolutionException { - InstanceWrapper ctx = getInstanceWrapper(component, true); - if (ctx != null) { - if (!ctx.isStarted()) { - ctx.start(); - } - return ctx.getInstance(); - } - return null; - } - - public Object getAssociatedInstance(AtomicComponent component) throws TargetResolutionException { - InstanceWrapper ctx = getInstanceWrapper(component, false); - if (ctx != null) { - if (!ctx.isStarted()) { - ctx.start(); - } - return ctx.getInstance(); - } - throw new TargetNotFoundException(component.getName()); - } - - public void persistNew(AtomicComponent component, String id, Object instance, long expiration) - throws PersistenceException { - throw new UnsupportedOperationException("Scope does not support persistence"); - - } - - public void persist(AtomicComponent component, String id, Object instance, long expiration) - throws PersistenceException { - throw new UnsupportedOperationException("Scope does not support persistence"); - } - - public void remove(AtomicComponent component) throws PersistenceException { - throw new UnsupportedOperationException("Scope does not support persistence"); - } - - protected Map> getListeners() { - if (listeners == null) { - listeners = new ConcurrentHashMap>(); - } - return listeners; - } - - protected void checkInit() { - if (getLifecycleState() != RUNNING) { - throw new IllegalStateException("Scope container not running [" + getLifecycleState() + "]"); - } - } - - protected WorkContext getWorkContext() { - return workContext; - } - - public String toString() { - return "In state [" + super.toString() + ']'; - } - - protected abstract InstanceWrapper getInstanceWrapper(AtomicComponent component, boolean create) - throws TargetResolutionException; -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/CompositeScopeContainer.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/CompositeScopeContainer.java deleted file mode 100644 index 21ff792282..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/CompositeScopeContainer.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 java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; -import java.util.ListIterator; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -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.TargetInitializationException; -import org.apache.tuscany.spi.component.TargetResolutionException; -import org.apache.tuscany.spi.event.Event; -import org.apache.tuscany.spi.model.Scope; - -import org.apache.tuscany.core.component.event.CompositeStart; -import org.apache.tuscany.core.component.event.CompositeStop; - -/** - * A scope context which manages atomic component instances keyed by composite - * - * @version $Rev$ $Date$ - */ -public class CompositeScopeContainer extends AbstractScopeContainer { - private static final InstanceWrapper EMPTY = new EmptyWrapper(); - private static final ComponentInitComparator COMPARATOR = new ComponentInitComparator(); - - private final Map instanceWrappers; - // the queue of instanceWrappers to destroy, in the order that their instances were created - private final List destroyQueue; - - public CompositeScopeContainer(ScopeContainerMonitor monitor) { - super(null, monitor); - instanceWrappers = new ConcurrentHashMap(); - destroyQueue = new ArrayList(); - } - - public Scope getScope() { - return Scope.COMPOSITE; - } - - public void onEvent(Event event) { - checkInit(); - if (event instanceof CompositeStart) { - try { - eagerInitComponents(); - } catch (ObjectCreationException e) { - monitor.eagerInitializationError(e); - } catch (TargetResolutionException e) { - monitor.eagerInitializationError(e); - } - lifecycleState = RUNNING; - } else if (event instanceof CompositeStop) { - shutdownContexts(); - } - } - - 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() { - checkInit(); - instanceWrappers.clear(); - synchronized (destroyQueue) { - destroyQueue.clear(); - } - lifecycleState = STOPPED; - } - - /** - * Notifies instanceWrappers of a shutdown in reverse order to which they were started - */ - private void shutdownContexts() { - if (destroyQueue.size() == 0) { - return; - } - synchronized (destroyQueue) { - // shutdown destroyable instances in reverse instantiation order - ListIterator iter = destroyQueue.listIterator(destroyQueue.size()); - while (iter.hasPrevious()) { - try { - iter.previous().stop(); - } catch (TargetDestructionException e) { - monitor.destructionError(e); - } - } - destroyQueue.clear(); - } - } - - public void register(AtomicComponent component) { - checkInit(); - instanceWrappers.put(component, EMPTY); - } - - protected InstanceWrapper getInstanceWrapper(AtomicComponent component, boolean create) - throws TargetResolutionException { - checkInit(); - InstanceWrapper ctx = instanceWrappers.get(component); - assert ctx != null; - if (ctx == EMPTY && !create) { - return null; - } - if (ctx == EMPTY) { - ctx = new InstanceWrapperImpl(component, component.createInstance()); - ctx.start(); - instanceWrappers.put(component, ctx); - synchronized (destroyQueue) { - destroyQueue.add(ctx); - } - } - return ctx; - } - - private void eagerInitComponents() throws ObjectCreationException, TargetResolutionException { - List componentList = new ArrayList(instanceWrappers.keySet()); - Collections.sort(componentList, COMPARATOR); - // start each group - for (AtomicComponent component : componentList) { - if (component.getInitLevel() <= 0) { - // Don't eagerly init - continue; - } - // the instance could have been created from a depth-first traversal - InstanceWrapper ctx = instanceWrappers.get(component); - if (ctx == EMPTY) { - try { - ctx = new InstanceWrapperImpl(component, component.createInstance()); - } catch (ObjectCreationException e) { - e.addContextName(component.getName()); - throw e; - } - ctx.start(); - instanceWrappers.put(component, ctx); - destroyQueue.add(ctx); - } - } - } - - private static class ComponentInitComparator implements Comparator { - public int compare(AtomicComponent o1, AtomicComponent o2) { - return o1.getInitLevel() - o2.getInitLevel(); - } - } - - private static class EmptyWrapper implements InstanceWrapper { - public Object getInstance() { - return null; - } - - public boolean isStarted() { - return true; - } - - public void start() throws TargetInitializationException { - - } - - public void stop() throws TargetDestructionException { - - } - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/CompositeScopeObjectFactory.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/CompositeScopeObjectFactory.java deleted file mode 100644 index a761f05d4b..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/CompositeScopeObjectFactory.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.component.scope; - -import org.osoa.sca.annotations.EagerInit; - -import org.apache.tuscany.spi.ObjectCreationException; -import org.apache.tuscany.spi.ObjectFactory; -import org.apache.tuscany.spi.annotation.Autowire; -import org.apache.tuscany.spi.component.ScopeContainerMonitor; -import org.apache.tuscany.spi.component.ScopeRegistry; -import org.apache.tuscany.spi.model.Scope; - -import org.apache.tuscany.api.annotation.Monitor; - -/** - * Creates a new composite scope context - * - * @version $$Rev$$ $$Date$$ - */ -@EagerInit -public class CompositeScopeObjectFactory implements ObjectFactory { - private ScopeContainerMonitor monitor; - - public CompositeScopeObjectFactory(@Autowire ScopeRegistry registry, - @Monitor ScopeContainerMonitor monitor) { - registry.registerFactory(Scope.COMPOSITE, this); - this.monitor = monitor; - } - - public CompositeScopeContainer getInstance() throws ObjectCreationException { - return new CompositeScopeContainer(monitor); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainer.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainer.java deleted file mode 100644 index 1a77f3ecb3..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainer.java +++ /dev/null @@ -1,217 +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.component.AtomicComponent; -import org.apache.tuscany.spi.component.PersistenceException; -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.TargetDestructionException; -import org.apache.tuscany.spi.component.TargetNotFoundException; -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 Store nonDurableStore; - private Map components; - - public ConversationalScopeContainer(Store store, WorkContext workContext, final ScopeContainerMonitor monitor) { - super(workContext, monitor); - this.nonDurableStore = store; - if (store != null) { - store.addListener(new ExpirationListener(monitor)); - } - components = new ConcurrentHashMap(); - } - - public Scope getScope() { - return Scope.CONVERSATION; - } - - 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) { - components.put(component, component); - component.addListener(this); - } - - @Override - public Object getInstance(AtomicComponent component) throws TargetResolutionException { - String conversationId = getConversationId(); - try { - workContext.setCurrentAtomicComponent(component); - Object instance = nonDurableStore.readRecord(component, conversationId); - if (instance != null) { - if (component.getMaxIdleTime() > 0) { - // update expiration - long expire = System.currentTimeMillis() + component.getMaxIdleTime(); - nonDurableStore.updateRecord(component, conversationId, instance, expire); - } - } else { - instance = component.createInstance(); - long expire = calculateExpiration(component); - nonDurableStore.insertRecord(component, conversationId, instance, expire); - component.init(instance); - } - return instance; - } 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); - } - } - - public Object getAssociatedInstance(AtomicComponent component) throws TargetResolutionException { - String conversationId = getConversationId(); - try { - workContext.setCurrentAtomicComponent(component); - Object instance = nonDurableStore.readRecord(component, conversationId); - if (instance != null) { - if (component.getMaxIdleTime() > 0) { - // update expiration - long expire = System.currentTimeMillis() + component.getMaxIdleTime(); - nonDurableStore.updateRecord(component, conversationId, instance, expire); - } - return instance; - } else { - throw new TargetNotFoundException(component.getName()); - } - } 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); - } - } - - 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); - 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) { - throw new UnsupportedOperationException(); - } - - /** - * Returns the conversation id associated with the current invocation context - */ - 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; - SCAObject object = expiration.getOwner(); - assert object instanceof AtomicComponent; - AtomicComponent owner = (AtomicComponent) object; - try { - owner.destroy(expiration.getInstance()); - } catch (TargetDestructionException e) { - monitor.destructionError(e); - } - } - } - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/ConversationalScopeObjectFactory.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/ConversationalScopeObjectFactory.java deleted file mode 100644 index 32dfaed8d9..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/ConversationalScopeObjectFactory.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.component.scope; - -import org.osoa.sca.annotations.EagerInit; - -import org.apache.tuscany.spi.ObjectCreationException; -import org.apache.tuscany.spi.ObjectFactory; -import org.apache.tuscany.spi.annotation.Autowire; -import org.apache.tuscany.spi.component.ScopeContainerMonitor; -import org.apache.tuscany.spi.component.ScopeRegistry; -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.api.annotation.Monitor; - -/** - * Creates a new Session Scope context - * - * @version $$Rev: 450456 $$ $$Date: 2006-09-27 10:28:36 -0400 (Wed, 27 Sep 2006) $$ - */ -@EagerInit -public class ConversationalScopeObjectFactory implements ObjectFactory { - private WorkContext context; - private Store store; - private ScopeContainerMonitor monitor; - - public ConversationalScopeObjectFactory(@Autowire ScopeRegistry registry, - @Autowire WorkContext context, - @Autowire Store store, - @Monitor ScopeContainerMonitor monitor) { - registry.registerFactory(Scope.CONVERSATION, this); - this.context = context; - this.store = store; - this.monitor = monitor; - } - - public ConversationalScopeContainer getInstance() throws ObjectCreationException { - return new ConversationalScopeContainer(store, context, monitor); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/HttpSessionScopeContainer.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/HttpSessionScopeContainer.java deleted file mode 100644 index 83c79b2367..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/HttpSessionScopeContainer.java +++ /dev/null @@ -1,135 +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.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 Map> contexts; - private final Map> destroyQueues; - - public HttpSessionScopeContainer(WorkContext workContext, ScopeContainerMonitor monitor) { - super(workContext, monitor); - contexts = new ConcurrentHashMap>(); - destroyQueues = new ConcurrentHashMap>(); - } - - public Scope getScope() { - return Scope.SESSION; - } - - 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) { - contexts.put(component, new ConcurrentHashMap()); - component.addListener(this); - } - - 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 = new InstanceWrapperImpl(component, component.createInstance()); - 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/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/HttpSessionScopeObjectFactory.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/HttpSessionScopeObjectFactory.java deleted file mode 100644 index 14713f9144..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/HttpSessionScopeObjectFactory.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.component.scope; - -import org.osoa.sca.annotations.EagerInit; - -import org.apache.tuscany.spi.ObjectCreationException; -import org.apache.tuscany.spi.ObjectFactory; -import org.apache.tuscany.spi.annotation.Autowire; -import org.apache.tuscany.spi.component.ScopeContainerMonitor; -import org.apache.tuscany.spi.component.ScopeRegistry; -import org.apache.tuscany.spi.component.WorkContext; -import org.apache.tuscany.spi.model.Scope; - -import org.apache.tuscany.api.annotation.Monitor; - -/** - * Creates a new HTTP session scope context - * - * @version $$Rev$$ $$Date$$ - */ -@EagerInit -public class HttpSessionScopeObjectFactory implements ObjectFactory { - private WorkContext context; - private ScopeContainerMonitor monitor; - - public HttpSessionScopeObjectFactory(@Autowire ScopeRegistry registry, - @Autowire WorkContext context, - @Monitor ScopeContainerMonitor monitor) { - registry.registerFactory(Scope.SESSION, this); - this.context = context; - this.monitor = monitor; - } - - public HttpSessionScopeContainer getInstance() throws ObjectCreationException { - return new HttpSessionScopeContainer(context, monitor); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/InstanceWrapper.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/InstanceWrapper.java deleted file mode 100644 index 50f4a31128..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/InstanceWrapper.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.component.scope; - -import org.apache.tuscany.spi.component.TargetDestructionException; -import org.apache.tuscany.spi.component.TargetInitializationException; - -/** - * Provides lifecycle management for an implementation instance associated with an {@link - * org.apache.tuscany.spi.component.AtomicComponent} for use by the atomic component's associated {@link - * org.apache.tuscany.spi.component.ScopeContainer} - * - * @version $Rev$ $Date$ - */ -public interface InstanceWrapper { - - Object getInstance(); - - boolean isStarted(); - - void start() throws TargetInitializationException; - - void stop() throws TargetDestructionException; - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/InstanceWrapperImpl.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/InstanceWrapperImpl.java deleted file mode 100644 index c4648d1e7b..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/InstanceWrapperImpl.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.component.scope; - -import org.apache.tuscany.spi.component.AtomicComponent; -import org.apache.tuscany.spi.component.TargetDestructionException; -import org.apache.tuscany.spi.component.TargetInitializationException; - -/** - * Default implementation of an InstanceWrapper - * - * @version $$Rev$$ $$Date$$ - */ -public class InstanceWrapperImpl implements InstanceWrapper { - private Object instance; - private AtomicComponent component; - private boolean started; - - public InstanceWrapperImpl(AtomicComponent component, Object instance) { - assert component != null; - assert instance != null; - this.component = component; - this.instance = instance; - } - - public boolean isStarted() { - return started; - } - - public Object getInstance() { - if (!started) { - throw new IllegalStateException("Instance not started"); - } - return instance; - } - - public void start() throws TargetInitializationException { - component.init(instance); - started = true; - } - - public void stop() throws TargetDestructionException { - component.destroy(instance); - started = false; - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/RequestScopeContainer.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/RequestScopeContainer.java deleted file mode 100644 index 22beaae740..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/RequestScopeContainer.java +++ /dev/null @@ -1,126 +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.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(WorkContext workContext, ScopeContainerMonitor monitor) { - super(workContext, monitor); - contexts = new ConcurrentHashMap>(); - destroyQueues = new ConcurrentHashMap>(); - } - - public Scope getScope() { - return Scope.REQUEST; - } - - 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) { - contexts.put(component, new ConcurrentHashMap()); - } - - 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 = new InstanceWrapperImpl(component, component.createInstance()); - 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/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/RequestScopeObjectFactory.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/RequestScopeObjectFactory.java deleted file mode 100644 index 0377bcd548..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/RequestScopeObjectFactory.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.scope; - -import org.apache.tuscany.spi.ObjectCreationException; -import org.apache.tuscany.spi.ObjectFactory; -import org.apache.tuscany.spi.annotation.Autowire; -import org.apache.tuscany.spi.component.ScopeContainerMonitor; -import org.apache.tuscany.spi.component.WorkContext; - -import org.apache.tuscany.api.annotation.Monitor; - -/** - * Creates a new request scope context - * - * @version $$Rev$$ $$Date$$ - */ -public class RequestScopeObjectFactory implements ObjectFactory { - private WorkContext context; - private ScopeContainerMonitor monitor; - - - public RequestScopeObjectFactory(@Autowire WorkContext context, @Monitor ScopeContainerMonitor monitor) { - this.context = context; - this.monitor = monitor; - } - - public RequestScopeContainer getInstance() throws ObjectCreationException { - return new RequestScopeContainer(context, monitor); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/ScopeRegistryImpl.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/ScopeRegistryImpl.java deleted file mode 100644 index da338dd0ef..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/ScopeRegistryImpl.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.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 ScopeContainer getScopeContainer(Scope scope) { - assert Scope.COMPOSITE != scope; - ScopeContainer container = scopeCache.get(scope); - if (container == null) { - ObjectFactory factory = factoryCache.get(scope); - if (factory != null) { - container = factory.getInstance(); - container.start(); - scopeCache.put(scope, container); - } - } - return container; - } - - public void registerFactory(Scope scope, ObjectFactory factory) { - factoryCache.put(scope, factory); - } - - public void deregisterFactory(Scope scope) { - factoryCache.remove(scope); - } - - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/StatelessScopeContainer.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/StatelessScopeContainer.java deleted file mode 100644 index cbd47b6cdd..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/StatelessScopeContainer.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.component.scope; - -import org.apache.tuscany.spi.component.AtomicComponent; -import org.apache.tuscany.spi.component.ScopeContainerMonitor; -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.model.Scope; - -/** - * A scope context which manages stateless atomic component instances in a non-pooled fashion - * - * @version $Rev$ $Date$ - */ -public class StatelessScopeContainer extends AbstractScopeContainer { - - public StatelessScopeContainer(WorkContext workContext, ScopeContainerMonitor monitor) { - super(workContext, monitor); - } - - public Scope getScope() { - return Scope.STATELESS; - } - - 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() { - if (lifecycleState != RUNNING) { - throw new IllegalStateException("Scope in wrong state [" + lifecycleState + "]"); - } - lifecycleState = STOPPED; - } - - public void onEvent(Event event) { - } - - public void register(AtomicComponent component) { - checkInit(); - } - - protected InstanceWrapper getInstanceWrapper(AtomicComponent component, boolean create) - throws TargetResolutionException { - // there never is a previously associated instance, return null - if (!create) { - return null; - } - InstanceWrapper ctx = new InstanceWrapperImpl(component, component.createInstance()); - ctx.start(); - return ctx; - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/StatelessScopeObjectFactory.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/StatelessScopeObjectFactory.java deleted file mode 100644 index 8e05510723..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/StatelessScopeObjectFactory.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.component.scope; - -import org.osoa.sca.annotations.EagerInit; - -import org.apache.tuscany.spi.ObjectCreationException; -import org.apache.tuscany.spi.ObjectFactory; -import org.apache.tuscany.spi.annotation.Autowire; -import org.apache.tuscany.spi.component.ScopeContainerMonitor; -import org.apache.tuscany.spi.component.ScopeRegistry; -import org.apache.tuscany.spi.component.WorkContext; -import org.apache.tuscany.spi.model.Scope; - -import org.apache.tuscany.api.annotation.Monitor; - -/** - * Creates a new stateless scope context - * - * @version $$Rev$$ $$Date$$ - */ -@EagerInit -public class StatelessScopeObjectFactory implements ObjectFactory { - private WorkContext context; - private ScopeContainerMonitor monitor; - - public StatelessScopeObjectFactory(@Autowire ScopeRegistry registry, - @Autowire WorkContext context, - @Monitor ScopeContainerMonitor monitor) { - registry.registerFactory(Scope.STATELESS, this); - this.context = context; - this.monitor = monitor; - } - - public StatelessScopeContainer getInstance() throws ObjectCreationException { - return new StatelessScopeContainer(context, monitor); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/DataBindingInteceptor.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/DataBindingInteceptor.java deleted file mode 100644 index dcc772d01c..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/DataBindingInteceptor.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.databinding.impl; - -import java.util.HashMap; -import java.util.Map; - -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.databinding.Mediator; -import org.apache.tuscany.spi.model.DataType; -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.Wire; - -/** - * An interceptor to transform data accross databindings on the wire - * - * @version $Rev$ $Date$ - */ -public class DataBindingInteceptor implements Interceptor { - private Interceptor next; - - private CompositeComponent compositeComponent; - - private Operation sourceOperation; - - private Operation targetOperation; - - private Mediator mediator; - - public DataBindingInteceptor(Wire sourceWire, Operation sourceOperation, Operation targetOperation) { - super(); - // this.sourceWire = sourceWire; - this.sourceOperation = sourceOperation; - // this.targetWire = targetWire; - this.targetOperation = targetOperation; - this.compositeComponent = sourceWire.getContainer().getParent(); - } - - /** - * @see org.apache.tuscany.spi.wire.Interceptor#getNext() - */ - public Interceptor getNext() { - return next; - } - - /** - * @see org.apache.tuscany.spi.wire.Interceptor#invoke(org.apache.tuscany.spi.wire.Message) - */ - public Message invoke(Message msg) { - Object input = transform(msg.getBody(), sourceOperation.getInputType(), targetOperation.getInputType()); - msg.setBody(input); - Message resultMsg = next.invoke(msg); - Object result = resultMsg.getBody(); - // FIXME: How to deal with faults? - if (resultMsg.isFault()) { - // We need to figure out what fault type it is and then transform it back the source fault type - // throw new InvocationRuntimeException((Throwable) result); - return resultMsg; - } else { - if (sourceOperation.isNonBlocking()) { - // Not to reset the message body - return resultMsg; - } - // FIXME: Should we fix the Operation model so that getOutputType returns DataType>? - DataType targetType = - new DataType("idl:output", Object.class, targetOperation.getOutputType()); - - targetType.setOperation(targetOperation.getOutputType().getOperation()); - DataType sourceType = - new DataType("idl:output", Object.class, sourceOperation.getOutputType()); - sourceType.setOperation(sourceOperation.getOutputType().getOperation()); - - Object newResult = transform(result, targetType, sourceType); - if (newResult != result) { - resultMsg.setBody(newResult); - } - } - return resultMsg; - } - - private Object transform(Object source, DataType sourceType, DataType targetType) { - if (sourceType == targetType || (sourceType != null && sourceType.equals(targetType))) { - return source; - } - Map, Object> metadata = new HashMap, Object>(); - metadata.put(CompositeComponent.class, compositeComponent); - return mediator.mediate(source, sourceType, targetType, metadata); - } - - /** - * @see org.apache.tuscany.spi.wire.Interceptor#isOptimizable() - */ - public boolean isOptimizable() { - return false; - } - - /** - * @see org.apache.tuscany.spi.wire.Interceptor#setNext(org.apache.tuscany.spi.wire.Interceptor) - */ - public void setNext(Interceptor next) { - this.next = next; - } - - /** - * @param mediator the mediator to set - */ - public void setMediator(Mediator mediator) { - this.mediator = mediator; - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/DataBindingJavaInterfaceProcessor.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/DataBindingJavaInterfaceProcessor.java deleted file mode 100644 index 046578ae66..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/DataBindingJavaInterfaceProcessor.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.databinding.impl; - -import java.lang.reflect.Method; -import java.lang.reflect.Type; -import java.math.BigDecimal; -import java.math.BigInteger; -import java.util.Arrays; -import java.util.Calendar; -import java.util.Date; -import java.util.GregorianCalendar; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; -import javax.xml.datatype.Duration; -import javax.xml.datatype.XMLGregorianCalendar; - -import org.apache.tuscany.spi.idl.InvalidServiceContractException; -import org.apache.tuscany.spi.idl.java.JavaInterfaceProcessorExtension; -import org.apache.tuscany.spi.idl.java.JavaServiceContract; -import org.apache.tuscany.spi.model.Operation; - -import org.apache.tuscany.api.annotation.DataContext; -import org.apache.tuscany.api.annotation.DataType; - -/** - * The databinding annotation processor for java interfaces - * - * @version $Rev$ $Date$ - */ -public class DataBindingJavaInterfaceProcessor extends JavaInterfaceProcessorExtension { - - private static final String SIMPLE_JAVA_OBJECTS = "java.lang.Object"; - - private static final Class[] SIMPLE_JAVA_TYPES = - {Byte.class, Character.class, Short.class, Integer.class, Long.class, Float.class, Double.class, Date.class, - Calendar.class, GregorianCalendar.class, Duration.class, XMLGregorianCalendar.class, BigInteger.class, - BigDecimal.class}; - - private static final Set SIMPLE_TYPE_SET = new HashSet(Arrays.asList(SIMPLE_JAVA_TYPES)); - - public void visitInterface(Class clazz, Class callbackClass, JavaServiceContract contract) - throws InvalidServiceContractException { - Map> operations = contract.getOperations(); - processInterface(clazz, contract, operations); - if (callbackClass != null) { - Map> callbackOperations = contract.getCallbackOperations(); - processInterface(callbackClass, contract, callbackOperations); - } - } - - private void processInterface(Class clazz, - JavaServiceContract contract, - Map> operations) { - DataType interfaceDataType = clazz.getAnnotation(DataType.class); - if (interfaceDataType != null) { - contract.setDataBinding(interfaceDataType.name()); - // FIXME: [rfeng] Keep data context as metadata? - for (DataContext c : interfaceDataType.context()) { - contract.setMetaData(c.key(), c.value()); - } - } - for (Method method : clazz.getMethods()) { - Operation operation = operations.get(method.getName()); - DataType operationDataType = method.getAnnotation(DataType.class); - - if (operationDataType != null) { - operation.setDataBinding(operationDataType.name()); - // FIXME: [rfeng] Keep data context as metadata? - for (DataContext c : operationDataType.context()) { - operation.setMetaData(c.key(), c.value()); - } - } - - String dataBinding = operation.getDataBinding(); - - // FIXME: We need a better way to identify simple java types - for (org.apache.tuscany.spi.model.DataType d : operation.getInputType().getLogical()) { - adjustSimpleType(d, dataBinding); - } - if (operation.getOutputType() != null) { - adjustSimpleType(operation.getOutputType(), dataBinding); - } - for (org.apache.tuscany.spi.model.DataType d : operation.getFaultTypes()) { - adjustSimpleType(d, dataBinding); - } - } - } - - private void adjustSimpleType(org.apache.tuscany.spi.model.DataType dataType, String dataBinding) { - Type type = dataType.getPhysical(); - if (!(type instanceof Class)) { - return; - } - Class cls = (Class) dataType.getPhysical(); - if (cls.isPrimitive() || SIMPLE_TYPE_SET.contains(cls)) { - dataType.setDataBinding(SIMPLE_JAVA_OBJECTS); - } else if (cls == String.class && (dataBinding == null || !dataBinding.equals(String.class.getName()))) { - // Identify the String as a simple type - dataType.setDataBinding(SIMPLE_JAVA_OBJECTS); - } - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/DataBindingRegistryImpl.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/DataBindingRegistryImpl.java deleted file mode 100644 index 4fe7a4efa7..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/DataBindingRegistryImpl.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.databinding.impl; - -import java.util.HashMap; -import java.util.Map; - -import org.osoa.sca.annotations.EagerInit; - -import org.apache.tuscany.spi.databinding.DataBinding; -import org.apache.tuscany.spi.databinding.DataBindingRegistry; -import org.apache.tuscany.spi.model.DataType; - -/** - * The default implementation of a data binding registry - * - * @version $Rev$ $Date$ - */ -@EagerInit -public class DataBindingRegistryImpl implements DataBindingRegistry { - private final Map bindings = new HashMap(); - - public DataBinding getDataBinding(String id) { - if (id == null) { - return null; - } - return bindings.get(id.toLowerCase()); - } - - public void register(DataBinding dataBinding) { - bindings.put(dataBinding.getName().toLowerCase(), dataBinding); - } - - public DataBinding unregister(String id) { - if (id == null) { - return null; - } - return bindings.remove(id.toLowerCase()); - } - - public DataType introspectType(Class javaType) { - DataType dataType; - for (DataBinding binding : bindings.values()) { - dataType = binding.introspect(javaType); - if (dataType != null) { - return dataType; - } - } - return null; - } - - public DataType introspectType(Object value) { - DataType dataType; - for (DataBinding binding : bindings.values()) { - dataType = binding.introspect(value); - if (dataType != null) { - return dataType; - } - } - return null; - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/DataBindingWirePostProcessor.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/DataBindingWirePostProcessor.java deleted file mode 100644 index e687a161eb..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/DataBindingWirePostProcessor.java +++ /dev/null @@ -1,157 +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.databinding.impl; - -import java.util.Map; -import java.util.Set; - -import org.apache.tuscany.spi.annotation.Autowire; -import org.apache.tuscany.spi.component.ReferenceBinding; -import org.apache.tuscany.spi.component.SCAObject; -import org.apache.tuscany.spi.databinding.Mediator; -import org.apache.tuscany.spi.model.Operation; -import org.apache.tuscany.spi.wire.InboundInvocationChain; -import org.apache.tuscany.spi.wire.InboundWire; -import org.apache.tuscany.spi.wire.Interceptor; -import org.apache.tuscany.spi.wire.OutboundInvocationChain; -import org.apache.tuscany.spi.wire.OutboundWire; -import org.apache.tuscany.spi.wire.WirePostProcessorExtension; -import org.osoa.sca.annotations.Constructor; - -/** - * This processor is responsible to add an interceptor to invocation chain if the source and target operations have - * different databinding requirements - * - * @version $Rev$ $Date$ - */ -public class DataBindingWirePostProcessor extends WirePostProcessorExtension { - private Mediator mediator; - - @Constructor({"mediator"}) - public DataBindingWirePostProcessor(@Autowire Mediator mediator) { - super(); - this.mediator = mediator; - } - - public void process(OutboundWire source, InboundWire target) { - Map, OutboundInvocationChain> chains = source.getInvocationChains(); - for (Map.Entry, OutboundInvocationChain> entry : chains.entrySet()) { - Operation sourceOperation = entry.getKey(); - Operation targetOperation = - getTargetOperation(target.getInvocationChains().keySet(), sourceOperation.getName()); - String sourceDataBinding = sourceOperation.getDataBinding(); - String targetDataBinding = targetOperation.getDataBinding(); - if (sourceDataBinding == null && targetDataBinding == null) { - continue; - } - if (sourceDataBinding == null || targetDataBinding == null - || !sourceDataBinding.equals(targetDataBinding)) { - // Add the interceptor to the source side because multiple - // references can be wired - // to the same service - DataBindingInteceptor interceptor = - new DataBindingInteceptor(source, sourceOperation, targetOperation); - interceptor.setMediator(mediator); - entry.getValue().addInterceptor(0, interceptor); - } - } - - // Check if there's a callback - Map callbackOperations = source.getServiceContract().getCallbackOperations(); - if (callbackOperations == null || callbackOperations.isEmpty()) { - return; - } - Object targetAddress = source.getContainer().getName(); - Map, OutboundInvocationChain> callbackChains = - target.getSourceCallbackInvocationChains(targetAddress); - if (callbackChains == null) { - // callback chains could be null - return; - } - for (Map.Entry, OutboundInvocationChain> entry : callbackChains.entrySet()) { - Operation sourceOperation = entry.getKey(); - Operation targetOperation = - getTargetOperation(source.getTargetCallbackInvocationChains().keySet(), sourceOperation - .getName()); - String sourceDataBinding = sourceOperation.getDataBinding(); - String targetDataBinding = targetOperation.getDataBinding(); - if (sourceDataBinding == null && targetDataBinding == null) { - continue; - } - if (sourceDataBinding == null || targetDataBinding == null - || !sourceDataBinding.equals(targetDataBinding)) { - // Add the interceptor to the source side because multiple - // references can be wired - // to the same service - DataBindingInteceptor interceptor = - new DataBindingInteceptor(source, sourceOperation, targetOperation); - interceptor.setMediator(mediator); - entry.getValue().addInterceptor(0, interceptor); - } - } - } - - public void process(InboundWire source, OutboundWire target) { - SCAObject container = source.getContainer(); - // Either Service or Reference - boolean isReference = container instanceof ReferenceBinding; - - Map, InboundInvocationChain> chains = source.getInvocationChains(); - for (Map.Entry, InboundInvocationChain> entry : chains.entrySet()) { - Operation sourceOperation = entry.getKey(); - Operation targetOperation = - getTargetOperation(target.getInvocationChains().keySet(), sourceOperation.getName()); - String sourceDataBinding = sourceOperation.getDataBinding(); - String targetDataBinding = targetOperation.getDataBinding(); - if (sourceDataBinding == null && targetDataBinding == null) { - continue; - } - if (sourceDataBinding == null || targetDataBinding == null - || !sourceDataBinding.equals(targetDataBinding)) { - // Add the interceptor to the source side - DataBindingInteceptor interceptor = - new DataBindingInteceptor(source, sourceOperation, targetOperation); - interceptor.setMediator(mediator); - if (isReference) { - // FIXME: We need a better way to position the interceptors - target.getInvocationChains().get(targetOperation).addInterceptor(0, interceptor); - Interceptor tail = entry.getValue().getTailInterceptor(); - if (tail != null) { - // HACK to relink the bridging interceptor - tail.setNext(interceptor); - } - } else { - entry.getValue().addInterceptor(0, interceptor); - } - - } - } - } - - private Operation getTargetOperation(Set> operations, String operationName) { - for (Operation op : operations) { - if (op.getName().equals(operationName)) { - return op; - } - } - return null; - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/DataTypeLoader.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/DataTypeLoader.java deleted file mode 100644 index 10731f8c53..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/DataTypeLoader.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.databinding.impl; - -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; - -import org.apache.tuscany.spi.annotation.Autowire; -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.deployer.DeploymentContext; -import org.apache.tuscany.spi.extension.LoaderExtension; -import org.apache.tuscany.spi.loader.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.model.DataType; -import org.apache.tuscany.spi.model.ModelObject; - -import org.osoa.sca.annotations.Constructor; - -/** - * The StAX loader for data type - */ -public class DataTypeLoader extends LoaderExtension { - public static final QName DATA_BINDING = - new QName("http://tuscany.apache.org/xmlns/sca/databinding/1.0", "databinding"); - - @Constructor({"registry"}) - public DataTypeLoader(@Autowire LoaderRegistry registry) { - super(registry); - } - - @Override - public QName getXMLType() { - return DATA_BINDING; - } - - public DataType load(CompositeComponent parent, - ModelObject object, XMLStreamReader reader, - DeploymentContext deploymentContext) throws XMLStreamException, LoaderException { - assert DATA_BINDING.equals(reader.getName()); - String name = reader.getAttributeValue(null, "name"); - LoaderUtil.skipToEndElement(reader); - if (name == null) { - throw new InvalidValueException("The 'name' attrbiute is required"); - } - DataType dataType = new DataType(name, Object.class, Object.class); - return dataType; - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/DirectedGraph.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/DirectedGraph.java deleted file mode 100755 index 02adf5860c..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/DirectedGraph.java +++ /dev/null @@ -1,357 +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.databinding.impl; - -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; - -/** - * Directed, weighted graph - * - * @param The type of vertex object - * @param The type of edge object - */ -public class DirectedGraph { - private final Map vertices = new HashMap(); - - /** - * Key for the shortest path cache - */ - private final class VertexPair { - private Vertex source; - - private Vertex target; - - /** - * @param source - * @param target - */ - private VertexPair(Vertex source, Vertex target) { - super(); - this.source = source; - this.target = target; - } - - public boolean equals(Object object) { - if (!VertexPair.class.isInstance(object)) { - return false; - } - VertexPair pair = (VertexPair)object; - return source == pair.source && target == pair.target; - } - - public int hashCode() { - int x = source == null ? 0 : source.hashCode(); - int y = target == null ? 0 : target.hashCode(); - return x ^ y; - } - - } - - private final Map paths = new HashMap(); - - /** - * Vertex of a graph - */ - public final class Vertex { - private V value; - - // TODO: Do we want to support multiple edges for a vertex pair? If so, - // we should use a List instead of Map - private Map outEdges = new HashMap(); - - private Vertex(V value) { - this.value = value; - } - - public String toString() { - return "(" + value + ")"; - } - - public V getValue() { - return value; - } - - public Map getOutEdges() { - return outEdges; - } - - } - - /** - * An Edge connects two vertices in one direction - */ - public final class Edge { - private Vertex sourceVertex; - - private Vertex targetVertex; - - private E value; - - private int weight; - - public Edge(Vertex source, Vertex target, E value, int weight) { - this.sourceVertex = source; - this.targetVertex = target; - this.value = value; - this.weight = weight; - } - - public String toString() { - return sourceVertex + "->" + targetVertex + "[" + value + "," + weight + "]"; - } - - public E getValue() { - return value; - } - - public void setValue(E value) { - this.value = value; - } - - public Vertex getTargetVertex() { - return targetVertex; - } - - public void setTargetVertex(Vertex vertex) { - this.targetVertex = vertex; - } - - public int getWeight() { - return weight; - } - - public void setWeight(int weight) { - this.weight = weight; - } - - public Vertex getSourceVertex() { - return sourceVertex; - } - - public void setSourceVertex(Vertex sourceVertex) { - this.sourceVertex = sourceVertex; - } - } - - private final class Node implements Comparable { - - private long distance = Integer.MAX_VALUE; - - private Node previous; // NOPMD by rfeng on 9/26/06 9:17 PM - - private Vertex vertex; // NOPMD by rfeng on 9/26/06 9:17 PM - - private Node(Vertex vertex) { - this.vertex = vertex; - } - - public int compareTo(Node o) { - return (distance > o.distance) ? 1 : ((distance == o.distance) ? 0 : -1); - } - } - - public void addEdge(V source, V target, E edgeValue, int weight) { - Vertex s = getVertex(source); - if (s == null) { - s = new Vertex(source); - vertices.put(source, s); - } - Vertex t = getVertex(target); - if (t == null) { - t = new Vertex(target); - vertices.put(target, t); - } - Edge edge = new Edge(s, t, edgeValue, weight); - s.outEdges.put(t, edge); - } - - public Vertex getVertex(V source) { - Vertex s = vertices.get(source); - return s; - } - - public boolean removeEdge(V source, V target) { - Vertex s = getVertex(source); - if (s == null) { - return false; - } - - Vertex t = getVertex(target); - if (t == null) { - return false; - } - - return s.outEdges.remove(t) != null; - - } - - public Edge getEdge(Vertex source, Vertex target) { - return source.outEdges.get(target); - } - - public Edge getEdge(V source, V target) { - return getEdge(getVertex(source), getVertex(target)); - } - - /** - * Get the shortes path from the source vertex to the target vertex using - * Dijkstra's algorithm. If there's no path, null will be returned. If the - * source is the same as the target, it returns a path with empty edges with - * weight 0. - * - * @param sourceValue The value identifies the source - * @param targetValue The value identifies the target - * @return The shortest path - */ - public Path getShortestPath(V sourceValue, V targetValue) { - Vertex source = getVertex(sourceValue); - if (source == null) { - return null; - } - Vertex target = getVertex(targetValue); - if (target == null) { - return null; - } - - VertexPair pair = new VertexPair(source, target); - if (paths.containsKey(pair)) { - return paths.get(pair); - } - - // HACK: To support same vertex - if (source == target) { - Path path = new Path(); - Edge edge = getEdge(source, target); - if (edge != null) { - path.addEdge(edge); - } - paths.put(pair, path); - return path; - } - - Map nodes = new HashMap(); - for (Vertex v : vertices.values()) { - Node node = new Node(v); - if (v == source) { - node.distance = 0; - } - nodes.put(v, node); - } - - Set otherNodes = new HashSet(nodes.values()); - Set nodesOnPath = new HashSet(); - while (!otherNodes.isEmpty()) { - Node nextNode = extractMin(otherNodes); - if (nextNode.vertex == target) { - Path path = getPath(nextNode); - paths.put(pair, path); // Cache it - return path; - } - nodesOnPath.add(nextNode); - for (Edge edge : nextNode.vertex.outEdges.values()) { - Node adjacentNode = nodes.get(edge.targetVertex); - if (nextNode.distance + edge.weight < adjacentNode.distance) { - adjacentNode.distance = nextNode.distance + edge.weight; - adjacentNode.previous = nextNode; - } - } - } - paths.put(pair, null); // Cache it - return null; - } - - /** - * Searches for the vertex u in the vertex set Q that has the least d[u] - * value. That vertex is removed from the set Q and returned to the user. - * - * @param nodes - * @return - */ - private Node extractMin(Set nodes) { - Node node = Collections.min(nodes); - nodes.remove(node); - return node; - } - - /** - * The path between two vertices - */ - public final class Path { - private List edges = new LinkedList(); - - private int weight; - - public int getWeight() { - return weight; - } - - public List getEdges() { - return edges; - } - - public void addEdge(Edge edge) { - edges.add(0, edge); - weight += edge.weight; - } - - public String toString() { - return edges + ", " + weight; - } - } - - private Path getPath(Node t) { - if (t.distance == Integer.MAX_VALUE) { - return null; - } - Path path = new Path(); - Node u = t; - while (u.previous != null) { - Edge edge = getEdge(u.previous.vertex, u.vertex); - path.addEdge(edge); - u = u.previous; - } - return path; - } - - public String toString() { - StringBuffer sb = new StringBuffer(); - for (Vertex v : vertices.values()) { - sb.append(v.outEdges.values()).append("\n"); - } - return sb.toString(); - } - - public Map getVertices() { - return vertices; - } - - public void addGraph(DirectedGraph otherGraph) { - for (Vertex v : otherGraph.vertices.values()) { - for (Edge e : v.outEdges.values()) { - addEdge(e.sourceVertex.value, e.targetVertex.value, e.value, e.weight); - } - } - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/Input2InputTransformer.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/Input2InputTransformer.java deleted file mode 100644 index 8bfeb534f3..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/Input2InputTransformer.java +++ /dev/null @@ -1,217 +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.databinding.impl; - -import java.util.List; - -import javax.xml.namespace.QName; - -import org.apache.tuscany.spi.annotation.Autowire; -import org.apache.tuscany.spi.databinding.DataBinding; -import org.apache.tuscany.spi.databinding.DataBindingRegistry; -import org.apache.tuscany.spi.databinding.Mediator; -import org.apache.tuscany.spi.databinding.PullTransformer; -import org.apache.tuscany.spi.databinding.TransformationContext; -import org.apache.tuscany.spi.databinding.TransformationException; -import org.apache.tuscany.spi.databinding.Transformer; -import org.apache.tuscany.spi.databinding.WrapperHandler; -import org.apache.tuscany.spi.databinding.extension.TransformerExtension; -import org.apache.tuscany.spi.idl.ElementInfo; -import org.apache.tuscany.spi.model.WrapperInfo; -import org.apache.tuscany.spi.model.DataType; -import org.apache.tuscany.spi.model.Operation; - -import org.osoa.sca.annotations.Service; - -/** - * This is a special transformer to transform the input from one IDL to the - * other one - */ -@Service(Transformer.class) -public class Input2InputTransformer extends TransformerExtension implements - PullTransformer { - - private static final String IDL_INPUT = "idl:input"; - - protected DataBindingRegistry dataBindingRegistry; - - protected Mediator mediator; - - public Input2InputTransformer() { - super(); - } - - @Override - public String getSourceDataBinding() { - return IDL_INPUT; - } - - @Override - public String getTargetDataBinding() { - return IDL_INPUT; - } - - /** - * @param mediator the mediator to set - */ - @Autowire - public void setMediator(Mediator mediator) { - this.mediator = mediator; - } - - /** - * @param dataBindingRegistry the dataBindingRegistry to set - */ - @Autowire - public void setDataBindingRegistry(DataBindingRegistry dataBindingRegistry) { - this.dataBindingRegistry = dataBindingRegistry; - } - - /** - * @see org.apache.tuscany.spi.databinding.extension.TransformerExtension#getSourceType() - */ - @Override - protected Class getSourceType() { - return Object[].class; - } - - /** - * @see org.apache.tuscany.spi.databinding.extension.TransformerExtension#getTargetType() - */ - @Override - protected Class getTargetType() { - return Object[].class; - } - - /** - * @see org.apache.tuscany.spi.databinding.Transformer#getWeight() - */ - public int getWeight() { - return 10000; - } - - @SuppressWarnings("unchecked") - public Object[] transform(Object[] source, TransformationContext context) { - DataType>> sourceType = context.getSourceDataType(); - Operation sourceOp = (Operation)sourceType.getOperation(); - boolean sourceWrapped = sourceOp != null && sourceOp.isWrapperStyle(); - - WrapperHandler sourceWrapperHandler = null; - if (sourceWrapped) { - sourceWrapperHandler = getWapperHandler(sourceType.getOperation().getDataBinding(), true); - } - - DataType>> targetType = context.getTargetDataType(); - Operation targetOp = (Operation)targetType.getOperation(); - boolean targetWrapped = targetOp != null && targetOp.isWrapperStyle(); - WrapperHandler targetWrapperHandler = null; - if (targetWrapped) { - targetWrapperHandler = getWapperHandler(targetType.getOperation().getDataBinding(), true); - } - - if ((!sourceWrapped) && targetWrapped) { - // Unwrapped --> Wrapped - WrapperInfo wrapper = targetOp.getWrapper(); - ElementInfo wrapperElement = wrapper.getInputWrapperElement(); - - // If the source can be wrapped, wrapped it first - if (sourceWrapperHandler != null) { - Object sourceWrapper = sourceWrapperHandler.create(wrapperElement, context); - for (int i = 0; i < source.length; i++) { - ElementInfo argElement = wrapper.getInputChildElements().get(i); - sourceWrapperHandler.setChild(sourceWrapper, i, argElement, source[0]); - } - } - Object targetWrapper = targetWrapperHandler.create(wrapperElement, context); - if (source == null) { - return new Object[] {targetWrapper}; - } - List> argTypes = wrapper.getUnwrappedInputType().getLogical(); - - for (int i = 0; i < source.length; i++) { - ElementInfo argElement = wrapper.getInputChildElements().get(i); - DataType argType = argTypes.get(i); - Object child = source[i]; - child = - mediator.mediate(source[i], sourceType.getLogical().get(i), argType, context - .getMetadata()); - targetWrapperHandler.setChild(targetWrapper, i, argElement, child); - } - return new Object[] {targetWrapper}; - } else if (sourceWrapped && (!targetWrapped)) { - // Wrapped to Unwrapped - Object sourceWrapper = source[0]; - List childElements = sourceOp.getWrapper().getInputChildElements(); - Object[] target = new Object[childElements.size()]; - - targetWrapperHandler = getWapperHandler(targetType.getOperation().getDataBinding(), false); - if (targetWrapperHandler != null) { - ElementInfo wrapperElement = sourceOp.getWrapper().getInputWrapperElement(); - // Object targetWrapper = - // targetWrapperHandler.create(wrapperElement, context); - DataType targetWrapperType = - new DataType(targetType.getOperation().getDataBinding(), Object.class, - wrapperElement.getQName()); - Object targetWrapper = - mediator.mediate(sourceWrapper, - sourceType.getLogical().get(0), - targetWrapperType, - context.getMetadata()); - for (int i = 0; i < childElements.size(); i++) { - ElementInfo childElement = childElements.get(i); - target[i] = targetWrapperHandler.getChild(targetWrapper, i, childElement); - } - } else { - for (int i = 0; i < childElements.size(); i++) { - ElementInfo childElement = childElements.get(i); - Object child = sourceWrapperHandler.getChild(sourceWrapper, i, childElement); - DataType childType = - sourceOp.getWrapper().getUnwrappedInputType().getLogical().get(i); - target[i] = - mediator.mediate(child, childType, targetType.getLogical().get(i), context - .getMetadata()); - } - } - return target; - } else { - // Assuming wrapper to wrapper conversion can be handled here as - // well - Object[] newArgs = new Object[source.length]; - for (int i = 0; i < source.length; i++) { - Object child = - mediator.mediate(source[i], sourceType.getLogical().get(i), targetType.getLogical() - .get(i), context.getMetadata()); - newArgs[i] = child; - } - return newArgs; - } - } - - private WrapperHandler getWapperHandler(String dataBindingId, boolean required) { - DataBinding dataBinding = dataBindingRegistry.getDataBinding(dataBindingId); - WrapperHandler wrapperHandler = dataBinding == null ? null : dataBinding.getWrapperHandler(); - if (wrapperHandler == null && required) { - throw new TransformationException( - "No wrapper handler is provided for databinding: " + dataBindingId); - } - return wrapperHandler; - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/MediatorImpl.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/MediatorImpl.java deleted file mode 100644 index 0093c0de91..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/MediatorImpl.java +++ /dev/null @@ -1,171 +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.databinding.impl; - -import java.util.List; -import java.util.Map; - -import org.apache.tuscany.spi.annotation.Autowire; -import org.apache.tuscany.spi.databinding.DataBindingRegistry; -import org.apache.tuscany.spi.databinding.DataPipe; -import org.apache.tuscany.spi.databinding.Mediator; -import org.apache.tuscany.spi.databinding.PullTransformer; -import org.apache.tuscany.spi.databinding.PushTransformer; -import org.apache.tuscany.spi.databinding.TransformationContext; -import org.apache.tuscany.spi.databinding.TransformationException; -import org.apache.tuscany.spi.databinding.Transformer; -import org.apache.tuscany.spi.databinding.TransformerRegistry; -import org.apache.tuscany.spi.model.DataType; -import org.osoa.sca.annotations.Scope; - -/** - * Default Mediator implementation - */ -@Scope("COMPOSITE") -public class MediatorImpl implements Mediator { - - private DataBindingRegistry dataBindingRegistry; - - private TransformerRegistry transformerRegistry; - - @Autowire - public void setTransformerRegistry(TransformerRegistry transformerRegistry) { - this.transformerRegistry = transformerRegistry; - } - - /** - * @param dataBindingRegistry the dataBindingRegistry to set - */ - @Autowire - public void setDataBindingRegistry(DataBindingRegistry dataBindingRegistry) { - this.dataBindingRegistry = dataBindingRegistry; - } - - /** - * @see org.apache.tuscany.spi.databinding.Mediator#mediate(java.lang.Object, - * org.apache.tuscany.spi.model.DataType, - * org.apache.tuscany.spi.model.DataType, Map) - */ - @SuppressWarnings("unchecked") - public Object mediate(Object source, - DataType sourceDataType, - DataType targetDataType, - Map, Object> metadata) { - if (sourceDataType == null) { - sourceDataType = dataBindingRegistry.introspectType(source); - } - if (sourceDataType == null) { - return source; - } else if (sourceDataType.equals(targetDataType)) { - return source; - } - - List path = getTransformerChain(sourceDataType, targetDataType); - - Object result = source; - int size = path.size(); - int i = 0; - while (i < size) { - Transformer transformer = path.get(i); - TransformationContext context = - createTransformationContext(sourceDataType, targetDataType, size, i, transformer, metadata); - // the source and target type - if (transformer instanceof PullTransformer) { - // For intermediate node, set data type to null - result = ((PullTransformer)transformer).transform(result, context); - } else if (transformer instanceof PushTransformer) { - DataPipe dataPipe = (i < size - 1) ? (DataPipe)path.get(++i) : null; - ((PushTransformer)transformer).transform(result, dataPipe.getSink(), context); - result = dataPipe.getResult(); - } - i++; - } - - return result; - } - - private TransformationContext createTransformationContext(DataType sourceDataType, - DataType targetDataType, - int size, - int index, - Transformer transformer, - Map, Object> metadata) { - DataType sourceType = - (index == 0) ? sourceDataType : new DataType(transformer.getSourceDataBinding(), - Object.class, null); - DataType targetType = - (index == size - 1) ? targetDataType : new DataType(transformer.getTargetDataBinding(), - Object.class, null); - ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); - TransformationContext context = - new TransformationContextImpl(sourceType, targetType, classLoader, metadata); - return context; - } - - @SuppressWarnings("unchecked") - public void mediate(Object source, - Object target, - DataType sourceDataType, - DataType targetDataType, - Map, Object> metadata) { - if (source == null) { - // Shortcut for null value - return; - } - if (sourceDataType == null) { - sourceDataType = dataBindingRegistry.introspectType(source); - } - if (sourceDataType == null) { - return; - } else if (sourceDataType.equals(targetDataType)) { - return; - } - - List path = getTransformerChain(sourceDataType, targetDataType); - Object result = source; - int size = path.size(); - for (int i = 0; i < size; i++) { - Transformer transformer = path.get(i); - TransformationContext context = - createTransformationContext(sourceDataType, targetDataType, size, i, transformer, metadata); - - if (transformer instanceof PullTransformer) { - result = ((PullTransformer)transformer).transform(result, context); - } else if (transformer instanceof PushTransformer) { - DataPipe dataPipe = (i < size - 1) ? (DataPipe)path.get(++i) : null; - Object sink = dataPipe != null ? dataPipe.getSink() : target; - ((PushTransformer)transformer).transform(result, sink, context); - result = (dataPipe != null) ? dataPipe.getResult() : null; - } - } - } - - private List getTransformerChain(DataType sourceDataType, DataType targetDataType) { - String sourceId = sourceDataType.getDataBinding(); - String targetId = targetDataType.getDataBinding(); - List path = transformerRegistry.getTransformerChain(sourceId, targetId); - if (path == null) { - TransformationException ex = new TransformationException("No path found for the transformation"); - ex.addContextName("Source: " + sourceId); - ex.addContextName("Target: " + targetId); - throw ex; - } - return path; - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/Output2OutputTransformer.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/Output2OutputTransformer.java deleted file mode 100644 index aaca7d2b9c..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/Output2OutputTransformer.java +++ /dev/null @@ -1,201 +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.databinding.impl; - -import java.util.List; - -import javax.xml.namespace.QName; - -import org.apache.tuscany.spi.annotation.Autowire; -import org.apache.tuscany.spi.databinding.DataBinding; -import org.apache.tuscany.spi.databinding.DataBindingRegistry; -import org.apache.tuscany.spi.databinding.Mediator; -import org.apache.tuscany.spi.databinding.PullTransformer; -import org.apache.tuscany.spi.databinding.TransformationContext; -import org.apache.tuscany.spi.databinding.TransformationException; -import org.apache.tuscany.spi.databinding.Transformer; -import org.apache.tuscany.spi.databinding.WrapperHandler; -import org.apache.tuscany.spi.databinding.extension.TransformerExtension; -import org.apache.tuscany.spi.idl.ElementInfo; -import org.apache.tuscany.spi.model.WrapperInfo; -import org.apache.tuscany.spi.model.DataType; -import org.apache.tuscany.spi.model.Operation; -import org.osoa.sca.annotations.Service; - -/** - * This is a special transformer to transform the output from one IDL to the - * other one - */ -@Service(Transformer.class) -public class Output2OutputTransformer extends TransformerExtension implements - PullTransformer { - private static final String IDL_OUTPUT = "idl:output"; - - protected DataBindingRegistry dataBindingRegistry; - - protected Mediator mediator; - - /** - * @param wrapperHandler - */ - public Output2OutputTransformer() { - super(); - } - - /** - * @param mediator the mediator to set - */ - @Autowire - public void setMediator(Mediator mediator) { - this.mediator = mediator; - } - - /** - * @param dataBindingRegistry the dataBindingRegistry to set - */ - @Autowire - public void setDataBindingRegistry(DataBindingRegistry dataBindingRegistry) { - this.dataBindingRegistry = dataBindingRegistry; - } - - @Override - public String getSourceDataBinding() { - return IDL_OUTPUT; - } - - @Override - public String getTargetDataBinding() { - return IDL_OUTPUT; - } - - /** - * @see org.apache.tuscany.spi.databinding.extension.TransformerExtension#getSourceType() - */ - @Override - protected Class getSourceType() { - return Object.class; - } - - /** - * @see org.apache.tuscany.spi.databinding.extension.TransformerExtension#getTargetType() - */ - @Override - protected Class getTargetType() { - return Object.class; - } - - /** - * @see org.apache.tuscany.spi.databinding.Transformer#getWeight() - */ - public int getWeight() { - return 10; - } - - private WrapperHandler getWapperHandler(Operation operation) { - String dataBindingId; - dataBindingId = operation.getDataBinding(); - DataBinding dataBinding = dataBindingRegistry.getDataBinding(dataBindingId); - WrapperHandler wrapperHandler = dataBinding == null ? null : dataBinding.getWrapperHandler(); - if (wrapperHandler == null) { - throw new TransformationException( - "No wrapper handler is provided for databinding: " + dataBindingId); - } - return wrapperHandler; - } - - private WrapperHandler getWapperHandler(String dataBindingId) { - DataBinding dataBinding = dataBindingRegistry.getDataBinding(dataBindingId); - return dataBinding == null ? null : dataBinding.getWrapperHandler(); - } - - @SuppressWarnings("unchecked") - public Object transform(Object response, TransformationContext context) { - try { - DataType sourceType = context.getSourceDataType(); - Operation sourceOp = (Operation)sourceType.getOperation(); - boolean sourceWrapped = sourceOp != null && sourceOp.isWrapperStyle(); - WrapperHandler sourceWrapperHandler = null; - if (sourceWrapped) { - sourceWrapperHandler = getWapperHandler(sourceOp); - } - - DataType targetType = context.getTargetDataType(); - Operation targetOp = (Operation)targetType.getOperation(); - boolean targetWrapped = targetOp != null && targetOp.isWrapperStyle(); - WrapperHandler targetWrapperHandler = null; - if (targetWrapped) { - targetWrapperHandler = getWapperHandler(targetOp); - } - - if ((!sourceWrapped) && targetWrapped) { - // Unwrapped --> Wrapped - WrapperInfo wrapper = targetOp.getWrapper(); - Object targetWrapper = - targetWrapperHandler.create(wrapper.getOutputWrapperElement(), context); - - List childElements = wrapper.getOutputChildElements(); - if (childElements.isEmpty()) { - // void output - return targetWrapper; - } - ElementInfo argElement = childElements.get(0); - DataType argType = wrapper.getUnwrappedOutputType(); - Object child = response; - child = mediator.mediate(response, sourceType.getLogical(), argType, context.getMetadata()); - targetWrapperHandler.setChild(targetWrapper, 0, argElement, child); - return targetWrapper; - } else if (sourceWrapped && (!targetWrapped)) { - // Wrapped to Unwrapped - Object sourceWrapper = response; - List childElements = sourceOp.getWrapper().getOutputChildElements(); - if (childElements.isEmpty()) { - // The void output - return null; - } - ElementInfo childElement = childElements.get(0); - - targetWrapperHandler = getWapperHandler(targetType.getLogical().getDataBinding()); - if (targetWrapperHandler != null) { - ElementInfo wrapperElement = sourceOp.getWrapper().getInputWrapperElement(); - // Object targetWrapper = - // targetWrapperHandler.create(wrapperElement, context); - DataType targetWrapperType = - new DataType(targetType.getLogical().getDataBinding(), Object.class, - wrapperElement.getQName()); - Object targetWrapper = - mediator.mediate(sourceWrapper, sourceType.getLogical(), targetWrapperType, context - .getMetadata()); - return targetWrapperHandler.getChild(targetWrapper, 0, childElement); - } else { - Object child = sourceWrapperHandler.getChild(sourceWrapper, 0, childElement); - DataType childType = sourceOp.getWrapper().getUnwrappedOutputType(); - return mediator.mediate(child, childType, targetType.getLogical(), context.getMetadata()); - } - } else { - // FIXME: Do we want to handle wrapped to wrapped? - return mediator.mediate(response, sourceType.getLogical(), targetType.getLogical(), context - .getMetadata()); - } - } catch (Exception e) { - throw new TransformationException(e); - } - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/PassByValueInterceptor.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/PassByValueInterceptor.java deleted file mode 100644 index 1252885244..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/PassByValueInterceptor.java +++ /dev/null @@ -1,244 +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.databinding.impl; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.ObjectStreamClass; -import java.io.OutputStream; -import java.io.Serializable; -import java.util.IdentityHashMap; -import java.util.Map; - -import org.apache.tuscany.spi.databinding.DataBinding; -import org.apache.tuscany.spi.wire.Interceptor; -import org.apache.tuscany.spi.wire.Message; - -import org.apache.tuscany.core.util.JavaIntrospectionHelper; - -/** - * An interceptor to enforce pass-by-value semantics for remotable interfaces - * - * @version $Rev$ $Date$ - */ -public class PassByValueInterceptor implements Interceptor { - private DataBinding[] argsDataBindings; - private DataBinding resultDataBinding; - - private DataBinding dataBinding; - - private Interceptor next; - - public Interceptor getNext() { - return next; - } - - public boolean isOptimizable() { - return false; - } - - public void setNext(Interceptor next) { - this.next = next; - } - - public Message invoke(Message msg) { - Object obj = msg.getBody(); - msg.setBody(copy((Object[]) obj)); - Message result = getNext().invoke(msg); - - if (!result.isFault()) { - result.setBody(copy(result.getBody(), getResultDataBinding())); - } - return result; - } - - - public Object[] copy(Object[] args) { - if (args == null) { - return null; - } - Object[] copiedArgs = new Object[args.length]; - Map map = new IdentityHashMap(); - for (int i = 0; i < args.length; i++) { - if (args[i] == null) { - copiedArgs[i] = null; - } else { - Object copiedArg = map.get(args[i]); - if (copiedArg != null) { - copiedArgs[i] = copiedArg; - } else { - DataBinding dataBinding = - (getArgsDataBindings() != null) ? getArgsDataBindings()[i] : null; - copiedArg = copy(args[i], dataBinding); - map.put(args[i], copiedArg); - copiedArgs[i] = copiedArg; - } - } - } - return copiedArgs; - } - - public Object copy(Object arg, DataBinding argDataBinding) { - if (arg == null) { - return null; - } - Object copiedArg; - if (dataBinding != null) { - copiedArg = dataBinding.copy(arg); - } else { - if (argDataBinding != null) { - copiedArg = argDataBinding.copy(arg); - } else { - final Class clazz = arg.getClass(); - if (JavaIntrospectionHelper.isImmutable(clazz)) { - // Immutable classes - return arg; - } - copiedArg = copyJavaObject(arg); - } - } - return copiedArg; - } - - private Object copyJavaObject(Object arg) { - try { - return deserializeJavaObject(serializeJavaObject(arg)); - } catch (IllegalArgumentException e) { - throw e; - //System.out.println("Problem serializing..."); - //return arg; - } - } - - public byte[] serializeJavaObject(Object arg) throws IllegalArgumentException { - if (arg == null) { - return null; - } - - ByteArrayOutputStream bos = null; - ObjectOutputStream oos = null; - - try { - if (arg instanceof Serializable) { - bos = new ByteArrayOutputStream(); - oos = getObjectOutputStream(bos); - oos.writeObject(arg); - - return bos.toByteArray(); - } else { - throw new IllegalArgumentException("Unable to serialize using Java Serialization"); - } - } catch (IOException e) { - throw new IllegalArgumentException("Exception while serializing argument ", e); - } finally { - try { - if (oos != null) { - oos.close(); - } - if (bos != null) { - bos.close(); - } - } catch (IOException e) { - throw new IllegalArgumentException("Exception while serializing argument ", e); - } - } - } - - public Object deserializeJavaObject(byte[] arg) { - if (arg == null) { - return null; - } - final Class clazz = arg.getClass(); - if (JavaIntrospectionHelper.isImmutable(clazz)) { - // Immutable classes - return arg; - } - - ByteArrayInputStream bis = null; - ObjectInputStream ois = null; - - try { - bis = new ByteArrayInputStream(arg); - ois = getObjectInputStream(bis, clazz.getClassLoader()); - - return ois.readObject(); - } catch (IOException e) { - throw new IllegalArgumentException("Exception when attempting to Java Deserialization of object ", e); - } catch (ClassNotFoundException e) { - throw new IllegalArgumentException("Exception when attempting to Java Deserialization of object ", e); - } finally { - try { - if (ois != null) { - ois.close(); - } - assert bis != null; - bis.close(); - } catch (IOException e) { - throw new IllegalArgumentException("Exception when attempting to Java Deserialization of object ", e); - } - } - } - - protected ObjectOutputStream getObjectOutputStream(OutputStream os) throws IOException { - return new ObjectOutputStream(os); - } - - protected ObjectInputStream getObjectInputStream(InputStream is, final ClassLoader cl) throws IOException { - return new ObjectInputStream(is) { - @Override - protected Class resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException { - try { - return Class.forName(desc.getName(), false, cl); - } catch (ClassNotFoundException e) { - return super.resolveClass(desc); - } - } - - }; - } - - public DataBinding getDataBinding() { - return dataBinding; - } - - public void setDataBinding(DataBinding dataBinding) { - this.dataBinding = dataBinding; - } - - public DataBinding[] getArgsDataBindings() { - return argsDataBindings; - } - - public void setArgsDataBindings(DataBinding[] argsDataBindings) { - this.argsDataBindings = argsDataBindings; - } - - public DataBinding getResultDataBinding() { - return resultDataBinding; - } - - public void setResultDataBinding(DataBinding retDataBinding) { - this.resultDataBinding = retDataBinding; - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/PassByValueWirePostProcessor.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/PassByValueWirePostProcessor.java deleted file mode 100644 index c5a9a66731..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/PassByValueWirePostProcessor.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.databinding.impl; - -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.apache.tuscany.spi.annotation.Autowire; -import org.apache.tuscany.spi.databinding.DataBinding; -import org.apache.tuscany.spi.databinding.DataBindingRegistry; -import org.apache.tuscany.spi.extension.AtomicComponentExtension; -import org.apache.tuscany.spi.model.DataType; -import org.apache.tuscany.spi.model.Operation; -import org.apache.tuscany.spi.model.ServiceContract; -import org.apache.tuscany.spi.wire.InboundInvocationChain; -import org.apache.tuscany.spi.wire.InboundWire; -import org.apache.tuscany.spi.wire.Interceptor; -import org.apache.tuscany.spi.wire.OutboundWire; -import org.apache.tuscany.spi.wire.WirePostProcessorExtension; - -/** - * This processor is responsible for enforcing the pass-by-value semantics required of Remotable interfaces. This is - * done by adding a pass-by-value interceptor to the inbound invocation chain of a target if the target interface is - * Remotable. - * - * @version $Rev$ $Date$ - */ -public class PassByValueWirePostProcessor extends WirePostProcessorExtension { - - private DataBindingRegistry dataBindingRegistry; - - public PassByValueWirePostProcessor() { - super(); - - } - - /** - * @param dataBindingRegistry the dataBindingRegistry to set - */ - @Autowire - public void setDataBindingRegistry(DataBindingRegistry dataBindingRegistry) { - this.dataBindingRegistry = dataBindingRegistry; - } - - public void process(OutboundWire source, InboundWire target) { - Interceptor tailInterceptor; - PassByValueInterceptor passByValueInterceptor; - Operation targetOperation; - Operation sourceOperation; - DataBinding[] argsDataBindings; - DataBinding resultDataBinding; - - boolean allowsPassByReference = false; - if (target.getContainer() instanceof AtomicComponentExtension) { - allowsPassByReference = - ((AtomicComponentExtension) target.getContainer()).isAllowsPassByReference(); - } - if (target.getServiceContract().isRemotable() - && !allowsPassByReference) { - Map, InboundInvocationChain> chains = target.getInvocationChains(); - for (Map.Entry, InboundInvocationChain> entry : chains.entrySet()) { - targetOperation = entry.getKey(); - sourceOperation = - getSourceOperation(source.getInvocationChains().keySet(), targetOperation.getName()); - - - if (null != sourceOperation) { - argsDataBindings = resolveArgsDataBindings(targetOperation); - resultDataBinding = resolveResultDataBinding(targetOperation); - passByValueInterceptor = new PassByValueInterceptor(); - passByValueInterceptor.setDataBinding(getDataBinding(targetOperation)); - passByValueInterceptor.setArgsDataBindings(argsDataBindings); - passByValueInterceptor.setResultDataBinding(resultDataBinding); - entry.getValue().addInterceptor(0, passByValueInterceptor); - tailInterceptor = source.getInvocationChains().get(sourceOperation).getTailInterceptor(); - if (tailInterceptor != null) { - tailInterceptor.setNext(passByValueInterceptor); - } - } - } - } - - // Check if there's a callback - Map callbackOperations = source.getServiceContract().getCallbackOperations(); - allowsPassByReference = false; - if (source.getContainer() instanceof AtomicComponentExtension) { - allowsPassByReference = - ((AtomicComponentExtension) source.getContainer()).isAllowsPassByReference(); - } - - if (source.getServiceContract().isRemotable() - && !allowsPassByReference - && callbackOperations != null - && !callbackOperations.isEmpty()) { - Object targetAddress = source.getContainer().getName(); - Map, InboundInvocationChain> callbackChains = source.getTargetCallbackInvocationChains(); - for (Map.Entry, InboundInvocationChain> entry : callbackChains.entrySet()) { - targetOperation = entry.getKey(); - sourceOperation = - getSourceOperation(target.getSourceCallbackInvocationChains(targetAddress).keySet(), - targetOperation.getName()); - - argsDataBindings = resolveArgsDataBindings(targetOperation); - resultDataBinding = resolveResultDataBinding(targetOperation); - - passByValueInterceptor = new PassByValueInterceptor(); - passByValueInterceptor.setDataBinding(getDataBinding(targetOperation)); - passByValueInterceptor.setArgsDataBindings(argsDataBindings); - passByValueInterceptor.setResultDataBinding(resultDataBinding); - - entry.getValue().addInterceptor(0, passByValueInterceptor); - tailInterceptor = - target.getSourceCallbackInvocationChains(targetAddress).get(sourceOperation) - .getTailInterceptor(); - if (tailInterceptor != null) { - tailInterceptor.setNext(passByValueInterceptor); - } - } - } - } - - public void process(InboundWire source, OutboundWire target) { - //to be done if required.. - } - - private Operation getSourceOperation(Set> operations, String operationName) { - for (Operation op : operations) { - if (op.getName().equals(operationName)) { - return op; - } - } - return null; - } - - private DataBinding getDataBinding(Operation operation) { - String dataBinding = operation.getDataBinding(); - if (dataBinding == null) { - ServiceContract serviceContract = operation.getServiceContract(); - dataBinding = serviceContract.getDataBinding(); - } - return dataBindingRegistry.getDataBinding(dataBinding); - - } - - @SuppressWarnings("unchecked") - private DataBinding[] resolveArgsDataBindings(Operation operation) { - List> argumentTypes = (List>) operation.getInputType().getLogical(); - DataBinding[] argDataBindings = new DataBinding[argumentTypes.size()]; - int count = 0; - for (DataType argType : argumentTypes) { - argDataBindings[count] = null; - if (argType != null) { - if (argType.getLogical() instanceof Class) { - argDataBindings[count] = - dataBindingRegistry.getDataBinding(((Class) argType.getLogical()).getName()); - } - } - ++count; - } - return argDataBindings; - } - - private DataBinding resolveResultDataBinding(Operation operation) { - DataType resultType = (DataType) operation.getOutputType(); - DataBinding resultBinding = null; - if (resultType != null && resultType.getLogical() instanceof Class) { - Class logical = (Class) resultType.getLogical(); - resultBinding = dataBindingRegistry.getDataBinding(logical.getName()); - } - return resultBinding; - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/PipedTransformer.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/PipedTransformer.java deleted file mode 100755 index 388ea710a7..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/PipedTransformer.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.databinding.impl; - -import org.apache.tuscany.spi.databinding.DataPipe; -import org.apache.tuscany.spi.databinding.PullTransformer; -import org.apache.tuscany.spi.databinding.PushTransformer; -import org.apache.tuscany.spi.databinding.TransformationContext; - -/** - * A utility class to connect PushTransformer and DataPipe to create a - * PullTransformer - * - * @param Source type - * @param Intermidate type - * @param Result type - */ -public class PipedTransformer implements PullTransformer { - private PushTransformer pusher; - - private DataPipe pipe; - - /** - * @param pumper - * @param pipe - */ - public PipedTransformer(PushTransformer pumper, DataPipe pipe) { - super(); - this.pusher = pumper; - this.pipe = pipe; - } - - public R transform(S source, TransformationContext context) { - pusher.transform(source, pipe.getSink(), context); - return pipe.getResult(); - } - - public String getSourceDataBinding() { - return pusher.getSourceDataBinding(); - } - - public String getTargetDataBinding() { - return pipe.getTargetDataBinding(); - } - - public int getWeight() { - return pusher.getWeight() + pipe.getWeight(); - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/SimpleDataBinding.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/SimpleDataBinding.java deleted file mode 100644 index b1550c9f0a..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/SimpleDataBinding.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.databinding.impl; - -import org.osoa.sca.annotations.Property; - -import org.apache.tuscany.spi.databinding.extension.DataBindingExtension; -import org.apache.tuscany.spi.loader.MissingResourceException; - -/** - * Simple databinding represented by a base java type. A SCDL property className is used to customize this component. - *

- * The following illustrates how a simple data binding can be registered as a SCA component. - *

- *

- * <component name="databinding.MyDataBinding">
- *   <system:implementation.java - * class="org.apache.tuscany.databinding.impl.SimpleDataBinding"/>
- *   <property name="className">my.Type</property>
- * </component> - *
- * - * @version $Rv$ $Date$ - */ -public class SimpleDataBinding extends DataBindingExtension { - - public SimpleDataBinding(@Property(name = "className")String className) throws MissingResourceException { - super(resolve(className)); - } - - private static Class resolve(String className) throws MissingResourceException { - ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); - try { - return Class.forName(className, false, classLoader); - } catch (ClassNotFoundException e) { - classLoader = SimpleDataBinding.class.getClassLoader(); - try { - return Class.forName(className, false, classLoader); - } catch (ClassNotFoundException e1) { - throw new MissingResourceException(className, e1); - } - } - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/TransformationContextImpl.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/TransformationContextImpl.java deleted file mode 100755 index 47f340097b..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/TransformationContextImpl.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.databinding.impl; - -import java.lang.ref.WeakReference; -import java.util.HashMap; -import java.util.Map; - -import org.apache.tuscany.spi.databinding.TransformationContext; -import org.apache.tuscany.spi.model.DataType; - -public class TransformationContextImpl implements TransformationContext { - private DataType sourceDataType; - - private DataType targetDataType; - - private final Map, Object> metadata = new HashMap, Object>(); - - private WeakReference classLoaderRef; - - public TransformationContextImpl() { - super(); - setClassLoader(Thread.currentThread().getContextClassLoader()); - } - - public TransformationContextImpl(DataType sourceDataType, - DataType targetDataType, - ClassLoader classLoader, - Map, Object> metadata) { - super(); - this.sourceDataType = sourceDataType; - this.targetDataType = targetDataType; - setClassLoader(classLoader); - if (metadata != null) { - this.metadata.putAll(metadata); - } - } - - public DataType getSourceDataType() { - return sourceDataType; - } - - public DataType getTargetDataType() { - return targetDataType; - } - - public void setSourceDataType(DataType sourceDataType) { - this.sourceDataType = sourceDataType; - } - - public void setTargetDataType(DataType targetDataType) { - this.targetDataType = targetDataType; - } - - public final void setClassLoader(ClassLoader classLoader) { - this.classLoaderRef = new WeakReference(classLoader); - } - - public ClassLoader getClassLoader() { - return classLoaderRef.get(); - } - - public Map, Object> getMetadata() { - return metadata; - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/TransformerRegistryImpl.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/TransformerRegistryImpl.java deleted file mode 100755 index c8bfa1cc8c..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/impl/TransformerRegistryImpl.java +++ /dev/null @@ -1,73 +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.databinding.impl; - -import java.util.ArrayList; -import java.util.List; - -import org.osoa.sca.annotations.EagerInit; - -import org.apache.tuscany.spi.databinding.Transformer; -import org.apache.tuscany.spi.databinding.TransformerRegistry; - -/** - * @version $Rev$ $Date$ - */ -@EagerInit -public class TransformerRegistryImpl implements TransformerRegistry { - - private final DirectedGraph graph = new DirectedGraph(); - - public void registerTransformer(String sourceType, String resultType, int weight, Transformer transformer) { - graph.addEdge(sourceType, resultType, transformer, weight); - } - - public void registerTransformer(Transformer transformer) { - graph.addEdge(transformer.getSourceDataBinding(), - transformer.getTargetDataBinding(), - transformer, - transformer.getWeight()); - } - - public boolean unregisterTransformer(String sourceType, String resultType) { - return graph.removeEdge(sourceType, resultType); - } - - public Transformer getTransformer(String sourceType, String resultType) { - DirectedGraph.Edge edge = graph.getEdge(sourceType, resultType); - return (edge == null) ? null : edge.getValue(); - } - - public List getTransformerChain(String sourceType, String resultType) { - List transformers = new ArrayList(); - DirectedGraph.Path path = graph.getShortestPath(sourceType, resultType); - if (path == null) { - return null; - } - for (DirectedGraph.Edge edge : path.getEdges()) { - transformers.add(edge.getValue()); - } - return transformers; - } - - public String toString() { - return graph.toString(); - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/DOMDataBinding.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/DOMDataBinding.java deleted file mode 100644 index d2df8cf888..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/DOMDataBinding.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.databinding.xml; - - -import org.w3c.dom.Node; - -import org.apache.tuscany.spi.databinding.WrapperHandler; -import org.apache.tuscany.spi.databinding.extension.DataBindingExtension; - -/** - * DOM DataBinding - * - * @version $Rev$ $Date$ - */ -public class DOMDataBinding extends DataBindingExtension { - public static final String NAME = Node.class.getName(); - - public DOMDataBinding() { - super(Node.class); - } - - @Override - public WrapperHandler getWrapperHandler() { - return new DOMWrapperHandler(); - } - - public Object copy(Object source) { - if (Node.class.isAssignableFrom(source.getClass())) { - Node nodeSource = (Node) source; - Node2String strTransformer = new Node2String(); - String stringCopy = strTransformer.transform(nodeSource, null); - - String2Node nodeTransformer = new String2Node(); - return nodeTransformer.transform(stringCopy, null); - } - - return super.copy(source); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/DOMWrapperHandler.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/DOMWrapperHandler.java deleted file mode 100644 index 0373ebcdfe..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/DOMWrapperHandler.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.databinding.xml; - -import javax.xml.namespace.QName; -import javax.xml.parsers.ParserConfigurationException; - -import org.apache.tuscany.spi.databinding.TransformationContext; -import org.apache.tuscany.spi.databinding.TransformationException; -import org.apache.tuscany.spi.databinding.WrapperHandler; -import org.apache.tuscany.spi.databinding.extension.DOMHelper; -import org.apache.tuscany.spi.idl.ElementInfo; -import org.w3c.dom.Document; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -public class DOMWrapperHandler implements WrapperHandler { - - private Document document; - - public DOMWrapperHandler() { - super(); - try { - this.document = DOMHelper.newDocument(); - } catch (ParserConfigurationException e) { - throw new TransformationException(e); - } - } - - public Node create(ElementInfo element, TransformationContext context) { - QName name = element.getQName(); - return DOMHelper.createElement(document, name); - } - - public Object getChild(Node wrapper, int i, ElementInfo element) { - int index = 0; - NodeList nodes = wrapper.getChildNodes(); - for (int j = 0; j < nodes.getLength(); j++) { - Node node = nodes.item(j); - if (node.getNodeType() != Node.ELEMENT_NODE) { - continue; - } - if (index != i) { - index++; - } else { - QName name = DOMHelper.getQName(node); - if (name.equals(element.getQName())) { - return node; - } - } - } - return null; - } - - public void setChild(Node wrapper, int i, ElementInfo childElement, Object value) { - Node node = (Node) value; - if (node.getNodeType() == Node.DOCUMENT_NODE) { - node = ((Document) node).getDocumentElement(); - } - wrapper.appendChild(wrapper.getOwnerDocument().importNode(node, true)); - } -} \ No newline at end of file diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/DOMXMLStreamReader.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/DOMXMLStreamReader.java deleted file mode 100644 index f94ddd545f..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/DOMXMLStreamReader.java +++ /dev/null @@ -1,1415 +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.databinding.xml; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import javax.xml.XMLConstants; -import javax.xml.namespace.NamespaceContext; -import javax.xml.namespace.QName; -import javax.xml.stream.Location; -import javax.xml.stream.XMLStreamException; - -import org.w3c.dom.Attr; -import org.w3c.dom.CharacterData; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.NamedNodeMap; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -import org.apache.tuscany.core.databinding.xml.StAXHelper.XMLFragmentStreamReader; - -public class DOMXMLStreamReader implements XMLFragmentStreamReader { - protected static class DelegatingNamespaceContext implements NamespaceContext { - private int counter; - - private NamespaceContext parent; - - private Map prefixToNamespaceMapping = new HashMap(); - - public DelegatingNamespaceContext(NamespaceContext parent) { - super(); - this.parent = parent; - - prefixToNamespaceMapping.put("xml", "http://www.w3.org/XML/1998/namespace"); - prefixToNamespaceMapping.put("xmlns", "http://www.w3.org/2000/xmlns/"); - prefixToNamespaceMapping.put("xsi", "http://www.w3.org/2001/XMLSchema-instance"); - } - - public synchronized QName createQName(String nsURI, String name) { - String prefix = nsURI != null ? (String) getPrefix(nsURI) : null; - if (prefix == null && nsURI != null && !nsURI.equals("")) { - prefix = "p" + (counter++); - } - if (prefix == null) { - prefix = ""; - } - if (nsURI != null) { - prefixToNamespaceMapping.put(prefix, nsURI); - } - return new QName(nsURI, name, prefix); - } - - public String getNamespaceURI(String prefix) { - if (prefix == null) { - throw new IllegalArgumentException("Prefix is null"); - } - - String ns = (String) prefixToNamespaceMapping.get(prefix); - if (ns != null) { - return ns; - } else if (parent != null) { - return parent.getNamespaceURI(prefix); - } else { - return null; - } - } - - public String getPrefix(String nsURI) { - if (nsURI == null) { - throw new IllegalArgumentException("Namespace is null"); - } - for (Map.Entry entry1 : prefixToNamespaceMapping.entrySet()) { - Map.Entry entry = entry1; - if (entry.getValue().equals(nsURI)) { - return (String) entry.getKey(); - } - } - if (parent != null) { - return parent.getPrefix(nsURI); - } else { - return null; - } - } - - public Iterator getPrefixes(String nsURI) { - List prefixList = new ArrayList(); - for (Map.Entry entry : prefixToNamespaceMapping.entrySet()) { - if (entry.getValue().equals(nsURI)) { - prefixList.add(entry.getKey()); - } - } - if (parent != null) { - for (Iterator i = parent.getPrefixes(nsURI); i.hasNext();) { - prefixList.add((String) i.next()); - } - } - return prefixList.iterator(); - } - - public void registerMapping(String prefix, String nsURI) { - prefixToNamespaceMapping.put(prefix, nsURI); - } - - public void removeMapping(String prefix) { - prefixToNamespaceMapping.remove(prefix); - } - - public void setParent(NamespaceContext parent) { - this.parent = parent; - } - } - - protected static class NameValuePair implements Map.Entry { - private Object key; - - private Object value; - - public NameValuePair(Object key, Object value) { - this.key = key; - this.value = value; - } - - public Object getKey() { - return key; - } - - public Object getValue() { - return value; - } - - public Object setValue(Object value) { - Object v = this.value; - this.value = value; - return v; - } - - } - - protected static class SimpleElementStreamReader implements XMLFragmentStreamReader { - - private static final int END_ELEMENT_STATE = 2; - - private static final int START_ELEMENT_STATE = 0; - - private static final int START_ELEMENT_STATE_WITH_NULL = 3; - - private static final int TEXT_STATE = 1; - - private static final QName XSI_NIL_QNAME = - new QName("http://www.w3.org/2001/XMLSchema-instance", "nil", "xsi"); - - private QName name; - - private DelegatingNamespaceContext namespaceContext = new DelegatingNamespaceContext(null); - - private int state = START_ELEMENT_STATE; - - private String value; - - public SimpleElementStreamReader(QName name, String value) { - this.name = name; - this.value = value; - if (value == null) { - state = START_ELEMENT_STATE_WITH_NULL; - } - } - - public void close() throws XMLStreamException { - // Do nothing - we've nothing to free here - } - - public int getAttributeCount() { - if (state == START_ELEMENT_STATE_WITH_NULL) { - return 1; - } - if (state == START_ELEMENT_STATE) { - return 0; - } else { - throw new IllegalStateException(); - } - - } - - public String getAttributeLocalName(int i) { - if (state == START_ELEMENT_STATE_WITH_NULL && i == 0) { - return XSI_NIL_QNAME.getLocalPart(); - } - if (state == START_ELEMENT_STATE) { - return null; - } else { - throw new IllegalStateException(); - } - } - - public QName getAttributeName(int i) { - if (state == START_ELEMENT_STATE_WITH_NULL && i == 0) { - return XSI_NIL_QNAME; - } - if (state == START_ELEMENT_STATE) { - return null; - } else { - throw new IllegalStateException(); - } - } - - public String getAttributeNamespace(int i) { - if (state == START_ELEMENT_STATE_WITH_NULL && i == 0) { - return XSI_NIL_QNAME.getNamespaceURI(); - } - if (state == START_ELEMENT_STATE) { - return null; - } else { - throw new IllegalStateException(); - } - } - - public String getAttributePrefix(int i) { - if (state == START_ELEMENT_STATE_WITH_NULL && i == 0) { - return XSI_NIL_QNAME.getPrefix(); - } - if (state == START_ELEMENT_STATE) { - return null; - } else { - throw new IllegalStateException(); - } - } - - public String getAttributeType(int i) { - return null; // not implemented - } - - public String getAttributeValue(int i) { - if (state == START_ELEMENT_STATE_WITH_NULL && i == 0) { - return "true"; - } - if (state == START_ELEMENT_STATE) { - return null; - } else { - throw new IllegalStateException(); - } - } - - public String getAttributeValue(String string, String string1) { - if (state == TEXT_STATE) { - // todo something - return null; - } else { - return null; - } - - } - - public String getCharacterEncodingScheme() { - return null; - } - - public String getElementText() throws XMLStreamException { - if (state == START_ELEMENT) { - // move to the end state and return the value - state = END_ELEMENT_STATE; - return value; - } else { - throw new XMLStreamException(); - } - - } - - public String getEncoding() { - return "UTF-8"; - } - - public int getEventType() { - switch (state) { - case START_ELEMENT_STATE: - case START_ELEMENT_STATE_WITH_NULL: - return START_ELEMENT; - case END_ELEMENT_STATE: - return END_ELEMENT; - case TEXT_STATE: - return CHARACTERS; - default: - throw new UnsupportedOperationException(); - // we've no idea what this is!!!!! - } - - } - - public String getLocalName() { - if (state != TEXT_STATE) { - return name.getLocalPart(); - } else { - return null; - } - } - - public Location getLocation() { - return new Location() { - public int getCharacterOffset() { - return 0; - } - - public int getColumnNumber() { - return 0; - } - - public int getLineNumber() { - return 0; - } - - public String getPublicId() { - return null; - } - - public String getSystemId() { - return null; - } - }; - } - - public QName getName() { - if (state != TEXT_STATE) { - return name; - } else { - return null; - } - } - - public NamespaceContext getNamespaceContext() { - return this.namespaceContext; - } - - public int getNamespaceCount() { - if (state == START_ELEMENT_STATE_WITH_NULL && isXsiNamespacePresent()) { - return 1; - } else { - return 0; - } - - } - - public String getNamespacePrefix(int i) { - if (state == START_ELEMENT_STATE_WITH_NULL && isXsiNamespacePresent() && i == 0) { - return XSI_NIL_QNAME.getPrefix(); - } else { - return null; - } - } - - public String getNamespaceURI() { - if (state != TEXT_STATE) { - return name.getNamespaceURI(); - } else { - return null; - } - - } - - public String getNamespaceURI(int i) { - if (state == START_ELEMENT_STATE_WITH_NULL && isXsiNamespacePresent() && i == 0) { - return XSI_NIL_QNAME.getNamespaceURI(); - } else { - return null; - } - } - - public String getNamespaceURI(String prefix) { - return namespaceContext.getNamespaceURI(prefix); - } - - public String getPIData() { - return null; - } - - public String getPITarget() { - return null; - } - - public String getPrefix() { - if (state != TEXT_STATE) { - return name.getPrefix(); - } else { - return null; - } - } - - public Object getProperty(String key) throws IllegalArgumentException { - return null; - } - - public String getText() { - if (state == TEXT_STATE) { - return value; - } else { - throw new IllegalStateException(); - } - } - - public char[] getTextCharacters() { - if (state == TEXT_STATE) { - return value.toCharArray(); - } else { - throw new IllegalStateException(); - } - } - - public int getTextCharacters(int i, char[] chars, int i1, int i2) throws XMLStreamException { - // not implemented - throw new UnsupportedOperationException(); - } - - public int getTextLength() { - if (state == TEXT_STATE) { - return value.length(); - } else { - throw new IllegalStateException(); - } - - } - - public int getTextStart() { - if (state == TEXT_STATE) { - return 0; - } else { - throw new IllegalStateException(); - } - } - - public String getVersion() { - return null; // todo 1.0 ? - } - - public boolean hasName() { - return state != TEXT_STATE; - - } - - public boolean hasNext() throws XMLStreamException { - return state != END_ELEMENT_STATE; - } - - public boolean hasText() { - return state == TEXT_STATE; - } - - public void init() { - // just add the current elements namespace and prefix to the this - // elements nscontext - registerNamespace(name.getPrefix(), name.getNamespaceURI()); - - } - - public boolean isAttributeSpecified(int i) { - return false; // no attribs here - } - - public boolean isCharacters() { - return state == TEXT_STATE; - } - - public boolean isEndElement() { - return state == END_ELEMENT_STATE; - } - - public boolean isEndOfFragment() { - return state == END_ELEMENT_STATE; - } - - public boolean isStandalone() { - return false; - } - - public boolean isStartElement() { - return state == START_ELEMENT_STATE || state == START_ELEMENT_STATE_WITH_NULL; - } - - public boolean isWhiteSpace() { - return false; // no whitespaces here - } - - /** - * Test whether the xsi namespace is present - * - * @return - */ - private boolean isXsiNamespacePresent() { - return namespaceContext.getNamespaceURI(XSI_NIL_QNAME.getPrefix()) != null; - } - - public int next() throws XMLStreamException { - switch (state) { - case START_ELEMENT_STATE: - state = TEXT_STATE; - return CHARACTERS; - case START_ELEMENT_STATE_WITH_NULL: - state = END_ELEMENT_STATE; - return END_ELEMENT; - case END_ELEMENT_STATE: - // oops, not supposed to happen! - throw new XMLStreamException("end already reached!"); - case TEXT_STATE: - state = END_ELEMENT_STATE; - return END_ELEMENT; - default: - throw new XMLStreamException("unknown event type!"); - } - } - - public int nextTag() throws XMLStreamException { - return 0; // todo - } - - /** - * @param prefix - * @param uri - */ - private void registerNamespace(String prefix, String uri) { - // todo - need to fix this up to cater for cases where - // namespaces are having no prefixes - if (!uri.equals(namespaceContext.getNamespaceURI(prefix))) { - // this namespace is not there. Need to declare it - namespaceContext.registerMapping(prefix, uri); - } - } - - public void require(int i, String string, String string1) throws XMLStreamException { - // not implemented - } - - public void setParentNamespaceContext(NamespaceContext nsContext) { - this.namespaceContext.setParent(nsContext); - } - - public boolean standaloneSet() { - return false; - } - - } - - private static final int DELEGATED_STATE = 2; - - private static final int END_ELEMENT_STATE = 1; - - // states for this pullparser - it can only have three states - private static final int START_ELEMENT_STATE = 0; - - private static final int TEXT_STATE = 3; - - private Map.Entry[] attributes; - - // reference to the child reader - private XMLFragmentStreamReader childReader; - - // current property index - private int currentPropertyIndex; - - private Map declaredNamespaceMap = new HashMap(); - - private QName elementQName; - - // we always create a new namespace context - private DelegatingNamespaceContext namespaceContext = new DelegatingNamespaceContext(null); - - private Map.Entry[] properties; - - private Element rootElement; - - private String rootElementName; - - private String rootElementURI; - - // integer field that keeps the state of this - // parser. - private int state = START_ELEMENT_STATE; - - public DOMXMLStreamReader(Node node) { - switch (node.getNodeType()) { - case Node.DOCUMENT_NODE: - this.rootElement = ((Document) node).getDocumentElement(); - break; - case Node.ELEMENT_NODE: - this.rootElement = (Element) node; - break; - default: - throw new IllegalArgumentException("Illegal Node"); - } - this.rootElementName = rootElement.getLocalName(); - this.rootElementURI = rootElement.getNamespaceURI(); - - declaredNamespaceMap.put("xml", "http://www.w3.org/XML/1998/namespace"); - declaredNamespaceMap.put("xmlns", "http://www.w3.org/2000/xmlns/"); - declaredNamespaceMap.put("xsi", "http://www.w3.org/2001/XMLSchema-instance"); - - populateProperties(); - } - - /* - * we need to pass in a namespace context since when delegated, we've no - * idea of the current namespace context. So it needs to be passed on here! - */ - protected DOMXMLStreamReader(QName elementQName, Map.Entry[] properties, Map.Entry[] attributes) { - // validate the lengths, since both the arrays are supposed - // to have - this.properties = properties; - this.elementQName = elementQName; - this.attributes = attributes; - - } - - public void close() throws XMLStreamException { - // do nothing here - we have no resources to free - } - - public int getAttributeCount() { - return (state == DELEGATED_STATE) ? childReader.getAttributeCount() - : ((attributes != null) && (state == START_ELEMENT_STATE) ? attributes.length : 0); - } - - public String getAttributeLocalName(int i) { - if (state == DELEGATED_STATE) { - return childReader.getAttributeLocalName(i); - } else if (state == START_ELEMENT_STATE) { - QName name = getAttributeName(i); - if (name == null) { - return null; - } else { - return name.getLocalPart(); - } - } else { - throw new IllegalStateException(); - } - } - - /** - * @param i - * @return - */ - public QName getAttributeName(int i) { - if (state == DELEGATED_STATE) { - return childReader.getAttributeName(i); - } else if (state == START_ELEMENT_STATE) { - if (attributes == null) { - return null; - } else { - if ((i >= (attributes.length)) || i < 0) { // out of range - return null; - } else { - // get the attribute pointer - Object attribPointer = attributes[i].getKey(); - // case one - attrib name is null - // this should be the pointer to the OMAttribute then - if (attribPointer instanceof String) { - return new QName((String) attribPointer); - } else if (attribPointer instanceof QName) { - return (QName) attribPointer; - } else { - return null; - } - } - } - } else { - throw new IllegalStateException(); // as per the api contract - } - - } - - public String getAttributeNamespace(int i) { - if (state == DELEGATED_STATE) { - return childReader.getAttributeNamespace(i); - } else if (state == START_ELEMENT_STATE) { - QName name = getAttributeName(i); - if (name == null) { - return null; - } else { - return name.getNamespaceURI(); - } - } else { - throw new IllegalStateException(); - } - } - - public String getAttributePrefix(int i) { - if (state == DELEGATED_STATE) { - return childReader.getAttributePrefix(i); - } else if (state == START_ELEMENT_STATE) { - QName name = getAttributeName(i); - if (name == null) { - return null; - } else { - return name.getPrefix(); - } - } else { - throw new IllegalStateException(); - } - } - - public String getAttributeType(int i) { - return null; // not supported - } - - public String getAttributeValue(int i) { - if (state == DELEGATED_STATE) { - return childReader.getAttributeValue(i); - } else if (state == START_ELEMENT_STATE) { - if (attributes == null) { - return null; - } else { - if ((i >= (attributes.length)) || i < 0) { // out of range - return null; - } else { - // get the attribute pointer - Object attribPointer = attributes[i].getKey(); - Object omAttribObj = attributes[i].getValue(); - // case one - attrib name is null - // this should be the pointer to the OMAttribute then - if (attribPointer instanceof String) { - return (String) omAttribObj; - } else if (attribPointer instanceof QName) { - return (String) omAttribObj; - } else { - return null; - } - } - } - } else { - throw new IllegalStateException(); - } - - } - - public String getAttributeValue(String nsUri, String localName) { - - int attribCount = getAttributeCount(); - String returnValue = null; - QName attribQualifiedName; - for (int i = 0; i < attribCount; i++) { - attribQualifiedName = getAttributeName(i); - if (nsUri == null) { - if (localName.equals(attribQualifiedName.getLocalPart())) { - returnValue = getAttributeValue(i); - break; - } - } else { - if (localName.equals(attribQualifiedName.getLocalPart()) && nsUri.equals(attribQualifiedName - .getNamespaceURI())) { - returnValue = getAttributeValue(i); - break; - } - } - - } - - return returnValue; - } - - public String getCharacterEncodingScheme() { - return null; // todo - should we return something for this ? - } - - /** - * todo implement the right contract for this - * - * @return - * @throws XMLStreamException - */ - public String getElementText() throws XMLStreamException { - if (state == DELEGATED_STATE) { - return childReader.getElementText(); - } else { - return null; - } - - } - - public String getEncoding() { - if (state == DELEGATED_STATE) { - return childReader.getEncoding(); - } else { - // we've no idea what the encoding is going to be in this case - // perhaps we ought to return some constant here, which the user - // might - // have access to change! - return null; - } - } - - // ///////////////////////////////////////////////////////////////////////// - // / attribute handling - // ///////////////////////////////////////////////////////////////////////// - - public int getEventType() { - if (state == START_ELEMENT_STATE) { - return START_ELEMENT; - } else if (state == END_ELEMENT_STATE) { - return END_ELEMENT; - } else { // this is the delegated state - return childReader.getEventType(); - } - - } - - public String getLocalName() { - if (state == DELEGATED_STATE) { - return childReader.getLocalName(); - } else if (state != TEXT_STATE) { - return elementQName.getLocalPart(); - } else { - throw new IllegalStateException(); - } - } - - /** - * @return - */ - public Location getLocation() { - // return a default location - return new Location() { - public int getCharacterOffset() { - return 0; - } - - public int getColumnNumber() { - return 0; - } - - public int getLineNumber() { - return 0; - } - - public String getPublicId() { - return null; - } - - public String getSystemId() { - return null; - } - }; - } - - public QName getName() { - if (state == DELEGATED_STATE) { - return childReader.getName(); - } else if (state != TEXT_STATE) { - return elementQName; - } else { - throw new IllegalStateException(); - } - - } - - public NamespaceContext getNamespaceContext() { - if (state == DELEGATED_STATE) { - return childReader.getNamespaceContext(); - } else { - return namespaceContext; - } - - } - - public int getNamespaceCount() { - if (state == DELEGATED_STATE) { - return childReader.getNamespaceCount(); - } else { - return declaredNamespaceMap.size(); - } - } - - /** - * @param i - * @return - */ - public String getNamespacePrefix(int i) { - if (state == DELEGATED_STATE) { - return childReader.getNamespacePrefix(i); - } else if (state != TEXT_STATE) { - // order the prefixes - String[] prefixes = makePrefixArray(); - if ((i >= prefixes.length) || (i < 0)) { - return null; - } else { - return prefixes[i]; - } - - } else { - throw new IllegalStateException(); - } - - } - - public String getNamespaceURI() { - if (state == DELEGATED_STATE) { - return childReader.getNamespaceURI(); - } else if (state == TEXT_STATE) { - return null; - } else { - return elementQName.getNamespaceURI(); - } - } - - public String getNamespaceURI(int i) { - if (state == DELEGATED_STATE) { - return childReader.getNamespaceURI(i); - } else if (state != TEXT_STATE) { - String namespacePrefix = getNamespacePrefix(i); - return namespacePrefix == null ? null : (String) declaredNamespaceMap.get(namespacePrefix); - } else { - throw new IllegalStateException(); - } - - } - - // ///////////////////////////////////////////////////////////////////////// - // //////////// end of attribute handling - // ///////////////////////////////////////////////////////////////////////// - - // ////////////////////////////////////////////////////////////////////////// - // //////////// namespace handling - // ////////////////////////////////////////////////////////////////////////// - - public String getNamespaceURI(String prefix) { - return namespaceContext.getNamespaceURI(prefix); - } - - public String getPIData() { - throw new UnsupportedOperationException("Yet to be implemented !!"); - } - - public String getPITarget() { - throw new UnsupportedOperationException("Yet to be implemented !!"); - } - - public String getPrefix() { - if (state == DELEGATED_STATE) { - return childReader.getPrefix(); - } else if (state == TEXT_STATE) { - return null; - } else { - return elementQName.getPrefix(); - } - } - - /** - * @param key - * @return - * @throws IllegalArgumentException - */ - public Object getProperty(String key) throws IllegalArgumentException { - if (state == START_ELEMENT_STATE || state == END_ELEMENT_STATE) { - return null; - } else if (state == TEXT_STATE) { - return null; - } else if (state == DELEGATED_STATE) { - return childReader.getProperty(key); - } else { - return null; - } - - } - - // ///////////////////////////////////////////////////////////////////////// - // /////// end of namespace handling - // ///////////////////////////////////////////////////////////////////////// - - public String getText() { - if (state == DELEGATED_STATE) { - return childReader.getText(); - } else if (state == TEXT_STATE) { - return (String) properties[currentPropertyIndex - 1].getValue(); - } else { - throw new IllegalStateException(); - } - } - - public char[] getTextCharacters() { - if (state == DELEGATED_STATE) { - return childReader.getTextCharacters(); - } else if (state == TEXT_STATE) { - return properties[currentPropertyIndex - 1].getValue() == null ? new char[0] - : ((String) properties[currentPropertyIndex - 1].getValue()).toCharArray(); - } else { - throw new IllegalStateException(); - } - } - - public int getTextCharacters(int i, char[] chars, int i1, int i2) throws XMLStreamException { - if (state == DELEGATED_STATE) { - return childReader.getTextCharacters(i, chars, i1, i2); - } else if (state == TEXT_STATE) { - // todo - implement this - return 0; - } else { - throw new IllegalStateException(); - } - } - - public int getTextLength() { - if (state == DELEGATED_STATE) { - return childReader.getTextLength(); - } else if (state == TEXT_STATE) { - return 0; // assume text always starts at 0 - } else { - throw new IllegalStateException(); - } - } - - public int getTextStart() { - if (state == DELEGATED_STATE) { - return childReader.getTextStart(); - } else if (state == TEXT_STATE) { - return 0; // assume text always starts at 0 - } else { - throw new IllegalStateException(); - } - } - - public String getVersion() { - return null; - } - - public boolean hasName() { - // since this parser always has a name, the hasname - // has to return true if we are still navigating this element - // if not we should ask the child reader for it. - if (state == DELEGATED_STATE) { - return childReader.hasName(); - } else { - return state != TEXT_STATE; - } - } - - /** - * @return - * @throws XMLStreamException - */ - public boolean hasNext() throws XMLStreamException { - if (state == DELEGATED_STATE) { - if (childReader.isEndOfFragment()) { - // the child reader is done. We shouldn't be getting the - // hasnext result from the child pullparser then - return true; - } else { - return childReader.hasNext(); - } - } else { - return state == START_ELEMENT_STATE || state == TEXT_STATE; - - } - } - - /** - * check the validity of this implementation - * - * @return - */ - public boolean hasText() { - if (state == DELEGATED_STATE) { - return childReader.hasText(); - } else { - return state == TEXT_STATE; - } - } - - /** - * we need to split out the calling to the populate namespaces seperately since this needs to be done *after* - * setting the parent namespace context. We cannot assume it will happen at construction! - */ - public void init() { - // here we have an extra issue to attend to. we need to look at the - // prefixes and uris (the combination) and populate a hashmap of - // namespaces. The hashmap of namespaces will be used to serve the - // namespace context - - populateNamespaceContext(); - } - - public boolean isAttributeSpecified(int i) { - return false; // not supported - } - - public boolean isCharacters() { - if (state == START_ELEMENT_STATE || state == END_ELEMENT_STATE) { - return false; - } - return childReader.isCharacters(); - } - - public boolean isEndElement() { - if (state == START_ELEMENT_STATE) { - return false; - } else if (state == END_ELEMENT_STATE) { - return true; - } - return childReader.isEndElement(); - } - - /** - * are we done ? - * - * @return - */ - public boolean isEndOfFragment() { - return state == END_ELEMENT_STATE; - } - - public boolean isStandalone() { - return true; - } - - public boolean isStartElement() { - if (state == START_ELEMENT_STATE) { - return true; - } else if (state == END_ELEMENT_STATE) { - return false; - } - return childReader.isStartElement(); - } - - public boolean isWhiteSpace() { - if (state == START_ELEMENT_STATE || state == END_ELEMENT_STATE) { - return false; - } - return childReader.isWhiteSpace(); - } - - /** - * Get the prefix list from the hastable and take that into an array - * - * @return - */ - private String[] makePrefixArray() { - String[] prefixes = - (String[]) declaredNamespaceMap.keySet().toArray(new String[declaredNamespaceMap.size()]); - Arrays.sort(prefixes); - return prefixes; - } - - public int next() throws XMLStreamException { - return updateStatus(); - } - - /** - * todo implement this - * - * @return - * @throws XMLStreamException - */ - public int nextTag() throws XMLStreamException { - return 0; - } - - // ///////////////////////////////////////////////////////////////////////// - // / Other utility methods - // //////////////////////////////////////////////////////////////////////// - - /** - * Populates a namespace context - */ - private void populateNamespaceContext() { - - // first add the current element namespace to the namespace context - // declare it if not found - registerNamespace(elementQName.getPrefix(), elementQName.getNamespaceURI()); - - // traverse through the attributes and populate the namespace context - // the attrib list can be of many combinations - // the valid combinations are - // String - String - // QName - QName - // null - OMAttribute - - if (attributes != null) { - for (int i = 0; i < attributes.length; i++) { // jump in two - Object attribName = attributes[i].getKey(); - if (attribName instanceof String) { - // ignore this case - Nothing to do - } else if (attribName instanceof QName) { - QName attribQName = (QName) attribName; - registerNamespace(attribQName.getPrefix(), attribQName.getNamespaceURI()); - - } - } - } - - } - - public final void populateProperties() { - if (properties != null) { - return; - } - if (elementQName == null) { - elementQName = namespaceContext.createQName(this.rootElementURI, this.rootElementName); - } else { - elementQName = - namespaceContext.createQName(elementQName.getNamespaceURI(), elementQName.getLocalPart()); - } - - List elementList = new ArrayList(); - List attributeList = new ArrayList(); - NamedNodeMap nodeMap = rootElement.getAttributes(); - for (int i = 0; i < nodeMap.getLength(); i++) { - Attr attr = (Attr) nodeMap.item(i); - if (XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals(attr.getNamespaceURI())) { - // Skip xmlns:xxx - if (!attr.getName().equals(attr.getLocalName())) { - // Skip xmlns="..." - registerNamespace(attr.getLocalName(), attr.getValue()); - } else { - registerNamespace(XMLConstants.DEFAULT_NS_PREFIX, attr.getValue()); - } - continue; - } - QName attrName = new QName(attr.getNamespaceURI(), attr.getLocalName()); - NameValuePair pair = new NameValuePair(attrName, attr.getValue()); - attributeList.add(pair); - } - NodeList nodeList = rootElement.getChildNodes(); - for (int i = 0; i < nodeList.getLength(); i++) { - Node node = nodeList.item(i); - switch (node.getNodeType()) { - case Node.TEXT_NODE: - case Node.CDATA_SECTION_NODE: - NameValuePair pair = new NameValuePair(ELEMENT_TEXT, ((CharacterData) node).getData()); - elementList.add(pair); - break; - - case Node.ELEMENT_NODE: - Element element = (Element) node; - QName elementName = new QName(element.getNamespaceURI(), element.getLocalName()); - pair = new NameValuePair(elementName, new DOMXMLStreamReader(element)); - elementList.add(pair); - break; - } - } - properties = elementList.toArray(new Map.Entry[elementList.size()]); - attributes = attributeList.toArray(new Map.Entry[attributeList.size()]); - } - - /** - * A convenient method to reuse the properties - * - * @return event to be thrown - * @throws XMLStreamException - */ - private int processProperties() throws XMLStreamException { - // move to the next property depending on the current property - // index - Object propPointer = properties[currentPropertyIndex].getKey(); - QName propertyQName = null; - boolean textFound = false; - if (propPointer == null) { - throw new XMLStreamException("property key cannot be null!"); - } else if (propPointer instanceof String) { - // propPointer being a String has a special case - // that is it can be a the special constant ELEMENT_TEXT that - // says this text event - if (ELEMENT_TEXT.equals(propPointer)) { - textFound = true; - } else { - propertyQName = new QName((String) propPointer); - } - } else if (propPointer instanceof QName) { - propertyQName = (QName) propPointer; - } else { - // oops - we've no idea what kind of key this is - throw new XMLStreamException("unidentified property key!!!" + propPointer); - } - - // ok! we got the key. Now look at the value - Object propertyValue = properties[currentPropertyIndex].getValue(); - // cater for the special case now - if (textFound) { - // no delegation here - make the parser null and immediately - // return with the event characters - childReader = null; - state = TEXT_STATE; - currentPropertyIndex++; - return CHARACTERS; - } else if (propertyValue == null || propertyValue instanceof String) { - // strings are handled by the NameValuePairStreamReader - childReader = new SimpleElementStreamReader(propertyQName, (String) propertyValue); - childReader.setParentNamespaceContext(this.namespaceContext); - childReader.init(); - } else if (propertyValue instanceof DOMXMLStreamReader) { - // ADBbean has it's own method to get a reader - XMLFragmentStreamReader reader = (DOMXMLStreamReader) propertyValue; - // we know for sure that this is an ADB XMLStreamreader. - // However we need to make sure that it is compatible - childReader = reader; - childReader.setParentNamespaceContext(this.namespaceContext); - childReader.init(); - } else { - // all special possiblilities has been tried! Let's treat - // the thing as a bean and try generating events from it - throw new UnsupportedOperationException("Not supported"); - // childReader = new - // WrappingXMLStreamReader(BeanUtil.getPullParser(propertyValue, - // propertyQName)); - // we cannot register the namespace context here - } - - // set the state here - state = DELEGATED_STATE; - // we are done with the delegation - // increment the property index - currentPropertyIndex++; - return childReader.getEventType(); - } - - /** - * @param prefix - * @param uri - */ - private void registerNamespace(String prefix, String uri) { - if (!uri.equals(namespaceContext.getNamespaceURI(prefix))) { - namespaceContext.registerMapping(prefix, uri); - declaredNamespaceMap.put(prefix, uri); - } - } - - public void require(int i, String string, String string1) throws XMLStreamException { - throw new UnsupportedOperationException(); - } - - /** - * add the namespace context - */ - - public void setParentNamespaceContext(NamespaceContext nsContext) { - // register the namespace context passed in to this - this.namespaceContext.setParent(nsContext); - - } - - public boolean standaloneSet() { - return true; - } - - /** - * By far this should be the most important method in this class this method changes the state of the parser - * according to the change in the - */ - private int updateStatus() throws XMLStreamException { - int returnEvent = -1; // invalid state is the default state - switch (state) { - case START_ELEMENT_STATE: - // current element is start element. We should be looking at the - // property list and making a pullparser for the property value - if (properties == null || properties.length == 0) { - // no properties - move to the end element state - // straightaway - state = END_ELEMENT_STATE; - returnEvent = END_ELEMENT; - } else { - // there are properties. now we should delegate this task to - // a - // child reader depending on the property type - returnEvent = processProperties(); - - } - break; - case END_ELEMENT_STATE: - // we've reached the end element already. If the user tries to - // push - // further ahead then it is an exception - throw new XMLStreamException("Trying to go beyond the end of the pullparser"); - - case DELEGATED_STATE: - if (childReader.isEndOfFragment()) { - // we've reached the end! - if (currentPropertyIndex > (properties.length - 1)) { - state = END_ELEMENT_STATE; - returnEvent = END_ELEMENT; - } else { - returnEvent = processProperties(); - } - } else { - returnEvent = childReader.next(); - } - break; - - case TEXT_STATE: - // if there are any more event we should be delegating to - // processProperties. if not we just return an end element - if (currentPropertyIndex > (properties.length - 1)) { - state = END_ELEMENT_STATE; - returnEvent = END_ELEMENT; - } else { - returnEvent = processProperties(); - } - break; - } - return returnEvent; - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/InputSource2Node.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/InputSource2Node.java deleted file mode 100644 index e9757fa13c..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/InputSource2Node.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.databinding.xml; - -import javax.xml.transform.Source; -import javax.xml.transform.dom.DOMResult; -import javax.xml.transform.stream.StreamSource; - -import org.apache.tuscany.spi.databinding.PullTransformer; -import org.apache.tuscany.spi.databinding.TransformationContext; -import org.apache.tuscany.spi.databinding.TransformationException; -import org.apache.tuscany.spi.databinding.Transformer; -import org.apache.tuscany.spi.databinding.extension.TransformerExtension; -import org.osoa.sca.annotations.Service; -import org.w3c.dom.Node; -import org.xml.sax.InputSource; - -/** - * Push DOM InputSource to Node - */ -@Service(Transformer.class) -public class InputSource2Node extends TransformerExtension implements - PullTransformer { - private static final Source2ResultTransformer TRANSFORMER = new Source2ResultTransformer(); - - public Node transform(InputSource source, TransformationContext context) { - try { - Source streamSource = new StreamSource(source.getCharacterStream()); - DOMResult result = new DOMResult(); - TRANSFORMER.transform(streamSource, result, context); - return result.getNode(); - } catch (Exception e) { - throw new TransformationException(e); - } - } - - public Class getSourceType() { - return InputSource.class; - } - - public Class getTargetType() { - return Node.class; - } - - public int getWeight() { - return 40; - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/InputSource2SAX.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/InputSource2SAX.java deleted file mode 100644 index be78a07ede..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/InputSource2SAX.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.databinding.xml; - -import org.apache.tuscany.spi.databinding.PushTransformer; -import org.apache.tuscany.spi.databinding.TransformationContext; -import org.apache.tuscany.spi.databinding.TransformationException; -import org.apache.tuscany.spi.databinding.Transformer; -import org.apache.tuscany.spi.databinding.extension.TransformerExtension; -import org.osoa.sca.annotations.Service; -import org.xml.sax.ContentHandler; -import org.xml.sax.InputSource; -import org.xml.sax.XMLReader; -import org.xml.sax.helpers.XMLReaderFactory; - -/** - * Push InputSource to SAX - */ -@Service(Transformer.class) -public class InputSource2SAX extends TransformerExtension implements - PushTransformer { - - public void transform(InputSource source, ContentHandler target, TransformationContext context) { - try { - XMLReader reader = XMLReaderFactory.createXMLReader(); - reader.setFeature("http://xml.org/sax/features/namespaces", true); - reader.setFeature("http://xml.org/sax/features/namespace-prefixes", false); - reader.setContentHandler(target); - reader.parse(source); - } catch (Exception e) { - throw new TransformationException(e); - } - } - - public Class getSourceType() { - return InputSource.class; - } - - public Class getTargetType() { - return ContentHandler.class; - } - - public int getWeight() { - return 40; - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/InputStream2Node.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/InputStream2Node.java deleted file mode 100644 index e103c82b33..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/InputStream2Node.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.databinding.xml; - -import java.io.InputStream; - -import javax.xml.transform.Source; -import javax.xml.transform.dom.DOMResult; -import javax.xml.transform.sax.SAXSource; - -import org.apache.tuscany.spi.databinding.PullTransformer; -import org.apache.tuscany.spi.databinding.TransformationContext; -import org.apache.tuscany.spi.databinding.TransformationException; -import org.apache.tuscany.spi.databinding.Transformer; -import org.apache.tuscany.spi.databinding.extension.TransformerExtension; -import org.osoa.sca.annotations.Service; -import org.w3c.dom.Node; -import org.xml.sax.InputSource; - -/** - * Push DOM InputSource to Node - */ -@Service(Transformer.class) -public class InputStream2Node extends TransformerExtension implements - PullTransformer { - private static final Source2ResultTransformer TRANSFORMER = new Source2ResultTransformer(); - - public Node transform(InputStream source, TransformationContext context) { - try { - Source streamSource = new SAXSource(new InputSource(source)); - DOMResult result = new DOMResult(); - TRANSFORMER.transform(streamSource, result, context); - return result.getNode(); - } catch (Exception e) { - throw new TransformationException(e); - } - } - - public Class getSourceType() { - return InputStream.class; - } - - public Class getTargetType() { - return Node.class; - } - - public int getWeight() { - return 40; - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/InputStream2SAX.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/InputStream2SAX.java deleted file mode 100644 index d74863ea95..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/InputStream2SAX.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.databinding.xml; - -import java.io.InputStream; - -import org.apache.tuscany.spi.databinding.PushTransformer; -import org.apache.tuscany.spi.databinding.TransformationContext; -import org.apache.tuscany.spi.databinding.TransformationException; -import org.apache.tuscany.spi.databinding.Transformer; -import org.apache.tuscany.spi.databinding.extension.TransformerExtension; -import org.osoa.sca.annotations.Service; -import org.xml.sax.ContentHandler; -import org.xml.sax.InputSource; -import org.xml.sax.XMLReader; -import org.xml.sax.helpers.XMLReaderFactory; - -/** - * Push InputStream to SAX - */ -@Service(Transformer.class) -public class InputStream2SAX extends TransformerExtension implements - PushTransformer { - public void transform(InputStream source, ContentHandler target, TransformationContext context) { - try { - XMLReader reader = XMLReaderFactory.createXMLReader(); - reader.setContentHandler(target); - reader.parse(new InputSource(source)); - } catch (Exception e) { - throw new TransformationException(e); - } - } - - public Class getSourceType() { - return InputStream.class; - } - - public Class getTargetType() { - return ContentHandler.class; - } - - public int getWeight() { - return 40; - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Node2Object.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Node2Object.java deleted file mode 100644 index ec0560e878..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Node2Object.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.databinding.xml; - -import org.apache.tuscany.spi.databinding.Transformer; -import org.apache.tuscany.spi.databinding.extension.SimpleType2JavaTransformer; -import org.osoa.sca.annotations.Service; -import org.w3c.dom.Document; -import org.w3c.dom.Node; - -/** - * Transformer to convert data from an simple Node to Java Object - */ -@Service(Transformer.class) -public class Node2Object extends SimpleType2JavaTransformer { - - public Node2Object() { - super(null); - } - - @Override - protected String getText(Node source) { - if (source instanceof Document) { - source = ((Document)source).getDocumentElement(); - } - return source.getTextContent(); - } - - public Class getSourceType() { - return Node.class; - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Node2OutputStream.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Node2OutputStream.java deleted file mode 100644 index 34fbdf8c6f..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Node2OutputStream.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.databinding.xml; - -import java.io.OutputStream; - -import javax.xml.transform.Result; -import javax.xml.transform.Source; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.stream.StreamResult; - -import org.apache.tuscany.spi.databinding.PushTransformer; -import org.apache.tuscany.spi.databinding.TransformationContext; -import org.apache.tuscany.spi.databinding.TransformationException; -import org.apache.tuscany.spi.databinding.Transformer; -import org.apache.tuscany.spi.databinding.extension.TransformerExtension; -import org.osoa.sca.annotations.Service; -import org.w3c.dom.Node; - -/** - * Push DOM Node to OutputStream - */ -@Service(Transformer.class) -public class Node2OutputStream extends TransformerExtension implements - PushTransformer { - private static final Source2ResultTransformer TRANSFORMER = new Source2ResultTransformer(); - - public void transform(Node source, OutputStream writer, TransformationContext context) { - try { - Source domSource = new DOMSource(source); - Result result = new StreamResult(writer); - TRANSFORMER.transform(domSource, result, context); - } catch (Exception e) { - throw new TransformationException(e); - } - } - - public Class getSourceType() { - return Node.class; - } - - public Class getTargetType() { - return OutputStream.class; - } - - public int getWeight() { - return 40; - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Node2String.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Node2String.java deleted file mode 100755 index 92378e96a3..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Node2String.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.databinding.xml; - -import java.io.StringWriter; - -import org.apache.tuscany.spi.databinding.PullTransformer; -import org.apache.tuscany.spi.databinding.TransformationContext; -import org.apache.tuscany.spi.databinding.TransformationException; -import org.apache.tuscany.spi.databinding.extension.TransformerExtension; -import org.osoa.sca.annotations.Service; -import org.w3c.dom.Node; - -/** - * Transform DOM Node to XML String - */ -@Service(org.apache.tuscany.spi.databinding.Transformer.class) -public class Node2String extends TransformerExtension implements PullTransformer { - private static final Node2Writer TRANSFORMER = new Node2Writer(); - - public String transform(Node source, TransformationContext context) { - try { - StringWriter writer = new StringWriter(); - TRANSFORMER.transform(source, writer, context); - return writer.toString(); - } catch (Exception e) { - throw new TransformationException(e); - } - } - - public Class getSourceType() { - return Node.class; - } - - public Class getTargetType() { - return String.class; - } - - public int getWeight() { - return 40; - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Node2Writer.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Node2Writer.java deleted file mode 100644 index 96328fdd2f..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Node2Writer.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.databinding.xml; - -import java.io.Writer; - -import javax.xml.transform.Result; -import javax.xml.transform.Source; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.stream.StreamResult; - -import org.apache.tuscany.spi.databinding.PushTransformer; -import org.apache.tuscany.spi.databinding.TransformationContext; -import org.apache.tuscany.spi.databinding.TransformationException; -import org.apache.tuscany.spi.databinding.Transformer; -import org.apache.tuscany.spi.databinding.extension.TransformerExtension; -import org.osoa.sca.annotations.Service; -import org.w3c.dom.Node; - -/** - * Push DOM Node to Writer - */ -@Service(Transformer.class) -public class Node2Writer extends TransformerExtension implements PushTransformer { - private static final Source2ResultTransformer TRANSFORMER = new Source2ResultTransformer(); - - public void transform(Node source, Writer writer, TransformationContext context) { - try { - Source domSource = new DOMSource(source); - Result result = new StreamResult(writer); - TRANSFORMER.transform(domSource, result, context); - } catch (Exception e) { - throw new TransformationException(e); - } - } - - public Class getSourceType() { - return Node.class; - } - - public Class getTargetType() { - return Writer.class; - } - - public int getWeight() { - return 40; - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Node2XMLStreamReader.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Node2XMLStreamReader.java deleted file mode 100644 index bff9051e01..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Node2XMLStreamReader.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.databinding.xml; - -import javax.xml.stream.XMLStreamReader; - -import org.apache.tuscany.core.databinding.xml.StAXHelper.XMLDocumentStreamReader; -import org.apache.tuscany.spi.databinding.PullTransformer; -import org.apache.tuscany.spi.databinding.TransformationContext; -import org.apache.tuscany.spi.databinding.TransformationException; -import org.apache.tuscany.spi.databinding.Transformer; -import org.apache.tuscany.spi.databinding.extension.TransformerExtension; -import org.osoa.sca.annotations.Service; -import org.w3c.dom.Node; - -/** - * Transform DOM Node to XML XMLStreamReader - */ -@Service(Transformer.class) -public class Node2XMLStreamReader extends TransformerExtension implements - PullTransformer { - - public XMLStreamReader transform(Node source, TransformationContext context) { - try { - DOMXMLStreamReader reader = new DOMXMLStreamReader(source); - return new XMLDocumentStreamReader(reader); - } catch (Exception e) { - throw new TransformationException(e); - } - } - - public Class getSourceType() { - return Node.class; - } - - public Class getTargetType() { - return XMLStreamReader.class; - } - - public int getWeight() { - return 40; - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Object2Node.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Object2Node.java deleted file mode 100644 index 7f472ba4ff..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Object2Node.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.databinding.xml; - -import javax.xml.namespace.QName; -import javax.xml.parsers.ParserConfigurationException; - -import org.apache.tuscany.spi.databinding.TransformationContext; -import org.apache.tuscany.spi.databinding.TransformationException; -import org.apache.tuscany.spi.databinding.Transformer; -import org.apache.tuscany.spi.databinding.extension.DOMHelper; -import org.apache.tuscany.spi.databinding.extension.Java2SimpleTypeTransformer; -import org.apache.tuscany.spi.idl.ElementInfo; -import org.osoa.sca.annotations.Service; -import org.w3c.dom.Document; -import org.w3c.dom.Node; - -/** - * Transformer to convert data from a simple java object to Node - */ -@Service(Transformer.class) -public class Object2Node extends Java2SimpleTypeTransformer { - - private Document factory; - - public Object2Node() { - super(null); - try { - factory = DOMHelper.newDocument(); - } catch (ParserConfigurationException e) { - throw new TransformationException(e); - } - } - - protected Node createElement(ElementInfo element, String text, TransformationContext context) { - QName name = element.getQName(); - Node root = DOMHelper.createElement(factory, name); - root.appendChild(factory.createTextNode(text)); - return root; - } - - public Class getTargetType() { - return Node.class; - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Reader2Node.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Reader2Node.java deleted file mode 100644 index 02de055c35..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Reader2Node.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.databinding.xml; - -import java.io.Reader; - -import javax.xml.transform.Source; -import javax.xml.transform.dom.DOMResult; -import javax.xml.transform.stream.StreamSource; - -import org.apache.tuscany.spi.databinding.PullTransformer; -import org.apache.tuscany.spi.databinding.TransformationContext; -import org.apache.tuscany.spi.databinding.TransformationException; -import org.apache.tuscany.spi.databinding.Transformer; -import org.apache.tuscany.spi.databinding.extension.TransformerExtension; -import org.osoa.sca.annotations.Service; -import org.w3c.dom.Node; - -/** - * Push DOM Reader to Node - */ -@Service(Transformer.class) -public class Reader2Node extends TransformerExtension implements PullTransformer { - private static final Source2ResultTransformer TRANSFORMER = new Source2ResultTransformer(); - - public Node transform(Reader source, TransformationContext context) { - try { - Source streamSource = new StreamSource(source); - DOMResult result = new DOMResult(); - TRANSFORMER.transform(streamSource, result, context); - return result.getNode(); - } catch (Exception e) { - throw new TransformationException(e); - } - } - - public Class getSourceType() { - return Reader.class; - } - - public Class getTargetType() { - return Node.class; - } - - public int getWeight() { - return 40; - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Reader2SAX.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Reader2SAX.java deleted file mode 100644 index 0a4504b3de..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Reader2SAX.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.databinding.xml; - -import java.io.Reader; - -import org.apache.tuscany.spi.databinding.PushTransformer; -import org.apache.tuscany.spi.databinding.TransformationContext; -import org.apache.tuscany.spi.databinding.TransformationException; -import org.apache.tuscany.spi.databinding.Transformer; -import org.apache.tuscany.spi.databinding.extension.TransformerExtension; -import org.osoa.sca.annotations.Service; -import org.xml.sax.ContentHandler; -import org.xml.sax.InputSource; - -/** - * Transform XML string to SAX - */ -@Service(Transformer.class) -public class Reader2SAX extends TransformerExtension implements - PushTransformer { - public void transform(Reader source, ContentHandler target, TransformationContext context) { - try { - new InputSource2SAX().transform(new InputSource(source), target, context); - } catch (Exception e) { - throw new TransformationException(e); - } - } - - public Class getSourceType() { - return Reader.class; - } - - public Class getTargetType() { - return ContentHandler.class; - } - - public int getWeight() { - return 40; - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/SAX2DOM.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/SAX2DOM.java deleted file mode 100644 index 8f8f0f952e..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/SAX2DOM.java +++ /dev/null @@ -1,244 +0,0 @@ -/* - * Copyright 2001-2004 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.tuscany.core.databinding.xml; - -import java.util.ArrayList; -import java.util.List; -import java.util.Stack; - -import javax.xml.parsers.ParserConfigurationException; - -import org.apache.tuscany.spi.databinding.extension.DOMHelper; -import org.w3c.dom.Comment; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.ProcessingInstruction; -import org.w3c.dom.Text; -import org.xml.sax.Attributes; -import org.xml.sax.ContentHandler; -import org.xml.sax.Locator; -import org.xml.sax.SAXException; -import org.xml.sax.ext.LexicalHandler; - -/** - * SAX2DOM adapter - */ -public class SAX2DOM implements ContentHandler, LexicalHandler { - public static final String EMPTYSTRING = ""; - public static final String XML_PREFIX = "xml"; - public static final String XMLNS_PREFIX = "xmlns"; - public static final String XMLNS_STRING = "xmlns:"; - public static final String XMLNS_URI = "http://www.w3.org/2000/xmlns/"; - - private Node root; - - private Document document; - - private Node nextSibling; - - private Stack nodeStk = new Stack(); - - private List namespaceDecls; - - private Node lastSibling; - - public SAX2DOM() throws ParserConfigurationException { - this.document = DOMHelper.newDocument(); - this.root = document; - } - - public SAX2DOM(Node root, Node nextSibling) throws ParserConfigurationException { - this.root = root; - if (root instanceof Document) { - this.document = (Document)root; - } else if (root != null) { - this.document = root.getOwnerDocument(); - } else { - this.document = DOMHelper.newDocument(); - this.root = document; - } - - this.nextSibling = nextSibling; - } - - public SAX2DOM(Node root) throws ParserConfigurationException { - this(root, null); - } - - public Node getDOM() { - return root; - } - - public void characters(char[] ch, int start, int length) { - final Node last = (Node)nodeStk.peek(); - - // No text nodes can be children of root (DOM006 exception) - if (last != document) { - final String text = new String(ch, start, length); - if (lastSibling != null && lastSibling.getNodeType() == Node.TEXT_NODE) { - ((Text)lastSibling).appendData(text); - } else if (last == root && nextSibling != null) { - lastSibling = last.insertBefore(document.createTextNode(text), nextSibling); - } else { - lastSibling = last.appendChild(document.createTextNode(text)); - } - - } - } - - public void startDocument() { - nodeStk.push(root); - } - - public void endDocument() { - nodeStk.pop(); - } - - public void startElement(String namespace, String localName, String qName, Attributes attrs) { - final Element tmp = (Element)document.createElementNS(namespace, qName); - - // Add namespace declarations first - if (namespaceDecls != null) { - final int nDecls = namespaceDecls.size(); - for (int i = 0; i < nDecls; i++) { - final String prefix = (String)namespaceDecls.get(i++); - - if (prefix == null || prefix.equals(EMPTYSTRING)) { - tmp.setAttributeNS(XMLNS_URI, XMLNS_PREFIX, (String)namespaceDecls.get(i)); - } else { - tmp.setAttributeNS(XMLNS_URI, XMLNS_STRING + prefix, (String)namespaceDecls.get(i)); - } - } - namespaceDecls.clear(); - } - - // Add attributes to element - final int nattrs = attrs.getLength(); - for (int i = 0; i < nattrs; i++) { - if (attrs.getLocalName(i) == null) { - tmp.setAttribute(attrs.getQName(i), attrs.getValue(i)); - } else { - tmp.setAttributeNS(attrs.getURI(i), attrs.getQName(i), attrs.getValue(i)); - } - } - - // Append this new node onto current stack node - Node last = (Node)nodeStk.peek(); - - // If the SAX2DOM is created with a non-null next sibling node, - // insert the result nodes before the next sibling under the root. - if (last == root && nextSibling != null) { - last.insertBefore(tmp, nextSibling); - } else { - last.appendChild(tmp); - } - - // Push this node onto stack - nodeStk.push(tmp); - lastSibling = null; - } - - public void endElement(String namespace, String localName, String qName) { - nodeStk.pop(); - lastSibling = null; - } - - public void startPrefixMapping(String prefix, String uri) { - if (namespaceDecls == null) { - namespaceDecls = new ArrayList(2); - } - namespaceDecls.add(prefix); - namespaceDecls.add(uri); - } - - public void endPrefixMapping(String prefix) { - // do nothing - } - - /** - * This class is only used internally so this method should never be called. - */ - public void ignorableWhitespace(char[] ch, int start, int length) { - } - - /** - * adds processing instruction node to DOM. - */ - public void processingInstruction(String target, String data) { - final Node last = (Node)nodeStk.peek(); - ProcessingInstruction pi = document.createProcessingInstruction(target, data); - if (pi != null) { - if (last == root && nextSibling != null) { - last.insertBefore(pi, nextSibling); - } else { - last.appendChild(pi); - } - - lastSibling = pi; - } - } - - /** - * This class is only used internally so this method should never be called. - */ - public void setDocumentLocator(Locator locator) { - } - - /** - * This class is only used internally so this method should never be called. - */ - public void skippedEntity(String name) { - } - - /** - * Lexical Handler method to create comment node in DOM tree. - */ - public void comment(char[] ch, int start, int length) { - final Node last = (Node)nodeStk.peek(); - Comment comment = document.createComment(new String(ch, start, length)); - if (comment != null) { - if (last == root && nextSibling != null) { - last.insertBefore(comment, nextSibling); - } else { - last.appendChild(comment); - } - - lastSibling = comment; - } - } - - // Lexical Handler methods- not implemented - public void startCDATA() { - } - - public void endCDATA() { - } - - public void startEntity(java.lang.String name) { - } - - public void endDTD() { - } - - public void endEntity(String name) { - } - - public void startDTD(String name, String publicId, String systemId) throws SAXException { - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/SAX2DOMPipe.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/SAX2DOMPipe.java deleted file mode 100644 index 79118b4a2c..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/SAX2DOMPipe.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.databinding.xml; - -import javax.xml.parsers.ParserConfigurationException; - -import org.apache.tuscany.spi.databinding.DataPipe; -import org.apache.tuscany.spi.databinding.Transformer; -import org.apache.tuscany.spi.databinding.extension.TransformerExtension; -import org.osoa.sca.annotations.Service; -import org.w3c.dom.Node; -import org.xml.sax.ContentHandler; - -@Service(Transformer.class) -public class SAX2DOMPipe extends TransformerExtension implements - DataPipe { - private SAX2DOM pipe; - - /** - * - */ - public SAX2DOMPipe() { - super(); - try { - this.pipe = new SAX2DOM(); - } catch (ParserConfigurationException e) { - throw new IllegalArgumentException(e); - } - } - - public Node getResult() { - return pipe.getDOM(); - } - - public Class getTargetType() { - return Node.class; - } - - public ContentHandler getSink() { - return pipe; - } - - public Class getSourceType() { - return ContentHandler.class; - } - - public int getWeight() { - return 30; - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Source2ResultTransformer.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Source2ResultTransformer.java deleted file mode 100755 index 7db14efb39..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Source2ResultTransformer.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.databinding.xml; - -import javax.xml.transform.Result; -import javax.xml.transform.Source; -import javax.xml.transform.TransformerFactory; - -import org.apache.tuscany.spi.databinding.PushTransformer; -import org.apache.tuscany.spi.databinding.TransformationContext; -import org.apache.tuscany.spi.databinding.TransformationException; -import org.apache.tuscany.spi.databinding.extension.TransformerExtension; -import org.osoa.sca.annotations.Service; - -/** - * Transform TrAX Source to Result - */ -@Service(org.apache.tuscany.spi.databinding.Transformer.class) -public class Source2ResultTransformer extends TransformerExtension implements - PushTransformer { - private static final TransformerFactory FACTORY = TransformerFactory.newInstance(); - - public void transform(Source source, Result result, TransformationContext context) { - try { - javax.xml.transform.Transformer transformer = FACTORY.newTransformer(); - transformer.transform(source, result); - } catch (Exception e) { - throw new TransformationException(e); - } - } - - public Class getSourceType() { - return Source.class; - } - - public Class getTargetType() { - return Result.class; - } - - public int getWeight() { - return 40; - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/StAX2SAXAdapter.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/StAX2SAXAdapter.java deleted file mode 100644 index 63fa53edb4..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/StAX2SAXAdapter.java +++ /dev/null @@ -1,256 +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.databinding.xml; - -import javax.xml.namespace.QName; -import javax.xml.stream.Location; -import javax.xml.stream.XMLStreamConstants; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; - -import org.xml.sax.Attributes; -import org.xml.sax.ContentHandler; -import org.xml.sax.Locator; -import org.xml.sax.SAXException; -import org.xml.sax.helpers.AttributesImpl; - -/** - * Adapter that converts from StAX to SAX event streams. Currently the following - * SAX events are not generated: - *
    - *
  • ignorableWhitespace
  • - *
  • skippedEntity
  • - *
      - * Also the following StAX events are not mapped: - *
        - *
      • CDATA
      • - *
      • COMMENT
      • - *
      • DTD
      • - *
      • ENTITY_DECLARATION
      • - *
      • ENTITY_REFERENCE
      • - *
      • NOTATION_DECLARATION
      • - *
      • SPACE
      • - *
      - * StAX ATTRIBUTE events are ignored but the equivalent attributes (derived from - * the START_ELEMENT event) are supplied in the SAX startElement event's - * Attributes parameter. If the adaptor is configured to pass namespace prefixes - * then namespace information will also be included in the Attributes; StAX - * NAMESPACE events are ignored.

      Another issue is namespace processing. If - * the reader is positioned at a sub-node, we cannot capture all the in-scope - * namespace bindings. Therefore we cannot re-create a proper SAX event stream - * from a StAX parser.

      For example

      <a:root xmlns:a="foo" - * xmlns:b="bar"><b:sub>a:foo</b:sub></a:root>

      And if - * you are handed a parser at <b:sub>, then your SAX events should look - * like:

      <b:sub xmlns:a="foo" xmlns:b="bar">a:foo</b:sub>

      - * not:

      <b:sub>a:foo</b:sub>

      Proposal: we change the - * receiver of SAX events (SDOXMLResourceImpl) so that it uses NamespaceContext - * to resolve prefix (as opposed to record start/endPrefixMappings and use it - * for resolution.) - * - * @version $Rev$ $Date$ - */ -public class StAX2SAXAdapter { - private final boolean namespacePrefixes; - - /** - * Construct a new StAX to SAX adapter that will convert a StAX event stream - * into a SAX event stream. - * - * @param namespacePrefixes whether xmlns attributes should be included in - * startElement events; - */ - public StAX2SAXAdapter(boolean namespacePrefixes) { - this.namespacePrefixes = namespacePrefixes; - } - - /** - * Pull events from the StAX stream and dispatch to the SAX ContentHandler. - * The StAX stream would typically be located on a START_DOCUMENT or - * START_ELEMENT event and when this method returns it will be located on - * the associated END_DOCUMENT or END_ELEMENT event. Behaviour with other - * start events is undefined. - * - * @param reader StAX event source to read - * @param handler SAX ContentHandler for processing events - * @throws XMLStreamException if there was a problem reading the stream - * @throws SAXException passed through from the ContentHandler - */ - public void parse(XMLStreamReader reader, ContentHandler handler) throws XMLStreamException, SAXException { - handler.setDocumentLocator(new LocatorAdaptor(reader.getLocation())); - - // remembers the nest level of elements to know when we are done - int level = 0; - int event = reader.getEventType(); - while (true) { - switch (event) { - case XMLStreamConstants.START_DOCUMENT: - level++; - handler.startDocument(); - break; - case XMLStreamConstants.START_ELEMENT: - level++; - handleStartElement(reader, handler); - break; - case XMLStreamConstants.PROCESSING_INSTRUCTION: - handler.processingInstruction(reader.getPITarget(), reader.getPIData()); - break; - case XMLStreamConstants.CHARACTERS: - handler.characters(reader.getTextCharacters(), reader.getTextStart(), reader - .getTextLength()); - break; - case XMLStreamConstants.END_ELEMENT: - handleEndElement(reader, handler); - level--; - if (level == 0) { - return; - } - break; - case XMLStreamConstants.END_DOCUMENT: - handler.endDocument(); - return; - /* - * uncomment to handle all events rather than just mapped - * ones // StAX events that are not mapped to SAX case - * XMLStreamConstants.COMMENT: case - * XMLStreamConstants.SPACE: case - * XMLStreamConstants.ENTITY_REFERENCE: case - * XMLStreamConstants.DTD: case XMLStreamConstants.CDATA: - * case XMLStreamConstants.NOTATION_DECLARATION: case - * XMLStreamConstants.ENTITY_DECLARATION: break; // StAX - * events handled in START_ELEMENT case - * XMLStreamConstants.ATTRIBUTE: case - * XMLStreamConstants.NAMESPACE: break; default: throw new - * AssertionError("Unknown StAX event: " + event); - */ - } - event = reader.next(); - } - } - - private void handleStartElement(XMLStreamReader reader, ContentHandler handler) throws SAXException { - // send startPrefixMapping events immediately before startElement event - int nsCount = reader.getNamespaceCount(); - for (int i = 0; i < nsCount; i++) { - String prefix = reader.getNamespacePrefix(i); - if (prefix == null) { // true for default namespace - prefix = ""; - } - handler.startPrefixMapping(prefix, reader.getNamespaceURI(i)); - } - - // fire startElement - QName qname = reader.getName(); - String prefix = qname.getPrefix(); - String rawname; - if (prefix == null || prefix.length() == 0) { - rawname = qname.getLocalPart(); - } else { - rawname = prefix + ':' + qname.getLocalPart(); - } - Attributes attrs = getAttributes(reader); - handler.startElement(qname.getNamespaceURI(), qname.getLocalPart(), rawname, attrs); - } - - private static void handleEndElement(XMLStreamReader reader, ContentHandler handler) throws SAXException { - // fire endElement - QName qname = reader.getName(); - handler.endElement(qname.getNamespaceURI(), qname.getLocalPart(), qname.toString()); - - // send endPrefixMapping events immediately after endElement event - // we send them in the opposite order to that returned but this is not - // actually required by SAX - int nsCount = reader.getNamespaceCount(); - for (int i = nsCount - 1; i >= 0; i--) { - String prefix = reader.getNamespacePrefix(i); - if (prefix == null) { // true for default namespace - prefix = ""; - } - handler.endPrefixMapping(prefix); - } - } - - /** - * Get the attributes associated with the current START_ELEMENT event. - * - * @return the StAX attributes converted to org.xml.sax.Attributes - */ - private Attributes getAttributes(XMLStreamReader reader) { - assert reader.getEventType() == XMLStreamConstants.START_ELEMENT; - - AttributesImpl attrs = new AttributesImpl(); - - // add namespace declarations if required - if (namespacePrefixes) { - for (int i = 0; i < reader.getNamespaceCount(); i++) { - String prefix = reader.getNamespacePrefix(i); - String uri = reader.getNamespaceURI(i); - attrs.addAttribute(null, prefix, "xmlns:" + prefix, "CDATA", uri); - } - } - - // Regular attributes - for (int i = 0; i < reader.getAttributeCount(); i++) { - String uri = reader.getAttributeNamespace(i); - if (uri == null) { - uri = ""; - } - String localName = reader.getAttributeLocalName(i); - String prefix = reader.getAttributePrefix(i); - String qname; - if (prefix == null || prefix.length() == 0) { - qname = localName; - } else { - qname = prefix + ':' + localName; - } - String type = reader.getAttributeType(i); - String value = reader.getAttributeValue(i); - - attrs.addAttribute(uri, localName, qname, type, value); - } - - return attrs; - } - - /** - * Adaptor for mapping Locator information. - */ - private static final class LocatorAdaptor implements Locator { - private final Location location; - - private LocatorAdaptor(Location location) { - this.location = location; - } - - public int getColumnNumber() { - return location == null ? 0 : location.getColumnNumber(); - } - - public int getLineNumber() { - return location == null ? 0 : location.getLineNumber(); - } - - public String getPublicId() { - return location == null ? "" : location.getPublicId(); - } - - public String getSystemId() { - return location == null ? "" : location.getSystemId(); - } - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/StAXHelper.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/StAXHelper.java deleted file mode 100755 index 5426384961..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/StAXHelper.java +++ /dev/null @@ -1,806 +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.databinding.xml; - -import java.io.InputStream; -import java.io.OutputStream; -import java.io.Reader; -import java.io.StringReader; -import java.io.StringWriter; -import java.io.Writer; -import java.util.NoSuchElementException; -import javax.xml.namespace.NamespaceContext; -import javax.xml.namespace.QName; -import javax.xml.stream.Location; -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLOutputFactory; -import javax.xml.stream.XMLStreamConstants; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import javax.xml.stream.XMLStreamWriter; -import javax.xml.transform.Source; - -public final class StAXHelper { - private static final XMLInputFactory INPUT_FACTORY = XMLInputFactory.newInstance(); - private static final XMLOutputFactory OUTPUT_FACTORY = XMLOutputFactory.newInstance(); - - private StAXHelper() { - } - - /** - * This class is derived from Apache Axis2 class org.apache.axis2.util.StreamWrapper. It's used wrap a - * XMLStreamReader to create a XMLStreamReader representing a document and it will produce START_DOCUMENT, - * END_DOCUMENT events. - */ - public static class XMLDocumentStreamReader implements XMLStreamReader { - private static final int STATE_COMPLETE_AT_NEXT = 2; // The wrapper - // will produce - // END_DOCUMENT - - private static final int STATE_COMPLETED = 3; // Done - - private static final int STATE_INIT = 0; // The wrapper will produce - // START_DOCUMENT - - private static final int STATE_SWITCHED = 1; // The real reader will - // produce events - - private XMLStreamReader realReader; - - private int state = STATE_INIT; - - public XMLDocumentStreamReader(XMLStreamReader realReader) { - if (realReader == null) { - throw new UnsupportedOperationException("Reader cannot be null"); - } - - this.realReader = realReader; - - // If the real reader is positioned at START_DOCUMENT, always use - // the real reader - if (realReader.getEventType() == START_DOCUMENT) { - state = STATE_SWITCHED; - } - } - - public void close() throws XMLStreamException { - realReader.close(); - } - - public int getAttributeCount() { - if (isDelegating()) { - return realReader.getAttributeCount(); - } else { - throw new IllegalStateException(); - } - } - - public String getAttributeLocalName(int i) { - if (isDelegating()) { - return realReader.getAttributeLocalName(i); - } else { - throw new IllegalStateException(); - } - } - - public QName getAttributeName(int i) { - if (isDelegating()) { - return realReader.getAttributeName(i); - } else { - throw new IllegalStateException(); - } - } - - public String getAttributeNamespace(int i) { - if (isDelegating()) { - return realReader.getAttributeNamespace(i); - } else { - throw new IllegalStateException(); - } - } - - public String getAttributePrefix(int i) { - if (isDelegating()) { - return realReader.getAttributePrefix(i); - } else { - throw new IllegalStateException(); - } - } - - public String getAttributeType(int i) { - if (isDelegating()) { - return realReader.getAttributeType(i); - } else { - throw new IllegalStateException(); - } - } - - public String getAttributeValue(int i) { - if (isDelegating()) { - return realReader.getAttributeValue(i); - } else { - throw new IllegalStateException(); - } - } - - public String getAttributeValue(String s, String s1) { - if (isDelegating()) { - return realReader.getAttributeValue(s, s1); - } else { - throw new IllegalStateException(); - } - } - - public String getCharacterEncodingScheme() { - return realReader.getCharacterEncodingScheme(); - } - - public String getElementText() throws XMLStreamException { - if (isDelegating()) { - return realReader.getElementText(); - } else { - throw new XMLStreamException(); - } - } - - public String getEncoding() { - return realReader.getEncoding(); - } - - public int getEventType() { - int event = -1; - switch (state) { - case STATE_SWITCHED: - case STATE_COMPLETE_AT_NEXT: - event = realReader.getEventType(); - break; - case STATE_INIT: - event = START_DOCUMENT; - break; - case STATE_COMPLETED: - event = END_DOCUMENT; - break; - } - return event; - } - - public String getLocalName() { - if (isDelegating()) { - return realReader.getLocalName(); - } else { - throw new IllegalStateException(); - } - } - - public Location getLocation() { - if (isDelegating()) { - return realReader.getLocation(); - } else { - return null; - } - } - - public QName getName() { - if (isDelegating()) { - return realReader.getName(); - } else { - throw new IllegalStateException(); - } - } - - public NamespaceContext getNamespaceContext() { - return realReader.getNamespaceContext(); - } - - public int getNamespaceCount() { - if (isDelegating()) { - return realReader.getNamespaceCount(); - } else { - throw new IllegalStateException(); - } - } - - public String getNamespacePrefix(int i) { - if (isDelegating()) { - return realReader.getNamespacePrefix(i); - } else { - throw new IllegalStateException(); - } - } - - public String getNamespaceURI() { - if (isDelegating()) { - return realReader.getNamespaceURI(); - } else { - throw new IllegalStateException(); - } - } - - public String getNamespaceURI(int i) { - if (isDelegating()) { - return realReader.getNamespaceURI(i); - } else { - throw new IllegalStateException(); - } - } - - public String getNamespaceURI(String s) { - if (isDelegating()) { - return realReader.getNamespaceURI(s); - } else { - throw new IllegalStateException(); - } - } - - public String getPIData() { - if (isDelegating()) { - return realReader.getPIData(); - } else { - throw new IllegalStateException(); - } - } - - public String getPITarget() { - if (isDelegating()) { - return realReader.getPITarget(); - } else { - throw new IllegalStateException(); - } - } - - public String getPrefix() { - if (isDelegating()) { - return realReader.getPrefix(); - } else { - throw new IllegalStateException(); - } - } - - public Object getProperty(String s) throws IllegalArgumentException { - if (isDelegating()) { - return realReader.getProperty(s); - } else { - throw new IllegalArgumentException(); - } - } - - public String getText() { - if (isDelegating()) { - return realReader.getText(); - } else { - throw new IllegalStateException(); - } - } - - public char[] getTextCharacters() { - if (isDelegating()) { - return realReader.getTextCharacters(); - } else { - throw new IllegalStateException(); - } - } - - public int getTextCharacters(int i, char[] chars, int i1, int i2) throws XMLStreamException { - if (isDelegating()) { - return realReader.getTextCharacters(i, chars, i1, i2); - } else { - throw new IllegalStateException(); - } - } - - public int getTextLength() { - if (isDelegating()) { - return realReader.getTextLength(); - } else { - throw new IllegalStateException(); - } - } - - public int getTextStart() { - if (isDelegating()) { - return realReader.getTextStart(); - } else { - throw new IllegalStateException(); - } - } - - public String getVersion() { - if (isDelegating()) { - return realReader.getVersion(); - } else { - return null; - } - } - - public boolean hasName() { - if (isDelegating()) { - return realReader.hasName(); - } else { - return false; - } - } - - public boolean hasNext() throws XMLStreamException { - if (state == STATE_COMPLETE_AT_NEXT) { - return true; - } else if (state == STATE_COMPLETED) { - return false; - } else if (state == STATE_SWITCHED) { - return realReader.hasNext(); - } else { - return true; - } - } - - public boolean hasText() { - if (isDelegating()) { - return realReader.hasText(); - } else { - return false; - } - } - - public boolean isAttributeSpecified(int i) { - if (isDelegating()) { - return realReader.isAttributeSpecified(i); - } else { - return false; - } - } - - public boolean isCharacters() { - if (isDelegating()) { - return realReader.isCharacters(); - } else { - return false; - } - } - - private boolean isDelegating() { - return state == STATE_SWITCHED || state == STATE_COMPLETE_AT_NEXT; - } - - public boolean isEndElement() { - if (isDelegating()) { - return realReader.isEndElement(); - } else { - return false; - } - } - - public boolean isStandalone() { - if (isDelegating()) { - return realReader.isStandalone(); - } else { - return false; - } - } - - public boolean isStartElement() { - if (isDelegating()) { - return realReader.isStartElement(); - } else { - return false; - } - } - - public boolean isWhiteSpace() { - if (isDelegating()) { - return realReader.isWhiteSpace(); - } else { - return false; - } - } - - public int next() throws XMLStreamException { - int returnEvent; - - switch (state) { - case STATE_SWITCHED: - returnEvent = realReader.next(); - if (returnEvent == END_DOCUMENT) { - state = STATE_COMPLETED; - } else if (!realReader.hasNext()) { - state = STATE_COMPLETE_AT_NEXT; - } - break; - case STATE_INIT: - state = STATE_SWITCHED; - returnEvent = realReader.getEventType(); - break; - case STATE_COMPLETE_AT_NEXT: - state = STATE_COMPLETED; - returnEvent = END_DOCUMENT; - break; - case STATE_COMPLETED: - // oops - no way we can go beyond this - throw new NoSuchElementException("End of stream has reached."); - default: - throw new UnsupportedOperationException(); - } - - return returnEvent; - } - - public int nextTag() throws XMLStreamException { - if (isDelegating()) { - return realReader.nextTag(); - } else { - throw new XMLStreamException(); - } - } - - public void require(int i, String s, String s1) throws XMLStreamException { - if (isDelegating()) { - realReader.require(i, s, s1); - } - } - - public boolean standaloneSet() { - if (isDelegating()) { - return realReader.standaloneSet(); - } else { - return false; - } - } - } - - public static interface XMLFragmentStreamReader extends XMLStreamReader { - - // this will help to handle Text within the current element. - // user should pass the element text to the property list as this - // ELEMENT_TEXT as the key. This key deliberately has a space in it - // so that it is not a valid XML name - String ELEMENT_TEXT = "Element Text"; - - /** - * Initiate the parser - this will do whatever the needed tasks to initiate the parser and must be called before - * attempting any specific parsing using this parser - */ - void init(); - - /** - * Extra method to query the state of the pullparser - */ - boolean isEndOfFragment(); - - /** - * add the parent namespace context to this parser - */ - void setParentNamespaceContext(NamespaceContext nsContext); - } - - /** - * The XMLStreamSerializer pulls events from the XMLStreamReader and dumps into the XMLStreamWriter - */ - public static class XMLStreamSerializer implements XMLStreamConstants { - public static final String NAMESPACE_PREFIX = "ns"; - private static int namespaceSuffix; - - /* - * The behavior of the serializer is such that it returns when it - * encounters the starting element for the second time. The depth - * variable tracks the depth of the serilizer and tells it when to - * return. Note that it is assumed that this serialization starts on an - * Element. - */ - - /** - * Field depth - */ - private int depth; - - /** - * Generates a unique namespace prefix that is not in the scope of the NamespaceContext - * - * @param nsCtxt - * @return string - */ - private String generateUniquePrefix(NamespaceContext nsCtxt) { - String prefix = NAMESPACE_PREFIX + namespaceSuffix++; - // null should be returned if the prefix is not bound! - while (nsCtxt.getNamespaceURI(prefix) != null) { - prefix = NAMESPACE_PREFIX + namespaceSuffix++; - } - - return prefix; - } - - /** - * Method serialize. - * - * @param node - * @param writer - * @throws XMLStreamException - */ - public void serialize(XMLStreamReader node, XMLStreamWriter writer) throws XMLStreamException { - serializeNode(node, writer); - } - - /** - * @param reader - * @param writer - * @throws XMLStreamException - */ - protected void serializeAttributes(XMLStreamReader reader, XMLStreamWriter writer) - throws XMLStreamException { - int count = reader.getAttributeCount(); - String prefix; - String namespaceName; - String writerPrefix; - for (int i = 0; i < count; i++) { - prefix = reader.getAttributePrefix(i); - namespaceName = reader.getAttributeNamespace(i); - /* - * Due to parser implementations returning null as the namespace - * URI (for the empty namespace) we need to make sure that we - * deal with a namespace name that is not null. The best way to - * work around this issue is to set the namespace uri to "" if - * it is null - */ - if (namespaceName == null) { - namespaceName = ""; - } - - writerPrefix = writer.getNamespaceContext().getPrefix(namespaceName); - - if (!"".equals(namespaceName)) { - // prefix has already being declared but this particular - // attrib has a - // no prefix attached. So use the prefix provided by the - // writer - if (writerPrefix != null && (prefix == null || prefix.equals(""))) { - writer.writeAttribute(writerPrefix, - namespaceName, - reader.getAttributeLocalName(i), - reader.getAttributeValue(i)); - - // writer prefix is available but different from the - // current - // prefix of the attrib. We should be decalring the new - // prefix - // as a namespace declaration - } else if (prefix != null && !"".equals(prefix) && !prefix.equals(writerPrefix)) { - writer.writeNamespace(prefix, namespaceName); - writer.writeAttribute(prefix, namespaceName, reader.getAttributeLocalName(i), reader - .getAttributeValue(i)); - - // prefix is null (or empty), but the namespace name is - // valid! it has not - // being written previously also. So we need to generate - // a prefix - // here - } else if (prefix == null || prefix.equals("")) { - prefix = generateUniquePrefix(writer.getNamespaceContext()); - writer.writeNamespace(prefix, namespaceName); - writer.writeAttribute(prefix, namespaceName, reader.getAttributeLocalName(i), reader - .getAttributeValue(i)); - } else { - writer.writeAttribute(prefix, namespaceName, reader.getAttributeLocalName(i), reader - .getAttributeValue(i)); - } - } else { - // empty namespace is equal to no namespace! - writer.writeAttribute(reader.getAttributeLocalName(i), reader.getAttributeValue(i)); - } - - } - } - - /** - * Method serializeCData. - * - * @param reader - * @param writer - * @throws XMLStreamException - */ - protected void serializeCData(XMLStreamReader reader, XMLStreamWriter writer) - throws XMLStreamException { - writer.writeCData(reader.getText()); - } - - /** - * Method serializeComment. - * - * @param reader - * @param writer - * @throws XMLStreamException - */ - protected void serializeComment(XMLStreamReader reader, XMLStreamWriter writer) - throws XMLStreamException { - writer.writeComment(reader.getText()); - } - - /** - * @param reader - * @param writer - * @throws XMLStreamException - */ - protected void serializeElement(XMLStreamReader reader, XMLStreamWriter writer) - throws XMLStreamException { - String prefix = reader.getPrefix(); - String nameSpaceName = reader.getNamespaceURI(); - if (nameSpaceName != null) { - String writerPrefix = writer.getPrefix(nameSpaceName); - if (writerPrefix != null) { - writer.writeStartElement(nameSpaceName, reader.getLocalName()); - } else { - if (prefix != null) { - writer.writeStartElement(prefix, reader.getLocalName(), nameSpaceName); - writer.writeNamespace(prefix, nameSpaceName); - writer.setPrefix(prefix, nameSpaceName); - } else { - writer.writeStartElement(nameSpaceName, reader.getLocalName()); - writer.writeDefaultNamespace(nameSpaceName); - writer.setDefaultNamespace(nameSpaceName); - } - } - } else { - writer.writeStartElement(reader.getLocalName()); - } - - // add the namespaces - int count = reader.getNamespaceCount(); - String namespacePrefix; - for (int i = 0; i < count; i++) { - namespacePrefix = reader.getNamespacePrefix(i); - if (namespacePrefix != null && namespacePrefix.length() == 0) { - continue; - } - - serializeNamespace(namespacePrefix, reader.getNamespaceURI(i), writer); - } - - // add attributes - serializeAttributes(reader, writer); - - } - - /** - * Method serializeEndElement. - * - * @param writer - * @throws XMLStreamException - */ - protected void serializeEndElement(XMLStreamWriter writer) throws XMLStreamException { - writer.writeEndElement(); - } - - /** - * Method serializeNamespace. - * - * @param prefix - * @param uri - * @param writer - * @throws XMLStreamException - */ - private void serializeNamespace(String prefix, String uri, XMLStreamWriter writer) - throws XMLStreamException { - String prefix1 = writer.getPrefix(uri); - if (prefix1 == null) { - writer.writeNamespace(prefix, uri); - writer.setPrefix(prefix, uri); - } - } - - /** - * Method serializeNode. - * - * @param reader - * @param writer - * @throws XMLStreamException - */ - protected void serializeNode(XMLStreamReader reader, XMLStreamWriter writer) - throws XMLStreamException { - // TODO We get the StAXWriter at this point and uses it hereafter - // assuming that this is the only entry point - // to this class. - // If there can be other classes calling methodes of this we might - // need to change methode signatures to - // OMOutputer - while (reader.hasNext()) { - int event = reader.next(); - if (event == START_ELEMENT) { - serializeElement(reader, writer); - depth++; - } else if (event == ATTRIBUTE) { - serializeAttributes(reader, writer); - } else if (event == CHARACTERS) { - serializeText(reader, writer); - } else if (event == COMMENT) { - serializeComment(reader, writer); - } else if (event == CDATA) { - serializeCData(reader, writer); - } else if (event == END_ELEMENT) { - serializeEndElement(writer); - depth--; - } else if (event == START_DOCUMENT) { - depth++; // if a start document is found then increment - // the depth - } else if (event == END_DOCUMENT) { - if (depth != 0) { - depth--; // for the end document - reduce the depth - } - try { - serializeEndElement(writer); - } catch (Exception e) { - // TODO: log exceptions - } - } - if (depth == 0) { - break; - } - } - } - - /** - * @param reader - * @param writer - * @throws XMLStreamException - */ - protected void serializeText(XMLStreamReader reader, XMLStreamWriter writer) - throws XMLStreamException { - writer.writeCharacters(reader.getText()); - } - } - - public static XMLStreamReader createXMLStreamReader(InputStream inputStream) throws XMLStreamException { - return INPUT_FACTORY.createXMLStreamReader(inputStream); - } - - public static XMLStreamReader createXMLStreamReader(Reader reader) throws XMLStreamException { - return INPUT_FACTORY.createXMLStreamReader(reader); - } - - public static XMLStreamReader createXMLStreamReader(Source source) throws XMLStreamException { - return INPUT_FACTORY.createXMLStreamReader(source); - } - - public static XMLStreamReader createXMLStreamReader(String string) throws XMLStreamException { - StringReader reader = new StringReader(string); - return createXMLStreamReader(reader); - } - - public static String save(XMLStreamReader reader) throws XMLStreamException { - StringWriter writer = new StringWriter(); - save(reader, writer); - return writer.toString(); - } - - public static void save(XMLStreamReader reader, OutputStream outputStream) throws XMLStreamException { - XMLStreamSerializer serializer = new XMLStreamSerializer(); - XMLStreamWriter streamWriter = OUTPUT_FACTORY.createXMLStreamWriter(outputStream); - serializer.serialize(reader, streamWriter); - streamWriter.flush(); - } - - public static void save(XMLStreamReader reader, Writer writer) throws XMLStreamException { - XMLStreamSerializer serializer = new XMLStreamSerializer(); - XMLStreamWriter streamWriter = OUTPUT_FACTORY.createXMLStreamWriter(writer); - serializer.serialize(reader, streamWriter); - streamWriter.flush(); - } - - public static void save(XMLStreamReader reader, XMLStreamWriter writer) throws XMLStreamException { - XMLStreamSerializer serializer = new XMLStreamSerializer(); - serializer.serialize(reader, writer); - writer.flush(); - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/StreamDataPipe.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/StreamDataPipe.java deleted file mode 100755 index d0b6ce07f2..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/StreamDataPipe.java +++ /dev/null @@ -1,57 +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.databinding.xml; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.InputStream; -import java.io.OutputStream; - -import org.apache.tuscany.spi.databinding.DataPipe; -import org.apache.tuscany.spi.databinding.Transformer; -import org.apache.tuscany.spi.databinding.extension.TransformerExtension; -import org.osoa.sca.annotations.Service; - -@Service(Transformer.class) -public class StreamDataPipe extends TransformerExtension implements - DataPipe { - - private ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); - - public InputStream getResult() { - return new ByteArrayInputStream(outputStream.toByteArray()); - } - - public Class getTargetType() { - return InputStream.class; - } - - public int getWeight() { - return 50; - } - - public OutputStream getSink() { - return outputStream; - } - - public Class getSourceType() { - return OutputStream.class; - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/String2Node.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/String2Node.java deleted file mode 100755 index 3f878a07b9..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/String2Node.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.databinding.xml; - -import java.io.StringReader; - -import javax.xml.parsers.DocumentBuilder; - -import org.apache.tuscany.spi.databinding.PullTransformer; -import org.apache.tuscany.spi.databinding.TransformationContext; -import org.apache.tuscany.spi.databinding.TransformationException; -import org.apache.tuscany.spi.databinding.Transformer; -import org.apache.tuscany.spi.databinding.extension.DOMHelper; -import org.apache.tuscany.spi.databinding.extension.TransformerExtension; -import org.osoa.sca.annotations.Service; -import org.w3c.dom.Node; -import org.xml.sax.InputSource; - -@Service(Transformer.class) -public class String2Node extends TransformerExtension implements PullTransformer { - - public Node transform(String source, TransformationContext context) { - try { - DocumentBuilder builder = DOMHelper.newDocumentBuilder(); - InputSource inputSource = new InputSource(new StringReader(source)); - return builder.parse(inputSource); - } catch (Exception e) { - throw new TransformationException(e); - } - } - - public Class getSourceType() { - return String.class; - } - - public Class getTargetType() { - return Node.class; - } - - public int getWeight() { - return 50; - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/String2SAX.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/String2SAX.java deleted file mode 100644 index 50ea110b17..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/String2SAX.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.databinding.xml; - -import java.io.StringReader; - -import org.apache.tuscany.spi.databinding.PushTransformer; -import org.apache.tuscany.spi.databinding.TransformationContext; -import org.apache.tuscany.spi.databinding.TransformationException; -import org.apache.tuscany.spi.databinding.Transformer; -import org.apache.tuscany.spi.databinding.extension.TransformerExtension; -import org.osoa.sca.annotations.Service; -import org.xml.sax.ContentHandler; -import org.xml.sax.InputSource; - -/** - * Transform XML string to SAX - */ -@Service(Transformer.class) -public class String2SAX extends TransformerExtension implements - PushTransformer { - - public void transform(String source, ContentHandler target, TransformationContext context) { - try { - new InputSource2SAX().transform(new InputSource(new StringReader(source)), target, context); - } catch (Exception e) { - throw new TransformationException(e); - } - } - - public Class getSourceType() { - return String.class; - } - - public Class getTargetType() { - return ContentHandler.class; - } - - public int getWeight() { - return 40; - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/String2XMLStreamReader.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/String2XMLStreamReader.java deleted file mode 100755 index 9793cc3f7e..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/String2XMLStreamReader.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.databinding.xml; - -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; - -import org.apache.tuscany.spi.databinding.PullTransformer; -import org.apache.tuscany.spi.databinding.TransformationContext; -import org.apache.tuscany.spi.databinding.TransformationException; -import org.apache.tuscany.spi.databinding.Transformer; -import org.apache.tuscany.spi.databinding.extension.TransformerExtension; -import org.osoa.sca.annotations.Service; - -@Service(Transformer.class) -public class String2XMLStreamReader extends TransformerExtension implements - PullTransformer { - - public XMLStreamReader transform(String source, TransformationContext context) { - try { - return StAXHelper.createXMLStreamReader(source); - } catch (XMLStreamException e) { - throw new TransformationException(e); - } - } - - public Class getSourceType() { - return String.class; - } - - public Class getTargetType() { - return XMLStreamReader.class; - } - - public int getWeight() { - return 50; - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Writer2ReaderDataPipe.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Writer2ReaderDataPipe.java deleted file mode 100755 index c66d0fd934..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/Writer2ReaderDataPipe.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.databinding.xml; - -import java.io.Reader; -import java.io.StringReader; -import java.io.StringWriter; -import java.io.Writer; - -import org.apache.tuscany.spi.databinding.DataPipe; -import org.apache.tuscany.spi.databinding.Transformer; -import org.apache.tuscany.spi.databinding.extension.TransformerExtension; -import org.osoa.sca.annotations.Service; - -@Service(Transformer.class) -public class Writer2ReaderDataPipe extends TransformerExtension implements DataPipe { - - private StringWriter writer = new StringWriter(); - - public Reader getResult() { - return new StringReader(writer.toString()); - } - - public Class getTargetType() { - return Reader.class; - } - - public int getWeight() { - return 50; - } - - public Writer getSink() { - return writer; - } - - public Class getSourceType() { - return Writer.class; - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/XMLStreamReader2Node.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/XMLStreamReader2Node.java deleted file mode 100644 index 6ecaa85be4..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/XMLStreamReader2Node.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.databinding.xml; - -import javax.xml.stream.XMLStreamReader; - -import org.apache.tuscany.spi.databinding.PullTransformer; -import org.apache.tuscany.spi.databinding.TransformationContext; -import org.apache.tuscany.spi.databinding.TransformationException; -import org.apache.tuscany.spi.databinding.Transformer; -import org.apache.tuscany.spi.databinding.extension.TransformerExtension; -import org.osoa.sca.annotations.Service; -import org.w3c.dom.Node; - -/** - * Transform DOM Node to XML XMLStreamReader - */ -@Service(Transformer.class) -public class XMLStreamReader2Node extends TransformerExtension implements - PullTransformer { - private SAX2DOMPipe pipe = new SAX2DOMPipe(); - - private XMLStreamReader2SAX stax2sax = new XMLStreamReader2SAX(); - - public Node transform(XMLStreamReader source, TransformationContext context) { - try { - stax2sax.transform(source, pipe.getSink(), context); - return pipe.getResult(); - } catch (Exception e) { - throw new TransformationException(e); - } - } - - public Class getSourceType() { - return XMLStreamReader.class; - } - - public Class getTargetType() { - return Node.class; - } - - public int getWeight() { - return 40; - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/XMLStreamReader2SAX.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/XMLStreamReader2SAX.java deleted file mode 100644 index 0c6f0b8df7..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/XMLStreamReader2SAX.java +++ /dev/null @@ -1,73 +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.databinding.xml; - -import javax.xml.stream.XMLStreamReader; - -import org.apache.tuscany.spi.databinding.PushTransformer; -import org.apache.tuscany.spi.databinding.TransformationContext; -import org.apache.tuscany.spi.databinding.TransformationException; -import org.apache.tuscany.spi.databinding.Transformer; -import org.apache.tuscany.spi.databinding.extension.TransformerExtension; -import org.osoa.sca.annotations.Service; -import org.xml.sax.ContentHandler; - -/** - * XMLStreamReader to SAX events - */ -@Service(Transformer.class) -public class XMLStreamReader2SAX extends TransformerExtension implements - PushTransformer { - - /** - * @see org.apache.tuscany.spi.databinding.PushTransformer#getSourceType() - */ - public Class getTargetType() { - return ContentHandler.class; - } - - /** - * @see org.apache.tuscany.spi.databinding.PushTransformer#getSourceType() - */ - public Class getSourceType() { - return XMLStreamReader.class; - } - - /** - * @see org.apache.tuscany.spi.databinding.PushTransformer#getWeight() - */ - public int getWeight() { - return 20; - } - - /** - * @see org.apache.tuscany.spi.databinding.PushTransformer#transform(java.lang.Object, - * java.lang.Object, - * org.apache.tuscany.spi.databinding.TransformationContext) - */ - public void transform(XMLStreamReader source, ContentHandler sink, TransformationContext context) { - StAX2SAXAdapter adapter = new StAX2SAXAdapter(false); - try { - adapter.parse(source, sink); - } catch (Exception e) { - throw new TransformationException(e); - } - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/XMLStreamReader2String.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/XMLStreamReader2String.java deleted file mode 100755 index 85ac7b5af6..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/XMLStreamReader2String.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.databinding.xml; - -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; - -import org.apache.tuscany.spi.databinding.PullTransformer; -import org.apache.tuscany.spi.databinding.TransformationContext; -import org.apache.tuscany.spi.databinding.TransformationException; -import org.apache.tuscany.spi.databinding.Transformer; -import org.apache.tuscany.spi.databinding.extension.TransformerExtension; -import org.osoa.sca.annotations.Service; - -@Service(Transformer.class) -public class XMLStreamReader2String extends TransformerExtension implements - PullTransformer { - - public String transform(XMLStreamReader source, TransformationContext context) { - try { - return StAXHelper.save(source); - } catch (XMLStreamException e) { - throw new TransformationException(e); - } - } - - public Class getSourceType() { - return XMLStreamReader.class; - } - - public Class getTargetType() { - return String.class; - } - - public int getWeight() { - return 40; - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/XMLStringDataBinding.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/XMLStringDataBinding.java deleted file mode 100644 index 39e9362524..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/databinding/xml/XMLStringDataBinding.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.databinding.xml; - -import org.apache.tuscany.spi.databinding.extension.DataBindingExtension; - -/** - * A DataBinding for the XML string - */ -public class XMLStringDataBinding extends DataBindingExtension { - public static final String NAME = String.class.getName(); - - public XMLStringDataBinding() { - super(NAME, String.class); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/deployer/AbstractDeploymentContext.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/deployer/AbstractDeploymentContext.java deleted file mode 100644 index c931cccde9..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/deployer/AbstractDeploymentContext.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.deployer; - -import java.net.URL; -import java.util.HashMap; -import java.util.Map; - -import org.apache.tuscany.spi.deployer.DeploymentContext; - -/** - * Base class for DeploymentContext implementations. - * - * @version $Rev$ $Date$ - */ -public abstract class AbstractDeploymentContext implements DeploymentContext { - private final ClassLoader classLoader; - private final URL scdlLocation; - private final Map properties = new HashMap(); - - protected AbstractDeploymentContext(ClassLoader classLoader, URL scdlLocation) { - this.classLoader = classLoader; - this.scdlLocation = scdlLocation; - } - - public ClassLoader getClassLoader() { - return classLoader; - } - - public URL getScdlLocation() { - return scdlLocation; - } - - public Object getExtension(String name) { - return properties.get(name); - } - - public void putExtension(String name, Object value) { - if (value == null) { - properties.remove(name); - } else { - properties.put(name, value); - } - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/deployer/ChildDeploymentContext.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/deployer/ChildDeploymentContext.java deleted file mode 100644 index c489ba04c3..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/deployer/ChildDeploymentContext.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.deployer; - -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 specifying the loader for application resources. - * - * @param parent the parent of this context - * @param classLoader the loader for application resources - * @param scdlLocation the location of the SCDL being deployed - */ - public ChildDeploymentContext(DeploymentContext parent, ClassLoader classLoader, URL scdlLocation) { - super(classLoader, scdlLocation); - assert parent != null; - this.parent = parent; - } - - public DeploymentContext getParent() { - return parent; - } - - public XMLInputFactory getXmlFactory() { - return parent.getXmlFactory(); - } - - public ScopeContainer getCompositeScope() { - return parent.getCompositeScope(); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/deployer/DeployerImpl.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/deployer/DeployerImpl.java deleted file mode 100644 index 303513f520..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/deployer/DeployerImpl.java +++ /dev/null @@ -1,145 +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 javax.xml.stream.XMLInputFactory; - -import org.apache.tuscany.spi.annotation.Autowire; -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.component.Component; -import org.apache.tuscany.spi.component.ComponentRegistrationException; -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.component.PrepareException; -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.deployer.Deployer; -import org.apache.tuscany.spi.deployer.DeploymentContext; -import org.apache.tuscany.spi.event.Event; -import org.apache.tuscany.spi.event.RuntimeEventListener; -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.api.annotation.Monitor; -import org.apache.tuscany.core.component.event.CompositeStop; -import org.apache.tuscany.core.component.scope.CompositeScopeContainer; - -/** - * Default implementation of Deployer. - * - * @version $Rev$ $Date$ - */ -public class DeployerImpl implements Deployer { - private XMLInputFactory xmlFactory; - private Loader loader; - private Builder builder; - private ScopeContainerMonitor monitor; - - public DeployerImpl(XMLInputFactory xmlFactory, Loader loader, Builder builder) { - this.xmlFactory = xmlFactory; - this.loader = loader; - this.builder = builder; - } - - public DeployerImpl() { - xmlFactory = XMLInputFactory.newInstance("javax.xml.stream.XMLInputFactory", getClass().getClassLoader()); - } - - @Autowire - public void setLoader(LoaderRegistry loader) { - this.loader = loader; - } - - @Autowire - public void setBuilder(BuilderRegistry builder) { - this.builder = builder; - } - - @Monitor - public void setMonitor(ScopeContainerMonitor monitor) { - this.monitor = monitor; - } - - public > Component deploy(CompositeComponent parent, - ComponentDefinition componentDefinition) - throws LoaderException, BuilderException, PrepareException { - final ScopeContainer scopeContainer = new CompositeScopeContainer(monitor); - scopeContainer.start(); - DeploymentContext deploymentContext = new RootDeploymentContext(null, xmlFactory, scopeContainer, null); - try { - load(parent, componentDefinition, deploymentContext); - } catch (LoaderException e) { - e.addContextName(componentDefinition.getName()); - throw e; - } - Component component = (Component) 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 CompositeStop) { - scopeContainer.stop(); - } - } - }; - component.addListener(listener); - component.prepare(); - try { - parent.register(component); - } catch (ComponentRegistrationException e) { - throw new BuilderInstantiationException("Error registering component", e); - } - return component; - } - - /** - * 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(CompositeComponent parent, - ComponentDefinition componentDefinition, - DeploymentContext deploymentContext) throws LoaderException { - loader.loadComponentType(parent, 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(CompositeComponent parent, - ComponentDefinition componentDefinition, - DeploymentContext deploymentContext) - throws BuilderException { - return builder.build(parent, componentDefinition, deploymentContext); - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/deployer/RootDeploymentContext.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/deployer/RootDeploymentContext.java deleted file mode 100644 index be5cc56d51..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/deployer/RootDeploymentContext.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.deployer; - -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 specifying the loader for application resources. - * - * @param classLoader the loader for application resources - * @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 scdlLocation the location of the SCDL being deployed - */ - public RootDeploymentContext(ClassLoader classLoader, - XMLInputFactory xmlFactory, - ScopeContainer scopeContainer, - URL scdlLocation) { - super(classLoader, scdlLocation); - this.xmlFactory = xmlFactory; - this.scopeContainer = scopeContainer; - } - - public DeploymentContext getParent() { - return null; - } - - public XMLInputFactory getXmlFactory() { - return xmlFactory; - } - - public ScopeContainer getCompositeScope() { - return scopeContainer; - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/idl/java/IllegalCallbackException.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/idl/java/IllegalCallbackException.java deleted file mode 100644 index f52bd4cfb1..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/idl/java/IllegalCallbackException.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.idl.java; - -import org.apache.tuscany.spi.idl.InvalidServiceContractException; - -/** - * Denotes an illegal callback interface - * - * @version $Rev$ $Date$ - */ - -public class IllegalCallbackException extends InvalidServiceContractException { - - public IllegalCallbackException(String message, String identifier) { - super(message, identifier); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/idl/java/InterfaceJavaLoader.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/idl/java/InterfaceJavaLoader.java deleted file mode 100644 index 9c272af719..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/idl/java/InterfaceJavaLoader.java +++ /dev/null @@ -1,118 +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.idl.java; - -import java.util.HashMap; -import java.util.Map; -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamConstants; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; - -import static org.osoa.sca.Version.XML_NAMESPACE_1_0; -import org.osoa.sca.annotations.Constructor; - -import org.apache.tuscany.spi.annotation.Autowire; -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.deployer.DeploymentContext; -import org.apache.tuscany.spi.extension.LoaderExtension; -import org.apache.tuscany.spi.idl.InvalidServiceContractException; -import org.apache.tuscany.spi.idl.java.JavaInterfaceProcessorRegistry; -import org.apache.tuscany.spi.idl.java.JavaServiceContract; -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.model.DataType; -import org.apache.tuscany.spi.model.InteractionScope; -import org.apache.tuscany.spi.model.ModelObject; - -import org.apache.tuscany.core.loader.StAXUtil; - -/** - * Loads a Java interface definition from an XML-based assembly file - * - * @version $Rev$ $Date$ - */ -public class InterfaceJavaLoader extends LoaderExtension { - public static final QName INTERFACE_JAVA = new QName(XML_NAMESPACE_1_0, "interface.java"); - - private final JavaInterfaceProcessorRegistry interfaceRegsitry; - - @Constructor({"registry", "interfaceRegsitry"}) - public InterfaceJavaLoader(@Autowire LoaderRegistry registry, - @Autowire JavaInterfaceProcessorRegistry interfaceRegistry) { - super(registry); - this.interfaceRegsitry = interfaceRegistry; - } - - public QName getXMLType() { - return INTERFACE_JAVA; - } - - public JavaServiceContract load(CompositeComponent parent, - ModelObject object, XMLStreamReader reader, - DeploymentContext deploymentContext) - throws XMLStreamException, LoaderException { - - assert INTERFACE_JAVA.equals(reader.getName()); - InteractionScope interactionScope = StAXUtil.interactionScope(reader.getAttributeValue(null, "scope")); - String name = reader.getAttributeValue(null, "interface"); - if (name == null) { - // allow "class" as well as seems to be a common mistake - name = reader.getAttributeValue(null, "class"); - } - if (name == null) { - throw new InvalidValueException("interface name not supplied"); - } - Class interfaceClass = LoaderUtil.loadClass(name, deploymentContext.getClassLoader()); - - name = reader.getAttributeValue(null, "callbackInterface"); - Class callbackClass = (name != null) ? LoaderUtil.loadClass(name, deploymentContext.getClassLoader()) : null; - - Map, ModelObject> extensions = new HashMap, ModelObject>(); - while (true) { - int event = reader.next(); - if (event == XMLStreamConstants.START_ELEMENT) { - ModelObject mo = registry.load(parent, null, reader, deploymentContext); - if (mo != null) { - extensions.put(mo.getClass(), mo); - } - } else if (event == XMLStreamConstants.END_ELEMENT && reader.getName().equals(INTERFACE_JAVA)) { - break; - } - } - JavaServiceContract serviceContract; - try { - serviceContract = interfaceRegsitry.introspect(interfaceClass, callbackClass); - } catch (InvalidServiceContractException e) { - throw new LoaderException(interfaceClass.getName(), e); - } - - // Set databinding from the SCDL extension - DataType dataType = (DataType) extensions.get(DataType.class); - if (dataType != null) { - serviceContract.setDataBinding(dataType.getDataBinding()); - } - serviceContract.getExtensions().putAll(extensions); - - serviceContract.setInteractionScope(interactionScope); - return serviceContract; - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/idl/java/JavaInterfaceProcessorRegistryImpl.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/idl/java/JavaInterfaceProcessorRegistryImpl.java deleted file mode 100644 index cd108ab238..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/idl/java/JavaInterfaceProcessorRegistryImpl.java +++ /dev/null @@ -1,162 +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.idl.java; - -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.osoa.sca.annotations.Callback; -import org.osoa.sca.annotations.EndConversation; -import org.osoa.sca.annotations.OneWay; -import org.osoa.sca.annotations.Remotable; -import org.osoa.sca.annotations.Scope; - -import org.apache.tuscany.spi.idl.InvalidConversationalOperationException; -import org.apache.tuscany.spi.idl.InvalidServiceContractException; -import org.apache.tuscany.spi.idl.OverloadedOperationException; -import org.apache.tuscany.spi.idl.java.JavaInterfaceProcessor; -import org.apache.tuscany.spi.idl.java.JavaInterfaceProcessorRegistry; -import org.apache.tuscany.spi.idl.java.JavaServiceContract; -import org.apache.tuscany.spi.model.DataType; -import org.apache.tuscany.spi.model.InteractionScope; -import org.apache.tuscany.spi.model.Operation; -import static org.apache.tuscany.spi.model.Operation.CONVERSATION_END; -import static org.apache.tuscany.spi.model.Operation.NO_CONVERSATION; - -import static org.apache.tuscany.core.util.JavaIntrospectionHelper.getBaseName; - -/** - * Default implementation of an InterfaceJavaIntrospector. - * - * @version $Rev$ $Date$ - */ -public class JavaInterfaceProcessorRegistryImpl implements JavaInterfaceProcessorRegistry { - public static final String IDL_INPUT = "idl:input"; - - private static final String UNKNOWN_DATABINDING = null; - - private List processors = new ArrayList(); - - public JavaInterfaceProcessorRegistryImpl() { - } - - public void registerProcessor(JavaInterfaceProcessor processor) { - processors.add(processor); - } - - public void unregisterProcessor(JavaInterfaceProcessor processor) { - processors.remove(processor); - } - - public JavaServiceContract introspect(Class type) throws InvalidServiceContractException { - Class callbackClass = null; - Callback callback = type.getAnnotation(Callback.class); - if (callback != null && !Void.class.equals(callback.value())) { - callbackClass = callback.value(); - } else if (callback != null && Void.class.equals(callback.value())) { - throw new IllegalCallbackException("No callback interface specified on annotation", type.getName()); - } - return introspect(type, callbackClass); - } - - public JavaServiceContract introspect(Class type, Class callback) - throws InvalidServiceContractException { - JavaServiceContract contract = new JavaServiceContract(); - contract.setInterfaceName(getBaseName(type)); - contract.setInterfaceClass(type); - boolean remotable = type.isAnnotationPresent(Remotable.class); - contract.setRemotable(remotable); - Scope interactionScope = type.getAnnotation(Scope.class); - boolean conversational = false; - if (interactionScope != null && "CONVERSATION".equalsIgnoreCase(interactionScope.value())) { - contract.setInteractionScope(InteractionScope.CONVERSATIONAL); - conversational = true; - } else { - contract.setInteractionScope(InteractionScope.NONCONVERSATIONAL); - } - contract.setOperations(getOperations(type, remotable, conversational)); - - if (callback != null) { - contract.setCallbackName(getBaseName(callback)); - contract.setCallbackClass(callback); - contract.setCallbackOperations(getOperations(callback, remotable, conversational)); - } - - for (JavaInterfaceProcessor processor : processors) { - processor.visitInterface(type, callback, contract); - } - return contract; - } - - private Map> getOperations(Class type, boolean remotable, boolean conversational) - throws InvalidServiceContractException { - Method[] methods = type.getMethods(); - Map> operations = new HashMap>(methods.length); - for (Method method : methods) { - String name = method.getName(); - if (remotable && operations.containsKey(name)) { - throw new OverloadedOperationException(method); - } - - Type returnType = method.getGenericReturnType(); - Type[] paramTypes = method.getGenericParameterTypes(); - Type[] faultTypes = method.getGenericExceptionTypes(); - boolean nonBlocking = method.isAnnotationPresent(OneWay.class); - int conversationSequence = NO_CONVERSATION; - if (method.isAnnotationPresent(EndConversation.class)) { - if (!conversational) { - throw new InvalidConversationalOperationException( - "Method is marked as end conversation but contract is not conversational", - method.getDeclaringClass().getName(), - method); - } - conversationSequence = CONVERSATION_END; - } else if (conversational) { - conversationSequence = Operation.CONVERSATION_CONTINUE; - } - - DataType returnDataType = new DataType(UNKNOWN_DATABINDING, returnType, returnType); - List> paramDataTypes = new ArrayList>(paramTypes.length); - for (Type paramType : paramTypes) { - paramDataTypes.add(new DataType(UNKNOWN_DATABINDING, paramType, paramType)); - } - List> faultDataTypes = new ArrayList>(faultTypes.length); - for (Type faultType : faultTypes) { - faultDataTypes.add(new DataType(UNKNOWN_DATABINDING, faultType, faultType)); - } - - DataType>> inputType = - new DataType>>(IDL_INPUT, Object[].class, paramDataTypes); - Operation operation = new Operation(name, - inputType, - returnDataType, - faultDataTypes, - nonBlocking, - UNKNOWN_DATABINDING, - conversationSequence); - operations.put(name, operation); - } - return operations; - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/IntrospectionRegistryImpl.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/IntrospectionRegistryImpl.java deleted file mode 100644 index 3dd1328b6a..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/IntrospectionRegistryImpl.java +++ /dev/null @@ -1,135 +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 java.lang.reflect.Constructor; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.deployer.DeploymentContext; -import org.apache.tuscany.spi.implementation.java.ImplementationProcessor; -import org.apache.tuscany.spi.implementation.java.IntrospectionRegistry; -import org.apache.tuscany.spi.implementation.java.JavaMappedProperty; -import org.apache.tuscany.spi.implementation.java.JavaMappedReference; -import org.apache.tuscany.spi.implementation.java.JavaMappedService; -import org.apache.tuscany.spi.implementation.java.PojoComponentType; -import org.apache.tuscany.spi.implementation.java.ProcessingException; - -import org.apache.tuscany.core.util.JavaIntrospectionHelper; - -/** - * Default implementation of the IntrospectionRegistry - * - * @version $Rev$ $Date$ - */ -public class IntrospectionRegistryImpl implements IntrospectionRegistry { - - private Monitor monitor; - private List cache = new ArrayList(); - - public IntrospectionRegistryImpl() { - } - - public IntrospectionRegistryImpl(Monitor monitor) { - this.monitor = monitor; - } - - @org.apache.tuscany.api.annotation.Monitor - public void setMonitor(Monitor monitor) { - this.monitor = monitor; - } - - public void registerProcessor(ImplementationProcessor processor) { - monitor.register(processor); - cache.add(processor); - } - - public void unregisterProcessor(ImplementationProcessor processor) { - monitor.unregister(processor); - cache.remove(processor); - } - - public PojoComponentType introspect(CompositeComponent parent, Class clazz, - PojoComponentType> type, - DeploymentContext context) - throws ProcessingException { - for (ImplementationProcessor processor : cache) { - processor.visitClass(parent, clazz, type, context); - } - - for (Constructor constructor : clazz.getConstructors()) { - for (ImplementationProcessor processor : cache) { - processor.visitConstructor(parent, constructor, type, context); - } - } - - Set methods = JavaIntrospectionHelper.getAllUniquePublicProtectedMethods(clazz); - for (Method method : methods) { - for (ImplementationProcessor processor : cache) { - processor.visitMethod(parent, method, type, context); - } - } - - Set fields = JavaIntrospectionHelper.getAllPublicAndProtectedFields(clazz); - for (Field field : fields) { - for (ImplementationProcessor processor : cache) { - processor.visitField(parent, field, type, context); - } - } - - Class superClass = clazz.getSuperclass(); - if (superClass != null) { - visitSuperClass(parent, superClass, type, context); - } - - for (ImplementationProcessor processor : cache) { - processor.visitEnd(parent, clazz, type, context); - } - return type; - } - - private void visitSuperClass(CompositeComponent parent, - Class clazz, - PojoComponentType> type, - DeploymentContext context) - throws ProcessingException { - if (!Object.class.equals(clazz)) { - for (ImplementationProcessor processor : cache) { - processor.visitSuperClass(parent, clazz, type, context); - } - clazz = clazz.getSuperclass(); - if (clazz != null) { - visitSuperClass(parent, clazz, type, context); - } - } - } - - public static interface Monitor { - void register(ImplementationProcessor processor); - - void unregister(ImplementationProcessor processor); - - void processing(ImplementationProcessor processor); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/PojoAtomicComponent.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/PojoAtomicComponent.java deleted file mode 100644 index 4ef4dc4d49..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/PojoAtomicComponent.java +++ /dev/null @@ -1,282 +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 java.lang.reflect.Field; -import java.lang.reflect.Member; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.tuscany.spi.ObjectCreationException; -import org.apache.tuscany.spi.ObjectFactory; -import org.apache.tuscany.spi.component.TargetDestructionException; -import org.apache.tuscany.spi.component.TargetInitializationException; -import org.apache.tuscany.spi.component.TargetResolutionException; -import org.apache.tuscany.spi.extension.AtomicComponentExtension; -import org.apache.tuscany.spi.model.Scope; -import org.apache.tuscany.spi.wire.OutboundWire; - -import org.apache.tuscany.core.injection.ArrayMultiplicityObjectFactory; -import org.apache.tuscany.core.injection.ConversationIDObjectFactory; -import org.apache.tuscany.core.injection.EventInvoker; -import org.apache.tuscany.core.injection.FieldInjector; -import org.apache.tuscany.core.injection.Injector; -import org.apache.tuscany.core.injection.InvalidAccessorException; -import org.apache.tuscany.core.injection.ListMultiplicityObjectFactory; -import org.apache.tuscany.core.injection.MethodInjector; -import org.apache.tuscany.core.injection.NoAccessorException; -import org.apache.tuscany.core.injection.NoMultiplicityTypeException; -import org.apache.tuscany.core.injection.ObjectCallbackException; -import org.apache.tuscany.core.injection.PojoObjectFactory; - -/** - * Base implementation of an {@link org.apache.tuscany.spi.component.AtomicComponent} whose type is a Java class - * - * @version $$Rev$$ $$Date$$ - */ -public abstract class PojoAtomicComponent extends AtomicComponentExtension { - protected EventInvoker initInvoker; - protected EventInvoker destroyInvoker; - protected PojoObjectFactory instanceFactory; - protected List constructorParamNames; - protected Map referenceSites; - protected Map resourceSites; - protected Map propertySites; - protected Map callbackSites; - protected List> injectors; - protected Class implementationClass; - private List> constructorParamTypes = new ArrayList>(); - - public PojoAtomicComponent(PojoConfiguration configuration) { - super(configuration.getName(), - configuration.getParent(), - configuration.getWireService(), - configuration.getWorkContext(), - configuration.getScheduler(), - configuration.getMonitor(), - configuration.getInitLevel(), - configuration.getMaxIdleTime(), - configuration.getMaxAge()); - assert configuration.getInstanceFactory() != null : "Object factory was null"; - initInvoker = configuration.getInitInvoker(); - destroyInvoker = configuration.getDestroyInvoker(); - instanceFactory = configuration.getInstanceFactory(); - constructorParamNames = configuration.getConstructorParamNames(); - constructorParamTypes = configuration.getConstructorParamTypes(); - injectors = new ArrayList>(); - referenceSites = configuration.getReferenceSite() != null ? configuration.getReferenceSite() - : new HashMap(); - propertySites = configuration.getPropertySites() != null ? configuration.getPropertySites() - : new HashMap(); - resourceSites = configuration.getResourceSites() != null ? configuration.getResourceSites() - : new HashMap(); - callbackSites = configuration.getCallbackSite() != null ? configuration.getCallbackSite() - : new HashMap(); - implementationClass = configuration.getImplementationClass(); - } - - - public boolean isDestroyable() { - return destroyInvoker != null; - } - - public void init(Object instance) throws TargetInitializationException { - if (initInvoker != null) { - try { - initInvoker.invokeEvent(instance); - } catch (ObjectCallbackException e) { - throw new TargetInitializationException("Error initializing component instance", getName(), e); - } - } - } - - public void destroy(Object instance) throws TargetDestructionException { - if (destroyInvoker != null) { - try { - destroyInvoker.invokeEvent(instance); - } catch (ObjectCallbackException e) { - throw new TargetDestructionException("Error destroying component instance", getName(), e); - } - } - } - - public boolean isOptimizable() { - // stateless implementations that require a destroy callback cannot be optimized since the callback is - // performed by the JavaTargetInvoker - return !(getScope() == Scope.STATELESS && isDestroyable()); - } - - public Object getTargetInstance() throws TargetResolutionException { - return scopeContainer.getInstance(this); - } - - public Object getAssociatedTargetInstance() throws TargetResolutionException { - return scopeContainer.getAssociatedInstance(this); - } - - public Object createInstance() throws ObjectCreationException { - Object instance = instanceFactory.getInstance(); - // inject the instance with properties and references - for (Injector injector : injectors) { - injector.inject(instance); - } - return instance; - } - - public void addPropertyFactory(String name, ObjectFactory factory) { - Member member = propertySites.get(name); - if (member instanceof Field) { - injectors.add(new FieldInjector((Field) member, factory)); - } else if (member instanceof Method) { - injectors.add(new MethodInjector((Method) member, factory)); - } - // cycle through constructor param names as well - for (int i = 0; i < constructorParamNames.size(); i++) { - if (name.equals(constructorParamNames.get(i))) { - ObjectFactory[] initializerFactories = instanceFactory.getInitializerFactories(); - initializerFactories[i] = factory; - break; - } - } - //FIXME throw an error if no injection site found - } - - public void addResourceFactory(String name, ObjectFactory factory) { - Member member = resourceSites.get(name); - if (member instanceof Field) { - injectors.add(new FieldInjector((Field) member, factory)); - } else if (member instanceof Method) { - injectors.add(new MethodInjector((Method) member, factory)); - } - // cycle through constructor param names as well - for (int i = 0; i < constructorParamNames.size(); i++) { - if (name.equals(constructorParamNames.get(i))) { - ObjectFactory[] initializerFactories = instanceFactory.getInitializerFactories(); - initializerFactories[i] = factory; - break; - } - } - //FIXME throw an error if no injection site found - } - - public void addConversationIDFactory(Member member) { - ObjectFactory convIDObjectFactory = new ConversationIDObjectFactory(workContext); - if (member instanceof Field) { - injectors.add(new FieldInjector((Field) member, convIDObjectFactory)); - } else if (member instanceof Method) { - injectors.add(new MethodInjector((Method) member, convIDObjectFactory)); - } else { - throw new InvalidAccessorException("Member must be a field or method", member.getName()); - } - } - - protected void onReferenceWire(OutboundWire wire) { - String name = wire.getReferenceName(); - Member member = referenceSites.get(name); - if (member != null) { - injectors.add(createInjector(member, wire)); - } - // cycle through constructor param names as well - for (int i = 0; i < constructorParamNames.size(); i++) { - if (name.equals(constructorParamNames.get(i))) { - ObjectFactory[] initializerFactories = instanceFactory.getInitializerFactories(); - initializerFactories[i] = createWireFactory(constructorParamTypes.get(i), wire); - break; - } - } - //TODO error if ref not set on constructor or ref site - } - - public void onReferenceWires(List wires) { - assert wires.size() > 0 : "Wires were empty"; - String referenceName = wires.get(0).getReferenceName(); - Member member = referenceSites.get(referenceName); - if (member == null) { - if (constructorParamNames.contains(referenceName)) { - // injected on the constructor - - } else { - throw new NoAccessorException(referenceName); - } - } - Class type = wires.get(0).getServiceContract().getInterfaceClass(); - if (type == null) { - throw new NoMultiplicityTypeException("Java interface must be specified for multiplicity", referenceName); - } - injectors.add(createMultiplicityInjector(member, type, wires)); - //TODO multiplicity for constructor injection - } - - public boolean implementsCallback(Class callbackClass) { - Class[] implementedInterfaces = implementationClass.getInterfaces(); - for (Class implementedInterface : implementedInterfaces) { - if (implementedInterface.isAssignableFrom(callbackClass)) { - return true; - } - } - - return false; - } - - protected Injector createInjector(Member member, OutboundWire wire) { - if (member instanceof Field) { - Class type = ((Field) member).getType(); - ObjectFactory factory = createWireFactory(type, wire); - return new FieldInjector((Field) member, factory); - } else if (member instanceof Method) { - Class type = ((Method) member).getParameterTypes()[0]; - ObjectFactory factory = createWireFactory(type, wire); - return new MethodInjector((Method) member, factory); - } else { - throw new InvalidAccessorException("Member must be a field or method", member.getName()); - } - } - - protected Injector createMultiplicityInjector(Member member, - Class interfaceType, - List wireFactories) { - List> factories = new ArrayList>(); - for (OutboundWire wire : wireFactories) { - factories.add(createWireFactory(interfaceType, wire)); - } - if (member instanceof Field) { - Field field = (Field) member; - if (field.getType().isArray()) { - return new FieldInjector(field, new ArrayMultiplicityObjectFactory(interfaceType, factories)); - } else { - return new FieldInjector(field, new ListMultiplicityObjectFactory(factories)); - } - } else if (member instanceof Method) { - Method method = (Method) member; - if (method.getParameterTypes()[0].isArray()) { - return new MethodInjector(method, new ArrayMultiplicityObjectFactory(interfaceType, factories)); - } else { - return new MethodInjector(method, new ListMultiplicityObjectFactory(factories)); - } - } else { - throw new InvalidAccessorException("Member must be a field or method", member.getName()); - } - } - - protected abstract ObjectFactory createWireFactory(Class interfaze, OutboundWire wire); - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/PojoConfiguration.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/PojoConfiguration.java deleted file mode 100644 index 104b1f647e..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/PojoConfiguration.java +++ /dev/null @@ -1,232 +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 java.lang.reflect.Member; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.component.WorkContext; -import org.apache.tuscany.spi.extension.ExecutionMonitor; -import org.apache.tuscany.spi.services.work.WorkScheduler; -import org.apache.tuscany.spi.wire.WireService; - -import org.apache.tuscany.core.injection.EventInvoker; -import org.apache.tuscany.core.injection.Injector; -import org.apache.tuscany.core.injection.PojoObjectFactory; - -/** - * Encapsulates confuration for a Java-based atomic component - * - * @version $Rev$ $Date$ - */ -public class PojoConfiguration { - private String name; - private CompositeComponent parent; - //private ScopeContainer scopeContainer; - private PojoObjectFactory instanceFactory; - private List constructorParamNames = new ArrayList(); - private List> constructorParamTypes = new ArrayList>(); - private int initLevel; - private EventInvoker initInvoker; - private EventInvoker destroyInvoker; - private List propertyInjectors = new ArrayList(); - private Map referenceSites = new HashMap(); - private Map propertySites = new HashMap(); - private Map resourceSites = new HashMap(); - private Map callbackSites = new HashMap(); - private WireService wireService; - private WorkContext workContext; - private WorkScheduler scheduler; - private ExecutionMonitor monitor; - private long maxIdleTime = -1; - private long maxAge = -1; - private Class implementationClass; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public CompositeComponent getParent() { - return parent; - } - - public void setParent(CompositeComponent parent) { - this.parent = parent; - } - - public PojoObjectFactory getInstanceFactory() { - return instanceFactory; - } - - public void setInstanceFactory(PojoObjectFactory objectFactory) { - this.instanceFactory = objectFactory; - } - - public List getConstructorParamNames() { - return constructorParamNames; - } - - public void setConstructorParamNames(List names) { - constructorParamNames = names; - } - - public void addConstructorParamName(String name) { - constructorParamNames.add(name); - } - - public List> getConstructorParamTypes() { - return constructorParamTypes; - } - - public void setConstructorParamTypes(List> constructorParamTypes) { - this.constructorParamTypes = constructorParamTypes; - } - - public void addConstructorParamType(Class type) { - constructorParamTypes.add(type); - } - - public int getInitLevel() { - return initLevel; - } - - public void setInitLevel(int initLevel) { - this.initLevel = initLevel; - } - - public long getMaxIdleTime() { - return maxIdleTime; - } - - public void setMaxIdleTime(long maxIdleTime) { - this.maxIdleTime = maxIdleTime; - } - - public long getMaxAge() { - return maxAge; - } - - public void setMaxAge(long maxAge) { - this.maxAge = maxAge; - } - - public EventInvoker getInitInvoker() { - return initInvoker; - } - - public void setInitInvoker(EventInvoker initInvoker) { - this.initInvoker = initInvoker; - } - - public EventInvoker getDestroyInvoker() { - return destroyInvoker; - } - - public void setDestroyInvoker(EventInvoker destroyInvoker) { - this.destroyInvoker = destroyInvoker; - } - - public List getPropertyInjectors() { - return propertyInjectors; - } - - public void addPropertyInjector(Injector injector) { - propertyInjectors.add(injector); - } - - public Map getReferenceSite() { - return referenceSites; - } - - public void addReferenceSite(String name, Member member) { - referenceSites.put(name, member); - } - - public Map getResourceSites() { - return resourceSites; - } - - public void addResourceSite(String name, Member member) { - resourceSites.put(name, member); - } - - public Map getCallbackSite() { - return callbackSites; - } - - public void addCallbackSite(String name, Member member) { - callbackSites.put(name, member); - } - - public Map getPropertySites() { - return propertySites; - } - - public void addPropertySite(String name, Member member) { - propertySites.put(name, member); - } - - public WireService getWireService() { - return wireService; - } - - public void setWireService(WireService wireService) { - this.wireService = wireService; - } - - public WorkContext getWorkContext() { - return workContext; - } - - public void setWorkContext(WorkContext workContext) { - this.workContext = workContext; - } - - public WorkScheduler getScheduler() { - return scheduler; - } - - public void setScheduler(WorkScheduler scheduler) { - this.scheduler = scheduler; - } - - public ExecutionMonitor getMonitor() { - return monitor; - } - - public void setMonitor(ExecutionMonitor monitor) { - this.monitor = monitor; - } - - public Class getImplementationClass() { - return implementationClass; - } - - public void setImplementationClass(Class implementationClass) { - this.implementationClass = implementationClass; - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/AbstractCompositeBuilder.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/AbstractCompositeBuilder.java deleted file mode 100644 index 965fde2fa8..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/AbstractCompositeBuilder.java +++ /dev/null @@ -1,71 +0,0 @@ -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.ComponentRegistrationException; -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.component.Reference; -import org.apache.tuscany.spi.component.Service; -import org.apache.tuscany.spi.deployer.DeploymentContext; -import org.apache.tuscany.spi.extension.ComponentBuilderExtension; -import org.apache.tuscany.spi.model.BoundReferenceDefinition; -import org.apache.tuscany.spi.model.BoundServiceDefinition; -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 CompositeComponent build(CompositeComponent parent, - CompositeComponent component, - CompositeComponentType componentType, - DeploymentContext deploymentContext) throws BuilderException { - - for (ComponentDefinition> definition : componentType.getComponents().values()) { - try { - Component child = builderRegistry.build(component, definition, deploymentContext); - component.register(child); - } catch (ComponentRegistrationException e) { - throw new BuilderInstantiationException("Error registering component", e); - } - } - for (ServiceDefinition definition : componentType.getServices().values()) { - try { - if (definition instanceof BoundServiceDefinition) { - BoundServiceDefinition bsd = (BoundServiceDefinition) definition; - Service service = builderRegistry.build(component, bsd, deploymentContext); - component.register(service); - } else { - throw new UnsupportedOperationException(); - } - } catch (ComponentRegistrationException e) { - throw new BuilderInstantiationException("Error registering service", e); - } - } - for (ReferenceDefinition definition : componentType.getReferences().values()) { - try { - if (definition instanceof BoundReferenceDefinition) { - BoundReferenceDefinition brd = (BoundReferenceDefinition) definition; - Reference child = builderRegistry.build(component, brd, deploymentContext); - component.register(child); - } else { - throw new UnsupportedOperationException(); - } - } catch (ComponentRegistrationException e) { - throw new BuilderInstantiationException("Error registering reference", e); - } - } - component.getExtensions().putAll(componentType.getExtensions()); - return component; - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/AbstractCompositeComponent.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/AbstractCompositeComponent.java deleted file mode 100644 index 0f10703802..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/AbstractCompositeComponent.java +++ /dev/null @@ -1,151 +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.util.List; -import java.util.Map; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - -import org.w3c.dom.Document; - -import org.apache.tuscany.spi.builder.Connector; -import org.apache.tuscany.spi.component.ComponentRegistrationException; -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.component.SCAObject; -import org.apache.tuscany.spi.component.TargetInvokerCreationException; -import org.apache.tuscany.spi.event.Event; -import org.apache.tuscany.spi.extension.CompositeComponentExtension; -import org.apache.tuscany.spi.model.Operation; -import org.apache.tuscany.spi.wire.InboundWire; -import org.apache.tuscany.spi.wire.TargetInvoker; - -import org.apache.tuscany.core.component.event.CompositeStart; -import org.apache.tuscany.core.component.event.CompositeStop; - -/** - * The base implementation of a composite context - * - * @version $Rev$ $Date$ - */ -public abstract class AbstractCompositeComponent 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; - - - /** - * @param name the name of the SCA composite - * @param parent the SCA composite parent - * @param connector the connector for fusing wires - * @param propertyValues the values of this composite's Properties - */ - public AbstractCompositeComponent(String name, - CompositeComponent parent, - Connector connector, - Map propertyValues) { - super(name, parent, connector, propertyValues); - } - - public void registerJavaObject(String name, Class service, I instance) - throws ComponentRegistrationException { - register(new SystemSingletonAtomicComponent(name, this, service, instance)); - } - - public void registerJavaObject(String name, List> services, I instance) - throws ComponentRegistrationException { - register(new SystemSingletonAtomicComponent(name, this, services, instance)); - } - - public void start() { - synchronized (lock) { - if (lifecycleState != UNINITIALIZED && lifecycleState != STOPPED) { - throw new IllegalStateException("Composite not in UNINITIALIZED state"); - } - - for (SCAObject child : systemChildren.values()) { - child.start(); - } - for (SCAObject child : children.values()) { - child.start(); - } - initializeLatch.countDown(); - initialized = true; - lifecycleState = INITIALIZED; - } - publish(new CompositeStart(this, this)); - } - - public void stop() { - if (lifecycleState == STOPPED) { - return; - } - - for (SCAObject child : children.values()) { - child.stop(); - } - for (SCAObject child : systemChildren.values()) { - child.stop(); - } - publish(new CompositeStop(this, this)); - // 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); - } - - public TargetInvoker createTargetInvoker(String targetName, Operation operation, InboundWire callbackWire) - throws TargetInvokerCreationException { - return null; - } - - /** - * 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(AbstractCompositeComponent.DEFAULT_WAIT, - TimeUnit.MILLISECONDS); - if (!success) { - throw new ComponentTimeoutException("Timeout waiting for context to initialize"); - } - } catch (InterruptedException e) { // should not happen - } - } - - } - - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/AbstractCompositeContext.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/AbstractCompositeContext.java deleted file mode 100644 index c571c04b3d..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/AbstractCompositeContext.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 org.osoa.sca.CompositeContext; -import org.osoa.sca.ServiceRuntimeException; - -import org.apache.tuscany.spi.QualifiedName; -import org.apache.tuscany.spi.component.Component; -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.component.Reference; -import org.apache.tuscany.spi.component.ReferenceBinding; -import org.apache.tuscany.spi.component.SCAObject; -import org.apache.tuscany.spi.component.Service; -import org.apache.tuscany.spi.component.ServiceBinding; -import org.apache.tuscany.spi.component.TargetResolutionException; -import org.apache.tuscany.spi.wire.InboundWire; -import org.apache.tuscany.spi.wire.Wire; -import org.apache.tuscany.spi.wire.WireService; - -/** - * Base implementation of the {@link org.osoa.sca.CompositeContext} - * - * @version $Rev$ $Date$ - */ -public abstract class AbstractCompositeContext implements CompositeContext { - protected final CompositeComponent composite; - protected final WireService wireService; - - public AbstractCompositeContext(final CompositeComponent composite, final WireService wireService) { - this.composite = composite; - this.wireService = wireService; - } - - public String getName() { - return composite.getName(); - } - - public String getURI() { - throw new UnsupportedOperationException(); - } - - public T locateService(Class serviceInterface, String serviceName) throws ServiceRuntimeException { - QualifiedName qName = new QualifiedName(serviceName); - if (qName.getPortName() == null) { - String name = serviceInterface.getName(); - qName = new QualifiedName(qName.getPartName(), name); - } - SCAObject child = composite.getChild(qName.getPartName()); - InboundWire wire = getInboundWire(child, qName); - if (wire.isOptimizable() - && wire.getServiceContract().getInterfaceClass() != null - && serviceInterface.isAssignableFrom(wire.getServiceContract().getInterfaceClass())) { - try { - return serviceInterface.cast(wire.getTargetService()); - } catch (TargetResolutionException e) { - throw new ServiceRuntimeException(e); - } - } - return wireService.createProxy(serviceInterface, wire); - } - - protected InboundWire getInboundWire(SCAObject child, QualifiedName qName) { - InboundWire wire = null; - if (child instanceof Component) { - wire = ((Component) child).getInboundWire(qName.getPortName()); - if (wire == null) { - throw new ServiceRuntimeException("Service not found [" + qName + "]"); - } - } else if (child instanceof Service) { - Service service = (Service) child; - for (ServiceBinding binding : service.getServiceBindings()) { - if (Wire.LOCAL_BINDING.equals(binding.getInboundWire().getBindingType())) { - wire = binding.getInboundWire(); - break; - } - } - if (wire == null) { - throw new ServiceRuntimeException("Local binding for service not found [" + qName + "]"); - } - } else if (child instanceof Reference) { - Reference service = (Reference) child; - if (service.getReferenceBindings().isEmpty()) { - throw new ServiceRuntimeException("No binding for reference [" + qName + "]"); - } - for (ReferenceBinding binding : service.getReferenceBindings()) { - if (Wire.LOCAL_BINDING.equals(binding.getInboundWire().getBindingType())) { - wire = binding.getInboundWire(); - break; - } - } - if (wire == null) { - // pick the first one - wire = service.getReferenceBindings().get(0).getInboundWire(); - } - } else if (child == null) { - throw new ServiceRuntimeException("Service not found [" + qName + "]"); - } else { - throw new ServiceRuntimeException("Invalid service type [" + child.getClass().getName() + "]"); - } - return wire; - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/ComponentTimeoutException.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/ComponentTimeoutException.java deleted file mode 100644 index ed64cb1236..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeBuilder.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeBuilder.java deleted file mode 100644 index 008c99db8d..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeBuilder.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.implementation.composite; - -import org.apache.tuscany.spi.builder.BuilderException; -import org.apache.tuscany.spi.component.Component; -import org.apache.tuscany.spi.component.CompositeComponent; -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(CompositeComponent parent, - ComponentDefinition componentDefinition, - DeploymentContext deploymentContext) throws BuilderException { - CompositeImplementation implementation = componentDefinition.getImplementation(); - CompositeComponentType componentType = implementation.getComponentType(); - String name = componentDefinition.getName(); - CompositeComponentImpl component = new CompositeComponentImpl(name, parent, connector, null); - - return build(parent, component, componentType, deploymentContext); - } - - protected Class getImplementationType() { - return CompositeImplementation.class; - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeComponentImpl.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeComponentImpl.java deleted file mode 100644 index 75bc2d8c78..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeComponentImpl.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.implementation.composite; - -import java.util.Map; - -import org.w3c.dom.Document; - -import org.apache.tuscany.spi.builder.Connector; -import org.apache.tuscany.spi.component.CompositeComponent; - -/** - * The standard implementation of a composite component. Autowiring is performed by delegating to the parent composite. - * - * @version $Rev$ $Date$ - */ -public class CompositeComponentImpl extends AbstractCompositeComponent { - private String uri; - private boolean systemComposite; - - /** - * Constructor specifying property values - * - * @param name the name of this Component - * @param parent this component's parent - * @param connector the connector to use for wires - * @param propertyValues this composite's Property values - */ - public CompositeComponentImpl(String name, - CompositeComponent parent, - Connector connector, - Map propertyValues) { - this(name, null, parent, connector, propertyValues); - } - - /** - * Constructor specifying if the composite is a system composite - * - * @param name the name of this Component - * @param parent this component's parent - * @param connector the connector to use for wires - * @param systemComposite true if the composite is a system composite - */ - public CompositeComponentImpl(String name, - CompositeComponent parent, - Connector connector, - boolean systemComposite) { - this(name, null, parent, connector, null, systemComposite); - } - - /** - * Constructor specifying name and URI. - * - * @param name the name of this Component - * @param uri the unique identifier for this component - * @param parent this component's parent - * @param connector the connector to use for wires - * @param propertyValues this composite's Property values - */ - public CompositeComponentImpl(String name, - String uri, - CompositeComponent parent, - Connector connector, - Map propertyValues) { - super(name, parent, connector, propertyValues); - this.uri = uri; - } - - /** - * Constructor specifying name and URI. - * - * @param name the name of this Component - * @param uri the unique identifier for this component - * @param parent this component's parent - * @param connector the connector to use for wires - * @param propertyValues this composite's Property values - * @param systemComposite true if the composite is a system composite - */ - public CompositeComponentImpl(String name, - String uri, - CompositeComponent parent, - Connector connector, - Map propertyValues, - boolean systemComposite) { - super(name, parent, connector, propertyValues); - this.uri = uri; - this.systemComposite = systemComposite; - } - - public String getURI() { - return uri; - } - - public boolean isSystem() { - return systemComposite; - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeComponentTypeLoader.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeComponentTypeLoader.java deleted file mode 100644 index c55f1b8ffa..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeComponentTypeLoader.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.implementation.composite; - -import java.net.URL; - -import org.apache.tuscany.spi.component.CompositeComponent; -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(CompositeComponent parent, CompositeImplementation implementation, - DeploymentContext deploymentContext) - throws LoaderException { - URL scdlLocation = implementation.getScdlLocation(); - ClassLoader cl = new CompositeClassLoader(implementation.getClassLoader()); - deploymentContext = new ChildDeploymentContext(deploymentContext, cl, scdlLocation); - CompositeComponentType componentType = loadFromSidefile(parent, scdlLocation, deploymentContext); - implementation.setComponentType(componentType); - } - - protected CompositeComponentType loadFromSidefile(CompositeComponent parent, - URL url, - DeploymentContext deploymentContext) - throws LoaderException { - return loaderRegistry.load(parent, null, url, CompositeComponentType.class, deploymentContext); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeLoader.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeLoader.java deleted file mode 100644 index b72c017cec..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeLoader.java +++ /dev/null @@ -1,235 +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 java.util.List; -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.Version.XML_NAMESPACE_1_0; - -import org.apache.tuscany.spi.QualifiedName; -import org.apache.tuscany.spi.annotation.Autowire; -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.deployer.CompositeClassLoader; -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.BoundServiceDefinition; -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.Artifact; -import org.apache.tuscany.spi.services.artifact.ArtifactRepository; - -import org.apache.tuscany.core.property.PropertyHelper; - -/** - * 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(XML_NAMESPACE_1_0, "composite"); - public static final String URI_DELIMITER = "/"; - - private final ArtifactRepository artifactRepository; - - public CompositeLoader(@Autowire LoaderRegistry registry, @Autowire ArtifactRepository artifactRepository) { - super(registry); - this.artifactRepository = artifactRepository; - } - - public QName getXMLType() { - return COMPOSITE; - } - - public CompositeComponentType load(CompositeComponent parent, - ModelObject object, - XMLStreamReader reader, - DeploymentContext deploymentContext) throws XMLStreamException, LoaderException { - CompositeComponentType> composite = - new CompositeComponentType>(); - composite.setName(reader.getAttributeValue(null, "name")); - boolean done = false; - while (!done) { - switch (reader.next()) { - case START_ELEMENT: - ModelObject o = registry.load(parent, composite, reader, deploymentContext); - if (o instanceof ServiceDefinition) { - composite.add((ServiceDefinition) o); - } else if (o instanceof ReferenceDefinition) { - composite.add((ReferenceDefinition) o); - } else if (o instanceof Property) { - composite.add((Property) o); - } else if (o instanceof ComponentDefinition) { - composite.add((ComponentDefinition) o); - } else if (o instanceof Include) { - composite.add((Include) o); - } else if (o instanceof Dependency) { - Artifact artifact = ((Dependency) o).getArtifact(); - if (artifactRepository != null) { - // default to jar type if not specified - if (artifact.getType() == null) { - artifact.setType("jar"); - } - artifactRepository.resolve(artifact); - } - if (artifact.getUrl() != null) { - ClassLoader classLoader = deploymentContext.getClassLoader(); - if (classLoader instanceof CompositeClassLoader) { - CompositeClassLoader ccl = (CompositeClassLoader) classLoader; - for (URL dep : artifact.getUrls()) { - ccl.addURL(dep); - } - } - } - } else if (o instanceof WireDefinition) { - composite.add((WireDefinition) o); - } else { - // add as an unknown model extension - if (o != null) { - composite.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(composite); - verifyCompositeCompleteness(composite); - done = true; - break; - } - } - } - for (ComponentDefinition> c : composite.getComponents().values()) { - PropertyHelper.processProperties(composite, c, deploymentContext); - } - return composite; - } - - protected void resolveWires(CompositeComponentType> composite) - throws InvalidWireException { - QualifiedName sourceName; - 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); - - sourceName = new QualifiedName(wire.getSource().getPath()); - serviceDefinition = composite.getDeclaredServices().get(sourceName.getPartName()); - if (serviceDefinition != null) { - if (serviceDefinition instanceof BoundServiceDefinition) { - ((BoundServiceDefinition) serviceDefinition).setTarget(wire.getTarget()); - } - } else { - componentDefinition = composite.getDeclaredComponents().get(sourceName.getPartName()); - if (componentDefinition != null) { - ReferenceTarget referenceTarget = createReferenceTarget(sourceName.getPortName(), - targetUri, - componentDefinition); - componentDefinition.add(referenceTarget); - } else { - throw new InvalidWireException("Source not found", sourceName.toString()); - } - } - } - } - - private ReferenceTarget createReferenceTarget(String 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.getName(); - } - } - - 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 instanceof BoundServiceDefinition && ((BoundServiceDefinition) svcDefn).getTarget() == null) { - throw new InvalidServiceException("Composite service not wired to a target", svcDefn.getName()); - } - } - } - - private void validateTarget(URI target, - CompositeComponentType> composite) - throws InvalidWireException { - QualifiedName targetName = new QualifiedName(target.getPath()); - // if target is not a reference of the composite - if (composite.getReferences().get(targetName.getPartName()) == null) { - ComponentDefinition targetDefinition = composite.getDeclaredComponents().get(targetName.getPartName()); - // if a target component exists in this composite - if (targetDefinition != null) { - Implementation implementation = targetDefinition.getImplementation(); - ComponentType componentType = implementation.getComponentType(); - Map services = componentType.getServices(); - if (targetName.getPortName() == null) { - if (services.size() > 1 || services.isEmpty()) { - throw new InvalidWireException("Ambiguous target", targetName.toString()); - } - } else { - if (services.get(targetName.getPortName()) == null) { - throw new InvalidWireException("Invalid target service", targetName.toString()); - } - } - } else { - throw new InvalidWireException("Target not found", targetName.toString()); - } - } - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/Dependency.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/Dependency.java deleted file mode 100644 index 808f36072f..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/Dependency.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.implementation.composite; - -import org.apache.tuscany.spi.model.ModelObject; -import org.apache.tuscany.spi.services.artifact.Artifact; - -/** - * A model object that represents a dependency on an external artifact. - * - * @version $Rev$ $Date$ - */ -public class Dependency extends ModelObject { - private Artifact artifact; - - public Artifact getArtifact() { - return artifact; - } - - public void setArtifact(Artifact artifact) { - this.artifact = artifact; - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/ImplementationCompositeLoader.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/ImplementationCompositeLoader.java deleted file mode 100644 index c814691185..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/ImplementationCompositeLoader.java +++ /dev/null @@ -1,126 +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.MalformedURLException; -import java.net.URL; -import java.util.Set; -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; - -import org.osoa.sca.Version; - -import org.apache.tuscany.spi.annotation.Autowire; -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.deployer.CompositeClassLoader; -import org.apache.tuscany.spi.deployer.DeploymentContext; -import org.apache.tuscany.spi.extension.LoaderExtension; -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.MissingResourceException; -import org.apache.tuscany.spi.model.CompositeImplementation; -import org.apache.tuscany.spi.model.ModelObject; -import org.apache.tuscany.spi.services.artifact.Artifact; -import org.apache.tuscany.spi.services.artifact.ArtifactRepository; - -/** - * Loader that handles an <implementation.composite> element. - * - * @version $Rev$ $Date$ - */ -public class ImplementationCompositeLoader extends LoaderExtension { - private static final QName IMPLEMENTATION_COMPOSITE = - new QName(Version.XML_NAMESPACE_1_0, "implementation.composite"); - - private final ArtifactRepository artifactRepository; - - public ImplementationCompositeLoader(@Autowire LoaderRegistry registry, - @Autowire ArtifactRepository artifactRepository) { - super(registry); - this.artifactRepository = artifactRepository; - } - - public QName getXMLType() { - return IMPLEMENTATION_COMPOSITE; - } - - public CompositeImplementation load(CompositeComponent parent, - ModelObject object, XMLStreamReader reader, - DeploymentContext deploymentContext) - throws XMLStreamException, LoaderException { - - assert IMPLEMENTATION_COMPOSITE.equals(reader.getName()); - String name = reader.getAttributeValue(null, "name"); - String group = reader.getAttributeValue(null, "group"); - String version = reader.getAttributeValue(null, "version"); - String scdlLocation = reader.getAttributeValue(null, "scdlLocation"); - String jarLocation = reader.getAttributeValue(null, "jarLocation"); - LoaderUtil.skipToEndElement(reader); - - CompositeImplementation impl = new CompositeImplementation(); - impl.setName(name); - if (scdlLocation != null) { - try { - impl.setScdlLocation(new URL(deploymentContext.getScdlLocation(), scdlLocation)); - } catch (MalformedURLException e) { - throw new InvalidValueException(scdlLocation, name, e); - } - impl.setClassLoader(deploymentContext.getClassLoader()); - } else if (jarLocation != null) { - URL jarUrl; - try { - jarUrl = new URL(deploymentContext.getScdlLocation(), jarLocation); - } catch (MalformedURLException e) { - throw new InvalidValueException(jarLocation, name, e); - } - try { - impl.setScdlLocation(new URL("jar:" + jarUrl.toExternalForm() + "!/META-INF/sca/default.scdl")); - } catch (MalformedURLException e) { - throw new AssertionError("Could not convert URL to a jar: url"); - } - impl.setClassLoader(new CompositeClassLoader(new URL[]{jarUrl}, deploymentContext.getClassLoader())); - } else if (artifactRepository != null && group != null && version != null) { - Artifact artifact = new Artifact(); - artifact.setGroup(group); - artifact.setName(name); - artifact.setVersion(version); - artifact.setType("jar"); - artifactRepository.resolve(artifact); - if (artifact.getUrl() == null) { - throw new MissingResourceException(artifact.toString(), name); - } - try { - impl.setScdlLocation(new URL("jar:" + artifact.getUrl() + "!/META-INF/sca/default.scdl")); - } catch (MalformedURLException e) { - throw new AssertionError(e); - } - Set artifactURLs = artifact.getUrls(); - URL[] urls = new URL[artifactURLs.size()]; - int i = 0; - for (URL artifactURL : artifactURLs) { - urls[i++] = artifactURL; - } - impl.setClassLoader(new CompositeClassLoader(urls, deploymentContext.getClassLoader())); - } - return impl; - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/ManagedCompositeContext.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/ManagedCompositeContext.java deleted file mode 100644 index 544eb75cdd..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/ManagedCompositeContext.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.implementation.composite; - -import org.osoa.sca.RequestContext; -import org.osoa.sca.ServiceReference; - -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.wire.WireService; - -/** - * The default implementation of a {@link org.osoa.sca.CompositeContext} injected on a component implementation - * instance - * - * @version $Rev$ $Date$ - */ -public class ManagedCompositeContext extends AbstractCompositeContext { - - /** - * Constructor. - * - * @param composite the parent composite of the component whose instance the current context is injected on - * @param wireService the wire service to use for generating proxies - */ - public ManagedCompositeContext(final CompositeComponent composite, final WireService wireService) { - super(composite, wireService); - } - - public String getName() { - return composite.getName(); - } - - public String getURI() { - throw new UnsupportedOperationException(); - } - - public RequestContext getRequestContext() { - throw new UnsupportedOperationException(); - } - - public ServiceReference createServiceReferenceForSession(Object self) { - throw new UnsupportedOperationException(); - } - - public ServiceReference createServiceReferenceForSession(Object self, String serviceName) { - throw new UnsupportedOperationException(); - } - - public ServiceReference newSession(String serviceName) { - throw new UnsupportedOperationException(); - } - - public ServiceReference newSession(String serviceName, Object sessionId) { - throw new UnsupportedOperationException(); - } - - public void start() { - throw new UnsupportedOperationException(); - } - - public void stop() { - throw new UnsupportedOperationException(); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/ManagedRequestContext.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/ManagedRequestContext.java deleted file mode 100644 index 9bc07582ee..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/ManagedRequestContext.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.implementation.composite; - -import javax.security.auth.Subject; - -import org.osoa.sca.RequestContext; -import org.osoa.sca.ServiceReference; - -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(); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/ReferenceImpl.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/ReferenceImpl.java deleted file mode 100644 index 3fcba7b054..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/ReferenceImpl.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.implementation.composite; - -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.CompositeComponent; -import org.apache.tuscany.spi.component.Reference; -import org.apache.tuscany.spi.component.ReferenceBinding; -import org.apache.tuscany.spi.model.Scope; -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(); - private boolean system; - - public ReferenceImpl(String name, CompositeComponent parent, ServiceContract contract) { - this(name, parent, contract, false); - } - - public ReferenceImpl(String name, - CompositeComponent parent, - ServiceContract contract, - boolean system) { - super(name, parent); - this.serviceContract = contract; - this.system = system; - } - - public Scope getScope() { - return Scope.SYSTEM; - } - - public ServiceContract getServiceContract() { - return serviceContract; - } - - public List getReferenceBindings() { - return Collections.unmodifiableList(bindings); - } - - public void addReferenceBinding(ReferenceBinding binding) { - binding.setReference(this); - 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(); - } - } - - @Override - public boolean isSystem() { - return system; - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/ServiceImpl.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/ServiceImpl.java deleted file mode 100644 index 2db8519ccc..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/ServiceImpl.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.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.CompositeComponent; -import org.apache.tuscany.spi.component.Service; -import org.apache.tuscany.spi.component.ServiceBinding; -import org.apache.tuscany.spi.model.Scope; -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 boolean system; - private URI targetUri; - - public ServiceImpl(String name, CompositeComponent parent, ServiceContract contract) { - this(name, parent, contract, null, false); - } - - public ServiceImpl(String name, - CompositeComponent parent, - ServiceContract contract, - URI targetUri, - boolean system) { - super(name, parent); - this.serviceContract = contract; - this.system = system; - this.targetUri = targetUri; - } - - public Scope getScope() { - return Scope.SYSTEM; - } - - public ServiceContract getServiceContract() { - return serviceContract; - } - - public URI getTargetUri() { - return targetUri; - } - - public List getServiceBindings() { - return Collections.unmodifiableList(bindings); - } - - public void addServiceBinding(ServiceBinding binding) { - binding.setService(this); - 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(); - } - } - - @Override - public boolean isSystem() { - return system; - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/SystemCompositeBuilder.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/SystemCompositeBuilder.java deleted file mode 100644 index 82fb5bf62e..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/SystemCompositeBuilder.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.implementation.composite; - -import org.apache.tuscany.spi.builder.BuilderException; -import org.apache.tuscany.spi.builder.BuilderRegistry; -import org.apache.tuscany.spi.builder.Connector; -import org.apache.tuscany.spi.component.CompositeComponent; -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.services.management.TuscanyManagementService; - -import org.apache.tuscany.core.implementation.system.model.SystemCompositeImplementation; - -/** - * Produces system composite components by evaluating an assembly. - * - * @version $Rev$ $Date$ - */ -public class SystemCompositeBuilder extends AbstractCompositeBuilder { - private TuscanyManagementService managementService; - - public SystemCompositeBuilder() { - } - - public SystemCompositeBuilder(BuilderRegistry builderRegistry, - Connector connector, - TuscanyManagementService managementService) { - this.builderRegistry = builderRegistry; - this.connector = connector; - this.managementService = managementService; - } - - public CompositeComponent build(CompositeComponent parent, - ComponentDefinition componentDefinition, - DeploymentContext deploymentContext) throws BuilderException { - SystemCompositeImplementation impl = componentDefinition.getImplementation(); - CompositeComponentType componentType = impl.getComponentType(); - String name = componentDefinition.getName(); - CompositeComponent component = new CompositeComponentImpl(name, parent, connector, true); - component.setManagementService(managementService); - build(parent, component, componentType, deploymentContext); - return component; - } - - protected Class getImplementationType() { - return SystemCompositeImplementation.class; - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/SystemSingletonAtomicComponent.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/SystemSingletonAtomicComponent.java deleted file mode 100644 index c8c14e2fad..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/composite/SystemSingletonAtomicComponent.java +++ /dev/null @@ -1,161 +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.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.tuscany.spi.ObjectCreationException; -import org.apache.tuscany.spi.component.AtomicComponent; -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.component.TargetDestructionException; -import org.apache.tuscany.spi.component.TargetInitializationException; -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.ServiceDefinition; -import org.apache.tuscany.spi.wire.InboundWire; -import org.apache.tuscany.spi.wire.OutboundWire; -import org.apache.tuscany.spi.wire.TargetInvoker; -import org.apache.tuscany.spi.wire.WireService; - -import org.apache.tuscany.core.wire.jdk.JDKWireService; - -/** - * 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 Map inboundWires; - private WireService wireService = new JDKWireService(); - - public SystemSingletonAtomicComponent(String name, CompositeComponent parent, Class interfaze, T instance) { - super(name, parent); - this.instance = instance; - inboundWires = new HashMap(); - initWire(interfaze); - } - - - public SystemSingletonAtomicComponent(String name, - CompositeComponent parent, - List> services, - T instance) { - super(name, parent); - this.instance = instance; - inboundWires = new HashMap(); - for (Class interfaze : services) { - initWire(interfaze); - } - } - - public Scope getScope() { - return Scope.COMPOSITE; - } - - public boolean isEagerInit() { - return false; - } - - public boolean isDestroyable() { - 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 void init(Object instance) throws TargetInitializationException { - - } - - public void destroy(Object instance) throws TargetDestructionException { - - } - - public Object createInstance() throws ObjectCreationException { - throw new UnsupportedOperationException(); - } - - public void removeInstance() { - throw new UnsupportedOperationException(); - } - - public void addInboundWire(InboundWire wire) { - inboundWires.put(wire.getServiceName(), wire); - } - - public Collection getInboundWires() { - return Collections.unmodifiableCollection(inboundWires.values()); - } - - public InboundWire getInboundWire(String serviceName) { - return inboundWires.get(serviceName); - } - - public void addOutboundWire(OutboundWire wire) { - throw new UnsupportedOperationException(); - } - - public void addOutboundWires(List wires) { - throw new UnsupportedOperationException(); - } - - public Map> getOutboundWires() { - return Collections.emptyMap(); - } - - - public TargetInvoker createTargetInvoker(String targetName, Operation operation, InboundWire callbackWire) { - return null; - } - - public boolean isSystem() { - return true; - } - - private void initWire(Class interfaze) { - JavaServiceContract serviceContract = new JavaServiceContract(interfaze); - ServiceDefinition def = new ServiceDefinition(interfaze.getName(), serviceContract, false); - InboundWire wire = wireService.createWire(def); - wire.setContainer(this); - inboundWires.put(wire.getServiceName(), wire); - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/JavaAtomicComponent.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/JavaAtomicComponent.java deleted file mode 100644 index bc087dd4c2..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/JavaAtomicComponent.java +++ /dev/null @@ -1,100 +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.java; - -import java.lang.reflect.Field; -import java.lang.reflect.Member; -import java.lang.reflect.Method; - -import org.apache.tuscany.spi.ObjectFactory; -import static org.apache.tuscany.spi.idl.java.JavaIDLUtils.findMethod; -import org.apache.tuscany.spi.model.Operation; -import org.apache.tuscany.spi.model.ServiceContract; -import org.apache.tuscany.spi.wire.InboundWire; -import org.apache.tuscany.spi.wire.OutboundWire; -import org.apache.tuscany.spi.wire.TargetInvoker; -import org.apache.tuscany.core.wire.WireObjectFactory; - -import org.apache.tuscany.core.implementation.PojoAtomicComponent; -import org.apache.tuscany.core.implementation.PojoConfiguration; -import org.apache.tuscany.core.injection.CallbackWireObjectFactory; -import org.apache.tuscany.core.injection.FieldInjector; -import org.apache.tuscany.core.injection.Injector; -import org.apache.tuscany.core.injection.InvalidAccessorException; -import org.apache.tuscany.core.injection.MethodInjector; - -/** - * The runtime instantiation of Java component implementations - * - * @version $Rev$ $Date$ - */ -public class JavaAtomicComponent extends PojoAtomicComponent { - - public JavaAtomicComponent(PojoConfiguration configuration) { - super(configuration); - } - - public TargetInvoker createTargetInvoker(String targetName, Operation operation, InboundWire callbackWire) { - Method[] methods; - Class callbackClass = null; - if (operation.isCallback()) { - callbackClass = operation.getServiceContract().getCallbackClass(); - methods = callbackClass.getMethods(); - - } else { - methods = operation.getServiceContract().getInterfaceClass().getMethods(); - } - Method method = findMethod(operation, methods); - return new JavaTargetInvoker(method, this, callbackWire, callbackClass, workContext, monitor); - } - - protected void onServiceWire(InboundWire wire) { - String name = wire.getCallbackReferenceName(); - if (name == null) { - // It's ok not to have one, we just do nothing - return; - } - Member member = callbackSites.get(name); - if (member != null) { - injectors.add(createCallbackInjector(member, wire.getServiceContract(), wire)); - } - } - - protected Injector createCallbackInjector(Member member, - ServiceContract contract, - InboundWire inboundWire) { - if (member instanceof Field) { - Field field = (Field) member; - ObjectFactory factory = new CallbackWireObjectFactory(field.getType(), wireService, inboundWire); - return new FieldInjector(field, factory); - } else if (member instanceof Method) { - Method method = (Method) member; - Class type = method.getParameterTypes()[0]; - ObjectFactory factory = new CallbackWireObjectFactory(type, wireService, inboundWire); - return new MethodInjector(method, factory); - } else { - throw new InvalidAccessorException("Member must be a field or method", member.getName()); - } - } - - @SuppressWarnings({"unchecked"}) - protected ObjectFactory createWireFactory(Class interfaze, OutboundWire wire) { - return new WireObjectFactory(interfaze, wire, wireService); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/JavaComponentBuilder.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/JavaComponentBuilder.java deleted file mode 100644 index 4f97965da9..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/JavaComponentBuilder.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.implementation.java; - -import java.lang.reflect.Constructor; -import java.lang.reflect.Member; -import java.lang.reflect.Method; - -import org.apache.tuscany.spi.ObjectFactory; -import org.apache.tuscany.spi.annotation.Autowire; -import org.apache.tuscany.spi.builder.BuilderConfigException; -import org.apache.tuscany.spi.component.AtomicComponent; -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.deployer.DeploymentContext; -import org.apache.tuscany.spi.extension.ComponentBuilderExtension; -import org.apache.tuscany.spi.host.ResourceHost; -import org.apache.tuscany.spi.implementation.java.ConstructorDefinition; -import org.apache.tuscany.spi.implementation.java.JavaMappedProperty; -import org.apache.tuscany.spi.implementation.java.JavaMappedReference; -import org.apache.tuscany.spi.implementation.java.JavaMappedService; -import org.apache.tuscany.spi.implementation.java.PojoComponentType; -import org.apache.tuscany.spi.implementation.java.Resource; -import org.apache.tuscany.spi.model.ComponentDefinition; -import org.apache.tuscany.spi.model.PropertyValue; - -import org.apache.tuscany.core.implementation.PojoConfiguration; -import org.apache.tuscany.core.injection.MethodEventInvoker; -import org.apache.tuscany.core.injection.PojoObjectFactory; -import org.apache.tuscany.core.injection.ResourceObjectFactory; - -/** - * Builds a Java-based atomic context from a component definition - * - * @version $$Rev$$ $$Date$$ - */ -public class JavaComponentBuilder extends ComponentBuilderExtension { - - private ResourceHost host; - - @Autowire - public void setHost(ResourceHost host) { - this.host = host; - } - - @SuppressWarnings("unchecked") - public AtomicComponent build(CompositeComponent parent, - ComponentDefinition definition, - DeploymentContext deployment) throws BuilderConfigException { - PojoComponentType> componentType = - definition.getImplementation().getComponentType(); - - PojoConfiguration configuration = new PojoConfiguration(); - configuration.setParent(parent); - if (definition.getInitLevel() != null) { - configuration.setInitLevel(definition.getInitLevel()); - } else { - configuration.setInitLevel(componentType.getInitLevel()); - } - if (componentType.getMaxAge() > 0) { - configuration.setMaxAge(componentType.getMaxAge()); - } else if (componentType.getMaxIdleTime() > 0) { - configuration.setMaxIdleTime(componentType.getMaxIdleTime()); - } - Method initMethod = componentType.getInitMethod(); - if (initMethod != null) { - configuration.setInitInvoker(new MethodEventInvoker(initMethod)); - } - Method destroyMethod = componentType.getDestroyMethod(); - if (destroyMethod != null) { - configuration.setDestroyInvoker(new MethodEventInvoker(destroyMethod)); - } - - configuration.setWireService(wireService); - configuration.setWorkContext(workContext); - configuration.setScheduler(workScheduler); - configuration.setImplementationClass(definition.getImplementation().getImplementationClass()); - - // setup property injection sites - for (JavaMappedProperty property : componentType.getProperties().values()) { - configuration.addPropertySite(property.getName(), property.getMember()); - } - - // setup reference injection sites - for (JavaMappedReference reference : componentType.getReferences().values()) { - Member member = reference.getMember(); - if (member != null) { - // could be null if the reference is mapped to a constructor - configuration.addReferenceSite(reference.getName(), member); - } - } - - for (Resource resource : componentType.getResources().values()) { - Member member = resource.getMember(); - if (member != null) { - // could be null if the resource is mapped to a constructor - configuration.addResourceSite(resource.getName(), member); - } - } - - // setup constructor injection - ConstructorDefinition ctorDef = componentType.getConstructorDefinition(); - Constructor constr = ctorDef.getConstructor(); - PojoObjectFactory instanceFactory = new PojoObjectFactory(constr); - configuration.setInstanceFactory(instanceFactory); - configuration.getConstructorParamNames().addAll(ctorDef.getInjectionNames()); - for (Class clazz : constr.getParameterTypes()) { - configuration.addConstructorParamType(clazz); - } - configuration.setMonitor(monitor); - configuration.setName(definition.getName()); - JavaAtomicComponent component = new JavaAtomicComponent(configuration); - - // handle properties - handleProperties(definition, component); - - // handle resources - handleResources(componentType, component, parent); - - handleCallbackSites(componentType, configuration); - - // FIXME JFM this should be refactored to be by operation - component.setAllowsPassByReference(componentType.isAllowsPassByReference()); - - if (componentType.getConversationIDMember() != null) { - component.addConversationIDFactory(componentType.getConversationIDMember()); - } - - return component; - } - - private void handleCallbackSites( - PojoComponentType> componentType, - PojoConfiguration configuration) { - for (JavaMappedService service : componentType.getServices().values()) { - // setup callback injection sites - if (service.getCallbackReferenceName() != null) { - // Only if there is a callback reference in the service - configuration.addCallbackSite(service.getCallbackReferenceName(), service.getCallbackMember()); - } - } - } - - @SuppressWarnings({"unchecked"}) - private void handleResources( - PojoComponentType> componentType, - JavaAtomicComponent component, - CompositeComponent parent) { - for (Resource resource : componentType.getResources().values()) { - ObjectFactory objectFactory = resource.getObjectFactory(); - if (objectFactory != null) { - component.addResourceFactory(resource.getName(), objectFactory); - } else { - String name = resource.getName(); - boolean optional = resource.isOptional(); - Class type = (Class) resource.getType(); - ResourceObjectFactory factory; - String mappedName = resource.getMappedName(); - if (mappedName == null) { - // by type - factory = new ResourceObjectFactory(type, optional, parent, host); - } else { - factory = new ResourceObjectFactory(type, mappedName, optional, parent, host); - } - component.addResourceFactory(name, factory); - } - } - } - - private void handleProperties(ComponentDefinition definition, JavaAtomicComponent component) { - for (PropertyValue property : definition.getPropertyValues().values()) { - ObjectFactory factory = property.getValueFactory(); - if (factory != null) { - component.addPropertyFactory(property.getName(), factory); - } - } - } - - protected Class getImplementationType() { - return JavaImplementation.class; - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/JavaComponentTypeLoader.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/JavaComponentTypeLoader.java deleted file mode 100644 index ddfef5a2a2..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/JavaComponentTypeLoader.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.implementation.java; - -import java.net.URL; - -import org.osoa.sca.annotations.Constructor; - -import org.apache.tuscany.spi.annotation.Autowire; -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.deployer.DeploymentContext; -import org.apache.tuscany.spi.extension.ComponentTypeLoaderExtension; -import org.apache.tuscany.spi.implementation.java.IntrospectionRegistry; -import org.apache.tuscany.spi.implementation.java.Introspector; -import org.apache.tuscany.spi.implementation.java.JavaMappedProperty; -import org.apache.tuscany.spi.implementation.java.JavaMappedReference; -import org.apache.tuscany.spi.implementation.java.JavaMappedService; -import org.apache.tuscany.spi.implementation.java.PojoComponentType; -import org.apache.tuscany.spi.implementation.java.ProcessingException; -import org.apache.tuscany.spi.loader.LoaderException; -import org.apache.tuscany.spi.loader.LoaderRegistry; - -import org.apache.tuscany.core.util.JavaIntrospectionHelper; - -/** - * @version $Rev$ $Date$ - */ -public class JavaComponentTypeLoader extends ComponentTypeLoaderExtension { - private Introspector introspector; - - @Constructor({"registry", "introspector"}) - public JavaComponentTypeLoader(@Autowire LoaderRegistry loaderRegistry, - @Autowire IntrospectionRegistry introspector) { - super(loaderRegistry); - this.introspector = introspector; - } - - @Override - protected Class getImplementationClass() { - return JavaImplementation.class; - } - - public void load(CompositeComponent parent, - JavaImplementation implementation, - DeploymentContext deploymentContext) throws LoaderException { - Class implClass = implementation.getImplementationClass(); - URL resource = implClass.getResource(JavaIntrospectionHelper.getBaseName(implClass) + ".componentType"); - PojoComponentType componentType; - if (resource == null) { - componentType = loadByIntrospection(parent, implementation, deploymentContext); - } else { - componentType = loadFromSidefile(parent, resource, deploymentContext); - } - implementation.setComponentType(componentType); - } - - protected PojoComponentType loadByIntrospection(CompositeComponent parent, - JavaImplementation implementation, - DeploymentContext deploymentContext) throws ProcessingException { - PojoComponentType> componentType = - new PojoComponentType>(); - Class implClass = implementation.getImplementationClass(); - introspector.introspect(parent, implClass, componentType, deploymentContext); - return componentType; - } - - protected PojoComponentType loadFromSidefile(CompositeComponent parent, - URL url, - DeploymentContext deploymentContext) throws LoaderException { - PojoComponentType> componentType = - new PojoComponentType>(); - return loaderRegistry.load(parent, componentType, url, PojoComponentType.class, deploymentContext); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/JavaImplementation.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/JavaImplementation.java deleted file mode 100644 index 807db532fe..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/JavaImplementation.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.implementation.java; - -import org.apache.tuscany.spi.model.AtomicImplementation; -import org.apache.tuscany.spi.implementation.java.PojoComponentType; - -/** - * @version $$Rev$$ $$Date$$ - */ -public class JavaImplementation extends AtomicImplementation { - private Class implementationClass; - - public Class getImplementationClass() { - return implementationClass; - } - - public void setImplementationClass(Class implementationClass) { - this.implementationClass = implementationClass; - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/JavaImplementationLoader.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/JavaImplementationLoader.java deleted file mode 100644 index 2ba538486d..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/JavaImplementationLoader.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.java; - -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; - -import static org.osoa.sca.Version.XML_NAMESPACE_1_0; -import org.osoa.sca.annotations.Constructor; - -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.extension.LoaderExtension; -import org.apache.tuscany.spi.loader.LoaderException; -import org.apache.tuscany.spi.loader.LoaderUtil; -import org.apache.tuscany.spi.loader.LoaderRegistry; -import org.apache.tuscany.spi.model.ModelObject; -import org.apache.tuscany.spi.deployer.DeploymentContext; -import org.apache.tuscany.spi.annotation.Autowire; - -public class JavaImplementationLoader extends LoaderExtension { - public static final QName IMPLEMENTATION_JAVA = new QName(XML_NAMESPACE_1_0, "implementation.java"); - - @Constructor({"registry"}) - public JavaImplementationLoader(@Autowire LoaderRegistry registry) { - super(registry); - } - - @Override - public QName getXMLType() { - return IMPLEMENTATION_JAVA; - } - - public ModelObject load(CompositeComponent parent, ModelObject object, XMLStreamReader reader, - DeploymentContext deploymentContext) - throws XMLStreamException, LoaderException { - assert IMPLEMENTATION_JAVA.equals(reader.getName()); - JavaImplementation implementation = new JavaImplementation(); - String implClass = reader.getAttributeValue(null, "class"); - Class implementationClass = LoaderUtil.loadClass(implClass, deploymentContext.getClassLoader()); - implementation.setImplementationClass(implementationClass); - registry.loadComponentType(parent, implementation, deploymentContext); - LoaderUtil.skipToEndElement(reader); - return implementation; - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/JavaTargetInvoker.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/JavaTargetInvoker.java deleted file mode 100644 index 6da60304fa..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/JavaTargetInvoker.java +++ /dev/null @@ -1,144 +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.java; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.Set; - -import org.osoa.sca.NoRegisteredCallbackException; - -import org.apache.tuscany.spi.component.ComponentException; -import org.apache.tuscany.spi.component.InvalidConversationSequenceException; -import org.apache.tuscany.spi.component.TargetException; -import org.apache.tuscany.spi.component.WorkContext; -import org.apache.tuscany.spi.extension.ExecutionMonitor; -import org.apache.tuscany.spi.extension.TargetInvokerExtension; -import org.apache.tuscany.spi.model.Scope; -import org.apache.tuscany.spi.wire.InboundWire; - -import static org.apache.tuscany.core.util.JavaIntrospectionHelper.findClosestMatchingMethod; -import static org.apache.tuscany.core.util.JavaIntrospectionHelper.getAllUniquePublicProtectedMethods; - -/** - * Responsible for synchronously dispatching an invocation to a Java component implementation instance - * - * @version $Rev$ $Date$ - */ -public class JavaTargetInvoker extends TargetInvokerExtension { - protected Method operation; - protected JavaAtomicComponent component; - protected Object target; - protected Class callbackClass; - protected boolean stateless; - - public JavaTargetInvoker(Method operation, - JavaAtomicComponent component, - InboundWire wire, - Class callbackClass, - WorkContext context, - ExecutionMonitor monitor) { - super(wire, context, monitor); - assert operation != null : "Operation method cannot be null"; - this.operation = operation; - this.component = component; - stateless = Scope.STATELESS == component.getScope(); - this.callbackClass = callbackClass; - } - - public JavaTargetInvoker(Method operation, - JavaAtomicComponent component, - InboundWire callbackWire, - WorkContext context, - ExecutionMonitor monitor) { - this(operation, component, callbackWire, null, context, monitor); - } - - public Object invokeTarget(final Object payload, final short sequence) throws InvocationTargetException { - try { - Object instance = getInstance(sequence); - if (callbackClass != null && !callbackClass.isInstance(instance)) { - throw new InvocationTargetException( - new NoRegisteredCallbackException("Instance is does not implement callback [" - + callbackClass.toString() + "]")); - } - if (!operation.getDeclaringClass().isInstance(instance)) { - Set methods = getAllUniquePublicProtectedMethods(instance.getClass()); - Method newOperation = findClosestMatchingMethod(operation.getName(), - operation.getParameterTypes(), methods); - if (newOperation != null) { - operation = newOperation; - } - } - Object ret; - if (payload != null && !payload.getClass().isArray()) { - ret = operation.invoke(instance, payload); - } else { - ret = operation.invoke(instance, (Object[]) payload); - } - if (stateless) { - // notify a stateless instance of a destruction event after the invoke - component.destroy(instance); - } else if (sequence == END) { - component.destroy(instance); - // if end conversation, remove resource - component.removeInstance(); - } - return ret; - } catch (IllegalAccessException e) { - throw new InvocationTargetException(e); - } catch (ComponentException e) { - throw new InvocationTargetException(e); - } - } - - @Override - public JavaTargetInvoker clone() throws CloneNotSupportedException { - try { - JavaTargetInvoker invoker = (JavaTargetInvoker) super.clone(); - invoker.target = null; - return invoker; - } catch (CloneNotSupportedException e) { - return null; // will not happen - } - } - - /** - * Resolves the target service instance or returns a cached one - */ - protected Object getInstance(short sequence) throws TargetException { - if (!cacheable) { - if (sequence == START || sequence == NONE) { - return component.getTargetInstance(); - } else if (sequence == CONTINUE || sequence == END) { - return component.getAssociatedTargetInstance(); - } else { - throw new InvalidConversationSequenceException("Unknown sequence type", String.valueOf(sequence)); - } - } else { - assert sequence == NONE; // conversations are not cacheable - if (target == null) { - target = component.getTargetInstance(); - } - return target; - } - } - - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/AllowsPassByReferenceProcessor.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/AllowsPassByReferenceProcessor.java deleted file mode 100644 index 53ad52e110..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/AllowsPassByReferenceProcessor.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.processor; - -import org.osoa.sca.annotations.AllowsPassByReference; - -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.deployer.DeploymentContext; -import org.apache.tuscany.spi.implementation.java.ImplementationProcessorExtension; -import org.apache.tuscany.spi.implementation.java.JavaMappedProperty; -import org.apache.tuscany.spi.implementation.java.JavaMappedReference; -import org.apache.tuscany.spi.implementation.java.JavaMappedService; -import org.apache.tuscany.spi.implementation.java.PojoComponentType; -import org.apache.tuscany.spi.implementation.java.ProcessingException; - -/** - * Processes {@link AllowsPassByReference} on an implementation - * - * @version $Rev: 479093 $ $Date: 2006-11-25 12:34:41 +0530 (Sat, 25 Nov 2006) $ - */ -public class AllowsPassByReferenceProcessor extends ImplementationProcessorExtension { - - public void visitClass(CompositeComponent parent, Class clazz, - PojoComponentType> type, - DeploymentContext context) - throws ProcessingException { - AllowsPassByReference annotation = clazz.getAnnotation(AllowsPassByReference.class); - if (annotation != null) { - type.setAllowsPassByReference(true); - } else { - type.setAllowsPassByReference(false); - } - - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/AmbiguousConstructorException.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/AmbiguousConstructorException.java deleted file mode 100644 index 03d092880d..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/AmbiguousConstructorException.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.implementation.processor; - -import org.apache.tuscany.spi.implementation.java.ProcessingException; - -/** - * Thrown when constructor parameters cannot be unambiguously resolved to a property or reference - * - * @version $Rev$ $Date$ - */ -public class AmbiguousConstructorException extends ProcessingException { - - public AmbiguousConstructorException(String message) { - super(message); - } - - public AmbiguousConstructorException(String message, String identifier) { - super(message, identifier); - } - - public AmbiguousConstructorException(String message, String identifier, Throwable cause) { - super(message, identifier, cause); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ConstructorProcessor.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ConstructorProcessor.java deleted file mode 100644 index f8fc449679..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ConstructorProcessor.java +++ /dev/null @@ -1,106 +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.processor; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Constructor; -import java.util.List; - -import org.apache.tuscany.spi.annotation.Autowire; -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.deployer.DeploymentContext; -import org.apache.tuscany.spi.implementation.java.ConstructorDefinition; -import org.apache.tuscany.spi.implementation.java.ImplementationProcessorExtension; -import org.apache.tuscany.spi.implementation.java.ImplementationProcessorService; -import org.apache.tuscany.spi.implementation.java.JavaMappedProperty; -import org.apache.tuscany.spi.implementation.java.JavaMappedReference; -import org.apache.tuscany.spi.implementation.java.JavaMappedService; -import org.apache.tuscany.spi.implementation.java.PojoComponentType; -import org.apache.tuscany.spi.implementation.java.ProcessingException; - - -/** - * Handles processing of a constructor decorated with {@link org.osoa.sca.annotations.Constructor} - * - * @version $Rev$ $Date$ - */ -@SuppressWarnings("unchecked") -public class ConstructorProcessor extends ImplementationProcessorExtension { - - private ImplementationProcessorService service; - - public ConstructorProcessor(@Autowire ImplementationProcessorService service) { - this.service = service; - } - - public void visitClass(CompositeComponent parent, Class clazz, - PojoComponentType> type, - DeploymentContext context) throws ProcessingException { - Constructor[] ctors = clazz.getConstructors(); - boolean found = false; - for (Constructor constructor : ctors) { - if (constructor.getAnnotation(org.osoa.sca.annotations.Constructor.class) != null) { - if (found) { - String name = constructor.getDeclaringClass().getName(); - throw new DuplicateConstructorException("Multiple constructors marked with @Constructor", name); - } - found = true; - } - } - } - - public void visitConstructor(CompositeComponent parent, Constructor constructor, - PojoComponentType> type, - DeploymentContext context) throws ProcessingException { - org.osoa.sca.annotations.Constructor annotation = - constructor.getAnnotation(org.osoa.sca.annotations.Constructor.class); - if (annotation == null) { - return; - } - ConstructorDefinition definition = type.getConstructorDefinition(); - if (definition != null && !definition.getConstructor().equals(constructor)) { - String name = constructor.getDeclaringClass().getName(); - throw new DuplicateConstructorException("Multiple constructor definitions found", name); - } else if (definition == null) { - definition = new ConstructorDefinition(constructor); - } - Class[] params = constructor.getParameterTypes(); - String[] names = annotation.value(); - Annotation[][] annotations = constructor.getParameterAnnotations(); - List injectionNames = definition.getInjectionNames(); - for (int i = 0; i < params.length; i++) { - Class param = params[i]; - Annotation[] paramAnnotations = annotations[i]; - try { - if (!service.processParam(param, paramAnnotations, names, i, type, injectionNames)) { - String name = (i < names.length) ? names[i] : ""; - service.addName(injectionNames, i, name); - } - } catch (ProcessingException e) { - e.setMember(constructor); - throw e; - } - } - if (names.length != 0 && names[0].length() != 0 && names.length != params.length) { - throw new InvalidConstructorException("Names in @Constructor do not match number of parameters"); - } - type.setConstructorDefinition(definition); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ContextProcessor.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ContextProcessor.java deleted file mode 100644 index b0216e3d38..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ContextProcessor.java +++ /dev/null @@ -1,124 +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.processor; - -import java.lang.reflect.Field; -import java.lang.reflect.Method; - -import org.osoa.sca.CompositeContext; -import org.osoa.sca.RequestContext; -import org.osoa.sca.annotations.Context; - -import org.apache.tuscany.spi.annotation.Autowire; -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.component.WorkContext; -import org.apache.tuscany.spi.deployer.DeploymentContext; -import org.apache.tuscany.spi.implementation.java.ImplementationProcessorExtension; -import org.apache.tuscany.spi.implementation.java.JavaMappedProperty; -import org.apache.tuscany.spi.implementation.java.JavaMappedReference; -import org.apache.tuscany.spi.implementation.java.JavaMappedService; -import org.apache.tuscany.spi.implementation.java.PojoComponentType; -import org.apache.tuscany.spi.implementation.java.ProcessingException; -import org.apache.tuscany.spi.implementation.java.Resource; -import org.apache.tuscany.spi.wire.WireService; - -import org.apache.tuscany.core.injection.CompositeContextObjectFactory; -import org.apache.tuscany.core.injection.RequestContextObjectFactory; -import org.apache.tuscany.core.util.JavaIntrospectionHelper; - -/** - * Processes {@link @Context} annotations on a component implementation and adds a {@link JavaMappedProperty} to the - * component type which will be used to inject the appropriate context - * - * @version $Rev$ $Date$ - */ -public class ContextProcessor extends ImplementationProcessorExtension { - private WireService wireService; - private WorkContext workContext; - - @Autowire - public void setWireService(WireService wireService) { - this.wireService = wireService; - } - - @Autowire - public void setWorkContext(WorkContext workContext) { - this.workContext = workContext; - } - - public void visitMethod(CompositeComponent parent, - Method method, - PojoComponentType> type, - DeploymentContext context) - throws ProcessingException { - if (method.getAnnotation(Context.class) == null) { - return; - } - if (method.getParameterTypes().length != 1) { - throw new IllegalContextException("Context setter must have one parameter", method.toString()); - } - Class paramType = method.getParameterTypes()[0]; - if (CompositeContext.class.equals(paramType)) { - String name = method.getName(); - name = JavaIntrospectionHelper.toPropertyName(name); - Resource resource = new Resource(); - resource.setName(name); - resource.setMember(method); - resource.setObjectFactory(new CompositeContextObjectFactory(parent, wireService)); - type.getResources().put(name, resource); - } else if (RequestContext.class.equals(paramType)) { - String name = method.getName(); - name = JavaIntrospectionHelper.toPropertyName(name); - Resource resource = new Resource(); - resource.setName(name); - resource.setMember(method); - resource.setObjectFactory(new RequestContextObjectFactory(workContext)); - type.getResources().put(name, resource); - } else { - throw new UnknownContextTypeException(paramType.getName()); - } - } - - public void visitField(CompositeComponent parent, Field field, - PojoComponentType> type, - DeploymentContext context) throws ProcessingException { - if (field.getAnnotation(Context.class) == null) { - return; - } - Class paramType = field.getType(); - if (CompositeContext.class.equals(paramType)) { - String name = field.getName(); - Resource resource = new Resource(); - resource.setName(name); - resource.setMember(field); - resource.setObjectFactory(new CompositeContextObjectFactory(parent, wireService)); - type.getResources().put(name, resource); - } else if (RequestContext.class.equals(paramType)) { - String name = field.getName(); - name = JavaIntrospectionHelper.toPropertyName(name); - Resource resource = new Resource(); - resource.setName(name); - resource.setMember(field); - resource.setObjectFactory(new RequestContextObjectFactory(workContext)); - type.getResources().put(name, resource); - } else { - throw new UnknownContextTypeException(paramType.getName()); - } - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ConversationProcessor.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ConversationProcessor.java deleted file mode 100644 index e3a173ea06..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ConversationProcessor.java +++ /dev/null @@ -1,142 +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.processor; - -import java.lang.reflect.Field; -import java.lang.reflect.Method; - -import org.osoa.sca.annotations.Conversation; -import org.osoa.sca.annotations.ConversationID; -import org.osoa.sca.annotations.Scope; - -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.deployer.DeploymentContext; -import org.apache.tuscany.spi.implementation.java.ImplementationProcessorExtension; -import org.apache.tuscany.spi.implementation.java.JavaMappedProperty; -import org.apache.tuscany.spi.implementation.java.JavaMappedReference; -import org.apache.tuscany.spi.implementation.java.JavaMappedService; -import org.apache.tuscany.spi.implementation.java.PojoComponentType; -import org.apache.tuscany.spi.implementation.java.ProcessingException; - -/** - * @version $Rev$ $Date$ - */ -public class ConversationProcessor extends ImplementationProcessorExtension { - private static final String SECONDS = " SECONDS"; - private static final String MINUTES = " MINUTES"; - private static final String HOURS = " HOURS"; - private static final String DAYS = " DAYS"; - private static final String YEARS = " YEARS"; - - public void visitClass(CompositeComponent parent, - Class clazz, - PojoComponentType> type, - DeploymentContext context) throws ProcessingException { - - Conversation conversation = clazz.getAnnotation(Conversation.class); - if (conversation == null) { - return; - } - Scope scope = clazz.getAnnotation(Scope.class); - if (scope == null) { - // implicitly assume conversation - type.setImplementationScope(org.apache.tuscany.spi.model.Scope.CONVERSATION); - } else if (scope != null && !"CONVERSATION".equals(scope.value().toUpperCase())) { - throw new InvalidConversationalImplementation( - "Service is marked with @Conversation but the scope is not @Scope(\"CONVERSATION\")", clazz.getName()); - } else if (conversation != null) { - long maxAge; - long maxIdleTime; - String maxAgeVal = conversation.maxAge(); - String maxIdleTimeVal = conversation.maxIdleTime(); - if (maxAgeVal.length() > 0 && maxIdleTimeVal.length() > 0) { - throw new InvalidConversationalImplementation("Max idle time and age both specified", clazz.getName()); - } - try { - if (maxAgeVal.length() > 0) { - maxAge = convertTimeMillis(maxAgeVal); - type.setMaxAge(maxAge); - } - } catch (NumberFormatException e) { - throw new InvalidConversationalImplementation("Invalid maximum age", clazz.getName(), e); - } - try { - if (maxIdleTimeVal.length() > 0) { - maxIdleTime = convertTimeMillis(maxIdleTimeVal); - type.setMaxIdleTime(maxIdleTime); - } - } catch (NumberFormatException e) { - throw new InvalidConversationalImplementation("Invalid maximum idle time", clazz.getName(), e); - } - } - - } - - public void visitMethod(CompositeComponent parent, Method method, - PojoComponentType> type, - DeploymentContext context) - throws ProcessingException { - ConversationID conversationID = method.getAnnotation(ConversationID.class); - if (conversationID == null) { - return; - } - type.setConversationIDMember(method); - } - - public void visitField(CompositeComponent parent, Field field, - PojoComponentType> type, - DeploymentContext context) throws ProcessingException { - ConversationID conversationID = field.getAnnotation(ConversationID.class); - if (conversationID == null) { - return; - } - type.setConversationIDMember(field); - } - - protected long convertTimeMillis(String expr) throws NumberFormatException { - expr = expr.trim().toUpperCase(); - int i = expr.lastIndexOf(SECONDS); - if (i >= 0) { - String units = expr.substring(0, i); - return Long.parseLong(units) * 1000; - } - i = expr.lastIndexOf(MINUTES); - if (i >= 0) { - String units = expr.substring(0, i); - return Long.parseLong(units) * 60000; - } - - i = expr.lastIndexOf(HOURS); - if (i >= 0) { - String units = expr.substring(0, i); - return Long.parseLong(units) * 3600000; - } - i = expr.lastIndexOf(DAYS); - if (i >= 0) { - String units = expr.substring(0, i); - return Long.parseLong(units) * 86400000; - } - i = expr.lastIndexOf(YEARS); - if (i >= 0) { - String units = expr.substring(0, i); - return Long.parseLong(units) * 31556926000L; - } - return Long.parseLong(expr) * 1000; // assume seconds if no suffix specified - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/DestroyProcessor.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/DestroyProcessor.java deleted file mode 100644 index 7ef540432f..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/DestroyProcessor.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.implementation.processor; - -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; - -import org.osoa.sca.annotations.Destroy; - -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.deployer.DeploymentContext; -import org.apache.tuscany.spi.implementation.java.ImplementationProcessorExtension; -import org.apache.tuscany.spi.implementation.java.JavaMappedProperty; -import org.apache.tuscany.spi.implementation.java.JavaMappedReference; -import org.apache.tuscany.spi.implementation.java.JavaMappedService; -import org.apache.tuscany.spi.implementation.java.PojoComponentType; -import org.apache.tuscany.spi.implementation.java.ProcessingException; - -/** - * Processes the {@link @Destroy} annotation on a component implementation and updates the component type with the - * decorated destructor method - * - * @version $Rev$ $Date$ - */ -public class DestroyProcessor extends ImplementationProcessorExtension { - - public void visitMethod(CompositeComponent parent, Method method, - PojoComponentType> type, - DeploymentContext context) - throws ProcessingException { - Destroy annotation = method.getAnnotation(Destroy.class); - if (annotation == null) { - return; - } - if (method.getParameterTypes().length != 0) { - throw new IllegalDestructorException("Destructor must not have argments", method.toString()); - } - if (type.getDestroyMethod() != null) { - throw new DuplicateDestructorException("More than one destructor found on implementation"); - } - if (Modifier.isProtected(method.getModifiers())) { - method.setAccessible(true); - } - type.setDestroyMethod(method); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/DuplicateConstructorException.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/DuplicateConstructorException.java deleted file mode 100644 index 88db7ebb79..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/DuplicateConstructorException.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.implementation.processor; - -import org.apache.tuscany.spi.implementation.java.ProcessingException; - -/** - * Thrown when more than one component implementation constructor is annotated with {@link - * org.osoa.sca.annotations.Constructor} - * - * @version $Rev$ $Date$ - */ -public class DuplicateConstructorException extends ProcessingException { - - public DuplicateConstructorException(String message) { - super(message); - } - - public DuplicateConstructorException(String message, String identifier) { - super(message, identifier); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/DuplicateDestructorException.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/DuplicateDestructorException.java deleted file mode 100644 index 6225bd6219..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/DuplicateDestructorException.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.implementation.processor; - -import org.apache.tuscany.spi.implementation.java.ProcessingException; - -/** - * Thrown when an implementation is annotated multiple times with {@link org.osoa.sca.annotations.Destroy} - * - * @version $Rev$ $Date$ - */ -public class DuplicateDestructorException extends ProcessingException { - - public DuplicateDestructorException(String message) { - super(message); - } - - public DuplicateDestructorException(String message, String identifier) { - super(message, identifier); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/DuplicateInitException.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/DuplicateInitException.java deleted file mode 100644 index 105edee1a2..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/DuplicateInitException.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.implementation.processor; - -import org.apache.tuscany.spi.implementation.java.ProcessingException; - -/** - * Thrown when an implementation is annotated multiple times with {@link @org.osoa.sca.annotations.Init} - * - * @version $Rev$ $Date$ - */ -public class DuplicateInitException extends ProcessingException { - - public DuplicateInitException(String message) { - super(message); - } - - public DuplicateInitException(String message, String identifier) { - super(message, identifier); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/DuplicateReferenceException.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/DuplicateReferenceException.java deleted file mode 100644 index 5eae1461c2..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/DuplicateReferenceException.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.implementation.processor; - -import org.apache.tuscany.spi.implementation.java.ProcessingException; - -/** - * Thrown when an implementation has more than one reference injection site with the same name - * - * @version $Rev$ $Date$ - */ -public class DuplicateReferenceException extends ProcessingException { - - public DuplicateReferenceException(String message) { - super(message); - } - - - public DuplicateReferenceException(String message, String identifier) { - super(message, identifier); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/DuplicateResourceException.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/DuplicateResourceException.java deleted file mode 100644 index 9dd718c03e..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/DuplicateResourceException.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.implementation.processor; - -import org.apache.tuscany.spi.implementation.java.ProcessingException; - -/** - * Thrown when an implementation has more than one resource injection site with the same name - * - * @version $Rev$ $Date$ - */ -public class DuplicateResourceException extends ProcessingException { - - public DuplicateResourceException(String message) { - super(message); - } - - public DuplicateResourceException(String message, String identifier) { - super(message, identifier); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/EagerInitProcessor.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/EagerInitProcessor.java deleted file mode 100644 index 9c8858b78c..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/EagerInitProcessor.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.implementation.processor; - -import org.osoa.sca.annotations.EagerInit; - -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.deployer.DeploymentContext; -import org.apache.tuscany.spi.implementation.java.ImplementationProcessorExtension; -import org.apache.tuscany.spi.implementation.java.JavaMappedProperty; -import org.apache.tuscany.spi.implementation.java.JavaMappedReference; -import org.apache.tuscany.spi.implementation.java.JavaMappedService; -import org.apache.tuscany.spi.implementation.java.PojoComponentType; -import org.apache.tuscany.spi.implementation.java.ProcessingException; - -/** - * Handles processing of {@link org.osoa.sca.annotations.EagerInit} - * - * @version $Rev$ $Date$ - */ -public class EagerInitProcessor extends ImplementationProcessorExtension { - - public void visitClass(CompositeComponent parent, Class clazz, - PojoComponentType> type, - DeploymentContext context) throws ProcessingException { - super.visitClass(parent, clazz, type, context); - EagerInit annotation = clazz.getAnnotation(EagerInit.class); - if (annotation == null) { - Class superClass = clazz.getSuperclass(); - while (!Object.class.equals(superClass)) { - annotation = superClass.getAnnotation(EagerInit.class); - if (annotation != null) { - break; - } - superClass = superClass.getSuperclass(); - } - if (annotation == null) { - return; - } - } - type.setInitLevel(annotation.value()); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/HeuristicPojoProcessor.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/HeuristicPojoProcessor.java deleted file mode 100644 index bdf5d23ea8..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/HeuristicPojoProcessor.java +++ /dev/null @@ -1,546 +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.processor; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Constructor; -import java.lang.reflect.Field; -import java.lang.reflect.Member; -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.Collection; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.osoa.sca.annotations.Remotable; -import org.osoa.sca.annotations.Service; - -import org.apache.tuscany.spi.annotation.Autowire; -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.databinding.extension.SimpleTypeMapperExtension; -import org.apache.tuscany.spi.deployer.DeploymentContext; -import org.apache.tuscany.spi.idl.InvalidServiceContractException; -import org.apache.tuscany.spi.idl.TypeInfo; -import org.apache.tuscany.spi.implementation.java.ConstructorDefinition; -import org.apache.tuscany.spi.implementation.java.ImplementationProcessorExtension; -import org.apache.tuscany.spi.implementation.java.ImplementationProcessorService; -import org.apache.tuscany.spi.implementation.java.JavaMappedProperty; -import org.apache.tuscany.spi.implementation.java.JavaMappedReference; -import org.apache.tuscany.spi.implementation.java.JavaMappedService; -import org.apache.tuscany.spi.implementation.java.PojoComponentType; -import org.apache.tuscany.spi.implementation.java.ProcessingException; -import org.apache.tuscany.spi.model.OverrideOptions; - -import static org.apache.tuscany.core.util.JavaIntrospectionHelper.getAllInterfaces; -import static org.apache.tuscany.core.util.JavaIntrospectionHelper.getAllPublicAndProtectedFields; -import static org.apache.tuscany.core.util.JavaIntrospectionHelper.getAllUniquePublicProtectedMethods; -import static org.apache.tuscany.core.util.JavaIntrospectionHelper.getBaseName; -import static org.apache.tuscany.core.util.JavaIntrospectionHelper.toPropertyName; - -/** - * Heuristically evaluates an un-annotated Java implementation type to determine services, references, and properties - * according to the algorithm described in the SCA Java Client and Implementation Model Specification

      TODO - * Implement: - *

      - * When no service inteface is annotated, need to calculate a single service comprising all public methods that are not - * reference or property injection sites. If that service can be exactly mapped to an interface implemented by the class - * then the service interface will be defined in terms of that interface. - * - * @version $Rev$ $Date$ - */ -public class HeuristicPojoProcessor extends ImplementationProcessorExtension { - private SimpleTypeMapperExtension typeMapper = new SimpleTypeMapperExtension(); - private ImplementationProcessorService implService; - - public HeuristicPojoProcessor(@Autowire ImplementationProcessorService service) { - this.implService = service; - } - - public void visitEnd( - CompositeComponent parent, - Class clazz, - PojoComponentType> type, - DeploymentContext context) throws ProcessingException { - Map services = type.getServices(); - if (services.isEmpty()) { - // heuristically determine the service - // TODO finish algorithm - Set interfaces = getAllInterfaces(clazz); - if (interfaces.size() == 0) { - // class is the interface - JavaMappedService service; - try { - service = implService.createService(clazz); - } catch (InvalidServiceContractException e) { - throw new ProcessingException(e); - } - type.getServices().put(service.getName(), service); - } else if (interfaces.size() == 1) { - JavaMappedService service; - try { - service = implService.createService(interfaces.iterator().next()); - } catch (InvalidServiceContractException e) { - throw new ProcessingException(e); - } - type.getServices().put(service.getName(), service); - } - } - Set methods = getAllUniquePublicProtectedMethods(clazz); - if (!type.getReferences().isEmpty() || !type.getProperties().isEmpty()) { - // references and properties have been explicitly defined - if (type.getServices().isEmpty()) { - calculateServiceInterface(clazz, type, methods); - if (type.getServices().isEmpty()) { - throw new ServiceTypeNotFoundException(clazz.getName()); - } - } - evaluateConstructor(type, clazz); - return; - } - calcPropRefs(methods, services, type, clazz); - evaluateConstructor(type, clazz); - } - - private void calcPropRefs(Set methods, - Map services, - PojoComponentType> type, - Class clazz) throws ProcessingException { - // heuristically determine the properties references - // make a first pass through all public methods with one param - for (Method method : methods) { - if (method.getParameterTypes().length != 1 || !Modifier.isPublic(method.getModifiers()) - || !method.getName().startsWith("set") - || method.getReturnType() != void.class) { - continue; - } - if (!isInServiceInterface(method, services)) { - String name = toPropertyName(method.getName()); - // avoid duplicate property or ref names - if (!type.getProperties().containsKey(name) && !type.getReferences().containsKey(name)) { - Class param = method.getParameterTypes()[0]; - Type genericType = method.getGenericParameterTypes()[0]; - if (isReferenceType(genericType)) { - type.add(createReference(name, method, param)); - } else { - type.add(createProperty(name, method, param)); - } - } - } - } - // second pass for protected methods with one param - for (Method method : methods) { - if (method.getParameterTypes().length != 1 || !Modifier.isProtected(method.getModifiers()) - || !method.getName().startsWith("set") - || method.getReturnType() != void.class) { - continue; - } - Class param = method.getParameterTypes()[0]; - String name = toPropertyName(method.getName()); - // avoid duplicate property or ref names - if (!type.getProperties().containsKey(name) && !type.getReferences().containsKey(name)) { - if (isReferenceType(param)) { - type.add(createReference(name, method, param)); - } else { - type.add(createProperty(name, method, param)); - } - } - } - Set fields = getAllPublicAndProtectedFields(clazz); - for (Field field : fields) { - Class paramType = field.getType(); - if (isReferenceType(paramType)) { - type.add(createReference(field.getName(), field, paramType)); - } else { - type.add(createProperty(field.getName(), field, paramType)); - } - } - } - - /** - * Determines the constructor to use based on the component type's references and properties - * - * @param type the component type - * @param clazz the implementation class corresponding to the component type - * @throws NoConstructorException if no suitable constructor is found - * @throws AmbiguousConstructorException if the parameters of a constructor cannot be unambiguously mapped to - * references and properties - */ - @SuppressWarnings("unchecked") - private void evaluateConstructor( - PojoComponentType> type, - Class clazz) throws ProcessingException { - // determine constructor if one is not annotated - ConstructorDefinition definition = type.getConstructorDefinition(); - Constructor constructor; - boolean explict = false; - if (definition != null - && definition.getConstructor().getAnnotation(org.osoa.sca.annotations.Constructor.class) != null) { - // the constructor was already defined explicitly - return; - } else if (definition != null) { - explict = true; - constructor = definition.getConstructor(); - } else { - // no definition, heuristically determine constructor - Constructor[] constructors = clazz.getConstructors(); - if (constructors.length == 0) { - throw new NoConstructorException("No public constructor for class", clazz.getName()); - } else if (constructors.length == 1) { - constructor = constructors[0]; - } else { - // FIXME multiple constructors, none yet done - Constructor selected = null; - int sites = type.getProperties().size() + type.getReferences().size(); - for (Constructor ctor : constructors) { - if (ctor.getParameterTypes().length == 0) { - selected = ctor; - } - if (ctor.getParameterTypes().length == sites) { - // TODO finish - // selected = constructor; - // select constructor - // break; - } - } - if (selected == null) { - throw new NoConstructorException(); - } - constructor = selected; - definition = new ConstructorDefinition(selected); - type.setConstructorDefinition(definition); - // return; - } - definition = new ConstructorDefinition(constructor); - type.setConstructorDefinition(definition); - } - Class[] params = constructor.getParameterTypes(); - if (params.length == 0) { - return; - } - List paramNames = definition.getInjectionNames(); - Map> props = type.getProperties(); - Map refs = type.getReferences(); - Annotation[][] annotations = constructor.getParameterAnnotations(); - if (!explict) { - // the constructor wasn't defined by an annotation, so check to see if any of the params have an annotation - // which we can impute as explicitly defining the constructor, e.g. @Property, @Reference, or @Autowire - explict = implService.injectionAnnotationsPresent(annotations); - } - if (explict) { - for (int i = 0; i < params.length; i++) { - Class param = params[i]; - implService.processParam(param, annotations[i], new String[0], i, type, paramNames); - } - } else { - if (!implService.areUnique(params)) { - throw new AmbiguousConstructorException("Cannot resolve non-unique parameter types, use @Constructor"); - } - if (!calcPropRefUniqueness(props.values(), refs.values())) { - throw new AmbiguousConstructorException("Cannot resolve non-unique parameter types, use @Constructor"); - } - boolean empty = props.size() + refs.size() == 0; - if (!empty) { - calcParamNames(params, props, refs, paramNames); - } else { - heuristicParamNames(params, refs, props, paramNames); - - } - } - } - - private void calcParamNames(Class[] params, - Map> props, - Map refs, - List paramNames) - throws AmbiguousConstructorException { - // the constructor param types must unambiguously match defined reference or property types - for (Class param : params) { - String name = findReferenceOrProperty(param, props, refs); - if (name == null) { - throw new AmbiguousConstructorException(param.getName()); - } - paramNames.add(name); - } - } - - private void heuristicParamNames(Class[] params, - Map refs, - Map> props, - List paramNames) - throws ProcessingException { - // heuristically determine refs and props from the parameter types - for (Class param : params) { - String name = getBaseName(param).toLowerCase(); - if (isReferenceType(param)) { - refs.put(name, createReference(name, null, param)); - } else { - props.put(name, createProperty(name, null, param)); - } - paramNames.add(name); - } - } - - /** - * Returns true if the union of the given collections of properties and references have unique Java types - */ - private boolean calcPropRefUniqueness( - Collection> props, - Collection refs) { - - Class[] classes = new Class[props.size() + refs.size()]; - int i = 0; - for (JavaMappedProperty property : props) { - classes[i] = property.getJavaType(); - i++; - } - for (JavaMappedReference reference : refs) { - classes[i] = reference.getServiceContract().getInterfaceClass(); - i++; - } - return implService.areUnique(classes); - } - - /** - * Unambiguously finds the reference or property associated with the given type - * - * @return the name of the reference or property if found, null if not - * @throws AmbiguousConstructorException if the constructor parameter cannot be resolved to a property or reference - */ - private String findReferenceOrProperty( - Class type, - Map> props, - Map refs) throws AmbiguousConstructorException { - - String name = null; - for (JavaMappedProperty property : props.values()) { - if (property.getJavaType().equals(type)) { - if (name != null) { - throw new AmbiguousConstructorException("Ambiguous property or reference for constructor type", - type.getName()); - } - name = property.getName(); - // do not break since ambiguities must be checked, i.e. more than one prop or ref of the same type - } - } - for (JavaMappedReference reference : refs.values()) { - if (reference.getServiceContract().getInterfaceClass().equals(type)) { - if (name != null) { - throw new AmbiguousConstructorException("Ambiguous property or reference for constructor type", - type.getName()); - } - name = reference.getName(); - // do not break since ambiguities must be checked, i.e. more than one prop or ref of the same type - } - } - return name; - } - - /** - * Returns true if a given type is reference according to the SCA specification rules for determining reference - * types - */ - private boolean isReferenceType(Type operationType) { - Class rawType; - Class referenceType = null; - if (operationType instanceof ParameterizedType) { - ParameterizedType parameterizedType = (ParameterizedType) operationType; - rawType = (Class) parameterizedType.getRawType(); - Type[] typeArgs = parameterizedType.getActualTypeArguments(); - if (typeArgs.length == 1) { - referenceType = (Class) typeArgs[0]; - } - } else { - rawType = (Class) operationType; - } - if (rawType.isArray()) { - referenceType = rawType.getComponentType(); - } else if (Collection.class.isAssignableFrom(rawType) && referenceType == null) { - return true; - } - if (referenceType != null) { - return referenceType.getAnnotation(Remotable.class) != null - || referenceType.getAnnotation(Service.class) != null; - } else { - return rawType.getAnnotation(Remotable.class) != null || rawType.getAnnotation(Service.class) != null; - } - } - - /** - * Returns true if the given operation is defined in the collection of service interfaces - */ - private boolean isInServiceInterface(Method operation, Map services) { - for (JavaMappedService service : services.values()) { - Class clazz = service.getServiceContract().getInterfaceClass(); - if (operation.getDeclaringClass().equals(clazz)) { - return true; - } - Method[] methods = service.getServiceContract().getInterfaceClass().getMethods(); - for (Method method : methods) { - if (operation.getName().equals(method.getName()) - && operation.getParameterTypes().length == method.getParameterTypes().length) { - Class[] methodTypes = method.getParameterTypes(); - for (int i = 0; i < operation.getParameterTypes().length; i++) { - Class paramType = operation.getParameterTypes()[i]; - if (!paramType.equals(methodTypes[i])) { - break; - } else if (i == operation.getParameterTypes().length - 1) { - return true; - } - } - } - } - } - return false; - } - - /** - * Creates a mapped reference - * - * @param name the reference name - * @param member the injection site the reference maps to - * @param paramType the service interface of the reference - */ - private JavaMappedReference createReference(String name, Member member, Class paramType) - throws ProcessingException { - return implService.createReference(name, member, paramType); - } - - /** - * Creates a mapped property - * - * @param name the property name - * @param member the injection site the reference maps to - * @param paramType the property type - */ - private JavaMappedProperty createProperty(String name, Member member, Class paramType) { - JavaMappedProperty property = new JavaMappedProperty(); - property.setName(name); - property.setMember(member); - property.setOverride(OverrideOptions.MAY); - property.setJavaType(paramType); - TypeInfo xmlType = typeMapper.getXMLType(paramType); - if (xmlType != null) { - property.setXmlType(xmlType.getQName()); - } - - return property; - } - - /** - * Populates a component type with a service whose interface type is determined by examining all implemented - * interfaces of the given class and chosing one whose operations match all of the class's non-property and - * non-reference methods - * - * @param clazz the class to examine - * @param type the component type - * @param methods all methods in the class to examine - */ - private void calculateServiceInterface( - Class clazz, - PojoComponentType> type, - Set methods) throws ProcessingException { - List nonPropRefMethods = new ArrayList(); - // Map services = type.getServices(); - Map references = type.getReferences(); - Map> properties = type.getProperties(); - // calculate methods that are not properties or references - for (Method method : methods) { - String name = toPropertyName(method.getName()); - if (!references.containsKey(name) && !properties.containsKey(name)) { - nonPropRefMethods.add(method); - } - } - // determine if an implemented interface matches all of the non-property and non-reference methods - Class[] interfaces = clazz.getInterfaces(); - if (interfaces.length == 0) { - return; - } - for (Class interfaze : interfaces) { - if (analyzeInterface(interfaze, nonPropRefMethods)) { - JavaMappedService service; - try { - service = implService.createService(interfaze); - } catch (InvalidServiceContractException e) { - throw new ProcessingException(e); - } - type.getServices().put(service.getName(), service); - } - } - } - - /** - * Determines if the methods of a given interface match the given list of methods - * - * @param interfaze the interface to examine - * @param nonPropRefMethods the list of methods to match against - * @return true if the interface matches - */ - private boolean analyzeInterface(Class interfaze, List nonPropRefMethods) { - Method[] interfaceMethods = interfaze.getMethods(); - if (nonPropRefMethods.size() != interfaceMethods.length) { - return false; - } - for (Method method : nonPropRefMethods) { - boolean found = false; - for (Method interfaceMethod : interfaceMethods) { - if (interfaceMethod.getName().equals(method.getName())) { - Class[] interfaceParamTypes = interfaceMethod.getParameterTypes(); - Class[] methodParamTypes = method.getParameterTypes(); - if (interfaceParamTypes.length == methodParamTypes.length) { - if (interfaceParamTypes.length == 0) { - found = true; - } else { - for (int i = 0; i < methodParamTypes.length; i++) { - Class param = methodParamTypes[i]; - if (!param.equals(interfaceParamTypes[i])) { - break; - } - if (i == methodParamTypes.length - 1) { - found = true; - } - } - } - } - if (found) { - break; - } - } - } - if (!found) { - return false; - } - } - return true; - } - -} - -/* - * 1) public setter methods that are not included in any service interface 2) protected setter methods 3) public or - * protected fields unless there is a setter method for the same name If the type associated with the member is an array - * or a java.util.Collection, then the basetype will be the element type of the array or the parameterized type of the - * Collection, otherwise the basetype will be the member type. If the basetype is an interface with an @Remotable or - * @Service annotation then the member will be defined as a reference, otherwise it will be defined as a property. - * - * - */ diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/IllegalCallbackReferenceException.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/IllegalCallbackReferenceException.java deleted file mode 100644 index 4581faa872..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/IllegalCallbackReferenceException.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.implementation.processor; - -import org.apache.tuscany.spi.implementation.java.ProcessingException; - -/** - * Denotes an illegcal use of {@link org.osoa.sca.annotations.Callback} on a reference - * - * @version $Rev$ $Date$ - */ -public class IllegalCallbackReferenceException extends ProcessingException { - - public IllegalCallbackReferenceException(String message) { - super(message); - } - - public IllegalCallbackReferenceException(String message, String identifier) { - super(message, identifier); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/IllegalContextException.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/IllegalContextException.java deleted file mode 100644 index 8c56cade83..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/IllegalContextException.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.implementation.processor; - -import org.apache.tuscany.spi.implementation.java.ProcessingException; - -/** - * Denotes an illegal signature for a method decorated with {@link org.osoa.sca.annotations.Context} - * - * @version $Rev$ $Date$ - */ -public class IllegalContextException extends ProcessingException { - - public IllegalContextException(String message) { - super(message); - } - - public IllegalContextException(String message, String identifier) { - super(message, identifier); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/IllegalDestructorException.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/IllegalDestructorException.java deleted file mode 100644 index fee42ea5c8..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/IllegalDestructorException.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.implementation.processor; - -import org.apache.tuscany.spi.implementation.java.ProcessingException; - -/** - * Denotes an illegal signature for a method decorated with {@link org.osoa.sca.annotations.Destroy} - * - * @version $Rev$ $Date$ - */ -public class IllegalDestructorException extends ProcessingException { - - public IllegalDestructorException(String message) { - super(message); - } - - public IllegalDestructorException(String message, String identifier) { - super(message, identifier); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/IllegalInitException.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/IllegalInitException.java deleted file mode 100644 index 219074b785..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/IllegalInitException.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.implementation.processor; - -import org.apache.tuscany.spi.implementation.java.ProcessingException; - -/** - * Denotes an illegal signature for a method decorated with {@link @org.osoa.sca.annotations.Init} - * - * @version $Rev$ $Date$ - */ -public class IllegalInitException extends ProcessingException { - public IllegalInitException(String message) { - super(message); - } - - public IllegalInitException(String message, String identifier) { - super(message, identifier); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/IllegalReferenceException.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/IllegalReferenceException.java deleted file mode 100644 index 11137bcaba..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/IllegalReferenceException.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.implementation.processor; - -import org.apache.tuscany.spi.implementation.java.ProcessingException; - -/** - * Denotes an illegal reference definition in a component type - * - * @version $Rev$ $Date$ - */ -public class IllegalReferenceException extends ProcessingException { - - public IllegalReferenceException(String message) { - super(message); - } - - public IllegalReferenceException(String message, String identifier) { - super(message, identifier); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/IllegalResourceException.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/IllegalResourceException.java deleted file mode 100644 index e25c1174e2..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/IllegalResourceException.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.implementation.processor; - -import org.apache.tuscany.spi.implementation.java.ProcessingException; - -/** - * Denotes an illegal resource definition in a component type - * - * @version $Rev$ $Date$ - */ -public class IllegalResourceException extends ProcessingException { - - public IllegalResourceException(String message) { - super(message); - } - - public IllegalResourceException(String message, String identifier) { - super(message, identifier); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/IllegalServiceDefinitionException.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/IllegalServiceDefinitionException.java deleted file mode 100644 index 1d9079636a..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/IllegalServiceDefinitionException.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.implementation.processor; - -import org.apache.tuscany.spi.implementation.java.ProcessingException; - -/** - * Denotes an illegal use of the {@link @org.osoa.sca.annotations.Service} annotation - * - * @version $Rev$ $Date$ - */ -public class IllegalServiceDefinitionException extends ProcessingException { - - public IllegalServiceDefinitionException(String message) { - super(message); - } - - public IllegalServiceDefinitionException(String message, String identifier) { - super(message, identifier); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ImplementationProcessorServiceImpl.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ImplementationProcessorServiceImpl.java deleted file mode 100644 index 3f5505f7f0..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ImplementationProcessorServiceImpl.java +++ /dev/null @@ -1,410 +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.processor; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Member; -import java.util.List; -import javax.xml.namespace.QName; - -import org.osoa.sca.annotations.Callback; -import org.osoa.sca.annotations.Property; -import org.osoa.sca.annotations.Reference; -import org.osoa.sca.annotations.Remotable; -import org.osoa.sca.annotations.Resource; - -import org.apache.tuscany.spi.annotation.Autowire; -import org.apache.tuscany.spi.databinding.extension.SimpleTypeMapperExtension; -import org.apache.tuscany.spi.idl.InvalidServiceContractException; -import org.apache.tuscany.spi.idl.TypeInfo; -import org.apache.tuscany.spi.idl.java.JavaInterfaceProcessorRegistry; -import org.apache.tuscany.spi.implementation.java.DuplicatePropertyException; -import org.apache.tuscany.spi.implementation.java.ImplementationProcessorService; -import org.apache.tuscany.spi.implementation.java.JavaMappedProperty; -import org.apache.tuscany.spi.implementation.java.JavaMappedReference; -import org.apache.tuscany.spi.implementation.java.JavaMappedService; -import org.apache.tuscany.spi.implementation.java.PojoComponentType; -import org.apache.tuscany.spi.implementation.java.ProcessingException; -import org.apache.tuscany.spi.model.OverrideOptions; -import org.apache.tuscany.spi.model.ServiceContract; - -import org.apache.tuscany.core.idl.java.IllegalCallbackException; -import static org.apache.tuscany.core.util.JavaIntrospectionHelper.getBaseName; - -/** - * The default implementation of an ImplementationProcessorService - * - * @version $Rev$ $Date$ - */ -public class ImplementationProcessorServiceImpl implements ImplementationProcessorService { - private JavaInterfaceProcessorRegistry registry; - private SimpleTypeMapperExtension typeMapper = new SimpleTypeMapperExtension(); - - public ImplementationProcessorServiceImpl(@Autowire JavaInterfaceProcessorRegistry registry) { - this.registry = registry; - } - - public JavaMappedService createService(Class interfaze) throws InvalidServiceContractException { - JavaMappedService service = new JavaMappedService(); - service.setName(interfaze.getName()); - service.setRemotable(interfaze.getAnnotation(Remotable.class) != null); - ServiceContract contract = registry.introspect(interfaze); - service.setServiceContract(contract); - return service; - } - - public void processCallback(Class interfaze, ServiceContract contract) throws IllegalCallbackException { - Callback callback = interfaze.getAnnotation(Callback.class); - if (callback != null && !Void.class.equals(callback.value())) { - Class callbackClass = callback.value(); - contract.setCallbackClass(callbackClass); - contract.setCallbackName(getBaseName(callbackClass)); - } else if (callback != null && Void.class.equals(callback.value())) { - throw new IllegalCallbackException("No callback interface specified on annotation", interfaze.getName()); - } - } - - public boolean areUnique(Class[] collection) { - if (collection.length == 0) { - return true; - } - return areUnique(collection, 0); - } - - public void addName(List names, int pos, String name) { - if (names.size() < pos) { - for (int i = 0; i < pos; i++) { - names.add(i, ""); - } - names.add(name); - } else if (names.size() > pos) { - names.remove(pos); - names.add(pos, name); - } else { - names.add(pos, name); - } - } - - public boolean processParam( - Class param, - Annotation[] paramAnnotations, - String[] constructorNames, - int pos, - PojoComponentType> type, - List injectionNames) throws ProcessingException { - boolean processed = false; - for (Annotation annot : paramAnnotations) { - if (Autowire.class.equals(annot.annotationType())) { - processed = true; - processAutowire(annot, constructorNames, pos, param, type, injectionNames); - } else if (Property.class.equals(annot.annotationType())) { - processed = true; - processProperty(annot, constructorNames, pos, type, param, injectionNames); - } else if (Reference.class.equals(annot.annotationType())) { - processed = true; - processReference(annot, constructorNames, pos, type, param, injectionNames); - } else if (Resource.class.equals(annot.annotationType())) { - processed = true; - processResource((Resource) annot, constructorNames, pos, type, param, injectionNames); - } - } - return processed; - } - - public boolean injectionAnnotationsPresent(Annotation[][] annots) { - for (Annotation[] annotations : annots) { - for (Annotation annotation : annotations) { - Class annotType = annotation.annotationType(); - if (annotType.equals(Autowire.class) || annotType.equals(Property.class) - || annotType.equals(Reference.class) - || annotType.equals(Resource.class)) { - return true; - } - } - } - return false; - } - - public JavaMappedReference createReference(String name, Member member, Class paramType) - throws ProcessingException { - JavaMappedReference reference = new JavaMappedReference(); - reference.setName(name); - reference.setMember(member); - reference.setRequired(false); - ServiceContract contract; - try { - contract = registry.introspect(paramType); - } catch (InvalidServiceContractException e1) { - throw new ProcessingException(e1); - } - try { - processCallback(paramType, contract); - } catch (IllegalCallbackException e) { - throw new ProcessingException(e); - } - reference.setServiceContract(contract); - return reference; - } - - /** - * Determines if all the members of a collection have unique types - * - * @param collection the collection to analyze - * @param start the position in the collection to start - * @return true if the types are unique - */ - private boolean areUnique(Class[] collection, int start) { - Object compare = collection[start]; - for (int i = start + 1; i < collection.length; i++) { - if (compare.equals(collection[i])) { - return false; - } - } - if (start + 1 < collection.length) { - return areUnique(collection, start + 1); - } else { - return true; - } - } - - /** - * Processes autowire metadata for a constructor parameter - * - * @param annot the autowire annotation - * @param constructorNames the parameter names as specified in an {@link org.osoa.sca.annotations.Constructor} - * annotation - * @param pos the position of the parameter in the constructor's parameter list - * @param param the parameter type - * @param type the component type associated with the implementation being processed - * @param injectionNames the collection of injection names to update - * @throws InvalidAutowireException - * @throws InvalidConstructorException - */ - private void processAutowire( - Annotation annot, - String[] constructorNames, - int pos, - Class param, - PojoComponentType> type, - List injectionNames) throws ProcessingException { - // the param is marked as an autowire - Autowire autowireAnnot = (Autowire) annot; - JavaMappedReference reference = new JavaMappedReference(); - reference.setAutowire(true); - String name = autowireAnnot.name(); - if (name == null || name.length() == 0) { - if (constructorNames.length > 1 && (constructorNames.length < pos + 1 || constructorNames[pos] == null)) { - throw new InvalidAutowireException("Names in @Constructor and autowire parameter do not match at " - + (pos + 1)); - } else if (constructorNames.length == 1 && constructorNames[0].length() == 0) { - // special case when @Constructor present with all autowire params not specifying any name - name = param.getName() + String.valueOf(pos); - } else if (constructorNames.length == 1 - && (constructorNames.length < pos + 1 || constructorNames[pos] == null)) { - throw new InvalidAutowireException("Names in @Constructor and autowire parameter do not match at " - + (pos + 1)); - } else if (constructorNames.length == 1 && constructorNames[0].length() > 0) { - name = constructorNames[pos]; - } else if (constructorNames.length == 0 || constructorNames[pos].length() == 0) { - name = param.getName() + String.valueOf(pos); - } else { - name = constructorNames[pos]; - } - } else if (pos < constructorNames.length && constructorNames[pos] != null - && constructorNames[pos].length() != 0 && !name.equals(constructorNames[pos])) { - String paramNum = String.valueOf(pos + 1); - throw new InvalidConstructorException("Name specified by @Constructor does not match autowire name", - paramNum); - } - reference.setName(name); - reference.setRequired(autowireAnnot.required()); - ServiceContract contract = null; - try { - contract = registry.introspect(param); - } catch (InvalidServiceContractException e) { - throw new ProcessingException(e); - } - -// ServiceContract contract = new JavaServiceContract(); - contract.setInterfaceClass(param); - reference.setServiceContract(contract); - type.getReferences().put(name, reference); - addName(injectionNames, pos, name); - } - - /** - * Processes parameter metadata for a constructor parameter - * - * @param annot the parameter annotation - * @param constructorNames the parameter names as specified in an {@link org.osoa.sca.annotations.Constructor} - * annotation - * @param pos the position of the parameter in the constructor's parameter list - * @param type the component type associated with the implementation being processed - * @param param the parameter type - * @param explicitNames the collection of injection names to update - * @throws ProcessingException - */ - private void processProperty( - Annotation annot, - String[] constructorNames, - int pos, - PojoComponentType> type, - Class param, - List explicitNames) throws ProcessingException { - // TODO multiplicity - // the param is marked as a property - Property propAnnot = (Property) annot; - JavaMappedProperty property = new JavaMappedProperty(); - property.setJavaType(param); - String name = propAnnot.name(); - if (name == null || name.length() == 0) { - if (constructorNames.length < pos + 1 || constructorNames[pos] == null - || constructorNames[pos].length() == 0) { - throw new InvalidPropertyException("No name specified for property parameter " + (pos + 1)); - } - name = constructorNames[pos]; - } else if (pos < constructorNames.length && constructorNames[pos] != null - && constructorNames[pos].length() != 0 && !name.equals(constructorNames[pos])) { - String paramNum = String.valueOf(pos + 1); - throw new InvalidConstructorException("Name specified by @Constructor does not match property name", - paramNum); - } - if (type.getProperties().get(name) != null) { - throw new DuplicatePropertyException(name); - } - property.setName(name); - property.setOverride(OverrideOptions.valueOf(propAnnot.override().toUpperCase())); - - String xmlType = propAnnot.xmlType(); - if (xmlType != null && xmlType.length() != 0) { - property.setXmlType(QName.valueOf(xmlType)); - } else { - TypeInfo typeInfo = typeMapper.getXMLType(property.getJavaType()); - if (typeInfo != null) { - property.setXmlType(typeInfo.getQName()); - } - } - property.setJavaType(param); - type.getProperties().put(name, property); - addName(explicitNames, pos, name); - } - - /** - * Processes reference metadata for a constructor parameter - * - * @param annot the parameter annotation - * @param constructorNames the parameter names as specified in an {@link org.osoa.sca.annotations.Constructor} - * annotation - * @param pos the position of the parameter in the constructor's parameter list - * @param type the component type associated with the implementation being processed - * @param param the parameter type - * @param explicitNames the collection of injection names to update - * @throws ProcessingException - */ - private void processReference( - Annotation annot, - String[] constructorNames, - int pos, - PojoComponentType> type, - Class param, - List explicitNames) throws ProcessingException { - - // TODO multiplicity - // the param is marked as a reference - Reference refAnnotation = (Reference) annot; - JavaMappedReference reference = new JavaMappedReference(); - String name = refAnnotation.name(); - if (name == null || name.length() == 0) { - if (constructorNames.length < pos + 1 || constructorNames[pos] == null - || constructorNames[pos].length() == 0) { - throw new InvalidReferenceException("No name specified for reference parameter " + (pos + 1)); - } - name = constructorNames[pos]; - } else if (pos < constructorNames.length && constructorNames[pos] != null - && constructorNames[pos].length() != 0 && !name.equals(constructorNames[pos])) { - String paramNum = String.valueOf(pos + 1); - throw new InvalidConstructorException("Name specified by @Constructor does not match reference name", - paramNum); - } - if (type.getReferences().get(name) != null) { - throw new DuplicateReferenceException(name); - } - reference.setName(name); - reference.setRequired(refAnnotation.required()); - try { - ServiceContract contract = registry.introspect(param); - reference.setServiceContract(contract); - } catch (InvalidServiceContractException e) { - throw new ProcessingException(e); - } - type.getReferences().put(name, reference); - addName(explicitNames, pos, name); - } - - /** - * Processes resource metadata for a constructor parameter - * - * @param resourceAnnot the resource annotation - * @param constructorNames the parameter names as specified in an {@link org.osoa.sca.annotations.Constructor} - * annotation - * @param pos the position of the parameter in the constructor's parameter list - * @param type the component type associated with the implementation being processed - * @param param the parameter type - * @param explicitNames the collection of injection names to update - * @throws ProcessingException - */ - private void processResource( - Resource resourceAnnot, - String[] constructorNames, - int pos, - PojoComponentType> type, - Class param, - List explicitNames) throws ProcessingException { - - org.apache.tuscany.spi.implementation.java.Resource resource = - new org.apache.tuscany.spi.implementation.java.Resource(); - String name = resourceAnnot.name(); - if (name == null || name.length() == 0) { - if (constructorNames.length < pos + 1 || constructorNames[pos] == null - || constructorNames[pos].length() == 0) { - String paramNum = String.valueOf(pos + 1); - throw new InvalidResourceException("No name specified for resource parameter", paramNum); - } - name = constructorNames[pos]; - } else if (pos < constructorNames.length && constructorNames[pos] != null - && constructorNames[pos].length() != 0 && !name.equals(constructorNames[pos])) { - String paramNum = String.valueOf(pos + 1); - throw new InvalidConstructorException("Name specified by @Constructor does not match resource name", - paramNum); - } - if (type.getResources().get(name) != null) { - throw new DuplicateResourceException(name); - } - resource.setName(name); - resource.setOptional(resourceAnnot.optional()); - resource.setType(param); - String mappedName = resourceAnnot.mappedName(); - if (mappedName.length() > 0) { - resource.setMappedName(mappedName); - } - type.add(resource); - addName(explicitNames, pos, name); - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/InitProcessor.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/InitProcessor.java deleted file mode 100644 index be5ac78008..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/InitProcessor.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.implementation.processor; - -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; - -import org.osoa.sca.annotations.Init; - -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.deployer.DeploymentContext; -import org.apache.tuscany.spi.implementation.java.ImplementationProcessorExtension; -import org.apache.tuscany.spi.implementation.java.JavaMappedProperty; -import org.apache.tuscany.spi.implementation.java.JavaMappedReference; -import org.apache.tuscany.spi.implementation.java.JavaMappedService; -import org.apache.tuscany.spi.implementation.java.PojoComponentType; -import org.apache.tuscany.spi.implementation.java.ProcessingException; - -/** - * Processes the {@link @Init} annotation on a component implementation and updates the component type with the - * decorated initializer method - * - * @version $Rev$ $Date$ - */ -public class InitProcessor extends ImplementationProcessorExtension { - - public void visitMethod(CompositeComponent parent, Method method, - PojoComponentType> type, - DeploymentContext context) - throws ProcessingException { - Init annotation = method.getAnnotation(Init.class); - if (annotation == null) { - return; - } - if (method.getParameterTypes().length != 0) { - throw new IllegalInitException("Initializer must not have argments", method.toString()); - } - if (type.getInitMethod() != null) { - throw new DuplicateInitException("More than one initializer found on implementaton"); - } - if (Modifier.isProtected(method.getModifiers())) { - method.setAccessible(true); - } - type.setInitMethod(method); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/InvalidAutowireException.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/InvalidAutowireException.java deleted file mode 100644 index 92a2a0923d..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/InvalidAutowireException.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.implementation.processor; - -import org.apache.tuscany.spi.implementation.java.ProcessingException; - -/** - * Denotes an invalid usage of {@link org.apache.tuscany.spi.annotation.Autowire} - * - * @version $Rev$ $Date$ - */ -public class InvalidAutowireException extends ProcessingException { - - public InvalidAutowireException(String message) { - super(message); - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/InvalidConstructorException.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/InvalidConstructorException.java deleted file mode 100644 index a2dd3f09c4..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/InvalidConstructorException.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.implementation.processor; - -import org.apache.tuscany.spi.implementation.java.ProcessingException; - -/** - * Denotes an invalid constructor definition, e.g. when the number of injection names specified in {@link - * org.osoa.sca.annotations.Constructor} do not match the number of actual constructor parameters - * - * @version $Rev$ $Date$ - */ -public class InvalidConstructorException extends ProcessingException { - - public InvalidConstructorException(String message) { - super(message); - } - - public InvalidConstructorException(String message, String identifier) { - super(message, identifier); - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/InvalidConversationalImplementation.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/InvalidConversationalImplementation.java deleted file mode 100644 index 28bd65200e..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/InvalidConversationalImplementation.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.implementation.processor; - -import org.apache.tuscany.spi.implementation.java.ProcessingException; - -/** - * Raised when an implementation specifies improper conversational metadata - * - * @version $Rev$ $Date$ - */ -public class InvalidConversationalImplementation extends ProcessingException { - - public InvalidConversationalImplementation(String message) { - super(message); - } - - public InvalidConversationalImplementation(String message, String identifier) { - super(message, identifier); - } - - public InvalidConversationalImplementation(String message, Throwable cause) { - super(message, cause); - } - - public InvalidConversationalImplementation(String message, String identifier, Throwable cause) { - super(message, identifier, cause); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/InvalidPropertyException.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/InvalidPropertyException.java deleted file mode 100644 index 5d4c245764..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/InvalidPropertyException.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.implementation.processor; - -import org.apache.tuscany.spi.implementation.java.ProcessingException; - -/** - * Denotes an invalid usage of {@link org.osoa.sca.annotations.Property} - * - * @version $Rev$ $Date$ - */ -public class InvalidPropertyException extends ProcessingException { - - public InvalidPropertyException(String message) { - super(message); - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/InvalidReferenceException.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/InvalidReferenceException.java deleted file mode 100644 index 8fbc07aa1c..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/InvalidReferenceException.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.implementation.processor; - -import org.apache.tuscany.spi.implementation.java.ProcessingException; - -/** - * Denotes an invalid usage of {@link org.osoa.sca.annotations.Reference} - * - * @version $Rev$ $Date$ - */ -public class InvalidReferenceException extends ProcessingException { - - public InvalidReferenceException(String message) { - super(message); - } - - public InvalidReferenceException(String message, Throwable cause) { - super(message, cause); - } - - public InvalidReferenceException(Throwable cause) { - super(cause); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/InvalidResourceException.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/InvalidResourceException.java deleted file mode 100644 index 6ab5a77d8e..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/InvalidResourceException.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.processor; - -import org.apache.tuscany.spi.implementation.java.ProcessingException; - -/** - * Denotes an invalid usage of {@link @org.osoa.sca.annotations.Resource} - * - * @version $Rev$ $Date$ - */ -public class InvalidResourceException extends ProcessingException { - - public InvalidResourceException(String message, String identifier) { - super(message, identifier); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/InvalidServiceType.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/InvalidServiceType.java deleted file mode 100644 index f3d0367661..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/InvalidServiceType.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.implementation.processor; - -import org.apache.tuscany.spi.implementation.java.ProcessingException; - -/** - * Thrown when a service type specified by an {@link org.osoa.sca.annotations.Service} annotation is invalid, e.g. it is - * not an interface - * - * @version $Rev$ $Date$ - */ -public class InvalidServiceType extends ProcessingException { - - public InvalidServiceType(String message, String identifier) { - super(message, identifier); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/MonitorProcessor.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/MonitorProcessor.java deleted file mode 100644 index e7acce2973..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/MonitorProcessor.java +++ /dev/null @@ -1,57 +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.processor; - -import org.apache.tuscany.spi.annotation.Autowire; -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.deployer.DeploymentContext; -import org.apache.tuscany.spi.implementation.java.AbstractPropertyProcessor; -import org.apache.tuscany.spi.implementation.java.ImplementationProcessorService; -import org.apache.tuscany.spi.implementation.java.JavaMappedProperty; - -import org.apache.tuscany.api.annotation.Monitor; -import org.apache.tuscany.core.injection.SingletonObjectFactory; -import org.apache.tuscany.host.MonitorFactory; - -/** - * Processes an {@link @Monitor} annotation, updating the component type with corresponding {@link - * org.apache.tuscany.spi.implementation.java.JavaMappedProperty} - * - * @version $Rev$ $Date$ - */ -public class MonitorProcessor extends AbstractPropertyProcessor { - private MonitorFactory monitorFactory; - - public MonitorProcessor(@Autowire MonitorFactory monitorFactory, @Autowire ImplementationProcessorService service) { - super(Monitor.class, service); - this.monitorFactory = monitorFactory; - } - - protected String getName(Monitor annotation) { - return null; - } - - protected void initProperty(JavaMappedProperty property, - Monitor annotation, - CompositeComponent parent, - DeploymentContext context) { - Class javaType = property.getJavaType(); - property.setDefaultValueFactory(new SingletonObjectFactory(monitorFactory.getMonitor(javaType))); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/NoConstructorException.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/NoConstructorException.java deleted file mode 100644 index f36b7900a4..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/NoConstructorException.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.implementation.processor; - -import org.apache.tuscany.spi.implementation.java.ProcessingException; - -/** - * Thrown when a suitable constructor for a component implementation cannot be found - * - * @version $Rev$ $Date$ - */ -public class NoConstructorException extends ProcessingException { - - public NoConstructorException() { - } - - public NoConstructorException(String message, String identifier) { - super(message, identifier); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/PropertyProcessor.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/PropertyProcessor.java deleted file mode 100644 index 09b3c7383d..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/PropertyProcessor.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.implementation.processor; - -import java.lang.reflect.Constructor; - -import javax.xml.namespace.QName; - -import org.apache.tuscany.spi.annotation.Autowire; -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.databinding.extension.SimpleTypeMapperExtension; -import org.apache.tuscany.spi.deployer.DeploymentContext; -import org.apache.tuscany.spi.idl.TypeInfo; -import org.apache.tuscany.spi.implementation.java.AbstractPropertyProcessor; -import org.apache.tuscany.spi.implementation.java.ImplementationProcessorService; -import org.apache.tuscany.spi.implementation.java.JavaMappedProperty; -import org.apache.tuscany.spi.implementation.java.JavaMappedReference; -import org.apache.tuscany.spi.implementation.java.JavaMappedService; -import org.apache.tuscany.spi.implementation.java.PojoComponentType; -import org.apache.tuscany.spi.implementation.java.ProcessingException; -import org.apache.tuscany.spi.model.OverrideOptions; -import org.osoa.sca.annotations.Property; - -/** - * Processes an {@link @Property} annotation, updating the component type with corresponding {@link JavaMappedProperty} - * - * @version $Rev$ $Date$ - */ -public class PropertyProcessor extends AbstractPropertyProcessor { - private SimpleTypeMapperExtension typeMapper = new SimpleTypeMapperExtension(); - - public PropertyProcessor(@Autowire ImplementationProcessorService service) { - super(Property.class, service); - } - - protected String getName(Property annotation) { - return annotation.name(); - } - - protected void initProperty(JavaMappedProperty property, - Property annotation, - CompositeComponent parent, - DeploymentContext context) { - property.setOverride(OverrideOptions.valueOf(annotation.override().toUpperCase())); - String xmlType = annotation.xmlType(); - if (xmlType != null && xmlType.length() != 0) { - property.setXmlType(QName.valueOf(annotation.xmlType())); - } else { - TypeInfo type = typeMapper.getXMLType(property.getJavaType()); - if (type != null) { - property.setXmlType(type.getQName()); - } - } - } - - public void visitConstructor(CompositeComponent parent, Constructor constructor, - PojoComponentType> type, - DeploymentContext context) throws ProcessingException { - // override since heuristic pojo processor evalautes properties - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ReferenceProcessor.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ReferenceProcessor.java deleted file mode 100644 index 1ee77f0a87..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ReferenceProcessor.java +++ /dev/null @@ -1,150 +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.processor; - -import java.lang.reflect.Constructor; -import java.lang.reflect.Field; -import java.lang.reflect.Method; - -import org.osoa.sca.annotations.Reference; - -import org.apache.tuscany.spi.annotation.Autowire; -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.deployer.DeploymentContext; -import org.apache.tuscany.spi.idl.InvalidServiceContractException; -import org.apache.tuscany.spi.idl.java.JavaInterfaceProcessorRegistry; -import org.apache.tuscany.spi.implementation.java.ImplementationProcessorExtension; -import org.apache.tuscany.spi.implementation.java.JavaMappedProperty; -import org.apache.tuscany.spi.implementation.java.JavaMappedReference; -import org.apache.tuscany.spi.implementation.java.JavaMappedService; -import org.apache.tuscany.spi.implementation.java.PojoComponentType; -import org.apache.tuscany.spi.implementation.java.ProcessingException; -import org.apache.tuscany.spi.model.ServiceContract; - -import static org.apache.tuscany.core.util.JavaIntrospectionHelper.toPropertyName; - -/** - * Processes an {@link @Reference} annotation, updating the component type with corresponding {@link - * org.apache.tuscany.spi.implementation.java.JavaMappedReference} - * - * @version $Rev$ $Date$ - */ -public class ReferenceProcessor extends ImplementationProcessorExtension { - - private JavaInterfaceProcessorRegistry regsitry; - - public ReferenceProcessor(@Autowire JavaInterfaceProcessorRegistry registry) { - this.regsitry = registry; - } - - public void visitMethod(CompositeComponent parent, Method method, - PojoComponentType> type, - DeploymentContext context) - throws ProcessingException { - Reference annotation = method.getAnnotation(Reference.class); - Autowire autowire = method.getAnnotation(Autowire.class); - boolean isAutowire = autowire != null; - if (annotation == null && !isAutowire) { - return; //Not a reference or autowire annotation. - } - if (method.getParameterTypes().length != 1) { - throw new IllegalReferenceException("Setter must have one parameter", method.toString()); - } - //process autowire required first let reference override. or if conflicting should this fault? - boolean required = false; - if (isAutowire) { - required = autowire.required(); - } - - String name = null; - - if (annotation != null) { - if (annotation.name() != null && annotation.name().length() > 0) { - name = annotation.name(); - } - required = annotation.required(); - } - if (name == null) { - name = toPropertyName(method.getName()); - } - if (type.getReferences().get(name) != null) { - throw new DuplicateReferenceException(name); - } - - JavaMappedReference reference = new JavaMappedReference(); - reference.setMember(method); - reference.setAutowire(isAutowire); - reference.setRequired(required); - reference.setName(name); - ServiceContract contract; - try { - contract = regsitry.introspect(method.getParameterTypes()[0]); - } catch (InvalidServiceContractException e) { - throw new ProcessingException(e); - } - reference.setServiceContract(contract); - type.getReferences().put(name, reference); - } - - public void visitField(CompositeComponent parent, Field field, - PojoComponentType> type, - DeploymentContext context) throws ProcessingException { - Reference annotation = field.getAnnotation(Reference.class); - boolean autowire = field.getAnnotation(Autowire.class) != null; - if (annotation == null && !autowire) { - return; - } - String name = field.getName(); - boolean required = false; - if (annotation != null) { - if (annotation.name() != null) { - name = annotation.name(); - } - required = annotation.required(); - } - if (name.length() == 0) { - name = field.getName(); - } - if (type.getReferences().get(name) != null) { - throw new DuplicateReferenceException(name); - } - JavaMappedReference reference = new JavaMappedReference(); - reference.setMember(field); - reference.setRequired(required); - reference.setAutowire(autowire); - reference.setName(name); - ServiceContract contract; - try { - contract = regsitry.introspect(field.getType()); - } catch (InvalidServiceContractException e) { - throw new ProcessingException(e); - } - reference.setServiceContract(contract); - type.getReferences().put(name, reference); - } - - public void visitConstructor(CompositeComponent parent, Constructor constructor, - PojoComponentType> type, - DeploymentContext context) throws ProcessingException { - - } - - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ResourceProcessor.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ResourceProcessor.java deleted file mode 100644 index c60e141f58..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ResourceProcessor.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.implementation.processor; - -import java.lang.reflect.Constructor; -import java.lang.reflect.Field; -import java.lang.reflect.Method; - -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.deployer.DeploymentContext; -import org.apache.tuscany.spi.implementation.java.ImplementationProcessorExtension; -import org.apache.tuscany.spi.implementation.java.JavaMappedProperty; -import org.apache.tuscany.spi.implementation.java.JavaMappedReference; -import org.apache.tuscany.spi.implementation.java.JavaMappedService; -import org.apache.tuscany.spi.implementation.java.PojoComponentType; -import org.apache.tuscany.spi.implementation.java.ProcessingException; -import org.apache.tuscany.spi.implementation.java.Resource; - -import static org.apache.tuscany.core.util.JavaIntrospectionHelper.toPropertyName; - -/** - * Processes an {@link @Resource} annotation, updating the component type with corresponding {@link - * org.apache.tuscany.spi.implementation.java.Resource} - * - * @version $Rev$ $Date$ - */ -public class ResourceProcessor extends ImplementationProcessorExtension { - - public ResourceProcessor() { - } - - public void visitMethod(CompositeComponent parent, Method method, - PojoComponentType> type, - DeploymentContext context) - throws ProcessingException { - org.osoa.sca.annotations.Resource annotation = method.getAnnotation(org.osoa.sca.annotations.Resource.class); - if (annotation == null) { - return; - } - if (method.getParameterTypes().length != 1) { - throw new IllegalResourceException("Resource setter must have one parameter", method.toString()); - } - String name = annotation.name(); - if (name.length() < 1) { - name = toPropertyName(method.getName()); - } - if (type.getResources().get(name) != null) { - throw new DuplicateResourceException(name); - } - - String mappedName = annotation.mappedName(); - Resource resource = new Resource(); - resource.setMember(method); - resource.setType(method.getParameterTypes()[0]); - resource.setOptional(annotation.optional()); - resource.setName(name); - if (mappedName.length() > 0) { - resource.setMappedName(mappedName); - } - type.add(resource); - } - - public void visitField(CompositeComponent parent, Field field, - PojoComponentType> type, - DeploymentContext context) throws ProcessingException { - - org.osoa.sca.annotations.Resource annotation = field.getAnnotation(org.osoa.sca.annotations.Resource.class); - if (annotation == null) { - return; - } - String name = annotation.name(); - if (name.length() < 1) { - name = field.getName(); - } - if (type.getResources().get(name) != null) { - throw new DuplicateResourceException(name); - } - - String mappedName = annotation.mappedName(); - Resource resource = new Resource(); - resource.setMember(field); - resource.setType(field.getType()); - resource.setOptional(annotation.optional()); - resource.setName(name); - if (mappedName.length() > 0) { - resource.setMappedName(mappedName); - } - type.add(resource); - } - - public void visitConstructor(CompositeComponent parent, Constructor constructor, - PojoComponentType> type, - DeploymentContext context) throws ProcessingException { - - } - - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ScopeProcessor.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ScopeProcessor.java deleted file mode 100644 index 634aff0377..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ScopeProcessor.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.implementation.processor; - -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.deployer.DeploymentContext; -import org.apache.tuscany.spi.implementation.java.ImplementationProcessorExtension; -import org.apache.tuscany.spi.implementation.java.JavaMappedProperty; -import org.apache.tuscany.spi.implementation.java.JavaMappedReference; -import org.apache.tuscany.spi.implementation.java.JavaMappedService; -import org.apache.tuscany.spi.implementation.java.PojoComponentType; -import org.apache.tuscany.spi.implementation.java.ProcessingException; -import org.apache.tuscany.spi.model.Scope; - -/** - * Processes the {@link Scope} annotation and updates the component type with the corresponding implmentation scope - * - * @version $Rev$ $Date$ - */ -public class ScopeProcessor extends ImplementationProcessorExtension { - - public void visitClass(CompositeComponent parent, Class clazz, - PojoComponentType> type, - DeploymentContext context) - throws ProcessingException { - org.osoa.sca.annotations.Scope annotation = clazz.getAnnotation(org.osoa.sca.annotations.Scope.class); - if (annotation == null) { - type.setImplementationScope(Scope.STATELESS); - return; - } - String name = annotation.value(); - Scope scope; - if ("COMPOSITE".equals(name)) { - scope = Scope.COMPOSITE; - } else if ("SESSION".equals(name)) { - scope = Scope.SESSION; - } else if ("CONVERSATION".equals(name)) { - scope = Scope.CONVERSATION; - } else if ("REQUEST".equals(name)) { - scope = Scope.REQUEST; - } else if ("SYSTEM".equals(name)) { - scope = Scope.SYSTEM; - } else { - scope = new Scope(name); - } - type.setImplementationScope(scope); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ServiceProcessor.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ServiceProcessor.java deleted file mode 100644 index 6f96c92006..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ServiceProcessor.java +++ /dev/null @@ -1,156 +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.processor; - -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.util.Set; - -import org.osoa.sca.annotations.Callback; -import org.osoa.sca.annotations.Remotable; - -import org.apache.tuscany.spi.annotation.Autowire; -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.deployer.DeploymentContext; -import org.apache.tuscany.spi.idl.InvalidServiceContractException; -import org.apache.tuscany.spi.implementation.java.ImplementationProcessorExtension; -import org.apache.tuscany.spi.implementation.java.JavaMappedProperty; -import org.apache.tuscany.spi.implementation.java.JavaMappedReference; -import org.apache.tuscany.spi.implementation.java.JavaMappedService; -import org.apache.tuscany.spi.implementation.java.PojoComponentType; -import org.apache.tuscany.spi.implementation.java.ProcessingException; -import org.apache.tuscany.spi.implementation.java.ImplementationProcessorService; -import org.apache.tuscany.spi.model.ServiceContract; - -import static org.apache.tuscany.core.util.JavaIntrospectionHelper.getAllInterfaces; -import static org.apache.tuscany.core.util.JavaIntrospectionHelper.toPropertyName; - -/** - * Processes an {@link org.osoa.sca.annotations.Service} annotation and updates the component type with corresponding - * {@link JavaMappedService}s. Also processes related {@link org.osoa.sca.annotations.Callback} annotations. - * - * @version $Rev$ $Date$ - */ -public class ServiceProcessor extends ImplementationProcessorExtension { - - private ImplementationProcessorService implService; - - public ServiceProcessor(@Autowire ImplementationProcessorService implService) { - this.implService = implService; - } - - public void visitClass(CompositeComponent parent, Class clazz, - PojoComponentType> type, - DeploymentContext context) throws ProcessingException { - org.osoa.sca.annotations.Service annotation = clazz.getAnnotation(org.osoa.sca.annotations.Service.class); - if (annotation == null) { - // scan intefaces for remotable - Set interfaces = getAllInterfaces(clazz); - for (Class interfaze : interfaces) { - if (interfaze.getAnnotation(Remotable.class) != null) { - JavaMappedService service; - try { - service = implService.createService(interfaze); - } catch (InvalidServiceContractException e) { - throw new ProcessingException(e); - } - type.getServices().put(service.getName(), service); - } - } - return; - } - Class[] interfaces = annotation.interfaces(); - if (interfaces.length == 0) { - Class interfaze = annotation.value(); - if (Void.class.equals(interfaze)) { - throw new IllegalServiceDefinitionException("No interfaces specified"); - } else { - interfaces = new Class[1]; - interfaces[0] = interfaze; - } - } - for (Class interfaze : interfaces) { - if (!interfaze.isInterface()) { - throw new InvalidServiceType("Service must be an interface", interfaze.getName()); - } - JavaMappedService service; - try { - service = implService.createService(interfaze); - } catch (InvalidServiceContractException e) { - throw new ProcessingException(e); - } - type.getServices().put(service.getName(), service); - } - } - - - public void visitMethod(CompositeComponent parent, - Method method, - PojoComponentType> type, - DeploymentContext context) throws ProcessingException { - - Callback annotation = method.getAnnotation(Callback.class); - if (annotation == null) { - return; - } - if (method.getParameterTypes().length != 1) { - throw new IllegalCallbackReferenceException("Setter must have one parameter", method.toString()); - } - String name = toPropertyName(method.getName()); - JavaMappedService callbackService = null; - Class callbackClass = method.getParameterTypes()[0]; - for (JavaMappedService service : type.getServices().values()) { - ServiceContract serviceContract = service.getServiceContract(); - if (serviceContract.getCallbackClass().equals(callbackClass)) { - callbackService = service; - } - } - if (callbackService == null) { - throw new IllegalCallbackReferenceException("Callback type does not match a service callback interface"); - } - callbackService.setCallbackReferenceName(name); - callbackService.setCallbackMember(method); - } - - public void visitField(CompositeComponent parent, Field field, - PojoComponentType> type, - DeploymentContext context) throws ProcessingException { - - Callback annotation = field.getAnnotation(Callback.class); - if (annotation == null) { - return; - } - String name = field.getName(); - JavaMappedService callbacksService = null; - Class callbackClass = field.getType(); - for (JavaMappedService service : type.getServices().values()) { - ServiceContract serviceContract = service.getServiceContract(); - if (serviceContract.getCallbackClass().equals(callbackClass)) { - callbacksService = service; - } - } - if (callbacksService == null) { - throw new IllegalCallbackReferenceException("Callback type does not match a service callback interface"); - } - callbacksService.setCallbackReferenceName(name); - callbacksService.setCallbackMember(field); - } - - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ServiceTypeNotFoundException.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ServiceTypeNotFoundException.java deleted file mode 100644 index 8a0d4afc3d..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ServiceTypeNotFoundException.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.implementation.processor; - -import org.apache.tuscany.spi.implementation.java.ProcessingException; - -/** - * Thrown when a service interface cannot be determined based on a heuristic evaluation of an implementation - * - * @version $Rev$ $Date$ - */ -public class ServiceTypeNotFoundException extends ProcessingException { - - public ServiceTypeNotFoundException(String message) { - super(message); - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/UnknownContextTypeException.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/UnknownContextTypeException.java deleted file mode 100644 index a7868349a6..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/UnknownContextTypeException.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.implementation.processor; - -/** - * Thrown when a method or field marked with {@link org.osoa.sca.annotations.Context} takes an unknown type - * - * @version $Rev$ $Date$ - */ -public class UnknownContextTypeException extends IllegalContextException { - - public UnknownContextTypeException(String message) { - super(message); - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/builder/SystemComponentBuilder.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/builder/SystemComponentBuilder.java deleted file mode 100644 index 33cbbe1232..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/builder/SystemComponentBuilder.java +++ /dev/null @@ -1,184 +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.system.builder; - -import java.lang.reflect.Constructor; -import java.lang.reflect.Member; -import java.lang.reflect.Method; -import java.util.Collection; -import java.util.Map; - -import org.apache.tuscany.spi.ObjectFactory; -import org.apache.tuscany.spi.annotation.Autowire; -import org.apache.tuscany.spi.builder.BuilderConfigException; -import org.apache.tuscany.spi.component.AtomicComponent; -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.deployer.DeploymentContext; -import org.apache.tuscany.spi.extension.ComponentBuilderExtension; -import org.apache.tuscany.spi.host.ResourceHost; -import org.apache.tuscany.spi.implementation.java.ConstructorDefinition; -import org.apache.tuscany.spi.implementation.java.JavaMappedProperty; -import org.apache.tuscany.spi.implementation.java.JavaMappedReference; -import org.apache.tuscany.spi.implementation.java.PojoComponentType; -import org.apache.tuscany.spi.implementation.java.Resource; -import org.apache.tuscany.spi.model.ComponentDefinition; -import org.apache.tuscany.spi.model.PropertyValue; -import org.apache.tuscany.spi.model.ServiceDefinition; - -import org.apache.tuscany.core.implementation.PojoConfiguration; -import org.apache.tuscany.core.implementation.system.component.SystemAtomicComponentImpl; -import org.apache.tuscany.core.implementation.system.model.SystemImplementation; -import org.apache.tuscany.core.injection.MethodEventInvoker; -import org.apache.tuscany.core.injection.PojoObjectFactory; -import org.apache.tuscany.core.injection.ResourceObjectFactory; - -/** - * Produces system atomic components from a component definition - * - * @version $$Rev$$ $$Date$$ - */ -public class SystemComponentBuilder extends ComponentBuilderExtension { - private ResourceHost host; - - protected Class getImplementationType() { - return SystemImplementation.class; - } - - @Autowire - public void setHost(ResourceHost host) { - this.host = host; - } - - @SuppressWarnings("unchecked") - public AtomicComponent build(CompositeComponent parent, - ComponentDefinition definition, - DeploymentContext deploymentContext) throws BuilderConfigException { - PojoComponentType> componentType = - definition.getImplementation().getComponentType(); - - PojoConfiguration configuration = new PojoConfiguration(); - configuration.setParent(parent); - if (definition.getInitLevel() != null) { - configuration.setInitLevel(definition.getInitLevel()); - } else { - configuration.setInitLevel(componentType.getInitLevel()); - } - Method initMethod = componentType.getInitMethod(); - if (initMethod != null) { - configuration.setInitInvoker(new MethodEventInvoker(initMethod)); - } - Method destroyMethod = componentType.getDestroyMethod(); - if (destroyMethod != null) { - configuration.setDestroyInvoker(new MethodEventInvoker(destroyMethod)); - } - // setup property injection sites - for (JavaMappedProperty property : componentType.getProperties().values()) { - configuration.addPropertySite(property.getName(), property.getMember()); - } - // setup reference injection sites - for (JavaMappedReference reference : componentType.getReferences().values()) { - Member member = reference.getMember(); - if (member != null) { - // could be null if the reference is mapped to a constructor - configuration.addReferenceSite(reference.getName(), member); - } - } - - for (Resource resource : componentType.getResources().values()) { - Member member = resource.getMember(); - if (member != null) { - // could be null if the resource is mapped to a constructor - configuration.addResourceSite(resource.getName(), member); - } - } - - // setup constructor injection - ConstructorDefinition ctorDef = componentType.getConstructorDefinition(); - Constructor constr = ctorDef.getConstructor(); - PojoObjectFactory instanceFactory = new PojoObjectFactory(constr); - configuration.setInstanceFactory(instanceFactory); - configuration.getConstructorParamNames().addAll(ctorDef.getInjectionNames()); - for (Class clazz : constr.getParameterTypes()) { - configuration.addConstructorParamType(clazz); - } - configuration.setName(definition.getName()); - SystemAtomicComponentImpl component = new SystemAtomicComponentImpl(configuration); - // handle properties - Map> propertyValues = definition.getPropertyValues(); - processProperties(propertyValues, componentType.getProperties().values(), component); - - // handle resources - for (Resource resource : componentType.getResources().values()) { - String name = resource.getName(); - boolean optional = resource.isOptional(); - Class type = (Class) resource.getType(); - ResourceObjectFactory factory; - String mappedName = resource.getMappedName(); - if (mappedName == null) { - // by type - factory = new ResourceObjectFactory(type, optional, parent, host); - } else { - factory = new ResourceObjectFactory(type, mappedName, optional, parent, host); - } - component.addResourceFactory(name, factory); - - } - return component; - } - -// private void processReferences(ComponentDefinition definition, -// Map references, -// CompositeComponent parent, -// SystemAtomicComponentImpl component) { -// // no proxies needed for system components -// for (ReferenceTarget target : definition.getReferenceTargets().values()) { -// String referenceName = target.getReferenceName(); -// JavaMappedReference referenceDefiniton = references.get(referenceName); -// Class interfaze = referenceDefiniton.getServiceContract().getInterfaceClass(); -// OutboundWire wire; -// if (referenceDefiniton.isAutowire()) { -// boolean required = referenceDefiniton.isRequired(); -// wire = new SystemOutboundAutowire(referenceName, interfaze, parent, required); -// } else { -// //FIXME support multiplicity! -// assert target.getTargets().size() == 1 : "Multiplicity not yet implemented"; -// QualifiedName targetName = new QualifiedName(target.getTargets().get(0).getPath()); -// wire = new SystemOutboundWireImpl(referenceName, targetName, interfaze); -// } -// component.addOutboundWire(wire); -// } -// } - - private void processProperties(Map> propertyValues, - Collection> properties, - SystemAtomicComponentImpl component) { - for (JavaMappedProperty property : properties) { - PropertyValue value = propertyValues.get(property.getName()); - ObjectFactory factory; - if (value != null) { - factory = value.getValueFactory(); - } else { - factory = property.getDefaultValueFactory(); - } - if (factory != null) { - component.addPropertyFactory(property.getName(), factory); - } - } - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/component/SystemAtomicComponentImpl.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/component/SystemAtomicComponentImpl.java deleted file mode 100644 index c43b0d1ee9..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/component/SystemAtomicComponentImpl.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.system.component; - -import org.apache.tuscany.spi.ObjectFactory; -import org.apache.tuscany.spi.model.Operation; -import org.apache.tuscany.spi.model.Scope; -import org.apache.tuscany.spi.wire.InboundWire; -import org.apache.tuscany.spi.wire.OutboundWire; -import org.apache.tuscany.spi.wire.TargetInvoker; - -import org.apache.tuscany.core.implementation.PojoAtomicComponent; -import org.apache.tuscany.core.implementation.PojoConfiguration; -import org.apache.tuscany.core.wire.OptimizedWireObjectFactory; - -/** - * Default implementation of a system atomic context - * - * @version $$Rev$$ $$Date$$ - */ -public class SystemAtomicComponentImpl extends PojoAtomicComponent { - - public SystemAtomicComponentImpl(PojoConfiguration configuration) { - super(configuration); - scope = Scope.COMPOSITE; - } - - public TargetInvoker createTargetInvoker(String targetName, Operation operation, InboundWire callbackWire) { - return null; - } - - public boolean isSystem() { - return true; - } - - protected ObjectFactory createWireFactory(Class interfaze, OutboundWire wire) { - return new OptimizedWireObjectFactory(wire); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/loader/SystemComponentTypeLoader.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/loader/SystemComponentTypeLoader.java deleted file mode 100644 index 2c7141044b..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/loader/SystemComponentTypeLoader.java +++ /dev/null @@ -1,101 +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.system.loader; - -import java.net.URL; - -import org.apache.tuscany.spi.annotation.Autowire; -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.deployer.DeploymentContext; -import org.apache.tuscany.spi.extension.ComponentTypeLoaderExtension; -import org.apache.tuscany.spi.implementation.java.IntrospectionRegistry; -import org.apache.tuscany.spi.implementation.java.Introspector; -import org.apache.tuscany.spi.implementation.java.JavaMappedProperty; -import org.apache.tuscany.spi.implementation.java.JavaMappedReference; -import org.apache.tuscany.spi.implementation.java.JavaMappedService; -import org.apache.tuscany.spi.implementation.java.PojoComponentType; -import org.apache.tuscany.spi.implementation.java.ProcessingException; -import org.apache.tuscany.spi.loader.LoaderException; -import org.apache.tuscany.spi.loader.LoaderRegistry; -import org.apache.tuscany.spi.model.Scope; - -import org.apache.tuscany.core.implementation.system.model.SystemImplementation; -import org.apache.tuscany.core.util.JavaIntrospectionHelper; - -/** - * Loads a system component type - * - * @version $Rev$ $Date$ - */ -public class SystemComponentTypeLoader extends ComponentTypeLoaderExtension { - private Introspector introspector; - - public SystemComponentTypeLoader() { - } - - public SystemComponentTypeLoader(Introspector introspector) { - this.introspector = introspector; - } - - public SystemComponentTypeLoader(LoaderRegistry loaderRegistry, Introspector introspector) { - super(loaderRegistry); - this.introspector = introspector; - } - - //FIXME autowire to support multiple interfaces - @Autowire - public void setIntrospector(IntrospectionRegistry introspector) { - this.introspector = introspector; - } - - public void load(CompositeComponent parent, - SystemImplementation implementation, - DeploymentContext deploymentContext) throws LoaderException { - Class implClass = implementation.getImplementationClass(); - URL sidefile = implClass.getResource(JavaIntrospectionHelper.getBaseName(implClass) + ".componentType"); - PojoComponentType componentType; - if (sidefile == null) { - componentType = loadByIntrospection(parent, implementation, deploymentContext); - } else { - componentType = loadFromSidefile(sidefile, deploymentContext); - } - // this means system components are always composite scoped - componentType.setImplementationScope(Scope.COMPOSITE); - implementation.setComponentType(componentType); - } - - protected Class getImplementationClass() { - return SystemImplementation.class; - } - - protected PojoComponentType loadByIntrospection(CompositeComponent parent, - SystemImplementation implementation, - DeploymentContext deploymentContext) throws ProcessingException { - PojoComponentType> componentType = - new PojoComponentType>(); - Class implClass = implementation.getImplementationClass(); - introspector.introspect(parent, implClass, componentType, deploymentContext); - return componentType; - } - - - protected PojoComponentType loadFromSidefile(URL url, DeploymentContext deploymentContext) throws LoaderException { - return loaderRegistry.load(null, null, url, PojoComponentType.class, deploymentContext); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/loader/SystemCompositeComponentTypeLoader.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/loader/SystemCompositeComponentTypeLoader.java deleted file mode 100644 index 0e05041ea5..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/loader/SystemCompositeComponentTypeLoader.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.implementation.system.loader; - -import java.net.URL; - -import org.apache.tuscany.spi.component.CompositeComponent; -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.core.deployer.ChildDeploymentContext; -import org.apache.tuscany.core.implementation.system.model.SystemCompositeImplementation; - -/** - * Loads a system composite component type - * - * @version $Rev$ $Date$ - */ -public class SystemCompositeComponentTypeLoader extends ComponentTypeLoaderExtension { - public SystemCompositeComponentTypeLoader() { - } - - public SystemCompositeComponentTypeLoader(LoaderRegistry loaderRegistry) { - super(loaderRegistry); - } - - protected Class getImplementationClass() { - return SystemCompositeImplementation.class; - } - - public void load(CompositeComponent parent, SystemCompositeImplementation implementation, - DeploymentContext deploymentContext) - throws LoaderException { - URL scdlLocation = implementation.getScdlLocation(); - if (scdlLocation == null) { - throw new LoaderException("SCDL location not found"); - } - ClassLoader cl = implementation.getClassLoader(); - deploymentContext = new ChildDeploymentContext(deploymentContext, cl, scdlLocation); - CompositeComponentType componentType = loadFromSidefile(parent, scdlLocation, deploymentContext); - implementation.setComponentType(componentType); - } - - - protected CompositeComponentType loadFromSidefile(CompositeComponent parent, - URL url, - DeploymentContext deploymentContext) - throws LoaderException { - return loaderRegistry.load(parent, null, url, CompositeComponentType.class, deploymentContext); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/loader/SystemImplementationLoader.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/loader/SystemImplementationLoader.java deleted file mode 100644 index d5d4269880..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/loader/SystemImplementationLoader.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.implementation.system.loader; - -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamConstants; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; - -import org.apache.tuscany.spi.annotation.Autowire; -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.deployer.DeploymentContext; -import org.apache.tuscany.spi.extension.LoaderExtension; -import org.apache.tuscany.spi.loader.LoaderException; -import org.apache.tuscany.spi.loader.LoaderRegistry; -import org.apache.tuscany.spi.loader.LoaderUtil; -import org.apache.tuscany.spi.loader.UnrecognizedElementException; -import org.apache.tuscany.spi.model.ModelObject; - -import org.apache.tuscany.core.implementation.system.model.SystemImplementation; - -/** - * Loads information for a system implementation - * - * @version $Rev$ $Date$ - */ -public class SystemImplementationLoader extends LoaderExtension { - public static final QName SYSTEM_IMPLEMENTATION = - new QName("http://tuscany.apache.org/xmlns/system/1.0-SNAPSHOT", "implementation.system"); - - public SystemImplementationLoader(@Autowire LoaderRegistry registry) { - super(registry); - } - - public SystemImplementation load(CompositeComponent parent, - ModelObject object, XMLStreamReader reader, - DeploymentContext deploymentContext) - throws XMLStreamException, LoaderException { - assert SYSTEM_IMPLEMENTATION.equals(reader.getName()); - SystemImplementation implementation = new SystemImplementation(); - String implClass = reader.getAttributeValue(null, "class"); - Class implementationClass = LoaderUtil.loadClass(implClass, deploymentContext.getClassLoader()); - implementation.setImplementationClass(implementationClass); - registry.loadComponentType(parent, implementation, deploymentContext); - while (true) { - int code = reader.next(); - if (code == XMLStreamConstants.START_ELEMENT) { - throw new UnrecognizedElementException(reader.getName()); - } else if (code == XMLStreamConstants.END_ELEMENT) { - return implementation; - } - } - } - - public QName getXMLType() { - return SYSTEM_IMPLEMENTATION; - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/model/SystemCompositeImplementation.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/model/SystemCompositeImplementation.java deleted file mode 100644 index e634609c5b..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/model/SystemCompositeImplementation.java +++ /dev/null @@ -1,57 +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.system.model; - -import java.net.URL; - -import org.apache.tuscany.spi.model.CompositeComponentType; -import org.apache.tuscany.spi.model.Implementation; - -/** - * Represents a system composite type - * - * @version $Rev$ $Date$ - */ -public class SystemCompositeImplementation extends Implementation { - private URL scdlLocation; - private ClassLoader classLoader; - - public SystemCompositeImplementation() { - } - - public SystemCompositeImplementation(CompositeComponentType componentType) { - super(componentType); - } - - public URL getScdlLocation() { - return scdlLocation; - } - - public void setScdlLocation(URL scdlLocation) { - this.scdlLocation = scdlLocation; - } - - public ClassLoader getClassLoader() { - return classLoader; - } - - public void setClassLoader(ClassLoader classLoader) { - this.classLoader = classLoader; - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/model/SystemImplementation.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/model/SystemImplementation.java deleted file mode 100644 index ce48ed3fe5..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/model/SystemImplementation.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.system.model; - -import org.apache.tuscany.spi.implementation.java.PojoComponentType; -import org.apache.tuscany.spi.model.AtomicImplementation; - -/** - * Represents the system composite implementation - * - * @version $Rev$ $Date$ - */ -public class SystemImplementation extends AtomicImplementation { - private Class implementationClass; - - public SystemImplementation(PojoComponentType componentType, Class implementationClass) { - super(componentType); - this.implementationClass = implementationClass; - } - - public SystemImplementation() { - } - - public SystemImplementation(Class implementationClass) { - this.implementationClass = implementationClass; - } - - public Class getImplementationClass() { - return implementationClass; - } - - public void setImplementationClass(Class implementationClass) { - this.implementationClass = implementationClass; - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/ArrayMultiplicityObjectFactory.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/ArrayMultiplicityObjectFactory.java deleted file mode 100644 index 1a441dcf87..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/ArrayMultiplicityObjectFactory.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.injection; - -import java.lang.reflect.Array; -import java.util.List; - -import org.apache.tuscany.spi.ObjectCreationException; -import org.apache.tuscany.spi.ObjectFactory; - -/** - * Resolves targets configured in a multiplicity by delegating to object factories and returning an Array - * containing object instances - * - * @version $Rev$ $Date$ - */ -public class ArrayMultiplicityObjectFactory implements ObjectFactory { - - private ObjectFactory[] factories; - - private Class interfaceType; - - public ArrayMultiplicityObjectFactory(Class interfaceType, List> factories) { - assert interfaceType != null : "Interface type was null"; - assert factories != null : "Object factories were null"; - this.interfaceType = interfaceType; - this.factories = factories.toArray(new ObjectFactory[factories.size()]); - } - - public Object getInstance() throws ObjectCreationException { - Object array = Array.newInstance(interfaceType, factories.length); - for (int i = 0; i < factories.length; i++) { - Array.set(array, i, factories[i].getInstance()); - } - return array; - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/CallbackWireObjectFactory.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/CallbackWireObjectFactory.java deleted file mode 100644 index fc389a23cf..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/CallbackWireObjectFactory.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.injection; - -import org.apache.tuscany.spi.ObjectCreationException; -import org.apache.tuscany.spi.ObjectFactory; -import org.apache.tuscany.spi.wire.InboundWire; -import org.apache.tuscany.spi.wire.WireService; - -/** - * Returns proxy instance for a wire callback - * - * @version $Rev$ $Date$ - */ -public class CallbackWireObjectFactory implements ObjectFactory { - - private WireService wireService; - private Class interfaze; - private InboundWire wire; - - public CallbackWireObjectFactory(Class interfaze, WireService wireService, InboundWire wire) { - this.interfaze = interfaze; - this.wireService = wireService; - this.wire = wire; - } - - public Object getInstance() throws ObjectCreationException { - return wireService.createCallbackProxy(interfaze, wire); - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/CompositeContextObjectFactory.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/CompositeContextObjectFactory.java deleted file mode 100644 index f904484e78..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/CompositeContextObjectFactory.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.injection; - -import org.osoa.sca.CompositeContext; - -import org.apache.tuscany.spi.ObjectCreationException; -import org.apache.tuscany.spi.ObjectFactory; -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.wire.WireService; - -import org.apache.tuscany.core.implementation.composite.ManagedCompositeContext; - -/** - * Creates instances of {@link org.apache.tuscany.core.implementation.composite.ManagedCompositeContext} for injection - * on component implementation instances - * - * @version $Rev$ $Date$ - */ -public class CompositeContextObjectFactory implements ObjectFactory { - private CompositeComponent composite; - private WireService wireService; - - public CompositeContextObjectFactory(CompositeComponent composite, WireService wireService) { - assert composite != null; - assert wireService != null; - this.composite = composite; - this.wireService = wireService; - } - - public CompositeContext getInstance() throws ObjectCreationException { - return new ManagedCompositeContext(composite, wireService); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/ContextInjector.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/ContextInjector.java deleted file mode 100644 index a422500f3c..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/ContextInjector.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.injection; - -import org.apache.tuscany.spi.ObjectCreationException; - -/** - * Implementations inject a pre-configured context type (interface) on an instance. - * - * @version $Rev$ $Date$ - */ -public interface ContextInjector extends Injector { - - void setContext(S context) throws ObjectCreationException; - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/ConversationIDObjectFactory.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/ConversationIDObjectFactory.java deleted file mode 100644 index 8dbc0a3a83..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/ConversationIDObjectFactory.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.injection; - -import org.apache.tuscany.spi.ObjectFactory; -import org.apache.tuscany.spi.component.WorkContext; -import org.apache.tuscany.spi.model.Scope; - -public class ConversationIDObjectFactory implements ObjectFactory { - - private WorkContext workContext; - - public ConversationIDObjectFactory(WorkContext workContext) { - this.workContext = workContext; - } - - public String getInstance() { - return (String)workContext.getIdentifier(Scope.CONVERSATION); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/EventInvoker.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/EventInvoker.java deleted file mode 100644 index af2382b36a..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/EventInvoker.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.injection; - -/** - * Performs an invocation on an instance - * - * @version $Rev$ $Date$ - */ -public interface EventInvoker { - - /** - * Performs the invocation on a given instance - * - * @throws ObjectCallbackException - */ - void invokeEvent(T instance) throws ObjectCallbackException; -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/FieldInjector.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/FieldInjector.java deleted file mode 100644 index e9f8f42aa1..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/FieldInjector.java +++ /dev/null @@ -1,57 +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 java.lang.reflect.Field; - -import org.apache.tuscany.spi.ObjectCreationException; -import org.apache.tuscany.spi.ObjectFactory; - -/** - * Injects a value created by an {@link org.apache.tuscany.spi.ObjectFactory} on a given field - * - * @version $Rev$ $Date$ - */ -public class FieldInjector implements Injector { - - private final Field field; - - private final ObjectFactory objectFactory; - - /** - * Create an injector and have it use the given ObjectFactory to inject a value on the instance using - * the reflected Field - */ - public FieldInjector(Field field, ObjectFactory objectFactory) { - this.field = field; - this.field.setAccessible(true); - this.objectFactory = objectFactory; - } - - /** - * Inject a new value on the given isntance - */ - public void inject(T instance) throws ObjectCreationException { - try { - field.set(instance, objectFactory.getInstance()); - } catch (IllegalAccessException e) { - throw new AssertionError("Field is not accessible [" + field + "]"); - } - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/InjectionRuntimeException.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/InjectionRuntimeException.java deleted file mode 100644 index c5f037d931..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/InjectionRuntimeException.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.injection; - -import org.apache.tuscany.api.TuscanyRuntimeException; - -/** - * Root unchecked exception for the injection package - * - * @version $Rev$ $Date$ - */ -public abstract class InjectionRuntimeException extends TuscanyRuntimeException { - - public InjectionRuntimeException() { - super(); - } - - public InjectionRuntimeException(String message) { - super(message); - } - - - protected InjectionRuntimeException(String message, String identifier) { - super(message, identifier); - } - - public InjectionRuntimeException(String message, Throwable cause) { - super(message, cause); - } - - protected InjectionRuntimeException(String message, String identifier, Throwable cause) { - super(message, identifier, cause); - } - - public InjectionRuntimeException(Throwable cause) { - super(cause); - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/Injector.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/Injector.java deleted file mode 100644 index c2125d8212..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/Injector.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.injection; - -import org.apache.tuscany.spi.ObjectCreationException; - -/** - * Implementations inject a pre-configured value on an instance - * - * @version $Rev$ $Date$ - */ -public interface Injector { - - /** - * Inject a value on the given instance - */ - void inject(T instance) throws ObjectCreationException; - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/InvalidAccessorException.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/InvalidAccessorException.java deleted file mode 100644 index 2e7ff0e754..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/InvalidAccessorException.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.injection; - -/** - * @version $$Rev$$ $$Date$$ - */ -public class InvalidAccessorException extends InjectionRuntimeException { - - public InvalidAccessorException(String message) { - super(message); - } - - public InvalidAccessorException(String message, String identifier) { - super(message, identifier); - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/InvalidResourceTypeException.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/InvalidResourceTypeException.java deleted file mode 100644 index 1a3eaf4d1a..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/InvalidResourceTypeException.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 org.apache.tuscany.spi.ObjectCreationException; - -/** - * Denotes an invalid resource type, i.e. that is not a component - * - * @version $Rev$ $Date$ - */ -public class InvalidResourceTypeException extends ObjectCreationException { - - public InvalidResourceTypeException(String message, String identifier) { - super(message, identifier); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/JNDIObjectFactory.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/JNDIObjectFactory.java deleted file mode 100644 index 0189d8245b..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/JNDIObjectFactory.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.injection; - -import javax.naming.Context; -import javax.naming.NamingException; - -import org.apache.tuscany.spi.ObjectCreationException; -import org.apache.tuscany.spi.ObjectFactory; - -/** - * An implementation of ObjectFactory that creates instances by looking them up in a JNDI context. - * - * @version $Rev$ $Date$ - */ -public class JNDIObjectFactory implements ObjectFactory { - private final Context context; - private final String name; - - public JNDIObjectFactory(Context context, String name) { - this.context = context; - this.name = name; - } - - - @SuppressWarnings("unchecked") - public T getInstance() throws ObjectCreationException { - try { - return (T) context.lookup(name); - } catch (NamingException e) { - throw new ObjectCreationException(e); - } - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/ListMultiplicityObjectFactory.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/ListMultiplicityObjectFactory.java deleted file mode 100644 index b261bcda53..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/ListMultiplicityObjectFactory.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.injection; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.tuscany.spi.ObjectCreationException; -import org.apache.tuscany.spi.ObjectFactory; - -/** - * Resolves targets configured in a multiplicity by delegating to object factories and returning an List - * containing object instances - * - * @version $Rev$ $Date$ - */ -public class ListMultiplicityObjectFactory implements ObjectFactory { - - private ObjectFactory[] factories; - - public ListMultiplicityObjectFactory(List> factories) { - assert factories != null : "Object factories were null"; - this.factories = factories.toArray(new ObjectFactory[factories.size()]); - } - - public List getInstance() throws ObjectCreationException { - List list = new ArrayList(); - for (ObjectFactory factory : factories) { - list.add(factory.getInstance()); - } - return list; - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/MethodEventInvoker.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/MethodEventInvoker.java deleted file mode 100644 index e43a1e1fa6..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/MethodEventInvoker.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.injection; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - -/** - * Performs an wire on a method of a given instance - * - * @version $Rev$ $Date$ - */ -public class MethodEventInvoker implements EventInvoker { - private final Method method; - - /** - * Intantiates an invoker for the given method - */ - public MethodEventInvoker(Method method) { - assert method != null; - this.method = method; - } - - public void invokeEvent(T instance) throws ObjectCallbackException { - try { - method.invoke(instance, (Object[]) null); - } catch (IllegalArgumentException e) { - String name = method.getName(); - throw new ObjectCallbackException("Exception thrown by callback method [" + name + "]", e.getCause()); - } catch (IllegalAccessException e) { - String name = method.getName(); - throw new AssertionError("Method is not accessible [" + name + "]"); - } catch (InvocationTargetException e) { - String name = method.getName(); - throw new ObjectCallbackException("Exception thrown by callback method [" + name + "]", e.getCause()); - } - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/MethodInjector.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/MethodInjector.java deleted file mode 100644 index 258f0817dd..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/MethodInjector.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.injection; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - -import org.apache.tuscany.spi.ObjectCreationException; -import org.apache.tuscany.spi.ObjectFactory; - -/** - * Injects a value created by an {@link org.apache.tuscany.spi.ObjectFactory} using a given method - * - * @version $Rev$ $Date$ - */ -public class MethodInjector implements Injector { - private final Method method; - private final ObjectFactory objectFactory; - - public MethodInjector(Method method, ObjectFactory objectFactory) { - assert method != null; - assert objectFactory != null; - this.method = method; - this.method.setAccessible(true); - this.objectFactory = objectFactory; - } - - public void inject(T instance) throws ObjectCreationException { - try { - method.invoke(instance, objectFactory.getInstance()); - } catch (IllegalAccessException e) { - throw new AssertionError("Method is not accessible [" + method + "]"); - } catch (IllegalArgumentException e) { - throw new ObjectCreationException("Exception thrown by setter", method.getName(), e); - } catch (InvocationTargetException e) { - throw new ObjectCreationException("Exception thrown by setter", method.getName(), e); - } - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/NoAccessorException.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/NoAccessorException.java deleted file mode 100644 index b3109074e3..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/NoAccessorException.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; - -/** - * @version $$Rev$$ $$Date$$ - */ -public class NoAccessorException extends InjectionRuntimeException { - public NoAccessorException() { - } - - public NoAccessorException(String message) { - super(message); - } - - public NoAccessorException(String message, Throwable cause) { - super(message, cause); - } - - public NoAccessorException(Throwable cause) { - super(cause); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/NoMultiplicityTypeException.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/NoMultiplicityTypeException.java deleted file mode 100644 index a86451525b..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/NoMultiplicityTypeException.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.injection; - -/** - * @version $Rev$ $Date$ - */ -public class NoMultiplicityTypeException extends InjectionRuntimeException { - - public NoMultiplicityTypeException(String message, String identifier) { - super(message, identifier); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/ObjectCallbackException.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/ObjectCallbackException.java deleted file mode 100644 index ff830aab4b..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/ObjectCallbackException.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.injection; - -/** - * Denotes an error when invoking on an object - * - * @version $Rev$ $Date$ - */ -public class ObjectCallbackException extends InjectionRuntimeException { - - public ObjectCallbackException() { - super(); - } - - public ObjectCallbackException(String message) { - super(message); - } - - public ObjectCallbackException(String message, String identifier) { - super(message, identifier); - } - - public ObjectCallbackException(String message, Throwable cause) { - super(message, cause); - } - - public ObjectCallbackException(Throwable cause) { - super(cause); - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/PojoObjectFactory.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/PojoObjectFactory.java deleted file mode 100644 index aadd6297ea..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/PojoObjectFactory.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.injection; - -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; -import java.util.List; - -import org.apache.tuscany.spi.ObjectCreationException; -import org.apache.tuscany.spi.ObjectFactory; - -/** - * Creates new instances of a Java class - * - * @version $Rev$ $Date$ - * @see org.apache.tuscany.core.injection.Injector - */ -public class PojoObjectFactory implements ObjectFactory { - - private final Constructor ctr; - private ObjectFactory[] initializerFactories; - - /** - * Creates the object factory - * - * @param ctr the constructor to use when instantiating a new object - */ - public PojoObjectFactory(Constructor ctr) { - assert ctr != null; - this.ctr = ctr; - initializerFactories = new ObjectFactory[ctr.getParameterTypes().length]; - } - - /** - * Creates the object factory - * - * @param ctr the constructor to use when instantiating a new object - * @param factories an ordered list of ObjectFactorys to use for returning constructor parameters - */ - public PojoObjectFactory(Constructor ctr, List factories) { - assert ctr != null; - int params = ctr.getParameterTypes().length; - assert params == factories.size(); - this.ctr = ctr; - initializerFactories = new ObjectFactory[params]; - int i = 0; - for (ObjectFactory factory : factories) { - initializerFactories[i] = factory; - i++; - } - } - - /** - * Returns the ordered array of ObjectFactorys use in creating constructor parameters - */ - public ObjectFactory[] getInitializerFactories() { - return initializerFactories; - } - - /** - * Sets an ObjectFactorys to use in creating constructor parameter - * - * @param pos the constructor parameter position - * @param factory the object factory - */ - public void setInitializerFactory(int pos, ObjectFactory factory) { - assert pos < initializerFactories.length; - initializerFactories[pos] = factory; - } - - /** - * Creates a new instance of an object - */ - public T getInstance() throws ObjectCreationException { - int size = initializerFactories.length; - Object[] initargs = new Object[size]; - // create the constructor arg array - for (int i = 0; i < size; i++) { - ObjectFactory objectFactory = initializerFactories[i]; - if (objectFactory == null) { - String name = ctr.getName(); - throw new ObjectCallbackException("Null object factory for constructor parameter [" + i + "]", name); - } - initargs[i] = objectFactory.getInstance(); - } - try { - ctr.setAccessible(true); - return ctr.newInstance(initargs); - } catch (IllegalArgumentException e) { - String name = ctr.getName(); - throw new ObjectCreationException("Exception thrown by constructor", name, e); - } catch (InstantiationException e) { - String name = ctr.getDeclaringClass().getName(); - throw new AssertionError("Class is not instantiable [" + name + "]"); - } catch (IllegalAccessException e) { - String name = ctr.getName(); - throw new AssertionError("Constructor is not accessible [" + name + "]"); - } catch (InvocationTargetException e) { - String name = ctr.getName(); - throw new ObjectCreationException("Exception thrown by constructor", name, e); - } - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/RequestContextObjectFactory.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/RequestContextObjectFactory.java deleted file mode 100644 index 9a9d97a273..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/RequestContextObjectFactory.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.apache.tuscany.core.injection; - -import org.apache.tuscany.spi.ObjectCreationException; -import org.apache.tuscany.spi.ObjectFactory; -import org.apache.tuscany.spi.component.WorkContext; - -import org.apache.tuscany.core.implementation.composite.ManagedRequestContext; - -/** - * Creates instances of {@link org.apache.tuscany.core.implementation.composite.ManagedRequestContext} for injection on - * component implementation instances - * - * @version $Rev$ $Date$ - */ -public class RequestContextObjectFactory implements ObjectFactory { - private WorkContext workContext; - - public RequestContextObjectFactory(WorkContext workContext) { - assert workContext != null; - this.workContext = workContext; - } - - public ManagedRequestContext getInstance() throws ObjectCreationException { - return new ManagedRequestContext(workContext); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/ResourceNotFoundException.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/ResourceNotFoundException.java deleted file mode 100644 index ed3ac20631..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/ResourceNotFoundException.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.injection; - -import org.apache.tuscany.spi.ObjectCreationException; - -/** - * Denotes an exception thrown when a runtime resource is not found - * - * @version $Rev$ $Date$ - */ -public class ResourceNotFoundException extends ObjectCreationException { - - public ResourceNotFoundException(String message, String identifier) { - super(message, identifier); - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/ResourceObjectFactory.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/ResourceObjectFactory.java deleted file mode 100644 index a68702157b..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/ResourceObjectFactory.java +++ /dev/null @@ -1,146 +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.ObjectCreationException; -import org.apache.tuscany.spi.ObjectFactory; -import org.apache.tuscany.spi.component.AtomicComponent; -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.component.SCAObject; -import org.apache.tuscany.spi.component.TargetResolutionException; -import org.apache.tuscany.spi.host.ResourceHost; -import org.apache.tuscany.spi.host.ResourceResolutionException; -import org.apache.tuscany.spi.wire.InboundWire; - -/** - * Resolves a runtime resource to be injected on a field or method of a Java component type marked with {@link - * org.osoa.sca.annotations.Resource}. If the mapped name of the resource is an absolute URI such as - * sca://localhost or jndi://localhost the host container namespace is searched; otherwise the - * URI is assumed to be relative and the parent composite is searched. If a mapped name is not provided, i.e. resolution - * is by type, the parent composite is first searched followed by the host namespace. - * - * @version $Rev$ $Date$ - */ -public class ResourceObjectFactory implements ObjectFactory { - - private Class type; - private String mappedName; - private CompositeComponent parent; - private ResourceHost host; - private boolean resolveFromHost; - private boolean optional; - - /** - * Instantiates a factory that resolves resources by type - * - * @param type the type of the resource to inject - * @param optional true if an error should be thrown if the resource is not found - * @param parent the parent composite of the component to inject on - * @param host the runtime resource provider - */ - public ResourceObjectFactory(Class type, - boolean optional, - CompositeComponent parent, - ResourceHost host) { - this.type = type; - this.parent = parent; - this.host = host; - this.optional = optional; - } - - /** - * Instantiates a factory that resolves resources by mapped name - * - * @param type the type of the resource to inject - * @param mappedName the resource name - * @param optional true if an error should be thrown if the resource is not found - * @param parent the parent composite of the component to inject on - * @param host the runtime resource provider - */ - public ResourceObjectFactory(Class type, - String mappedName, - boolean optional, - CompositeComponent parent, - ResourceHost host) { - this.type = type; - this.parent = parent; - this.host = host; - if (mappedName.indexOf("://") >= 0) { - this.resolveFromHost = true; - } - this.mappedName = mappedName; - this.optional = optional; - } - - @SuppressWarnings({"unchecked"}) - public T getInstance() throws ObjectCreationException { - if (resolveFromHost) { - return resolveInstance(); - } else { - T instance = null; - if (mappedName == null) { - try { - InboundWire wire = parent.resolveSystemAutowire(type); - if (wire != null) { - instance = (T) wire.getTargetService(); - } - } catch (TargetResolutionException e) { - throw new ObjectCreationException(e); - } - if (instance == null) { - // if not found in parent scope, search the host namespace - resolveFromHost = true; - instance = resolveInstance(); - } - if (instance == null && !optional) { - throw new ResourceNotFoundException("No resource found matching type", type.getName()); - } - return instance; - } else { - SCAObject child = parent.getSystemChild(mappedName); - if (child instanceof AtomicComponent) { - try { - AtomicComponent component = (AtomicComponent) child; - instance = type.cast(component.getTargetInstance()); - } catch (TargetResolutionException e) { - throw new ObjectCreationException(e); - } - } else if (child != null) { - throw new InvalidResourceTypeException("Invalid resource type", mappedName); - } else if (!optional) { - throw new ResourceNotFoundException("No resource found for URI", mappedName); - } - return instance; - } - } - } - - private T resolveInstance() { - try { - if (mappedName == null) { - return host.resolveResource(type); - } else { - return host.resolveResource(type, mappedName); - } - } catch (ResourceResolutionException e) { - throw new ObjectCreationException(e); - } - - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/SingletonObjectFactory.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/injection/SingletonObjectFactory.java deleted file mode 100644 index 713c1ae54f..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/launcher/CompositeContextImpl.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/launcher/CompositeContextImpl.java deleted file mode 100644 index 246ef8bdf7..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/launcher/CompositeContextImpl.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.launcher; - -import org.osoa.sca.RequestContext; -import org.osoa.sca.ServiceReference; - -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.wire.WireService; - -import org.apache.tuscany.core.implementation.composite.AbstractCompositeContext; - - -/** - * Default implementation of the {@link org.osoa.sca.CompositeContext} for non-managed code - * - * @version $Rev$ $Date$ - */ -public class CompositeContextImpl extends AbstractCompositeContext { - - public CompositeContextImpl(final CompositeComponent composite, final WireService wireService) { - super(composite, wireService); - } - - public ServiceReference createServiceReferenceForSession(Object arg0) { - throw new UnsupportedOperationException(); - } - - public ServiceReference createServiceReferenceForSession(Object arg0, String arg1) { - throw new UnsupportedOperationException(); - } - - public RequestContext getRequestContext() { - throw new UnsupportedOperationException(); - } - - public ServiceReference newSession(String arg0) { - throw new UnsupportedOperationException(); - } - - public ServiceReference newSession(String arg0, Object arg1) { - throw new UnsupportedOperationException(); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/launcher/LaunchException.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/launcher/LaunchException.java deleted file mode 100644 index 730f29611a..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/launcher/LaunchException.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.launcher; - -import org.apache.tuscany.api.TuscanyException; - -/** - * Exception indicating that there was a problem launching an application. - * - * @version $Rev$ $Date$ - */ -public abstract class LaunchException extends TuscanyException { - - protected LaunchException(String message) { - super(message); - } - - protected LaunchException(String message, String identifier) { - super(message, identifier); - } - - protected LaunchException(String message, String identifier, Throwable cause) { - super(message, identifier, cause); - } - - protected LaunchException(String message, Throwable cause) { - super(message, cause); - } - - protected LaunchException(Throwable cause) { - super(cause); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/launcher/LauncherImpl.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/launcher/LauncherImpl.java deleted file mode 100644 index adf95a9bd9..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/launcher/LauncherImpl.java +++ /dev/null @@ -1,250 +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.launcher; - -import java.io.File; -import java.net.URL; -import java.util.ArrayList; -import java.util.List; -import javax.xml.stream.XMLInputFactory; - -import org.osoa.sca.CompositeContext; - -import org.apache.tuscany.spi.bootstrap.ComponentNames; -import org.apache.tuscany.spi.bootstrap.RuntimeComponent; -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.component.SCAObject; -import org.apache.tuscany.spi.component.AtomicComponent; -import org.apache.tuscany.spi.deployer.Deployer; -import org.apache.tuscany.spi.loader.LoaderException; -import org.apache.tuscany.spi.model.ComponentDefinition; -import org.apache.tuscany.spi.model.CompositeImplementation; -import org.apache.tuscany.spi.services.management.TuscanyManagementService; - -import org.apache.tuscany.api.TuscanyException; -import org.apache.tuscany.core.bootstrap.Bootstrapper; -import org.apache.tuscany.core.bootstrap.DefaultBootstrapper; -import org.apache.tuscany.core.implementation.system.model.SystemCompositeImplementation; -import org.apache.tuscany.host.Launcher; -import org.apache.tuscany.host.MonitorFactory; -import org.apache.tuscany.host.RuntimeInfo; -import org.apache.tuscany.host.runtime.InitializationException; -import org.apache.tuscany.host.monitor.FormatterRegistry; - -/** - * Basic launcher implementation. - * - * @version $Rev$ $Date$ - */ -public class LauncherImpl implements Launcher { - /** - * A conventional META-INF based location for the system SCDL. - * - * @see #bootRuntime(URL,MonitorFactory) - */ - public static final String METAINF_SYSTEM_SCDL_PATH = "META-INF/tuscany/system.scdl"; - - /** - * A conventional META-INF based location for the application SCDL. - */ - public static final String METAINF_APPLICATION_SCDL_PATH = "META-INF/sca/default.scdl"; - - private ClassLoader applicationLoader; - - private RuntimeComponent runtime; - - private Deployer deployer; - - private CompositeComponent composite; - - public void bootRuntime(URL systemScdl, ClassLoader systemClassLoader, MonitorFactory monitor) - throws TuscanyException { - if (systemScdl == null) { - throw new LoaderException("Null system SCDL URL"); - } - - XMLInputFactory xmlFactory = XMLInputFactory.newInstance("javax.xml.stream.XMLInputFactory", systemClassLoader); - TuscanyManagementService managementService = null; - Bootstrapper bootstrapper = new DefaultBootstrapper(monitor, xmlFactory, managementService); - Deployer bootDeployer = bootstrapper.createDeployer(); - - // create and start the core runtime - runtime = bootstrapper.createRuntime(); - runtime.start(); - - // initialize the runtime info - CompositeComponent parent = runtime.getSystemComponent(); - RuntimeInfo runtimeInfo = new LauncherRuntimeInfo(getInstallDirectory(), getApplicationRootDirectory(), true); - parent.registerJavaObject("RuntimeInfo", RuntimeInfo.class, runtimeInfo); - - // register the monitor factory - if (monitor instanceof FormatterRegistry) { - List> interfazes = new ArrayList>(2); - interfazes.add(MonitorFactory.class); - interfazes.add(FormatterRegistry.class); - parent.registerJavaObject("MonitorFactory", interfazes, monitor); - } else { - parent.registerJavaObject("MonitorFactory", MonitorFactory.class, monitor); - } - parent.start(); - // create a ComponentDefinition to represent the component we are going to deploy - SystemCompositeImplementation compositeImplementation = new SystemCompositeImplementation(); - compositeImplementation.setScdlLocation(systemScdl); - compositeImplementation.setClassLoader(systemClassLoader); - ComponentDefinition definition = - new ComponentDefinition( - ComponentNames.TUSCANY_SYSTEM, compositeImplementation); - try { - // deploy the component into the runtime under the system parent - composite = (CompositeComponent) bootDeployer.deploy(parent, definition); - } catch (TuscanyException e) { - e.addContextName(definition.getName()); - throw e; - } - // start the system - composite.start(); - - SCAObject child = composite.getSystemChild(ComponentNames.TUSCANY_DEPLOYER); - if (!(child instanceof AtomicComponent)) { - throw new InitializationException("Deployer must be an atomic component"); - } - deployer = (Deployer) ((AtomicComponent) child).getTargetInstance(); - runtime.getRootComponent().start(); - } - - /** - * Shuts down the active runtime being managed by this instance. - */ - public void shutdownRuntime() { - if (composite != null) { - composite.stop(); - composite = null; - } - - if (runtime != null) { - runtime.stop(); - runtime = null; - } - } - - public CompositeContext bootApplication(URL applicationScdl, ClassLoader applicationLoader) { - // FIXME implement - throw new UnsupportedOperationException(); - } - - /** - * Returns the classloader for application classes. - * - * @return the classloader for application classes - */ - public ClassLoader getApplicationLoader() { - return applicationLoader; - } - - /** - * Set the classloader to be used for application classes. You should almost always supply your own application - * classloader, based on the hosting environment that the runtime is embedded in. - * - * @param applicationLoader the classloader to be used for application classes - */ - public void setApplicationLoader(ClassLoader applicationLoader) { - this.applicationLoader = applicationLoader; - } - - /** - * Boots the runtime defined by the specified SCDL. - * - * @param systemScdl a resource path to the SCDL defining the system. - * @return a CompositeComponent for the newly booted runtime system - * @throws LoaderException - */ - @Deprecated - public CompositeComponent bootRuntime(URL systemScdl, MonitorFactory monitor) throws TuscanyException { - ClassLoader systemClassLoader = getClass().getClassLoader(); - bootRuntime(systemScdl, systemClassLoader, monitor); - return composite; - } - - /** - * Boots the application defined by the specified SCDL. - * - * @param name the name of the application component - * @param appScdl URL to the SCDL defining the application - * @return a CompositeComponent for the newly booted application - * @throws LoaderException - */ - @Deprecated - public CompositeComponent bootApplication(String name, URL appScdl) throws TuscanyException { - ClassLoader applicationLoader = getApplicationLoader(); - - if (appScdl == null) { - throw new LoaderException("No application scdl found"); - } - - // create a ComponentDefinition to represent the component we are going to deploy - CompositeImplementation impl = new CompositeImplementation(); - impl.setScdlLocation(appScdl); - impl.setClassLoader(applicationLoader); - ComponentDefinition definition = - new ComponentDefinition(name, impl); - - // deploy the component into the runtime under the system parent - CompositeComponent parent = runtime.getRootComponent(); - // FIXME andyp -- this seems bogus when running inside an appserver - ClassLoader ccl = Thread.currentThread().getContextClassLoader(); - - try { - - Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); - return (CompositeComponent) deployer.deploy(parent, definition); - } finally { - Thread.currentThread().setContextClassLoader(ccl); - } - } - - public File getInstallDirectory() { - String property = System.getProperty("tuscany.installDir"); - if (property != null) { - return new File(property); - } - - // TODO: TUSCANY-648, should this throw an exception if it not running from a jar? - - URL url = getClass().getResource("LauncherImpl.class"); - String jarLocation = url.toString(); - if ("jar".equals(url.getProtocol())) { - jarLocation = jarLocation.substring(4, jarLocation.lastIndexOf("!/")); - } - if (jarLocation.startsWith("file:")) { - jarLocation = jarLocation.substring(5); - } - - File jarFile = new File(jarLocation); - return jarFile.getParentFile().getParentFile(); - } - - public File getApplicationRootDirectory() { - String property = System.getProperty("tuscany.applicationRootDir"); - if (property != null) { - return new File(property); - } - - return new File(System.getProperty("user.dir")); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/launcher/LauncherRuntimeInfo.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/launcher/LauncherRuntimeInfo.java deleted file mode 100644 index a46631508b..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/launcher/LauncherRuntimeInfo.java +++ /dev/null @@ -1,96 +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.launcher; - -import java.io.File; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URI; - -import org.apache.tuscany.host.RuntimeInfo; - -/** - * @version $Rev$ $Date$ - */ -public class LauncherRuntimeInfo implements RuntimeInfo { - - /** Install directory */ - private final File installDirectory; - - /** Application root directory */ - private final File applicationRootDirectory; - - private final boolean online; - - /** - * Initializes the installation and application root directories. - * - * @param installDirectory Installation directory. - * @param applicationRootDirectory Application root directory. - */ - public LauncherRuntimeInfo(File installDirectory, File applicationRootDirectory, boolean online) { - this.installDirectory = installDirectory; - this.applicationRootDirectory = applicationRootDirectory; - this.online = online; - } - - public URI getDomain() { - throw new UnsupportedOperationException(); - } - - /** - * Return the directory where the running runtime was installed. - * - * @return the directory where the runtime was installed - */ - public File getInstallDirectory() { - return installDirectory; - } - - /** - * Return the root directory used to resolve application file paths. - * - * @return the directory used to resolve application file paths. - */ - public File getApplicationRootDirectory() { - return applicationRootDirectory; - } - - /** - * Gets the base URL for the runtime. - * - * @return The base URL for the runtime. - */ - public URL getBaseURL() { - try { - return installDirectory.toURL(); - } catch (MalformedURLException e) { - // TODO Decide on how to handle the exception - throw new RuntimeException(e); - } - } - - public boolean isOnline() { - return online; - } - - public String getRuntimeId() { - throw new UnsupportedOperationException(); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/loader/ComponentLoader.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/loader/ComponentLoader.java deleted file mode 100644 index 3b0a030987..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/loader/ComponentLoader.java +++ /dev/null @@ -1,315 +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.lang.reflect.Type; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.Map; -import javax.xml.namespace.QName; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.ParserConfigurationException; -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 org.w3c.dom.Document; -import static org.osoa.sca.Version.XML_NAMESPACE_1_0; -import org.osoa.sca.annotations.Constructor; - -import org.apache.tuscany.spi.ObjectFactory; -import org.apache.tuscany.spi.annotation.Autowire; -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.databinding.extension.DOMHelper; -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.MissingMustOverridePropertyException; -import org.apache.tuscany.spi.loader.MissingReferenceException; -import org.apache.tuscany.spi.loader.NotOverridablePropertyException; -import org.apache.tuscany.spi.loader.PropertyObjectFactory; -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.BoundReferenceDefinition; -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.OverrideOptions; -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.apache.tuscany.core.binding.local.LocalBindingDefinition; -import org.apache.tuscany.core.implementation.system.model.SystemImplementation; -import org.apache.tuscany.core.property.SimplePropertyObjectFactory; - -/** - * 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(XML_NAMESPACE_1_0, "component"); - private static final QName PROPERTY = new QName(XML_NAMESPACE_1_0, "property"); - private static final QName REFERENCE = new QName(XML_NAMESPACE_1_0, "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(@Autowire LoaderRegistry registry, @Autowire PropertyObjectFactory propertyFactory) { - super(registry); - this.propertyFactory = propertyFactory; - } - - public QName getXMLType() { - return COMPONENT; - } - - @SuppressWarnings("unchecked") - public ComponentDefinition load(CompositeComponent parent, - ModelObject object, - XMLStreamReader reader, - DeploymentContext deploymentContext) throws XMLStreamException, LoaderException { - assert COMPONENT.equals(reader.getName()); - String name = reader.getAttributeValue(null, "name"); - String initLevel = reader.getAttributeValue(null, "initLevel"); - - try { - Implementation impl = loadImplementation(parent, reader, deploymentContext); - registry.loadComponentType(parent, impl, deploymentContext); - - ComponentDefinition> componentDefinition = - new ComponentDefinition>(name, impl); - - 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, deploymentContext, componentDefinition); - } else if (REFERENCE.equals(qname)) { - loadReference(reader, deploymentContext, componentDefinition); - } else { - throw new UnrecognizedElementException(qname); - } - reader.next(); - break; - case END_ELEMENT: - if (reader.getName().equals(COMPONENT)) { - // hack to leave alone SystemImplementation - if (!((Implementation) componentDefinition - .getImplementation() instanceof SystemImplementation)) { - populatePropertyValues(componentDefinition); - } - ComponentType> type = - (ComponentType>) componentDefinition - .getImplementation().getComponentType(); - for (ReferenceDefinition ref : type.getReferences().values()) { - if (ref.isAutowire()) { - ReferenceTarget referenceTarget = new ReferenceTarget(); - referenceTarget.setReferenceName(ref.getName()); - componentDefinition.add(referenceTarget); - } - } - validate(componentDefinition); - return componentDefinition; - } - break; - } - } - } catch (LoaderException e) { - e.addContextName(name); - throw e; - } - } - - protected Implementation loadImplementation(CompositeComponent parent, - XMLStreamReader reader, - DeploymentContext deploymentContext) - throws XMLStreamException, LoaderException { - reader.nextTag(); - ModelObject o = registry.load(parent, null, reader, deploymentContext); - if (!(o instanceof Implementation)) { - throw new MissingImplementationException(); - } - return (Implementation) o; - } - - @SuppressWarnings("unchecked") - protected void loadProperty(XMLStreamReader reader, - DeploymentContext deploymentContext, - ComponentDefinition componentDefinition) throws XMLStreamException, - LoaderException { - String name = reader.getAttributeValue(null, PROPERTY_NAME_ATTR); - Implementation implementation = componentDefinition.getImplementation(); - ComponentType componentType = implementation.getComponentType(); - Property property = (Property) componentType.getProperties().get(name); - if (property == null) { - throw new UndefinedPropertyException(name); - } else if (OverrideOptions.NO.equals(property.getOverride())) { - throw new NotOverridablePropertyException(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); - LoaderUtil.skipToEndElement(reader); - } else { - try { - DocumentBuilder documentBuilder = DOMHelper.newDocumentBuilder(); - Document value = StAXUtil.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(new SimplePropertyObjectFactory(property, propertyValue.getValue())); - propertyValue.setValueFactory(objectFactory); - componentDefinition.add(propertyValue); - } - - protected void loadReference(XMLStreamReader reader, - DeploymentContext deploymentContext, - ComponentDefinition componentDefinition) throws XMLStreamException, - LoaderException { - String name = reader.getAttributeValue(null, "name"); - String text = reader.getElementText(); - String target = text != null ? text.trim() : null; - - - if (name == null) { - throw new InvalidReferenceException("No name specified"); - } else if (target == null) { - throw new InvalidReferenceException("No target specified", name); - } - Implementation impl = componentDefinition.getImplementation(); - ComponentType componentType = impl.getComponentType(); - if (!componentType.getReferences().containsKey(name)) { - throw new UndefinedReferenceException(name); - } - if (componentType instanceof CompositeComponentType) { - ReferenceDefinition definition = componentType.getReferences().get(name); - assert definition instanceof BoundReferenceDefinition; - BoundReferenceDefinition brd = (BoundReferenceDefinition) definition; - if (brd.getBindings().isEmpty()) { - // TODO JFM allow selection of a default binding - try { - LocalBindingDefinition binding = new LocalBindingDefinition(new URI(target)); - brd.addBinding(binding); - } catch (URISyntaxException e) { - throw new InvalidReferenceException(e); - } - } else { - for (BindingDefinition binding : brd.getBindings()) { - try { - // FIXME this is bad - clarify in the spec how URIs are overriden - binding.setTargetUri(new URI(target)); - } catch (URISyntaxException e) { - throw new LoaderException(e); - } - } - } - } else { - ReferenceTarget referenceTarget = new ReferenceTarget(); - referenceTarget.setReferenceName(name); - try { - referenceTarget.addTarget(new URI(target)); - } catch (URISyntaxException e) { - throw new InvalidReferenceException(e); - } - componentDefinition.add(referenceTarget); - } - } - - @SuppressWarnings("unchecked") - protected void populatePropertyValues(ComponentDefinition> componentDefinition) - throws MissingMustOverridePropertyException { - 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.getOverride() == OverrideOptions.MUST) { - throw new MissingMustOverridePropertyException(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.isAutowire() || !referenceDef.isRequired()) { - continue; - } - String name = referenceDef.getName(); - if (!definition.getReferenceTargets().containsKey(name)) { - throw new MissingReferenceException(name); - } - } - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/loader/ComponentTypeElementLoader.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/loader/ComponentTypeElementLoader.java deleted file mode 100644 index 3aa0d3fadc..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/loader/ComponentTypeElementLoader.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.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.Version.XML_NAMESPACE_1_0; -import org.osoa.sca.annotations.Constructor; - -import org.apache.tuscany.spi.annotation.Autowire; -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.deployer.DeploymentContext; -import org.apache.tuscany.spi.extension.LoaderExtension; -import org.apache.tuscany.spi.loader.LoaderException; -import org.apache.tuscany.spi.loader.LoaderRegistry; -import org.apache.tuscany.spi.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(XML_NAMESPACE_1_0, "componentType"); - - @Constructor - public ComponentTypeElementLoader(@Autowire LoaderRegistry registry) { - super(registry); - } - - public QName getXMLType() { - return COMPONENT_TYPE; - } - - @SuppressWarnings("unchecked") - public ComponentType load(CompositeComponent parent, - ModelObject object, - XMLStreamReader reader, - DeploymentContext deploymentContext) 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(parent, componentType, reader, deploymentContext); - 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/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/loader/DependencyLoader.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/loader/DependencyLoader.java deleted file mode 100644 index 66aafb6525..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/loader/DependencyLoader.java +++ /dev/null @@ -1,88 +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.stream.XMLStreamConstants; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; - -import org.apache.tuscany.spi.annotation.Autowire; -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.deployer.DeploymentContext; -import org.apache.tuscany.spi.extension.LoaderExtension; -import org.apache.tuscany.spi.loader.LoaderException; -import org.apache.tuscany.spi.loader.LoaderRegistry; -import org.apache.tuscany.spi.loader.UnrecognizedElementException; -import org.apache.tuscany.spi.model.ModelObject; -import org.apache.tuscany.spi.services.artifact.Artifact; - -import org.apache.tuscany.core.implementation.composite.Dependency; - -/** - * Loader for handling elements. - * - * @version $Rev$ $Date$ - */ -public class DependencyLoader extends LoaderExtension { - private static final String NS = "http://tuscany.apache.org/xmlns/1.0-SNAPSHOT"; - private static final QName DEPENDENCY = new QName(NS, "dependency"); - private static final QName GROUP = new QName(NS, "group"); - private static final QName NAME = new QName(NS, "name"); - private static final QName VERSION = new QName(NS, "version"); - private static final QName CLASSIFIER = new QName(NS, "classifier"); - private static final QName TYPE = new QName(NS, "type"); - - public DependencyLoader(@Autowire LoaderRegistry registry) { - super(registry); - } - - public QName getXMLType() { - return DEPENDENCY; - } - - public Dependency load(CompositeComponent parent, - ModelObject object, - XMLStreamReader reader, - DeploymentContext deploymentContext) - throws XMLStreamException, LoaderException { - - Artifact artifact = new Artifact(); - while (reader.nextTag() == XMLStreamConstants.START_ELEMENT) { - QName name = reader.getName(); - String text = reader.getElementText(); - if (GROUP.equals(name)) { - artifact.setGroup(text); - } else if (NAME.equals(name)) { - artifact.setName(text); - } else if (VERSION.equals(name)) { - artifact.setVersion(text); - } else if (CLASSIFIER.equals(name)) { - artifact.setClassifier(text); - } else if (TYPE.equals(name)) { - artifact.setType(text); - } else { - throw new UnrecognizedElementException(name); - } - } - Dependency dependency = new Dependency(); - dependency.setArtifact(artifact); - return dependency; - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/loader/IncludeLoader.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/loader/IncludeLoader.java deleted file mode 100644 index 61146d5afd..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/loader/IncludeLoader.java +++ /dev/null @@ -1,111 +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.URL; -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; - -import static org.osoa.sca.Version.XML_NAMESPACE_1_0; -import org.osoa.sca.annotations.Constructor; - -import org.apache.tuscany.spi.annotation.Autowire; -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.deployer.DeploymentContext; -import org.apache.tuscany.spi.extension.LoaderExtension; -import org.apache.tuscany.spi.loader.LoaderException; -import org.apache.tuscany.spi.loader.LoaderRegistry; -import org.apache.tuscany.spi.loader.LoaderUtil; -import org.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(XML_NAMESPACE_1_0, "include"); - - @Constructor({"registry"}) - public IncludeLoader(@Autowire LoaderRegistry registry) { - super(registry); - } - - public QName getXMLType() { - return INCLUDE; - } - - public Include load(CompositeComponent parent, 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); - } - - DeploymentContext childContext = new ChildDeploymentContext(deploymentContext, cl, url); - CompositeComponentType composite; - try { - composite = loadFromSidefile(parent, url, childContext); - } catch (LoaderException e) { - e.addContextName(name); - throw e; - } - - Include include = new Include(); - include.setName(name); - include.setScdlLocation(url); - include.setIncluded(composite); - return include; - } - - protected CompositeComponentType loadFromSidefile(CompositeComponent parent, - URL url, - DeploymentContext deploymentContext) - throws LoaderException { - return registry.load(parent, null, url, CompositeComponentType.class, deploymentContext); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/loader/JNDIPropertyFactory.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/loader/JNDIPropertyFactory.java deleted file mode 100644 index 8759377840..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/loader/JNDIPropertyFactory.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.loader; - -import javax.naming.Context; -import javax.naming.InitialContext; -import javax.naming.NamingException; - -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.JNDIObjectFactory; - -/** - * A StAXPropertyFactory that creates property values by looking them up in the default JNDI InitialContext.

      This - * can be used to locate resources in a J2EE environment and inject them as configuration properties. For example, to - * access a database a component could write: &at;Property DataSource myDB; and configure with - * <properties> <v:myDb>java:comp/env/jdbc/MyDatabase</v:myDB> </properties> - * - * @version $Rev$ $Date$ - */ -public class JNDIPropertyFactory implements PropertyObjectFactory { - public ObjectFactory createObjectFactory(Property property, PropertyValue value) - throws LoaderException { - String text = value.getValue().getDocumentElement().getTextContent(); - try { - Context context = new InitialContext(); - return new JNDIObjectFactory(context, text); - } catch (NamingException e) { - throw new LoaderException(e); - } - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/loader/LoaderExceptionFormatter.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/loader/LoaderExceptionFormatter.java deleted file mode 100644 index 4fad10c95f..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/loader/LoaderExceptionFormatter.java +++ /dev/null @@ -1,50 +0,0 @@ -package org.apache.tuscany.core.loader; - -import java.io.PrintWriter; - -import org.osoa.sca.annotations.Destroy; -import org.osoa.sca.annotations.EagerInit; - -import org.apache.tuscany.spi.annotation.Autowire; -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(@Autowire 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()); - } else { - writer.write("\n"); - } - e.appendContextStack(writer).append("\n"); - return writer; - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/loader/LoaderRegistryImpl.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/loader/LoaderRegistryImpl.java deleted file mode 100644 index ee0fd27c55..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/loader/LoaderRegistryImpl.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.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.component.CompositeComponent; -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(CompositeComponent parent, - 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(parent, object, reader, deploymentContext); - } - - public MO load(CompositeComponent parent, - 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(parent, 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(CompositeComponent parent, - 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(parent, 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/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/loader/PolicySetLoader.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/loader/PolicySetLoader.java deleted file mode 100644 index b232f6e3e2..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/loader/PolicySetLoader.java +++ /dev/null @@ -1,196 +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.Version.XML_NAMESPACE_1_0; -import org.osoa.sca.annotations.Constructor; - -import org.apache.tuscany.spi.annotation.Autowire; -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.deployer.DeploymentContext; -import org.apache.tuscany.spi.extension.LoaderExtension; -import org.apache.tuscany.spi.loader.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(XML_NAMESPACE_1_0, "policySet"); - - private static final QName INTENTMAP = new QName(XML_NAMESPACE_1_0, "intentMap"); - - private static final QName QUALIFIER = new QName(XML_NAMESPACE_1_0, "qualifier"); - - private static final QName POLICYSETREFERENCE = new QName(XML_NAMESPACE_1_0, "policySetReference"); - - private static final QName WSPOLICYATTACHMENT = new QName(WSPOLICY_NAMESPACE, "PolicyAttachment"); - - @Constructor({"registry"}) - public PolicySetLoader(@Autowire LoaderRegistry registry) { - super(registry); - - } - - @Override - public QName getXMLType() { - return POLICYSET; - } - - public PolicySet load(CompositeComponent parent, 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(XML_NAMESPACE_1_0, name), parseIntentName(provides)); - String[] appliesToArtifact = split(appliesTo); - for (String artifact : appliesToArtifact) { - policySet.addAppliedArtifacts(new QName(XML_NAMESPACE_1_0, 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(XML_NAMESPACE_1_0, 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/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/loader/PropertyLoader.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/loader/PropertyLoader.java deleted file mode 100644 index 16c81caab7..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/loader/PropertyLoader.java +++ /dev/null @@ -1,103 +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.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; - -import static org.osoa.sca.Version.XML_NAMESPACE_1_0; -import org.osoa.sca.annotations.Constructor; -import org.w3c.dom.Document; - -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.deployer.DeploymentContext; -import org.apache.tuscany.spi.extension.LoaderExtension; -import org.apache.tuscany.spi.loader.LoaderException; -import org.apache.tuscany.spi.loader.LoaderRegistry; -import org.apache.tuscany.spi.model.OverrideOptions; -import org.apache.tuscany.spi.model.Property; -import org.apache.tuscany.spi.model.ModelObject; -import org.apache.tuscany.spi.annotation.Autowire; - -/** - * 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 PROPERTY_OVERRIDE_ATTR = "override"; - - public static final QName PROPERTY = new QName(XML_NAMESPACE_1_0, "property"); - private final DocumentBuilder documentBuilder; - - @Constructor({"registry"}) - public PropertyLoader(@Autowire 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(CompositeComponent parent, 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 override = reader.getAttributeValue(null, PROPERTY_OVERRIDE_ATTR); - - Document value = StAXUtil.createPropertyValue(reader, xmlType, documentBuilder); - - Property property = new Property(); - property.setName(name); - property.setXmlType(xmlType); - property.setMany(many); - - if (override != null) { - property.setOverride(OverrideOptions.valueOf(override.toUpperCase())); - } - property.setDefaultValue(value); - return property; - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/loader/ReferenceLoader.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/loader/ReferenceLoader.java deleted file mode 100644 index eb3a030934..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/loader/ReferenceLoader.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 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.Version.XML_NAMESPACE_1_0; -import org.osoa.sca.annotations.Constructor; - -import org.apache.tuscany.spi.annotation.Autowire; -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.deployer.DeploymentContext; -import org.apache.tuscany.spi.extension.LoaderExtension; -import org.apache.tuscany.spi.loader.LoaderException; -import org.apache.tuscany.spi.loader.LoaderRegistry; -import org.apache.tuscany.spi.loader.UnrecognizedElementException; -import org.apache.tuscany.spi.model.BindingDefinition; -import org.apache.tuscany.spi.model.BoundReferenceDefinition; -import org.apache.tuscany.spi.model.ComponentType; -import org.apache.tuscany.spi.model.CompositeComponentType; -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(XML_NAMESPACE_1_0, "reference"); - - @Constructor - public ReferenceLoader(@Autowire LoaderRegistry registry) { - super(registry); - } - - public QName getXMLType() { - return REFERENCE; - } - - public ReferenceDefinition load(CompositeComponent parent, - ModelObject object, XMLStreamReader reader, - DeploymentContext deploymentContext) - throws XMLStreamException, LoaderException { - assert REFERENCE.equals(reader.getName()); - String name = reader.getAttributeValue(null, "name"); - Multiplicity multiplicity = - StAXUtil.multiplicity(reader.getAttributeValue(null, "multiplicity"), Multiplicity.ONE_ONE); - List bindings = new ArrayList(); - ServiceContract contract = null; - while (true) { - switch (reader.next()) { - case START_ELEMENT: - ModelObject o = registry.load(parent, null, reader, deploymentContext); - if (o instanceof ServiceContract) { - contract = (ServiceContract) o; - } else if (o instanceof BindingDefinition) { - bindings.add((BindingDefinition) o); - } else { - throw new UnrecognizedElementException(reader.getName()); - } - break; - case END_ELEMENT: - if (object instanceof ComponentType && !(object instanceof CompositeComponentType)) { - // loading a reference in a component type side file - ReferenceDefinition referenceDefinition = new ReferenceDefinition(name, contract); - referenceDefinition.setMultiplicity(multiplicity); - return referenceDefinition; - } - return new BoundReferenceDefinition(name, contract, bindings, multiplicity); - } - } - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/loader/ServiceLoader.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/loader/ServiceLoader.java deleted file mode 100644 index 90a2be722f..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/loader/ServiceLoader.java +++ /dev/null @@ -1,118 +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 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.Version.XML_NAMESPACE_1_0; -import org.osoa.sca.annotations.Constructor; - -import org.apache.tuscany.spi.annotation.Autowire; -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.deployer.DeploymentContext; -import org.apache.tuscany.spi.extension.LoaderExtension; -import org.apache.tuscany.spi.loader.InvalidReferenceException; -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.BoundServiceDefinition; -import org.apache.tuscany.spi.model.ComponentType; -import org.apache.tuscany.spi.model.CompositeComponentType; -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(XML_NAMESPACE_1_0, "service"); - private static final QName REFERENCE = new QName(XML_NAMESPACE_1_0, "reference"); - - @Constructor - public ServiceLoader(@Autowire LoaderRegistry registry) { - super(registry); - } - - public QName getXMLType() { - return SERVICE; - } - - public ServiceDefinition load(CompositeComponent parent, - ModelObject object, - XMLStreamReader reader, - DeploymentContext deploymentContext) throws XMLStreamException, LoaderException { - assert SERVICE.equals(reader.getName()); - String name = reader.getAttributeValue(null, "name"); - String target = null; - List bindings = new ArrayList(); - ServiceContract serviceContract = null; - while (true) { - int i = reader.next(); - switch (i) { - case START_ELEMENT: - // there is a reference already using this qname which doesn't seem appropriate. - if (REFERENCE.equals(reader.getName())) { - String text = reader.getElementText(); - target = text != null ? text.trim() : null; - } else { - ModelObject o = registry.load(parent, null, reader, deploymentContext); - if (o instanceof ServiceContract) { - serviceContract = (ServiceContract) o; - } else if (o instanceof BindingDefinition) { - bindings.add((BindingDefinition) o); - } else { - throw new UnrecognizedElementException(reader.getName()); - } - } - break; - case END_ELEMENT: - if (SERVICE.equals(reader.getName())) { - if (object instanceof ComponentType && !(object instanceof CompositeComponentType)) { - // the load is being done for an atomic component type - // FIXME need a way to specify "remotable" on a service - return new ServiceDefinition(name, serviceContract, false); - } - URI targetURI = null; - if (target != null) { - try { - targetURI = new URI(target); - } catch (URISyntaxException e) { - throw new InvalidReferenceException(target, name); - } - } - // FIXME need a way to specify "remotable" on a service - return new BoundServiceDefinition(name, serviceContract, bindings, false, targetURI); - } - break; - } - } - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/loader/StAXUtil.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/loader/StAXUtil.java deleted file mode 100644 index 50dee55c8e..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/loader/StAXUtil.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.loader; - -import java.util.HashMap; -import java.util.Map; - -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.apache.tuscany.spi.model.InteractionScope; -import org.apache.tuscany.spi.model.Multiplicity; -import org.w3c.dom.Attr; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; - -/** - * Utility classes to support StAX-based loaders - * - * @version $Rev$ $Date$ - */ -public final class StAXUtil { - 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); - } - - private StAXUtil() { - } - - /** - * Convert a "multiplicity" attribute to the equivalent enum value. - * - * @param multiplicity the attribute to convert - * @param def the default value - * @return the enum equivalent - */ - public static Multiplicity multiplicity(String multiplicity, Multiplicity def) { - return multiplicity == null ? def : MULTIPLICITY.get(multiplicity); - } - - /** - * Convert a "scope" attribute to the equivalent enum value. Returns - * CONVERSATIONAL if the value equals (ignoring case) "conversational", - * otherwise returns NONCONVERSATIONAL. - * - * @param scope the attribute to convert - * @return the enum equivalent - */ - public static InteractionScope interactionScope(String scope) { - if ("conversational".equalsIgnoreCase(scope)) { - return InteractionScope.CONVERSATIONAL; - } else { - return InteractionScope.NONCONVERSATIONAL; - } - } - - 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 - */ - 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/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/loader/StringParserPropertyFactory.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/loader/StringParserPropertyFactory.java deleted file mode 100644 index eda09d6f11..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/loader/WireLoader.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/loader/WireLoader.java deleted file mode 100644 index 76b0858b94..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/loader/WireLoader.java +++ /dev/null @@ -1,112 +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.Version.XML_NAMESPACE_1_0; -import org.osoa.sca.annotations.Constructor; - -import org.apache.tuscany.spi.annotation.Autowire; -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.deployer.DeploymentContext; -import org.apache.tuscany.spi.extension.LoaderExtension; -import org.apache.tuscany.spi.loader.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(XML_NAMESPACE_1_0, "wire"); - private static final QName SOURCE_URI = new QName(XML_NAMESPACE_1_0, "source.uri"); - private static final QName TARGET_URI = new QName(XML_NAMESPACE_1_0, "target.uri"); - - @Constructor({"registry"}) - public WireLoader(@Autowire LoaderRegistry registry) { - super(registry); - } - - public QName getXMLType() { - return WIRE; - } - - public WireDefinition load(CompositeComponent parent, - 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) { - sourceURI = new URI(uriString); - } 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) { - targetURI = new URI(uriString); - } 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/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/monitor/DefaultExceptionFormatter.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/monitor/DefaultExceptionFormatter.java deleted file mode 100644 index 686c74c7f8..0000000000 --- a/branches/pre-spec-changes/kernel/core/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.appendContextStack(e.appendBaseMessage(writer)); - } else if (exception instanceof TuscanyRuntimeException) { - TuscanyRuntimeException e = (TuscanyRuntimeException) exception; - e.appendContextStack(e.appendBaseMessage(writer)); - } - writer.append("\n"); - return writer; - } - - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/monitor/InvalidLevelException.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/monitor/InvalidLevelException.java deleted file mode 100644 index cf07b0f914..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/monitor/JavaLoggingMonitorFactory.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/monitor/JavaLoggingMonitorFactory.java deleted file mode 100644 index 019dcbdcd3..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/monitor/JavaLoggingMonitorFactory.java +++ /dev/null @@ -1,321 +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 java.lang.ref.WeakReference; -import java.lang.reflect.InvocationHandler; -import java.lang.reflect.Method; -import java.lang.reflect.Proxy; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.MissingResourceException; -import java.util.Properties; -import java.util.ResourceBundle; -import java.util.WeakHashMap; -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.api.annotation.LogLevel; -import org.apache.tuscany.host.MonitorFactory; -import org.apache.tuscany.host.monitor.ExceptionFormatter; -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 implements MonitorFactory, FormatterRegistry { - private String bundleName; - private Level defaultLevel; - private Map levels; - private List formatters = new ArrayList(); - private ExceptionFormatter defaultFormatter = new DefaultExceptionFormatter(); - private Map, WeakReference> proxies = new WeakHashMap, WeakReference>(); - - /** - * 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() { - } - - public void initialize(Map configProperties) { - if (configProperties == null) { - return; - } - initInternal(configProperties); - } - - private 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, bundleName); - proxies.put(monitorInterface, new WeakReference(proxy)); - } - return proxy; - } - - private T getCachedMonitor(Class monitorInterface) { - WeakReference ref = proxies.get(monitorInterface); - return (ref != null) ? monitorInterface.cast(ref.get()) : null; - } - - private T createMonitor(Class monitorInterface, String bundleName) { - String className = monitorInterface.getName(); - Logger logger = Logger.getLogger(className); - 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); - } - - ResourceBundle bundle = locateBundle(monitorInterface, bundleName); - - InvocationHandler handler = new LoggingHandler(logger, levels, bundle, formatters, defaultFormatter); - return monitorInterface - .cast(Proxy.newProxyInstance(monitorInterface.getClassLoader(), new Class[]{monitorInterface}, handler)); - } - - private static 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); - } - - private static final class LoggingHandler implements InvocationHandler { - private final Logger logger; - private final Map methodLevels; - private final ResourceBundle bundle; - private List formatters; - private ExceptionFormatter defaultFormatter; - - public LoggingHandler(Logger logger, - Map methodLevels, - ResourceBundle bundle, - List formatters, - ExceptionFormatter defaultFormatter) { - this.logger = logger; - this.methodLevels = methodLevels; - this.bundle = bundle; - this.formatters = formatters; - this.defaultFormatter = defaultFormatter; - } - - 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) { - Throwable e = (Throwable) o; - ExceptionFormatter formatter = null; - for (ExceptionFormatter candidate : formatters) { - if (candidate.canFormat(e.getClass())) { - formatter = candidate; - break; - } - } - StringWriter writer = new StringWriter(); - PrintWriter pw = new PrintWriter(writer); - if (formatter != null) { - formatter.write(pw, e); - } else { - defaultFormatter.write(pw, e); - } - format(pw, e); - pw.close(); - logRecord.setMessage(writer.toString()); - break; - } - } - } - logRecord.setResourceBundle(bundle); - logger.log(logRecord); - } - return null; - } - - private 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); - } - } - - private 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 = null; - for (ExceptionFormatter candidate : formatters) { - if (candidate.canFormat(throwable.getClass())) { - formatter = candidate; - break; - } - } - if (formatter != null) { - formatter.write(pw, throwable); - } else { - defaultFormatter.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/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/monitor/MonitorFactoryUtil.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/monitor/MonitorFactoryUtil.java deleted file mode 100644 index 92224d469f..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/monitor/NullMonitorFactory.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/monitor/NullMonitorFactory.java deleted file mode 100644 index 8ba3053c2f..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/monitor/NullMonitorFactory.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.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; - -/** - * Implementation of a {@link MonitorFactory} that produces implementations that simply return. - * - * @version $Rev$ $Date$ - */ -@EagerInit -public class NullMonitorFactory implements MonitorFactory { - /** - * Singleton wire 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)); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/policy/IntentRegistryImpl.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/policy/IntentRegistryImpl.java deleted file mode 100644 index 5ea24e4c9b..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/policy/IntentRegistryImpl.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.policy; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import javax.xml.namespace.QName; - -import org.apache.tuscany.spi.model.Intent; -import org.apache.tuscany.spi.model.IntentName; -import org.apache.tuscany.spi.policy.IntentRegistry; - -/** - * The default implementation of a data intent registry - */ -public class IntentRegistryImpl implements IntentRegistry { - private final Map intentRepo = new HashMap(); - - public Collection getQualifiedIntents(final IntentName qualifiable, final QName artifact) { - List result = new ArrayList(); - for (IntentName intentName : intentRepo.keySet()) { - if (intentRepo.get(intentName).getAppliedArtifacts().contains(artifact) - && PolicyHelper.isQualifiedIntentFor(intentName, qualifiable, true)) { - result.add(intentName); - } - } - return result; - } - - public Collection inlineProfileIntent(final Collection intentNameList, - final QName artifact) { - - return getConcretIntentsInternal(intentNameList, artifact); - } - - private Collection getConcretIntentsInternal(final Collection intentNameList, - QName artifact) { - List result = new ArrayList(); - for (IntentName intentName : intentNameList) { - IntentEntry intentEntry = intentRepo.get(intentName); - if (!intentEntry.isProfileIntent()) { - if (intentEntry.getAppliedArtifacts().contains(artifact)) { - result.add(intentEntry.getName()); - } - } else { - result.addAll(getConcretIntentsInternal(intentEntry.getRequriedIntents(), artifact)); - } - } - return result; - } - - public boolean isApplicable(IntentName intentName, QName artifact) { - if (intentRepo.containsKey(intentName)) { - return intentRepo.get(intentName).getAppliedArtifacts().contains(artifact); - } - return false; - } - - public void register(Intent intent) { - - IntentEntry entry = new IntentEntry(intent); - // if the qualified intents have been registered, make the intent qualifiable(unqualified) - if (!getQualifiedIntents(intent.getName()).isEmpty()) { - entry.setQualified(false); - } - intentRepo.put(intent.getName(), entry); - List qualifiables = getAllQualifiableIntent(intent.getName()); - // set qualifiable intent of this intent unqualified - for (IntentName qualifiable : qualifiables) { - IntentEntry qualifiableEntry = intentRepo.get(qualifiable); - qualifiableEntry.setQualified(false); - for (QName artifact : intent.getAppliedArtifacts()) { - qualifiableEntry.addAppliedArtifacts(artifact); - } - } - } - - public void unRegister(Intent intent) { - if (intentRepo.containsKey(intent.getName())) { - IntentEntry intentEntry = intentRepo.get(intent.getName()); - List appliedArtifacts = intent.getAppliedArtifacts(); - for (QName artifact : appliedArtifacts) { - if (intentEntry.getAppliedArtifacts().contains(artifact)) { - intentEntry.removeappliedArtifact(artifact); - } - } - if (intentEntry.getAppliedArtifacts().isEmpty()) { - intentRepo.remove(intent.getName()); - } - } - } - - public boolean isQualifiedIntent(IntentName name) { - IntentEntry intentEntry = intentRepo.get(name); - return intentEntry.isQualified(); - } - - private List getQualifiedIntents(final IntentName qualifiable) { - List result = new ArrayList(); - for (IntentName intentName : intentRepo.keySet()) { - if (PolicyHelper.isQualifiedIntentFor(intentName, qualifiable, true)) { - result.add(intentName); - } - } - return result; - } - - private List getAllQualifiableIntent(final IntentName qualified) { - - List result = new ArrayList(); - for (IntentName intentName : intentRepo.keySet()) { - if (PolicyHelper.isQualifiedIntentFor(qualified, intentName, false)) { - result.add(intentName); - } - } - return result; - } - - /** - * Wrapper class for intent used internally - */ - private static final class IntentEntry extends Intent { - - /** - * Whether this intent is qualified, defaults to true - */ - private boolean isQualified = true; - - private IntentEntry(Intent intent) { - super(intent.getName(), intent.getDescription()); - appliedArtifacts.addAll(intent.getAppliedArtifacts()); - requriedIntents.addAll(intent.getRequriedIntents()); - } - - public boolean isQualified() { - return isQualified; - } - - public void setQualified(boolean isQualified) { - this.isQualified = isQualified; - } - - public void removeappliedArtifact(QName artifact) { - appliedArtifacts.remove(artifact); - } - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/policy/PolicyBuilderRegistryImpl.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/policy/PolicyBuilderRegistryImpl.java deleted file mode 100644 index e80d5c7b00..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/policy/PolicyBuilderRegistryImpl.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.policy; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.tuscany.spi.builder.BuilderException; -import org.apache.tuscany.spi.model.ReferenceDefinition; -import org.apache.tuscany.spi.model.ServiceDefinition; -import org.apache.tuscany.spi.policy.PolicyBuilderRegistry; -import org.apache.tuscany.spi.policy.SourcePolicyBuilder; -import org.apache.tuscany.spi.policy.TargetPolicyBuilder; -import org.apache.tuscany.spi.wire.InboundWire; -import org.apache.tuscany.spi.wire.OutboundWire; - -/** - * The default policy builder - * - * @version $Rev$ $Date$ - */ -public class PolicyBuilderRegistryImpl implements PolicyBuilderRegistry { - - private final List> sourceBuilders; - private final List> targetBuilders; - - public PolicyBuilderRegistryImpl() { - sourceBuilders = new ArrayList>(); - targetBuilders = new ArrayList>(); - for (int i = 0; i <= FINAL; i++) { - sourceBuilders.add(new ArrayList()); - targetBuilders.add(new ArrayList()); - } - } - - public void registerTargetBuilder(int phase, TargetPolicyBuilder builder) { - assert INITIAL <= phase && phase <= FINAL : "Illegal phase"; - targetBuilders.get(phase).add(builder); - } - - public void registerSourceBuilder(int phase, SourcePolicyBuilder builder) { - assert INITIAL <= phase && phase <= FINAL : "Illegal phase"; - sourceBuilders.get(phase).add(builder); - } - - - public void buildSource(ReferenceDefinition referenceDefinition, OutboundWire wire) throws BuilderException { - for (List builders : sourceBuilders) { - for (SourcePolicyBuilder builder : builders) { - builder.build(referenceDefinition, wire); - } - } - } - - public void buildTarget(ServiceDefinition serviceDefinition, InboundWire wire) throws BuilderException { - for (List builders : targetBuilders) { - for (TargetPolicyBuilder builder : builders) { - builder.build(serviceDefinition, wire); - } - } - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/policy/PolicyEngineImpl.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/policy/PolicyEngineImpl.java deleted file mode 100644 index 308e43c038..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/policy/PolicyEngineImpl.java +++ /dev/null @@ -1,297 +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.policy; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import javax.xml.namespace.QName; - -import org.apache.tuscany.spi.model.IntentMap; -import org.apache.tuscany.spi.model.IntentName; -import org.apache.tuscany.spi.model.PolicyContentModel; -import org.apache.tuscany.spi.model.PolicyModel; -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.policy.IntentRegistry; -import org.apache.tuscany.spi.policy.PolicyEngine; -import org.apache.tuscany.spi.policy.PolicySetContainer; -import org.apache.tuscany.spi.policy.SCATypeManager; - -/** - * Default implementation of a polciy engine - */ -public class PolicyEngineImpl implements PolicyEngine { - private final IntentRegistry intentRegistry; - private final PolicySetContainer policySetContainer; - private final SCATypeManager scaTypeManager; - - public PolicyEngineImpl(IntentRegistry intentRegistry, - PolicySetContainer policySetContainer, - SCATypeManager scaTypeManager) { - this.intentRegistry = intentRegistry; - this.policySetContainer = policySetContainer; - this.scaTypeManager = scaTypeManager; - } - - @SuppressWarnings("unchecked") - public Collection getPolicy(final IntentName[] requires, - final QName[] policySetNames, - final QName artifactType) { - if (requires == null || requires.length == 0) { - return Collections.EMPTY_LIST; - } - Collection result = new ArrayList(); - Collection requiredIntents = java.util.Arrays.asList(requires); - Collection matchings; - - //handle profile intents - requiredIntents = intentRegistry.inlineProfileIntent(requiredIntents, artifactType); - // - if (policySetNames != null && policySetNames.length != 0) { - Collection explicitPolicySet = getExplicitPolicySet(policySetNames); - matchings = calculateExplicitPolicySet(requiredIntents, explicitPolicySet, artifactType, result); - //remove satisfied intent - requiredIntents.removeAll(matchings); - } - // - if (requiredIntents.size() > 0) { - matchings = findingAdditionalMatching(requiredIntents, artifactType, result); - requiredIntents.removeAll(matchings); - } - //If no collection of policySets covers all required intents, the configuration is not valid. - if (requiredIntents.size() > 0) { - //TODO - } - return result; - } - - - private boolean introspectPolicySet(PolicySet policySet, IntentName intent, QName artifactType, - Collection matchings) { - Collection appliedArtifacts = policySet.getAppliedArtifacts(); - boolean provide = false; - for (QName name : appliedArtifacts) { - if (this.scaTypeManager.isTypeOf(artifactType, name)) { - provide = true; - break; - } - } - if (!provide) { - return false; - } - //1. The required intent matches a provides intent in a policySet exactly. - if (policySet.getProvideIntents().contains(intent)) { - if (intentRegistry.isQualifiedIntent(intent)) { - addMatching(matchings, policySet); - } else { - Collection intentMaps = policySet.getIntentMaps(); - provide = searchIntentMaps(intent, intent, matchings, intentMaps); - if (provide) { - return true; - } - } - } else if (provideAbstract(intent, policySet.getProvideIntents())) { - // 2. The provides intent is a parent (e.g. prefix) of the required intent (in this case the policySet must - // have an intentMap entry for the requested qualifier) - Collection intentMaps = policySet.getIntentMaps(); - IntentName satisfiedIntent = getSatisfiedIntent(intent, policySet.getProvideIntents()); - provide = searchIntentMaps(intent, satisfiedIntent, matchings, intentMaps); - if (provide) { - return true; - } - } else if (provideQualifier(intent, policySet.getProvideIntents())) { - //3. The provides intent is more qualified than the required intent - if (intentRegistry.isQualifiedIntent(intent)) { - addMatching(matchings, policySet); - } else { - //TODO - } - } - - //handle PolicySetReference - Collection policySetReferences = policySet.getPolicySetReferences(); - for (PolicySetReference reference : policySetReferences) { - PolicySet referencedPolicySet = policySetContainer.getPolicySet(reference.getReference()); - if (introspectPolicySet(referencedPolicySet, intent, artifactType, matchings)) { - return true; - } - } - - return false; - } - - private void addMatching(Collection matching, PolicyContentModel policy) { - if (!policy.getWsPolicyAttachments().isEmpty()) { - matching.addAll(policy.getWsPolicyAttachments()); - } - if (!policy.getPolicyExtensions().isEmpty()) { - matching.addAll(policy.getPolicyExtensions()); - } - } - - private boolean searchIntentMaps(IntentName require, - IntentName satisfiedIntent, - Collection matchings, - Collection intentMaps) { - String qualifierName = getQualifierName(require, satisfiedIntent, intentMaps); - for (IntentMap intentMap : intentMaps) { - if (intentMap.getProvideIntents().contains(qualifierName)) { - Collection qualifiers = intentMap.getQualifiers(); - for (Qualifier qualifier : qualifiers) { - String nextQualifier = getNextQualifier(require, satisfiedIntent, intentMap); - if (qualifier.getName().equals(nextQualifier)) { - if (intentRegistry - .isQualifiedIntent(new IntentName(satisfiedIntent.toString() + "/" + nextQualifier))) { - addMatching(matchings, qualifier); - return true; - } else { - require = new IntentName(require.toString() + "/" + intentMap.getDefaultProvideIntent()); - satisfiedIntent = new IntentName(satisfiedIntent.toString() + "/" + qualifierName); - intentMaps = new ArrayList(0); - intentMaps.add(qualifier.getIntentMap()); - searchIntentMaps(require, satisfiedIntent, matchings, intentMaps); - } - break; - } - } - } - } - return false; - } - - private String getQualifierName(IntentName require, IntentName satisfiedIntent, Collection intentMaps) { - String[] requrieQualifiers = require.getQualifiedNames(); - String[] satisfiedQualifiers = satisfiedIntent.getQualifiedNames(); - if (requrieQualifiers.length == satisfiedQualifiers.length) { - return requrieQualifiers[requrieQualifiers.length - 1]; - } else if (requrieQualifiers.length > satisfiedQualifiers.length) { - return satisfiedQualifiers[satisfiedQualifiers.length - 1]; - } - //TODO raise exception - return null; - } - - private String getNextQualifier(IntentName require, IntentName satisfiedIntent, IntentMap intentMap) { - String[] requrieQualifiers = require.getQualifiedNames(); - String[] satisfiedQualifiers = satisfiedIntent.getQualifiedNames(); - if (requrieQualifiers.length > satisfiedQualifiers.length) { - return requrieQualifiers[satisfiedQualifiers.length]; - } else { - return intentMap.getDefaultProvideIntent(); - } - } - - private IntentName getSatisfiedIntent(IntentName require, Collection provides) { - for (IntentName name : provides) { - if (PolicyHelper.isQualifiedIntentFor(require, name, true)) { - return name; - } - } - //TODO raise exception - return null; - } - - private boolean provideAbstract(IntentName require, Collection provides) { - for (IntentName name : provides) { - if (PolicyHelper.isQualifiedIntentFor(require, name, true)) { - return true; - } - } - return false; - } - - private boolean provideQualifier(IntentName require, Collection provides) { - for (IntentName name : provides) { - if (PolicyHelper.isQualifiedIntentFor(name, require, true)) { - return true; - } - } - return false; - } - - private Collection getExplicitPolicySet(QName[] policySetNames) { - Collection result = new ArrayList(); - for (QName policySetName : policySetNames) { - PolicySet set = policySetContainer.getPolicySet(policySetName); - if (set != null) { - result.add(set); - } - } - return result; - } - - /** - * Step C. Calculate the list of explicitly specified policySets that apply to the target element as follows: 1. - * Start with the list of policySets specified in the element's policySet attribute. 2. If any of these explicitly - * listed policySets has an XPath expression in its appliesTo attribute that does not match the target element - * (binding or implementation) then the composite is invalid. It does not match if the XPath returns a result set - * that corresponds to XPath false. For example, a policySet could have appliesTo=”binding.ws/soaphttp”. This would - * return false if the target element is a element. 3. Include the values of policySet attributes - * from ancestor elements. 4. Remove any policySet where the XPath expression in that policySet’s appliesTo - * attribute does not match the target element. - *

      - * - * @param requires - * @param policies - * @return intent names was satisfied by this step. - */ - private Collection calculateExplicitPolicySet(Collection requires, - Collection policies, - QName artifactType, - Collection matchings) { - Collection satisfied = new ArrayList(); - for (IntentName intent : requires) { - for (PolicySet policySet : policies) { - if (introspectPolicySet(policySet, intent, artifactType, matchings)) { - satisfied.add(intent); - } - } - } - return satisfied; - } - - /** - * * The remaining required intents, if any, are provided by finding additional matching policySets within the SCA - * system. E. Choose the smallest collection of these policySets that match all remaining required intents. A - * policySet matches a required intent if any of the following are true: 1. The required intent matches a provides - * intent in a policySet exactly. 2. The provides intent is a parent (e.g. prefix) of the required intent (in this - * case the policySet must have an intentMap entry for the requested qualifier) 3. The provides intent is more - * qualified than the required intent All intents should now be satisfied. - * - * @param remainings - * @param artifactType - * @param matchings - */ - private Collection findingAdditionalMatching(final Collection remainings, - QName artifactType, - Collection matchings) { - Collection satisfied = new ArrayList(); - Collection policies = this.policySetContainer.getAllPolicySet(); - for (IntentName intent : remainings) { - for (PolicySet policySet : policies) { - if (introspectPolicySet(policySet, intent, artifactType, matchings)) { - satisfied.add(intent); - } - } - } - return satisfied; - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/policy/PolicyHelper.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/policy/PolicyHelper.java deleted file mode 100644 index 50c94aaf13..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/policy/PolicyHelper.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.policy; - -import org.apache.tuscany.spi.model.IntentName; - -/** - * Contains utility methods for dealing with policies - */ -public final class PolicyHelper { - - private PolicyHelper() { - } - - /** - * Whether qualified is qualified intent for qualifiable - *

      - * For example: sec.confidentiality/message is direct qualifier for sec.confidentiality. - * sec.confidentiality/message/body is qualifier for sec.confidentiality, but not a direct qualifier - * - * @param qualified qualified intent name - * @param qualifiable qualifiable intent name - * @param direct indicate whether to expect qualified is direct qualified intent for - * qualifiable - * @return whether qualified is qualified intent for qualifiable - */ - public static boolean isQualifiedIntentFor(final IntentName qualified, - final IntentName qualifiable, - boolean direct) { - if (qualified.equals(qualifiable) || !qualified.getDomain().equals(qualifiable.getDomain())) { - return false; - } - boolean result = true; - String[] shortArray = qualifiable.getQualifiedNames(); - String[] longArray = qualified.getQualifiedNames(); - if (longArray.length - shortArray.length < 1 && !direct) { - return false; - } else if (direct && longArray.length - shortArray.length != 1) { - return false; - } - for (int i = 0; i < shortArray.length; i++) { - if (!shortArray[i].equals(longArray[i])) { - result = false; - break; - } - } - return result; - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/property/PropertyHelper.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/property/PropertyHelper.java deleted file mode 100644 index 77e3a6829f..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/property/PropertyHelper.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.property; - -import java.io.InputStream; -import java.net.URI; -import java.net.URL; -import java.util.Iterator; -import java.util.Map; - -import javax.xml.namespace.NamespaceContext; -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.xpath.XPath; -import javax.xml.xpath.XPathConstants; -import javax.xml.xpath.XPathExpression; -import javax.xml.xpath.XPathExpressionException; -import javax.xml.xpath.XPathFactory; - -import org.apache.tuscany.core.databinding.xml.InputStream2Node; -import org.apache.tuscany.spi.databinding.extension.DOMHelper; -import org.apache.tuscany.spi.deployer.DeploymentContext; -import org.apache.tuscany.spi.loader.InvalidValueException; -import org.apache.tuscany.spi.loader.LoaderException; -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.Property; -import org.apache.tuscany.spi.model.PropertyValue; -import org.w3c.dom.Document; -import org.w3c.dom.Node; - -/** - * The property factory backed by the DataBindingframework - */ -public final class PropertyHelper { - - private static final XPathFactory FACTORY = XPathFactory.newInstance(); - - private PropertyHelper() { - } - - public static Document evaluate(NamespaceContext nsContext, Node node, String xPathExpression) - throws XPathExpressionException, ParserConfigurationException { - XPath path = FACTORY.newXPath(); - if (nsContext != null) { - path.setNamespaceContext(nsContext); - } else { - path.setNamespaceContext(new DOMNamespeceContext(node)); - } - XPathExpression expression = path.compile(xPathExpression); - Node result = (Node)expression.evaluate(node, XPathConstants.NODE); - if (result == null) { - return null; - } - - // TODO: How to wrap the result into a Document? - Document document = DOMHelper.newDocument(); - if (result instanceof Document) { - return document; - } else { - document.appendChild(document.importNode(result, true)); - return document; - } - } - - public static Document loadFromFile(String file, DeploymentContext deploymentContext) - throws LoaderException { - try { - URI uri = URI.create(file); - URL url = null; - if (!uri.isAbsolute()) { - url = deploymentContext.getClassLoader().getResource(file); - } else { - url = uri.toURL(); - } - InputStream is = url.openStream(); - try { - InputStream2Node transformer = new InputStream2Node(); - return (Document)transformer.transform(is, null); - } finally { - is.close(); - } - } catch (Exception e) { - throw new LoaderException(e); - } - } - - @SuppressWarnings("unchecked") - public static void processProperties(CompositeComponentType> parent, - ComponentDefinition> componentDefinition, - DeploymentContext deploymentContext) throws LoaderException { - Map> propertyValues = componentDefinition.getPropertyValues(); - for (PropertyValue propValue : propertyValues.values()) { - Document node = propValue.getValue(); - String source = propValue.getSource(); - String file = propValue.getFile(); - if (source != null) { - try { - // $/... - int index = source.indexOf('/'); - if (index == -1) { - // Tolerating $prop - source = source + "/"; - index = source.length() - 1; - } - if (source.charAt(0) == '$') { - String name = source.substring(1, index); - Property compositeProp = parent.getProperties().get(name); - if (compositeProp == null) { - InvalidValueException ex = - new InvalidValueException( - "The 'source' cannot be resolved to a composite property"); - ex.addContextName(source); - throw ex; - } - Document document = compositeProp.getDefaultValue(); - // Adding /value because the document root is "value" - String path = source.substring(index); - String xpath = null; - if ("/".equals(path)) { - // trailing / is not legal for xpath - xpath = "/value"; - } else { - xpath = "/value" + path; - } - - // FIXME: How to deal with namespaces? - node = evaluate(null, document, xpath); - propValue.setValue(node); - Property prop = - (Property)componentDefinition.getImplementation().getComponentType() - .getProperties().get(propValue.getName()); - propValue - .setValueFactory(new SimplePropertyObjectFactory(prop, propValue.getValue())); - } else { - InvalidValueException ex = - new InvalidValueException("The 'source' has an invalid value"); - ex.addContextName(source); - throw ex; - } - } catch (Exception e) { - throw new LoaderException(e); - } - } else if (file != null) { - node = loadFromFile(propValue.getFile(), deploymentContext); - propValue.setValue(node); - Property prop = - (Property)componentDefinition.getImplementation().getComponentType().getProperties() - .get(propValue.getName()); - propValue.setValueFactory(new SimplePropertyObjectFactory(prop, propValue.getValue())); - } - } - } - - private static class DOMNamespeceContext implements NamespaceContext { - private Node node; - - /** - * @param node - */ - public DOMNamespeceContext(Node node) { - super(); - this.node = node; - } - - public String getNamespaceURI(String prefix) { - return node.lookupNamespaceURI(prefix); - } - - public String getPrefix(String namespaceURI) { - return node.lookupPrefix(namespaceURI); - } - - public Iterator getPrefixes(String namespaceURI) { - return null; - } - - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/property/PropertyObjectFactoryImpl.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/property/PropertyObjectFactoryImpl.java deleted file mode 100644 index acb1403228..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/property/PropertyObjectFactoryImpl.java +++ /dev/null @@ -1,96 +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.property; - -import javax.xml.namespace.QName; - -import org.apache.tuscany.core.databinding.xml.DOMDataBinding; -import org.apache.tuscany.spi.ObjectCreationException; -import org.apache.tuscany.spi.ObjectFactory; -import org.apache.tuscany.spi.annotation.Autowire; -import org.apache.tuscany.spi.databinding.DataBinding; -import org.apache.tuscany.spi.databinding.DataBindingRegistry; -import org.apache.tuscany.spi.databinding.Mediator; -import org.apache.tuscany.spi.idl.ElementInfo; -import org.apache.tuscany.spi.idl.TypeInfo; -import org.apache.tuscany.spi.loader.PropertyObjectFactory; -import org.apache.tuscany.spi.model.DataType; -import org.apache.tuscany.spi.model.Property; -import org.apache.tuscany.spi.model.PropertyValue; -import org.osoa.sca.annotations.Constructor; -import org.osoa.sca.annotations.Scope; -import org.osoa.sca.annotations.Service; -import org.w3c.dom.Node; - -@Service(PropertyObjectFactory.class) -@Scope("COMPOSITE") -public class PropertyObjectFactoryImpl implements PropertyObjectFactory { - private DataBindingRegistry registry; - private Mediator mediator; - - public PropertyObjectFactoryImpl() { - } - - @Constructor({"registry", "mediator"}) - public PropertyObjectFactoryImpl(@Autowire DataBindingRegistry registry, @Autowire Mediator mediator) { - super(); - this.registry = registry; - this.mediator = mediator; - } - - public ObjectFactory createObjectFactory(Property property, PropertyValue value) { - if (mediator == null) { - return new SimplePropertyObjectFactory(property, value.getValue()); - } - return new ObjectFactoryImpl(property, value); - } - - public class ObjectFactoryImpl

      implements ObjectFactory

      { - private Property

      property; - private PropertyValue

      propertyValue; - private DataType sourceDataType; - private DataType targetDataType; - - public ObjectFactoryImpl(Property

      property, PropertyValue

      propertyValue) { - this.property = property; - this.propertyValue = propertyValue; - sourceDataType = new DataType(DOMDataBinding.NAME, Node.class, this.property.getXmlType()); - TypeInfo typeInfo = new TypeInfo(property.getXmlType(), true, null); - ElementInfo elementInfo = new ElementInfo(null, typeInfo); - sourceDataType.setMetadata(ElementInfo.class.getName(), elementInfo); - Class javaType = this.property.getJavaType(); - String dataBinding = (String)property.getExtensions().get(DataBinding.class.getName()); - if (dataBinding != null) { - targetDataType = new DataType(dataBinding, javaType, javaType); - } else { - targetDataType = registry.introspectType(javaType); - if (targetDataType == null) { - targetDataType = new DataType("java.lang.Object", javaType, javaType); - } - } - } - - @SuppressWarnings("unchecked") - public P getInstance() throws ObjectCreationException { - return (P)mediator.mediate(propertyValue.getValue(), sourceDataType, targetDataType, null); - } - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/property/SimplePropertyObjectFactory.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/property/SimplePropertyObjectFactory.java deleted file mode 100644 index b291eb8d96..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/property/SimplePropertyObjectFactory.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.property; - -import org.apache.tuscany.spi.ObjectCreationException; -import org.apache.tuscany.spi.ObjectFactory; -import org.apache.tuscany.spi.databinding.extension.SimpleTypeMapperExtension; -import org.apache.tuscany.spi.idl.TypeInfo; -import org.apache.tuscany.spi.model.Property; -import org.w3c.dom.Document; - -public class SimplePropertyObjectFactory

      implements ObjectFactory

      { - private SimpleTypeMapperExtension typeMapper; - private Property

      property; - private Document value; - private P instance; - - public SimplePropertyObjectFactory(Property

      property, Document value) { - super(); - this.property = property; - this.value = (value == null) ? property.getDefaultValue() : value; - this.typeMapper = new SimpleTypeMapperExtension(); - } - - @SuppressWarnings("unchecked") - public P getInstance() throws ObjectCreationException { - if (value == null) { - return null; - } - if (instance == null) { - String text = value.getDocumentElement().getTextContent(); - TypeInfo xmlType = null; - if (property.getJavaType() == null) { - xmlType = new TypeInfo(property.getXmlType(), true, null); - } else { - xmlType = typeMapper.getXMLType(property.getJavaType()); - } - if (xmlType == null) { - throw new IllegalArgumentException("Complex property is not supported."); - } - instance = (P)typeMapper.toJavaObject(xmlType, text, null); - } - return instance; - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/runtime/AbstractRuntime.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/runtime/AbstractRuntime.java deleted file mode 100644 index 9a91c9569d..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/runtime/AbstractRuntime.java +++ /dev/null @@ -1,311 +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 java.net.URL; -import javax.xml.stream.XMLInputFactory; - -import org.osoa.sca.CompositeContext; - -import org.apache.tuscany.core.bootstrap.Bootstrapper; -import org.apache.tuscany.core.bootstrap.DefaultBootstrapper; -import org.apache.tuscany.core.implementation.system.model.SystemCompositeImplementation; -import org.apache.tuscany.core.monitor.NullMonitorFactory; -import org.apache.tuscany.core.launcher.CompositeContextImpl; -import org.apache.tuscany.host.MonitorFactory; -import org.apache.tuscany.host.RuntimeInfo; -import org.apache.tuscany.host.management.ManagementService; -import org.apache.tuscany.host.runtime.InitializationException; -import org.apache.tuscany.host.runtime.TuscanyRuntime; -import org.apache.tuscany.spi.bootstrap.RuntimeComponent; -import org.apache.tuscany.spi.bootstrap.ComponentNames; -import org.apache.tuscany.spi.builder.BuilderException; -import org.apache.tuscany.spi.component.ComponentException; -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.component.ComponentRegistrationException; -import org.apache.tuscany.spi.component.SCAObject; -import org.apache.tuscany.spi.component.AtomicComponent; -import org.apache.tuscany.spi.component.TargetResolutionException; -import org.apache.tuscany.spi.deployer.Deployer; -import org.apache.tuscany.spi.loader.LoaderException; -import org.apache.tuscany.spi.model.ComponentDefinition; -import org.apache.tuscany.spi.model.CompositeImplementation; -import org.apache.tuscany.spi.services.management.TuscanyManagementService; -import org.apache.tuscany.spi.wire.WireService; - -/** - * @version $Rev$ $Date$ - */ -public abstract class AbstractRuntime implements TuscanyRuntime { - private final XMLInputFactory xmlFactory; - private URL systemScdl; - private String applicationName; - private URL applicationScdl; - private ClassLoader hostClassLoader; - private ClassLoader applicationClassLoader; - private RuntimeInfo runtimeInfo; - private MonitorFactory monitorFactory; - private ManagementService managementService; - - private RuntimeComponent runtime; - private CompositeComponent systemComponent; - private CompositeComponent tuscanySystem; - private Deployer deployer; - private WireService wireService; - - protected AbstractRuntime() { - this(new NullMonitorFactory()); - } - - protected AbstractRuntime(MonitorFactory monitorFactory) { - this.monitorFactory = monitorFactory; - xmlFactory = XMLInputFactory.newInstance("javax.xml.stream.XMLInputFactory", 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 getApplicationClassLoader() { - return applicationClassLoader; - } - - public void setApplicationClassLoader(ClassLoader applicationClassLoader) { - this.applicationClassLoader = applicationClassLoader; - } - - public ClassLoader getHostClassLoader() { - return hostClassLoader; - } - - public void setHostClassLoader(ClassLoader hostClassLoader) { - this.hostClassLoader = hostClassLoader; - } - - public RuntimeInfo getRuntimeInfo() { - return runtimeInfo; - } - - public void setRuntimeInfo(RuntimeInfo 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; - } - - protected XMLInputFactory getXMLFactory() { - return xmlFactory; - } - - protected RuntimeComponent getRuntime() { - return runtime; - } - - protected CompositeComponent getSystemComponent() { - return systemComponent; - } - - protected CompositeComponent getTuscanySystem() { - return tuscanySystem; - } - - protected Deployer getDeployer() { - return deployer; - } - - protected WireService getWireService() { - return wireService; - } - - public void initialize() throws InitializationException { - Bootstrapper bootstrapper = createBootstrapper(); - runtime = bootstrapper.createRuntime(); - runtime.start(); - - systemComponent = runtime.getSystemComponent(); - registerSystemComponents(); - systemComponent.start(); - - // deploy the system scdl - try { - tuscanySystem = deploySystemScdl(bootstrapper.createDeployer(), - systemComponent, - ComponentNames.TUSCANY_SYSTEM, - getSystemScdl(), - getClass().getClassLoader()); - } catch (LoaderException e) { - throw new InitializationException(e); - } catch (BuilderException e) { - throw new InitializationException(e); - } catch (ComponentException e) { - throw new InitializationException(e); - } - tuscanySystem.start(); - - this.deployer = locateDeployer(); - this.wireService = locateWireService(); - } - - public void destroy() { - this.wireService = null; - this.deployer = null; - if (tuscanySystem != null) { - tuscanySystem.stop(); - tuscanySystem = null; - } - if (systemComponent != null) { - systemComponent.stop(); - systemComponent = null; - } - if (runtime != null) { - runtime.stop(); - runtime = null; - } - } - - - - protected Bootstrapper createBootstrapper() { - TuscanyManagementService tms = (TuscanyManagementService) getManagementService(); - return new DefaultBootstrapper(getMonitorFactory(), xmlFactory, tms); - } - - protected void registerSystemComponents() throws InitializationException { - try { - systemComponent.registerJavaObject(RuntimeInfo.COMPONENT_NAME, RuntimeInfo.class, runtimeInfo); - systemComponent.registerJavaObject("MonitorFactory", MonitorFactory.class, getMonitorFactory()); - } catch (ComponentRegistrationException e) { - throw new InitializationException(e); - } - } - - protected Deployer locateDeployer() throws InitializationException { - SCAObject deployerComponent = tuscanySystem.getSystemChild(ComponentNames.TUSCANY_DEPLOYER); - if (!(deployerComponent instanceof AtomicComponent)) { - throw new InitializationException("Deployer must be an atomic component"); - } - try { - return (Deployer)((AtomicComponent)deployerComponent).getTargetInstance(); - } catch (TargetResolutionException e) { - throw new InitializationException(e); - } - } - - protected WireService locateWireService() throws InitializationException { - SCAObject wireServiceComponent = tuscanySystem.getSystemChild(ComponentNames.TUSCANY_WIRE_SERVICE); - if (!(wireServiceComponent instanceof AtomicComponent)) { - throw new InitializationException("WireService must be an atomic component"); - } - try { - return (WireService)((AtomicComponent)wireServiceComponent).getTargetInstance(); - } catch (TargetResolutionException e) { - throw new InitializationException(e); - } - } - - protected CompositeComponent deploySystemScdl(Deployer deployer, - CompositeComponent parent, - String name, - URL systemScdl, - ClassLoader systemClassLoader) - throws LoaderException, BuilderException, ComponentException { - - SystemCompositeImplementation impl = new SystemCompositeImplementation(); - impl.setScdlLocation(systemScdl); - impl.setClassLoader(systemClassLoader); - ComponentDefinition definition = - new ComponentDefinition(name, impl); - - return (CompositeComponent) deployer.deploy(parent, definition); - } - - @Deprecated - public CompositeContext deployApplication(String name, URL scdlLocation, ClassLoader classLoader) - throws InitializationException { - try { - CompositeComponent application = deployApplicationScdl(getDeployer(), - getRuntime().getRootComponent(), - name, - scdlLocation, - classLoader); - application.start(); - return new CompositeContextImpl(application, getWireService()); - } catch (LoaderException ex) { - throw new InitializationException(ex); - } catch (BuilderException ex) { - throw new InitializationException(ex); - } catch (ComponentException ex) { - throw new InitializationException(ex); - } - } - - protected CompositeComponent deployApplicationScdl(Deployer deployer, - CompositeComponent parent, - String name, - URL applicationScdl, - ClassLoader applicationClassLoader) - throws LoaderException, BuilderException, ComponentException { - - CompositeImplementation impl = new CompositeImplementation(); - impl.setScdlLocation(applicationScdl); - impl.setClassLoader(applicationClassLoader); - ComponentDefinition definition = - new ComponentDefinition(name, impl); - - return (CompositeComponent) deployer.deploy(parent, definition); - } - - public CompositeContext getContext() { - throw new UnsupportedOperationException(); - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/services/artifact/LocalMavenRepository.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/services/artifact/LocalMavenRepository.java deleted file mode 100644 index f50e8544a3..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/services/artifact/LocalMavenRepository.java +++ /dev/null @@ -1,100 +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.artifact; - -import java.io.File; -import java.net.MalformedURLException; -import java.security.AccessController; -import java.security.PrivilegedAction; -import java.util.Collection; - -import org.osoa.sca.annotations.Property; - -import org.apache.tuscany.spi.services.artifact.Artifact; -import org.apache.tuscany.spi.services.artifact.ArtifactRepository; - -/** - * An implementation of ArtifactRepository that uses a local Maven2 repository. - * - * @version $Rev$ $Date$ - */ -public class LocalMavenRepository implements ArtifactRepository { - private File localRepo; - - /** - * Constructor specifying the location of the local repo. Relative paths are resolved against the user's home - * directory. - * - * @param repoPath the path to the local repo - */ - public LocalMavenRepository(@Property(name = "repository") String repoPath) { - String home = AccessController.doPrivileged(new PrivilegedAction() { - public String run() { - return System.getProperty("user.home"); - } - }); - this.localRepo = new File(home, repoPath); - } - - public void resolve(Artifact artifact) { - if (artifact.getUrl() != null) { - return; - } - - String path = getPath(artifact); - File artifactFile = new File(localRepo, path); - if (artifactFile.exists()) { - try { - artifact.setUrl(artifactFile.toURI().toURL()); - } catch (MalformedURLException e) { - // toURI should have escaped the filename to allow it to be converted to a URL - throw new AssertionError(); - } - } - } - - /** - * Return the path into the repo for an artifact. The path for an artifact is ${group.replace('.', - * '/')}/$[name}/${version}/${name}-${version}[-${classifier}].${type} - * - * @param artifact the artifact to resolve - * @return the path into the repo for the artifact - */ - protected String getPath(Artifact artifact) { - StringBuilder builder = new StringBuilder(); - if (artifact.getGroup() != null) { - builder.append(artifact.getGroup().replace('.', '/')).append('/'); - } - builder.append(artifact.getName()).append('/'); - builder.append(artifact.getVersion()).append('/'); - - builder.append(artifact.getName()).append('-').append(artifact.getVersion()); - if (artifact.getClassifier() != null) { - builder.append('-').append(artifact.getClassifier()); - } - builder.append('.').append(artifact.getType()); - return builder.toString(); - } - - public void resolve(Collection artifacts) { - for (Artifact artifact : artifacts) { - resolve(artifact); - } - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/AssemblyServiceImpl.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/AssemblyServiceImpl.java deleted file mode 100644 index e264663dd4..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/AssemblyServiceImpl.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.services.deployment; - -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.net.URLConnection; -import java.util.Map; -import java.util.HashMap; - -import org.apache.tuscany.host.deployment.AssemblyService; -import org.apache.tuscany.host.deployment.DeploymentException; -import org.apache.tuscany.host.deployment.UnsupportedContentTypeException; -import org.apache.tuscany.spi.deployer.ChangeSetHandlerRegistry; -import org.apache.tuscany.spi.deployer.ChangeSetHandler; - -/** - * @version $Rev$ $Date$ - */ -public class AssemblyServiceImpl implements AssemblyService, ChangeSetHandlerRegistry { - private final Map registry = new HashMap(); - - public void applyChanges(URL changeSet) throws DeploymentException, IOException { - if (changeSet == null) { - throw new IllegalArgumentException("changeSet is null"); - } - - URLConnection connection = changeSet.openConnection(); - String contentType = connection.getContentType(); - //todo try and figure out content type from the URL - if (contentType == null) { - throw new UnsupportedContentTypeException(null, changeSet.toString()); - } - - InputStream is = connection.getInputStream(); - try { - applyChanges(is, contentType); - } finally { - try { - is.close(); - } catch (IOException e) { - // ignore - } - } - } - - public void applyChanges(InputStream changeSet, String contentType) throws DeploymentException, IOException { - if (changeSet == null) { - throw new IllegalArgumentException("changeSet is null"); - } - if (contentType == null) { - throw new IllegalArgumentException("contentType is null"); - } - - ChangeSetHandler handler = registry.get(contentType); - if (handler == null) { - throw new UnsupportedContentTypeException(contentType); - } - - handler.applyChanges(changeSet); - } - - public void register(ChangeSetHandler handler) { - registry.put(handler.getContentType(), handler); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/ContributionServiceImpl.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/ContributionServiceImpl.java deleted file mode 100644 index 64fec4e246..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/ContributionServiceImpl.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.services.deployment; - -import java.io.IOException; -import java.io.InputStream; -import java.net.URI; -import java.net.URISyntaxException; -import java.net.URL; -import java.net.URLConnection; -import java.util.HashMap; -import java.util.Map; - -import org.apache.tuscany.host.deployment.ContributionService; -import org.apache.tuscany.host.deployment.DeploymentException; -import org.apache.tuscany.host.deployment.UnsupportedContentTypeException; -import org.apache.tuscany.spi.deployer.ContributionProcessor; -import org.apache.tuscany.spi.deployer.ContributionProcessorRegistry; - -/** - * @version $Rev$ $Date$ - */ -public class ContributionServiceImpl implements ContributionService, ContributionProcessorRegistry { - private Map registry = new HashMap(); - - public void register(ContributionProcessor processor) { - registry.put(processor.getContentType(), processor); - } - - public URI contribute(URL contribution) throws DeploymentException, IOException { - if (contribution == null) { - throw new IllegalArgumentException("contribution is null"); - } - - URI source; - try { - source = contribution.toURI(); - } catch (URISyntaxException e) { - throw new IllegalArgumentException("contribution cannot be converted to a URI", e); - } - - URLConnection connection = contribution.openConnection(); - String contentType = connection.getContentType(); - //todo try and figure out content type from the URL - if (contentType == null) { - throw new UnsupportedContentTypeException(null, contribution.toString()); - } - - InputStream is = connection.getInputStream(); - try { - return contribute(source, is, contentType); - } finally { - try { - is.close(); - } catch (IOException e) { - // ignore - } - } - } - - public URI contribute(URI source, InputStream contribution, String contentType) - throws DeploymentException, IOException { - if (contentType == null) { - throw new IllegalArgumentException("contentType was null"); - } - - ContributionProcessor processor = registry.get(contentType); - if (processor == null) { - throw new UnsupportedContentTypeException(contentType, source.toString()); - } - - return null; - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/InvalidDocumentException.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/InvalidDocumentException.java deleted file mode 100644 index f509929f29..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/InvalidDocumentException.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.services.deployment; - -import org.apache.tuscany.host.deployment.DeploymentException; - -/** - * Exception that indicates that the supplied XML Document invalid. - * - * @version $Rev$ $Date$ - */ -public class InvalidDocumentException extends DeploymentException { - protected InvalidDocumentException(String rootElement) { - super(rootElement); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/XMLChangeSetHandler.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/XMLChangeSetHandler.java deleted file mode 100644 index 87f68340e2..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/XMLChangeSetHandler.java +++ /dev/null @@ -1,132 +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.deployment; - -import java.io.IOException; -import java.io.InputStream; -import javax.xml.namespace.QName; -import javax.xml.stream.XMLInputFactory; -import static javax.xml.stream.XMLStreamConstants.END_DOCUMENT; -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 org.apache.tuscany.spi.bootstrap.RuntimeComponent; -import org.apache.tuscany.spi.builder.Builder; -import org.apache.tuscany.spi.builder.BuilderException; -import org.apache.tuscany.spi.component.Component; -import org.apache.tuscany.spi.component.ComponentRegistrationException; -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.component.PrepareException; -import org.apache.tuscany.spi.deployer.ChangeSetHandler; -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.model.ComponentDefinition; - -import org.apache.tuscany.core.deployer.RootDeploymentContext; -import org.apache.tuscany.host.deployment.ContentTypes; -import org.apache.tuscany.host.deployment.DeploymentException; - -/** - * @version $Rev$ $Date$ - */ -public class XMLChangeSetHandler implements ChangeSetHandler { - private static final String NS = "http://tuscany.apache.org/xmlns/1.0-SNAPSHOT"; - private static final QName CHANGESET = new QName(NS, "changeSet"); - private static final QName CREATECOMPONENT = new QName(NS, "createComponent"); - - private final RuntimeComponent runtime; - private final Builder builder; - private final Loader loader; - private final XMLInputFactory xmlFactory; - - public XMLChangeSetHandler(RuntimeComponent runtime, Loader loader, Builder builder) { - this.runtime = runtime; - this.loader = loader; - this.builder = builder; - xmlFactory = XMLInputFactory.newInstance("javax.xml.stream.XMLInputFactory", getClass().getClassLoader()); - } - - public String getContentType() { - return ContentTypes.CHANGESET_XML; - } - - public void applyChanges(InputStream changeSet) throws DeploymentException, IOException { - try { - XMLStreamReader xmlReader = xmlFactory.createXMLStreamReader(changeSet); - while (true) { - switch (xmlReader.next()) { - case START_ELEMENT: - if (!CHANGESET.equals(xmlReader.getName())) { - throw new InvalidDocumentException(xmlReader.getName().toString()); - } - processChanges(xmlReader); - break; - case END_DOCUMENT: - return; - } - } - } catch (XMLStreamException e) { - throw (IOException) new IOException(e.getMessage()).initCause(e); - } - } - - public void processChanges(XMLStreamReader xmlReader) throws XMLStreamException, DeploymentException { - while (true) { - switch (xmlReader.next()) { - case START_ELEMENT: - if (CREATECOMPONENT.equals(xmlReader.getName())) { - createComponent(xmlReader); - } else { - // reject unrecognized commands - throw new InvalidDocumentException(xmlReader.getName().toString()); - } - break; - case END_ELEMENT: - return; - } - } - } - - public void createComponent(XMLStreamReader xmlReader) throws XMLStreamException { - DeploymentContext deploymentContext = new RootDeploymentContext(null, xmlFactory, null, null); - CompositeComponent parent = runtime.getRootComponent(); - try { - ComponentDefinition componentDefinition = - (ComponentDefinition) loader.load(parent, null, xmlReader, deploymentContext); - Component component = builder.build(parent, componentDefinition, deploymentContext); - component.prepare(); - parent.register(component); - } catch (LoaderException e) { - // FIXME throw something appropriate - throw new AssertionError("FIXME"); - } catch (BuilderException e) { - // FIXME throw something appropriate - throw new AssertionError("FIXME"); - } catch (PrepareException e) { - // FIXME throw something appropriate - throw new AssertionError("FIXME"); - } catch (ComponentRegistrationException e) { - // FIXME throw something appropriate - throw new AssertionError("FIXME"); - } - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/services/extension/AbstractExtensionDeployer.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/services/extension/AbstractExtensionDeployer.java deleted file mode 100644 index cc3339e2b7..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/services/extension/AbstractExtensionDeployer.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.services.extension; - -import java.io.File; -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URL; - -import org.apache.tuscany.core.implementation.system.model.SystemCompositeImplementation; -import org.apache.tuscany.spi.annotation.Autowire; -import org.apache.tuscany.spi.component.Component; -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.component.ComponentException; -import org.apache.tuscany.spi.deployer.CompositeClassLoader; -import org.apache.tuscany.spi.deployer.Deployer; -import org.apache.tuscany.spi.loader.LoaderException; -import org.apache.tuscany.spi.model.ComponentDefinition; -import org.apache.tuscany.spi.builder.BuilderException; - -/** - * @version $Rev$ $Date$ - */ -public class AbstractExtensionDeployer { - protected Deployer deployer; - protected CompositeComponent parent; - - @Autowire - public void setDeployer(Deployer deployer) { - this.deployer = deployer; - } - - @Autowire - public void setParent(CompositeComponent parent) { - this.parent = parent; - } - - protected void deployExtension(File file) { - // extension name is file name less any extension - String name = file.getName(); - int dot = name.lastIndexOf('.'); - if (dot > 0) { - name = name.substring(0, dot); - } - URL url; - try { - url = file.toURI().toURL(); - } catch (MalformedURLException e) { - // toURI should have encoded the URL - throw new AssertionError(); - } - - deployExtension(name, url); - } - - protected void deployExtension(String name, URL url) { - // FIXME for now, assume this class's ClassLoader is the Tuscany system classloader - // FIXME we should really use the one associated with the parent composite - CompositeClassLoader extensionCL = new CompositeClassLoader(getClass().getClassLoader()); - - // see if the URL points to a composite JAR by looking for a default SCDL file inside it - URL scdlLocation; - try { - scdlLocation = new URL("jar:" + url.toExternalForm() + "!/META-INF/sca/default.scdl"); - } catch (MalformedURLException e) { - // the form of the jar: URL should be correct given url.toExternalForm() worked - throw new AssertionError(); - } - try { - scdlLocation.openStream().close(); - // we connected to the SCDL so let's add the JAR file to the classloader - extensionCL.addURL(url); - } catch (IOException e) { - // assume that the URL we were given is not a JAR file so just use the supplied resource - scdlLocation = url; - } - - // create a ComponentDefinition to represent the component we are going to deploy - SystemCompositeImplementation implementation = new SystemCompositeImplementation(); - implementation.setScdlLocation(scdlLocation); - implementation.setClassLoader(extensionCL); - ComponentDefinition definition = - new ComponentDefinition(name, implementation); - - // FIXME: [rfeng] Should we reset the thread context class loader here? - // From the debugger with tomcat, the current TCCL is the RealmClassLoader - // ClassLoader contextCL = Thread.currentThread().getContextClassLoader(); - try { - // Thread.currentThread().setContextClassLoader(extensionCL); - Component component = null; - try { - component = deployer.deploy(parent, definition); - component.start(); - } catch (BuilderException e) { - // FIXME JFM handle the exception - e.printStackTrace(); - } catch (ComponentException e) { - // FIXME handle the exception - e.printStackTrace(); - } - } catch (LoaderException e) { - // FIXME handle the exception - e.printStackTrace(); - } - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/services/host/DelegatingResourceHostRegistry.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/services/host/DelegatingResourceHostRegistry.java deleted file mode 100644 index 38ce4d16d2..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/services/host/DelegatingResourceHostRegistry.java +++ /dev/null @@ -1,142 +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.host; - -import java.util.HashMap; -import java.util.Map; - -import org.osoa.sca.annotations.Service; - -import org.apache.tuscany.spi.host.ResourceHost; -import org.apache.tuscany.spi.host.ResourceHostRegistry; -import org.apache.tuscany.spi.host.ResourceResolutionException; - -/** - * The default implementation of a ResourceRegisty that resolves resources in the SCA:// - * namespace against its parent composite and delegates resolution to registered ResourceHosts for other - * namespaces. The search order for resources resolved by type starts with the SCA namespace and proceeds to hosts in - * the order they were registered. - * - * @version $Rev$ $Date$ - */ -@Service(interfaces = {ResourceHost.class, ResourceHostRegistry.class}) -public class DelegatingResourceHostRegistry implements ResourceHost, ResourceHostRegistry { - private static final String SCA_PREFIX = "SCA://"; - private Map resourceHosts = new HashMap(); - private Map, Object> systemResources = new HashMap, Object>(); - private Map mappedSystemResources = new HashMap(); - - public DelegatingResourceHostRegistry() { - } - - public void registerResourceHost(String uri, ResourceHost host) { - resourceHosts.put(uri, host); - } - - public void unregisterResourceHost(String uri) { - resourceHosts.remove(uri); - } - - public void registerResource(Class type, Object resource) { - systemResources.put(type, resource); - } - - public void registerResource(Class type, String name, Object resource) { - mappedSystemResources.put(new Key(type, name), resource); - } - - public void unregisterResource(Class type, String name) { - mappedSystemResources.remove(new Key(type, name)); - } - - public void unregisterResource(Class type) { - systemResources.remove(type); - } - - public T resolveResource(Class type) throws ResourceResolutionException { - T instance = type.cast(systemResources.get(type)); - if (instance == null) { - for (ResourceHost host : resourceHosts.values()) { - instance = host.resolveResource(type); - if (instance != null) { - return instance; - } - } - } - return instance; - } - - public T resolveResource(Class type, String mappedName) throws ResourceResolutionException { - if (mappedName.startsWith(SCA_PREFIX)) { - String name = mappedName.substring(SCA_PREFIX.length()); - return type.cast(mappedSystemResources.get(new Key(type, name))); - } else { - int pos = mappedName.indexOf("://"); - if (pos == -1) { - return type.cast(mappedSystemResources.get(new Key(type, mappedName))); - } - String uri = mappedName.substring(0, pos + 3); - ResourceHost host = resourceHosts.get(uri); - if (host == null) { - throw new ResourceResolutionException("No resource host for URI", uri); - } - return host.resolveResource(type, mappedName); - } - } - - private class Key { - private Class clazz; - private String name; - - public Key(Class clazz, String name) { - this.clazz = clazz; - this.name = name; - } - - public Key(Class clazz) { - this.clazz = clazz; - } - - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - - Key key = (Key) o; - - if (clazz != null ? !clazz.equals(key.clazz) : key.clazz != null) { - return false; - } - if (name != null ? !name.equals(key.name) : key.name != null) { - return false; - } - return true; - } - - public int hashCode() { - int result; - result = clazz != null ? clazz.hashCode() : 0; - result = 31 * result + (name != null ? name.hashCode() : 0); - return result; - } - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/services/store/memory/MemoryStore.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/services/store/memory/MemoryStore.java deleted file mode 100644 index b1a0b67001..0000000000 --- a/branches/pre-spec-changes/kernel/core/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.getCanonicalName(), 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.getCanonicalName(), id); - } - Record record = map.get(id); - if (record == null) { - throw new StoreWriteException("Record not found", owner.getCanonicalName(), 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.getCanonicalName(), id); - } - if (map.remove(id) == null) { - throw new StoreWriteException("Owner not found", owner.getCanonicalName(), 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/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/services/work/jca/JcaWorkScheduler.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/services/work/jca/JcaWorkScheduler.java deleted file mode 100644 index 79b7bf4ca1..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/services/work/jca/JcaWorkScheduler.java +++ /dev/null @@ -1,206 +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.work.jca; - -import javax.resource.spi.work.Work; -import javax.resource.spi.work.WorkEvent; -import javax.resource.spi.work.WorkException; -import javax.resource.spi.work.WorkListener; -import javax.resource.spi.work.WorkManager; -import javax.resource.spi.work.WorkRejectedException; - -import org.apache.tuscany.spi.services.work.NotificationListener; -import org.apache.tuscany.spi.services.work.WorkScheduler; -import org.apache.tuscany.spi.services.work.WorkSchedulerException; - -/** - * A work scheduler implementation based on the JCA SPI work manager. - *

      - *

      - * This needs a JCA SPI work manager implementation available for scheduling work. Instances can be configured with a - * work manager implementation that is injected in. It is the responsibility of the runtime environment to make a work - * manager implementaion available.

      - */ -public class JcaWorkScheduler implements WorkScheduler { - - /** - * Underlying JCA work manager - */ - private WorkManager jcaWorkManager; - - /** - * Initializes the JCA work manager. - * - * @param jcaWorkManager JCA work manager. - */ - public JcaWorkScheduler(WorkManager jcaWorkManager) { - - if (jcaWorkManager == null) { - throw new IllegalArgumentException("Work manager cannot be null"); - } - this.jcaWorkManager = jcaWorkManager; - - } - - /** - * Schedules a unit of work for future execution. The notification listener is used to register interest in - * callbacks regarding the status of the work. - * - * @param work The unit of work that needs to be asynchronously executed. - */ - public void scheduleWork(T work) { - scheduleWork(work, null); - } - - /** - * Schedules a unit of work for future execution. The notification listener is used to register interest in - * callbacks regarding the status of the work. - * - * @param work The unit of work that needs to be asynchronously executed. - * @param listener Notification listener for callbacks. - */ - public void scheduleWork(T work, NotificationListener listener) { - - if (work == null) { - throw new IllegalArgumentException("Work cannot be null"); - } - - JcaWork jcaWork = new JcaWork(work); - try { - if (listener == null) { - jcaWorkManager.scheduleWork(jcaWork); - } else { - JcaWorkListener jcaWorkListener = new JcaWorkListener(listener); - // TODO Clarify the usage of timeout and execution context - jcaWorkManager.scheduleWork(jcaWork, -1, null, jcaWorkListener); - } - } catch (WorkRejectedException ex) { - if (listener != null) { - listener.workRejected(work); - } else { - throw new WorkSchedulerException(ex); - } - } catch (WorkException ex) { - throw new WorkSchedulerException(ex); - } - - } - - /* - * Worklistener for keeping track of work status callbacks. - * - */ - private class JcaWorkListener implements WorkListener { - - // Notification listener - private NotificationListener listener; - - /* - * Initializes the notification listener. - */ - public JcaWorkListener(NotificationListener listener) { - this.listener = listener; - } - - /* - * Callback when the work is accepted. - */ - public void workAccepted(WorkEvent workEvent) { - T work = getWork(workEvent); - listener.workAccepted(work); - } - - /* - * Callback when the work is rejected. - */ - public void workRejected(WorkEvent workEvent) { - T work = getWork(workEvent); - listener.workRejected(work); - } - - /* - * Callback when the work is started. - */ - public void workStarted(WorkEvent workEvent) { - T work = getWork(workEvent); - listener.workStarted(work); - } - - /* - * Callback when the work is completed. - */ - public void workCompleted(WorkEvent workEvent) { - T work = getWork(workEvent); - Exception exception = workEvent.getException(); - if (exception != null) { - listener.workFailed(work, exception); - } else { - listener.workCompleted(work); - } - } - - /* - * Gets the underlying work from the work event. - */ - @SuppressWarnings("unchecked") - private T getWork(WorkEvent workEvent) { - JcaWork jcaWork = (JcaWork) workEvent.getWork(); - return jcaWork.getWork(); - } - - } - - /* - * JCA work wrapper. - */ - private class JcaWork implements Work { - - // Work that is being executed. - private T work; - - /* - * Initializes the work instance. - */ - public JcaWork(T work) { - this.work = work; - } - - /* - * Releases the work. - */ - public void release() { - } - - /* - * Performs the work. - */ - public void run() { - work.run(); - } - - /* - * Returns the completed work. - */ - public T getWork() { - return work; - } - - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/services/work/jsr237/Jsr237WorkScheduler.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/services/work/jsr237/Jsr237WorkScheduler.java deleted file mode 100644 index 8fa8000477..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/services/work/jsr237/Jsr237WorkScheduler.java +++ /dev/null @@ -1,217 +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.work.jsr237; - -import org.osoa.sca.annotations.Scope; - -import org.apache.tuscany.spi.annotation.Autowire; -import org.apache.tuscany.spi.services.work.NotificationListener; -import org.apache.tuscany.spi.services.work.WorkScheduler; -import org.apache.tuscany.spi.services.work.WorkSchedulerException; - -import commonj.work.Work; -import commonj.work.WorkEvent; -import commonj.work.WorkException; -import commonj.work.WorkListener; -import commonj.work.WorkManager; -import commonj.work.WorkRejectedException; - -/** - * A work scheduler implementation based on a JSR 237 work manager. - *

      - *

      - * This needs a JSR 237 work manager implementation available for scheduling work. Instances can be configured with a - * work manager implementation that is injected in. It is the responsibility of the runtime environment to make a work - * manager implementaion available. For example, if the managed environment supports work manager the runtime can use - * the appropriate lookup mechanism to inject the work manager implementation.

      - */ -@Scope("COMPOSITE") -public class Jsr237WorkScheduler implements WorkScheduler { - - /** - * Underlying JSR-237 work manager - */ - private WorkManager jsr237WorkManager; - - /** - * Initializes the JSR 237 work manager. - * - * @param jsr237WorkManager JSR 237 work manager. - */ - public Jsr237WorkScheduler(@Autowire WorkManager jsr237WorkManager) { - if (jsr237WorkManager == null) { - throw new IllegalArgumentException("Work manager cannot be null"); - } - this.jsr237WorkManager = jsr237WorkManager; - } - - /** - * Schedules a unit of work for future execution. The notification listener is used to register interest in - * callbacks regarding the status of the work. - * - * @param work The unit of work that needs to be asynchronously executed. - */ - public void scheduleWork(T work) { - scheduleWork(work, null); - } - - /** - * Schedules a unit of work for future execution. The notification listener is used to register interest in - * callbacks regarding the status of the work. - * - * @param work The unit of work that needs to be asynchronously executed. - * @param listener Notification listener for callbacks. - */ - public void scheduleWork(T work, NotificationListener listener) { - - if (work == null) { - throw new IllegalArgumentException("Work cannot be null"); - } - - Jsr237Work jsr237Work = new Jsr237Work(work); - try { - if (listener == null) { - jsr237WorkManager.schedule(jsr237Work); - } else { - Jsr237WorkListener jsr237WorkListener = new Jsr237WorkListener(listener, work); - jsr237WorkManager.schedule(jsr237Work, jsr237WorkListener); - } - } catch (WorkRejectedException ex) { - if (listener != null) { - listener.workRejected(work); - } else { - throw new WorkSchedulerException(ex); - } - } catch (WorkException ex) { - throw new WorkSchedulerException(ex); - } - - } - - /* - * Worklistener for keeping track of work status callbacks. - * - */ - private class Jsr237WorkListener implements WorkListener { - - // Notification listener - private NotificationListener listener; - - // Work - private T work; - - /* - * Initializes the notification listener. - */ - public Jsr237WorkListener(NotificationListener listener, T work) { - this.listener = listener; - this.work = work; - } - - /* - * Callback when the work is accepted. - */ - public void workAccepted(WorkEvent workEvent) { - T work = getWork(); - listener.workAccepted(work); - } - - /* - * Callback when the work is rejected. - */ - public void workRejected(WorkEvent workEvent) { - T work = getWork(); - listener.workRejected(work); - } - - /* - * Callback when the work is started. - */ - public void workStarted(WorkEvent workEvent) { - T work = getWork(); - listener.workStarted(work); - } - - /* - * Callback when the work is completed. - */ - public void workCompleted(WorkEvent workEvent) { - T work = getWork(); - Exception exception = workEvent.getException(); - if (exception != null) { - listener.workFailed(work, exception); - } else { - listener.workCompleted(work); - } - } - - /* - * Gets the underlying work from the work event. - */ - private T getWork() { - return work; - } - - } - - /* - * JCA work wrapper. - */ - private class Jsr237Work implements Work { - - // Work that is being executed. - private T work; - - /* - * Initializes the work instance. - */ - public Jsr237Work(T work) { - this.work = work; - } - - /* - * Returns the completed work. - */ - public T getWork() { - return work; - } - - /* - * Release the work. - */ - public void release() { - } - - /* - * Work attributes are not daemon. - */ - public boolean isDaemon() { - return false; - } - - /* - * Runs the work. - */ - public void run() { - work.run(); - } - - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/services/work/jsr237/workmanager/DefaultWorkEvent.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/services/work/jsr237/workmanager/DefaultWorkEvent.java deleted file mode 100644 index c391d0b597..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/services/work/jsr237/workmanager/DefaultWorkEvent.java +++ /dev/null @@ -1,73 +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.work.jsr237.workmanager; - -import commonj.work.WorkEvent; -import commonj.work.WorkException; -import commonj.work.WorkItem; - -/** - * Default immutable implementation of the WorkEvent class. - */ -class DefaultWorkEvent implements WorkEvent { - - // Work item for this event - private WorkItem workItem; - - // Exception if something has gone wrong - private WorkException exception; - - /** - * Instantiates the event. - * - * @param workItem Work item for this event. - */ - public DefaultWorkEvent(final DefaultWorkItem workItem) { - this.workItem = workItem; - this.exception = workItem.getException(); - } - - /** - * Returns the work type based on whether the work was accepted, started, - * rejected or completed. - * - * @return Work type. - */ - public int getType() { - return workItem.getStatus(); - } - - /** - * Returns the work item associated with this work type. - * - * @return Work item. - */ - public WorkItem getWorkItem() { - return workItem; - } - - /** - * Returns the exception if the work completed with an exception. - * - * @return Work exception. - */ - public WorkException getException() { - return exception; - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/services/work/jsr237/workmanager/DefaultWorkItem.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/services/work/jsr237/workmanager/DefaultWorkItem.java deleted file mode 100644 index 0adc005bb0..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/services/work/jsr237/workmanager/DefaultWorkItem.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.work.jsr237.workmanager; - -import commonj.work.Work; -import commonj.work.WorkException; -import commonj.work.WorkItem; - -/** - * An identity based immutable implementation of the WorkItem - * interface. - * - */ -class DefaultWorkItem implements WorkItem { - - // Id scoped for the VM - private String id; - - // Status - private int status = -1; - - // Result - private Work result; - - // Original work - private Work originalWork; - - // Exception - private WorkException exception; - - /** - * Instantiates an id for this item. - * - * @param id of this work event. - */ - protected DefaultWorkItem(final String id, final Work orginalWork) { - this.id = id; - this.originalWork = orginalWork; - } - - /** - * Returns the id. - * - * @return Id of this item. - */ - public String getId() { - return id; - } - - /** - * Returns the original work. - * - * @return Original work. - */ - public Work getOriginalWork() { - return originalWork; - } - - /** - * Returns the work result if the work completed. - * - * @return Work. - * @throws WorkException If the work completed with an exception. - */ - public Work getResult() throws WorkException { - return result; - } - - /** - * Sets the result. - * - * @param result Result. - */ - protected void setResult(final Work result) { - this.result = result; - } - - /** - * Returns the exception if work completed with an exception. - * - * @return Work exception. - */ - protected WorkException getException() { - return exception; - } - - /** - * Sets the exception. - * - * @param exception Exception. - */ - protected void setException(final WorkException exception) { - this.exception = exception; - } - - /** - * Returns the work type based on whether the work was accepted, started, - * rejected or completed. - * - * @return Work status. - */ - public int getStatus() { - return status; - } - - /** - * Sets the status. - * - * @param status Status. - */ - protected void setStatus(final int status) { - this.status = status; - } - - /** - * @see Object#hashCode() - */ - public int hashCode() { - return id.hashCode(); - } - - /** - * Indicates whether some other object is "equal to" this one. - * - * @param obj Object to be compared. - * @return true if this object is the same as the obj argument; false - * otherwise.. - */ - public boolean equals(final Object obj) { - return (obj != null) && (obj.getClass() == DefaultWorkItem.class) && ((DefaultWorkItem) obj).id.equals(id); - } - - /** - * Compares this object with the specified object for order. Returns a - * negative integer, zero, or a positive integer as this object is less - * than, equal to, or greater than the specified object. - * - * @param o Object to be compared. - * @return A negative integer, zero, or a positive integer as this object - * is less than, equal to, or greater than the specified object. - * @throws ClassCastException needs better documentation. - */ - public int compareTo(final Object o) { - if (o.getClass() != DefaultWorkItem.class) { - throw new ClassCastException(o.getClass().getName()); - } else { - return ((DefaultWorkItem) o).getId().compareTo(getId()); - } - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/services/work/jsr237/workmanager/ThreadPoolWorkManager.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/services/work/jsr237/workmanager/ThreadPoolWorkManager.java deleted file mode 100644 index 1a7639b41d..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/services/work/jsr237/workmanager/ThreadPoolWorkManager.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.services.work.jsr237.workmanager; - -import java.rmi.server.UID; -import java.util.Collection; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.RejectedExecutionException; - -import org.osoa.sca.annotations.Destroy; -import org.osoa.sca.annotations.Property; - -import commonj.work.Work; -import commonj.work.WorkEvent; -import commonj.work.WorkException; -import commonj.work.WorkItem; -import commonj.work.WorkListener; -import commonj.work.WorkManager; -import commonj.work.WorkRejectedException; - -/** - * A thread-pool based implementation for the JSR-237 work manager. - *

      - *

      - * This implementation supports only local work. - *

      - * TODO Elaborate the implementation.

      - */ -public class ThreadPoolWorkManager implements WorkManager { - - // Map of work items currently handled by the work manager - private Map workItems = new ConcurrentHashMap(); - - // Thread-pool - private ExecutorService executor; - - /** - * Initializes the thread-pool. - * - * @param threadPoolSize Thread-pool size. - */ - public ThreadPoolWorkManager(@Property(name = "poolSize") int threadPoolSize) { - executor = Executors.newFixedThreadPool(threadPoolSize); - } - - /** - * Schedules a unit of work asynchronously. - * - * @param work Work that needs to be scheduled. - * @return Work Work item representing the asynchronous work - */ - public WorkItem schedule(Work work) throws WorkException { - return schedule(work, null); - } - - /** - * Schedules a unit of work asynchronously. - * - * @param work Work that needs to be scheduled. - * @param workListener Work listener for callbacks. - * @return Work Work item representing the asynchronous work - */ - public WorkItem schedule(Work work, WorkListener workListener) throws WorkRejectedException { - - DefaultWorkItem workItem = new DefaultWorkItem(new UID().toString(), work); - if (workListener != null) { - workItems.put(workItem, workListener); - } - workAccepted(workItem, work); - if (scheduleWork(work, workItem)) { - return workItem; - } else { - workItem.setStatus(WorkEvent.WORK_REJECTED); - if (workListener != null) { - workListener.workRejected(new DefaultWorkEvent(workItem)); - } - throw new WorkRejectedException("Unable to schedule work"); - } - } - - /** - * Wait for all the specified units of work to finish. - * - * @param works Units of the work that need to finish. - * @param timeout Timeout for waiting for the units of work to finish. - */ - public boolean waitForAll(Collection works, long timeout) { - throw new UnsupportedOperationException("waitForAll not supported"); - } - - /** - * Wait for any of the specified units of work to finish. - * - * @param works Units of the work that need to finish. - * @param timeout Timeout for waiting for the units of work to finish. - */ - public Collection waitForAny(Collection works, long timeout) { - throw new UnsupportedOperationException("waitForAny not supported"); - } - - /** - * Method provided for subclasses to indicate a work accptance. - * - * @param workItem Work item representing the work that was accepted. - * @param work Work that was accepted. - */ - private void workAccepted(final DefaultWorkItem workItem, final Work work) { - WorkListener listener = workItems.get(workItem); - if (listener != null) { - workItem.setStatus(WorkEvent.WORK_ACCEPTED); - WorkEvent event = new DefaultWorkEvent(workItem); - listener.workAccepted(event); - } - } - - /* - * Method to indicate a work start. - */ - private void workStarted(final DefaultWorkItem workItem, final Work work) { - WorkListener listener = workItems.get(workItem); - if (listener != null) { - workItem.setStatus(WorkEvent.WORK_STARTED); - WorkEvent event = new DefaultWorkEvent(workItem); - listener.workStarted(event); - } - } - - /* - * Method to indicate a work completion. - */ - private void workCompleted(final DefaultWorkItem workItem, final Work work) { - workCompleted(workItem, work, null); - } - - /* - * Method to indicate a work completion. - */ - private void workCompleted(final DefaultWorkItem workItem, final Work work, final WorkException exception) { - WorkListener listener = workItems.get(workItem); - if (listener != null) { - workItem.setStatus(WorkEvent.WORK_COMPLETED); - workItem.setResult(work); - workItem.setException(exception); - WorkEvent event = new DefaultWorkEvent(workItem); - listener.workCompleted(event); - workItems.remove(workItem); - } - } - - /* - * Schedules the work using the threadpool. - */ - private boolean scheduleWork(final Work work, final DefaultWorkItem workItem) { - try { - executor.execute(new DecoratingWork(workItem, work)); - return true; - } catch (RejectedExecutionException ex) { - return false; - } - } - - /* - * Class that decorates the original worker so that it can get callbacks when work is done. - */ - private final class DecoratingWork implements Runnable { - - // Work item for this work. - private DefaultWorkItem workItem; - - // The original work. - private Work decoratedWork; - - /* - * Initializes the work item and underlying work. - */ - private DecoratingWork(final DefaultWorkItem workItem, final Work decoratedWork) { - this.workItem = workItem; - this.decoratedWork = decoratedWork; - } - - /* - * Overrides the run method. - */ - public void run() { - workStarted(workItem, decoratedWork); - try { - decoratedWork.run(); - workCompleted(workItem, decoratedWork); - } catch (Throwable th) { - workCompleted(workItem, decoratedWork, new WorkException(th.getMessage(), th)); - } - } - - } - - @Destroy - public void destroy() { - executor.shutdown(); - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/util/ClassLoaderHelper.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/util/ClassLoaderHelper.java deleted file mode 100644 index a8c57db9d1..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/util/ClassLoaderHelper.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.util; - -import java.io.File; -import java.net.URL; -import java.net.MalformedURLException; -import java.net.URLClassLoader; - -/** - * Functions to create & manipulate classloaders. - * - * @version $$Rev$$ $$Date$$ - */ - -public final class ClassLoaderHelper { - /** - * Hide constructor - */ - private ClassLoaderHelper() { - } - - /** - * Create a classloader for the supplied classpath. - * - * @param path a list of file/directory names separated by the platform path separator - * @param parent the parent for the new classloader - * @return a classloader that will load classes from the supplied path - */ - public static ClassLoader createClassLoader(ClassLoader parent, String path) { - String[] files = path.split(File.pathSeparator); - return createClassLoader(parent, files); - } - - /** - * Create a classloader for a classpath supplied as individual file names. - * - * @param files a list of file/directory names - * @param parent the parent for the new classloader - * @return a classloader that will load classes from the supplied path - */ - public static ClassLoader createClassLoader(ClassLoader parent, String[] files) { - URL[] urls = new URL[files.length]; - for (int i = 0; i < files.length; i++) { - try { - File file = new File(files[i]); - urls[i] = file.toURI().toURL(); - } catch (MalformedURLException e) { - // just ignore this value - continue; - } - } - - return new URLClassLoader(urls, parent); - } - - /** - * Create a classloader for a classpath supplied as a list of files. - * - * @param files a list of files - * @param parent the parent for the new classloader - * @return a classloader that will load classes from the supplied path - */ - public static ClassLoader createClassLoader(ClassLoader parent, File[] files) { - URL[] urls = new URL[files.length]; - for (int i = 0; i < files.length; i++) { - try { - File file = files[i]; - urls[i] = file.toURI().toURL(); - } catch (MalformedURLException e) { - - continue; - } - } - return new URLClassLoader(urls, parent); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/util/JavaIntrospectionHelper.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/util/JavaIntrospectionHelper.java deleted file mode 100644 index 6b11725481..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/BridgingInterceptor.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/BridgingInterceptor.java deleted file mode 100644 index c1766fbb6f..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/BridgingInterceptor.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.wire; - -import org.apache.tuscany.spi.wire.Interceptor; - -/** - * Responsible for bridging an outbound to an inbound invocation chain associated with a source and target respectively - * - * @version $Rev$ $Date$ - */ -public interface BridgingInterceptor extends Interceptor { -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/CallbackInterfaceInterceptor.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/CallbackInterfaceInterceptor.java deleted file mode 100644 index 06f0e62f70..0000000000 --- a/branches/pre-spec-changes/kernel/core/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 outbound side 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/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/InboundInvocationChainImpl.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/InboundInvocationChainImpl.java deleted file mode 100644 index 45b580d419..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/InboundInvocationChainImpl.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.wire; - -import org.apache.tuscany.spi.model.Operation; -import org.apache.tuscany.spi.wire.InboundInvocationChain; - -/** - * Contains a target-side invocation chain - * - * @version $Rev$ $Date$ - */ -public class InboundInvocationChainImpl extends InvocationChainImpl implements InboundInvocationChain { - - /** - * Creates an new target-side chain for the given operation - */ - public InboundInvocationChainImpl(Operation operation) { - super(operation); - } - - public void prepare() { - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/InboundWireImpl.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/InboundWireImpl.java deleted file mode 100644 index b529cafbb6..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/InboundWireImpl.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.wire; - -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.SCAObject; -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.wire.InboundInvocationChain; -import org.apache.tuscany.spi.wire.InboundWire; -import org.apache.tuscany.spi.wire.OutboundInvocationChain; -import org.apache.tuscany.spi.wire.OutboundWire; - -/** - * Default implementation of an inbound wire - * - * @version $Rev$ $Date$ - */ -public class InboundWireImpl implements InboundWire { - private QName bindingType = LOCAL_BINDING; - private String serviceName; - private ServiceContract serviceContract; - private OutboundWire targetWire; - private String callbackReferenceName; - private Map, InboundInvocationChain> chains = new HashMap, InboundInvocationChain>(); - private Map, OutboundInvocationChain>> callbackSourceChainMaps = - new HashMap, OutboundInvocationChain>>(); - private SCAObject container; - private AtomicComponent targetComponent; - private boolean optimizable; - - - /** - * Creates a local inbound wire - */ - public InboundWireImpl() { - } - - - /** - * Creates an inbound wire for the given binding type - * - * @param bindingType the binding type - */ - public InboundWireImpl(QName bindingType) { - this.bindingType = bindingType; - } - - public QName getBindingType() { - return bindingType; - } - - public Object getTargetService() throws TargetResolutionException { - // JFM fixme hack - if (targetWire == null && targetComponent != null) { - return targetComponent.getTargetInstance(); - } - assert targetWire != null; - // optimized, no interceptors or handlers on either end - return targetWire.getTargetService(); - } - - public ServiceContract getServiceContract() { - return serviceContract; - } - - public void setServiceContract(ServiceContract serviceContract) { - this.serviceContract = serviceContract; - } - - public void addInterface(Class claz) { - throw new UnsupportedOperationException("Additional proxy interfaces not yet supported"); - } - - public String getServiceName() { - return serviceName; - } - - public void setServiceName(String serviceName) { - this.serviceName = serviceName; - } - - public Map, InboundInvocationChain> getInvocationChains() { - return chains; - } - - public void addInvocationChains(Map, InboundInvocationChain> chains) { - this.chains.putAll(chains); - } - - public void addInvocationChain(Operation operation, InboundInvocationChain chain) { - chains.put(operation, chain); - } - - public Map, OutboundInvocationChain> getSourceCallbackInvocationChains(Object targetAddr) { - return callbackSourceChainMaps.get(targetAddr); - } - - public void addSourceCallbackInvocationChains(Object targetAddr, - Map, OutboundInvocationChain> chains) { - callbackSourceChainMaps.put(targetAddr, chains); - } - - public void addSourceCallbackInvocationChain(Object targetAddr, - Operation operation, - OutboundInvocationChain chain) { - Map, OutboundInvocationChain> chains = callbackSourceChainMaps.get(targetAddr); - if (chains == null) { - chains = new HashMap, OutboundInvocationChain>(); - callbackSourceChainMaps.put(targetAddr, chains); - } - chains.put(operation, chain); - } - - public void setTargetWire(OutboundWire wire) { - targetWire = wire; - } - - public String getCallbackReferenceName() { - return callbackReferenceName; - } - - public void setCallbackReferenceName(String callbackReferenceName) { - this.callbackReferenceName = callbackReferenceName; - } - - public boolean isOptimizable() { - return optimizable; - } - - public void setOptimizable(boolean optimizable) { - this.optimizable = optimizable; - } - - public SCAObject getContainer() { - return container; - } - - public void setContainer(SCAObject container) { - if (container instanceof AtomicComponent) { - targetComponent = (AtomicComponent) container; - } - this.container = container; - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/IncompatibleServiceContractExceptionFormatter.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/IncompatibleServiceContractExceptionFormatter.java deleted file mode 100644 index 92da622d11..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/IncompatibleServiceContractExceptionFormatter.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.wire; - -import java.io.PrintWriter; - -import org.osoa.sca.annotations.Destroy; -import org.osoa.sca.annotations.EagerInit; - -import org.apache.tuscany.spi.annotation.Autowire; -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(@Autowire 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"); - - } - e.appendContextStack(writer); - return writer; - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/InvocationChainImpl.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/InvocationChainImpl.java deleted file mode 100644 index d93426af4c..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/InvocationChainImpl.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.wire; - -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.TargetInvoker; - -/** - * Contains functionality common to source- and target- side invocation chains - * - * @version $Rev$ $Date$ - */ -public abstract class InvocationChainImpl implements InvocationChain { - protected Operation operation; - protected TargetInvoker targetInvoker; - protected Interceptor interceptorChainHead; - protected Interceptor interceptorChainTail; - - - // the pointer to a bridged target head interceptor or null if the target has no interceptors - protected Interceptor targetInterceptorChainHead; - - public InvocationChainImpl(Operation operation) { - assert operation != null : "No operation type specified"; - this.operation = operation; - } - - public Operation getOperation() { - return operation; - } - - 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; - } - - public void setTargetInterceptor(Interceptor interceptor) { - targetInterceptorChainHead = interceptor; - } - - public Interceptor getTargetInterceptor() { - return targetInterceptorChainHead; - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/InvokerInterceptor.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/InvokerInterceptor.java deleted file mode 100644 index 90b17a930c..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/InvokerInterceptor.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.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$ - * @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/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/LoopBackWire.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/LoopBackWire.java deleted file mode 100644 index a2cd71cafe..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/LoopBackWire.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.wire; - -import org.apache.tuscany.spi.component.TargetResolutionException; - -/** - * A specialized wire that points back to its target container. Used to autowire to parent composites - * - * @version $Rev$ $Date$ - */ -public class LoopBackWire extends InboundWireImpl { - - public Object getTargetService() throws TargetResolutionException { - return getContainer(); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/NoMethodForOperationException.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/NoMethodForOperationException.java deleted file mode 100644 index aec281d190..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/NonBlockingBridgingInterceptor.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/NonBlockingBridgingInterceptor.java deleted file mode 100644 index 225cab79bc..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/NonBlockingBridgingInterceptor.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.wire; - -import java.util.LinkedList; - -import org.osoa.sca.CompositeContext; -import org.osoa.sca.CurrentCompositeContext; -import org.osoa.sca.ServiceRuntimeException; - -import org.apache.tuscany.spi.component.WorkContext; -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.model.Scope; - -/** - * Bridges interceptors in a non-blocking fashion between an {@link org.apache.tuscany.spi.wire.InboundInvocationChain} - * and an {@link org.apache.tuscany.spi.wire.OutboundInvocationChain} by using a {@link - * org.apache.tuscany.spi.component.WorkContext}. - * - * @version $$Rev$$ $$Date$$ - */ -public class NonBlockingBridgingInterceptor implements BridgingInterceptor { - - private static final Message RESPONSE = new ImmutableMessage(); - - private WorkScheduler workScheduler; - private WorkContext workContext; - private Interceptor next; - - public NonBlockingBridgingInterceptor(WorkScheduler workScheduler, WorkContext workContext) { - this.workScheduler = workScheduler; - this.workContext = workContext; - } - - public NonBlockingBridgingInterceptor(WorkScheduler workScheduler, WorkContext workContext, Interceptor next) { - this.workScheduler = workScheduler; - this.workContext = workContext; - this.next = next; - } - - public Message invoke(final Message msg) { - final CompositeContext currentContext = CurrentCompositeContext.getContext(); - // 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.setCurrentCorrelationId(null); - // if we got a conversation id, transfer it to new thread - if (conversationID != null) { - workContext.setIdentifier(Scope.CONVERSATION, conversationID); - } - CompositeContext oldContext = CurrentCompositeContext.setContext(currentContext); - try { - next.invoke(msg); - } catch (Exception e) { - // REVIEW uncomment when it is available - // monitor.executionError(e); - e.printStackTrace(); - } finally { - CurrentCompositeContext.setContext(oldContext); - } - } - }); - } 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 void setTargetInvoker(TargetInvoker invoker) { - throw new UnsupportedOperationException(); - } - - public TargetInvoker getTargetInvoker() { - return null; - } - - public Message getRelatedCallbackMessage() { - return null; - } - - public Object getFromAddress() { - return null; - } - - public void setFromAddress(Object fromAddress) { - throw new UnsupportedOperationException(); - } - - public Object popFromAddress() { - return null; - } - - public void pushFromAddress(Object fromAddress) { - throw new UnsupportedOperationException(); - } - - public LinkedList getCallbackRoutingChain() { - return null; - } - - public void setCallbackRoutingChain(LinkedList fromAddresses) { - throw new UnsupportedOperationException(); - } - - 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/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/OptimizedWireObjectFactory.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/OptimizedWireObjectFactory.java deleted file mode 100644 index 4a4b268201..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/OptimizedWireObjectFactory.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.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.OutboundWire; - -/** - * Returns a target instance directly from a wire - * - * @version $Rev$ $Date$ - */ -public class OptimizedWireObjectFactory implements ObjectFactory { - - private OutboundWire wire; - - public OptimizedWireObjectFactory(OutboundWire factory) { - this.wire = factory; - } - - public Object getInstance() throws ObjectCreationException { - try { - return wire.getTargetService(); - } catch (TargetResolutionException e) { - throw new ObjectCreationException(e); - } - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/OutboundInvocationChainImpl.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/OutboundInvocationChainImpl.java deleted file mode 100644 index a9d83cb7a0..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/OutboundInvocationChainImpl.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.wire; - -import org.apache.tuscany.spi.model.Operation; -import org.apache.tuscany.spi.wire.OutboundInvocationChain; - -/** - * Contains a outgoing invocation pipeline for a service operation. - * - * @version $Rev$ $Date$ - */ -public class OutboundInvocationChainImpl extends InvocationChainImpl implements OutboundInvocationChain { - - /** - * Creates an new outbound chain - */ - public OutboundInvocationChainImpl(Operation operation) { - super(operation); - } - - public void prepare() { - if (interceptorChainHead != null) { - if (targetInterceptorChainHead != null) { - // Connect source interceptor chain directly to target interceptor chain - interceptorChainTail.setNext(targetInterceptorChainHead); - } - } else { - // no source interceptor chain or source handlers, connect to target interceptor chain or channel - if (targetInterceptorChainHead != null) { - interceptorChainHead = targetInterceptorChainHead; - interceptorChainTail = targetInterceptorChainHead; - } - } - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/OutboundWireImpl.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/OutboundWireImpl.java deleted file mode 100644 index bad92ffe1e..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/OutboundWireImpl.java +++ /dev/null @@ -1,176 +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.util.HashMap; -import java.util.Map; -import javax.xml.namespace.QName; - -import org.apache.tuscany.spi.QualifiedName; -import org.apache.tuscany.spi.component.SCAObject; -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.wire.InboundInvocationChain; -import org.apache.tuscany.spi.wire.InboundWire; -import org.apache.tuscany.spi.wire.OutboundInvocationChain; -import org.apache.tuscany.spi.wire.OutboundWire; - -/** - * Default implementation of an outbound wire - * - * @version $Rev$ $Date$ - */ -public class OutboundWireImpl implements OutboundWire { - private QName bindingType = LOCAL_BINDING; - private ServiceContract serviceContract; - private Class[] callbackInterfaces; - private Map, OutboundInvocationChain> chains = new HashMap, OutboundInvocationChain>(); - private Map, InboundInvocationChain> callbackTargetChains = - new HashMap, InboundInvocationChain>(); - private String referenceName; - private QualifiedName targetName; - private InboundWire targetWire; - private SCAObject container; - private boolean autowire; - private boolean optimizable; - - /** - * Creates a local outbound wire - */ - public OutboundWireImpl() { - } - - /** - * Creates an outbound wire for the given binding type - * - * @param bindingType the binding type - */ - public OutboundWireImpl(QName bindingType) { - this.bindingType = bindingType; - } - - public void setOptimizable(boolean optimizable) { - this.optimizable = optimizable; - } - - public QName getBindingType() { - return bindingType; - } - - public Object getTargetService() throws TargetResolutionException { - if (targetWire == null) { - return null; - } - // optimized, no interceptors or handlers on either end - return targetWire.getTargetService(); - } - - public ServiceContract getServiceContract() { - return serviceContract; - } - - public void setServiceContract(ServiceContract serviceContract) { - this.serviceContract = serviceContract; - } - - public void addInterface(Class claz) { - throw new UnsupportedOperationException("Additional proxy interfaces not yet supported"); - } - - public void setCallbackInterface(Class interfaze) { - callbackInterfaces = new Class[]{interfaze}; - } - - public Class getCallbackInterface() { - return callbackInterfaces[0]; - } - - public void addCallbackInterface(Class claz) { - throw new UnsupportedOperationException("Additional callback interfaces not yet supported"); - } - - public Class[] getImplementedCallbackInterfaces() { - return callbackInterfaces; - } - - public void setTargetWire(InboundWire wire) { - this.targetWire = wire; - } - - public Map, OutboundInvocationChain> getInvocationChains() { - return chains; - } - - public void addInvocationChains(Map, OutboundInvocationChain> chains) { - this.chains.putAll(chains); - } - - public void addInvocationChain(Operation operation, OutboundInvocationChain chain) { - chains.put(operation, chain); - } - - public Map, InboundInvocationChain> getTargetCallbackInvocationChains() { - return callbackTargetChains; - } - - public void addTargetCallbackInvocationChains(Map, InboundInvocationChain> chains) { - callbackTargetChains.putAll(chains); - } - - public void addTargetCallbackInvocationChain(Operation operation, InboundInvocationChain chain) { - callbackTargetChains.put(operation, chain); - } - - public String getReferenceName() { - return referenceName; - } - - public void setReferenceName(String referenceName) { - this.referenceName = referenceName; - } - - public QualifiedName getTargetName() { - return targetName; - } - - public void setTargetName(QualifiedName targetName) { - this.targetName = targetName; - } - - public boolean isAutowire() { - return autowire; - } - - public void setAutowire(boolean autowire) { - this.autowire = autowire; - } - - public boolean isOptimizable() { - return optimizable; - } - - public SCAObject getContainer() { - return container; - } - - public void setContainer(SCAObject container) { - this.container = container; - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/SynchronousBridgingInterceptor.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/SynchronousBridgingInterceptor.java deleted file mode 100644 index f09bda400a..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/SynchronousBridgingInterceptor.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 org.apache.tuscany.spi.wire.Interceptor; -import org.apache.tuscany.spi.wire.Message; - -/** - * Synchronously bridges interceptors between an {@link org.apache.tuscany.spi.wire.InboundInvocationChain} and an - * {@link org.apache.tuscany.spi.wire.OutboundInvocationChain}. - * - * @version $$Rev$$ $$Date$$ - */ -public class SynchronousBridgingInterceptor implements BridgingInterceptor { - private Interceptor next; - - public SynchronousBridgingInterceptor() { - } - - public SynchronousBridgingInterceptor(Interceptor next) { - this.next = next; - } - - public Message invoke(Message msg) { - return next.invoke(msg); - } - - public Interceptor getNext() { - return next; - } - - public void setNext(Interceptor next) { - this.next = next; - } - - public boolean isOptimizable() { - return true; - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/WireObjectFactory.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/WireObjectFactory.java deleted file mode 100644 index c04869e8f5..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/WireObjectFactory.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.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.OutboundChainHolder; -import org.apache.tuscany.spi.wire.OutboundWire; -import org.apache.tuscany.spi.wire.WireService; - -/** - * Uses a wire to return an object instance - * - * @version $Rev$ $Date$ - */ -public class WireObjectFactory implements ObjectFactory { - private Class interfaze; - private OutboundWire wire; - private WireService wireService; - // 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 wireService the wire service to create the proxy - * @throws NoMethodForOperationException - */ - public WireObjectFactory(Class interfaze, OutboundWire wire, WireService wireService) - throws NoMethodForOperationException { - this.interfaze = interfaze; - this.wire = wire; - this.wireService = wireService; - this.mappings = WireUtils.createInterfaceToWireMapping(interfaze, wire); - } - - public T getInstance() throws ObjectCreationException { - // note optimization must be done lazily as wire object factories are created during the build phase prior - // to the outbound and inbound wires being connected - if ((optimizable - || wire.isOptimizable()) - && wire.getServiceContract().getInterfaceClass() != null - && interfaze.isAssignableFrom(wire.getServiceContract().getInterfaceClass())) { - optimizable = true; - try { - return interfaze.cast(wire.getTargetService()); - } catch (TargetResolutionException e) { - throw new ObjectCreationException(e); - } - } - // 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(wireService.createProxy(interfaze, wire, newChains)); - } - - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/WireServiceExtension.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/WireServiceExtension.java deleted file mode 100644 index 460a6a40a8..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/WireServiceExtension.java +++ /dev/null @@ -1,287 +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.util.Map; - -import org.apache.tuscany.spi.QualifiedName; -import org.apache.tuscany.spi.component.AtomicComponent; -import org.apache.tuscany.spi.component.ReferenceBinding; -import org.apache.tuscany.spi.component.ServiceBinding; -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.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.ServiceContract; -import org.apache.tuscany.spi.model.ServiceDefinition; -import org.apache.tuscany.spi.policy.PolicyBuilderRegistry; -import org.apache.tuscany.spi.wire.InboundInvocationChain; -import org.apache.tuscany.spi.wire.InboundWire; -import org.apache.tuscany.spi.wire.IncompatibleServiceContractException; -import org.apache.tuscany.spi.wire.OutboundInvocationChain; -import org.apache.tuscany.spi.wire.OutboundWire; -import org.apache.tuscany.spi.wire.WireService; - -import org.apache.tuscany.core.binding.local.LocalReferenceBinding; - -/** - * Base class for wire service extensions - * - * @version $Rev$ $Date$ - */ -public abstract class WireServiceExtension implements WireService { - protected PolicyBuilderRegistry policyRegistry; - protected WorkContext context; - - protected WireServiceExtension(WorkContext context, PolicyBuilderRegistry policyRegistry) { - this.policyRegistry = policyRegistry; - this.context = context; - } - - public OutboundInvocationChain createOutboundChain(Operation operation) { - return new OutboundInvocationChainImpl(operation); - } - - public InboundInvocationChain createInboundChain(Operation operation) { - return new InboundInvocationChainImpl(operation); - } - - public InboundWire createWire(ServiceDefinition service) { - InboundWire wire = new InboundWireImpl(); - ServiceContract contract = service.getServiceContract(); - wire.setServiceContract(contract); - wire.setServiceName(service.getName()); - for (Operation operation : contract.getOperations().values()) { - InboundInvocationChain chain = createInboundChain(operation); - // TODO handle policy - chain.addInterceptor(new InvokerInterceptor()); - wire.addInvocationChain(operation, chain); - } - if (contract.getCallbackName() != null) { - wire.setCallbackReferenceName(service.getCallbackReferenceName()); - } - return wire; - } - - public void createWires(AtomicComponent component, ComponentDefinition definition) { - Implementation implementation = definition.getImplementation(); - ComponentType componentType = implementation.getComponentType(); - // create incoming service wires - for (ServiceDefinition service : componentType.getServices().values()) { - InboundWire wire = createWire(service); - wire.setContainer(component); - component.addInboundWire(wire); - } - // create outgoing reference wires - for (ReferenceTarget referenceTarget : definition.getReferenceTargets().values()) { - Map references = componentType.getReferences(); - ReferenceDefinition mappedReference = references.get(referenceTarget.getReferenceName()); - assert mappedReference != null; - OutboundWire wire = createWire(referenceTarget, mappedReference); - wire.setContainer(component); - component.addOutboundWire(wire); - } - } - - public void createWires(ReferenceBinding referenceBinding, ServiceContract contract, QualifiedName targetName) { - InboundWire inboundWire = new InboundWireImpl(referenceBinding.getBindingType()); - inboundWire.setServiceContract(contract); - inboundWire.setContainer(referenceBinding); - for (Operation operation : contract.getOperations().values()) { - InboundInvocationChain chain = createInboundChain(operation); - inboundWire.addInvocationChain(operation, chain); - } - OutboundWire outboundWire = new OutboundWireImpl(referenceBinding.getBindingType()); - outboundWire.setTargetName(targetName); - - // [rfeng] Check if the Reference has the binding contract - ServiceContract bindingContract = referenceBinding.getBindingServiceContract(); - if (bindingContract == null) { - bindingContract = contract; - } - outboundWire.setServiceContract(bindingContract); - outboundWire.setContainer(referenceBinding); - for (Operation operation : bindingContract.getOperations().values()) { - OutboundInvocationChain chain = createOutboundChain(operation); - if (referenceBinding instanceof LocalReferenceBinding) { - // Not ideal but the local binding case is special as its inbound and outbound wires are connected - // before the outbound wire is connected to the reference target. This requires the binding outbound - // chain to have an interceptor to connect to from the binding inbound chain. This outbound - // interceptor will then be bridged to the head target interceptor - chain.addInterceptor(new SynchronousBridgingInterceptor()); - } else { - chain.addInterceptor(new InvokerInterceptor()); - } - outboundWire.addInvocationChain(operation, chain); - } - // Add target callback chain to outbound wire - if (contract.getCallbackName() != null) { - outboundWire.setCallbackInterface(contract.getCallbackClass()); - for (Operation operation : contract.getCallbackOperations().values()) { - InboundInvocationChain callbackTargetChain = createInboundChain(operation); - // TODO handle policy - callbackTargetChain.addInterceptor(new InvokerInterceptor()); - outboundWire.addTargetCallbackInvocationChain(operation, callbackTargetChain); - } - } - referenceBinding.setInboundWire(inboundWire); - referenceBinding.setOutboundWire(outboundWire); - } - - public void createWires(ServiceBinding serviceBinding, ServiceContract contract, String targetName) { - InboundWire inboundWire = new InboundWireImpl(serviceBinding.getBindingType()); - // [rfeng] Check if the Reference has the serviceBinding contract - ServiceContract bindingContract = serviceBinding.getBindingServiceContract(); - if (bindingContract == null) { - bindingContract = contract; - } - inboundWire.setServiceContract(bindingContract); - inboundWire.setContainer(serviceBinding); - for (Operation operation : bindingContract.getOperations().values()) { - InboundInvocationChain inboundChain = createInboundChain(operation); - inboundChain.addInterceptor(new SynchronousBridgingInterceptor()); - inboundWire.addInvocationChain(operation, inboundChain); - } - - OutboundWire outboundWire = new OutboundWireImpl(serviceBinding.getBindingType()); - outboundWire.setServiceContract(contract); - outboundWire.setTargetName(new QualifiedName(targetName)); - outboundWire.setContainer(serviceBinding); - - for (Operation operation : contract.getOperations().values()) { - OutboundInvocationChain outboundChain = createOutboundChain(operation); - outboundWire.addInvocationChain(operation, outboundChain); - } - - // Add target callback chain to outbound wire - if (contract.getCallbackName() != null) { - outboundWire.setCallbackInterface(contract.getCallbackClass()); - for (Operation operation : contract.getCallbackOperations().values()) { - InboundInvocationChain callbackTargetChain = createInboundChain(operation); - // TODO handle policy - callbackTargetChain.addInterceptor(new InvokerInterceptor()); - outboundWire.addTargetCallbackInvocationChain(operation, callbackTargetChain); - } - } - serviceBinding.setInboundWire(inboundWire); - serviceBinding.setOutboundWire(outboundWire); - } - - /** - * Compares two operations for wiring compatibility as defined by the SCA assembly specification, namely:

        - *
      1. compatibility for the individual method is defined as compatibility of the signature, that is method name, - * input types, and output types MUST BE the same.
      2. the order of the input and output types also MUST BE the - * same.
      3. the set of Faults and Exceptions expected by the source MUST BE the same or be a superset of those - * specified by the service.
      - * - * @param source the source contract to compare - * @param target the target contract to compare - * @throws org.apache.tuscany.spi.wire.IncompatibleServiceContractException - * if the two contracts don't match - */ - public void checkCompatibility(ServiceContract source, ServiceContract target, boolean ignoreCallback) - throws IncompatibleServiceContractException { - if (source == target) { - // Shortcut for performance - return; - } - if (source.isRemotable() != target.isRemotable()) { - throw new IncompatibleServiceContractException("Remotable settings do not match", source, target); - } - if (source.getInteractionScope() != target.getInteractionScope()) { - throw new IncompatibleServiceContractException("Interaction scopes settings do not match", source, target); - } - - for (Operation operation : source.getOperations().values()) { - Operation targetOperation = target.getOperations().get(operation.getName()); - if (targetOperation == null) { - throw new IncompatibleServiceContractException("Operation not found on target", source, target); - } - if (!operation.equals(targetOperation)) { - throw new IncompatibleServiceContractException("Target operations are not compatible", source, target); - } - } - - if (ignoreCallback) { - return; - } - - for (Operation operation : source.getCallbackOperations().values()) { - Operation targetOperation = target.getCallbackOperations().get(operation.getName()); - if (targetOperation == null) { - throw new IncompatibleServiceContractException("Callback operation not found on target", - source, - target, - null, - targetOperation); - } - if (!operation.equals(targetOperation)) { - throw new IncompatibleServiceContractException("Target callback operation is not compatible", - source, - target, - operation, - targetOperation); - } - } - } - - /** - * Creates a wire for flowing outbound invocations from a reference - * - * @param target the reference definition - * @param definition the reference target configuration - * @return the wire the outbound wire - */ - protected OutboundWire createWire(ReferenceTarget target, ReferenceDefinition definition) { - if (!definition.isAutowire() && target.getTargets().size() != 1) { - //TODO multiplicity - throw new UnsupportedOperationException(); - } - ServiceContract contract = definition.getServiceContract(); - OutboundWire wire = new OutboundWireImpl(); - if (!definition.isAutowire()) { - QualifiedName qName = new QualifiedName(target.getTargets().get(0).toString()); - wire.setTargetName(qName); - } else { - wire.setAutowire(true); - } - wire.setServiceContract(contract); - wire.setReferenceName(target.getReferenceName()); - for (Operation operation : contract.getOperations().values()) { - //TODO handle policy - OutboundInvocationChain chain = createOutboundChain(operation); - wire.addInvocationChain(operation, chain); - - } - if (contract.getCallbackName() != null) { - wire.setCallbackInterface(contract.getCallbackClass()); - for (Operation operation : contract.getCallbackOperations().values()) { - InboundInvocationChain callbackTargetChain = createInboundChain(operation); - // TODO handle policy - callbackTargetChain.addInterceptor(new InvokerInterceptor()); - wire.addTargetCallbackInvocationChain(operation, callbackTargetChain); - } - } - return wire; - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/WireUtils.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/WireUtils.java deleted file mode 100644 index 73aa34e6bb..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/WireUtils.java +++ /dev/null @@ -1,146 +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.component.Component; -import org.apache.tuscany.spi.component.SCAObject; -import static org.apache.tuscany.spi.idl.java.JavaIDLUtils.findMethod; -import org.apache.tuscany.spi.model.Operation; -import org.apache.tuscany.spi.wire.InboundInvocationChain; -import org.apache.tuscany.spi.wire.InboundWire; -import org.apache.tuscany.spi.wire.Interceptor; -import org.apache.tuscany.spi.wire.OutboundChainHolder; -import org.apache.tuscany.spi.wire.OutboundInvocationChain; -import org.apache.tuscany.spi.wire.OutboundWire; - -/** - * Utilities for operating on wires - * - * @version $Rev$ $Date$ - */ -public final class WireUtils { - - private WireUtils() { - } - - /** - * Maps invocation chains on a wire to corresponding methods - * - * @param wire the wire containing the invocation chains to map - * @param methods the methods to map to - * @return a collection containing the method to invocation chain mapping - * @throws NoMethodForOperationException - */ - public static Map createInboundMapping(InboundWire wire, Method[] methods) - throws NoMethodForOperationException { - Map chains = new HashMap(); - for (Map.Entry, InboundInvocationChain> entry : wire.getInvocationChains().entrySet()) { - Operation operation = entry.getKey(); - InboundInvocationChain chain = entry.getValue(); - Method method = findMethod(operation, methods); - if (method == null) { - throw new NoMethodForOperationException(operation.getName()); - } - chains.put(method, chain); - } - return chains; - } - - - /** - * 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 - */ - public static Map createInterfaceToWireMapping(Class interfaze, OutboundWire wire) - throws NoMethodForOperationException { - Map, OutboundInvocationChain> invocationChains = wire.getInvocationChains(); - Map chains = new HashMap(invocationChains.size()); - Method[] methods = interfaze.getMethods(); - for (Map.Entry, OutboundInvocationChain> entry : invocationChains.entrySet()) { - Operation operation = entry.getKey(); - Method method = findMethod(operation, methods); - if (method == null) { - throw new NoMethodForOperationException(operation.getName()); - } - chains.put(method, new OutboundChainHolder(entry.getValue())); - } - 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(OutboundWire wire) { - for (OutboundInvocationChain 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.getTargetCallbackInvocationChains().isEmpty(); - } - - /** - * 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(InboundWire wire) { - SCAObject container = wire.getContainer(); - if (!(container instanceof Component) || !((Component) container).isOptimizable()) { - return false; - } - for (InboundInvocationChain chain : wire.getInvocationChains().values()) { - if (chain.getHeadInterceptor() != null) { - Interceptor current = chain.getHeadInterceptor(); - while (current != null) { - if (!current.isOptimizable()) { - return false; - } - current = current.getNext(); - } - } - } - return true; - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKCallbackInvocationHandler.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKCallbackInvocationHandler.java deleted file mode 100644 index 741ef21794..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKCallbackInvocationHandler.java +++ /dev/null @@ -1,137 +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.jdk; - -import java.io.Externalizable; -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import java.lang.reflect.InvocationHandler; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.LinkedList; -import java.util.Map; - -import org.osoa.sca.NoRegisteredCallbackException; - -import org.apache.tuscany.spi.component.AtomicComponent; -import org.apache.tuscany.spi.component.ReactivationException; -import org.apache.tuscany.spi.component.SCAExternalizable; -import org.apache.tuscany.spi.component.WorkContext; -import static org.apache.tuscany.spi.idl.java.JavaIDLUtils.findOperation; -import org.apache.tuscany.spi.model.Operation; -import org.apache.tuscany.spi.wire.AbstractOutboundInvocationHandler; -import org.apache.tuscany.spi.wire.InboundWire; -import org.apache.tuscany.spi.wire.OutboundInvocationChain; -import org.apache.tuscany.spi.wire.TargetInvoker; -import org.apache.tuscany.spi.wire.WireInvocationHandler; - - -/** - * Responsible for invoking on an outbound wire associated with a callback. The handler retrieves the correct outbound - * callback wire from the work context. - *

      - * TODO cache target invoker - * - * @version $Rev$ $Date$ - */ -public class JDKCallbackInvocationHandler extends AbstractOutboundInvocationHandler - implements WireInvocationHandler, InvocationHandler, Externalizable, SCAExternalizable { - private transient WorkContext context; - private transient InboundWire wire; - private String serviceName; - - /** - * Constructor used for deserialization only - */ - public JDKCallbackInvocationHandler() { - } - - public JDKCallbackInvocationHandler(InboundWire wire, WorkContext context) { - this.context = context; - this.wire = wire; - this.serviceName = wire.getServiceName(); - } - - @SuppressWarnings({"unchecked"}) - public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { - if (method.getParameterTypes().length == 0 && "toString".equals(method.getName())) { - return "[Proxy - " + Integer.toHexString(hashCode()) + "]"; - } else if (method.getDeclaringClass().equals(Object.class) - && "equals".equals(method.getName())) { - // TODO implement - throw new UnsupportedOperationException(); - } else if (Object.class.equals(method.getDeclaringClass()) - && "hashCode".equals(method.getName())) { - return hashCode(); - // TODO beter hash algorithm - } - Object correlationId = context.getCurrentCorrelationId(); - context.setCurrentCorrelationId(null); - LinkedList callbackRoutingChain = (LinkedList) context.getCurrentCallbackRoutingChain().clone(); - if (callbackRoutingChain == null) { - throw new AssertionError("Missing stack of from addresses"); - } - Object targetAddress = callbackRoutingChain.removeFirst(); - if (targetAddress == null) { - throw new AssertionError("Popped a null from address from stack"); - } - //TODO optimize as this is slow in local invocations - Map, OutboundInvocationChain> sourceCallbackInvocationChains = - wire.getSourceCallbackInvocationChains(targetAddress); - Operation operation = findOperation(method, sourceCallbackInvocationChains.keySet()); - OutboundInvocationChain chain = sourceCallbackInvocationChains.get(operation); - TargetInvoker invoker = chain.getTargetInvoker(); - - try { - return invoke(chain, invoker, args, correlationId, callbackRoutingChain); - } catch (InvocationTargetException e) { - Throwable t = e.getCause(); - if (t instanceof NoRegisteredCallbackException) { - throw t; - } - throw e; - } - } - - - public Object invoke(Method method, Object[] args) throws Throwable { - return invoke(null, method, args); - } - - public void writeExternal(ObjectOutput out) throws IOException { - out.writeObject(serviceName); - } - - public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { - serviceName = (String) in.readObject(); - } - - public void setWorkContext(WorkContext context) { - this.context = context; - } - - public void reactivate() throws ReactivationException { - AtomicComponent owner = context.getCurrentAtomicComponent(); - if (owner == null) { - throw new ReactivationException("Current atomic component not set on work context"); - } - wire = owner.getInboundWire(serviceName); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKInboundInvocationHandler.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKInboundInvocationHandler.java deleted file mode 100644 index d0d82484e3..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKInboundInvocationHandler.java +++ /dev/null @@ -1,173 +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.jdk; - -import java.io.Externalizable; -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import java.lang.reflect.InvocationHandler; -import java.lang.reflect.Method; -import java.util.HashMap; -import java.util.Map; - -import org.apache.tuscany.spi.component.AtomicComponent; -import org.apache.tuscany.spi.component.ReactivationException; -import org.apache.tuscany.spi.component.SCAExternalizable; -import org.apache.tuscany.spi.component.TargetInvocationException; -import org.apache.tuscany.spi.component.WorkContext; -import org.apache.tuscany.spi.wire.AbstractInboundInvocationHandler; -import org.apache.tuscany.spi.wire.InboundInvocationChain; -import org.apache.tuscany.spi.wire.InboundWire; -import org.apache.tuscany.spi.wire.TargetInvoker; -import org.apache.tuscany.spi.wire.WireInvocationHandler; - -import org.apache.tuscany.core.wire.WireUtils; - - -/** - * Receives a request from a proxy and performs an invocation on an {@link org.apache.tuscany.spi.wire.InboundWire} via - * an {@link InboundInvocationChain} - * - * @version $Rev$ $Date$ - */ -public final class JDKInboundInvocationHandler extends AbstractInboundInvocationHandler - implements WireInvocationHandler, InvocationHandler, Externalizable, SCAExternalizable { - private static final long serialVersionUID = -307902641125881043L; - - /* - * an association of an operation to chain holder. The holder contains the invocation chain - * and a local clone of the master TargetInvoker. TargetInvokers will be cloned by the handler and placed in the - * holder if they are cacheable. This allows optimizations such as avoiding target resolution when a source refers - * to a target of greater scope since the target reference can be maintained by the invoker. When a target invoker - * is not cacheable, the master associated with the wire chains will be used. - */ - private transient Map chains; - private transient WorkContext context; - private String serviceName; - private Class interfaze; - - /** - * Constructor used for deserialization only - */ - public JDKInboundInvocationHandler() { - } - - public JDKInboundInvocationHandler(Class interfaze, InboundWire wire, WorkContext context) { - this.context = context; - this.serviceName = wire.getServiceName(); - this.interfaze = interfaze; - init(interfaze, wire); - } - - public void setWorkContext(WorkContext context) { - this.context = context; - } - - /** - * Dispatches a client request made on a proxy - */ - public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { - ChainHolder holder = chains.get(method); - if (holder == null) { - if (method.getParameterTypes().length == 0 && "toString".equals(method.getName())) { - return "[Proxy - " + Integer.toHexString(hashCode()) + "]"; - } else if (method.getDeclaringClass().equals(Object.class) - && "equals".equals(method.getName())) { - // TODO implement - throw new UnsupportedOperationException(); - } else if (Object.class.equals(method.getDeclaringClass()) - && "hashCode".equals(method.getName())) { - return hashCode(); - // TODO beter hash algorithm - } - throw new TargetInvocationException("Operation not configured", method.getName()); - } - InboundInvocationChain chain = holder.chain; - TargetInvoker invoker; - if (holder.cachedInvoker == null) { - assert chain != null; - if (chain.getTargetInvoker() == null) { - String name = chain.getOperation().getName(); - throw new TargetInvocationException("No target invoker configured for operation", name); - } - if (chain.getTargetInvoker().isCacheable()) { - // clone and store the invoker locally - holder.cachedInvoker = (TargetInvoker) chain.getTargetInvoker().clone(); - invoker = holder.cachedInvoker; - } else { - invoker = chain.getTargetInvoker(); - } - } else { - assert chain != null; - invoker = chain.getTargetInvoker(); - } - context.setCurrentCorrelationId(null); - return invoke(chain, invoker, args); - } - - - public Object invoke(Method method, Object[] args) throws Throwable { - return invoke(null, method, args); - } - - public void writeExternal(ObjectOutput out) throws IOException { - out.writeObject(serviceName); - out.writeObject(interfaze); - } - - public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { - serviceName = (String) in.readObject(); - interfaze = (Class) in.readObject(); - } - - public void reactivate() throws ReactivationException { - // TODO this method will be extremely slow - look to optimize - AtomicComponent owner = context.getCurrentAtomicComponent(); - if (owner == null) { - throw new ReactivationException("Current atomic component not set on work context"); - } - InboundWire wire = owner.getInboundWire(serviceName); - init(interfaze, wire); - } - - private void init(Class interfaze, InboundWire wire) { - this.chains = new HashMap(); - Method[] methods = interfaze.getMethods(); - Map invocationChains = WireUtils.createInboundMapping(wire, methods); - for (Map.Entry entry : invocationChains.entrySet()) { - this.chains.put(entry.getKey(), new ChainHolder(entry.getValue())); - } - } - - /** - * A holder used to associate an wire chain with a local copy of a target invoker that was previously cloned from - * the chain master - */ - private class ChainHolder { - InboundInvocationChain chain; - TargetInvoker cachedInvoker; - - public ChainHolder(InboundInvocationChain config) { - this.chain = config; - } - - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKOutboundInvocationHandler.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKOutboundInvocationHandler.java deleted file mode 100644 index 99cfb3c627..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKOutboundInvocationHandler.java +++ /dev/null @@ -1,249 +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.jdk; - -import java.io.Externalizable; -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import java.lang.reflect.InvocationHandler; -import java.lang.reflect.Method; -import java.util.List; -import java.util.Map; -import java.util.UUID; - -import org.osoa.sca.NoRegisteredCallbackException; - -import org.apache.tuscany.spi.component.AtomicComponent; -import org.apache.tuscany.spi.component.ReactivationException; -import org.apache.tuscany.spi.component.SCAExternalizable; -import org.apache.tuscany.spi.component.SCAObject; -import org.apache.tuscany.spi.component.TargetInvocationException; -import org.apache.tuscany.spi.component.WorkContext; -import static org.apache.tuscany.spi.model.InteractionScope.CONVERSATIONAL; -import org.apache.tuscany.spi.model.Scope; -import org.apache.tuscany.spi.model.ServiceContract; -import org.apache.tuscany.spi.wire.AbstractOutboundInvocationHandler; -import org.apache.tuscany.spi.wire.OutboundChainHolder; -import org.apache.tuscany.spi.wire.OutboundInvocationChain; -import org.apache.tuscany.spi.wire.OutboundWire; -import org.apache.tuscany.spi.wire.TargetInvoker; -import org.apache.tuscany.spi.wire.WireInvocationHandler; - -import org.apache.tuscany.core.implementation.PojoAtomicComponent; -import org.apache.tuscany.core.wire.NoMethodForOperationException; -import org.apache.tuscany.core.wire.WireUtils; - - -/** - * Receives a request from a proxy and performs an invocation on an {@link org.apache.tuscany.spi.wire.OutboundWire} via - * an {@link org.apache.tuscany.spi.wire.OutboundInvocationChain} - * - * @version $Rev$ $Date$ - */ -public final class JDKOutboundInvocationHandler extends AbstractOutboundInvocationHandler - implements WireInvocationHandler, InvocationHandler, Externalizable, SCAExternalizable { - private static final long serialVersionUID = -6155278451964527325L; - - /* - * an association of an operation to chain holder. The holder contains an invocation chain - * and a local clone of the master TargetInvoker. TargetInvokers will be cloned by the handler and placed in the - * holder if they are cacheable. This allows optimizations such as avoiding target resolution when a source refers - * to a target of greater scope since the target reference can be maintained by the invoker. When a target invoker - * is not cacheable, the master associated with the wire chains will be used. - */ - private transient Map chains; - private transient WorkContext workContext; - private transient Object fromAddress; - private transient boolean wireContainerIsAtomicComponent; - private transient boolean contractHasCallback; - private transient boolean callbackIsImplemented; - private transient String callbackClassName; - private transient boolean contractIsRemotable; - private transient boolean contractIsConversational; - private transient String convIdForRemotableTarget; - private transient String convIdFromThread; - private String referenceName; - private Class interfaze; - - /** - * Constructor used for deserialization only - */ - public JDKOutboundInvocationHandler() { - } - - public JDKOutboundInvocationHandler(Class interfaze, OutboundWire wire, WorkContext workContext) - throws NoMethodForOperationException { - this.workContext = workContext; - this.interfaze = interfaze; - init(interfaze, wire, null); - } - - public JDKOutboundInvocationHandler(Class interfaze, - OutboundWire wire, - Map mapping, - WorkContext workContext) - throws NoMethodForOperationException { - this.workContext = workContext; - this.interfaze = interfaze; - init(interfaze, wire, mapping); - } - - public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { - OutboundChainHolder holder = chains.get(method); - if (holder == null) { - if (method.getParameterTypes().length == 0 && "toString".equals(method.getName())) { - return "[Proxy - " + Integer.toHexString(hashCode()) + "]"; - } else if (method.getDeclaringClass().equals(Object.class) - && "equals".equals(method.getName())) { - // TODO implement - throw new UnsupportedOperationException(); - } else if (Object.class.equals(method.getDeclaringClass()) - && "hashCode".equals(method.getName())) { - return hashCode(); - // TODO beter hash algorithm - } - throw new TargetInvocationException("Operation not configured", method.getName()); - } - OutboundInvocationChain chain = holder.getChain(); - TargetInvoker invoker; - - if (holder.getCachedInvoker() == null) { - assert chain != null; - if (chain.getTargetInvoker() == null) { - String name = chain.getOperation().getName(); - throw new TargetInvocationException("No target invoker configured for operation", name); - } - if (chain.getTargetInvoker().isCacheable()) { - // clone and store the invoker locally - holder.setCachedInvoker((TargetInvoker) chain.getTargetInvoker().clone()); - invoker = holder.getCachedInvoker(); - } else { - invoker = chain.getTargetInvoker(); - } - } else { - assert chain != null; - invoker = chain.getTargetInvoker(); - } - - if (wireContainerIsAtomicComponent && contractHasCallback && !callbackIsImplemented) { - throw new NoRegisteredCallbackException("Instance is does not implement callback: " - + callbackClassName); - } - - if (contractIsConversational) { - assert workContext != null : "Work context cannot be null for conversational invocation"; - // Check for a conv id on thread and remember it - convIdFromThread = (String) workContext.getIdentifier(Scope.CONVERSATION); - if (contractIsRemotable) { - if (convIdForRemotableTarget == null) { - convIdForRemotableTarget = createConversationID(); - } - // Always use the conv id for this target - workContext.setIdentifier(Scope.CONVERSATION, convIdForRemotableTarget); - } else if (convIdFromThread == null) { - String newConvId = createConversationID(); - workContext.setIdentifier(Scope.CONVERSATION, newConvId); - } - } - - Object result = invoke(chain, invoker, args, null, null); - if (contractIsConversational && contractIsRemotable) { - // Make sure we restore the remembered conv id to continue propagating - workContext.setIdentifier(Scope.CONVERSATION, convIdFromThread); - } - return result; - } - - public Object invoke(Method method, Object[] args) throws Throwable { - return invoke(null, method, args); - } - - protected Object getFromAddress() { - return contractHasCallback ? fromAddress : null; - } - - public void setWorkContext(WorkContext context) { - workContext = context; - } - - public void writeExternal(ObjectOutput out) throws IOException { - out.writeObject(referenceName); - out.writeObject(interfaze); - } - - public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { - referenceName = (String) in.readObject(); - interfaze = (Class) in.readObject(); - } - - public void reactivate() throws ReactivationException { - AtomicComponent owner = workContext.getCurrentAtomicComponent(); - if (owner == null) { - throw new ReactivationException("Current atomic component not set on work context"); - } - List wires = owner.getOutboundWires().get(referenceName); - if (wires == null) { - throw new ReactivationException("Reference wire not found", referenceName, owner.getName()); - } - // TODO handle multiplicity - OutboundWire wire = wires.get(0); - try { - init(interfaze, wire, null); - } catch (NoMethodForOperationException e) { - throw new ReactivationException(e); - } - } - - private void init(Class interfaze, OutboundWire wire, Map mapping) - throws NoMethodForOperationException { - ServiceContract contract = wire.getServiceContract(); - this.referenceName = wire.getReferenceName(); - SCAObject wireContainer = wire.getContainer(); - this.fromAddress = (wireContainer == null) ? null : wireContainer.getName(); - this.contractIsConversational = contract.getInteractionScope().equals(CONVERSATIONAL); - this.contractIsRemotable = contract.isRemotable(); - this.contractHasCallback = contract.getCallbackClass() != null; - if (contractHasCallback) { - this.callbackClassName = contract.getCallbackClass().getName(); - } else { - this.callbackClassName = null; - } - // FIXME JFM this should be done during the callback and not be dependent on PojoAtomicComponent - this.wireContainerIsAtomicComponent = wireContainer instanceof PojoAtomicComponent; - if (wireContainerIsAtomicComponent && contractHasCallback) { - this.callbackIsImplemented = - ((PojoAtomicComponent) wireContainer).implementsCallback(contract.getCallbackClass()); - } else { - this.callbackIsImplemented = false; - } - if (mapping == null) { - chains = WireUtils.createInterfaceToWireMapping(interfaze, wire); - } else { - chains = mapping; - } - } - - // TODO Temporary fix to return a string with a UUID - private String createConversationID() { - return UUID.randomUUID().toString(); - } - - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKWireService.java b/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKWireService.java deleted file mode 100644 index e15b851351..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKWireService.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.wire.jdk; - -import java.lang.reflect.Method; -import java.lang.reflect.Proxy; -import java.util.Map; - -import org.osoa.sca.annotations.Constructor; -import org.osoa.sca.annotations.EagerInit; - -import org.apache.tuscany.spi.annotation.Autowire; -import org.apache.tuscany.spi.component.WorkContext; -import org.apache.tuscany.spi.policy.PolicyBuilderRegistry; -import org.apache.tuscany.spi.wire.InboundWire; -import org.apache.tuscany.spi.wire.OutboundChainHolder; -import org.apache.tuscany.spi.wire.OutboundWire; -import org.apache.tuscany.spi.wire.ProxyCreationException; -import org.apache.tuscany.spi.wire.Wire; -import org.apache.tuscany.spi.wire.WireInvocationHandler; - -import org.apache.tuscany.core.wire.WireServiceExtension; - -/** - * the default implementation of a wire service that uses JDK dynamic proxies - * - * @version $$Rev$$ $$Date$$ - */ -@EagerInit -public class JDKWireService extends WireServiceExtension { - - public JDKWireService() { - super(null, null); - } - - @Constructor - public JDKWireService(@Autowire WorkContext context, @Autowire PolicyBuilderRegistry policyRegistry) { - super(context, policyRegistry); - } - - public T createProxy(Class interfaze, Wire wire) throws ProxyCreationException { - assert interfaze != null; - assert wire != null; - if (wire instanceof InboundWire) { - InboundWire inbound = (InboundWire) wire; - JDKInboundInvocationHandler handler = new JDKInboundInvocationHandler(interfaze, inbound, context); - ClassLoader cl = interfaze.getClassLoader(); - return interfaze.cast(Proxy.newProxyInstance(cl, new Class[]{interfaze}, handler)); - } else if (wire instanceof OutboundWire) { - OutboundWire outbound = (OutboundWire) wire; - JDKOutboundInvocationHandler handler = new JDKOutboundInvocationHandler(interfaze, outbound, context); - ClassLoader cl = interfaze.getClassLoader(); - return interfaze.cast(Proxy.newProxyInstance(cl, new Class[]{interfaze}, handler)); - } else { - throw new ProxyCreationException("Invalid wire type", wire.getClass().getName()); - } - } - - public T createProxy(Class interfaze, Wire wire, Map mapping) - throws ProxyCreationException { - assert interfaze != null; - assert wire != null; - assert mapping != null; - if (wire instanceof InboundWire) { - InboundWire inbound = (InboundWire) wire; - JDKInboundInvocationHandler handler = new JDKInboundInvocationHandler(interfaze, inbound, context); - ClassLoader cl = interfaze.getClassLoader(); - return interfaze.cast(Proxy.newProxyInstance(cl, new Class[]{interfaze}, handler)); - } else if (wire instanceof OutboundWire) { - OutboundWire outbound = (OutboundWire) wire; - JDKOutboundInvocationHandler handler = new JDKOutboundInvocationHandler(interfaze, outbound, context); - ClassLoader cl = interfaze.getClassLoader(); - return interfaze.cast(Proxy.newProxyInstance(cl, new Class[]{interfaze}, handler)); - } else { - throw new ProxyCreationException("Invalid wire type", wire.getClass().getName()); - } - } - - public Object createCallbackProxy(Class interfaze, InboundWire wire) throws ProxyCreationException { - ClassLoader cl = interfaze.getClassLoader(); - JDKCallbackInvocationHandler handler = new JDKCallbackInvocationHandler(wire, context); - return interfaze.cast(Proxy.newProxyInstance(cl, new Class[]{interfaze}, handler)); - } - - public WireInvocationHandler createHandler(Class interfaze, Wire wire) { - assert wire != null; - if (wire instanceof InboundWire) { - InboundWire inbound = (InboundWire) wire; - return new JDKInboundInvocationHandler(interfaze, inbound, context); - } else if (wire instanceof OutboundWire) { - OutboundWire outbound = (OutboundWire) wire; - return new JDKOutboundInvocationHandler(interfaze, outbound, context); - } else { - throw new ProxyCreationException("Invalid wire type", wire.getClass().getName()); - } - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/main/resources/org/apache/tuscany/core/composite.scdl b/branches/pre-spec-changes/kernel/core/src/main/resources/org/apache/tuscany/core/composite.scdl deleted file mode 100644 index b51c9e4f68..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/resources/org/apache/tuscany/core/composite.scdl +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/branches/pre-spec-changes/kernel/core/src/main/resources/org/apache/tuscany/core/databinding.scdl b/branches/pre-spec-changes/kernel/core/src/main/resources/org/apache/tuscany/core/databinding.scdl deleted file mode 100644 index 28075d1bf8..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/resources/org/apache/tuscany/core/databinding.scdl +++ /dev/null @@ -1,157 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - org.w3c.dom.Node - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/branches/pre-spec-changes/kernel/core/src/main/resources/org/apache/tuscany/core/formatters.scdl b/branches/pre-spec-changes/kernel/core/src/main/resources/org/apache/tuscany/core/formatters.scdl deleted file mode 100644 index 194bdd27fd..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/resources/org/apache/tuscany/core/formatters.scdl +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/branches/pre-spec-changes/kernel/core/src/main/resources/org/apache/tuscany/core/implementation.scdl b/branches/pre-spec-changes/kernel/core/src/main/resources/org/apache/tuscany/core/implementation.scdl deleted file mode 100644 index 9d4a3dbeda..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/resources/org/apache/tuscany/core/implementation.scdl +++ /dev/null @@ -1,78 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/branches/pre-spec-changes/kernel/core/src/main/resources/org/apache/tuscany/core/interfaceJava.scdl b/branches/pre-spec-changes/kernel/core/src/main/resources/org/apache/tuscany/core/interfaceJava.scdl deleted file mode 100644 index 40e5070e69..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/resources/org/apache/tuscany/core/interfaceJava.scdl +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - - - - diff --git a/branches/pre-spec-changes/kernel/core/src/main/resources/org/apache/tuscany/core/javaImplementation.scdl b/branches/pre-spec-changes/kernel/core/src/main/resources/org/apache/tuscany/core/javaImplementation.scdl deleted file mode 100644 index b53b01480f..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/resources/org/apache/tuscany/core/javaImplementation.scdl +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/branches/pre-spec-changes/kernel/core/src/main/resources/org/apache/tuscany/core/loader.scdl b/branches/pre-spec-changes/kernel/core/src/main/resources/org/apache/tuscany/core/loader.scdl deleted file mode 100644 index cfc0382895..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/resources/org/apache/tuscany/core/loader.scdl +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/branches/pre-spec-changes/kernel/core/src/main/resources/org/apache/tuscany/core/systemImplementation.scdl b/branches/pre-spec-changes/kernel/core/src/main/resources/org/apache/tuscany/core/systemImplementation.scdl deleted file mode 100644 index f4c2c456ba..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/main/resources/org/apache/tuscany/core/systemImplementation.scdl +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/binding/local/AbstractLocalTargetInvokerTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/binding/local/AbstractLocalTargetInvokerTestCase.java deleted file mode 100644 index 8dc0023332..0000000000 --- a/branches/pre-spec-changes/kernel/core/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.Message; -import org.apache.tuscany.spi.wire.MessageImpl; -import org.apache.tuscany.spi.wire.OutboundInvocationChain; -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); - OutboundInvocationChain chain = EasyMock.createMock(OutboundInvocationChain.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); - OutboundInvocationChain chain = EasyMock.createMock(OutboundInvocationChain.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/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/binding/local/LocalBindingBuilderTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/binding/local/LocalBindingBuilderTestCase.java deleted file mode 100644 index 41609d856a..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/binding/local/LocalBindingBuilderTestCase.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.binding.local; - -import org.apache.tuscany.spi.component.ServiceBinding; -import org.apache.tuscany.spi.model.BoundServiceDefinition; - -import junit.framework.TestCase; - -/** - * @version $Rev$ $Date$ - */ -public class LocalBindingBuilderTestCase extends TestCase { - - public void testBuild() throws Exception { - LocalBindingBuilder builder = new LocalBindingBuilder(); - BoundServiceDefinition def = new BoundServiceDefinition(); - def.setName("foo"); - ServiceBinding binding = builder.build(null, def, null, null); - assertEquals(LocalServiceBinding.class, binding.getClass()); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/binding/local/LocalBindingLoaderTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/binding/local/LocalBindingLoaderTestCase.java deleted file mode 100644 index 1633d5f8ea..0000000000 --- a/branches/pre-spec-changes/kernel/core/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, 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, 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, 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/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/binding/local/LocalCallbackTargetInvokerInvocationExceptionTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/binding/local/LocalCallbackTargetInvokerInvocationExceptionTestCase.java deleted file mode 100644 index 1976170f54..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/binding/local/LocalCallbackTargetInvokerInvocationExceptionTestCase.java +++ /dev/null @@ -1,86 +0,0 @@ -package org.apache.tuscany.core.binding.local; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.Map; - -import org.apache.tuscany.spi.model.Operation; -import org.apache.tuscany.spi.wire.InboundWire; -import org.apache.tuscany.spi.wire.Interceptor; -import org.apache.tuscany.spi.wire.Message; -import org.apache.tuscany.spi.wire.MessageImpl; -import org.apache.tuscany.spi.wire.OutboundInvocationChain; - -import junit.framework.TestCase; -import org.easymock.EasyMock; - -/** - * @version $Rev$ $Date$ - */ -public class LocalCallbackTargetInvokerInvocationExceptionTestCase extends TestCase { - private InboundWire wire; - private Message message; - private OutboundInvocationChain chain; - private LocalCallbackTargetInvoker invoker; - - /** - * 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 { - Message response = invoker.invoke(message); - assertTrue(response.isFault()); - Object body = response.getBody(); - assertTrue(SomeException.class.equals(body.getClass())); - EasyMock.verify(wire); - EasyMock.verify(chain); - } - - protected void setUp() throws Exception { - super.setUp(); - Object targetAddress = new Object(); - message = new MessageImpl(); - message.pushFromAddress(targetAddress); - message.setBody("foo"); - Message response = new MessageImpl(); - response.setBody("response"); - Operation operation = new Operation("echo", null, null, null); - Interceptor head = new ErrorInterceptor(); - chain = EasyMock.createMock(OutboundInvocationChain.class); - EasyMock.expect(chain.getTargetInvoker()).andReturn(null); - EasyMock.expect(chain.getHeadInterceptor()).andReturn(head); - EasyMock.replay(chain); - Map, OutboundInvocationChain> chains = new HashMap, OutboundInvocationChain>(); - chains.put(operation, chain); - wire = EasyMock.createMock(InboundWire.class); - EasyMock.expect(wire.getSourceCallbackInvocationChains(targetAddress)).andReturn(chains); - EasyMock.replay(wire); - invoker = new LocalCallbackTargetInvoker(operation, wire); - } - - 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/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/binding/local/LocalCallbackTargetInvokerTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/binding/local/LocalCallbackTargetInvokerTestCase.java deleted file mode 100644 index 123f32d66a..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/binding/local/LocalCallbackTargetInvokerTestCase.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.binding.local; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.Map; - -import org.apache.tuscany.spi.model.Operation; -import org.apache.tuscany.spi.wire.InboundWire; -import org.apache.tuscany.spi.wire.Interceptor; -import org.apache.tuscany.spi.wire.Message; -import org.apache.tuscany.spi.wire.MessageImpl; -import org.apache.tuscany.spi.wire.OutboundInvocationChain; - -import junit.framework.TestCase; -import org.easymock.EasyMock; - -/** - * @version $Rev$ $Date$ - */ -public class LocalCallbackTargetInvokerTestCase extends TestCase { - private InboundWire wire; - private Message message; - private OutboundInvocationChain 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(); - Object targetAddress = new Object(); - message = new MessageImpl(); - message.pushFromAddress(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(OutboundInvocationChain.class); - EasyMock.expect(chain.getTargetInvoker()).andReturn(null); - EasyMock.expect(chain.getHeadInterceptor()).andReturn(head); - EasyMock.replay(chain); - Map, OutboundInvocationChain> chains = new HashMap, OutboundInvocationChain>(); - chains.put(operation, chain); - wire = EasyMock.createMock(InboundWire.class); - EasyMock.expect(wire.getSourceCallbackInvocationChains(targetAddress)).andReturn(chains); - EasyMock.replay(wire); - - invoker = new LocalCallbackTargetInvoker(operation, wire); - } - - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/binding/local/LocalCallbackTargetInvokerThrowableTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/binding/local/LocalCallbackTargetInvokerThrowableTestCase.java deleted file mode 100644 index 9c1bbc616e..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/binding/local/LocalCallbackTargetInvokerThrowableTestCase.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.binding.local; - -import java.lang.reflect.Type; -import java.lang.reflect.UndeclaredThrowableException; -import java.util.HashMap; -import java.util.Map; - -import org.apache.tuscany.spi.model.Operation; -import org.apache.tuscany.spi.wire.InboundWire; -import org.apache.tuscany.spi.wire.Interceptor; -import org.apache.tuscany.spi.wire.Message; -import org.apache.tuscany.spi.wire.MessageImpl; -import org.apache.tuscany.spi.wire.OutboundInvocationChain; - -import junit.framework.TestCase; -import org.easymock.EasyMock; -import org.easymock.IAnswer; - -/** - * @version $Rev$ $Date$ - */ -public class LocalCallbackTargetInvokerThrowableTestCase extends TestCase { - private InboundWire wire; - private Message message; - private OutboundInvocationChain chain; - private Interceptor head; - private LocalCallbackTargetInvoker invoker; - - /** - * Verfies an exception thrown in the target is propagated to the client correctly - */ - public void testThrowableTargetInvocation() throws Exception { - Message response = invoker.invoke(message); - assertTrue(response.isFault()); - Object body = response.getBody(); - if (!(body instanceof UndeclaredThrowableException)) { - fail(); // EasyMock wraps the Throwable in an UndeclaredThrowableException - } - UndeclaredThrowableException e = (UndeclaredThrowableException) body; - assertTrue(InsidiousException.class.equals(e.getUndeclaredThrowable().getClass())); - EasyMock.verify(wire); - EasyMock.verify(chain); - EasyMock.verify(head); - } - - @SuppressWarnings("unchecked") - protected void setUp() throws Exception { - super.setUp(); - Object targetAddress = new Object(); - message = new MessageImpl(); - message.pushFromAddress(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))).andStubAnswer(new IAnswer() { - public Object answer() throws Throwable { - throw new InsidiousException(); // andThrow() does not seem to work here - } - }); - EasyMock.replay(head); - chain = EasyMock.createMock(OutboundInvocationChain.class); - EasyMock.expect(chain.getTargetInvoker()).andReturn(null); - EasyMock.expect(chain.getHeadInterceptor()).andReturn(head); - EasyMock.replay(chain); - Map, OutboundInvocationChain> chains = new HashMap, OutboundInvocationChain>(); - chains.put(operation, chain); - wire = EasyMock.createMock(InboundWire.class); - EasyMock.expect(wire.getSourceCallbackInvocationChains(targetAddress)).andReturn(chains); - EasyMock.replay(wire); - invoker = new LocalCallbackTargetInvoker(operation, wire); - } - - private class InsidiousException extends Throwable { - - } - - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/binding/local/LocalTargetInvokerTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/binding/local/LocalTargetInvokerTestCase.java deleted file mode 100644 index a313d341ed..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/binding/local/LocalTargetInvokerTestCase.java +++ /dev/null @@ -1,127 +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.HashMap; -import java.util.Map; - -import org.apache.tuscany.spi.component.SCAObject; -import org.apache.tuscany.spi.model.Operation; -import org.apache.tuscany.spi.model.ServiceContract; -import org.apache.tuscany.spi.wire.Message; -import org.apache.tuscany.spi.wire.MessageImpl; -import org.apache.tuscany.spi.wire.OutboundInvocationChain; -import org.apache.tuscany.spi.wire.OutboundWire; -import org.apache.tuscany.spi.wire.TargetInvoker; - -import junit.framework.TestCase; -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); - OutboundInvocationChain chain = EasyMock.createNiceMock(OutboundInvocationChain.class); - EasyMock.expect(chain.getTargetInvoker()).andReturn(targetInvoker); - EasyMock.replay(chain); - Map, OutboundInvocationChain> chains = new HashMap, OutboundInvocationChain>(); - chains.put(operation, chain); - OutboundWire wire = EasyMock.createNiceMock(OutboundWire.class); - wire.getInvocationChains(); - EasyMock.expectLastCall().andReturn(chains); - EasyMock.expect(wire.getServiceContract()).andReturn(serviceContract); - EasyMock.replay(wire); - 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); - OutboundInvocationChain chain = EasyMock.createNiceMock(OutboundInvocationChain.class); - EasyMock.expect(chain.getTargetInvoker()).andReturn(targetInvoker); - EasyMock.replay(chain); - Map, OutboundInvocationChain> chains = new HashMap, OutboundInvocationChain>(); - chains.put(operation, chain); - SCAObject container = EasyMock.createMock(SCAObject.class); - EasyMock.expect(container.getName()).andReturn("foo").atLeastOnce(); - EasyMock.replay(container); - OutboundWire wire = EasyMock.createNiceMock(OutboundWire.class); - EasyMock.expect(wire.getContainer()).andReturn(container).atLeastOnce(); - wire.getInvocationChains(); - EasyMock.expectLastCall().andReturn(chains); - EasyMock.expect(wire.getServiceContract()).andReturn(contract); - EasyMock.replay(wire); - TargetInvoker invoker = new LocalTargetInvoker(operation, wire); - Message msg = EasyMock.createMock(Message.class); - msg.pushFromAddress(EasyMock.eq("foo")); - 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); - OutboundInvocationChain chain = EasyMock.createNiceMock(OutboundInvocationChain.class); - EasyMock.expect(chain.getTargetInvoker()).andReturn(targetInvoker); - EasyMock.replay(chain); - Map, OutboundInvocationChain> chains = new HashMap, OutboundInvocationChain>(); - chains.put(operation, chain); - OutboundWire wire = EasyMock.createNiceMock(OutboundWire.class); - wire.getInvocationChains(); - EasyMock.expectLastCall().andReturn(chains); - EasyMock.expect(wire.getServiceContract()).andReturn(serviceContract); - EasyMock.replay(wire); - 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/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/bootstrap/BootstrapperTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/bootstrap/BootstrapperTestCase.java deleted file mode 100644 index 728902e82b..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/bootstrap/BootstrapperTestCase.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.bootstrap; - -import junit.framework.TestCase; - -import org.apache.tuscany.core.deployer.DeployerImpl; -import org.apache.tuscany.core.monitor.NullMonitorFactory; - -/** - * Verifies the default bootstrapper can be instantiated - * - * @version $Rev$ $Date$ - */ -public class BootstrapperTestCase extends TestCase { - private Bootstrapper bootstrapper; - - public void testDeployerBootstrap() { - DeployerImpl deployer = (DeployerImpl) bootstrapper.createDeployer(); - } - - protected void setUp() throws Exception { - super.setUp(); - bootstrapper = new DefaultBootstrapper(new NullMonitorFactory(), null, null); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/AbstractConnectorImplTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/AbstractConnectorImplTestCase.java deleted file mode 100644 index b828262d6e..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/AbstractConnectorImplTestCase.java +++ /dev/null @@ -1,306 +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.InvocationTargetException; -import java.lang.reflect.Type; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import javax.xml.namespace.QName; - -import org.apache.tuscany.spi.QualifiedName; -import org.apache.tuscany.spi.component.AtomicComponent; -import org.apache.tuscany.spi.component.CompositeComponent; -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.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.wire.InboundInvocationChain; -import org.apache.tuscany.spi.wire.InboundWire; -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.MessageImpl; -import org.apache.tuscany.spi.wire.OutboundInvocationChain; -import org.apache.tuscany.spi.wire.OutboundWire; -import org.apache.tuscany.spi.wire.TargetInvoker; -import org.apache.tuscany.spi.wire.WireService; - -import junit.framework.TestCase; -import org.apache.tuscany.core.binding.local.LocalReferenceBinding; -import org.apache.tuscany.core.binding.local.LocalServiceBinding; -import org.apache.tuscany.core.implementation.composite.ServiceImpl; -import org.apache.tuscany.core.mock.binding.MockServiceBinding; -import org.apache.tuscany.core.wire.InboundInvocationChainImpl; -import org.apache.tuscany.core.wire.InboundWireImpl; -import org.apache.tuscany.core.wire.InvokerInterceptor; -import org.apache.tuscany.core.wire.OutboundInvocationChainImpl; -import org.apache.tuscany.core.wire.OutboundWireImpl; -import org.apache.tuscany.core.wire.SynchronousBridgingInterceptor; -import org.apache.tuscany.core.wire.jdk.JDKWireService; -import org.easymock.EasyMock; - -/** - * @version $Rev$ $Date$ - */ -public abstract class AbstractConnectorImplTestCase extends TestCase { - protected static final String TARGET = "target"; - protected static final QualifiedName TARGET_NAME = new QualifiedName(TARGET); - protected static final String TARGET_SERVICE = "FooService"; - protected static final QualifiedName TARGET_SERVICE_NAME = new QualifiedName("target/FooService"); - protected static final String RESPONSE = "response"; - - protected ConnectorImpl connector; - protected ServiceContract contract; - protected Operation operation; - - protected void setUp() throws Exception { - super.setUp(); - WireService wireService = new JDKWireService(null, null); - connector = new ConnectorImpl(wireService, null, null, null); - contract = new JavaServiceContract(Foo.class); - operation = new Operation("bar", null, null, null); - } - - protected AtomicComponent createAtomicTarget() throws Exception { - InboundInvocationChain chain = new InboundInvocationChainImpl(operation); - chain.addInterceptor(new InvokerInterceptor()); - InboundWire targetWire = new InboundWireImpl(); - targetWire.setServiceContract(contract); - targetWire.addInvocationChain(operation, chain); - - MockInvoker mockInvoker = new MockInvoker(); - - // create the target - AtomicComponent target = EasyMock.createMock(AtomicComponent.class); - EasyMock.expect(target.getName()).andReturn(TARGET).anyTimes(); - EasyMock.expect(target.isOptimizable()).andReturn(false).anyTimes(); - EasyMock.expect(target.getScope()).andReturn(Scope.COMPOSITE).atLeastOnce(); - EasyMock.expect(target.isSystem()).andReturn(false).atLeastOnce(); - target.getInboundWire(EasyMock.eq(TARGET_SERVICE)); - EasyMock.expectLastCall().andReturn(targetWire).atLeastOnce(); - target.createTargetInvoker(EasyMock.eq(TARGET_SERVICE), EasyMock.eq(operation), EasyMock.eq(targetWire)); - EasyMock.expectLastCall().andReturn(mockInvoker); - EasyMock.replay(target); - targetWire.setContainer(target); - return target; - } - - protected AtomicComponent createAtomicSource(CompositeComponent parent) throws Exception { - // create the outbound wire and chain from the source component - OutboundInvocationChain outboundChain = new OutboundInvocationChainImpl(operation); - - OutboundWire outboundWire = new OutboundWireImpl(); - outboundWire.setTargetName(TARGET_SERVICE_NAME); - outboundWire.setServiceContract(contract); - outboundWire.addInvocationChain(operation, outboundChain); - - Map> outboundWires = new HashMap>(); - List list = new ArrayList(); - list.add(outboundWire); - outboundWires.put(TARGET_SERVICE, list); - - // create the source - AtomicComponent source = EasyMock.createMock(AtomicComponent.class); - EasyMock.expect(source.isSystem()).andReturn(false).atLeastOnce(); - EasyMock.expect(source.getScope()).andReturn(Scope.COMPOSITE); - EasyMock.expect(source.getParent()).andReturn(parent).atLeastOnce(); - EasyMock.expect(source.getOutboundWires()).andReturn(outboundWires).atLeastOnce(); - EasyMock.expect(source.getName()).andReturn("source").atLeastOnce(); - source.getInboundWires(); - EasyMock.expectLastCall().andReturn(Collections.emptyList()); - EasyMock.replay(source); - - outboundWire.setContainer(source); - return source; - } - - - protected Service createServiceNonLocalBinding() throws WireConnectException { - QName qName = new QName("foo", "bar"); - ServiceBinding serviceBinding = new MockServiceBinding(); - InboundInvocationChain targetInboundChain = new InboundInvocationChainImpl(operation); - targetInboundChain.addInterceptor(new SynchronousBridgingInterceptor()); - InboundWire serviceInboundWire = new InboundWireImpl(qName); - serviceInboundWire.setServiceContract(contract); - serviceInboundWire.addInvocationChain(operation, targetInboundChain); - serviceInboundWire.setContainer(serviceBinding); - - OutboundInvocationChain targetOutboundChain = new OutboundInvocationChainImpl(operation); - // place an invoker interceptor on the end - targetOutboundChain.addInterceptor(new InvokerInterceptor()); - OutboundWire targetOutboundWire = new OutboundWireImpl(qName); - targetOutboundWire.setServiceContract(contract); - targetOutboundWire.addInvocationChain(operation, targetOutboundChain); - targetOutboundWire.setContainer(serviceBinding); - - serviceBinding.setInboundWire(serviceInboundWire); - serviceBinding.setOutboundWire(targetOutboundWire); - // manually connect the service chains - connector.connect(targetInboundChain, targetOutboundChain); - Service service = new ServiceImpl(TARGET, null, contract); - service.addServiceBinding(serviceBinding); - return service; - } - - /** - * Creates a service configured with the local binding and places an invoker interceptor on the end of each outbound - * chain for invocation testing without needing to wire the service to a target - * - * @throws org.apache.tuscany.core.builder.WireConnectException - * - */ - protected Service createLocalService(CompositeComponent parent) throws WireConnectException { - LocalServiceBinding serviceBinding = new LocalServiceBinding(TARGET, parent); - InboundInvocationChain targetInboundChain = new InboundInvocationChainImpl(operation); - targetInboundChain.addInterceptor(new SynchronousBridgingInterceptor()); - InboundWire localServiceInboundWire = new InboundWireImpl(); - localServiceInboundWire.setServiceContract(contract); - localServiceInboundWire.addInvocationChain(operation, targetInboundChain); - localServiceInboundWire.setContainer(serviceBinding); - - OutboundInvocationChain targetOutboundChain = new OutboundInvocationChainImpl(operation); - // place an invoker interceptor on the end - targetOutboundChain.addInterceptor(new InvokerInterceptor()); - OutboundWire targetOutboundWire = new OutboundWireImpl(); - targetOutboundWire.setServiceContract(contract); - targetOutboundWire.addInvocationChain(operation, targetOutboundChain); - targetOutboundWire.setContainer(serviceBinding); - - serviceBinding.setInboundWire(localServiceInboundWire); - serviceBinding.setOutboundWire(targetOutboundWire); - // manually connect the service chains - connector.connect(targetInboundChain, targetOutboundChain); - Service service = new ServiceImpl(TARGET, null, contract); - service.addServiceBinding(serviceBinding); - return service; - } - - protected ReferenceBinding createLocalReferenceBinding(QualifiedName target) - throws TargetInvokerCreationException { - ReferenceBinding referenceBinding = new LocalReferenceBinding("local", null); - InboundInvocationChain inboundChain = new InboundInvocationChainImpl(operation); - InboundWire referenceInboundWire = new InboundWireImpl(); - referenceInboundWire.setServiceContract(contract); - referenceInboundWire.setContainer(referenceBinding); - referenceInboundWire.addInvocationChain(operation, inboundChain); - - OutboundInvocationChain outboundChain = new OutboundInvocationChainImpl(operation); - // Outbound chains always contains at least one interceptor - outboundChain.addInterceptor(new SynchronousBridgingInterceptor()); - OutboundWire outboundWire = new OutboundWireImpl(); - outboundWire.setServiceContract(contract); - outboundWire.setTargetName(target); - outboundWire.addInvocationChain(operation, outboundChain); - outboundWire.setContainer(referenceBinding); - - referenceBinding.setInboundWire(referenceInboundWire); - referenceBinding.setOutboundWire(outboundWire); - - return referenceBinding; - } - - protected InboundWire createLocalInboundWire(CompositeComponent parent) throws WireConnectException { - InboundInvocationChain chain = new InboundInvocationChainImpl(operation); - chain.addInterceptor(new SynchronousBridgingInterceptor()); - InboundWire wire = new InboundWireImpl(); - wire.setServiceContract(contract); - LocalReferenceBinding referenceBinding = new LocalReferenceBinding("", parent); - wire.setContainer(referenceBinding); - wire.addInvocationChain(operation, chain); - - OutboundInvocationChain targetOutboundChain = new OutboundInvocationChainImpl(operation); - // place an invoker interceptor on the end - targetOutboundChain.addInterceptor(new InvokerInterceptor()); - OutboundWire targetOutboundWire = new OutboundWireImpl(); - targetOutboundWire.setServiceContract(contract); - targetOutboundWire.addInvocationChain(operation, targetOutboundChain); - referenceBinding.setInboundWire(wire); - referenceBinding.setOutboundWire(targetOutboundWire); - // manually connect the service chains - connector.connect(chain, targetOutboundChain); - return wire; - } - - protected static class MockInvoker implements TargetInvoker { - public Object invokeTarget(final Object payload, final short sequence) throws InvocationTargetException { - return null; - } - - public Message invoke(Message msg) throws InvocationRuntimeException { - Message resp = new MessageImpl(); - resp.setBody(RESPONSE); - return resp; - } - - public boolean isCacheable() { - return false; - } - - public void setCacheable(boolean cacheable) { - - } - - public boolean isOptimizable() { - return false; - } - - public Object clone() throws CloneNotSupportedException { - return super.clone(); - } - } - - protected static class MockInterceptor implements Interceptor { - private Interceptor next; - private boolean invoked; - - public Message invoke(Message msg) { - invoked = true; - return next.invoke(msg); - } - - public void setNext(Interceptor next) { - this.next = next; - } - - public Interceptor getNext() { - return next; - } - - public boolean isInvoked() { - return invoked; - } - - public boolean isOptimizable() { - return false; - } - } - - protected interface Foo { - String echo(); - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/AtomicConnectorTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/AtomicConnectorTestCase.java deleted file mode 100644 index f89ba7ea8d..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/AtomicConnectorTestCase.java +++ /dev/null @@ -1,125 +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.List; -import java.util.Map; - -import org.apache.tuscany.spi.component.AtomicComponent; -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.component.Service; -import org.apache.tuscany.spi.component.ServiceBinding; -import org.apache.tuscany.spi.model.Scope; -import org.apache.tuscany.spi.wire.InboundInvocationChain; -import org.apache.tuscany.spi.wire.InboundWire; -import org.apache.tuscany.spi.wire.Message; -import org.apache.tuscany.spi.wire.MessageImpl; -import org.apache.tuscany.spi.wire.OutboundInvocationChain; -import org.apache.tuscany.spi.wire.OutboundWire; - -import org.apache.tuscany.core.implementation.composite.ServiceImpl; -import org.apache.tuscany.core.wire.InboundInvocationChainImpl; -import org.apache.tuscany.core.wire.InboundWireImpl; -import org.apache.tuscany.core.wire.OutboundInvocationChainImpl; -import org.apache.tuscany.core.wire.OutboundWireImpl; -import org.easymock.EasyMock; - -/** - * @version $Rev$ $Date$ - */ -public class AtomicConnectorTestCase extends AbstractConnectorImplTestCase { - - public void testConnectSynchronousServiceWiresToAtomicTarget() throws Exception { - AtomicComponent target = createAtomicTarget(); - - // create the parent composite - CompositeComponent parent = EasyMock.createMock(CompositeComponent.class); - EasyMock.expect(parent.getChild("target")).andReturn(target); - EasyMock.replay(parent); - - InboundInvocationChain inboundChain = new InboundInvocationChainImpl(operation); - InboundWire inboundWire = new InboundWireImpl(); - inboundWire.addInvocationChain(operation, inboundChain); - inboundWire.setServiceContract(contract); - - OutboundInvocationChain outboundChain = new OutboundInvocationChainImpl(operation); - OutboundWire outboundWire = new OutboundWireImpl(); - outboundWire.setTargetName(TARGET_SERVICE_NAME); - outboundWire.addInvocationChain(operation, outboundChain); - outboundWire.setServiceContract(contract); - - // create the binding - ServiceBinding binding = EasyMock.createMock(ServiceBinding.class); - EasyMock.expect(binding.getName()).andReturn("source"); - binding.setService(EasyMock.isA(Service.class)); - EasyMock.expect(binding.isSystem()).andReturn(false).atLeastOnce(); - EasyMock.expect(binding.getInboundWire()).andReturn(inboundWire).atLeastOnce(); - EasyMock.expect(binding.getOutboundWire()).andReturn(outboundWire); - EasyMock.expect(binding.getScope()).andReturn(Scope.SYSTEM); - EasyMock.replay(binding); - - outboundWire.setContainer(binding); - inboundWire.setContainer(binding); - - Service service = new ServiceImpl("foo", parent, null); - service.addServiceBinding(binding); - - connector.connect(service); - MessageImpl msg = new MessageImpl(); - msg.setTargetInvoker(inboundChain.getTargetInvoker()); - Message resp = inboundChain.getHeadInterceptor().invoke(msg); - assertEquals(RESPONSE, resp.getBody()); - EasyMock.verify(binding); - } - - public void testConnectNonBlockingServiceWiresToAtomicTarget() throws Exception { - // JFM FIXME - } - - public void testConnectCallbackServiceWiresToAtomicTarget() throws Exception { - // JFM FIXME - } - - /** - * Verifies connecting a wire from an atomic component to a target atomic component with one synchronous operation - */ - public void testConnectAtomicComponentToAtomicComponentSyncWire() throws Exception { - - AtomicComponent target = createAtomicTarget(); - // create the parent composite - CompositeComponent parent = EasyMock.createMock(CompositeComponent.class); - EasyMock.expect(parent.getChild("target")).andReturn(target); - EasyMock.replay(parent); - AtomicComponent source = createAtomicSource(parent); - connector.connect(source); - - MessageImpl msg = new MessageImpl(); - Map> wires = source.getOutboundWires(); - OutboundWire wire = wires.get(TARGET_SERVICE).get(0); - OutboundInvocationChain chain = wire.getInvocationChains().get(operation); - msg.setTargetInvoker(chain.getTargetInvoker()); - Message resp = chain.getHeadInterceptor().invoke(msg); - assertEquals(RESPONSE, resp.getBody()); - } - - protected void setUp() throws Exception { - super.setUp(); - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/BuilderRegistryNoBindingsTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/BuilderRegistryNoBindingsTestCase.java deleted file mode 100644 index 29cb7db48b..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/BuilderRegistryNoBindingsTestCase.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.builder; - -import java.net.URI; -import java.util.ArrayList; -import java.util.List; - -import org.apache.tuscany.spi.builder.BuilderRegistry; -import org.apache.tuscany.spi.component.CompositeComponent; -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.BindingDefinition; -import org.apache.tuscany.spi.model.BoundReferenceDefinition; -import org.apache.tuscany.spi.model.BoundServiceDefinition; -import org.apache.tuscany.spi.model.Multiplicity; - -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.apache.tuscany.core.deployer.RootDeploymentContext; -import org.easymock.EasyMock; - -/** - * @version $Rev$ $Date$ - */ -public class BuilderRegistryNoBindingsTestCase extends TestCase { - private DeploymentContext deploymentContext; - private CompositeComponent parent; - private BuilderRegistry registry; - - public void testNoServiceBindings() throws Exception { - ServiceBinding binding = EasyMock.createNiceMock(ServiceBinding.class); - EasyMock.replay(binding); - List bindingDefs = new ArrayList(); - BoundServiceDefinition definition = new BoundServiceDefinition("foo", null, bindingDefs, false, new URI("foo")); - Service service = registry.build(parent, definition, deploymentContext); - assertEquals(1, service.getServiceBindings().size()); - assertTrue(service.getServiceBindings().get(0) instanceof LocalServiceBinding); - } - - public void testReferenceBindingBuilderDispatch() throws Exception { - ReferenceBinding binding = EasyMock.createNiceMock(ReferenceBinding.class); - EasyMock.replay(binding); - List bindingDefs = new ArrayList(); - BoundReferenceDefinition definition = - new BoundReferenceDefinition("foo", null, bindingDefs, Multiplicity.ONE_ONE); - Reference reference = registry.build(parent, definition, deploymentContext); - assertEquals(1, reference.getReferenceBindings().size()); - assertTrue(reference.getReferenceBindings().get(0) instanceof LocalReferenceBinding); - } - - protected void setUp() throws Exception { - super.setUp(); - deploymentContext = new RootDeploymentContext(null, null, null, null); - parent = EasyMock.createNiceMock(CompositeComponent.class); - EasyMock.replay(parent); - registry = new BuilderRegistryImpl(null, null); - registry.register(LocalBindingDefinition.class, new LocalBindingBuilder()); - } - - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/BuilderRegistryTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/BuilderRegistryTestCase.java deleted file mode 100644 index ea557e981d..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/BuilderRegistryTestCase.java +++ /dev/null @@ -1,217 +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 org.apache.tuscany.spi.QualifiedName; -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.CompositeComponent; -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.BoundReferenceDefinition; -import org.apache.tuscany.spi.model.BoundServiceDefinition; -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.Scope; -import org.apache.tuscany.spi.model.ServiceContract; -import org.apache.tuscany.spi.wire.WireService; - -import junit.framework.TestCase; -import org.apache.tuscany.core.deployer.RootDeploymentContext; -import org.easymock.EasyMock; - -/** - * @version $Rev$ $Date$ - */ -public class BuilderRegistryTestCase extends TestCase { - private DeploymentContext deploymentContext; - //private BuilderRegistryImpl registry; - private CompositeComponent parent; - - public void testRegistration() throws Exception { - MockBuilder builder = new MockBuilder(); - BuilderRegistry registry = new BuilderRegistryImpl(null, null); - registry.register(CompositeImplementation.class, builder); - CompositeImplementation implementation = new CompositeImplementation(); - ComponentDefinition componentDefinition = - new ComponentDefinition(implementation); - componentDefinition.getImplementation().setComponentType(new CompositeComponentType()); - registry.build(parent, componentDefinition, deploymentContext); - } - - @SuppressWarnings({"unchecked"}) - public void testServiceBindingBuilderDispatch() throws Exception { - WireService wireService = EasyMock.createMock(WireService.class); - wireService.createWires(EasyMock.isA(ServiceBinding.class), - (ServiceContract) EasyMock.isNull(), EasyMock.isA(String.class) - ); - EasyMock.expectLastCall().times(2); - EasyMock.replay(wireService); - BuilderRegistry registry = new BuilderRegistryImpl(null, wireService); - ServiceBinding binding = EasyMock.createNiceMock(ServiceBinding.class); - EasyMock.replay(binding); - BindingBuilder builder = EasyMock.createMock(BindingBuilder.class); - EasyMock.expect(builder.build(EasyMock.isA(CompositeComponent.class), - EasyMock.isA(BoundServiceDefinition.class), - EasyMock.isA(MockBindingDefinition.class), - EasyMock.isA(DeploymentContext.class))).andReturn(binding).times(2); - EasyMock.replay(builder); - registry.register(MockBindingDefinition.class, builder); - List bindingDefs = new ArrayList(); - bindingDefs.add(new MockBindingDefinition()); - bindingDefs.add(new MockBindingDefinition()); - BoundServiceDefinition definition = new BoundServiceDefinition("foo", null, bindingDefs, false, new URI("foo")); - Service service = registry.build(parent, definition, deploymentContext); - assertEquals(2, service.getServiceBindings().size()); - EasyMock.verify(wireService); - } - - @SuppressWarnings({"unchecked"}) - public void testReferenceBindingBuilderDispatch() throws Exception { - WireService wireService = EasyMock.createMock(WireService.class); - wireService.createWires(EasyMock.isA(ReferenceBinding.class), - (ServiceContract) EasyMock.isNull(), (QualifiedName) EasyMock.isNull() - ); - EasyMock.expectLastCall().times(2); - EasyMock.replay(wireService); - BuilderRegistry registry = new BuilderRegistryImpl(null, wireService); - ReferenceBinding binding = EasyMock.createNiceMock(ReferenceBinding.class); - EasyMock.replay(binding); - BindingBuilder builder = EasyMock.createMock(BindingBuilder.class); - EasyMock.expect(builder.build(EasyMock.isA(CompositeComponent.class), - EasyMock.isA(BoundReferenceDefinition.class), - EasyMock.isA(MockBindingDefinition.class), - EasyMock.isA(DeploymentContext.class))).andReturn(binding).times(2); - EasyMock.replay(builder); - registry.register(MockBindingDefinition.class, builder); - List bindingDefs = new ArrayList(); - bindingDefs.add(new MockBindingDefinition()); - bindingDefs.add(new MockBindingDefinition()); - BoundReferenceDefinition definition = new BoundReferenceDefinition("foo", null, bindingDefs, ONE_ONE); - Reference reference = registry.build(parent, definition, deploymentContext); - assertEquals(2, reference.getReferenceBindings().size()); - EasyMock.verify(wireService); - } - - @SuppressWarnings({"unchecked"}) - public void testComponentImplementationDispatch() 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); - WireService wireService = EasyMock.createMock(WireService.class); - wireService.createWires(EasyMock.isA(AtomicComponent.class), - EasyMock.isA(ComponentDefinition.class)); - EasyMock.replay(wireService); - BuilderRegistry registry = new BuilderRegistryImpl(scopeRegistry, wireService); - - AtomicComponent component = EasyMock.createNiceMock(AtomicComponent.class); - EasyMock.replay(component); - ComponentBuilder builder = EasyMock.createMock(ComponentBuilder.class); - EasyMock.expect(builder.build(EasyMock.isA(CompositeComponent.class), - EasyMock.isA(ComponentDefinition.class), - EasyMock.isA(DeploymentContext.class))).andReturn(component); - EasyMock.replay(builder); - registry.register(FooImplementation.class, builder); - - FooImplementation impl = new FooImplementation(); - impl.setComponentType(new ComponentType()); - ComponentDefinition definition = new ComponentDefinition("foo", impl); - Component ret = registry.build(parent, definition, deploymentContext); - assertNotNull(ret); - EasyMock.verify(wireService); - } - - 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); - WireService wireService = EasyMock.createMock(WireService.class); - wireService.createWires(EasyMock.isA(AtomicComponent.class), - EasyMock.isA(ComponentDefinition.class)); - EasyMock.replay(wireService); - BuilderRegistry registry = new BuilderRegistryImpl(scopeRegistry, wireService); - - AtomicComponent component = EasyMock.createNiceMock(AtomicComponent.class); - EasyMock.replay(component); - ComponentBuilder builder = EasyMock.createMock(ComponentBuilder.class); - EasyMock.expect(builder.build(EasyMock.isA(CompositeComponent.class), - 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); - ComponentDefinition definition = new ComponentDefinition("foo", impl); - try { - Component ret = registry.build(parent, definition, deploymentContext); - fail("Should throw NoConversationalContractException"); - } - catch(NoConversationalContractException e) { - // expected - } -} - - protected void setUp() throws Exception { - super.setUp(); - deploymentContext = new RootDeploymentContext(null, null, null, null); - parent = EasyMock.createNiceMock(CompositeComponent.class); - EasyMock.replay(parent); - } - - private class MockBuilder implements ComponentBuilder { - public Component build(CompositeComponent parent, - ComponentDefinition componentDefinition, - DeploymentContext deploymentContext) throws BuilderConfigException { - return null; - } - } - - private class MockBindingDefinition extends BindingDefinition { - - } - - private class FooImplementation extends Implementation { - - } - - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/ConnectorImplTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/ConnectorImplTestCase.java deleted file mode 100644 index fc5daa6b12..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/ConnectorImplTestCase.java +++ /dev/null @@ -1,322 +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.util.Collections; - -import org.apache.tuscany.spi.component.AtomicComponent; -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.component.ReferenceBinding; -import org.apache.tuscany.spi.component.SCAObject; -import org.apache.tuscany.spi.model.Operation; -import org.apache.tuscany.spi.model.Scope; -import org.apache.tuscany.spi.wire.InboundInvocationChain; -import org.apache.tuscany.spi.wire.InboundWire; -import org.apache.tuscany.spi.wire.Interceptor; -import org.apache.tuscany.spi.wire.Message; -import org.apache.tuscany.spi.wire.MessageImpl; -import org.apache.tuscany.spi.wire.OutboundInvocationChain; -import org.apache.tuscany.spi.wire.OutboundWire; -import org.apache.tuscany.spi.wire.TargetInvoker; - -import org.apache.tuscany.core.wire.InboundInvocationChainImpl; -import org.apache.tuscany.core.wire.InboundWireImpl; -import org.apache.tuscany.core.wire.InvokerInterceptor; -import org.apache.tuscany.core.wire.OutboundInvocationChainImpl; -import org.apache.tuscany.core.wire.OutboundWireImpl; -import org.apache.tuscany.core.wire.SynchronousBridgingInterceptor; -import org.easymock.EasyMock; - -/** - * @version $Rev$ $Date$ - */ -public class ConnectorImplTestCase extends AbstractConnectorImplTestCase { - - public void testConnectTargetNotFound() throws Exception { - CompositeComponent parent = EasyMock.createMock(CompositeComponent.class); - EasyMock.expect(parent.getName()).andReturn("parent"); - parent.getChild(EasyMock.isA(String.class)); - EasyMock.expectLastCall().andReturn(null); - EasyMock.replay(parent); - try { - AtomicComponent source = createAtomicSource(parent); - connector.connect(source); - fail(); - } catch (TargetServiceNotFoundException e) { - // expected - } - } - - public void testOutboundToInboundOptimization() throws Exception { - AtomicComponent container = EasyMock.createNiceMock(AtomicComponent.class); - EasyMock.expect(container.isSystem()).andReturn(true); - EasyMock.replay(container); - InboundWire inboundWire = new InboundWireImpl(); - inboundWire.setContainer(container); - OutboundWire outboundWire = EasyMock.createMock(OutboundWire.class); - outboundWire.setTargetWire(EasyMock.eq(inboundWire)); - EasyMock.expect(outboundWire.getContainer()).andReturn(container).atLeastOnce(); - EasyMock.replay(outboundWire); - - connector.connect(outboundWire, inboundWire, true); - EasyMock.verify(outboundWire); - } - - /** - * Verifies that stateless targets with a destructor are not optimized as the destructor callback event must be - * issued by the TargetInvoker after it dispatches to the target - */ - public void testOutboundToInboundNoOptimizationBecauseStatelessDestructor() throws Exception { - AtomicComponent container = EasyMock.createNiceMock(AtomicComponent.class); - EasyMock.expect(container.isSystem()).andReturn(false); - EasyMock.expect(container.getScope()).andReturn(Scope.STATELESS); - EasyMock.expect(container.isDestroyable()).andReturn(true); - EasyMock.replay(container); - InboundWire inboundWire = new InboundWireImpl(); - inboundWire.setContainer(container); - OutboundWire outboundWire = EasyMock.createMock(OutboundWire.class); - outboundWire.getInvocationChains(); - EasyMock.expectLastCall().andReturn(Collections.emptyMap()).atLeastOnce(); - outboundWire.getTargetCallbackInvocationChains(); - EasyMock.expectLastCall().andReturn(Collections.emptyMap()).atLeastOnce(); - EasyMock.expect(outboundWire.getContainer()).andReturn(container).atLeastOnce(); - EasyMock.replay(outboundWire); - - connector.connect(outboundWire, inboundWire, true); - EasyMock.verify(outboundWire); - } - - public void testOutboundToInboundNoOptimizationAtomic() throws Exception { - AtomicComponent container = EasyMock.createNiceMock(AtomicComponent.class); - EasyMock.expect(container.isSystem()).andReturn(false); - EasyMock.expect(container.getScope()).andReturn(Scope.STATELESS); - EasyMock.expect(container.isOptimizable()).andReturn(false); - EasyMock.replay(container); - InboundWire inboundWire = new InboundWireImpl(); - inboundWire.setContainer(container); - OutboundWire outboundWire = EasyMock.createMock(OutboundWire.class); - EasyMock.expect(outboundWire.getContainer()).andReturn(container).atLeastOnce(); - outboundWire.getInvocationChains(); - EasyMock.expectLastCall().andReturn(Collections.emptyMap()).atLeastOnce(); - outboundWire.getTargetCallbackInvocationChains(); - EasyMock.expectLastCall().andReturn(Collections.emptyMap()).atLeastOnce(); - EasyMock.replay(outboundWire); - - connector.connect(outboundWire, inboundWire, true); - EasyMock.verify(outboundWire); - } - - public void testOutboundToInboundNoOptimizationNonAtomicTarget() throws Exception { - ReferenceBinding container = EasyMock.createNiceMock(ReferenceBinding.class); - EasyMock.expect(container.isSystem()).andReturn(false); - EasyMock.replay(container); - InboundWire inboundWire = new InboundWireImpl(); - inboundWire.setContainer(container); - OutboundWire outboundWire = EasyMock.createMock(OutboundWire.class); - outboundWire.getInvocationChains(); - EasyMock.expectLastCall().andReturn(Collections.emptyMap()).atLeastOnce(); - outboundWire.getTargetCallbackInvocationChains(); - EasyMock.expectLastCall().andReturn(Collections.emptyMap()).atLeastOnce(); - EasyMock.expect(outboundWire.getContainer()).andReturn(container).atLeastOnce(); - EasyMock.replay(outboundWire); - - connector.connect(outboundWire, inboundWire, true); - EasyMock.verify(outboundWire); - } - - public void testOutboundToInboundChainConnect() throws Exception { - TargetInvoker invoker = new MockInvoker(); - InboundInvocationChain inboundChain = new InboundInvocationChainImpl(operation); - inboundChain.addInterceptor(new InvokerInterceptor()); - OutboundInvocationChain outboundChain = new OutboundInvocationChainImpl(operation); - connector.connect(outboundChain, inboundChain, invoker, false); - Interceptor interceptor = outboundChain.getHeadInterceptor(); - assertTrue(interceptor instanceof SynchronousBridgingInterceptor); - MessageImpl msg = new MessageImpl(); - msg.setTargetInvoker(new MockInvoker()); - Message resp = interceptor.invoke(msg); - assertEquals(RESPONSE, resp.getBody()); - } - - public void testOutboundToInboundChainConnectNoInboundInterceptor() { - TargetInvoker invoker = new MockInvoker(); - InboundInvocationChain inboundChain = new InboundInvocationChainImpl(operation); - OutboundInvocationChain outboundChain = new OutboundInvocationChainImpl(operation); - try { - connector.connect(outboundChain, inboundChain, invoker, false); - fail(); - } catch (WireConnectException e) { - // expected - } - } - - public void testInboundToOutboundChainConnect() throws Exception { - InboundInvocationChain inboundChain = new InboundInvocationChainImpl(operation); - OutboundInvocationChain outboundChain = new OutboundInvocationChainImpl(operation); - outboundChain.addInterceptor(new InvokerInterceptor()); - connector.connect(inboundChain, outboundChain); - Interceptor interceptor = inboundChain.getHeadInterceptor(); - assertTrue(interceptor instanceof SynchronousBridgingInterceptor); - MessageImpl msg = new MessageImpl(); - msg.setTargetInvoker(new MockInvoker()); - Message resp = interceptor.invoke(msg); - assertEquals(RESPONSE, resp.getBody()); - } - - public void testInboundToOutboundChainConnectNoOutboundInterceptors() throws Exception { - InboundInvocationChain inboundChain = new InboundInvocationChainImpl(operation); - OutboundInvocationChain outboundChain = new OutboundInvocationChainImpl(operation); - try { - connector.connect(inboundChain, outboundChain); - fail(); - } catch (WireConnectException e) { - // expected - } - } - - public void testInboundOutboundSystemWireOptimization() throws Exception { - SCAObject container = EasyMock.createMock(SCAObject.class); - EasyMock.expect(container.isSystem()).andReturn(true); - EasyMock.replay(container); - InboundWire inboundWire = EasyMock.createMock(InboundWire.class); - inboundWire.setTargetWire(EasyMock.isA(OutboundWire.class)); - EasyMock.expect(inboundWire.getContainer()).andReturn(container).atLeastOnce(); - EasyMock.replay(inboundWire); - OutboundWire outboundWire = new OutboundWireImpl(); - outboundWire.setContainer(container); - connector.connect(inboundWire, outboundWire, true); - EasyMock.verify(inboundWire); - EasyMock.verify(container); - } - - public void testOutboundInboundSystemWireOptimization() throws Exception { - SCAObject container = EasyMock.createMock(SCAObject.class); - EasyMock.expect(container.isSystem()).andReturn(true); - EasyMock.replay(container); - OutboundWire outboundWire = EasyMock.createMock(OutboundWire.class); - outboundWire.setTargetWire(EasyMock.isA(InboundWire.class)); - EasyMock.expect(outboundWire.getContainer()).andReturn(container).atLeastOnce(); - EasyMock.replay(outboundWire); - InboundWire inboundWire = new InboundWireImpl(); - inboundWire.setContainer(container); - connector.connect(outboundWire, inboundWire, true); - EasyMock.verify(outboundWire); - EasyMock.verify(container); - } - - public void testIncompatibleInboundOutboundWiresConnect() throws Exception { - Operation operation = new Operation("bar", null, null, null); - InboundWire inboundWire = new InboundWireImpl(); - inboundWire.addInvocationChain(operation, new InboundInvocationChainImpl(operation)); - OutboundWire outboundWire = new OutboundWireImpl(); - try { - connector.connect(inboundWire, outboundWire, false); - fail(); - } catch (IncompatibleInterfacesException e) { - // expected - } - - } - - public void testIncompatibleOutboundInboundWiresConnect() throws Exception { - SCAObject container = EasyMock.createNiceMock(SCAObject.class); - EasyMock.expect(container.isSystem()).andReturn(false); - EasyMock.replay(container); - Operation operation = new Operation("bar", null, null, null); - InboundWire inboundWire = new InboundWireImpl(); - inboundWire.setContainer(container); - OutboundWire outboundWire = new OutboundWireImpl(); - outboundWire.setContainer(container); - outboundWire.addInvocationChain(operation, new OutboundInvocationChainImpl(operation)); - try { - connector.connect(outboundWire, inboundWire, false); - fail(); - } catch (IncompatibleInterfacesException e) { - // expected - } - - } - - 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 testInvalidConnectObject() throws Exception { - try { - connector.connect(EasyMock.createNiceMock(SCAObject.class)); - fail(); - } catch (AssertionError e) { - // expected - } - } - - protected void setUp() throws Exception { - super.setUp(); - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/ConnectorPostProcessTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/ConnectorPostProcessTestCase.java deleted file mode 100644 index 857b17eff5..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/ConnectorPostProcessTestCase.java +++ /dev/null @@ -1,104 +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.HashMap; -import java.util.Map; - -import org.apache.tuscany.spi.component.AtomicComponent; -import org.apache.tuscany.spi.model.Operation; -import org.apache.tuscany.spi.model.ServiceContract; -import org.apache.tuscany.spi.wire.InboundInvocationChain; -import org.apache.tuscany.spi.wire.InboundWire; -import org.apache.tuscany.spi.wire.OutboundInvocationChain; -import org.apache.tuscany.spi.wire.OutboundWire; -import org.apache.tuscany.spi.wire.WirePostProcessorRegistry; -import org.apache.tuscany.spi.wire.WireService; - -import junit.framework.TestCase; -import org.easymock.EasyMock; -import static org.easymock.EasyMock.createMock; -import static org.easymock.EasyMock.createNiceMock; -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.expectLastCall; -import static org.easymock.EasyMock.replay; -import static org.easymock.EasyMock.verify; - -/** - * @version $Rev$ $Date$ - */ -public class ConnectorPostProcessTestCase extends TestCase { - - public void testInboundToOutboundPostProcessCalled() throws Exception { - OutboundWire owire = createNiceMock(OutboundWire.class); - replay(owire); - InboundWire iwire = createNiceMock(InboundWire.class); - Map, InboundInvocationChain> chains = new HashMap, InboundInvocationChain>(); - expect(iwire.getInvocationChains()).andReturn(chains); - replay(iwire); - WirePostProcessorRegistry registry = createMock(WirePostProcessorRegistry.class); - registry.process(EasyMock.eq(iwire), EasyMock.eq(owire)); - replay(registry); - WireService wireService = createMock(WireService.class); - wireService.checkCompatibility((ServiceContract) EasyMock.anyObject(), - (ServiceContract) EasyMock.anyObject(), EasyMock.eq(false)); - expectLastCall().anyTimes(); - replay(wireService); - ConnectorImpl connector = new ConnectorImpl(wireService, registry, null, null); - connector.connect(iwire, owire, false); - verify(registry); - } - - public void testOutboundToInboundPostProcessCalled() throws Exception { - AtomicComponent source = createNiceMock(AtomicComponent.class); - expect(source.getName()).andReturn("Component"); - replay(source); - - AtomicComponent target = createNiceMock(AtomicComponent.class); - expect(target.getName()).andReturn("Component"); - replay(target); - - OutboundWire owire = createNiceMock(OutboundWire.class); - EasyMock.expect(owire.getContainer()).andReturn(source); - - Map, OutboundInvocationChain> chains = new HashMap, OutboundInvocationChain>(); - expect(owire.getInvocationChains()).andReturn(chains); - Map, InboundInvocationChain> ichains = new HashMap, InboundInvocationChain>(); - expect(owire.getTargetCallbackInvocationChains()).andReturn(ichains); - replay(owire); - InboundWire iwire = createNiceMock(InboundWire.class); - expect(iwire.getSourceCallbackInvocationChains("Component")).andReturn(chains); - EasyMock.expect(iwire.getContainer()).andReturn(target); - replay(iwire); - WirePostProcessorRegistry registry = createMock(WirePostProcessorRegistry.class); - registry.process(EasyMock.eq(owire), EasyMock.eq(iwire)); - replay(registry); - WireService wireService = createMock(WireService.class); - wireService.checkCompatibility((ServiceContract) EasyMock.anyObject(), - (ServiceContract) EasyMock.anyObject(), EasyMock.eq(false)); - expectLastCall().anyTimes(); - replay(wireService); - ConnectorImpl connector = new ConnectorImpl(wireService, registry, null, null); - - connector.connect(owire, iwire, false); - verify(registry); - } - - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/IllegalCallbackExceptionTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/IllegalCallbackExceptionTestCase.java deleted file mode 100644 index 40ddc837c7..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/IllegalCallbackExceptionTestCase.java +++ /dev/null @@ -1,43 +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 junit.framework.TestCase; - -/** - * @version $Rev$ $Date$ - */ -public class IllegalCallbackExceptionTestCase extends TestCase { - - public void testInstantiation() throws Exception { - IllegalCallbackException e = new IllegalCallbackException("message", - "identifier", - "source name", - "ref name", - "target name", - "service name"); - assertEquals("message", e.getMessage()); - assertEquals("identifier", e.getIdentifier()); - assertEquals("source name", e.getSourceName()); - assertEquals("ref name", e.getReferenceName()); - assertEquals("target name", e.getTargetName()); - assertEquals("service name", e.getTargetServiceName()); - - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/InboundtoOutboundConnectTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/InboundtoOutboundConnectTestCase.java deleted file mode 100644 index 4676dbb7cc..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/InboundtoOutboundConnectTestCase.java +++ /dev/null @@ -1,168 +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.idl.InvalidServiceContractException; -import org.apache.tuscany.spi.idl.java.JavaInterfaceProcessorRegistry; -import org.apache.tuscany.spi.model.Operation; -import org.apache.tuscany.spi.model.ServiceContract; -import org.apache.tuscany.spi.wire.InboundInvocationChain; -import org.apache.tuscany.spi.wire.Message; -import org.apache.tuscany.spi.wire.MessageImpl; -import org.apache.tuscany.spi.wire.OutboundInvocationChain; -import org.apache.tuscany.spi.wire.TargetInvoker; - -import junit.framework.TestCase; -import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl; -import org.apache.tuscany.core.mock.component.SimpleTarget; -import org.apache.tuscany.core.mock.wire.MockSyncInterceptor; -import org.apache.tuscany.core.wire.InboundInvocationChainImpl; -import org.apache.tuscany.core.wire.InvokerInterceptor; -import org.apache.tuscany.core.wire.OutboundInvocationChainImpl; -import org.easymock.EasyMock; - -/** - * Verifies connection strategies between {@link org.apache.tuscany.spi.wire.OutboundInvocationChain}s and {@link - * org.apache.tuscany.spi.wire.InboundInvocationChain}s - * - * @version $$Rev$$ $$Date$$ - */ -public class InboundtoOutboundConnectTestCase extends TestCase { - private Operation operation; - private ConnectorImpl connector; - - public void testNoInterceptors() throws Exception { - InboundInvocationChain inboundChain = new InboundInvocationChainImpl(operation); - OutboundInvocationChain outboundChain = new OutboundInvocationChainImpl(operation); - outboundChain.addInterceptor(new InvokerInterceptor()); - TargetInvoker invoker = EasyMock.createNiceMock(TargetInvoker.class); - EasyMock.expect(invoker.invoke(EasyMock.isA(Message.class))).andReturn(new MessageImpl()); - EasyMock.replay(invoker); - connector.connect(inboundChain, outboundChain); - inboundChain.setTargetInvoker(invoker); - inboundChain.prepare(); - Message msg = new MessageImpl(); - msg.setTargetInvoker(invoker); - inboundChain.getHeadInterceptor().invoke(msg); - EasyMock.verify(invoker); - } - - - /** - * Verifies an invocation with a single source interceptor - */ - public void testSourceInterceptor() throws Exception { - MockSyncInterceptor interceptor = new MockSyncInterceptor(); - InboundInvocationChain inboundChain = new InboundInvocationChainImpl(operation); - inboundChain.addInterceptor(interceptor); - OutboundInvocationChain outboundChain = new OutboundInvocationChainImpl(operation); - outboundChain.addInterceptor(new InvokerInterceptor()); - Message msg = new MessageImpl(); - TargetInvoker invoker = EasyMock.createNiceMock(TargetInvoker.class); - EasyMock.expect(invoker.invoke(EasyMock.eq(msg))).andReturn(msg); - EasyMock.replay(invoker); - assertEquals(0, interceptor.getCount()); - connector.connect(inboundChain, outboundChain); - inboundChain.setTargetInvoker(invoker); - inboundChain.prepare(); - msg.setTargetInvoker(inboundChain.getTargetInvoker()); - assertEquals(msg, inboundChain.getHeadInterceptor().invoke(msg)); - assertEquals(1, interceptor.getCount()); - EasyMock.verify(invoker); - } - - /** - * Verifies an invocation with a single target interceptor - */ - public void testTargetInterceptor() throws Exception { - MockSyncInterceptor interceptor = new MockSyncInterceptor(); - InboundInvocationChain inboundChain = new InboundInvocationChainImpl(operation); - inboundChain.addInterceptor(interceptor); - OutboundInvocationChain outboundChain = new OutboundInvocationChainImpl(operation); - outboundChain.addInterceptor(new InvokerInterceptor()); - Message msg = new MessageImpl(); - TargetInvoker invoker = EasyMock.createNiceMock(TargetInvoker.class); - EasyMock.expect(invoker.invoke(EasyMock.eq(msg))).andReturn(msg); - EasyMock.replay(invoker); - assertEquals(0, interceptor.getCount()); - connector.connect(inboundChain, outboundChain); - inboundChain.setTargetInvoker(invoker); - inboundChain.prepare(); - msg.setTargetInvoker(inboundChain.getTargetInvoker()); - assertEquals(msg, inboundChain.getHeadInterceptor().invoke(msg)); - assertEquals(1, interceptor.getCount()); - EasyMock.verify(invoker); - } - - /** - * Verifies an invocation with a source and target interceptor - */ - public void testSourceTargetInterceptor() throws Exception { - MockSyncInterceptor sourceInterceptor = new MockSyncInterceptor(); - MockSyncInterceptor targetInterceptor = new MockSyncInterceptor(); - OutboundInvocationChain outboundChain = new OutboundInvocationChainImpl(operation); - outboundChain.addInterceptor(sourceInterceptor); - outboundChain.addInterceptor(new InvokerInterceptor()); - InboundInvocationChain inboundChain = new InboundInvocationChainImpl(operation); - inboundChain.addInterceptor(targetInterceptor); - Message msg = new MessageImpl(); - TargetInvoker invoker = EasyMock.createNiceMock(TargetInvoker.class); - EasyMock.expect(invoker.invoke(EasyMock.eq(msg))).andReturn(msg); - EasyMock.replay(invoker); - assertEquals(0, sourceInterceptor.getCount()); - assertEquals(0, targetInterceptor.getCount()); - connector.connect(inboundChain, outboundChain); - inboundChain.setTargetInvoker(invoker); - inboundChain.prepare(); - msg.setTargetInvoker(inboundChain.getTargetInvoker()); - assertEquals(msg, inboundChain.getHeadInterceptor().invoke(msg)); - assertEquals(1, sourceInterceptor.getCount()); - assertEquals(1, targetInterceptor.getCount()); - EasyMock.verify(invoker); - } - - public void testOptimizeSet() throws Exception { - OutboundInvocationChain outboundChain = new OutboundInvocationChainImpl(operation); - outboundChain.addInterceptor(new InvokerInterceptor()); - InboundInvocationChain inboundChain = new InboundInvocationChainImpl(operation); - Message msg = new MessageImpl(); - TargetInvoker invoker = EasyMock.createNiceMock(TargetInvoker.class); - EasyMock.expect(invoker.invoke(EasyMock.eq(msg))).andReturn(msg); - EasyMock.replay(invoker); - connector.connect(inboundChain, outboundChain); - inboundChain.setTargetInvoker(invoker); - inboundChain.prepare(); - msg.setTargetInvoker(inboundChain.getTargetInvoker()); - assertEquals(msg, inboundChain.getHeadInterceptor().invoke(msg)); - EasyMock.verify(invoker); - } - - protected void setUp() throws Exception { - super.setUp(); - connector = new ConnectorImpl(); - JavaInterfaceProcessorRegistry registry = new JavaInterfaceProcessorRegistryImpl(); - ServiceContract contract; - try { - contract = registry.introspect(SimpleTarget.class); - } catch (InvalidServiceContractException e) { - throw new AssertionError(); - } - operation = contract.getOperations().get("echo"); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/IncompatibleInterfacesExceptionTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/IncompatibleInterfacesExceptionTestCase.java deleted file mode 100644 index 7fa6633258..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/IncompatibleInterfacesExceptionTestCase.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.builder; - -import junit.framework.TestCase; - -/** - * @version $Rev$ $Date$ - */ -public class IncompatibleInterfacesExceptionTestCase extends TestCase { - - public void testInstantiation() throws Exception { - IncompatibleInterfacesException e = new IncompatibleInterfacesException("message", - "source name", - "ref name", - "target name", - "service name"); - assertEquals("message", e.getMessage()); - assertEquals("source name", e.getSourceName()); - assertEquals("ref name", e.getReferenceName()); - assertEquals("target name", e.getTargetName()); - assertEquals("service name", e.getTargetServiceName()); - - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/InvalidTargetTypeExceptionTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/InvalidTargetTypeExceptionTestCase.java deleted file mode 100644 index c34be84745..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/InvalidTargetTypeExceptionTestCase.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.builder; - -import junit.framework.TestCase; - -/** - * @version $Rev$ $Date$ - */ -public class InvalidTargetTypeExceptionTestCase extends TestCase { - - public void testInstantiation() throws Exception { - InvalidTargetTypeException e = new InvalidTargetTypeException("message", - "source name", - "ref name", - "target name", - "service name"); - assertEquals("message", e.getMessage()); - assertEquals("source name", e.getSourceName()); - assertEquals("ref name", e.getReferenceName()); - assertEquals("target name", e.getTargetName()); - assertEquals("service name", e.getTargetServiceName()); - - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/LocalReferenceWiringTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/LocalReferenceWiringTestCase.java deleted file mode 100644 index 0806708056..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/LocalReferenceWiringTestCase.java +++ /dev/null @@ -1,236 +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.Collections; - -import org.apache.tuscany.spi.QualifiedName; -import org.apache.tuscany.spi.component.AtomicComponent; -import org.apache.tuscany.spi.component.CompositeComponent; -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.model.Scope; -import org.apache.tuscany.spi.wire.InboundInvocationChain; -import org.apache.tuscany.spi.wire.InboundWire; -import org.apache.tuscany.spi.wire.Interceptor; -import org.apache.tuscany.spi.wire.Message; -import org.apache.tuscany.spi.wire.MessageImpl; - -import org.apache.tuscany.core.implementation.composite.CompositeComponentImpl; -import org.apache.tuscany.core.implementation.composite.ReferenceImpl; -import org.easymock.EasyMock; -import org.easymock.IAnswer; - -/** - * Verifies various wiring "scenarios" or paths through the connector - * - * @version $Rev$ $Date$ - */ -public class LocalReferenceWiringTestCase extends AbstractConnectorImplTestCase { - protected ReferenceBinding referenceBinding; - private Reference reference; - - /** - * Verifies the case where the outbound reference wire is connected to a target atomic component that is a sibling - * to the reference's parent composite. This wiring scenario occurs when a reference is configured with the local - * binding. - */ - public void testConnectLocalReferenceBindingToAtomicComponentService() throws Exception { - final AtomicComponent atomicComponent = createAtomicTarget(); - CompositeComponent topComposite = EasyMock.createMock(CompositeComponent.class); - topComposite.getChild(TARGET); - EasyMock.expectLastCall().andStubAnswer(new IAnswer() { - public Object answer() throws Throwable { - return atomicComponent; - } - }); - EasyMock.replay(topComposite); - CompositeComponent parent = new CompositeComponentImpl("parent", topComposite, connector, null); - reference = createLocalReference(parent, TARGET_SERVICE_NAME); - parent.register(reference); - // connect to the target - connector.connect(parent); - // connect the internal reference chains - connector.connect(reference); - InboundInvocationChain chain = referenceBinding.getInboundWire().getInvocationChains().get(operation); - Interceptor interceptor = chain.getHeadInterceptor(); - MessageImpl msg = new MessageImpl(); - msg.setTargetInvoker(new MockInvoker()); - Message resp = interceptor.invoke(msg); - assertEquals(RESPONSE, resp.getBody()); - } - - /** - * Verifies the case where the outbound reference wire is connected to a target composite service that is a sibling - * to the reference's parent composite. This wiring scenario occurs when a reference is configured with the local - * binding. - */ - public void testConnectLocalReferenceBindingToCompositeService() throws Exception { - final CompositeComponent topComposite = EasyMock.createMock(CompositeComponent.class); - - topComposite.getInboundWire(TARGET); - EasyMock.expectLastCall().andStubAnswer(new IAnswer() { - public Object answer() throws Throwable { - return createLocalInboundWire(topComposite); - } - }); - final Service service = createLocalService(topComposite); - topComposite.getChild(TARGET); - EasyMock.expectLastCall().andStubAnswer(new IAnswer() { - public Object answer() throws Throwable { - return service; - } - }); - EasyMock.replay(topComposite); - - CompositeComponent parent = new CompositeComponentImpl("parent", topComposite, connector, null); - reference = createLocalReference(parent, TARGET_NAME); - parent.register(reference); - connector.connect(parent); - connector.connect(reference); - InboundInvocationChain chain = referenceBinding.getInboundWire().getInvocationChains().get(operation); - Interceptor interceptor = chain.getHeadInterceptor(); - MessageImpl msg = new MessageImpl(); - msg.setTargetInvoker(new MockInvoker()); - Message resp = interceptor.invoke(msg); - assertEquals(RESPONSE, resp.getBody()); - } - - /** - * Verfies an exception if the target composite service (a sibling to the reference's parent) does not have a local - * binding - */ - public void testConnectLocalReferenceBindingToCompositeServiceNoMatchingBinding() throws Exception { - final Service service = createServiceNonLocalBinding(); - CompositeComponent topComposite = EasyMock.createMock(CompositeComponent.class); - EasyMock.expect(topComposite.getName()).andReturn("foo"); - topComposite.getChild(TARGET); - EasyMock.expectLastCall().andStubAnswer(new IAnswer() { - public Object answer() throws Throwable { - return service; - } - }); - EasyMock.replay(topComposite); - - CompositeComponent parent = new CompositeComponentImpl("parent", topComposite, connector, null); - reference = createLocalReference(parent, TARGET_NAME); - parent.register(reference); - try { - connector.connect(parent); - fail(); - } catch (NoCompatibleBindingsException e) { - // expected - } - } - - /** - * Verifies a connection to a service offered by a sibling composite of the reference's parent - * - * @throws Exception - */ - public void testConnectLocalReferenceBindingToSiblingCompositeService() throws Exception { - final CompositeComponent sibling = EasyMock.createMock(CompositeComponent.class); - final InboundWire localServiceInboundWire = createLocalInboundWire(sibling); - EasyMock.expect(sibling.getName()).andReturn("sibling").atLeastOnce(); - sibling.getInboundWires(); - EasyMock.expectLastCall().andReturn(Collections.emptyList()).atLeastOnce(); - EasyMock.expect(sibling.isSystem()).andReturn(false).atLeastOnce(); - sibling.getInboundWire(TARGET_SERVICE); - EasyMock.expectLastCall().andStubAnswer(new IAnswer() { - public Object answer() throws Throwable { - return localServiceInboundWire; - } - }); - EasyMock.expect(sibling.getScope()).andReturn(Scope.SYSTEM).anyTimes(); - EasyMock.replay(sibling); - - CompositeComponent topComposite = EasyMock.createMock(CompositeComponent.class); - EasyMock.expect(topComposite.getName()).andReturn("foo").atLeastOnce(); - topComposite.getChild(TARGET); - EasyMock.expectLastCall().andStubAnswer(new IAnswer() { - public Object answer() throws Throwable { - return sibling; - } - }); - EasyMock.replay(topComposite); - - CompositeComponent parent = new CompositeComponentImpl("parent", topComposite, connector, null); - reference = createLocalReference(parent, TARGET_SERVICE_NAME); - parent.register(reference); - parent.register(sibling); - connector.connect(parent); - connector.connect(reference); - InboundInvocationChain chain = referenceBinding.getInboundWire().getInvocationChains().get(operation); - Interceptor interceptor = chain.getHeadInterceptor(); - MessageImpl msg = new MessageImpl(); - msg.setTargetInvoker(new MockInvoker()); - Message resp = interceptor.invoke(msg); - assertEquals(RESPONSE, resp.getBody()); - } - - public void testConnectLocalReferenceBindingToSiblingCompositeServiceNoMatchingBinding() throws Exception { - try { - final CompositeComponent sibling = EasyMock.createMock(CompositeComponent.class); - sibling.getInboundWire(TARGET_SERVICE); - EasyMock.expectLastCall().andReturn(null); - EasyMock.expect(sibling.getName()).andReturn("sibling").atLeastOnce(); - EasyMock.expect(sibling.getScope()).andReturn(Scope.SYSTEM).atLeastOnce(); - EasyMock.expectLastCall().andStubAnswer(new IAnswer() { - public Object answer() throws Throwable { - return null; - } - }); - EasyMock.replay(sibling); - - CompositeComponent topComposite = EasyMock.createMock(CompositeComponent.class); - topComposite.getChild(TARGET); - EasyMock.expectLastCall().andStubAnswer(new IAnswer() { - public Object answer() throws Throwable { - return sibling; - } - }); - EasyMock.expect(topComposite.getName()).andReturn("top").atLeastOnce(); - EasyMock.replay(topComposite); - - CompositeComponent parent = new CompositeComponentImpl("parent", topComposite, connector, null); - - reference = createLocalReference(parent, TARGET_SERVICE_NAME); - parent.register(reference); - connector.connect(parent); - fail(); - } catch (TargetServiceNotFoundException e) { - // expected - } - } - - protected void setUp() throws Exception { - super.setUp(); - } - - - private Reference createLocalReference(CompositeComponent parent, QualifiedName target) throws Exception { - referenceBinding = createLocalReferenceBinding(target); - Reference reference = new ReferenceImpl("foo", parent, contract); - reference.addReferenceBinding(referenceBinding); - return reference; - } - - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/NonBlockingForwardNonBlockingCallbackConnectionTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/NonBlockingForwardNonBlockingCallbackConnectionTestCase.java deleted file mode 100644 index 896a98b773..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/NonBlockingForwardNonBlockingCallbackConnectionTestCase.java +++ /dev/null @@ -1,172 +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.util.HashMap; -import java.util.Map; - -import org.apache.tuscany.spi.QualifiedName; -import org.apache.tuscany.spi.component.AtomicComponent; -import org.apache.tuscany.spi.component.WorkContext; -import org.apache.tuscany.spi.idl.java.JavaServiceContract; -import org.apache.tuscany.spi.model.Operation; -import org.apache.tuscany.spi.model.ServiceContract; -import org.apache.tuscany.spi.services.work.NotificationListener; -import org.apache.tuscany.spi.services.work.WorkScheduler; -import org.apache.tuscany.spi.wire.InboundInvocationChain; -import org.apache.tuscany.spi.wire.InboundWire; -import org.apache.tuscany.spi.wire.Interceptor; -import org.apache.tuscany.spi.wire.Message; -import org.apache.tuscany.spi.wire.MessageImpl; -import org.apache.tuscany.spi.wire.OutboundInvocationChain; -import org.apache.tuscany.spi.wire.OutboundWire; -import org.apache.tuscany.spi.wire.TargetInvoker; -import org.apache.tuscany.spi.wire.WireService; - -import junit.framework.TestCase; -import org.apache.tuscany.core.component.WorkContextImpl; -import org.apache.tuscany.core.wire.InboundInvocationChainImpl; -import org.apache.tuscany.core.wire.InboundWireImpl; -import org.apache.tuscany.core.wire.OutboundInvocationChainImpl; -import org.apache.tuscany.core.wire.OutboundWireImpl; -import org.apache.tuscany.core.wire.jdk.JDKWireService; -import org.easymock.EasyMock; - -/** - * Verifies connections with non-blocking forward and callback invocations - * - * @version $Rev$ $Date$ - */ -public class NonBlockingForwardNonBlockingCallbackConnectionTestCase extends TestCase { - private Operation operation; - private Operation callbackOperation; - private ServiceContract contract; - private ConnectorImpl connector; - - public void testNonBlockingForwardAndNonBlockingCallbackAtomicToAtomic() throws Exception { - AtomicComponent target = EasyMock.createMock(AtomicComponent.class); - EasyMock.expect(target.isSystem()).andReturn(false).anyTimes(); - EasyMock.expect(target.getName()).andReturn("target").anyTimes(); - EasyMock.expect(target.createTargetInvoker(EasyMock.eq("service"), - EasyMock.isA(Operation.class), - EasyMock.isA(InboundWire.class))).andReturn(EasyMock.createNiceMock(TargetInvoker.class)); - EasyMock.replay(target); - - InboundWire inboundWire = new InboundWireImpl(); - inboundWire.setContainer(target); - inboundWire.setServiceContract(contract); - InboundInvocationChain inboundChain = new InboundInvocationChainImpl(operation); - inboundChain.addInterceptor(new NonBlockingForwardNonBlockingCallbackConnectionTestCase.MockInterceptor()); - inboundWire.addInvocationChain(operation, inboundChain); - - AtomicComponent source = createSource(); - OutboundWire outboundWire = new OutboundWireImpl(); - outboundWire.setContainer(source); - outboundWire.setServiceContract(contract); - outboundWire.setTargetName(new QualifiedName("target/service")); - OutboundInvocationChain outboundChain = new OutboundInvocationChainImpl(operation); - outboundWire.addInvocationChain(operation, outboundChain); - - InboundInvocationChain callbackInboundChain = new InboundInvocationChainImpl(callbackOperation); - callbackInboundChain - .addInterceptor(new NonBlockingForwardNonBlockingCallbackConnectionTestCase.MockInterceptor()); - Map, InboundInvocationChain> chains = new HashMap, InboundInvocationChain>(); - chains.put(callbackOperation, callbackInboundChain); - outboundWire.addTargetCallbackInvocationChains(chains); - - connector.connect(outboundWire, inboundWire, true); - - // test the forward request - Message msg = new MessageImpl(); - msg.setBody("foo"); - Message ret = outboundChain.getHeadInterceptor().invoke(msg); - assertEquals(null, ret.getBody()); - - // test the callback - msg = new MessageImpl(); - msg.setBody("callback"); - Map, OutboundInvocationChain> callbackChains = - inboundWire.getSourceCallbackInvocationChains("source"); - OutboundInvocationChain callbackInvocationChain = callbackChains.get(callbackOperation); - ret = callbackInvocationChain.getHeadInterceptor().invoke(msg); - assertEquals(null, ret.getBody()); - - EasyMock.verify(source); - EasyMock.verify(target); - } - - protected void setUp() throws Exception { - super.setUp(); - WorkContext context = new WorkContextImpl(); - WireService wireService = new JDKWireService(null, null); - WorkScheduler scheduler = new MockWorkScheduler(); - connector = new ConnectorImpl(wireService, null, scheduler, context); - operation = new Operation("bar", null, null, null); - operation.setNonBlocking(true); - callbackOperation = new Operation("callback", null, null, null); - callbackOperation.setNonBlocking(true); - contract = new JavaServiceContract(); - Map> ops = new HashMap>(); - ops.put("callback", callbackOperation); - contract.setCallbackOperations(ops); - } - - private AtomicComponent createSource() throws Exception { - AtomicComponent component = EasyMock.createMock(AtomicComponent.class); - EasyMock.expect(component.getName()).andReturn("source").atLeastOnce(); - EasyMock.expect(component.isSystem()).andReturn(false).anyTimes(); - EasyMock.expect(component.createTargetInvoker(EasyMock.eq("callback"), - EasyMock.isA(Operation.class), - (InboundWire) EasyMock.isNull())).andReturn(EasyMock.createNiceMock(TargetInvoker.class)); - EasyMock.replay(component); - return component; - } - - private class MockInterceptor implements Interceptor { - - public Message invoke(Message msg) { - return msg; - } - - public void setNext(Interceptor next) { - - } - - public Interceptor getNext() { - return null; - } - - public boolean isOptimizable() { - return false; - } - } - - private class MockWorkScheduler implements WorkScheduler { - - public void scheduleWork(T work, NotificationListener listener) { - throw new UnsupportedOperationException(); - } - - public void scheduleWork(T work) { - work.run(); - } - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/NonBlockingForwardSyncCallbackConnectionTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/NonBlockingForwardSyncCallbackConnectionTestCase.java deleted file mode 100644 index 0e425b73bf..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/NonBlockingForwardSyncCallbackConnectionTestCase.java +++ /dev/null @@ -1,171 +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.util.Map; -import java.util.HashMap; - -import org.apache.tuscany.spi.model.Operation; -import org.apache.tuscany.spi.model.ServiceContract; -import org.apache.tuscany.spi.component.AtomicComponent; -import org.apache.tuscany.spi.component.WorkContext; -import org.apache.tuscany.spi.wire.InboundWire; -import org.apache.tuscany.spi.wire.TargetInvoker; -import org.apache.tuscany.spi.wire.InboundInvocationChain; -import org.apache.tuscany.spi.wire.OutboundWire; -import org.apache.tuscany.spi.wire.OutboundInvocationChain; -import org.apache.tuscany.spi.wire.Message; -import org.apache.tuscany.spi.wire.MessageImpl; -import org.apache.tuscany.spi.wire.WireService; -import org.apache.tuscany.spi.wire.Interceptor; -import org.apache.tuscany.spi.QualifiedName; -import org.apache.tuscany.spi.idl.java.JavaServiceContract; -import org.apache.tuscany.spi.services.work.WorkScheduler; -import org.apache.tuscany.spi.services.work.NotificationListener; - -import junit.framework.TestCase; -import org.easymock.EasyMock; -import org.apache.tuscany.core.wire.InboundWireImpl; -import org.apache.tuscany.core.wire.InboundInvocationChainImpl; -import org.apache.tuscany.core.wire.OutboundWireImpl; -import org.apache.tuscany.core.wire.OutboundInvocationChainImpl; -import org.apache.tuscany.core.wire.jdk.JDKWireService; -import org.apache.tuscany.core.component.WorkContextImpl; - -/** - * Verifies connections with non-blocking forward and synchronous callback invocations - * - * @version $Rev$ $Date$ - */ -public class NonBlockingForwardSyncCallbackConnectionTestCase extends TestCase { - private Operation operation; - private Operation callbackOperation; - private ServiceContract contract; - private ConnectorImpl connector; - - public void testNonBlockingForwardAndSyncCallbackAtomicToAtomic() throws Exception { - AtomicComponent target = EasyMock.createMock(AtomicComponent.class); - EasyMock.expect(target.isSystem()).andReturn(false).anyTimes(); - EasyMock.expect(target.getName()).andReturn("target").anyTimes(); - EasyMock.expect(target.createTargetInvoker(EasyMock.eq("service"), - EasyMock.isA(Operation.class), - EasyMock.isA(InboundWire.class))).andReturn(EasyMock.createNiceMock(TargetInvoker.class)); - EasyMock.replay(target); - - InboundWire inboundWire = new InboundWireImpl(); - inboundWire.setContainer(target); - inboundWire.setServiceContract(contract); - InboundInvocationChain inboundChain = new InboundInvocationChainImpl(operation); - inboundChain.addInterceptor(new NonBlockingForwardSyncCallbackConnectionTestCase.MockInterceptor()); - inboundWire.addInvocationChain(operation, inboundChain); - - AtomicComponent source = createSource(); - OutboundWire outboundWire = new OutboundWireImpl(); - outboundWire.setContainer(source); - outboundWire.setServiceContract(contract); - outboundWire.setTargetName(new QualifiedName("target/service")); - OutboundInvocationChain outboundChain = new OutboundInvocationChainImpl(operation); - outboundWire.addInvocationChain(operation, outboundChain); - - InboundInvocationChain callbackInboundChain = new InboundInvocationChainImpl(callbackOperation); - callbackInboundChain.addInterceptor(new NonBlockingForwardSyncCallbackConnectionTestCase.MockInterceptor()); - Map, InboundInvocationChain> chains = new HashMap, InboundInvocationChain>(); - chains.put(callbackOperation, callbackInboundChain); - outboundWire.addTargetCallbackInvocationChains(chains); - - connector.connect(outboundWire, inboundWire, true); - - // test the forward request - Message msg = new MessageImpl(); - msg.setBody("foo"); - Message ret = outboundChain.getHeadInterceptor().invoke(msg); - assertEquals(null, ret.getBody()); - - // test the callback - msg = new MessageImpl(); - msg.setBody("callback"); - Map, OutboundInvocationChain> callbackChains = - inboundWire.getSourceCallbackInvocationChains("source"); - OutboundInvocationChain callbackInvocationChain = callbackChains.get(callbackOperation); - ret = callbackInvocationChain.getHeadInterceptor().invoke(msg); - assertEquals("callback", ret.getBody()); - - EasyMock.verify(source); - EasyMock.verify(target); - } - - - protected void setUp() throws Exception { - super.setUp(); - WorkContext context = new WorkContextImpl(); - WireService wireService = new JDKWireService(null, null); - WorkScheduler scheduler = new NonBlockingForwardSyncCallbackConnectionTestCase.MockWorkScheduler(); - connector = new ConnectorImpl(wireService, null, scheduler, context); - operation = new Operation("bar", null, null, null); - operation.setNonBlocking(true); - callbackOperation = new Operation("callback", null, null, null); - contract = new JavaServiceContract(); - Map> ops = new HashMap>(); - ops.put("callback", callbackOperation); - contract.setCallbackOperations(ops); - } - - private AtomicComponent createSource() throws Exception { - AtomicComponent component = EasyMock.createMock(AtomicComponent.class); - EasyMock.expect(component.getName()).andReturn("source").atLeastOnce(); - EasyMock.expect(component.isSystem()).andReturn(false).anyTimes(); - EasyMock.expect(component.createTargetInvoker(EasyMock.eq("callback"), - EasyMock.isA(Operation.class), - (InboundWire) EasyMock.isNull())).andReturn(EasyMock.createNiceMock(TargetInvoker.class)); - EasyMock.replay(component); - return component; - } - - private class MockInterceptor implements Interceptor { - - public Message invoke(Message msg) { - return msg; - } - - public void setNext(Interceptor next) { - - } - - public Interceptor getNext() { - return null; - } - - public boolean isOptimizable() { - return false; - } - } - - private class MockWorkScheduler implements WorkScheduler { - - public void scheduleWork(T work, NotificationListener listener) { - throw new UnsupportedOperationException(); - } - - public void scheduleWork(T work) { - work.run(); - } - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/OutboundToInboundConnectTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/OutboundToInboundConnectTestCase.java deleted file mode 100644 index 2c8e2c3fa8..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/OutboundToInboundConnectTestCase.java +++ /dev/null @@ -1,184 +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.idl.InvalidServiceContractException; -import org.apache.tuscany.spi.idl.java.JavaInterfaceProcessorRegistry; -import org.apache.tuscany.spi.model.Operation; -import org.apache.tuscany.spi.model.ServiceContract; -import org.apache.tuscany.spi.wire.InboundInvocationChain; -import org.apache.tuscany.spi.wire.Interceptor; -import org.apache.tuscany.spi.wire.Message; -import org.apache.tuscany.spi.wire.MessageImpl; -import org.apache.tuscany.spi.wire.OutboundInvocationChain; -import org.apache.tuscany.spi.wire.TargetInvoker; -import static org.apache.tuscany.spi.wire.TargetInvoker.NONE; - -import junit.framework.TestCase; -import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl; -import org.apache.tuscany.core.mock.component.SimpleTarget; -import org.apache.tuscany.core.mock.wire.MockSyncInterceptor; -import org.apache.tuscany.core.wire.InboundInvocationChainImpl; -import org.apache.tuscany.core.wire.InvokerInterceptor; -import org.apache.tuscany.core.wire.OutboundInvocationChainImpl; -import org.easymock.EasyMock; -import static org.easymock.EasyMock.createNiceMock; -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.replay; -import static org.easymock.EasyMock.verify; - -/** - * Verifies connection strategies between {@link org.apache.tuscany.spi.wire.OutboundInvocationChain}s and {@link - * org.apache.tuscany.spi.wire.InboundInvocationChain}s - * - * @version $$Rev$$ $$Date$$ - */ -public class OutboundToInboundConnectTestCase extends TestCase { - - public void testNoInterceptorsNoHandlers() throws Exception { - ConnectorImpl connector = new ConnectorImpl(); - InboundInvocationChain inboundChain = setupTarget(null); - OutboundInvocationChain outboundChain = setupSource(null); - String[] val = new String[]{"foo"}; - TargetInvoker invoker = createNiceMock(TargetInvoker.class); - expect(invoker.invokeTarget(EasyMock.eq(val), EasyMock.eq(NONE))).andReturn(val); - replay(invoker); - connector.connect(outboundChain, inboundChain, invoker, false); - inboundChain.prepare(); - assertEquals(val, outboundChain.getTargetInvoker().invokeTarget(val, NONE)); - verify(invoker); - } - - - /** - * Verifies an invocation with a single source interceptor - */ - public void testSourceInterceptor() throws Exception { - ConnectorImpl connector = new ConnectorImpl(); - MockSyncInterceptor interceptor = new MockSyncInterceptor(); - List interceptors = new ArrayList(); - interceptors.add(interceptor); - OutboundInvocationChain outboundChain = setupSource(interceptors); - InboundInvocationChain inboundChain = setupTarget(null); - Message msg = new MessageImpl(); - TargetInvoker invoker = createNiceMock(TargetInvoker.class); - expect(invoker.invoke(EasyMock.eq(msg))).andReturn(msg); - replay(invoker); - assertEquals(0, interceptor.getCount()); - connector.connect(outboundChain, inboundChain, invoker, false); - inboundChain.prepare(); - msg.setTargetInvoker(outboundChain.getTargetInvoker()); - assertEquals(msg, outboundChain.getHeadInterceptor().invoke(msg)); - assertEquals(1, interceptor.getCount()); - verify(invoker); - } - - /** - * Verifies an invocation with a single target interceptor - */ - public void testTargetInterceptor() throws Exception { - ConnectorImpl connector = new ConnectorImpl(); - MockSyncInterceptor interceptor = new MockSyncInterceptor(); - List interceptors = new ArrayList(); - interceptors.add(interceptor); - OutboundInvocationChain outboundChain = setupSource(null); - InboundInvocationChain inboundChain = setupTarget(interceptors); - Message msg = new MessageImpl(); - TargetInvoker invoker = createNiceMock(TargetInvoker.class); - expect(invoker.invoke(EasyMock.eq(msg))).andReturn(msg); - replay(invoker); - assertEquals(0, interceptor.getCount()); - connector.connect(outboundChain, inboundChain, invoker, false); - inboundChain.prepare(); - msg.setTargetInvoker(outboundChain.getTargetInvoker()); - assertEquals(msg, outboundChain.getHeadInterceptor().invoke(msg)); - assertEquals(1, interceptor.getCount()); - verify(invoker); - } - - /** - * Verifies an invocation with a source and target interceptor - */ - public void testSourceTargetInterceptor() throws Exception { - ConnectorImpl connector = new ConnectorImpl(); - MockSyncInterceptor sourceInterceptor = new MockSyncInterceptor(); - List sourceInterceptors = new ArrayList(); - sourceInterceptors.add(sourceInterceptor); - MockSyncInterceptor targetInterceptor = new MockSyncInterceptor(); - List targetInterceptors = new ArrayList(); - targetInterceptors.add(targetInterceptor); - OutboundInvocationChain outboundChain = setupSource(sourceInterceptors); - InboundInvocationChain inboundChain = setupTarget(targetInterceptors); - Message msg = new MessageImpl(); - TargetInvoker invoker = createNiceMock(TargetInvoker.class); - expect(invoker.invoke(EasyMock.eq(msg))).andReturn(msg); - replay(invoker); - assertEquals(0, sourceInterceptor.getCount()); - assertEquals(0, targetInterceptor.getCount()); - connector.connect(outboundChain, inboundChain, invoker, false); - inboundChain.prepare(); - msg.setTargetInvoker(outboundChain.getTargetInvoker()); - assertEquals(msg, outboundChain.getHeadInterceptor().invoke(msg)); - assertEquals(1, sourceInterceptor.getCount()); - assertEquals(1, targetInterceptor.getCount()); - verify(invoker); - } - - - public InboundInvocationChain setupTarget(List interceptors) { - JavaInterfaceProcessorRegistry registry = new JavaInterfaceProcessorRegistryImpl(); - ServiceContract contract; - try { - contract = registry.introspect(SimpleTarget.class); - } catch (InvalidServiceContractException e) { - throw new AssertionError(); - } - Operation operation = contract.getOperations().get("echo"); - InboundInvocationChainImpl chain = new InboundInvocationChainImpl(operation); - if (interceptors != null) { - for (Interceptor interceptor : interceptors) { - chain.addInterceptor(interceptor); - } - } - chain.addInterceptor(new InvokerInterceptor()); // add tail interceptor - return chain; - } - - public OutboundInvocationChain setupSource(List interceptors) { - JavaInterfaceProcessorRegistry registry = new JavaInterfaceProcessorRegistryImpl(); - ServiceContract contract; - try { - contract = registry.introspect(SimpleTarget.class); - } catch (InvalidServiceContractException e) { - throw new AssertionError(); - } - Operation operation = contract.getOperations().get("echo"); - OutboundInvocationChainImpl chain = new OutboundInvocationChainImpl(operation); - if (interceptors != null) { - for (Interceptor interceptor : interceptors) { - chain.addInterceptor(interceptor); - } - } - return chain; - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/ReferenceConnectorTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/ReferenceConnectorTestCase.java deleted file mode 100644 index 2aa6d0247a..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/ReferenceConnectorTestCase.java +++ /dev/null @@ -1,168 +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.component.AtomicComponent; -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.component.Reference; -import org.apache.tuscany.spi.component.ReferenceBinding; -import org.apache.tuscany.spi.model.Operation; -import org.apache.tuscany.spi.model.ServiceContract; -import org.apache.tuscany.spi.wire.InboundInvocationChain; -import org.apache.tuscany.spi.wire.InboundWire; -import org.apache.tuscany.spi.wire.Interceptor; -import org.apache.tuscany.spi.wire.Message; -import org.apache.tuscany.spi.wire.MessageImpl; -import org.apache.tuscany.spi.wire.OutboundInvocationChain; -import org.apache.tuscany.spi.wire.OutboundWire; - -import org.apache.tuscany.core.implementation.composite.ReferenceImpl; -import org.apache.tuscany.core.wire.InboundInvocationChainImpl; -import org.apache.tuscany.core.wire.InboundWireImpl; -import org.apache.tuscany.core.wire.InvokerInterceptor; -import org.apache.tuscany.core.wire.OutboundInvocationChainImpl; -import org.apache.tuscany.core.wire.OutboundWireImpl; -import org.easymock.EasyMock; - -/** - * @version $Rev$ $Date$ - */ -public class ReferenceConnectorTestCase extends AbstractConnectorImplTestCase { - private AtomicComponent source; - private CompositeComponent parent; - - public void testConnectReferenceWiresNoInboundInterceptors() throws Exception { - InboundInvocationChain inboundChain = new InboundInvocationChainImpl(operation); - InboundWire inboundWire = new InboundWireImpl(); - inboundWire.setServiceContract(contract); - inboundWire.addInvocationChain(operation, inboundChain); - - OutboundInvocationChain outboundChain = new OutboundInvocationChainImpl(operation); - // Outbound chains always contains at least one interceptor - outboundChain.addInterceptor(new InvokerInterceptor()); - OutboundWire outboundWire = new OutboundWireImpl(); - outboundWire.setServiceContract(contract); - outboundWire.setTargetName(TARGET_SERVICE_NAME); - outboundWire.addInvocationChain(operation, outboundChain); - - ReferenceBinding referenceBinding = EasyMock.createMock(ReferenceBinding.class); - referenceBinding.setReference(EasyMock.isA(Reference.class)); - EasyMock.expect(referenceBinding.createTargetInvoker(contract, operation)).andReturn(null); - EasyMock.expect(referenceBinding.getInboundWire()).andReturn(inboundWire); - EasyMock.expect(referenceBinding.getOutboundWire()).andReturn(outboundWire); - EasyMock.expect(referenceBinding.isSystem()).andReturn(false).atLeastOnce(); - EasyMock.replay(referenceBinding); - inboundWire.setContainer(referenceBinding); - outboundWire.setContainer(referenceBinding); - - Reference reference = new ReferenceImpl("foo", parent, contract); - reference.addReferenceBinding(referenceBinding); - - connector.connect(reference); - - EasyMock.verify(referenceBinding); - Interceptor interceptor = inboundChain.getHeadInterceptor(); - MessageImpl msg = new MessageImpl(); - msg.setTargetInvoker(new MockInvoker()); - Message resp = interceptor.invoke(msg); - assertEquals(RESPONSE, resp.getBody()); - } - - public void testConnectReferenceWiresWithInboundInterceptors() throws Exception { - MockInterceptor inboundInterceptor = new MockInterceptor(); - InboundInvocationChain inboundChain = new InboundInvocationChainImpl(operation); - inboundChain.addInterceptor(inboundInterceptor); - InboundWire inboundWire = new InboundWireImpl(); - inboundWire.setServiceContract(contract); - inboundWire.addInvocationChain(operation, inboundChain); - - OutboundInvocationChain outboundChain = new OutboundInvocationChainImpl(operation); - // Outbound always contains at lease one interceptor - outboundChain.addInterceptor(new InvokerInterceptor()); - OutboundWire outboundWire = new OutboundWireImpl(); - outboundWire.setServiceContract(contract); - outboundWire.setTargetName(TARGET_SERVICE_NAME); - outboundWire.addInvocationChain(operation, outboundChain); - - ReferenceBinding referenceBinding = EasyMock.createMock(ReferenceBinding.class); - referenceBinding.setReference(EasyMock.isA(Reference.class)); - EasyMock.expect(referenceBinding.createTargetInvoker(contract, operation)).andReturn(null); - EasyMock.expect(referenceBinding.getInboundWire()).andReturn(inboundWire); - EasyMock.expect(referenceBinding.getOutboundWire()).andReturn(outboundWire); - EasyMock.expect(referenceBinding.isSystem()).andReturn(false); - EasyMock.replay(referenceBinding); - inboundWire.setContainer(referenceBinding); - outboundWire.setContainer(referenceBinding); - - Reference reference = new ReferenceImpl("foo", parent, contract); - reference.addReferenceBinding(referenceBinding); - - connector.connect(reference); - - EasyMock.verify(referenceBinding); - Interceptor interceptor = inboundChain.getHeadInterceptor(); - MessageImpl msg = new MessageImpl(); - msg.setTargetInvoker(new MockInvoker()); - Message resp = interceptor.invoke(msg); - assertEquals(RESPONSE, resp.getBody()); - assertTrue(inboundInterceptor.isInvoked()); - } - - public void testOutboundWireToInboundReferenceTarget() throws Exception { - AtomicComponent component = EasyMock.createMock(AtomicComponent.class); - EasyMock.expect(component.getName()).andReturn("foo"); - EasyMock.replay(component); - - ReferenceBinding target = EasyMock.createMock(ReferenceBinding.class); - EasyMock.expect(target.createTargetInvoker(EasyMock.isA(ServiceContract.class), EasyMock.isA(Operation.class))) - .andReturn(new MockInvoker()); - EasyMock.replay(target); - - InboundInvocationChain inboundChain = new InboundInvocationChainImpl(operation); - inboundChain.addInterceptor(new InvokerInterceptor()); - InboundWire targetWire = new InboundWireImpl(); - targetWire.setServiceContract(contract); - targetWire.addInvocationChain(operation, inboundChain); - targetWire.setContainer(target); - - // create the outbound wire and chain from the source component - OutboundInvocationChain sourceChain = new OutboundInvocationChainImpl(operation); - OutboundWire sourceWire = new OutboundWireImpl(); - sourceWire.setServiceContract(contract); - sourceWire.setTargetName(TARGET_SERVICE_NAME); - sourceWire.addInvocationChain(operation, sourceChain); - sourceWire.setContainer(component); - sourceWire.setContainer(source); - - connector.connect(sourceWire, targetWire, false); - Interceptor interceptor = sourceChain.getHeadInterceptor(); - MessageImpl msg = new MessageImpl(); - msg.setTargetInvoker(new MockInvoker()); - Message resp = interceptor.invoke(msg); - assertEquals(RESPONSE, resp.getBody()); - } - - protected void setUp() throws Exception { - super.setUp(); - parent = EasyMock.createNiceMock(CompositeComponent.class); - source = EasyMock.createNiceMock(AtomicComponent.class); - EasyMock.replay(source); - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/ServiceConnectorTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/ServiceConnectorTestCase.java deleted file mode 100644 index 5de8287bdf..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/ServiceConnectorTestCase.java +++ /dev/null @@ -1,171 +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.component.AtomicComponent; -import org.apache.tuscany.spi.component.CompositeComponent; -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.model.Operation; -import org.apache.tuscany.spi.model.Scope; -import org.apache.tuscany.spi.wire.InboundInvocationChain; -import org.apache.tuscany.spi.wire.InboundWire; -import org.apache.tuscany.spi.wire.Interceptor; -import org.apache.tuscany.spi.wire.Message; -import org.apache.tuscany.spi.wire.MessageImpl; -import org.apache.tuscany.spi.wire.OutboundInvocationChain; -import org.apache.tuscany.spi.wire.OutboundWire; - -import org.apache.tuscany.core.implementation.composite.ReferenceImpl; -import org.apache.tuscany.core.implementation.composite.ServiceImpl; -import org.apache.tuscany.core.mock.binding.MockServiceBinding; -import org.apache.tuscany.core.wire.InboundInvocationChainImpl; -import org.apache.tuscany.core.wire.InboundWireImpl; -import org.apache.tuscany.core.wire.InvokerInterceptor; -import org.apache.tuscany.core.wire.OutboundInvocationChainImpl; -import org.apache.tuscany.core.wire.OutboundWireImpl; -import org.apache.tuscany.core.wire.SynchronousBridgingInterceptor; -import org.easymock.EasyMock; - -/** - * @version $Rev$ $Date$ - */ -public class ServiceConnectorTestCase extends AbstractConnectorImplTestCase { - private CompositeComponent parent; - private InboundInvocationChain inboundChain; - private ServiceBinding sourceServiceBinding; - - public void testConnectServiceToAtomicComponent() throws Exception { - configureAtomicTarget(); - Service sourceService = new ServiceImpl("foo", parent, contract); - sourceService.addServiceBinding(sourceServiceBinding); - connector.connect(sourceService); - Interceptor interceptor = inboundChain.getHeadInterceptor(); - MessageImpl msg = new MessageImpl(); - msg.setTargetInvoker(new MockInvoker()); - Message resp = interceptor.invoke(msg); - assertEquals(RESPONSE, resp.getBody()); - } - - public void testConnectServiceToChildCompositeService() throws Exception { - configureChildCompositeServiceTarget(); - Service sourceService = new ServiceImpl("foo", parent, contract); - sourceService.addServiceBinding(sourceServiceBinding); - connector.connect(sourceService); - Interceptor interceptor = inboundChain.getHeadInterceptor(); - MessageImpl msg = new MessageImpl(); - msg.setTargetInvoker(new MockInvoker()); - Message resp = interceptor.invoke(msg); - assertEquals(RESPONSE, resp.getBody()); - } - - public void testConnectServiceToReference() throws Exception { - configureReferenceTarget(); - Service sourceService = new ServiceImpl("foo", parent, contract); - sourceService.addServiceBinding(sourceServiceBinding); - connector.connect(sourceService); - Interceptor interceptor = inboundChain.getHeadInterceptor(); - MessageImpl msg = new MessageImpl(); - msg.setTargetInvoker(new MockInvoker()); - Message resp = interceptor.invoke(msg); - assertEquals(RESPONSE, resp.getBody()); - } - - protected void setUp() throws Exception { - super.setUp(); - inboundChain = new InboundInvocationChainImpl(operation); - InboundWire inboundWire = new InboundWireImpl(); - inboundWire.setServiceContract(contract); - inboundWire.addInvocationChain(operation, inboundChain); - - OutboundInvocationChain outboundChain = new OutboundInvocationChainImpl(operation); - // Outbound chains always contains at least one interceptor - outboundChain.addInterceptor(new SynchronousBridgingInterceptor()); - OutboundWire outboundWire = new OutboundWireImpl(); - outboundWire.setServiceContract(contract); - outboundWire.setTargetName(TARGET_SERVICE_NAME); - outboundWire.addInvocationChain(operation, outboundChain); - - sourceServiceBinding = new MockServiceBinding(); - sourceServiceBinding.setInboundWire(inboundWire); - sourceServiceBinding.setOutboundWire(outboundWire); - inboundWire.setContainer(sourceServiceBinding); - outboundWire.setContainer(sourceServiceBinding); - - } - - private void configureAtomicTarget() throws Exception { - InboundInvocationChain inboundChain = new InboundInvocationChainImpl(operation); - inboundChain.addInterceptor(new InvokerInterceptor()); - InboundWire inboundWire = new InboundWireImpl(); - inboundWire.setServiceContract(contract); - inboundWire.addInvocationChain(operation, inboundChain); - - AtomicComponent atomicTarget = EasyMock.createMock(AtomicComponent.class); - EasyMock.expect(atomicTarget.getInboundWire(EasyMock.isA(String.class))).andReturn(inboundWire).atLeastOnce(); - EasyMock.expect(atomicTarget.getScope()).andReturn(Scope.COMPOSITE); - EasyMock.expect(atomicTarget.createTargetInvoker(EasyMock.isA(String.class), - EasyMock.isA(Operation.class), - EasyMock.isA(InboundWire.class))).andReturn(new MockInvoker()); - EasyMock.replay(atomicTarget); - - inboundWire.setContainer(atomicTarget); - - parent = EasyMock.createNiceMock(CompositeComponent.class); - EasyMock.expect(parent.getChild(TARGET)).andReturn(atomicTarget); - EasyMock.replay(parent); - } - - private void configureChildCompositeServiceTarget() throws Exception { - InboundInvocationChain inboundChain = new InboundInvocationChainImpl(operation); - inboundChain.addInterceptor(new InvokerInterceptor()); - InboundWire inboundWire = new InboundWireImpl(); - inboundWire.setServiceContract(contract); - inboundWire.addInvocationChain(operation, inboundChain); - - CompositeComponent compositeTarget = EasyMock.createMock(CompositeComponent.class); - Service service = createLocalService(compositeTarget); - ServiceBinding binding = service.getServiceBindings().get(0); - EasyMock.expect(compositeTarget.getInboundWire(TARGET_SERVICE)).andReturn(binding.getInboundWire()); - EasyMock.expect(compositeTarget.getScope()).andReturn(Scope.SYSTEM).anyTimes(); - EasyMock.replay(compositeTarget); - - inboundWire.setContainer(compositeTarget); - - parent = EasyMock.createNiceMock(CompositeComponent.class); - EasyMock.expect(parent.getChild(TARGET)).andReturn(compositeTarget); - EasyMock.replay(parent); - } - - - private void configureReferenceTarget() throws Exception { - ReferenceBinding binding = createLocalReferenceBinding(TARGET_NAME); - Reference referenceTarget = new ReferenceImpl(TARGET, parent, contract); - referenceTarget.addReferenceBinding(binding); - // put a terminating interceptor on the outbound wire of the reference for testing an invocation - binding.getOutboundWire().getInvocationChains().get(operation).addInterceptor(new InvokerInterceptor()); - connector.connect(binding.getInboundWire(), binding.getOutboundWire(), true); - parent = EasyMock.createNiceMock(CompositeComponent.class); - EasyMock.expect(parent.getChild(TARGET)).andReturn(referenceTarget); - EasyMock.replay(parent); - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/SynchronousForwardCallbackConnectionTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/SynchronousForwardCallbackConnectionTestCase.java deleted file mode 100644 index 9beca64444..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/SynchronousForwardCallbackConnectionTestCase.java +++ /dev/null @@ -1,256 +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.util.HashMap; -import java.util.Map; - -import org.apache.tuscany.spi.QualifiedName; -import org.apache.tuscany.spi.component.AtomicComponent; -import org.apache.tuscany.spi.component.ReferenceBinding; -import org.apache.tuscany.spi.component.ServiceBinding; -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.InboundInvocationChain; -import org.apache.tuscany.spi.wire.InboundWire; -import org.apache.tuscany.spi.wire.Interceptor; -import org.apache.tuscany.spi.wire.Message; -import org.apache.tuscany.spi.wire.MessageImpl; -import org.apache.tuscany.spi.wire.OutboundInvocationChain; -import org.apache.tuscany.spi.wire.OutboundWire; -import org.apache.tuscany.spi.wire.TargetInvoker; -import org.apache.tuscany.spi.wire.WireService; - -import junit.framework.TestCase; -import org.apache.tuscany.core.wire.InboundInvocationChainImpl; -import org.apache.tuscany.core.wire.InboundWireImpl; -import org.apache.tuscany.core.wire.OutboundInvocationChainImpl; -import org.apache.tuscany.core.wire.OutboundWireImpl; -import org.apache.tuscany.core.wire.jdk.JDKWireService; -import org.easymock.EasyMock; - -/** - * Verifies connections with synchronous forward and callback invocations - * - * @version $Rev$ $Date$ - */ -public class SynchronousForwardCallbackConnectionTestCase extends TestCase { - private Operation operation; - private Operation callbackOperation; - private ServiceContract contract; - private ConnectorImpl connector; - - public void testSyncForwardAndCallbackAtomicToAtomic() throws Exception { - AtomicComponent target = EasyMock.createMock(AtomicComponent.class); - EasyMock.expect(target.isSystem()).andReturn(false).anyTimes(); - EasyMock.expect(target.getName()).andReturn("target").anyTimes(); - EasyMock.expect(target.createTargetInvoker(EasyMock.eq("service"), - EasyMock.isA(Operation.class), - EasyMock.isA(InboundWire.class))).andReturn(EasyMock.createNiceMock(TargetInvoker.class)); - EasyMock.replay(target); - - InboundWire inboundWire = new InboundWireImpl(); - inboundWire.setContainer(target); - inboundWire.setServiceContract(contract); - InboundInvocationChain inboundChain = new InboundInvocationChainImpl(operation); - inboundChain.addInterceptor(new MockInterceptor()); - inboundWire.addInvocationChain(operation, inboundChain); - - AtomicComponent source = createSource(); - OutboundWire outboundWire = new OutboundWireImpl(); - outboundWire.setContainer(source); - outboundWire.setServiceContract(contract); - outboundWire.setTargetName(new QualifiedName("target/service")); - OutboundInvocationChain outboundChain = new OutboundInvocationChainImpl(operation); - outboundWire.addInvocationChain(operation, outboundChain); - - InboundInvocationChain callbackInboundChain = new InboundInvocationChainImpl(callbackOperation); - callbackInboundChain.addInterceptor(new MockInterceptor()); - Map, InboundInvocationChain> chains = new HashMap, InboundInvocationChain>(); - chains.put(callbackOperation, callbackInboundChain); - outboundWire.addTargetCallbackInvocationChains(chains); - - connector.connect(outboundWire, inboundWire, true); - - // test the forward request - Message msg = new MessageImpl(); - msg.setBody("foo"); - Message ret = outboundChain.getHeadInterceptor().invoke(msg); - assertEquals("foo", ret.getBody()); - - // test the callback - msg = new MessageImpl(); - msg.setBody("callback"); - Map, OutboundInvocationChain> callbackChains = - inboundWire.getSourceCallbackInvocationChains("source"); - OutboundInvocationChain callbackInvocationChain = callbackChains.get(callbackOperation); - ret = callbackInvocationChain.getHeadInterceptor().invoke(msg); - assertEquals("callback", ret.getBody()); - - EasyMock.verify(source); - EasyMock.verify(target); - } - - public void testSyncForwardAndCallbackAtomicToReferenceBinding() throws Exception { - ReferenceBinding target = EasyMock.createMock(ReferenceBinding.class); - EasyMock.expect(target.isSystem()).andReturn(false).anyTimes(); - EasyMock.expect(target.createTargetInvoker(EasyMock.isA(ServiceContract.class), - EasyMock.isA(Operation.class))).andReturn(EasyMock.createNiceMock(TargetInvoker.class)); - EasyMock.replay(target); - - InboundWire inboundWire = new InboundWireImpl(); - inboundWire.setContainer(target); - inboundWire.setServiceContract(contract); - InboundInvocationChain inboundChain = new InboundInvocationChainImpl(operation); - inboundChain.addInterceptor(new MockInterceptor()); - inboundWire.addInvocationChain(operation, inboundChain); - - AtomicComponent source = createSource(); - OutboundWire outboundWire = new OutboundWireImpl(); - outboundWire.setContainer(source); - outboundWire.setServiceContract(contract); - outboundWire.setTargetName(new QualifiedName("target/service")); - OutboundInvocationChain outboundChain = new OutboundInvocationChainImpl(operation); - outboundWire.addInvocationChain(operation, outboundChain); - - InboundInvocationChain callbackInboundChain = new InboundInvocationChainImpl(callbackOperation); - callbackInboundChain.addInterceptor(new MockInterceptor()); - Map, InboundInvocationChain> chains = new HashMap, InboundInvocationChain>(); - chains.put(callbackOperation, callbackInboundChain); - outboundWire.addTargetCallbackInvocationChains(chains); - - connector.connect(outboundWire, inboundWire, true); - // test the forward request - Message msg = new MessageImpl(); - msg.setBody("foo"); - Message ret = outboundChain.getHeadInterceptor().invoke(msg); - assertEquals("foo", ret.getBody()); - - // test the callback - msg = new MessageImpl(); - msg.setBody("callback"); - Map, OutboundInvocationChain> callbackChains = - inboundWire.getSourceCallbackInvocationChains("source"); - OutboundInvocationChain callbackInvocationChain = callbackChains.get(callbackOperation); - ret = callbackInvocationChain.getHeadInterceptor().invoke(msg); - assertEquals("callback", ret.getBody()); - - EasyMock.verify(target); - EasyMock.verify(source); - } - - public void testSyncForwardAndCallbackReferenceBindingToServiceBinding() throws Exception { - ReferenceBinding source = EasyMock.createMock(ReferenceBinding.class); - EasyMock.expect(source.isSystem()).andReturn(false).anyTimes(); - EasyMock.expect(source.getName()).andReturn("source").atLeastOnce(); - EasyMock.expect(source.createTargetInvoker(EasyMock.isA(ServiceContract.class), - EasyMock.isA(Operation.class))).andReturn(EasyMock.createNiceMock(TargetInvoker.class)); - EasyMock.replay(source); - - ServiceBinding target = EasyMock.createMock(ServiceBinding.class); - EasyMock.expect(target.isSystem()).andReturn(false).anyTimes(); - EasyMock.expect(target.createTargetInvoker(EasyMock.isA(ServiceContract.class), - EasyMock.isA(Operation.class))).andReturn(EasyMock.createNiceMock(TargetInvoker.class)); - EasyMock.replay(target); - - InboundWire inboundWire = new InboundWireImpl(); - inboundWire.setContainer(target); - inboundWire.setServiceContract(contract); - InboundInvocationChain inboundChain = new InboundInvocationChainImpl(operation); - inboundChain.addInterceptor(new MockInterceptor()); - inboundWire.addInvocationChain(operation, inboundChain); - - OutboundWire outboundWire = new OutboundWireImpl(); - outboundWire.setContainer(source); - outboundWire.setServiceContract(contract); - outboundWire.setTargetName(new QualifiedName("target/service")); - OutboundInvocationChain outboundChain = new OutboundInvocationChainImpl(operation); - outboundWire.addInvocationChain(operation, outboundChain); - - InboundInvocationChain callbackInboundChain = new InboundInvocationChainImpl(callbackOperation); - callbackInboundChain.addInterceptor(new MockInterceptor()); - Map, InboundInvocationChain> chains = new HashMap, InboundInvocationChain>(); - chains.put(callbackOperation, callbackInboundChain); - outboundWire.addTargetCallbackInvocationChains(chains); - - connector.connect(outboundWire, inboundWire, true); - // test the forward request - Message msg = new MessageImpl(); - msg.setBody("foo"); - Message ret = outboundChain.getHeadInterceptor().invoke(msg); - assertEquals("foo", ret.getBody()); - - // test the callback - msg = new MessageImpl(); - msg.setBody("callback"); - Map, OutboundInvocationChain> callbackChains = - inboundWire.getSourceCallbackInvocationChains("source"); - OutboundInvocationChain callbackInvocationChain = callbackChains.get(callbackOperation); - ret = callbackInvocationChain.getHeadInterceptor().invoke(msg); - assertEquals("callback", ret.getBody()); - - EasyMock.verify(source); - EasyMock.verify(target); - } - - protected void setUp() throws Exception { - super.setUp(); - WireService wireService = new JDKWireService(null, null); - connector = new ConnectorImpl(wireService, null, null, null); - operation = new Operation("bar", null, null, null); - callbackOperation = new Operation("callback", null, null, null); - contract = new JavaServiceContract(); - Map> ops = new HashMap>(); - ops.put("callback", callbackOperation); - contract.setCallbackOperations(ops); - } - - private AtomicComponent createSource() throws Exception { - AtomicComponent component = EasyMock.createMock(AtomicComponent.class); - EasyMock.expect(component.getName()).andReturn("source").atLeastOnce(); - EasyMock.expect(component.isSystem()).andReturn(false).anyTimes(); - EasyMock.expect(component.createTargetInvoker(EasyMock.eq("callback"), - EasyMock.isA(Operation.class), - (InboundWire) EasyMock.isNull())).andReturn(EasyMock.createNiceMock(TargetInvoker.class)); - EasyMock.replay(component); - return component; - } - - private class MockInterceptor implements Interceptor { - - public Message invoke(Message msg) { - return msg; - } - - public void setNext(Interceptor next) { - - } - - public Interceptor getNext() { - return null; - } - - public boolean isOptimizable() { - return false; - } - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/TargetServiceNotFoundExceptionTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/TargetServiceNotFoundExceptionTestCase.java deleted file mode 100644 index b6ecd952e3..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/TargetServiceNotFoundExceptionTestCase.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.builder; - -import junit.framework.TestCase; - -/** - * @version $Rev$ $Date$ - */ -public class TargetServiceNotFoundExceptionTestCase extends TestCase { - - public void testInstantiation() throws Exception { - TargetServiceNotFoundException e = new TargetServiceNotFoundException("message", - "source name", - "ref name", - "target name", - "service name"); - assertEquals("message", e.getMessage()); - assertEquals("source name", e.getSourceName()); - assertEquals("ref name", e.getReferenceName()); - assertEquals("target name", e.getTargetName()); - assertEquals("service name", e.getTargetServiceName()); - - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/WirePostProcessorRegistryImplTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/WirePostProcessorRegistryImplTestCase.java deleted file mode 100644 index 359733a4fc..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/WirePostProcessorRegistryImplTestCase.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.builder; - -import org.apache.tuscany.spi.wire.WirePostProcessor; -import org.apache.tuscany.spi.wire.WirePostProcessorRegistry; -import org.apache.tuscany.spi.wire.InboundWire; -import org.apache.tuscany.spi.wire.OutboundWire; - -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(); - OutboundWire owire = EasyMock.createMock(OutboundWire.class); - InboundWire iwire = EasyMock.createMock(InboundWire.class); - WirePostProcessor processor = createMock(WirePostProcessor.class); - processor.process(EasyMock.eq(owire), EasyMock.eq(iwire)); - EasyMock.replay(processor); - registry.register(processor); - registry.process(owire, iwire); - registry.unregister(processor); - registry.process(owire, iwire); - verify(processor); - } - - public void testProcessInboundToOutbound() throws Exception { - WirePostProcessorRegistry registry = new WirePostProcessorRegistryImpl(); - OutboundWire owire = EasyMock.createMock(OutboundWire.class); - InboundWire iwire = EasyMock.createMock(InboundWire.class); - WirePostProcessor processor = createMock(WirePostProcessor.class); - processor.process(EasyMock.eq(iwire), EasyMock.eq(owire)); - EasyMock.replay(processor); - registry.register(processor); - registry.process(iwire, owire); - verify(processor); - } - - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/WiringExceptionFormatterTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/WiringExceptionFormatterTestCase.java deleted file mode 100644 index 0269fd07e1..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/builder/WiringExceptionFormatterTestCase.java +++ /dev/null @@ -1,88 +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 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", - "source name", - "ref name", - "target name", - "service name"); - 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 name") >= 0); - assertTrue(buffer.indexOf("ref name") >= 0); - assertTrue(buffer.indexOf("target name") >= 0); - assertTrue(buffer.indexOf("service name") >= 0); - } - - - public void testFormatNulls() throws Exception { - WiringException e = new MockWiringException("message", - "identifier", - "source name", - null, - "target name", - 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); - assertTrue(buffer.indexOf("source name") >= 0); - assertTrue(buffer.indexOf("target name") >= 0); - } - - private class MockWiringException extends WiringException { - - public MockWiringException(String message, String - identifier, - String sourceName, - String referenceName, - String targetName, - String serviceName) { - super(message, identifier); - setSourceName(sourceName); - setReferenceName(referenceName); - setTargetName(targetName); - setTargetServiceName(serviceName); - } - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/WorkContextImplTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/WorkContextImplTestCase.java deleted file mode 100644 index aee910ddaf..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/WorkContextImplTestCase.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.component; - -import org.apache.tuscany.spi.component.WorkContext; - -import junit.framework.TestCase; - -/** - * @version $Rev$ $Date$ - */ -public class WorkContextImplTestCase extends TestCase { - - public void testPushPopServiceNames() throws Exception { - WorkContext context = new WorkContextImpl(); - context.pushServiceName("foo"); - context.pushServiceName("bar"); - assertEquals("bar", context.getCurrentServiceName()); - assertEquals("bar", context.popServiceName()); - assertEquals("foo", context.getCurrentServiceName()); - assertEquals("foo", context.popServiceName()); - assertNull(context.getCurrentServiceName()); - } - - public void testGetCurrentServiceNamesNull() throws Exception { - WorkContext context = new WorkContextImpl(); - assertNull(context.getCurrentServiceName()); - } - - public void testPopCurrentServiceNamesNull() throws Exception { - WorkContext context = new WorkContextImpl(); - assertNull(context.popServiceName()); - } - - public void testClearServiceNames() throws Exception { - WorkContext context = new WorkContextImpl(); - context.pushServiceName("foo"); - context.pushServiceName("bar"); - context.clearServiceNames(); - assertNull(context.getCurrentServiceName()); - } - - public void testClearServiceNamesNull() throws Exception { - WorkContext context = new WorkContextImpl(); - context.clearServiceNames(); - assertNull(context.getCurrentServiceName()); - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/event/EventTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/event/EventTestCase.java deleted file mode 100644 index 79b9757c2c..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/event/EventTestCase.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.event; - -import org.apache.tuscany.spi.component.CompositeComponent; - -import junit.framework.TestCase; -import org.easymock.EasyMock; - -/** - * @version $Rev$ $Date$ - */ -public class EventTestCase extends TestCase { - - private CompositeComponent component; - - public void testCompositeStart() { - CompositeStart event = new CompositeStart(this, component); - assertEquals(component, event.getComposite()); - } - - public void testCompositeStop() { - CompositeStop event = new CompositeStop(this, component); - assertEquals(component, event.getComposite()); - } - - 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(); - component = EasyMock.createNiceMock(CompositeComponent.class); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/AbstractScopeContainerTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/AbstractScopeContainerTestCase.java deleted file mode 100644 index f8f8dd5f60..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/AbstractScopeContainerTestCase.java +++ /dev/null @@ -1,126 +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.WorkContext; -import org.apache.tuscany.spi.event.Event; -import org.apache.tuscany.spi.event.EventFilter; -import org.apache.tuscany.spi.event.RuntimeEventListener; -import org.apache.tuscany.spi.event.TrueFilter; -import org.apache.tuscany.spi.model.Scope; - -import junit.framework.TestCase; -import org.easymock.EasyMock; - -/** - * @version $Rev$ $Date$ - */ -public class AbstractScopeContainerTestCase extends TestCase { - - public void testFireListener() { - TestContainer container = new TestContainer("foo"); - RuntimeEventListener listener = EasyMock.createMock(RuntimeEventListener.class); - Event event = new TestEvent(); - listener.onEvent(EasyMock.eq(event)); - EasyMock.replay(listener); - container.addListener(listener); - container.publish(event); - EasyMock.verify(listener); - } - - public void testRemoveListener() { - TestContainer container = new TestContainer("foo"); - RuntimeEventListener listener = EasyMock.createMock(RuntimeEventListener.class); - EasyMock.replay(listener); - Event event = new TestEvent(); - container.addListener(listener); - container.removeListener(listener); - container.publish(event); - EasyMock.verify(listener); - } - - public void testFalseFilterListener() { - TestContainer container = new TestContainer("foo"); - RuntimeEventListener listener = EasyMock.createMock(RuntimeEventListener.class); - Event event = new TestEvent(); - EasyMock.replay(listener); - container.addListener(new FalseFilter(), listener); - container.publish(event); - EasyMock.verify(listener); - } - - public void testTrueFilterListener() { - TestContainer container = new TestContainer("foo"); - RuntimeEventListener listener = EasyMock.createMock(RuntimeEventListener.class); - Event event = new TestEvent(); - listener.onEvent(EasyMock.eq(event)); - EasyMock.replay(listener); - container.addListener(new TrueFilter(), listener); - container.publish(event); - EasyMock.verify(listener); - } - - public void testToString() { - TestContainer container = new TestContainer("foo"); - assertNotNull(container.toString()); - } - - private class TestContainer extends AbstractScopeContainer { - - public TestContainer(String name) { - super(null, null); - } - - protected InstanceWrapper getInstanceWrapper(AtomicComponent component, boolean create) { - return null; - } - - public Scope getScope() { - return null; - } - - public void register(AtomicComponent component) { - - } - - public void onEvent(Event event) { - - } - - public WorkContext getWorkContext() { - return super.getWorkContext(); - } - } - - private class TestEvent implements Event { - public Object getSource() { - return null; - } - } - - private class FalseFilter implements EventFilter { - - public boolean match(Event event) { - return false; - } - } - - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/BasicCompositeScopeTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/BasicCompositeScopeTestCase.java deleted file mode 100644 index cd68b46541..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/BasicCompositeScopeTestCase.java +++ /dev/null @@ -1,127 +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.ScopeContainer; -import org.apache.tuscany.spi.component.TargetNotFoundException; - -import junit.framework.TestCase; -import org.apache.tuscany.core.component.event.CompositeStop; -import org.apache.tuscany.core.implementation.PojoConfiguration; -import org.apache.tuscany.core.implementation.system.component.SystemAtomicComponentImpl; -import org.apache.tuscany.core.injection.EventInvoker; -import org.apache.tuscany.core.injection.MethodEventInvoker; -import org.apache.tuscany.core.injection.PojoObjectFactory; -import org.apache.tuscany.core.mock.component.CompositeScopeInitDestroyComponent; - -/** - * @version $$Rev$$ $$Date$$ - */ -public class BasicCompositeScopeTestCase extends TestCase { - - private EventInvoker initInvoker; - private EventInvoker destroyInvoker; - private PojoObjectFactory factory; - - public void testLifecycleManagement() throws Exception { - CompositeScopeContainer scopeContext = new CompositeScopeContainer(null); - scopeContext.start(); - AtomicComponent component = createComponent(scopeContext); - // start the request - CompositeScopeInitDestroyComponent o1 = - (CompositeScopeInitDestroyComponent) scopeContext.getInstance(component); - assertTrue(o1.isInitialized()); - assertFalse(o1.isDestroyed()); - CompositeScopeInitDestroyComponent o2 = - (CompositeScopeInitDestroyComponent) scopeContext.getInstance(component); - assertEquals(o1, o2); - scopeContext.onEvent(new CompositeStop(this, null)); - assertTrue(o1.isDestroyed()); - scopeContext.stop(); - } - - - public void testGetAssociatedInstance() throws Exception { - CompositeScopeContainer scopeContext = new CompositeScopeContainer(null); - scopeContext.start(); - AtomicComponent component = createComponent(scopeContext); - // start the request - scopeContext.getInstance(component); - scopeContext.getAssociatedInstance(component); - } - - public void testGetAssociatedInstanceNonExistent() throws Exception { - CompositeScopeContainer scopeContext = new CompositeScopeContainer(null); - scopeContext.start(); - AtomicComponent component = createComponent(scopeContext); - // start the request - try { - scopeContext.getAssociatedInstance(component); - fail(); - } catch (TargetNotFoundException e) { - // expected - } - } - - public void testCompositeIsolation() throws Exception { - CompositeScopeContainer scopeContext = new CompositeScopeContainer(null); - scopeContext.start(); - - AtomicComponent component = createComponent(scopeContext); - - CompositeScopeInitDestroyComponent o1 = - (CompositeScopeInitDestroyComponent) scopeContext.getInstance(component); - assertTrue(o1.isInitialized()); - assertFalse(o1.isDestroyed()); - - CompositeScopeInitDestroyComponent o2 = - (CompositeScopeInitDestroyComponent) scopeContext.getInstance(component); - assertSame(o1, o2); - scopeContext.onEvent(new CompositeStop(this, null)); - assertTrue(o1.isDestroyed()); - scopeContext.stop(); - } - - protected void setUp() throws Exception { - super.setUp(); - factory = new PojoObjectFactory( - CompositeScopeInitDestroyComponent.class.getConstructor((Class[]) null)); - initInvoker = new MethodEventInvoker(CompositeScopeInitDestroyComponent.class.getMethod( - "init", (Class[]) null)); - destroyInvoker = new MethodEventInvoker(CompositeScopeInitDestroyComponent.class.getMethod( - "destroy", (Class[]) null)); - } - - protected void tearDown() throws Exception { - super.tearDown(); - } - - private AtomicComponent createComponent(ScopeContainer scopeContainer) { - PojoConfiguration configuration = new PojoConfiguration(); - configuration.setInstanceFactory(factory); - configuration.setInitInvoker(initInvoker); - configuration.setDestroyInvoker(destroyInvoker); - configuration.setName("foo"); - SystemAtomicComponentImpl component = new SystemAtomicComponentImpl(configuration); - component.setScopeContainer(scopeContainer); - component.start(); - return component; - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/BasicConversationalScopeTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/BasicConversationalScopeTestCase.java deleted file mode 100644 index c97f3cb96f..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/BasicConversationalScopeTestCase.java +++ /dev/null @@ -1,129 +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.ScopeContainer; -import org.apache.tuscany.spi.component.WorkContext; -import org.apache.tuscany.spi.model.Scope; -import org.apache.tuscany.spi.services.store.StoreMonitor; - -import junit.framework.TestCase; -import org.apache.tuscany.core.component.WorkContextImpl; -import org.apache.tuscany.core.component.event.ConversationEnd; -import org.apache.tuscany.core.implementation.PojoConfiguration; -import org.apache.tuscany.core.implementation.system.component.SystemAtomicComponentImpl; -import org.apache.tuscany.core.injection.EventInvoker; -import org.apache.tuscany.core.injection.MethodEventInvoker; -import org.apache.tuscany.core.injection.PojoObjectFactory; -import org.apache.tuscany.core.mock.component.ConversationalScopeInitDestroyComponent; -import org.apache.tuscany.core.services.store.memory.MemoryStore; -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 EventInvoker initInvoker; - private EventInvoker destroyInvoker; - private PojoObjectFactory factory; - - public void testLifecycleManagement() throws Exception { - StoreMonitor monitor = EasyMock.createMock(StoreMonitor.class); - monitor.start(EasyMock.isA(String.class)); - monitor.stop(EasyMock.isA(String.class)); - MemoryStore store = new MemoryStore(monitor); - WorkContext workContext = new WorkContextImpl(); - ConversationalScopeContainer scopeContext = new ConversationalScopeContainer(store, workContext, null); - scopeContext.start(); - AtomicComponent atomicContext = createContext(scopeContext); - // start the request - String conversation = "conv"; - workContext.setIdentifier(Scope.CONVERSATION, conversation); - ConversationalScopeInitDestroyComponent o1 = - (ConversationalScopeInitDestroyComponent) scopeContext.getInstance(atomicContext); - //assertTrue(o1.isInitialized()); - assertFalse(o1.isDestroyed()); - ConversationalScopeInitDestroyComponent o2 = - (ConversationalScopeInitDestroyComponent) scopeContext.getInstance(atomicContext); - assertSame(o1, o2); - scopeContext.onEvent(new ConversationEnd(this, conversation)); - //assertTrue(o1.isDestroyed()); - scopeContext.stop(); - } - - public void testCompositeIsolation() throws Exception { - StoreMonitor monitor = EasyMock.createMock(StoreMonitor.class); - monitor.start(EasyMock.isA(String.class)); - monitor.stop(EasyMock.isA(String.class)); - MemoryStore store = new MemoryStore(monitor); - WorkContext workContext = new WorkContextImpl(); - ConversationalScopeContainer scopeContext = new ConversationalScopeContainer(store, workContext, null); - scopeContext.start(); - - AtomicComponent atomicContext = createContext(scopeContext); - - String conversation1 = "conv"; - workContext.setIdentifier(Scope.CONVERSATION, conversation1); - ConversationalScopeInitDestroyComponent o1 = - (ConversationalScopeInitDestroyComponent) scopeContext.getInstance(atomicContext); - //assertTrue(o1.isInitialized()); - assertFalse(o1.isDestroyed()); - - String conversation2 = "conv2"; - workContext.setIdentifier(Scope.CONVERSATION, conversation2); - ConversationalScopeInitDestroyComponent o2 = - (ConversationalScopeInitDestroyComponent) scopeContext.getInstance(atomicContext); - assertNotSame(o1, o2); - - scopeContext.onEvent(new ConversationEnd(this, conversation1)); - //assertTrue(o1.isDestroyed()); - assertFalse(o2.isDestroyed()); - scopeContext.onEvent(new ConversationEnd(this, conversation2)); - //assertTrue(o2.isDestroyed()); - scopeContext.stop(); - } - - protected void setUp() throws Exception { - super.setUp(); - factory = new PojoObjectFactory( - ConversationalScopeInitDestroyComponent.class.getConstructor((Class[]) null)); - initInvoker = new MethodEventInvoker( - ConversationalScopeInitDestroyComponent.class.getMethod("init", (Class[]) null)); - destroyInvoker = new MethodEventInvoker( - ConversationalScopeInitDestroyComponent.class.getMethod("destroy", (Class[]) null)); - } - - protected void tearDown() throws Exception { - super.tearDown(); - } - - private AtomicComponent createContext(ScopeContainer scopeContainer) { - PojoConfiguration configuration = new PojoConfiguration(); - configuration.setInstanceFactory(factory); - configuration.setInitInvoker(initInvoker); - configuration.setDestroyInvoker(destroyInvoker); - configuration.setName("foo"); - SystemAtomicComponentImpl component = new SystemAtomicComponentImpl(configuration); - component.setScopeContainer(scopeContainer); - component.start(); - return component; - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/BasicHttpSessionScopeTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/BasicHttpSessionScopeTestCase.java deleted file mode 100644 index 44e9bbc1d6..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/BasicHttpSessionScopeTestCase.java +++ /dev/null @@ -1,145 +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.ScopeContainer; -import org.apache.tuscany.spi.component.TargetNotFoundException; -import org.apache.tuscany.spi.component.WorkContext; -import org.apache.tuscany.spi.model.Scope; - -import junit.framework.TestCase; -import org.apache.tuscany.core.component.WorkContextImpl; -import org.apache.tuscany.core.component.event.HttpSessionEnd; -import org.apache.tuscany.core.implementation.PojoConfiguration; -import org.apache.tuscany.core.implementation.system.component.SystemAtomicComponentImpl; -import org.apache.tuscany.core.injection.EventInvoker; -import org.apache.tuscany.core.injection.MethodEventInvoker; -import org.apache.tuscany.core.injection.PojoObjectFactory; -import org.apache.tuscany.core.mock.component.SessionScopeInitDestroyComponent; - -/** - * @version $$Rev$$ $$Date$$ - */ -public class BasicHttpSessionScopeTestCase extends TestCase { - private EventInvoker initInvoker; - private EventInvoker destroyInvoker; - private PojoObjectFactory factory; - - public void testLifecycleManagement() throws Exception { - WorkContext workContext = new WorkContextImpl(); - HttpSessionScopeContainer scopeContext = new HttpSessionScopeContainer(workContext, null); - scopeContext.start(); - AtomicComponent component = createComponent(scopeContext); - // start the request - Object session = new Object(); - workContext.setIdentifier(Scope.SESSION, session); - SessionScopeInitDestroyComponent o1 = - (SessionScopeInitDestroyComponent) scopeContext.getInstance(component); - assertTrue(o1.isInitialized()); - assertFalse(o1.isDestroyed()); - SessionScopeInitDestroyComponent o2 = - (SessionScopeInitDestroyComponent) scopeContext.getInstance(component); - assertSame(o1, o2); - scopeContext.onEvent(new HttpSessionEnd(this, session)); - assertTrue(o1.isDestroyed()); - scopeContext.stop(); - } - - public void testGetAssociatedInstance() throws Exception { - WorkContext workContext = new WorkContextImpl(); - HttpSessionScopeContainer scopeContext = new HttpSessionScopeContainer(workContext, null); - scopeContext.start(); - AtomicComponent component = createComponent(scopeContext); - // start the request - Object session = new Object(); - workContext.setIdentifier(Scope.SESSION, session); - scopeContext.getInstance(component); - scopeContext.getAssociatedInstance(component); - } - - public void testGetAssociatedInstanceNonExistent() throws Exception { - WorkContext workContext = new WorkContextImpl(); - HttpSessionScopeContainer scopeContext = new HttpSessionScopeContainer(workContext, null); - scopeContext.start(); - AtomicComponent component = createComponent(scopeContext); - // start the request - Object session = new Object(); - workContext.setIdentifier(Scope.SESSION, session); - try { - scopeContext.getAssociatedInstance(component); - fail(); - } catch (TargetNotFoundException e) { - // expected - } - } - - public void testSessionIsolation() throws Exception { - WorkContext workContext = new WorkContextImpl(); - HttpSessionScopeContainer scopeContext = new HttpSessionScopeContainer(workContext, null); - scopeContext.start(); - - AtomicComponent component = createComponent(scopeContext); - - Object session1 = new Object(); - workContext.setIdentifier(Scope.SESSION, session1); - SessionScopeInitDestroyComponent o1 = - (SessionScopeInitDestroyComponent) scopeContext.getInstance(component); - assertTrue(o1.isInitialized()); - - Object session2 = new Object(); - workContext.setIdentifier(Scope.SESSION, session2); - SessionScopeInitDestroyComponent o2 = - (SessionScopeInitDestroyComponent) scopeContext.getInstance(component); - assertNotSame(o1, o2); - - scopeContext.onEvent(new HttpSessionEnd(this, session1)); - assertTrue(o1.isDestroyed()); - assertFalse(o2.isDestroyed()); - scopeContext.onEvent(new HttpSessionEnd(this, session2)); - assertTrue(o2.isDestroyed()); - scopeContext.stop(); - } - - protected void setUp() throws Exception { - super.setUp(); - factory = new PojoObjectFactory( - SessionScopeInitDestroyComponent.class.getConstructor((Class[]) null)); - initInvoker = new MethodEventInvoker( - SessionScopeInitDestroyComponent.class.getMethod("init", (Class[]) null)); - destroyInvoker = new MethodEventInvoker( - SessionScopeInitDestroyComponent.class.getMethod("destroy", (Class[]) null)); - } - - protected void tearDown() throws Exception { - super.tearDown(); - } - - private AtomicComponent createComponent(ScopeContainer scopeContainer) { - PojoConfiguration configuration = new PojoConfiguration(); - configuration.setInstanceFactory(factory); - configuration.setInitInvoker(initInvoker); - configuration.setDestroyInvoker(destroyInvoker); - configuration.setName("foo"); - SystemAtomicComponentImpl component = new SystemAtomicComponentImpl(configuration); - component.setScopeContainer(scopeContainer); - component.start(); - return component; - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/BasicRequestScopeTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/BasicRequestScopeTestCase.java deleted file mode 100644 index 435e7d29b7..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/BasicRequestScopeTestCase.java +++ /dev/null @@ -1,128 +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.ScopeContainer; -import org.apache.tuscany.spi.component.TargetNotFoundException; - -import junit.framework.TestCase; -import org.apache.tuscany.core.component.event.RequestEnd; -import org.apache.tuscany.core.implementation.PojoConfiguration; -import org.apache.tuscany.core.implementation.system.component.SystemAtomicComponentImpl; -import org.apache.tuscany.core.injection.EventInvoker; -import org.apache.tuscany.core.injection.MethodEventInvoker; -import org.apache.tuscany.core.injection.PojoObjectFactory; -import org.apache.tuscany.core.mock.component.RequestScopeInitDestroyComponent; - -/** - * @version $$Rev$$ $$Date$$ - */ -public class BasicRequestScopeTestCase extends TestCase { - private EventInvoker initInvoker; - private EventInvoker destroyInvoker; - private PojoObjectFactory factory; - - public void testLifecycleManagement() throws Exception { - RequestScopeContainer scopeContainer = new RequestScopeContainer(null, null); - scopeContainer.start(); - AtomicComponent component = createComponent(scopeContainer); - // start the request - RequestScopeInitDestroyComponent o1 = - (RequestScopeInitDestroyComponent) scopeContainer.getInstance(component); - assertTrue(o1.isInitialized()); - assertFalse(o1.isDestroyed()); - RequestScopeInitDestroyComponent o2 = - (RequestScopeInitDestroyComponent) scopeContainer.getInstance(component); - assertSame(o1, o2); - scopeContainer.onEvent(new RequestEnd(this)); - assertTrue(o1.isDestroyed()); - scopeContainer.stop(); - } - - public void testGetAssociatedInstance() throws Exception { - RequestScopeContainer scopeContainer = new RequestScopeContainer(null, null); - scopeContainer.start(); - AtomicComponent component = createComponent(scopeContainer); - // start the request - scopeContainer.getInstance(component); - scopeContainer.getAssociatedInstance(component); - scopeContainer.stop(); - } - - public void testGetAssociatedInstanceNonExistent() throws Exception { - RequestScopeContainer scopeContainer = new RequestScopeContainer(null, null); - scopeContainer.start(); - AtomicComponent component = createComponent(scopeContainer); - // start the request - try { - scopeContainer.getAssociatedInstance(component); - fail(); - } catch (TargetNotFoundException e) { - // expected - } - scopeContainer.stop(); - } - - public void testRequestIsolation() throws Exception { - RequestScopeContainer scopeContainer = new RequestScopeContainer(null, null); - scopeContainer.start(); - - AtomicComponent component = createComponent(scopeContainer); - - RequestScopeInitDestroyComponent o1 = - (RequestScopeInitDestroyComponent) scopeContainer.getInstance(component); - assertTrue(o1.isInitialized()); - scopeContainer.onEvent(new RequestEnd(this)); - assertTrue(o1.isDestroyed()); - - RequestScopeInitDestroyComponent o2 = - (RequestScopeInitDestroyComponent) scopeContainer.getInstance(component); - assertNotSame(o1, o2); - scopeContainer.onEvent(new RequestEnd(this)); - assertTrue(o2.isDestroyed()); - scopeContainer.stop(); - } - - protected void setUp() throws Exception { - super.setUp(); - factory = new PojoObjectFactory( - RequestScopeInitDestroyComponent.class.getConstructor((Class[]) null)); - initInvoker = new MethodEventInvoker( - RequestScopeInitDestroyComponent.class.getMethod("init", (Class[]) null)); - destroyInvoker = new MethodEventInvoker( - RequestScopeInitDestroyComponent.class.getMethod("destroy", (Class[]) null)); - } - - protected void tearDown() throws Exception { - super.tearDown(); - } - - private AtomicComponent createComponent(ScopeContainer scopeContainer) { - PojoConfiguration configuration = new PojoConfiguration(); - configuration.setInstanceFactory(factory); - configuration.setInitInvoker(initInvoker); - configuration.setDestroyInvoker(destroyInvoker); - configuration.setName("foo"); - SystemAtomicComponentImpl component = new SystemAtomicComponentImpl(configuration); - component.setScopeContainer(scopeContainer); - component.start(); - return component; - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/BasicStatelessScopeTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/BasicStatelessScopeTestCase.java deleted file mode 100644 index 9ca9230e5b..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/BasicStatelessScopeTestCase.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.component.scope; - -import org.apache.tuscany.spi.component.AtomicComponent; -import org.apache.tuscany.spi.component.ScopeContainer; -import org.apache.tuscany.spi.component.TargetNotFoundException; -import org.apache.tuscany.spi.component.WorkContext; - -import junit.framework.Assert; -import junit.framework.TestCase; -import org.apache.tuscany.core.component.WorkContextImpl; -import org.apache.tuscany.core.implementation.PojoConfiguration; -import org.apache.tuscany.core.implementation.system.component.SystemAtomicComponentImpl; -import org.apache.tuscany.core.injection.PojoObjectFactory; -import org.apache.tuscany.core.mock.component.StatelessComponent; -import org.apache.tuscany.core.mock.component.StatelessComponentImpl; - -/** - * Unit tests for the composite scope container - * - * @version $Rev$ $Date$ - */ -public class BasicStatelessScopeTestCase extends TestCase { - private PojoObjectFactory factory; - - /** - * Verfies instance identity is properly maintained - */ - public void testInstanceManagement() throws Exception { - WorkContext ctx = new WorkContextImpl(); - StatelessScopeContainer scope = new StatelessScopeContainer(ctx, null); - scope.start(); - AtomicComponent component1 = createComponent(scope); - scope.register(component1); - AtomicComponent component2 = createComponent(scope); - scope.register(component2); - StatelessComponentImpl comp1 = (StatelessComponentImpl) scope.getInstance(component1); - Assert.assertNotNull(comp1); - StatelessComponentImpl comp2 = (StatelessComponentImpl) scope.getInstance(component2); - Assert.assertNotNull(comp2); - Assert.assertNotSame(comp1, comp2); - scope.stop(); - } - - public void testGetAssociatedInstance() throws Exception { - WorkContext ctx = new WorkContextImpl(); - StatelessScopeContainer scope = new StatelessScopeContainer(ctx, null); - scope.start(); - AtomicComponent component1 = createComponent(scope); - scope.register(component1); - try { - // always throws an exception, which is the semantic for stateless implementations - scope.getAssociatedInstance(component1); - fail(); - } catch (TargetNotFoundException e) { - // expected - } - scope.stop(); - } - - public void testRegisterContextAfterRequest() throws Exception { - WorkContext ctx = new WorkContextImpl(); - StatelessScopeContainer scope = new StatelessScopeContainer(ctx, null); - - scope.start(); - AtomicComponent component1 = createComponent(scope); - scope.register(component1); - StatelessComponent comp1 = (StatelessComponentImpl) scope.getInstance(component1); - Assert.assertNotNull(comp1); - AtomicComponent component2 = createComponent(scope); - scope.register(component2); - StatelessComponentImpl comp2 = (StatelessComponentImpl) scope.getInstance(component2); - Assert.assertNotNull(comp2); - scope.stop(); - } - - - /** - * Tests setting no components in the scope - */ - public void testSetNullComponents() throws Exception { - WorkContext ctx = new WorkContextImpl(); - StatelessScopeContainer scope = new StatelessScopeContainer(ctx, null); - scope.start(); - scope.stop(); - } - - protected void setUp() throws Exception { - super.setUp(); - factory = - new PojoObjectFactory(StatelessComponentImpl.class.getConstructor((Class[]) null)); - - } - - private AtomicComponent createComponent(ScopeContainer scopeContainer) { - PojoConfiguration configuration = new PojoConfiguration(); - configuration.setInstanceFactory(factory); - configuration.setName("foo"); - AtomicComponent component = new SystemAtomicComponentImpl(configuration); - component.setScopeContainer(scopeContainer); - return component; - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/CompositeScopeInitDestroyErrorTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/CompositeScopeInitDestroyErrorTestCase.java deleted file mode 100644 index 8ac4ce46a4..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/CompositeScopeInitDestroyErrorTestCase.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 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 junit.framework.TestCase; -import org.apache.tuscany.core.component.event.CompositeStart; -import org.apache.tuscany.core.component.event.CompositeStop; -import org.easymock.EasyMock; - -/** - * @version $Rev$ $Date$ - */ -public class CompositeScopeInitDestroyErrorTestCase extends TestCase { - - public void testInitializeErrorMonitor() throws Exception { - ScopeContainerMonitor monitor; - monitor = EasyMock.createMock(ScopeContainerMonitor.class); - monitor.eagerInitializationError(EasyMock.isA(ObjectCreationException.class)); - EasyMock.replay(monitor); - CompositeScopeContainer scope = new CompositeScopeContainer(monitor); - scope.start(); - AtomicComponent component = EasyMock.createMock(AtomicComponent.class); - EasyMock.expect(component.getName()).andReturn("foo").atLeastOnce(); - EasyMock.expect(component.createInstance()).andThrow(new ObjectCreationException("")); - EasyMock.expect(component.getInitLevel()).andReturn(1); - EasyMock.replay(component); - scope.register(component); - scope.onEvent(new CompositeStart(this, null)); - EasyMock.verify(monitor); - } - - public void testDestroyErrorMonitor() throws Exception { - 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.getName()).andReturn("foo").atLeastOnce(); - EasyMock.expect(component.createInstance()).andReturn(new Object()); - EasyMock.expect(component.getInitLevel()).andReturn(1); - component.init(EasyMock.isA(Object.class)); - component.destroy(EasyMock.isA(Object.class)); - EasyMock.expectLastCall().andThrow(new TargetDestructionException("", "")); - EasyMock.replay(component); - scope.register(component); - scope.onEvent(new CompositeStart(this, null)); - scope.onEvent(new CompositeStop(this, null)); - EasyMock.verify(monitor); - } - - - protected void setUp() throws Exception { - super.setUp(); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/CompositeScopeInstanceLifecycleTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/CompositeScopeInstanceLifecycleTestCase.java deleted file mode 100644 index 0d70bcf252..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/CompositeScopeInstanceLifecycleTestCase.java +++ /dev/null @@ -1,186 +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.TargetException; - -import junit.framework.TestCase; -import org.apache.tuscany.core.component.event.CompositeStart; -import org.apache.tuscany.core.component.event.CompositeStop; -import org.apache.tuscany.core.mock.component.OrderedInitPojo; -import org.apache.tuscany.core.mock.component.OrderedInitPojoImpl; -import org.easymock.EasyMock; -import org.easymock.IAnswer; - -/** - * Lifecycle unit tests for the composite scope container - * - * @version $Rev$ $Date$ - */ -public class CompositeScopeInstanceLifecycleTestCase extends TestCase { - - /** - * Verify init and stop by scope container on an atomic component - * - * @throws Exception - */ - public void testInitDestroy() throws Exception { - CompositeScopeContainer scope = new CompositeScopeContainer(null); - scope.start(); - Foo comp = new Foo(); - AtomicComponent component = EasyMock.createMock(AtomicComponent.class); - EasyMock.expect(component.createInstance()).andReturn(comp); - EasyMock.expect(component.getInitLevel()).andReturn(1).atLeastOnce(); - component.init(EasyMock.eq(comp)); - component.destroy(EasyMock.eq(comp)); - EasyMock.replay(component); - scope.register(component); - scope.onEvent(new CompositeStart(this, null)); - assertNotNull(scope.getInstance(component)); - // expire composite - scope.onEvent(new CompositeStop(this, null)); - scope.stop(); - EasyMock.verify(component); - } - - /** - * Verify init and stop by scope container on an atomic component when set to eager initialize - * - * @throws Exception - */ - public void testEagerInitDestroy() throws Exception { - CompositeScopeContainer scope = new CompositeScopeContainer(null); - scope.start(); - Foo comp = new Foo(); - AtomicComponent initDestroyComponent = EasyMock.createMock(AtomicComponent.class); - EasyMock.expect(initDestroyComponent.createInstance()).andReturn(comp); - EasyMock.expect(initDestroyComponent.getInitLevel()).andReturn(1).atLeastOnce(); - initDestroyComponent.init(EasyMock.eq(comp)); - initDestroyComponent.destroy(EasyMock.eq(comp)); - EasyMock.replay(initDestroyComponent); - scope.register(initDestroyComponent); - scope.onEvent(new CompositeStart(this, null)); - // expire composite - scope.onEvent(new CompositeStop(this, null)); - scope.stop(); - EasyMock.verify(initDestroyComponent); - } - - - public void testDestroyOrder() throws Exception { - CompositeScopeContainer scope = new CompositeScopeContainer(null); - scope.start(); - - AtomicComponent oneComponent = createComponent(0); - scope.register(oneComponent); - AtomicComponent twoComponent = createComponent(0); - scope.register(twoComponent); - AtomicComponent threeComponent = createComponent(0); - scope.register(threeComponent); - - scope.onEvent(new CompositeStart(this, null)); - OrderedInitPojo one = (OrderedInitPojo) scope.getInstance(oneComponent); - assertNotNull(one); - assertEquals(1, one.getNumberInstantiated()); - assertEquals(1, one.getInitOrder()); - - OrderedInitPojo two = (OrderedInitPojo) scope.getInstance(twoComponent); - assertNotNull(two); - assertEquals(2, two.getNumberInstantiated()); - assertEquals(2, two.getInitOrder()); - - OrderedInitPojo three = (OrderedInitPojo) scope.getInstance(threeComponent); - assertNotNull(three); - assertEquals(3, three.getNumberInstantiated()); - assertEquals(3, three.getInitOrder()); - - // expire composite - scope.onEvent(new CompositeStop(this, null)); - assertEquals(0, one.getNumberInstantiated()); - scope.stop(); - EasyMock.verify(oneComponent); - EasyMock.verify(twoComponent); - EasyMock.verify(threeComponent); - } - - public void testEagerInitDestroyOrder() throws Exception { - CompositeScopeContainer scope = new CompositeScopeContainer(null); - scope.start(); - - AtomicComponent oneComponent = createComponent(1); - scope.register(oneComponent); - AtomicComponent twoComponent = createComponent(1); - scope.register(twoComponent); - AtomicComponent threeComponent = createComponent(1); - scope.register(threeComponent); - - scope.onEvent(new CompositeStart(this, null)); - OrderedInitPojo one = (OrderedInitPojo) scope.getInstance(oneComponent); - assertNotNull(one); - - OrderedInitPojo two = (OrderedInitPojo) scope.getInstance(twoComponent); - assertNotNull(two); - - OrderedInitPojo three = (OrderedInitPojo) scope.getInstance(threeComponent); - assertNotNull(three); - - // expire composite - scope.onEvent(new CompositeStop(this, null)); - assertEquals(0, one.getNumberInstantiated()); - scope.stop(); - EasyMock.verify(oneComponent); - EasyMock.verify(twoComponent); - EasyMock.verify(threeComponent); - } - - @SuppressWarnings("unchecked") - private AtomicComponent createComponent(int init) throws TargetException { - AtomicComponent component = EasyMock.createMock(AtomicComponent.class); - EasyMock.expect(component.createInstance()).andStubAnswer(new IAnswer() { - public Object answer() throws Throwable { - return new OrderedInitPojoImpl(); - } - }); - EasyMock.expect(component.getInitLevel()).andReturn(init).atLeastOnce(); - component.init(EasyMock.isA(OrderedInitPojoImpl.class)); - EasyMock.expectLastCall().andAnswer(new IAnswer() { - public Object answer() throws Throwable { - OrderedInitPojoImpl pojo = (OrderedInitPojoImpl) EasyMock.getCurrentArguments()[0]; - pojo.init(); - return null; - } - }); - component.destroy(EasyMock.isA(OrderedInitPojoImpl.class)); - EasyMock.expectLastCall().andAnswer(new IAnswer() { - public Object answer() throws Throwable { - OrderedInitPojoImpl pojo = (OrderedInitPojoImpl) EasyMock.getCurrentArguments()[0]; - pojo.destroy(); - return null; - } - }); - EasyMock.replay(component); - return component; - } - - private class Foo { - - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/CompositeScopeObjectFactoryTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/CompositeScopeObjectFactoryTestCase.java deleted file mode 100644 index 611fbfc13f..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/CompositeScopeObjectFactoryTestCase.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.scope; - -import org.apache.tuscany.spi.component.ScopeRegistry; -import org.apache.tuscany.spi.model.Scope; - -import junit.framework.TestCase; -import org.easymock.EasyMock; - -/** - * @version $Rev$ $Date$ - */ -public class CompositeScopeObjectFactoryTestCase extends TestCase { - - public void testCreation() { - ScopeRegistry registry = EasyMock.createMock(ScopeRegistry.class); - registry.registerFactory(EasyMock.isA(Scope.class), EasyMock.isA(CompositeScopeObjectFactory.class)); - - assertNotNull(new CompositeScopeObjectFactory(registry, null).getInstance()); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/CompositeScopeRestartTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/CompositeScopeRestartTestCase.java deleted file mode 100644 index 1fdaeed48c..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/CompositeScopeRestartTestCase.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.component.scope; - -import java.lang.reflect.Constructor; - -import org.apache.tuscany.spi.component.AtomicComponent; - -import junit.framework.TestCase; -import org.apache.tuscany.core.component.event.CompositeStart; -import org.apache.tuscany.core.component.event.CompositeStop; -import org.apache.tuscany.core.implementation.PojoConfiguration; -import org.apache.tuscany.core.implementation.system.component.SystemAtomicComponentImpl; -import org.apache.tuscany.core.injection.MethodEventInvoker; -import org.apache.tuscany.core.injection.PojoObjectFactory; - -/** - * Verifies the scope container properly disposes resources and canbe restarted - * - * @version $$Rev$$ $$Date$$ - */ -public class CompositeScopeRestartTestCase extends TestCase { - - public void testRestart() throws Exception { - CompositeScopeContainer scope = new CompositeScopeContainer(null); - scope.start(); - MethodEventInvoker initInvoker = - new MethodEventInvoker(InitDestroyOnce.class.getMethod("init")); - MethodEventInvoker destroyInvoker = - new MethodEventInvoker(InitDestroyOnce.class.getMethod("destroy")); - PojoConfiguration configuration = new PojoConfiguration(); - configuration.setInitInvoker(initInvoker); - configuration.setDestroyInvoker(destroyInvoker); - Constructor ctr = InitDestroyOnce.class.getConstructor((Class[]) null); - configuration.setInstanceFactory(new PojoObjectFactory(ctr)); - configuration.setName("InitDestroy"); - AtomicComponent component = new SystemAtomicComponentImpl(configuration); - component.setScopeContainer(scope); - component.start(); - - scope.onEvent(new CompositeStart(this, null)); - Object instance = component.getTargetInstance(); - assertSame(instance, component.getTargetInstance()); - - scope.onEvent(new CompositeStop(this, null)); - scope.stop(); - component.stop(); - - scope.start(); - scope.onEvent(new CompositeStart(this, null)); - component.start(); - assertNotSame(instance, component.getTargetInstance()); - scope.onEvent(new CompositeStop(this, null)); - scope.stop(); - component.stop(); - } - - public static class InitDestroyOnce { - - private boolean initialized; - private boolean destroyed; - - public InitDestroyOnce() { - } - - public void init() { - if (!initialized) { - initialized = true; - } else { - fail("Scope did not clean up properly - Init called more than once"); - } - } - - public void destroy() { - if (!destroyed) { - destroyed = true; - } else { - fail("Scope did not clean up properly - Destroyed called more than once"); - } - } - - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainerDestroyOnExpirationTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainerDestroyOnExpirationTestCase.java deleted file mode 100644 index a1a3616d0a..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainerDestroyOnExpirationTestCase.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.component.scope; - -import org.apache.tuscany.spi.component.AtomicComponent; -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.Event; -import org.apache.tuscany.spi.event.EventFilter; -import org.apache.tuscany.spi.event.RuntimeEventListener; -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.StoreReadException; -import org.apache.tuscany.spi.services.store.StoreWriteException; - -import junit.framework.TestCase; -import org.apache.tuscany.core.component.WorkContextImpl; -import org.easymock.EasyMock; - -/** - * @version $Rev$ $Date$ - */ -public class ConversationalScopeContainerDestroyOnExpirationTestCase extends TestCase { - private ScopeContainer container; - private TestStore store; - 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.getListener().onEvent(new StoreExpirationEvent(this, component, new Object())); - EasyMock.verify(component); - } - - protected void setUp() throws Exception { - super.setUp(); - component = EasyMock.createMock(AtomicComponent.class); - component.destroy(EasyMock.isA(Object.class)); - EasyMock.replay(component); - store = new TestStore(); - WorkContext context = new WorkContextImpl(); - container = new ConversationalScopeContainer(store, context, null); - container.start(); - } - - protected void tearDown() throws Exception { - super.tearDown(); - container.stop(); - } - - private class TestStore implements Store { - private RuntimeEventListener listener; - - public RuntimeEventListener getListener() { - return listener; - } - - public void insertRecord(SCAObject owner, String id, Object object, long expiration) - throws StoreWriteException { - - } - - public void updateRecord(SCAObject owner, String id, Object object, long expiration) - throws StoreWriteException { - - } - - public Object readRecord(SCAObject owner, String id) throws StoreReadException { - return null; - } - - public void removeRecord(SCAObject owner, String id) throws StoreWriteException { - - } - - public void removeRecords() throws StoreWriteException { - - } - - public void recover(RecoveryListener listener) throws StoreReadException { - - } - - public void publish(Event object) { - - } - - public void addListener(RuntimeEventListener listener) { - this.listener = listener; - } - - public void addListener(EventFilter filter, RuntimeEventListener listener) { - - } - - public void removeListener(RuntimeEventListener listener) { - - } - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainerMaxAgeTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainerMaxAgeTestCase.java deleted file mode 100644 index 79ea057652..0000000000 --- a/branches/pre-spec-changes/kernel/core/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 org.apache.tuscany.spi.component.AtomicComponent; -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 junit.framework.TestCase; -import org.apache.tuscany.core.component.WorkContextImpl; -import org.easymock.EasyMock; - -/** - * @version $Rev$ $Date$ - */ -public class ConversationalScopeContainerMaxAgeTestCase extends TestCase { - - private ScopeContainer container; - private WorkContext context; - private Store store; - private AtomicComponent component; - - public void testMaxAgeUpdate() throws Exception { - context.setIdentifier(Scope.CONVERSATION, "12345"); - container.getInstance(component); - EasyMock.verify(store); - } - - protected void setUp() throws Exception { - super.setUp(); - ConversationalScopeContainerMaxAgeTestCase.Foo foo = new ConversationalScopeContainerMaxAgeTestCase.Foo(); - context = new WorkContextImpl(); - component = EasyMock.createMock(AtomicComponent.class); - EasyMock.expect(component.getName()).andReturn("foo").atLeastOnce(); - EasyMock.expect(component.getMaxIdleTime()).andReturn(-1L).atLeastOnce(); - EasyMock.expect(component.getMaxAge()).andReturn(600000L).atLeastOnce(); - EasyMock.replay(component); - store = EasyMock.createMock(Store.class); - EasyMock.expect(store.readRecord(EasyMock.isA(SCAObject.class), EasyMock.isA(String.class))).andReturn(foo); - 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(); - } - - private class Foo { - - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainerMaxIdleTimeTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainerMaxIdleTimeTestCase.java deleted file mode 100644 index 2ba152d223..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainerMaxIdleTimeTestCase.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.component.scope; - -import org.apache.tuscany.spi.component.AtomicComponent; -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 junit.framework.TestCase; -import org.apache.tuscany.core.component.WorkContextImpl; -import org.easymock.EasyMock; - -/** - * @version $Rev$ $Date$ - */ -public class ConversationalScopeContainerMaxIdleTimeTestCase extends TestCase { - - private ScopeContainer container; - private WorkContext context; - private Store store; - private AtomicComponent component; - - public void testMaxIdleTimeUpdate() throws Exception { - context.setIdentifier(Scope.CONVERSATION, "12345"); - container.getInstance(component); - EasyMock.verify(store); - } - - protected void setUp() throws Exception { - super.setUp(); - Foo foo = new Foo(); - context = new WorkContextImpl(); - component = EasyMock.createMock(AtomicComponent.class); - EasyMock.expect(component.getName()).andReturn("foo").atLeastOnce(); - EasyMock.expect(component.getMaxIdleTime()).andReturn(600000L).atLeastOnce(); - EasyMock.replay(component); - store = EasyMock.createMock(Store.class); - EasyMock.expect(store.readRecord(EasyMock.isA(SCAObject.class), EasyMock.isA(String.class))).andReturn(foo); - store.addListener(EasyMock.isA(RuntimeEventListener.class)); - store.updateRecord(EasyMock.isA(SCAObject.class), - EasyMock.isA(String.class), - EasyMock.eq(foo), - 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(); - } - - private class Foo { - - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainerPersistenceTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainerPersistenceTestCase.java deleted file mode 100644 index ae7e91a59a..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainerPersistenceTestCase.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.component.scope; - -import java.util.UUID; - -import org.apache.tuscany.spi.component.AtomicComponent; -import org.apache.tuscany.spi.component.ScopeContainer; -import org.apache.tuscany.spi.component.TargetNotFoundException; -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 junit.framework.TestCase; -import org.apache.tuscany.core.component.WorkContextImpl; -import org.apache.tuscany.core.services.store.memory.MemoryStore; -import org.easymock.EasyMock; - -/** - * @version $Rev$ $Date$ - */ -public class ConversationalScopeContainerPersistenceTestCase extends TestCase { - private ScopeContainer container; - private WorkContext context; - - /** - * Verifies the scope container properly creates an instance - */ - public void testNotYetPersistedInMemory() 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.createInstance()).andReturn(new Foo()); - EasyMock.expect(component.getMaxAge()).andReturn(600000L).atLeastOnce(); - component.init(EasyMock.isA(Object.class)); - EasyMock.replay(component); - container.register(component); - assertTrue(container.getInstance(component) instanceof Foo); - EasyMock.verify(component); - } - - 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); - Foo foo = new Foo(); - Foo foo2 = new Foo(); - container.persistNew(component, id, foo, System.currentTimeMillis() + 100000); - assertEquals(foo, container.getInstance(component)); - container.persistNew(component, id2, foo2, System.currentTimeMillis() + 100000); - context.setIdentifier(Scope.CONVERSATION, id2); - assertEquals(foo2, container.getInstance(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); - Foo foo = new Foo(); - container.persistNew(component, id, foo, System.currentTimeMillis() + 100000); - assertEquals(foo, container.getInstance(component)); - container.persist(component, id, foo, System.currentTimeMillis() + 100000); - assertEquals(foo, container.getInstance(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.getName()).andReturn("foo").atLeastOnce(); - EasyMock.replay(component); - container.register(component); - Foo foo = new Foo(); - container.persistNew(component, id, foo, System.currentTimeMillis() + 100000); - assertEquals(foo, container.getInstance(component)); - container.remove(component); - try { - container.getAssociatedInstance(component); - fail(); - } catch (TargetNotFoundException e) { - //expected - } - EasyMock.verify(component); - } - - public void testRecreateAfterRemoveInMemory() 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.getMaxAge()).andReturn(600000L).atLeastOnce(); - component.init(EasyMock.isA(Object.class)); - EasyMock.expect(component.getMaxIdleTime()).andReturn(-1L).atLeastOnce(); - EasyMock.expect(component.createInstance()).andReturn(new Foo()); - EasyMock.replay(component); - container.register(component); - Foo foo = new Foo(); - container.persistNew(component, id, foo, System.currentTimeMillis() + 100000); - assertEquals(foo, container.getInstance(component)); - container.remove(component); - Foo foo2 = (Foo) container.getInstance(component); - assertNotNull(foo2); - assertNotSame(foo, foo2); - 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.getName()).andReturn("foo").atLeastOnce(); - EasyMock.expect(component.getMaxIdleTime()).andReturn(-1L).atLeastOnce(); - component.addListener(EasyMock.eq(container)); - EasyMock.replay(component); - container.register(component); - Foo foo = new Foo(); - container.persistNew(component, id, foo, System.currentTimeMillis() + 100000); - assertEquals(foo, container.getAssociatedInstance(component)); - assertEquals(foo, container.getAssociatedInstance(component)); - context.setIdentifier(Scope.CONVERSATION, id2); - try { - container.getAssociatedInstance(component); - fail(); - } catch (TargetNotFoundException e) { - //expected - } - EasyMock.verify(component); - } - - protected void setUp() throws Exception { - super.setUp(); - context = new WorkContextImpl(); - 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(); - } - - private class Foo { - - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeInstanceLifecycleTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeInstanceLifecycleTestCase.java deleted file mode 100644 index 782b175b47..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeInstanceLifecycleTestCase.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.component.scope; - -import org.apache.tuscany.spi.component.AtomicComponent; -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.StoreMonitor; - -import junit.framework.TestCase; -import org.apache.tuscany.core.component.WorkContextImpl; -import org.apache.tuscany.core.services.store.memory.MemoryStore; -import org.easymock.EasyMock; - -/** - * Lifecycle unit tests for the conversational scope container - * - * @version $Rev: 451895 $ $Date: 2006-10-02 02:58:18 -0400 (Mon, 02 Oct 2006) $ - */ -public class ConversationalScopeInstanceLifecycleTestCase extends TestCase { - - public void testInitRemove() throws Exception { - StoreMonitor monitor = EasyMock.createMock(StoreMonitor.class); - monitor.start(EasyMock.isA(String.class)); - monitor.stop(EasyMock.isA(String.class)); - MemoryStore store = new MemoryStore(monitor); - WorkContext ctx = new WorkContextImpl(); - ConversationalScopeContainer scope = new ConversationalScopeContainer(store, ctx, null); - scope.start(); - - Foo comp = new Foo(); - AtomicComponent component = EasyMock.createMock(AtomicComponent.class); - EasyMock.expect(component.createInstance()).andReturn(comp); - component.init(EasyMock.eq(comp)); - EasyMock.expect(component.getMaxAge()).andReturn(1L).anyTimes(); - component.addListener(EasyMock.isA(RuntimeEventListener.class)); - EasyMock.replay(component); - scope.register(component); - String convID = "ConvID"; - ctx.setIdentifier(Scope.CONVERSATION, convID); - assertNotNull(scope.getInstance(component)); - // expire - scope.remove(component); - scope.stop(); - EasyMock.verify(component); - scope.stop(); - } - - private class Foo { - - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeRestartTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeRestartTestCase.java deleted file mode 100644 index bc5ddc7c2c..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeRestartTestCase.java +++ /dev/null @@ -1,112 +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.lang.reflect.Constructor; - -import org.apache.tuscany.spi.component.AtomicComponent; -import org.apache.tuscany.spi.component.WorkContext; -import org.apache.tuscany.spi.model.Scope; -import org.apache.tuscany.spi.services.store.StoreMonitor; - -import junit.framework.TestCase; -import org.apache.tuscany.core.component.WorkContextImpl; -import org.apache.tuscany.core.component.event.ConversationEnd; -import org.apache.tuscany.core.component.event.ConversationStart; -import org.apache.tuscany.core.implementation.PojoConfiguration; -import org.apache.tuscany.core.implementation.system.component.SystemAtomicComponentImpl; -import org.apache.tuscany.core.injection.MethodEventInvoker; -import org.apache.tuscany.core.injection.PojoObjectFactory; -import org.apache.tuscany.core.services.store.memory.MemoryStore; -import org.easymock.EasyMock; - -/** - * Verifies the scope container properly disposes resources and can be restarted - * - * @version $$Rev: 471111 $$ $$Date: 2006-11-03 23:06:48 -0500 (Fri, 03 Nov 2006) $$ - */ -public class ConversationalScopeRestartTestCase extends TestCase { - - public void testRestart() throws Exception { - StoreMonitor monitor = EasyMock.createMock(StoreMonitor.class); - monitor.start(EasyMock.isA(String.class)); - monitor.stop(EasyMock.isA(String.class)); - MemoryStore store = new MemoryStore(monitor); - WorkContext ctx = new WorkContextImpl(); - ConversationalScopeContainer scope = new ConversationalScopeContainer(store, ctx, null); - scope.start(); - MethodEventInvoker initInvoker = new MethodEventInvoker( - ConversationalScopeRestartTestCase.InitDestroyOnce.class.getMethod("init")); - MethodEventInvoker destroyInvoker = - new MethodEventInvoker(InitDestroyOnce.class.getMethod("destroy")); - PojoConfiguration configuration = new PojoConfiguration(); - configuration.setInitInvoker(initInvoker); - configuration.setDestroyInvoker(destroyInvoker); - Constructor ctr = InitDestroyOnce.class.getConstructor((Class[]) null); - configuration.setInstanceFactory(new PojoObjectFactory(ctr)); - configuration.setName("InitDestroy"); - AtomicComponent component = new SystemAtomicComponentImpl(configuration); - component.setScopeContainer(scope); - component.start(); - - String conversation = "conv"; - ctx.setIdentifier(Scope.CONVERSATION, conversation); - scope.onEvent(new ConversationStart(this, conversation)); - Object instance = component.getTargetInstance(); - assertSame(instance, component.getTargetInstance()); - - scope.onEvent(new ConversationEnd(this, conversation)); - scope.stop(); - component.stop(); - - scope.start(); - scope.onEvent(new ConversationStart(this, conversation)); - component.start(); - //assertNotSame(instance, context.getServiceInstance()); - scope.onEvent(new ConversationEnd(this, conversation)); - scope.stop(); - component.stop(); - } - - public static class InitDestroyOnce { - - private boolean initialized; - private boolean destroyed; - - public InitDestroyOnce() { - } - - public void init() { - if (!initialized) { - initialized = true; - } else { - fail("Scope did not clean up properly - Init called more than once"); - } - } - - public void destroy() { - if (!destroyed) { - destroyed = true; - } else { - fail("Scope did not clean up properly - Destroyed called more than once"); - } - } - - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/DependencyLifecycleTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/DependencyLifecycleTestCase.java deleted file mode 100644 index 4a2497a725..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/DependencyLifecycleTestCase.java +++ /dev/null @@ -1,170 +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 org.apache.tuscany.spi.component.AtomicComponent; -import org.apache.tuscany.spi.component.WorkContext; -import org.apache.tuscany.spi.model.Scope; - -import junit.framework.TestCase; -import org.apache.tuscany.core.component.WorkContextImpl; -import org.apache.tuscany.core.component.event.CompositeStart; -import org.apache.tuscany.core.component.event.CompositeStop; -import org.apache.tuscany.core.component.event.HttpSessionEnd; -import org.apache.tuscany.core.component.event.RequestEnd; -import org.apache.tuscany.core.component.event.RequestStart; -import org.apache.tuscany.core.mock.component.OrderedDependentPojo; -import org.apache.tuscany.core.mock.component.OrderedDependentPojoImpl; -import org.apache.tuscany.core.mock.component.OrderedInitPojo; -import org.apache.tuscany.core.mock.component.OrderedInitPojoImpl; - -/** - * Tests dependencies are initalized and destroyed in the proper order (i.e. LIFO) - * - * @version $Rev$ $Date$ - */ -public class DependencyLifecycleTestCase extends TestCase { - - public void testInitDestroyOrderCompositeScope() throws Exception { - CompositeScopeContainer scopeCtx = new CompositeScopeContainer(null); - scopeCtx.start(); - Map contexts = MockFactory.createWiredComponents("source", - OrderedDependentPojoImpl.class, - scopeCtx, - "target", - OrderedInitPojoImpl.class, - scopeCtx); - for (AtomicComponent component : contexts.values()) { - scopeCtx.register(component); - } - AtomicComponent sourceComponent = contexts.get("source"); - AtomicComponent targetComponent = contexts.get("target"); - scopeCtx.register(sourceComponent); - scopeCtx.register(targetComponent); - scopeCtx.onEvent(new CompositeStart(this, null)); - OrderedDependentPojo source = (OrderedDependentPojo) scopeCtx.getInstance(sourceComponent); - OrderedInitPojo target = (OrderedInitPojo) scopeCtx.getInstance(targetComponent); - assertNotNull(source.getPojo()); - assertNotNull(target); - assertEquals(2, source.getNumberInstantiated()); - scopeCtx.onEvent(new CompositeStop(this, null)); - assertEquals(0, source.getNumberInstantiated()); - scopeCtx.stop(); - } - - public void testInitDestroyOrderAfterStartCompositeScope() throws Exception { - CompositeScopeContainer scopeCtx = new CompositeScopeContainer(null); - scopeCtx.start(); - Map contexts = MockFactory.createWiredComponents("source", - OrderedDependentPojoImpl.class, - scopeCtx, - "target", - OrderedInitPojoImpl.class, - scopeCtx); - AtomicComponent sourceComponent = contexts.get("source"); - AtomicComponent targetComponent = contexts.get("target"); - scopeCtx.onEvent(new CompositeStart(this, null)); - scopeCtx.register(sourceComponent); - scopeCtx.register(targetComponent); - OrderedDependentPojo source = (OrderedDependentPojo) scopeCtx.getInstance(sourceComponent); - OrderedInitPojo target = (OrderedInitPojo) scopeCtx.getInstance(targetComponent); - assertNotNull(source.getPojo()); - assertNotNull(target); - assertEquals(2, source.getNumberInstantiated()); - scopeCtx.onEvent(new CompositeStop(this, null)); - assertEquals(0, source.getNumberInstantiated()); - scopeCtx.stop(); - } - - - public void testInitDestroyOrderSessionScope() throws Exception { - WorkContext ctx = new WorkContextImpl(); - HttpSessionScopeContainer scopeCtx = new HttpSessionScopeContainer(ctx, null); - scopeCtx.start(); - Object session = new Object(); - Map contexts = MockFactory.createWiredComponents("source", - OrderedDependentPojoImpl.class, - scopeCtx, - "target", - OrderedInitPojoImpl.class, - scopeCtx); - AtomicComponent sourceComponent = contexts.get("source"); - AtomicComponent targetComponent = contexts.get("target"); - scopeCtx.register(sourceComponent); - scopeCtx.register(targetComponent); - ctx.setIdentifier(Scope.SESSION, session); - OrderedDependentPojo source = (OrderedDependentPojo) scopeCtx.getInstance(sourceComponent); - assertNotNull(source.getPojo()); - assertEquals(2, source.getNumberInstantiated()); - scopeCtx.onEvent(new HttpSessionEnd(this, session)); - assertEquals(0, source.getNumberInstantiated()); - scopeCtx.stop(); - } - - - public void testInitDestroyOrderAfterStartSessionScope() throws Exception { - WorkContext ctx = new WorkContextImpl(); - HttpSessionScopeContainer scopeCtx = new HttpSessionScopeContainer(ctx, null); - scopeCtx.start(); - Object session = new Object(); - Map contexts = MockFactory.createWiredComponents("source", - OrderedDependentPojoImpl.class, - scopeCtx, - "target", - OrderedInitPojoImpl.class, - scopeCtx); - AtomicComponent sourceComponent = contexts.get("source"); - AtomicComponent targetComponent = contexts.get("target"); - ctx.setIdentifier(Scope.SESSION, session); - scopeCtx.register(sourceComponent); - scopeCtx.register(targetComponent); - OrderedDependentPojo source = (OrderedDependentPojo) scopeCtx.getInstance(sourceComponent); - assertNotNull(source.getPojo()); - assertEquals(2, source.getNumberInstantiated()); - scopeCtx.onEvent(new HttpSessionEnd(this, session)); - assertEquals(0, source.getNumberInstantiated()); - scopeCtx.stop(); - } - - public void testInitDestroyOrderRequestScope() throws Exception { - WorkContext ctx = new WorkContextImpl(); - RequestScopeContainer scopeCtx = new RequestScopeContainer(ctx, null); - scopeCtx.start(); - scopeCtx.onEvent(new RequestStart(this)); - Map contexts = MockFactory.createWiredComponents("source", - OrderedDependentPojoImpl.class, - scopeCtx, - "target", - OrderedInitPojoImpl.class, - scopeCtx); - AtomicComponent sourceComponent = contexts.get("source"); - AtomicComponent targetComponent = contexts.get("target"); - scopeCtx.register(sourceComponent); - scopeCtx.register(targetComponent); - OrderedDependentPojo source = (OrderedDependentPojo) scopeCtx.getInstance(sourceComponent); - assertNotNull(source.getPojo()); - assertEquals(2, source.getNumberInstantiated()); - scopeCtx.onEvent(new RequestEnd(this)); - assertEquals(0, source.getNumberInstantiated()); - scopeCtx.stop(); - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/HttpSessionScopeInitDestroyErrorTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/HttpSessionScopeInitDestroyErrorTestCase.java deleted file mode 100644 index 7aa2f9a120..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/HttpSessionScopeInitDestroyErrorTestCase.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.scope; - -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.WorkContext; -import org.apache.tuscany.spi.event.RuntimeEventListener; -import org.apache.tuscany.spi.model.Scope; - -import junit.framework.TestCase; -import org.apache.tuscany.core.component.WorkContextImpl; -import org.apache.tuscany.core.component.event.HttpSessionEnd; -import org.apache.tuscany.core.component.event.HttpSessionStart; -import org.easymock.EasyMock; - -/** - * @version $Rev$ $Date$ - */ -public class HttpSessionScopeInitDestroyErrorTestCase extends TestCase { - - public void testDestroyErrorMonitor() throws Exception { - ScopeContainerMonitor monitor; - monitor = EasyMock.createMock(ScopeContainerMonitor.class); - monitor.destructionError(EasyMock.isA(TargetDestructionException.class)); - EasyMock.replay(monitor); - WorkContext workContext = new WorkContextImpl(); - HttpSessionScopeContainer scope = new HttpSessionScopeContainer(workContext, monitor); - scope.start(); - AtomicComponent component = EasyMock.createMock(AtomicComponent.class); - component.addListener(EasyMock.isA(RuntimeEventListener.class)); - EasyMock.expect(component.getName()).andReturn("foo").atLeastOnce(); - EasyMock.expect(component.createInstance()).andReturn(new Object()); - EasyMock.expect(component.isEagerInit()).andReturn(true); - component.init(EasyMock.isA(Object.class)); - component.destroy(EasyMock.isA(Object.class)); - EasyMock.expectLastCall().andThrow(new TargetDestructionException("", "")); - EasyMock.replay(component); - scope.register(component); - Object id = new Object(); - scope.onEvent(new HttpSessionStart(this, id)); - workContext.setIdentifier(Scope.SESSION, id); - scope.getInstance(component); - scope.onEvent(new HttpSessionEnd(this, id)); - EasyMock.verify(monitor); - } - - - protected void setUp() throws Exception { - super.setUp(); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/HttpSessionScopeInstanceLifecycleTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/HttpSessionScopeInstanceLifecycleTestCase.java deleted file mode 100644 index 29d6d54450..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/HttpSessionScopeInstanceLifecycleTestCase.java +++ /dev/null @@ -1,136 +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.TargetException; -import org.apache.tuscany.spi.component.WorkContext; -import org.apache.tuscany.spi.event.RuntimeEventListener; -import org.apache.tuscany.spi.model.Scope; - -import junit.framework.TestCase; -import org.apache.tuscany.core.component.WorkContextImpl; -import org.apache.tuscany.core.component.event.HttpSessionEnd; -import org.apache.tuscany.core.component.event.HttpSessionStart; -import org.apache.tuscany.core.mock.component.OrderedInitPojo; -import org.apache.tuscany.core.mock.component.OrderedInitPojoImpl; -import org.easymock.EasyMock; -import org.easymock.IAnswer; - -/** - * Lifecycle unit tests for the composite scope container - * - * @version $Rev$ $Date$ - */ -public class HttpSessionScopeInstanceLifecycleTestCase extends TestCase { - - public void testInitDestroy() throws Exception { - WorkContext ctx = new WorkContextImpl(); - HttpSessionScopeContainer scope = new HttpSessionScopeContainer(ctx, null); - scope.start(); - Foo comp = new Foo(); - AtomicComponent component = EasyMock.createMock(AtomicComponent.class); - EasyMock.expect(component.createInstance()).andReturn(comp); - component.addListener(EasyMock.isA(RuntimeEventListener.class)); - component.init(EasyMock.eq(comp)); - component.destroy(EasyMock.eq(comp)); - EasyMock.replay(component); - scope.register(component); - Object session = new Object(); - ctx.setIdentifier(Scope.SESSION, session); - scope.onEvent(new HttpSessionStart(this, session)); - assertNotNull(scope.getInstance(component)); - // expire - scope.onEvent(new HttpSessionEnd(this, session)); - scope.stop(); - EasyMock.verify(component); - scope.stop(); - } - - public void testDestroyOrder() throws Exception { - WorkContext ctx = new WorkContextImpl(); - HttpSessionScopeContainer scope = new HttpSessionScopeContainer(ctx, null); - scope.start(); - - AtomicComponent oneComponent = createComponent(); - scope.register(oneComponent); - AtomicComponent twoComponent = createComponent(); - scope.register(twoComponent); - AtomicComponent threeComponent = createComponent(); - scope.register(threeComponent); - - Object session = new Object(); - ctx.setIdentifier(Scope.SESSION, session); - scope.onEvent(new HttpSessionStart(this, session)); - OrderedInitPojo one = (OrderedInitPojo) scope.getInstance(oneComponent); - assertNotNull(one); - assertEquals(1, one.getNumberInstantiated()); - assertEquals(1, one.getInitOrder()); - - OrderedInitPojo two = (OrderedInitPojo) scope.getInstance(twoComponent); - assertNotNull(two); - assertEquals(2, two.getNumberInstantiated()); - assertEquals(2, two.getInitOrder()); - - OrderedInitPojo three = (OrderedInitPojo) scope.getInstance(threeComponent); - assertNotNull(three); - assertEquals(3, three.getNumberInstantiated()); - assertEquals(3, three.getInitOrder()); - - scope.onEvent(new HttpSessionEnd(this, session)); - assertEquals(0, one.getNumberInstantiated()); - scope.stop(); - EasyMock.verify(oneComponent); - EasyMock.verify(twoComponent); - EasyMock.verify(threeComponent); - } - - @SuppressWarnings("unchecked") - private AtomicComponent createComponent() throws TargetException { - AtomicComponent component = EasyMock.createMock(AtomicComponent.class); - EasyMock.expect(component.createInstance()).andStubAnswer(new IAnswer() { - public Object answer() throws Throwable { - return new OrderedInitPojoImpl(); - } - }); - component.addListener(EasyMock.isA(RuntimeEventListener.class)); - component.init(EasyMock.isA(OrderedInitPojoImpl.class)); - EasyMock.expectLastCall().andAnswer(new IAnswer() { - public Object answer() throws Throwable { - OrderedInitPojoImpl pojo = (OrderedInitPojoImpl) EasyMock.getCurrentArguments()[0]; - pojo.init(); - return null; - } - }); - component.destroy(EasyMock.isA(OrderedInitPojoImpl.class)); - EasyMock.expectLastCall().andAnswer(new IAnswer() { - public Object answer() throws Throwable { - OrderedInitPojoImpl pojo = (OrderedInitPojoImpl) EasyMock.getCurrentArguments()[0]; - pojo.destroy(); - return null; - } - }); - EasyMock.replay(component); - return component; - } - - private class Foo { - - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/HttpSessionScopeRestartTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/HttpSessionScopeRestartTestCase.java deleted file mode 100644 index eff0eb6d3a..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/HttpSessionScopeRestartTestCase.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.component.scope; - -import java.lang.reflect.Constructor; - -import org.apache.tuscany.spi.component.AtomicComponent; -import org.apache.tuscany.spi.component.WorkContext; -import org.apache.tuscany.spi.model.Scope; - -import junit.framework.TestCase; -import org.apache.tuscany.core.component.WorkContextImpl; -import org.apache.tuscany.core.component.event.HttpSessionEnd; -import org.apache.tuscany.core.component.event.HttpSessionStart; -import org.apache.tuscany.core.implementation.PojoConfiguration; -import org.apache.tuscany.core.implementation.system.component.SystemAtomicComponentImpl; -import org.apache.tuscany.core.injection.MethodEventInvoker; -import org.apache.tuscany.core.injection.PojoObjectFactory; - -/** - * Verifies the scope container properly disposes resources and canbe restarted - * - * @version $$Rev$$ $$Date$$ - */ -public class HttpSessionScopeRestartTestCase extends TestCase { - - public void testRestart() throws Exception { - WorkContext ctx = new WorkContextImpl(); - HttpSessionScopeContainer scope = new HttpSessionScopeContainer(ctx, null); - scope.start(); - MethodEventInvoker initInvoker = new MethodEventInvoker( - HttpSessionScopeRestartTestCase.InitDestroyOnce.class.getMethod("init")); - MethodEventInvoker destroyInvoker = - new MethodEventInvoker(InitDestroyOnce.class.getMethod("destroy")); - PojoConfiguration configuration = new PojoConfiguration(); - configuration.setInitInvoker(initInvoker); - configuration.setDestroyInvoker(destroyInvoker); - Constructor ctr = InitDestroyOnce.class.getConstructor((Class[]) null); - configuration.setInstanceFactory(new PojoObjectFactory(ctr)); - configuration.setName("InitDestroy"); - AtomicComponent component = new SystemAtomicComponentImpl(configuration); - component.setScopeContainer(scope); - component.start(); - - Object session = new Object(); - ctx.setIdentifier(Scope.SESSION, session); - scope.onEvent(new HttpSessionStart(this, session)); - Object instance = component.getTargetInstance(); - assertSame(instance, component.getTargetInstance()); - - scope.onEvent(new HttpSessionEnd(this, session)); - scope.stop(); - component.stop(); - - scope.start(); - scope.onEvent(new HttpSessionStart(this, session)); - component.start(); - assertNotSame(instance, component.getTargetInstance()); - scope.onEvent(new HttpSessionEnd(this, session)); - scope.stop(); - component.stop(); - } - - public static class InitDestroyOnce { - - private boolean initialized; - private boolean destroyed; - - public InitDestroyOnce() { - } - - public void init() { - if (!initialized) { - initialized = true; - } else { - fail("Scope did not clean up properly - Init called more than once"); - } - } - - public void destroy() { - if (!destroyed) { - destroyed = true; - } else { - fail("Scope did not clean up properly - Destroyed called more than once"); - } - } - - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/InstanceWrapperTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/InstanceWrapperTestCase.java deleted file mode 100644 index 5600987d8b..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/InstanceWrapperTestCase.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.component.scope; - -import org.apache.tuscany.spi.component.AtomicComponent; - -import junit.framework.TestCase; -import org.easymock.EasyMock; - -/** - * @version $Rev$ $Date$ - */ -public class InstanceWrapperTestCase extends TestCase { - - public void testExceptionInit() throws Exception { - AtomicComponent component = getComponent(); - InstanceWrapper wrapper = new InstanceWrapperImpl(component, new Object()); - try { - wrapper.start(); - fail(); - } catch (SomeException e) { - // expected - } - assertFalse(wrapper.isStarted()); - EasyMock.verify(component); - } - - public void testNonStart() throws Exception { - AtomicComponent comp = EasyMock.createNiceMock(AtomicComponent.class); // class-level one has an expects - InstanceWrapper wrapper = new InstanceWrapperImpl(comp, new Object()); - try { - wrapper.getInstance(); - fail(); - } catch (IllegalStateException e) { - // expected - } - } - - private AtomicComponent getComponent() throws Exception { - // do not use setUp() since we do not need this in all testcases - AtomicComponent comp = EasyMock.createMock(AtomicComponent.class); - comp.init(EasyMock.isA(Object.class)); - EasyMock.expectLastCall().andThrow(new SomeException()); - EasyMock.replay(comp); - return comp; - } - - private class SomeException extends RuntimeException { - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/MockFactory.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/MockFactory.java deleted file mode 100644 index 30c12292ba..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/MockFactory.java +++ /dev/null @@ -1,137 +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.lang.reflect.Method; -import java.util.HashMap; -import java.util.Map; - -import org.osoa.sca.annotations.Destroy; -import org.osoa.sca.annotations.EagerInit; -import org.osoa.sca.annotations.Init; - -import org.apache.tuscany.spi.QualifiedName; -import org.apache.tuscany.spi.component.AtomicComponent; -import org.apache.tuscany.spi.component.ScopeContainer; -import org.apache.tuscany.spi.idl.java.JavaServiceContract; -import org.apache.tuscany.spi.wire.InboundWire; -import org.apache.tuscany.spi.wire.OutboundWire; - -import org.apache.tuscany.core.implementation.PojoConfiguration; -import org.apache.tuscany.core.implementation.system.component.SystemAtomicComponentImpl; -import org.apache.tuscany.core.injection.MethodEventInvoker; -import org.apache.tuscany.core.injection.PojoObjectFactory; -import org.apache.tuscany.core.wire.InboundWireImpl; -import org.apache.tuscany.core.wire.OutboundWireImpl; - -/** - * @version $$Rev$$ $$Date$$ - */ -public final class MockFactory { - - private MockFactory() { - } - - @SuppressWarnings("unchecked") - public static Map createWiredComponents(String source, - Class sourceClass, - ScopeContainer sourceScopeContainer, - String target, - Class targetClass, - ScopeContainer targetScopeContainer) - throws NoSuchMethodException { - - Map components = new HashMap(); - AtomicComponent targetComponent = createAtomicComponent(target, targetScopeContainer, targetClass); - PojoConfiguration sourceConfig = new PojoConfiguration(); - sourceConfig.setInstanceFactory(new PojoObjectFactory(sourceClass.getConstructor())); - - //create target wire - Method[] sourceMethods = sourceClass.getMethods(); - Class[] interfaces = targetClass.getInterfaces(); - EagerInit eager = targetClass.getAnnotation(EagerInit.class); - if (eager != null) { - sourceConfig.setInitLevel(eager.value()); - } - - Method setter = null; - for (Class interfaze : interfaces) { - - for (Method method : sourceMethods) { - if (method.getParameterTypes().length == 1) { - if (interfaze.isAssignableFrom(method.getParameterTypes()[0])) { - setter = method; - } - } - if (method.getAnnotation(Init.class) != null) { - sourceConfig.setInitInvoker(new MethodEventInvoker(method)); - - } else if (method.getAnnotation(Destroy.class) != null) { - sourceConfig.setDestroyInvoker(new MethodEventInvoker(method)); - } - } - - } - if (setter == null) { - throw new IllegalArgumentException("No setter found on source for target"); - } - - sourceConfig.addReferenceSite(setter.getName(), setter); - sourceConfig.setName(source); - AtomicComponent sourceComponent = new SystemAtomicComponentImpl(sourceConfig); - sourceComponent.setScopeContainer(sourceScopeContainer); - QualifiedName targetName = new QualifiedName(target); - OutboundWire wire = new OutboundWireImpl(); - wire.setReferenceName(setter.getName()); - wire.setServiceContract(new JavaServiceContract(targetClass)); - InboundWire inboundWire = new InboundWireImpl(); - inboundWire.setContainer(targetComponent); - inboundWire.setServiceContract(new JavaServiceContract(targetClass)); - inboundWire.setServiceName(targetName.getPortName()); - wire.setTargetWire(inboundWire); - sourceComponent.addOutboundWire(wire); - components.put(source, sourceComponent); - components.put(target, targetComponent); - return components; - } - - @SuppressWarnings("unchecked") - public static AtomicComponent createAtomicComponent(String name, ScopeContainer container, Class clazz) - throws NoSuchMethodException { - PojoConfiguration configuration = new PojoConfiguration(); - configuration.setInstanceFactory(new PojoObjectFactory(clazz.getConstructor())); - EagerInit eager = clazz.getAnnotation(EagerInit.class); - if (eager != null) { - configuration.setInitLevel(eager.value()); - } - Method[] methods = clazz.getMethods(); - for (Method method : methods) { - if (method.getAnnotation(Init.class) != null) { - configuration.setInitInvoker(new MethodEventInvoker(method)); - } else if (method.getAnnotation(Destroy.class) != null) { - configuration.setDestroyInvoker(new MethodEventInvoker(method)); - } - } - configuration.setName(name); - AtomicComponent component = new SystemAtomicComponentImpl(configuration); - component.setScopeContainer(container); - return component; - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/RequestScopeInitDestroyErrorTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/RequestScopeInitDestroyErrorTestCase.java deleted file mode 100644 index 3f562c9b61..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/RequestScopeInitDestroyErrorTestCase.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.component.scope; - -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.event.RuntimeEventListener; - -import junit.framework.TestCase; -import org.apache.tuscany.core.component.WorkContextImpl; -import org.apache.tuscany.core.component.event.RequestEnd; -import org.apache.tuscany.core.component.event.RequestStart; -import org.easymock.EasyMock; - -/** - * @version $Rev$ $Date$ - */ -public class RequestScopeInitDestroyErrorTestCase extends TestCase { - - public void testDestroyErrorMonitor() throws Exception { - ScopeContainerMonitor monitor; - monitor = EasyMock.createMock(ScopeContainerMonitor.class); - monitor.destructionError(EasyMock.isA(TargetDestructionException.class)); - EasyMock.replay(monitor); - RequestScopeContainer scope = new RequestScopeContainer(new WorkContextImpl(), monitor); - scope.start(); - AtomicComponent component = EasyMock.createMock(AtomicComponent.class); - component.addListener(EasyMock.isA(RuntimeEventListener.class)); - EasyMock.expect(component.getName()).andReturn("foo").atLeastOnce(); - EasyMock.expect(component.createInstance()).andReturn(new Object()); - component.init(EasyMock.isA(Object.class)); - component.destroy(EasyMock.isA(Object.class)); - EasyMock.expectLastCall().andThrow(new TargetDestructionException("", "")); - EasyMock.replay(component); - scope.register(component); - scope.onEvent(new RequestStart(this)); - scope.getInstance(component); - scope.onEvent(new RequestEnd(this)); - EasyMock.verify(monitor); - } - - - protected void setUp() throws Exception { - super.setUp(); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/RequestScopeInstanceLifecycleTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/RequestScopeInstanceLifecycleTestCase.java deleted file mode 100644 index 6601640c3b..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/RequestScopeInstanceLifecycleTestCase.java +++ /dev/null @@ -1,129 +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.TargetException; -import org.apache.tuscany.spi.component.WorkContext; - -import junit.framework.TestCase; -import org.apache.tuscany.core.component.WorkContextImpl; -import org.apache.tuscany.core.component.event.RequestEnd; -import org.apache.tuscany.core.component.event.RequestStart; -import org.apache.tuscany.core.mock.component.OrderedInitPojo; -import org.apache.tuscany.core.mock.component.OrderedInitPojoImpl; -import org.easymock.EasyMock; -import org.easymock.IAnswer; - -/** - * Lifecycle unit tests for the request scope container - * - * @version $Rev$ $Date$ - */ -public class RequestScopeInstanceLifecycleTestCase extends TestCase { - - public void testInitDestroy() throws Exception { - WorkContext ctx = new WorkContextImpl(); - RequestScopeContainer scope = new RequestScopeContainer(ctx, null); - scope.start(); - Foo comp = new Foo(); - AtomicComponent component = EasyMock.createMock(AtomicComponent.class); - EasyMock.expect(component.createInstance()).andReturn(comp); - component.init(EasyMock.eq(comp)); - component.destroy(EasyMock.eq(comp)); - EasyMock.replay(component); - scope.register(component); - scope.onEvent(new RequestStart(this)); - assertNotNull(scope.getInstance(component)); - // expire - scope.onEvent(new RequestEnd(this)); - scope.stop(); - EasyMock.verify(component); - scope.stop(); - } - - public void testDestroyOrder() throws Exception { - WorkContext ctx = new WorkContextImpl(); - RequestScopeContainer scope = new RequestScopeContainer(ctx, null); - scope.start(); - - AtomicComponent oneComponent = createComponent(); - scope.register(oneComponent); - AtomicComponent twoComponent = createComponent(); - scope.register(twoComponent); - AtomicComponent threeComponent = createComponent(); - scope.register(threeComponent); - - scope.onEvent(new RequestStart(this)); - OrderedInitPojo one = (OrderedInitPojo) scope.getInstance(oneComponent); - assertNotNull(one); - assertEquals(1, one.getNumberInstantiated()); - assertEquals(1, one.getInitOrder()); - - OrderedInitPojo two = (OrderedInitPojo) scope.getInstance(twoComponent); - assertNotNull(two); - assertEquals(2, two.getNumberInstantiated()); - assertEquals(2, two.getInitOrder()); - - OrderedInitPojo three = (OrderedInitPojo) scope.getInstance(threeComponent); - assertNotNull(three); - assertEquals(3, three.getNumberInstantiated()); - assertEquals(3, three.getInitOrder()); - - scope.onEvent(new RequestEnd(this)); - assertEquals(0, one.getNumberInstantiated()); - scope.stop(); - EasyMock.verify(oneComponent); - EasyMock.verify(twoComponent); - EasyMock.verify(threeComponent); - } - - @SuppressWarnings("unchecked") - private AtomicComponent createComponent() throws TargetException { - AtomicComponent component = EasyMock.createMock(AtomicComponent.class); - EasyMock.expect(component.createInstance()).andStubAnswer(new IAnswer() { - public Object answer() throws Throwable { - return new OrderedInitPojoImpl(); - } - }); - component.init(EasyMock.isA(OrderedInitPojoImpl.class)); - EasyMock.expectLastCall().andAnswer(new IAnswer() { - public Object answer() throws Throwable { - OrderedInitPojoImpl pojo = (OrderedInitPojoImpl) EasyMock.getCurrentArguments()[0]; - pojo.init(); - return null; - } - }); - component.destroy(EasyMock.isA(OrderedInitPojoImpl.class)); - EasyMock.expectLastCall().andAnswer(new IAnswer() { - public Object answer() throws Throwable { - OrderedInitPojoImpl pojo = (OrderedInitPojoImpl) EasyMock.getCurrentArguments()[0]; - pojo.destroy(); - return null; - } - }); - EasyMock.replay(component); - return component; - } - - private class Foo { - - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/RequestScopeRestartTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/RequestScopeRestartTestCase.java deleted file mode 100644 index 335d8c621d..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/RequestScopeRestartTestCase.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.component.scope; - -import java.lang.reflect.Constructor; - -import org.apache.tuscany.spi.component.AtomicComponent; -import org.apache.tuscany.spi.component.WorkContext; - -import junit.framework.TestCase; -import org.apache.tuscany.core.component.WorkContextImpl; -import org.apache.tuscany.core.component.event.RequestEnd; -import org.apache.tuscany.core.implementation.PojoConfiguration; -import org.apache.tuscany.core.implementation.system.component.SystemAtomicComponentImpl; -import org.apache.tuscany.core.injection.MethodEventInvoker; -import org.apache.tuscany.core.injection.PojoObjectFactory; - -/** - * Verifies the scope container properly disposes resources and canbe restarted - * - * @version $$Rev$$ $$Date$$ - */ -public class RequestScopeRestartTestCase extends TestCase { - - public void testRestart() throws Exception { - WorkContext ctx = new WorkContextImpl(); - RequestScopeContainer scope = new RequestScopeContainer(ctx, null); - scope.start(); - MethodEventInvoker initInvoker = - new MethodEventInvoker(InitDestroyOnce.class.getMethod("init")); - MethodEventInvoker destroyInvoker = - new MethodEventInvoker(InitDestroyOnce.class.getMethod("destroy")); - PojoConfiguration configuration = new PojoConfiguration(); - configuration.setInitInvoker(initInvoker); - configuration.setDestroyInvoker(destroyInvoker); - Constructor ctr = InitDestroyOnce.class.getConstructor((Class[]) null); - configuration.setInstanceFactory(new PojoObjectFactory(ctr)); - configuration.setName("InitDestroy"); - AtomicComponent component = new SystemAtomicComponentImpl(configuration); - component.setScopeContainer(scope); - component.start(); - - Object instance = component.getTargetInstance(); - assertSame(instance, component.getTargetInstance()); - - scope.onEvent(new RequestEnd(this)); - scope.stop(); - component.stop(); - - scope.start(); - component.start(); - assertNotSame(instance, component.getTargetInstance()); - scope.onEvent(new RequestEnd(this)); - scope.stop(); - component.stop(); - } - - public static class InitDestroyOnce { - - private boolean initialized; - private boolean destroyed; - - public InitDestroyOnce() { - } - - public void init() { - if (!initialized) { - initialized = true; - } else { - fail("Scope did not clean up properly - Init called more than once"); - } - } - - public void destroy() { - if (!destroyed) { - destroyed = true; - } else { - fail("Scope did not clean up properly - Destroyed called more than once"); - } - } - - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/ScopeRegistryTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/ScopeRegistryTestCase.java deleted file mode 100644 index e1380eb4c0..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/ScopeRegistryTestCase.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.component.scope; - -import org.apache.tuscany.spi.component.ScopeContainer; -import org.apache.tuscany.spi.component.ScopeRegistry; -import org.apache.tuscany.spi.component.WorkContext; -import org.apache.tuscany.spi.model.Scope; - -import junit.framework.TestCase; -import org.apache.tuscany.core.component.WorkContextImpl; - -/** - * Verifies retrieval of standard scope contexts from the default scope registry - * - * @version $$Rev$$ $$Date$$ - */ -public class ScopeRegistryTestCase extends TestCase { - public void testScopeContextCreation() throws Exception { - WorkContext context = new WorkContextImpl(); - ScopeRegistry scopeRegistry = new ScopeRegistryImpl(); - scopeRegistry.registerFactory(Scope.REQUEST, new RequestScopeObjectFactory(context, null)); - HttpSessionScopeObjectFactory sessionFactory = new HttpSessionScopeObjectFactory(scopeRegistry, context, null); - scopeRegistry.registerFactory(Scope.SESSION, sessionFactory); - scopeRegistry.registerFactory(Scope.CONVERSATION, - new ConversationalScopeObjectFactory(scopeRegistry, context, null, null)); - ScopeContainer request = scopeRegistry.getScopeContainer(Scope.REQUEST); - assertTrue(request instanceof RequestScopeContainer); - assertSame(request, scopeRegistry.getScopeContainer(Scope.REQUEST)); - ScopeContainer session = scopeRegistry.getScopeContainer(Scope.SESSION); - assertTrue(session instanceof HttpSessionScopeContainer); - assertSame(session, scopeRegistry.getScopeContainer(Scope.SESSION)); - assertNotSame(request, session); - ScopeContainer conversation = scopeRegistry.getScopeContainer(Scope.CONVERSATION); - assertTrue(conversation instanceof ConversationalScopeContainer); - assertSame(conversation, scopeRegistry.getScopeContainer(Scope.CONVERSATION)); - assertNotSame(session, conversation); - } - - public void testDeregisterFactory() throws Exception { - WorkContext context = new WorkContextImpl(); - ScopeRegistry scopeRegistry = new ScopeRegistryImpl(); - RequestScopeObjectFactory factory = new RequestScopeObjectFactory(context, null); - scopeRegistry.registerFactory(Scope.REQUEST, factory); - scopeRegistry.deregisterFactory(Scope.REQUEST); - assertNull(scopeRegistry.getScopeContainer(Scope.REQUEST)); - ConversationalScopeObjectFactory convFactory = - new ConversationalScopeObjectFactory(scopeRegistry, context, null, null); - scopeRegistry.registerFactory(Scope.CONVERSATION, convFactory); - scopeRegistry.deregisterFactory(Scope.CONVERSATION); - assertNull(scopeRegistry.getScopeContainer(Scope.CONVERSATION)); - } - - public void testScopeNotRegistered() throws Exception { - WorkContext workContext = new WorkContextImpl(); - ScopeRegistry scopeRegistry = new ScopeRegistryImpl(); - assertNull(scopeRegistry.getScopeContainer(Scope.REQUEST)); - assertNull(scopeRegistry.getScopeContainer(Scope.SESSION)); - assertNull(scopeRegistry.getScopeContainer(Scope.CONVERSATION)); - assertNull(scopeRegistry.getScopeContainer(Scope.STATELESS)); - } - - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/StatelessScopeContainerTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/StatelessScopeContainerTestCase.java deleted file mode 100644 index 89cd9b51d7..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/StatelessScopeContainerTestCase.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.component.scope; - -import junit.framework.TestCase; - -/** - * @version $Rev$ $Date$ - */ -public class StatelessScopeContainerTestCase extends TestCase { - - public void testBadStopWithoutStart() throws Exception { - StatelessScopeContainer container = new StatelessScopeContainer(null, null); - try { - container.stop(); - fail(); - } catch (IllegalStateException e) { - //expected - } - } - - public void testBadDoubleStart() throws Exception { - StatelessScopeContainer container = new StatelessScopeContainer(null, null); - try { - container.start(); - container.start(); - fail(); - } catch (IllegalStateException e) { - //expected - } - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/StatelessScopeObjectFactoryTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/StatelessScopeObjectFactoryTestCase.java deleted file mode 100644 index 0902b9d78c..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/StatelessScopeObjectFactoryTestCase.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.scope; - -import org.apache.tuscany.spi.component.ScopeRegistry; -import org.apache.tuscany.spi.model.Scope; - -import junit.framework.TestCase; -import org.easymock.EasyMock; - -/** - * @version $Rev$ $Date$ - */ -public class StatelessScopeObjectFactoryTestCase extends TestCase { - - public void testCreation() { - ScopeRegistry registry = EasyMock.createMock(ScopeRegistry.class); - registry.registerFactory(EasyMock.isA(Scope.class), EasyMock.isA(StatelessScopeObjectFactory.class)); - assertNotNull(new StatelessScopeObjectFactory(registry, null, null).getInstance()); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/WorkContextTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/WorkContextTestCase.java deleted file mode 100644 index 8a9fdf4ac4..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/WorkContextTestCase.java +++ /dev/null @@ -1,212 +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.CompositeComponent; -import org.apache.tuscany.spi.component.WorkContext; - -import junit.framework.TestCase; -import org.apache.tuscany.core.component.WorkContextImpl; -import org.easymock.EasyMock; - -/** - * @version $Rev$ $Date$ - */ -public class WorkContextTestCase extends TestCase { - - public void testRemoteComponent() throws Exception { - WorkContext ctx = new WorkContextImpl(); - CompositeComponent component = EasyMock.createNiceMock(CompositeComponent.class); - CompositeComponent component2 = EasyMock.createNiceMock(CompositeComponent.class); - ctx.setRemoteComponent(component); - assertEquals(component, ctx.getRemoteComponent()); - ctx.setRemoteComponent(component2); - assertEquals(component2, ctx.getRemoteComponent()); - } - - public void testNonSetRemoteComponent() throws Exception { - WorkContext ctx = new WorkContextImpl(); - assertNull(ctx.getRemoteComponent()); - } - - public void testSetCurrentAtomicComponent() throws Exception { - WorkContext ctx = new WorkContextImpl(); - 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 WorkContextImpl(); - assertNull(ctx.getCurrentAtomicComponent()); - } - - public void testIndentifier() throws Exception { - WorkContext ctx = new WorkContextImpl(); - Object id = new Object(); - ctx.setIdentifier(this, id); - assertEquals(id, ctx.getIdentifier(this)); - } - - public void testClearIndentifier() throws Exception { - WorkContext ctx = new WorkContextImpl(); - Object id = new Object(); - ctx.setIdentifier(this, id); - ctx.clearIdentifier(this); - assertNull(ctx.getIdentifier(this)); - } - - public void testClearIndentifiers() throws Exception { - WorkContext ctx = new WorkContextImpl(); - 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 WorkContextImpl(); - ctx.clearIdentifier(this); - } - - public void testNullIndentifier() throws Exception { - WorkContext ctx = new WorkContextImpl(); - Object id = new Object(); - ctx.setIdentifier(this, id); - ctx.clearIdentifier(null); - assertEquals(id, ctx.getIdentifier(this)); - } - - public void testNoIndentifier() throws Exception { - WorkContext ctx = new WorkContextImpl(); - assertNull(ctx.getIdentifier(this)); - } - - public void testSetGetCorrelationId() { - WorkContext context = new WorkContextImpl(); - context.setCurrentCorrelationId("msg-005"); - assertEquals(context.getCurrentCorrelationId(), "msg-005"); - context.setCurrentCorrelationId(null); - assertNull(context.getCurrentCorrelationId()); - } - - public void testSetGetCorrelationIdInNewThread() throws InterruptedException { - WorkContext context = new WorkContextImpl(); - context.setCurrentCorrelationId("msg-005"); - assertEquals(context.getCurrentCorrelationId(), "msg-005"); - context.setIdentifier("TX", "002"); - ChildThread t = new ChildThread(context); - t.start(); - t.join(); - assertTrue(t.passed); - context.setCurrentCorrelationId(null); - assertNull(context.getCurrentCorrelationId()); - } - - public void testCurrentAtomicComponentDoesNotPropagateToChildThread() throws InterruptedException { - // NOTE should behaviour be to propagate? - WorkContext context = new WorkContextImpl(); - context.setCurrentAtomicComponent(EasyMock.createNiceMock(AtomicComponent.class)); - TestCurrentAtomicComponentChildThread t = new TestCurrentAtomicComponentChildThread(context); - t.start(); - t.join(); - assertTrue(t.passed); - context.setCurrentAtomicComponent(null); - assertNull(context.getCurrentAtomicComponent()); - } - - public void testCurrentRemoteComponentDoesNotPropagateToChildThread() throws InterruptedException { - // NOTE should behaviour be to propagate? - WorkContext context = new WorkContextImpl(); - context.setRemoteComponent(EasyMock.createNiceMock(CompositeComponent.class)); - TestCurrentRemoteComponentChildThread t = new TestCurrentRemoteComponentChildThread(context); - t.start(); - t.join(); - assertTrue(t.passed); - context.setRemoteComponent(null); - assertNull(context.getRemoteComponent()); - } - - 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.getCurrentCorrelationId()); - 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; - } - } - - } - - private static final class TestCurrentRemoteComponentChildThread extends Thread { - private WorkContext context; - private boolean passed = true; - - private TestCurrentRemoteComponentChildThread(WorkContext context) { - this.context = context; - } - - @Override - public void run() { - try { - assertNull(context.getRemoteComponent()); - } catch (AssertionError e) { - passed = false; - } - } - - } - - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DataBindingInterceptorTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DataBindingInterceptorTestCase.java deleted file mode 100644 index 1f85cf6505..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DataBindingInterceptorTestCase.java +++ /dev/null @@ -1,131 +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.databinding.impl; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.apache.tuscany.spi.component.Component; -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.databinding.Mediator; -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.wire.InboundWire; -import org.apache.tuscany.spi.wire.Interceptor; -import org.apache.tuscany.spi.wire.Message; -import org.apache.tuscany.spi.wire.OutboundWire; - -import junit.framework.Assert; -import junit.framework.TestCase; -import org.easymock.EasyMock; -import static org.easymock.EasyMock.createMock; -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.expectLastCall; -import static org.easymock.EasyMock.replay; - -/** - * @version $Rev$ $Date$ - */ -public class DataBindingInterceptorTestCase extends TestCase { - - @SuppressWarnings("unchecked") - public final void testInvoke() { - DataType type1 = new DataType("xml:string", String.class, String.class); - List> types1 = new ArrayList>(); - types1.add(type1); - DataType>> inputType1 = - new DataType>>("xml:string", Object[].class, types1); - - DataType type2 = new DataType("foo", Foo.class, Foo.class); - List> types2 = new ArrayList>(); - types2.add(type2); - DataType>> inputType2 = - new DataType>>("foo", Object[].class, types2); - - Operation operation1 = - new Operation("call", inputType1, type1, null, false, "xml:string", NO_CONVERSATION); - Operation operation2 = - new Operation("call", inputType2, type2, null, false, "org.w3c.dom.Node", NO_CONVERSATION); - - DataType outputType1 = - new DataType("idl:output", Object.class, operation1.getOutputType()); - DataType outputType2 = - new DataType("idl:output", Object.class, operation2.getOutputType()); - - OutboundWire outboundWire = EasyMock.createMock(OutboundWire.class); - InboundWire inboundWire = EasyMock.createMock(InboundWire.class); - CompositeComponent composite = EasyMock.createMock(CompositeComponent.class); - Component component = EasyMock.createMock(Component.class); - EasyMock.expect(component.getParent()).andReturn(composite).once(); - EasyMock.expect(outboundWire.getContainer()).andReturn(component); - EasyMock.replay(outboundWire, inboundWire, composite, component); - - DataBindingInteceptor interceptor = new DataBindingInteceptor(outboundWire, operation1, operation2); - Mediator mediator = createMock(Mediator.class); - Object[] source = new Object[]{"bar"}; - Foo foo = new Foo(); - foo.bar = "bar"; - Object[] target = new Object[]{foo}; - expect(mediator.mediate(EasyMock.same(source), - EasyMock.same(inputType1), - EasyMock.same(inputType2), - EasyMock.isA(Map.class))).andReturn(target); - // expect(mediator.mediate(target[0], type2, - // type1)).andReturn(source[0]); - expect(mediator.mediate(EasyMock.same(target[0]), - EasyMock.eq(outputType2), - EasyMock.eq(outputType1), - EasyMock.isA(Map.class))).andReturn(source[0]); - replay(mediator); - interceptor.setMediator(mediator); - Message msg = createMock(Message.class); - msg.setBody(EasyMock.anyObject()); - expectLastCall().anyTimes(); - expect(msg.getBody()).andReturn(source).once().andReturn(target[0]).once().andReturn(source[0]); - expect(msg.isFault()).andReturn(false).once(); - replay(msg); - Interceptor next = createMock(Interceptor.class); - expect(next.invoke(msg)).andReturn(msg); - replay(next); - interceptor.setNext(next); - interceptor.invoke(msg); - String result = (String) msg.getBody(); - Assert.assertEquals(source[0], result); - EasyMock.verify(mediator, msg, next); - } - - protected void setUp() throws Exception { - super.setUp(); - } - - private static class Foo { - private String bar; - - public String getBar() { - return bar; - } - - public void setBar(String bar) { - this.bar = bar; - } - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DataBindingJavaInterfaceProcessorTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DataBindingJavaInterfaceProcessorTestCase.java deleted file mode 100644 index 91702ac091..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DataBindingJavaInterfaceProcessorTestCase.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.databinding.impl; - -import static org.apache.tuscany.spi.model.Operation.NO_CONVERSATION; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.Map; - -import junit.framework.Assert; -import junit.framework.TestCase; - -import org.apache.tuscany.api.annotation.DataContext; -import org.apache.tuscany.api.annotation.DataType; -import org.apache.tuscany.spi.idl.InvalidServiceContractException; -import org.apache.tuscany.spi.idl.java.JavaServiceContract; -import org.apache.tuscany.spi.model.Operation; -import org.osoa.sca.annotations.Remotable; -import org.w3c.dom.Node; - -/** - * - */ -public class DataBindingJavaInterfaceProcessorTestCase extends TestCase { - - /** - * @see junit.framework.TestCase#setUp() - */ - protected void setUp() throws Exception { - super.setUp(); - } - - /** - * @throws InvalidServiceContractException - */ - public final void testVisitInterface() throws InvalidServiceContractException { - DataBindingJavaInterfaceProcessor processor = new DataBindingJavaInterfaceProcessor(); - JavaServiceContract contract = new JavaServiceContract(MockInterface.class); - Map> operations = new HashMap>(); - Operation operation = new Operation("call", null, null, null, false, null, NO_CONVERSATION); - Operation operation1 = new Operation("call1", null, null, null, false, null, NO_CONVERSATION); - operations.put("call", operation); - operations.put("call1", operation1); - contract.setOperations(operations); - processor.visitInterface(MockInterface.class, null, contract); - Assert.assertEquals("org.w3c.dom.Node", contract.getDataBinding()); - Assert.assertEquals("element", (String)contract.getMetaData().get("nodeType")); - Assert.assertEquals("org.w3c.dom.Node", contract.getOperations().get("call").getDataBinding()); - Assert.assertEquals("xml:string", contract.getOperations().get("call1").getDataBinding()); - } - - @DataType(name = "org.w3c.dom.Node", context = {@DataContext(key = "nodeType", value = "element")}) - @Remotable - public static interface MockInterface { - Node call(Node msg); - - @DataType(name = "xml:string") - String call1(String msg); - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DataBindingLoaderTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DataBindingLoaderTestCase.java deleted file mode 100644 index 02dd10ee97..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DataBindingLoaderTestCase.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.databinding.impl; - -import javax.xml.stream.XMLStreamConstants; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; - -import junit.framework.Assert; -import junit.framework.TestCase; - -import org.apache.tuscany.spi.loader.InvalidValueException; -import org.apache.tuscany.spi.loader.LoaderException; -import org.apache.tuscany.spi.model.DataType; -import org.apache.tuscany.spi.model.ModelObject; -import org.easymock.EasyMock; - -/** - * Testcase for DataBindingLoader - */ -public class DataBindingLoaderTestCase extends TestCase { - private XMLStreamReader reader; - - /** - * @see junit.framework.TestCase#setUp() - */ - protected void setUp() throws Exception { - super.setUp(); - } - - public final void testLoad() throws LoaderException, XMLStreamException { - reader = EasyMock.createMock(XMLStreamReader.class); - // EasyMock.expect(reader.getEventType()).andReturn(XMLStreamConstants.START_ELEMENT); - EasyMock.expect(reader.hasNext()).andReturn(true).anyTimes(); - EasyMock.expect(reader.getName()).andReturn(DataTypeLoader.DATA_BINDING); - EasyMock.expect(reader.getAttributeValue(null, "name")).andReturn("ABC"); - EasyMock.expect(reader.next()).andReturn(XMLStreamConstants.END_ELEMENT); - EasyMock.replay(reader); - - ModelObject mo = new DataTypeLoader(null).load(null, null, reader, null); - Assert.assertTrue(mo instanceof DataType); - Assert.assertEquals("ABC", ((DataType)mo).getDataBinding()); - EasyMock.verify(reader); - - EasyMock.reset(reader); - - // EasyMock.expect(reader.getEventType()).andReturn(XMLStreamConstants.START_ELEMENT); - EasyMock.expect(reader.hasNext()).andReturn(true).anyTimes(); - EasyMock.expect(reader.getName()).andReturn(DataTypeLoader.DATA_BINDING); - EasyMock.expect(reader.getAttributeValue(null, "name")).andReturn(null); - EasyMock.expect(reader.next()).andReturn(XMLStreamConstants.END_ELEMENT); - EasyMock.replay(reader); - try { - mo = new DataTypeLoader(null).load(null, null, reader, null); - Assert.fail("InvalidValueException should have been thrown"); - } catch (InvalidValueException e) { - Assert.assertTrue(true); - } - EasyMock.verify(reader); - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DataBindingRegistryImplTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DataBindingRegistryImplTestCase.java deleted file mode 100644 index 30af31b1cb..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DataBindingRegistryImplTestCase.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.databinding.impl; - -import static org.easymock.EasyMock.createMock; -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.replay; - -import javax.xml.stream.XMLStreamReader; - -import junit.framework.Assert; -import junit.framework.TestCase; - -import org.apache.tuscany.spi.databinding.DataBinding; -import org.apache.tuscany.spi.databinding.DataBindingRegistry; -import org.apache.tuscany.spi.model.DataType; -import org.easymock.EasyMock; -import org.xml.sax.ContentHandler; - -/** - * - */ -public class DataBindingRegistryImplTestCase extends TestCase { - private DataBindingRegistry registry; - - /** - * @see junit.framework.TestCase#setUp() - */ - protected void setUp() throws Exception { - super.setUp(); - registry = new DataBindingRegistryImpl(); - } - - public void testRegistry() { - DataBinding db1 = createMock(DataBinding.class); - expect(db1.getName()).andReturn(ContentHandler.class.getName()).anyTimes(); - DataType dataType1 = new DataType(ContentHandler.class, ContentHandler.class); - expect(db1.introspect(ContentHandler.class)).andReturn(dataType1); - expect(db1.introspect((Class)EasyMock.anyObject())).andReturn(null).anyTimes(); - replay(db1); - - registry.register(db1); - - DataBinding db2 = createMock(DataBinding.class); - expect(db2.getName()).andReturn(XMLStreamReader.class.getName()).anyTimes(); - DataType dataType2 = new DataType(XMLStreamReader.class, XMLStreamReader.class); - expect(db2.introspect(XMLStreamReader.class)).andReturn(dataType2); - expect(db2.introspect((Class)EasyMock.anyObject())).andReturn(null).anyTimes(); - replay(db2); - - registry.register(db2); - - String name = db1.getName(); - DataBinding db3 = registry.getDataBinding(name); - Assert.assertTrue(db1 == db3); - - DataType dt = registry.introspectType(ContentHandler.class); - Assert.assertEquals(dataType1, dt); - Assert.assertTrue(dt.getDataBinding().equalsIgnoreCase(name)); - - registry.unregister(name); - DataBinding db4 = registry.getDataBinding(name); - Assert.assertNull(db4); - - dt = registry.introspectType(ContentHandler.class); - Assert.assertNull(dt); - - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DataBindingTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DataBindingTestCase.java deleted file mode 100644 index de5c537274..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DataBindingTestCase.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.databinding.impl; - -import java.lang.reflect.Method; - -import junit.framework.Assert; -import junit.framework.TestCase; - -import org.apache.tuscany.api.annotation.DataContext; -import org.apache.tuscany.api.annotation.DataType; - -public class DataBindingTestCase extends TestCase { - @SuppressWarnings("unused") - public void testDataType() throws Exception { - Class testClass = Test.class; - DataType d = testClass.getAnnotation(DataType.class); - Assert.assertEquals(d.name(), "sdo"); - Assert.assertEquals(d.context().length, 0); - - Method method = testClass.getMethod("test", new Class[] {Object.class}); - DataType d2 = method.getAnnotation(DataType.class); - Assert.assertEquals(d2.name(), "jaxb"); - Assert.assertEquals(d2.context()[0].key(), "contextPath"); - Assert.assertEquals(d2.context()[0].value(), "com.example.ipo.jaxb"); - } - - @DataType(name = "sdo") - private static interface Test { - @DataType(name = "jaxb", context = {@DataContext(key = "contextPath", value = "com.example.ipo.jaxb")}) - Object test(Object object); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DataBindingWirePostProcessorOptimizationTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DataBindingWirePostProcessorOptimizationTestCase.java deleted file mode 100644 index d871978cb4..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DataBindingWirePostProcessorOptimizationTestCase.java +++ /dev/null @@ -1,111 +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.databinding.impl; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.Map; - -import org.apache.tuscany.spi.component.SCAObject; -import org.apache.tuscany.spi.databinding.Mediator; -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.InboundInvocationChain; -import org.apache.tuscany.spi.wire.InboundWire; -import org.apache.tuscany.spi.wire.OutboundInvocationChain; -import org.apache.tuscany.spi.wire.OutboundWire; - -import junit.framework.TestCase; -import org.easymock.EasyMock; - -/** - * Verifies that data binding interceptor is not added to invocation chains when the data binding types are not set on - * service contracts - * - * @version $Rev$ $Date$ - */ -public class DataBindingWirePostProcessorOptimizationTestCase extends TestCase { - private DataBindingWirePostProcessor processor; - private OutboundInvocationChain outboundChain; - private OutboundWire outboundWire; - private InboundInvocationChain inboundChain; - private InboundWire inboundWire; - - public void testNoInterceptorInterposedOutboundToInbound() { - processor.process(outboundWire, inboundWire); - EasyMock.verify(outboundChain); - EasyMock.verify(inboundChain); - EasyMock.verify(outboundWire); - EasyMock.verify(inboundWire); - } - - public void testNoInterceptorInterposedInboundToOutbound() { - processor.process(inboundWire, outboundWire); - EasyMock.verify(outboundChain); - EasyMock.verify(inboundChain); - EasyMock.verify(outboundWire); - EasyMock.verify(inboundWire); - } - - - protected void setUp() throws Exception { - super.setUp(); - SCAObject container = EasyMock.createMock(SCAObject.class); - EasyMock.expect(container.getName()).andReturn("foo"); - EasyMock.replay(container); - - Mediator mediator = new MediatorImpl(); - processor = new DataBindingWirePostProcessor(mediator); - - ServiceContract contract = new JavaServiceContract(null); - Operation operation = new Operation("test", null, null, null); - operation.setServiceContract(contract); - Map> operations = new HashMap>(); - operations.put("test", operation); - contract.setOperations(operations); - contract.setCallbackOperations(operations); - - inboundChain = EasyMock.createMock(InboundInvocationChain.class); - EasyMock.replay(inboundChain); - Map, InboundInvocationChain> inboundChains = new HashMap, InboundInvocationChain>(); - inboundChains.put(operation, inboundChain); - - outboundChain = EasyMock.createMock(OutboundInvocationChain.class); - EasyMock.replay(outboundChain); - Map, OutboundInvocationChain> outboundChains = - new HashMap, OutboundInvocationChain>(); - outboundChains.put(operation, outboundChain); - - outboundWire = EasyMock.createMock(OutboundWire.class); - EasyMock.expect(outboundWire.getInvocationChains()).andReturn(outboundChains); - EasyMock.expect(outboundWire.getServiceContract()).andReturn(contract).anyTimes(); - EasyMock.expect(outboundWire.getContainer()).andReturn(container).anyTimes(); - EasyMock.expect(outboundWire.getTargetCallbackInvocationChains()).andReturn(inboundChains).anyTimes(); - EasyMock.replay(outboundWire); - - inboundWire = EasyMock.createMock(InboundWire.class); - EasyMock.expect(inboundWire.getInvocationChains()).andReturn(inboundChains); - EasyMock.expect(inboundWire.getContainer()).andReturn(container).anyTimes(); - EasyMock.expect(inboundWire.getSourceCallbackInvocationChains(EasyMock.eq("foo"))).andReturn(outboundChains) - .anyTimes(); - EasyMock.replay(inboundWire); - - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DataBindingWirePostProcessorTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DataBindingWirePostProcessorTestCase.java deleted file mode 100644 index 29bf91f2c7..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DataBindingWirePostProcessorTestCase.java +++ /dev/null @@ -1,231 +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.databinding.impl; - -import java.lang.reflect.Type; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.w3c.dom.Node; - -import org.apache.tuscany.spi.component.Component; -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.component.ReferenceBinding; -import org.apache.tuscany.spi.component.ServiceBinding; -import org.apache.tuscany.spi.databinding.Mediator; -import org.apache.tuscany.spi.idl.java.JavaServiceContract; -import org.apache.tuscany.spi.model.DataType; -import org.apache.tuscany.spi.model.Operation; -import org.apache.tuscany.spi.model.ServiceContract; -import org.apache.tuscany.spi.wire.InboundInvocationChain; -import org.apache.tuscany.spi.wire.InboundWire; -import org.apache.tuscany.spi.wire.Interceptor; -import org.apache.tuscany.spi.wire.OutboundInvocationChain; -import org.apache.tuscany.spi.wire.OutboundWire; - -import junit.framework.TestCase; -import org.easymock.EasyMock; -import static org.easymock.EasyMock.createMock; -import static org.easymock.EasyMock.expect; - -/** - * @version $Rev$ $Date$ - */ -public class DataBindingWirePostProcessorTestCase extends TestCase { - private DataBindingWirePostProcessor processor; - - /** - * @see junit.framework.TestCase#setUp() - */ - protected void setUp() throws Exception { - super.setUp(); - Mediator mediator = new MediatorImpl(); - this.processor = new DataBindingWirePostProcessor(mediator); - } - - public void testProcess1() { - InboundWire inboundWire = createMock(InboundWire.class); - OutboundWire outboundWire = createMock(OutboundWire.class); - - Component component = createMock(Component.class); - CompositeComponent composite = createMock(CompositeComponent.class); - expect(component.getParent()).andReturn(composite); - expect(inboundWire.getContainer()).andReturn(component); - expect(outboundWire.getContainer()).andReturn(component); - - Map, OutboundInvocationChain> outboundChains = - new HashMap, OutboundInvocationChain>(); - DataType type1 = new DataType(String.class, String.class); - List> types = new ArrayList>(); - types.add(type1); - DataType>> inputType1 = new DataType>>(Object[].class, types); - DataType outputType1 = new DataType(String.class, String.class); - Operation op1 = new Operation("test", inputType1, outputType1, null); - ServiceContract outboundContract = new JavaServiceContract(null); - outboundContract.setDataBinding(String.class.getName()); - op1.setServiceContract(outboundContract); - - OutboundInvocationChain outboundChain = createMock(OutboundInvocationChain.class); - outboundChains.put(op1, outboundChain); - expect(outboundWire.getInvocationChains()).andReturn(outboundChains); - outboundChain.addInterceptor(EasyMock.anyInt(), (Interceptor) EasyMock.anyObject()); - - Map, InboundInvocationChain> inboundChains = - new HashMap, InboundInvocationChain>(); - DataType type2 = new DataType(Node.class, Node.class); - List> types2 = new ArrayList>(); - types2.add(type2); - DataType>> inputType2 = - new DataType>>(Object[].class, types2); - DataType outputType2 = new DataType(String.class, String.class); - Operation op2 = new Operation("test", inputType2, outputType2, null); - ServiceContract inboundContract = new JavaServiceContract(null); - inboundContract.setDataBinding(Node.class.getName()); - op2.setServiceContract(inboundContract); - - InboundInvocationChain inboundChain = createMock(InboundInvocationChain.class); - inboundChains.put(op2, inboundChain); - expect(inboundWire.getInvocationChains()).andReturn(inboundChains); - - ServiceContract contract = new JavaServiceContract(); - Map> operations = Collections.emptyMap(); - contract.setCallbackOperations(operations); - expect(outboundWire.getServiceContract()).andReturn(contract); - - EasyMock.replay(composite, component, inboundWire, outboundWire, inboundChain, outboundChain); - - processor.process(outboundWire, inboundWire); - } - - public void testProcess2() { - InboundWire inboundWire = createMock(InboundWire.class); - OutboundWire outboundWire = createMock(OutboundWire.class); - - ReferenceBinding referenceBinding = createMock(ReferenceBinding.class); - CompositeComponent composite = createMock(CompositeComponent.class); - expect(referenceBinding.getParent()).andReturn(composite); - expect(inboundWire.getContainer()).andReturn(referenceBinding).anyTimes(); - expect(outboundWire.getContainer()).andReturn(referenceBinding).anyTimes(); - - Map, OutboundInvocationChain> outboundChains = - new HashMap, OutboundInvocationChain>(); - DataType type1 = new DataType(String.class, String.class); - List> types = new ArrayList>(); - types.add(type1); - DataType>> inputType1 = new DataType>>(Object[].class, types); - DataType outputType1 = new DataType(String.class, String.class); - Operation op1 = new Operation("test", inputType1, outputType1, null); - ServiceContract outboundContract = new JavaServiceContract(null); - outboundContract.setDataBinding(String.class.getName()); - op1.setServiceContract(outboundContract); - - OutboundInvocationChain outboundChain = createMock(OutboundInvocationChain.class); - outboundChains.put(op1, outboundChain); - expect(outboundWire.getInvocationChains()).andReturn(outboundChains).anyTimes(); - outboundChain.addInterceptor(EasyMock.anyInt(), (Interceptor) EasyMock.anyObject()); - - Map, InboundInvocationChain> inboundChains = - new HashMap, InboundInvocationChain>(); - DataType type2 = new DataType(Node.class, Node.class); - List> types2 = new ArrayList>(); - types2.add(type2); - DataType>> inputType2 = - new DataType>>(Object[].class, types2); - DataType outputType2 = new DataType(String.class, String.class); - Operation op2 = new Operation("test", inputType2, outputType2, null); - ServiceContract inboundContract = new JavaServiceContract(null); - inboundContract.setDataBinding(Node.class.getName()); - op2.setServiceContract(inboundContract); - - InboundInvocationChain inboundChain = createMock(InboundInvocationChain.class); - inboundChains.put(op2, inboundChain); - expect(inboundWire.getInvocationChains()).andReturn(inboundChains).anyTimes(); - - ServiceContract contract = new JavaServiceContract(); - Map> operations = Collections.emptyMap(); - contract.setCallbackOperations(operations); - expect(inboundWire.getServiceContract()).andReturn(contract); - expect(inboundChain.getTailInterceptor()).andReturn(null); - - EasyMock.replay(composite, referenceBinding, inboundWire, outboundWire, inboundChain, outboundChain); - - processor.process(inboundWire, outboundWire); - } - - public void testProcess3() { - InboundWire inboundWire = createMock(InboundWire.class); - OutboundWire outboundWire = createMock(OutboundWire.class); - - ServiceBinding serviceBinding = createMock(ServiceBinding.class); - CompositeComponent composite = createMock(CompositeComponent.class); - expect(serviceBinding.getParent()).andReturn(composite); - expect(inboundWire.getContainer()).andReturn(serviceBinding).anyTimes(); - expect(outboundWire.getContainer()).andReturn(serviceBinding).anyTimes(); - - Map, OutboundInvocationChain> outboundChains = - new HashMap, OutboundInvocationChain>(); - DataType type1 = new DataType(String.class, String.class); - List> types = new ArrayList>(); - types.add(type1); - DataType>> inputType1 = new DataType>>(Object[].class, types); - DataType outputType1 = new DataType(String.class, String.class); - Operation op1 = new Operation("test", inputType1, outputType1, null); - ServiceContract outboundContract = new JavaServiceContract(null); - outboundContract.setDataBinding(String.class.getName()); - op1.setServiceContract(outboundContract); - - OutboundInvocationChain outboundChain = createMock(OutboundInvocationChain.class); - outboundChains.put(op1, outboundChain); - expect(outboundWire.getInvocationChains()).andReturn(outboundChains).anyTimes(); - // outboundChain.addInterceptor(EasyMock.anyInt(), (Interceptor) - // EasyMock.anyObject()); - - Map, InboundInvocationChain> inboundChains = - new HashMap, InboundInvocationChain>(); - DataType type2 = new DataType(Node.class, Node.class); - List> types2 = new ArrayList>(); - types2.add(type2); - DataType>> inputType2 = - new DataType>>(Object[].class, types2); - DataType outputType2 = new DataType(String.class, String.class); - Operation op2 = new Operation("test", inputType2, outputType2, null); - ServiceContract inboundContract = new JavaServiceContract(null); - inboundContract.setDataBinding(Node.class.getName()); - op2.setServiceContract(inboundContract); - - InboundInvocationChain inboundChain = createMock(InboundInvocationChain.class); - inboundChains.put(op2, inboundChain); - expect(inboundWire.getInvocationChains()).andReturn(inboundChains).anyTimes(); - inboundChain.addInterceptor(EasyMock.anyInt(), (Interceptor) EasyMock.anyObject()); - - ServiceContract contract = new JavaServiceContract(); - Map> operations = Collections.emptyMap(); - contract.setCallbackOperations(operations); - expect(inboundWire.getServiceContract()).andReturn(contract); - - EasyMock.replay(composite, serviceBinding, inboundWire, outboundWire, inboundChain, outboundChain); - - processor.process(inboundWire, outboundWire); - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DirectedGraphTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DirectedGraphTestCase.java deleted file mode 100755 index 70244df8e2..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DirectedGraphTestCase.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.databinding.impl; - -import java.util.List; - -import junit.framework.Assert; -import junit.framework.TestCase; - -import org.apache.tuscany.core.databinding.impl.DirectedGraph.Edge; -import org.apache.tuscany.core.databinding.impl.DirectedGraph.Vertex; - -public class DirectedGraphTestCase extends TestCase { - private DirectedGraph graph; - - protected void setUp() throws Exception { - super.setUp(); - graph = new DirectedGraph(); - graph.addEdge("a", "b", null, 3); - graph.addEdge("b", "c", null, 1); - graph.addEdge("a", "c", null, 8); - graph.addEdge("a", "d", null, 3); - graph.addEdge("b", "d", null, 2); - graph.addEdge("c", "b", null, 1); - graph.addEdge("c", "d", null, 2); - graph.addEdge("d", "b", null, 1); - graph.addEdge("a", "e", null, 8); - graph.addEdge("c", "c", null, 2); - } - - public void testGraph() { - // System.out.println(graph); - - Vertex vertex = graph.getVertex("a"); - Assert.assertNotNull(vertex); - Assert.assertEquals(vertex.getValue(), "a"); - - Assert.assertNull(graph.getVertex("1")); - - Edge edge = graph.getEdge("a", "b"); - Assert.assertNotNull(edge); - Assert.assertEquals(edge.getWeight(), 3); - - edge = graph.getEdge("b", "a"); - Assert.assertNull(edge); - - DirectedGraph.Path path = graph.getShortestPath("a", "c"); - - List.Edge> edges = path.getEdges(); - Assert.assertEquals(edges.size(), 2); - Assert.assertEquals(edges.get(0), graph.getEdge("a", "b")); - Assert.assertEquals(edges.get(1), graph.getEdge("b", "c")); - - Assert.assertEquals(path.getWeight(), 4); - - DirectedGraph.Path path2 = graph.getShortestPath("b", "e"); - Assert.assertNull(path2); - - DirectedGraph.Path path3 = graph.getShortestPath("a", "a"); - Assert.assertTrue(path3.getWeight() == 0 && path3.getEdges().isEmpty()); - - DirectedGraph.Path path4 = graph.getShortestPath("c", "c"); - Assert.assertTrue(path4.getWeight() == 2 && path4.getEdges().size() == 1); - - // System.out.println(path); - - } - - protected void tearDown() throws Exception { - super.tearDown(); - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/IDLTransformerTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/IDLTransformerTestCase.java deleted file mode 100644 index dd873ea6ee..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/IDLTransformerTestCase.java +++ /dev/null @@ -1,219 +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.databinding.impl; - -import java.util.ArrayList; -import java.util.List; - -import javax.xml.namespace.QName; - -import junit.framework.TestCase; - -import org.apache.tuscany.core.databinding.xml.DOMDataBinding; -import org.apache.tuscany.core.databinding.xml.Node2Object; -import org.apache.tuscany.core.databinding.xml.Node2String; -import org.apache.tuscany.core.databinding.xml.Object2Node; -import org.apache.tuscany.core.databinding.xml.String2Node; -import org.apache.tuscany.spi.databinding.DataBindingRegistry; -import org.apache.tuscany.spi.databinding.TransformationContext; -import org.apache.tuscany.spi.databinding.extension.DOMHelper; -import org.apache.tuscany.spi.databinding.extension.SimpleTypeMapperExtension; -import org.apache.tuscany.spi.idl.ElementInfo; -import org.apache.tuscany.spi.idl.TypeInfo; -import org.apache.tuscany.spi.model.WrapperInfo; -import org.apache.tuscany.spi.model.DataType; -import org.w3c.dom.Document; -import org.w3c.dom.Element; - -public class IDLTransformerTestCase extends TestCase { - private static final String IPO_XML = - "" + "" - + " " - + " 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" - + " " - + " " - + ""; - - private static final String URI_ORDER_XSD = "http://example.com/order.xsd"; - - /** - * @see junit.framework.TestCase#setUp() - */ - protected void setUp() throws Exception { - super.setUp(); - } - - public void testTransform() throws Exception { - List> types0 = new ArrayList>(); - DataType wrapperType = - new DataType(null, Object.class, new QName(URI_ORDER_XSD, "checkOrderStatus")); - types0.add(wrapperType); - DataType>> inputType0 = - new DataType>>("idl:input", Object[].class, types0); - - List> types1 = new ArrayList>(); - DataType customerIdType = - new DataType(null, Object.class, new QName(URI_ORDER_XSD, "customerId")); - DataType orderType = - new DataType(null, Object.class, new QName(URI_ORDER_XSD, "order")); - DataType flagType = new DataType(null, Object.class, new QName(URI_ORDER_XSD, "flag")); - types1.add(customerIdType); - types1.add(orderType); - types1.add(flagType); - DataType>> inputType = - new DataType>>("idl:input", Object[].class, types1); - - DataType statusType = - new DataType(null, Object.class, new QName(URI_ORDER_XSD, "status")); - DataType responseType = - new DataType(null, Object.class, new QName(URI_ORDER_XSD, "checkOrderStatusResponse")); - - org.apache.tuscany.spi.model.Operation op = - new org.apache.tuscany.spi.model.Operation("checkOrderStatus", inputType0, responseType, - null); - op.setDataBinding(DOMDataBinding.NAME); - - inputType0.setOperation(op); - op.setWrapperStyle(true); - ElementInfo inputElement = - new ElementInfo(new QName(URI_ORDER_XSD, "checkOrderStatus"), new TypeInfo(null, false, null)); - wrapperType.setMetadata(ElementInfo.class.getName(), inputElement); - - ElementInfo customerId = - new ElementInfo(new QName("", "customerId"), SimpleTypeMapperExtension.XSD_SIMPLE_TYPES - .get("string")); - ElementInfo order = - new ElementInfo(new QName("", "order"), new TypeInfo(new QName(URI_ORDER_XSD), false, null)); - ElementInfo flag = - new ElementInfo(new QName("", "flag"), SimpleTypeMapperExtension.XSD_SIMPLE_TYPES.get("int")); - - customerIdType.setMetadata(ElementInfo.class.getName(), customerId); - orderType.setMetadata(ElementInfo.class.getName(), order); - flagType.setMetadata(ElementInfo.class.getName(), flag); - - customerIdType.setOperation(op); - orderType.setOperation(op); - flagType.setOperation(op); - - List inputElements = new ArrayList(); - inputElements.add(customerId); - inputElements.add(order); - inputElements.add(flag); - - ElementInfo statusElement = - new ElementInfo(new QName("", "status"), SimpleTypeMapperExtension.XSD_SIMPLE_TYPES.get("string")); - - statusType.setMetadata(ElementInfo.class.getName(), statusElement); - statusType.setOperation(op); - - List outputElements = new ArrayList(); - outputElements.add(statusElement); - - ElementInfo outputElement = - new ElementInfo(new QName(URI_ORDER_XSD, "checkOrderStatusResponse"), new TypeInfo(null, false, - null)); - - responseType.setMetadata(ElementInfo.class.getName(), inputElement); - responseType.setOperation(op); - - WrapperInfo wrapperInfo = - new WrapperInfo(inputElement, outputElement, inputElements, outputElements, inputType, statusType); - op.setWrapper(wrapperInfo); - op.setDataBinding(DOMDataBinding.NAME); - - MediatorImpl m = new MediatorImpl(); - TransformerRegistryImpl tr = new TransformerRegistryImpl(); - tr.registerTransformer(new String2Node()); - tr.registerTransformer(new Node2String()); - tr.registerTransformer(new Node2Object()); - tr.registerTransformer(new Object2Node()); - m.setTransformerRegistry(tr); - DataBindingRegistry dataBindingRegistry = new DataBindingRegistryImpl(); - dataBindingRegistry.register(new DOMDataBinding()); - m.setDataBindingRegistry(dataBindingRegistry); - - Object[] source = new Object[] {"cust001", IPO_XML, Integer.valueOf(1)}; - Input2InputTransformer t = new Input2InputTransformer(); - t.setDataBindingRegistry(dataBindingRegistry); - t.setMediator(m); - - TransformationContext context = new TransformationContextImpl(); - List> types = new ArrayList>(); - types.add(new DataType(Object.class.getName(), String.class, String.class)); - types.add(new DataType("java.lang.String", String.class, String.class)); - types.add(new DataType(Object.class.getName(), int.class, int.class)); - DataType>> inputType1 = - new DataType>>("idl:input", Object[].class, types); - context.setSourceDataType(inputType1); - context.setTargetDataType(op.getInputType()); - Object[] results = t.transform(source, context); - assertEquals(1, results.length); - assertTrue(results[0] instanceof Element); - Element element = (Element)results[0]; - assertEquals("http://example.com/order.xsd", element.getNamespaceURI()); - assertEquals("checkOrderStatus", element.getLocalName()); - - TransformationContext context1 = new TransformationContextImpl(); - DataType sourceType = - new DataType("idl:output", Object.class, op.getOutputType()); - sourceType.setOperation(op.getOutputType().getOperation()); - - context1.setSourceDataType(sourceType); - DataType targetType = - new DataType("idl:output", Object.class, - new DataType("java.lang.Object", String.class, String.class)); - context1.setTargetDataType(targetType); - - Document factory = DOMHelper.newDocument(); - Element responseElement = - factory.createElementNS("http://example.com/order.wsdl", "p:checkOrderStatusResponse"); - Element status = factory.createElement("status"); - responseElement.appendChild(status); - status.appendChild(factory.createTextNode("shipped")); - Output2OutputTransformer t2 = new Output2OutputTransformer(); - t2.setMediator(m); - t2.setDataBindingRegistry(dataBindingRegistry); - Object st = t2.transform(responseElement, context1); - assertEquals("shipped", st); - - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/MediatorImplTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/MediatorImplTestCase.java deleted file mode 100644 index 3cb7f243a9..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/MediatorImplTestCase.java +++ /dev/null @@ -1,118 +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.databinding.impl; - -import java.io.StringWriter; -import java.io.Writer; - -import junit.framework.Assert; -import junit.framework.TestCase; - -import org.apache.tuscany.core.databinding.xml.Node2String; -import org.apache.tuscany.core.databinding.xml.Node2Writer; -import org.apache.tuscany.core.databinding.xml.SAX2DOMPipe; -import org.apache.tuscany.core.databinding.xml.String2SAX; -import org.apache.tuscany.spi.databinding.DataBindingRegistry; -import org.apache.tuscany.spi.databinding.TransformationContext; -import org.apache.tuscany.spi.databinding.TransformerRegistry; -import org.apache.tuscany.spi.model.DataType; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; - -/** - * Test case for MediatorImpl - */ -public class MediatorImplTestCase extends TestCase { - private static final String IPO_XML = - "" + "" - + " " - + " 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" - + " " - + " " - + ""; - - private MediatorImpl mediator; - - protected void setUp() throws Exception { - super.setUp(); - - TransformerRegistry registry = new TransformerRegistryImpl(); - registry.registerTransformer(new String2SAX()); - registry.registerTransformer(new SAX2DOMPipe()); - registry.registerTransformer(new Node2String()); - registry.registerTransformer(new Node2Writer()); - - mediator = new MediatorImpl(); - mediator.setTransformerRegistry(registry); - - DataBindingRegistry dataBindingRegistry = new DataBindingRegistryImpl(); - mediator.setDataBindingRegistry(dataBindingRegistry); - } - - private TransformationContext createTransformationContext(Class sourceType, Class targetType) { - TransformationContext context = new TransformationContextImpl(); - DataType sourceDataType = new DataType(sourceType, sourceType); - DataType targetDataType = new DataType(targetType, targetType); - context.setSourceDataType(sourceDataType); - context.setTargetDataType(targetDataType); - return context; - } - - public void testTransform1() { - TransformationContext context = createTransformationContext(String.class, Node.class); - Object node = - mediator.mediate(IPO_XML, context.getSourceDataType(), context.getTargetDataType(), null); - Assert.assertTrue(node instanceof Document); - Element root = ((Document)node).getDocumentElement(); - Assert.assertEquals(root.getNamespaceURI(), "http://www.example.com/IPO"); - Assert.assertEquals(root.getLocalName(), "purchaseOrder"); - } - - public void testTransform2() { - TransformationContext context = createTransformationContext(String.class, Writer.class); - Writer writer = new StringWriter(); - mediator.mediate(IPO_XML, writer, context.getSourceDataType(), context.getTargetDataType(), null); - String str = writer.toString(); - Assert.assertTrue(str != null && str.indexOf("1999-12-05") != -1); - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/PassByValueInterceptorTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/PassByValueInterceptorTestCase.java deleted file mode 100644 index 571f5ae7ab..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/PassByValueInterceptorTestCase.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.databinding.impl; - -import java.io.Serializable; - -import junit.framework.TestCase; - -/** - * Test case for ByValueInterceptor - */ -public class PassByValueInterceptorTestCase extends TestCase { - private MySerialiable serialiable = new MySerialiable(); - private String str = "ABC"; - private Integer i = new Integer(1); - private String[] array = new String[] {"1", "2"}; - private Object[] values; - - /** - * @see junit.framework.TestCase#setUp() - */ - protected void setUp() throws Exception { - super.setUp(); - values = new Object[] {serialiable, str, i, serialiable, array}; - } - - private static class MySerialiable implements Serializable { - private static final long serialVersionUID = 7827201707529055310L; - private final String name = "Serializable"; - private final int age = 100; - - public int getAge() { - return age; - } - - public String getName() { - return name; - } - } - - public void testCopy() { - Object[] copy = new PassByValueInterceptor().copy(values); - assertTrue(copy[0] instanceof MySerialiable); - MySerialiable copied = (MySerialiable)copy[0]; - assertNotSame(serialiable, copy[0]); - assertEquals(serialiable.getName(), copied.getName()); - assertEquals(serialiable.getAge(), copied.getAge()); - assertSame(copy[1], str); - assertSame(copy[2], i); - assertSame(copy[0], copy[3]); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/PassByValueWirePostProcessorTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/PassByValueWirePostProcessorTestCase.java deleted file mode 100644 index 8d998441e9..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/PassByValueWirePostProcessorTestCase.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.databinding.impl; - -import java.lang.reflect.Type; -import java.util.Hashtable; -import java.util.Map; - -import org.apache.tuscany.spi.ObjectCreationException; -import org.apache.tuscany.spi.component.TargetResolutionException; -import org.apache.tuscany.spi.databinding.DataBindingRegistry; -import org.apache.tuscany.spi.extension.AtomicComponentExtension; -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.InboundInvocationChain; -import org.apache.tuscany.spi.wire.InboundWire; -import org.apache.tuscany.spi.wire.Interceptor; -import org.apache.tuscany.spi.wire.OutboundInvocationChain; -import org.apache.tuscany.spi.wire.OutboundWire; -import org.apache.tuscany.spi.wire.TargetInvoker; - -import junit.framework.TestCase; -import org.apache.tuscany.core.wire.InboundInvocationChainImpl; -import org.apache.tuscany.core.wire.OutboundInvocationChainImpl; -import org.apache.tuscany.core.wire.SynchronousBridgingInterceptor; -import org.easymock.EasyMock; -import static org.easymock.EasyMock.createMock; -import static org.easymock.EasyMock.expect; - -/** - * Testcase for testing if the PassByValueWireProcessor adds the PassByValueInterceptor to the invocation chains and - * also ensure that the outbound and inbound chain of interceptors are linked after this insertion - * - * @version $Rev$ $Date$ - */ -public class PassByValueWirePostProcessorTestCase extends TestCase { - private PassByValueWirePostProcessor processor; - - /** - * @see junit.framework.TestCase#setUp() - */ - protected void setUp() throws Exception { - super.setUp(); - this.processor = new PassByValueWirePostProcessor(); - DataBindingRegistry dataBindingRegistry = createMock(DataBindingRegistry.class); - processor.setDataBindingRegistry(dataBindingRegistry); - } - - public void testProcessInclusionOfInterceptor() { - - InboundWire inboundWire = createMock(InboundWire.class); - OutboundWire outboundWire = createMock(OutboundWire.class); - - ServiceContract serviceContract = new JavaServiceContract(null); - serviceContract.setRemotable(true); - Map, InboundInvocationChain> inChainsMap = - new Hashtable, InboundInvocationChain>(); - - Operation operation1 = new Operation("testMethod", null, null, null); - operation1.setServiceContract(serviceContract); - InboundInvocationChainImpl inChain = new InboundInvocationChainImpl(operation1); - inChainsMap.put(operation1, inChain); - - AtomicComponentExtension componentExtn = new FooComponent(); - - Map, OutboundInvocationChain> outChainsMap = - new Hashtable, OutboundInvocationChain>(); - OutboundInvocationChainImpl outChain = new OutboundInvocationChainImpl(operation1); - outChainsMap.put(operation1, outChain); - - expect(inboundWire.getContainer()).andReturn(componentExtn).times(2); - expect(outboundWire.getContainer()).andReturn(componentExtn).times(2); - expect(inboundWire.getServiceContract()).andReturn(serviceContract); - expect(inboundWire.getInvocationChains()).andReturn(inChainsMap); - expect(outboundWire.getServiceContract()).andReturn(serviceContract).times(2); - expect(outboundWire.getInvocationChains()).andReturn(outChainsMap).times(2); - - Interceptor inInterceptor = createMock(Interceptor.class); - Interceptor outInterceptor = createMock(Interceptor.class); - inChain.addInterceptor(0, inInterceptor); - outChain.addInterceptor(0, outInterceptor); - outChain.addInterceptor(new SynchronousBridgingInterceptor(inChain.getHeadInterceptor())); - - EasyMock.replay(inboundWire, outboundWire); - processor.process(outboundWire, inboundWire); - - assertEquals(true, inChain.getHeadInterceptor() instanceof PassByValueInterceptor); - assertEquals(true, - outChain.getTailInterceptor().getNext() instanceof PassByValueInterceptor); - assertEquals(true, outChain.getTailInterceptor().getNext().equals( - inChain.getHeadInterceptor())); - - } - - public void testProcessExclusionOfInterceptorWhenAllowsPassByReference() { - InboundWire inboundWire = createMock(InboundWire.class); - OutboundWire outboundWire = createMock(OutboundWire.class); - - ServiceContract serviceContract = new JavaServiceContract(null); - serviceContract.setRemotable(true); - Map, InboundInvocationChain> inChainsMap = - new Hashtable, InboundInvocationChain>(); - - Operation operation1 = new Operation("testMethod", null, null, null); - InboundInvocationChainImpl inChain = new InboundInvocationChainImpl(operation1); - inChainsMap.put(operation1, inChain); - - AtomicComponentExtension componentExtn = new FooComponent(); - componentExtn.setAllowsPassByReference(true); - - - Map, OutboundInvocationChain> outChainsMap = - new Hashtable, OutboundInvocationChain>(); - OutboundInvocationChainImpl outChain = new OutboundInvocationChainImpl(operation1); - outChainsMap.put(operation1, outChain); - - expect(inboundWire.getContainer()).andReturn(componentExtn).times(2); - expect(outboundWire.getContainer()).andReturn(componentExtn).times(2); - expect(inboundWire.getServiceContract()).andReturn(serviceContract); - expect(inboundWire.getInvocationChains()).andReturn(inChainsMap); - expect(outboundWire.getServiceContract()).andReturn(serviceContract).times(2); - expect(outboundWire.getInvocationChains()).andReturn(outChainsMap).times(2); - - Interceptor inInterceptor = createMock(Interceptor.class); - Interceptor outInterceptor = createMock(Interceptor.class); - inChain.addInterceptor(0, inInterceptor); - outChain.addInterceptor(0, outInterceptor); - outChain.addInterceptor(new SynchronousBridgingInterceptor(inChain.getHeadInterceptor())); - - EasyMock.replay(inboundWire, outboundWire); - processor.process(outboundWire, inboundWire); - - assertEquals(false, inChain.getHeadInterceptor() instanceof PassByValueInterceptor); - assertEquals(false, - outChain.getTailInterceptor().getNext() instanceof PassByValueInterceptor); - assertEquals(true, outChain.getTailInterceptor().getNext().equals( - inChain.getHeadInterceptor())); - } - - private class FooComponent extends AtomicComponentExtension { - - public FooComponent() { - super(null, null, null, null, null, null, 0); - } - - public Object createInstance() throws ObjectCreationException { - return null; - } - - public Object getTargetInstance() throws TargetResolutionException { - return null; - } - - public TargetInvoker createTargetInvoker(String targetName, Operation operation, InboundWire callbackWire) { - return null; - } - - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/TransformerRegistryImplTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/TransformerRegistryImplTestCase.java deleted file mode 100644 index 6250efd897..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/TransformerRegistryImplTestCase.java +++ /dev/null @@ -1,106 +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.databinding.impl; - -import static org.easymock.EasyMock.createMock; -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.replay; - -import java.util.List; - -import junit.framework.Assert; -import junit.framework.TestCase; - -import org.apache.tuscany.spi.databinding.Transformer; -import org.apache.tuscany.spi.databinding.TransformerRegistry; - -/** - * - */ -public class TransformerRegistryImplTestCase extends TestCase { - private TransformerRegistry registry; - - /** - * @see junit.framework.TestCase#setUp() - */ - protected void setUp() throws Exception { - super.setUp(); - registry = new TransformerRegistryImpl(); - } - - public void testRegisterTransformer1() { - Transformer transformer = createMock(Transformer.class); - registry.registerTransformer("a", "b", 10, transformer); - Transformer t = registry.getTransformer("a", "b"); - Assert.assertSame(t, transformer); - } - - public void testRegisterTransformerTransformer() { - Transformer transformer = createMock(Transformer.class); - expect(transformer.getSourceDataBinding()).andReturn("a"); - expect(transformer.getTargetDataBinding()).andReturn("b"); - expect(transformer.getWeight()).andReturn(10); - replay(transformer); - registry.registerTransformer(transformer); - Transformer t = registry.getTransformer("a", "b"); - Assert.assertSame(t, transformer); - } - - public void testUnregisterTransformer() { - Transformer transformer = createMock(Transformer.class); - registry.registerTransformer("a", "b", 10, transformer); - boolean result = registry.unregisterTransformer("a", "b"); - Assert.assertTrue(result); - Transformer t = registry.getTransformer("a", "b"); - Assert.assertNull(t); - } - - public void testGetTransformerChain() { - Transformer t1 = createMock(Transformer.class); - expect(t1.getSourceDataBinding()).andReturn("a"); - expect(t1.getTargetDataBinding()).andReturn("b"); - expect(t1.getWeight()).andReturn(10); - replay(t1); - Transformer t2 = createMock(Transformer.class); - expect(t2.getSourceDataBinding()).andReturn("b"); - expect(t2.getTargetDataBinding()).andReturn("c"); - expect(t2.getWeight()).andReturn(20); - replay(t2); - - Transformer t3 = createMock(Transformer.class); - expect(t3.getSourceDataBinding()).andReturn("a"); - expect(t3.getTargetDataBinding()).andReturn("c"); - expect(t3.getWeight()).andReturn(120); - replay(t3); - - registry.registerTransformer(t1); - registry.registerTransformer(t2); - registry.registerTransformer(t3); - - List l1 = registry.getTransformerChain("a", "b"); - Assert.assertTrue(l1.size() == 1 && l1.get(0) == t1); - List l2 = registry.getTransformerChain("a", "c"); - Assert.assertTrue(l2.size() == 2 && l2.get(0) == t1 && l2.get(1) == t2); - List l3 = registry.getTransformerChain("a", "d"); - Assert.assertNull(l3); - - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/xml/DOM2StAXTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/xml/DOM2StAXTestCase.java deleted file mode 100644 index 942b2d67e9..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/xml/DOM2StAXTestCase.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.databinding.xml; - -import javax.xml.stream.XMLStreamReader; - -import junit.framework.Assert; -import junit.framework.TestCase; - -import org.w3c.dom.Node; - -public class DOM2StAXTestCase extends TestCase { - private static final String IPO_XML = - "" + "" - + " " - + " 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" - + " " - + " " - + ""; - - /** - * @see junit.framework.TestCase#setUp() - */ - protected void setUp() throws Exception { - super.setUp(); - } - - public void testTransformation() { - String2Node t1 = new String2Node(); - Node node = t1.transform(IPO_XML, null); - Node2XMLStreamReader t2 = new Node2XMLStreamReader(); - XMLStreamReader reader = t2.transform(node, null); - XMLStreamReader2String t3 = new XMLStreamReader2String(); - String xml = t3.transform(reader, null); - Assert.assertTrue(xml != null && xml.indexOf("1999-12-05") != -1); - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/xml/DataPipeTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/xml/DataPipeTestCase.java deleted file mode 100644 index d4eaf9b2a9..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/xml/DataPipeTestCase.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.databinding.xml; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.Reader; -import java.io.Writer; - -import junit.framework.Assert; -import junit.framework.TestCase; - -import org.apache.tuscany.core.databinding.impl.PipedTransformer; -import org.apache.tuscany.spi.databinding.extension.DOMHelper; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; - -/** - * Test case for DataPipe - */ -public class DataPipeTestCase extends TestCase { - - public final void testStreamPipe() throws IOException { - byte[] bytes = new byte[] {1, 2, 3}; - StreamDataPipe pipe = new StreamDataPipe(); - Assert.assertSame(OutputStream.class, pipe.getSourceType()); - Assert.assertSame(InputStream.class, pipe.getTargetType()); - OutputStream os = pipe.getSink(); - os.write(bytes); - byte[] newBytes = new byte[16]; - int count = pipe.getResult().read(newBytes); - Assert.assertEquals(3, count); - for (int i = 0; i < bytes.length; i++) { - Assert.assertEquals(bytes[i], newBytes[i]); - } - } - - public final void testWriter2ReaderPipe() throws IOException { - String str = "ABC"; - Writer2ReaderDataPipe pipe = new Writer2ReaderDataPipe(); - Assert.assertSame(Writer.class, pipe.getSourceType()); - Assert.assertSame(Reader.class, pipe.getTargetType()); - pipe.getSink().write(str); - char[] buf = new char[16]; - int count = pipe.getResult().read(buf); - Assert.assertEquals(3, count); - for (int i = 0; i < str.length(); i++) { - Assert.assertEquals(str.charAt(i), buf[i]); - } - } - - public final void testPiped() throws Exception { - Node2Writer node2Writer = new Node2Writer(); - Writer2ReaderDataPipe pipe = new Writer2ReaderDataPipe(); - PipedTransformer transformer = - new PipedTransformer(node2Writer, pipe); - Document document = DOMHelper.newDocument(); - Element element = document.createElementNS("http://ns1", "root"); - document.appendChild(element); - Reader reader = transformer.transform(document, null); - Assert.assertEquals(transformer.getWeight(), node2Writer.getWeight() + pipe.getWeight()); - Assert.assertEquals(transformer.getSourceDataBinding(), node2Writer.getSourceDataBinding()); - Assert.assertEquals(transformer.getTargetDataBinding(), pipe.getTargetDataBinding()); - char[] buf = new char[120]; - int count = reader.read(buf); - String xml = new String(buf, 0, count); - Assert.assertTrue(xml.contains("")); - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/xml/Node2StringTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/xml/Node2StringTestCase.java deleted file mode 100755 index 9b9aa3b893..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/xml/Node2StringTestCase.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.databinding.xml; - -import junit.framework.TestCase; - -import org.apache.tuscany.spi.databinding.extension.DOMHelper; -import org.w3c.dom.Document; -import org.w3c.dom.Element; - -public class Node2StringTestCase extends TestCase { - public void testTransformation() throws Exception { - Document document = DOMHelper.newDocument(); - Element element = document.createElementNS("http://ns1", "test"); - document.appendChild(element); - - new Node2String().transform(document, null); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/xml/PushTransformationTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/xml/PushTransformationTestCase.java deleted file mode 100644 index a2318b2faa..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/xml/PushTransformationTestCase.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.databinding.xml; - -import javax.xml.stream.XMLStreamReader; - -import junit.framework.Assert; -import junit.framework.TestCase; - -import org.apache.tuscany.core.databinding.impl.PipedTransformer; -import org.w3c.dom.Node; -import org.xml.sax.ContentHandler; - -public class PushTransformationTestCase extends TestCase { - private static final String IPO_XML = - "" + "" - + " " - + " 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" - + " " - + " " - + ""; - - /** - * @see junit.framework.TestCase#setUp() - */ - protected void setUp() throws Exception { - super.setUp(); - } - - public void testTransformation() { - String2XMLStreamReader t1 = new String2XMLStreamReader(); - XMLStreamReader reader = t1.transform(IPO_XML, null); - XMLStreamReader2SAX t2 = new XMLStreamReader2SAX(); - PipedTransformer t3 = - new PipedTransformer(t2, new SAX2DOMPipe()); - Node node = t3.transform(reader, null); - Assert.assertNotNull(node); - Node2String t4 = new Node2String(); - String xml = t4.transform(node, null); - Assert.assertTrue(xml != null && xml.indexOf("1999-12-05") != -1); - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/xml/StAXHelperTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/xml/StAXHelperTestCase.java deleted file mode 100644 index 7d18e83ac6..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/xml/StAXHelperTestCase.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.databinding.xml; - -import javax.xml.stream.XMLStreamReader; - -import junit.framework.TestCase; - -/** - * Test Case for StAXHelper - */ -public class StAXHelperTestCase extends TestCase { - private static final String XML = - "" + "" - + ""; - - /** - * @see junit.framework.TestCase#setUp() - */ - protected void setUp() throws Exception { - super.setUp(); - } - - public void testHelper() throws Exception { - XMLStreamReader reader = StAXHelper.createXMLStreamReader(XML); - String xml = StAXHelper.save(reader); - reader = StAXHelper.createXMLStreamReader(xml); - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/xml/TraxTransformerTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/xml/TraxTransformerTestCase.java deleted file mode 100644 index 7e9494d423..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/databinding/xml/TraxTransformerTestCase.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.databinding.xml; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.StringReader; -import java.io.StringWriter; -import java.io.Writer; -import java.net.URL; - -import junit.framework.TestCase; - -import org.w3c.dom.Node; -import org.xml.sax.Attributes; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; -import org.xml.sax.helpers.DefaultHandler; - -/** - * - */ -public class TraxTransformerTestCase extends TestCase { - private URL url; - - /** - * @see junit.framework.TestCase#setUp() - */ - protected void setUp() throws Exception { - super.setUp(); - url = getClass().getResource("foo.xml"); - } - - public void testTransformDOM() throws IOException { - InputStream is = url.openStream(); - InputStream2Node t1 = new InputStream2Node(); - Node node = t1.transform(is, null); - is.close(); - Writer writer = new StringWriter(); - Node2Writer t2 = new Node2Writer(); - t2.transform(node, writer, null); - String str = writer.toString(); - StringReader reader = new StringReader(str); - Reader2Node t3 = new Reader2Node(); - node = t3.transform(reader, null); - ByteArrayOutputStream os = new ByteArrayOutputStream(); - Node2OutputStream t4 = new Node2OutputStream(); - t4.transform(node, os, null); - InputSource inputSource = new InputSource(new ByteArrayInputStream(os.toByteArray())); - InputSource2Node t5 = new InputSource2Node(); - node = t5.transform(inputSource, null); - } - - public void testTransformSAX() throws IOException { - MyContentHandler handler = new MyContentHandler(); - InputStream is = url.openStream(); - InputStream2SAX t1 = new InputStream2SAX(); - t1.transform(is, handler, null); - is.close(); - - String xml = "bar"; - - InputSource inputSource = new InputSource(new StringReader(xml)); - InputSource2SAX t2 = new InputSource2SAX(); - MyContentHandler handler2 = new MyContentHandler(); - t2.transform(inputSource, handler2, null); - - } - - private static class MyContentHandler extends DefaultHandler { - - @Override - public void startElement(String namespaceURI, String localName, String qName, Attributes atts) - throws SAXException { - super.startElement(namespaceURI, localName, qName, atts); - } - - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/deployer/BootstrapDeployerTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/deployer/BootstrapDeployerTestCase.java deleted file mode 100644 index f98f749c9f..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/deployer/BootstrapDeployerTestCase.java +++ /dev/null @@ -1,168 +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.URL; -import java.util.Collection; -import java.util.Map; -import javax.xml.stream.XMLInputFactory; - -import org.apache.tuscany.spi.bootstrap.ComponentNames; -import org.apache.tuscany.spi.component.Component; -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.component.SCAObject; -import org.apache.tuscany.spi.deployer.DeploymentContext; -import org.apache.tuscany.spi.loader.LoaderException; -import org.apache.tuscany.spi.model.BindingDefinition; -import org.apache.tuscany.spi.model.BoundServiceDefinition; -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.Property; -import org.apache.tuscany.spi.model.PropertyValue; -import org.apache.tuscany.spi.model.ReferenceDefinition; -import org.apache.tuscany.spi.model.ServiceDefinition; - -import junit.framework.TestCase; -import org.apache.tuscany.core.bootstrap.Bootstrapper; -import org.apache.tuscany.core.bootstrap.DefaultBootstrapper; -import org.apache.tuscany.core.implementation.system.model.SystemCompositeImplementation; -import org.apache.tuscany.core.mock.component.BasicInterface; -import org.apache.tuscany.core.monitor.NullMonitorFactory; -import static org.easymock.EasyMock.createNiceMock; -import static org.easymock.EasyMock.isA; -import static org.easymock.EasyMock.replay; -import static org.easymock.EasyMock.verify; - -/** - * Verifies the default boostrap deployer - * - * @version $Rev$ $Date$ - */ -public class BootstrapDeployerTestCase extends TestCase { - private DeployerImpl deployer; - private DeploymentContext deploymentContext; - private ComponentDefinition componentDefinition; - private SystemCompositeImplementation implementation; - - @SuppressWarnings("unchecked") - public void testBoot1Load() throws LoaderException { - CompositeComponent parent = createNiceMock(CompositeComponent.class); - URL scdl = BootstrapDeployerTestCase.class.getResource("boot1.scdl"); - implementation.setScdlLocation(scdl); - deployer.load(parent, componentDefinition, deploymentContext); - CompositeComponentType> composite = - implementation.getComponentType(); - assertNotNull(composite); - assertEquals("boot1", composite.getName()); - - // check parse of - Map services = composite.getDeclaredServices(); - assertEquals(1, services.size()); // included doesn't count - services = composite.getServices(); - assertEquals(2, services.size()); // included counts - BoundServiceDefinition serviceDefinition = (BoundServiceDefinition) services.get("service"); - assertNotNull(serviceDefinition); - assertEquals("service", serviceDefinition.getName()); - assertEquals(BasicInterface.class, serviceDefinition.getServiceContract().getInterfaceClass()); - Collection bindings = serviceDefinition.getBindings(); - assertTrue(bindings.isEmpty()); - - // check parse of - Map>> components = composite.getDeclaredComponents(); - assertEquals(1, components.size()); // included doesn't count - components = composite.getComponents(); - assertEquals(2, components.size()); // included counts - ComponentDefinition> component = components.get("component"); - assertNotNull(component); - PropertyValue propVal = component.getPropertyValues().get("publicProperty"); - assertEquals("propval", propVal.getValueFactory().getInstance()); - - // check introspection of implementation - ComponentType componentType = component.getImplementation().getComponentType(); - assertNotNull(componentType); // details checked in SystemComponentTypeLoaderTestCase - - // check included component - Map includes = composite.getIncludes(); - assertEquals(1, includes.size()); - Include include = includes.get("boot1-include"); - assertNotNull(include); - CompositeComponentType included = include.getIncluded(); - assertNotNull(included); - assertEquals(1, included.getComponents().size()); - } - - public void testBoot1Deployment() throws Exception { - URL scdl = BootstrapDeployerTestCase.class.getResource("boot1.scdl"); - implementation.setScdlLocation(scdl); - CompositeComponent parent = createNiceMock(CompositeComponent.class); - parent.register(isA(SCAObject.class)); - replay(parent); - // load the boot1 file using the bootstrap deployer - componentDefinition.setName("simple"); - Component component = deployer.deploy(parent, componentDefinition); - assertNotNull(component); - verify(parent); - } - - public void testBoot2Deployment() throws Exception { - URL scdl = BootstrapDeployerTestCase.class.getResource("boot2.scdl"); - implementation.setScdlLocation(scdl); - CompositeComponent parent = createNiceMock(CompositeComponent.class); - parent.register(isA(SCAObject.class)); - replay(parent); - - // load the boot2 file using the bootstrap deployer - componentDefinition.setName("newDeployer"); - CompositeComponent component = (CompositeComponent) deployer.deploy(parent, componentDefinition); - assertNotNull(component); - verify(parent); - component.start(); - SCAObject newDeployer = component.getSystemChild(ComponentNames.TUSCANY_DEPLOYER); - assertNotNull(newDeployer); - SCAObject wireService = component.getSystemChild(ComponentNames.TUSCANY_WIRE_SERVICE); - assertNotNull(wireService); - -/* // FIXME - // load the boot2 file using the newly loaded deployer - parent.reset(); - parent.expects(once()).method("register").withAnyArguments(); - componentDefinition.setName("newDeployer2"); - component = newDeployer.deploy((CompositeComponent) parent.proxy(), componentDefinition); - assertNotNull(component); - parent.verify(); - component.start(); - Deployer newDeployer2 = (Deployer) component.getServiceInstance("deployer"); - assertNotNull(newDeployer2); -*/ - } - - protected void setUp() throws Exception { - super.setUp(); - XMLInputFactory xmlFactory = XMLInputFactory.newInstance(); - Bootstrapper bootstrapper = new DefaultBootstrapper(new NullMonitorFactory(), xmlFactory, null); - deployer = (DeployerImpl) bootstrapper.createDeployer(); - deploymentContext = new RootDeploymentContext(null, xmlFactory, null, null); - implementation = new SystemCompositeImplementation(); - implementation.setClassLoader(getClass().getClassLoader()); - componentDefinition = new ComponentDefinition(implementation); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/idl/java/ConversationalIntrospectionTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/idl/java/ConversationalIntrospectionTestCase.java deleted file mode 100644 index 2eabf4add0..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/idl/java/ConversationalIntrospectionTestCase.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.idl.java; - -import org.osoa.sca.annotations.EndConversation; -import org.osoa.sca.annotations.Scope; - -import org.apache.tuscany.spi.idl.InvalidConversationalOperationException; -import org.apache.tuscany.spi.idl.java.JavaServiceContract; -import static org.apache.tuscany.spi.model.InteractionScope.CONVERSATIONAL; -import static org.apache.tuscany.spi.model.InteractionScope.NONCONVERSATIONAL; -import org.apache.tuscany.spi.model.Operation; - -import junit.framework.TestCase; - -/** - * @version $Rev$ $Date$ - */ -public class ConversationalIntrospectionTestCase extends TestCase { - private JavaInterfaceProcessorRegistryImpl registry = new JavaInterfaceProcessorRegistryImpl(); - - public void testServiceContractConversationalInformationIntrospection() throws Exception { - JavaServiceContract contract = registry.introspect(Foo.class); - assertEquals(CONVERSATIONAL, contract.getInteractionScope()); - int seq = contract.getOperations().get("operation").getConversationSequence(); - assertEquals(Operation.CONVERSATION_CONTINUE, seq); - seq = contract.getOperations().get("endOperation").getConversationSequence(); - assertEquals(Operation.CONVERSATION_END, seq); - } - - public void testBadServiceContract() throws Exception { - try { - registry.introspect(BadFoo.class); - fail(); - } catch (InvalidConversationalOperationException e) { - //expected - } - } - - public void testNonConversationalInformationIntrospection() throws Exception { - JavaServiceContract contract = registry.introspect(NonConversationalFoo.class); - assertEquals(NONCONVERSATIONAL, contract.getInteractionScope()); - int seq = contract.getOperations().get("operation").getConversationSequence(); - assertEquals(Operation.NO_CONVERSATION, seq); - } - - @Scope("CONVERSATION") - private interface Foo { - void operation(); - - @EndConversation - void endOperation(); - } - - private interface BadFoo { - void operation(); - - @EndConversation - void endOperation(); - } - - private interface NonConversationalFoo { - void operation(); - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/idl/java/JavaInterfaceProcessorRegistryImplTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/idl/java/JavaInterfaceProcessorRegistryImplTestCase.java deleted file mode 100644 index e3a7deb10a..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/idl/java/JavaInterfaceProcessorRegistryImplTestCase.java +++ /dev/null @@ -1,100 +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.idl.java; - -import java.lang.reflect.Type; -import java.util.List; -import java.util.Map; - -import org.apache.tuscany.spi.idl.InvalidServiceContractException; -import org.apache.tuscany.spi.idl.java.JavaInterfaceProcessor; -import org.apache.tuscany.spi.idl.java.JavaServiceContract; -import org.apache.tuscany.spi.model.DataType; -import org.apache.tuscany.spi.model.Operation; - -import junit.framework.TestCase; -import org.apache.tuscany.core.util.JavaIntrospectionHelper; -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.isA; -import static org.easymock.EasyMock.replay; -import static org.easymock.EasyMock.verify; - -/** - * @version $Rev$ $Date$ - */ -public class JavaInterfaceProcessorRegistryImplTestCase extends TestCase { - private JavaInterfaceProcessorRegistryImpl impl; - - public void testSimpleInterface() throws InvalidServiceContractException { - JavaServiceContract contract = impl.introspect(Simple.class); - // TODO spec to clairfy interface name - assertEquals(JavaIntrospectionHelper.getBaseName(Simple.class), contract.getInterfaceName()); - assertEquals(Simple.class, contract.getInterfaceClass()); - Map> operations = contract.getOperations(); - assertEquals(1, operations.size()); - Operation baseInt = operations.get("baseInt"); - assertNotNull(baseInt); - - DataType returnType = baseInt.getOutputType(); - assertEquals(Integer.TYPE, returnType.getPhysical()); - assertEquals(Integer.TYPE, returnType.getLogical()); - - List> parameterTypes = baseInt.getInputType().getLogical(); - assertEquals(1, parameterTypes.size()); - DataType arg0 = parameterTypes.get(0); - assertEquals(Integer.TYPE, arg0.getPhysical()); - assertEquals(Integer.TYPE, arg0.getLogical()); - - List> faultTypes = baseInt.getFaultTypes(); - assertEquals(1, faultTypes.size()); - DataType fault0 = faultTypes.get(0); - assertEquals(IllegalArgumentException.class, fault0.getPhysical()); - assertEquals(IllegalArgumentException.class, fault0.getLogical()); - } - - public void testUnregister() throws Exception { - JavaInterfaceProcessor processor = createMock(JavaInterfaceProcessor.class); - processor.visitInterface(eq(Base.class), EasyMock.same((Class)null), isA(JavaServiceContract.class)); - expectLastCall().once(); - replay(processor); - impl.registerProcessor(processor); - impl.introspect(Base.class); - impl.unregisterProcessor(processor); - impl.introspect(Base.class); - verify(processor); - } - - protected void setUp() throws Exception { - super.setUp(); - impl = new JavaInterfaceProcessorRegistryImpl(); - - } - - private static interface Base { - int baseInt(int param) throws IllegalArgumentException; - } - - private static interface Simple extends Base { - - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/IntrospectionRegistryTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/IntrospectionRegistryTestCase.java deleted file mode 100644 index fb5e7fbb1f..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/IntrospectionRegistryTestCase.java +++ /dev/null @@ -1,124 +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 java.lang.reflect.Method; -import java.lang.reflect.Field; -import java.lang.reflect.Constructor; - -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.deployer.DeploymentContext; -import org.apache.tuscany.spi.implementation.java.ImplementationProcessor; -import org.apache.tuscany.spi.implementation.java.JavaMappedProperty; -import org.apache.tuscany.spi.implementation.java.JavaMappedReference; -import org.apache.tuscany.spi.implementation.java.JavaMappedService; -import org.apache.tuscany.spi.implementation.java.PojoComponentType; - -import junit.framework.TestCase; -import org.apache.tuscany.core.implementation.IntrospectionRegistryImpl.Monitor; -import org.apache.tuscany.core.monitor.NullMonitorFactory; -import org.easymock.EasyMock; - -/** - * @version $Rev$ $Date$ - */ -public class IntrospectionRegistryTestCase extends TestCase { - - private Monitor monitor; - - public void testRegister() throws Exception { - IntrospectionRegistryImpl registry = new IntrospectionRegistryImpl(monitor); - ImplementationProcessor processor = EasyMock.createNiceMock(ImplementationProcessor.class); - registry.registerProcessor(processor); - } - - public void testUnegister() throws Exception { - IntrospectionRegistryImpl registry = new IntrospectionRegistryImpl(monitor); - ImplementationProcessor processor = EasyMock.createNiceMock(ImplementationProcessor.class); - registry.registerProcessor(processor); - registry.unregisterProcessor(processor); - } - - @SuppressWarnings("unchecked") - public void testWalk() throws Exception { - IntrospectionRegistryImpl registry = new IntrospectionRegistryImpl(monitor); - ImplementationProcessor processor = EasyMock.createMock(ImplementationProcessor.class); - processor.visitClass(EasyMock.isA(CompositeComponent.class), - EasyMock.eq(Bar.class), - EasyMock.isA(PojoComponentType.class), - EasyMock.isA(DeploymentContext.class)); - processor.visitConstructor(EasyMock.isA(CompositeComponent.class), - EasyMock.isA(Constructor.class), - EasyMock.isA(PojoComponentType.class), - EasyMock.isA(DeploymentContext.class)); - processor.visitMethod(EasyMock.isA(CompositeComponent.class), - EasyMock.isA(Method.class), - EasyMock.isA(PojoComponentType.class), - EasyMock.isA(DeploymentContext.class)); - processor.visitField(EasyMock.isA(CompositeComponent.class), - EasyMock.isA(Field.class), - EasyMock.isA(PojoComponentType.class), - EasyMock.isA(DeploymentContext.class)); - processor.visitSuperClass(EasyMock.isA(CompositeComponent.class), - EasyMock.isA(Class.class), - EasyMock.isA(PojoComponentType.class), - EasyMock.isA(DeploymentContext.class)); - processor.visitEnd(EasyMock.isA(CompositeComponent.class), - EasyMock.isA(Class.class), - EasyMock.isA(PojoComponentType.class), - EasyMock.isA(DeploymentContext.class)); - - // mock.expects(once()).method("visitClass"); -// mock.expects(once()).method("visitMethod"); -// mock.expects(once()).method("visitField"); -// mock.expects(once()).method("visitConstructor"); -// mock.expects(once()).method("visitSuperClass"); -// mock.expects(once()).method("visitEnd"); - EasyMock.replay(processor); - registry.registerProcessor(processor); - registry.introspect(EasyMock.createNiceMock(CompositeComponent.class), - Bar.class, - new PojoComponentType>(), - EasyMock.createNiceMock(DeploymentContext.class)); - EasyMock.verify(processor); - } - - - protected void setUp() throws Exception { - super.setUp(); - monitor = new NullMonitorFactory().getMonitor(Monitor.class); - } - - private class Baz { - - } - - private class Bar extends Baz { - - protected String bar; - - public Bar() { - } - - public void bar() { - } - - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/PojoAtomicComponentTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/PojoAtomicComponentTestCase.java deleted file mode 100644 index 6fcef3622e..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/PojoAtomicComponentTestCase.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.implementation; - -import org.apache.tuscany.spi.ObjectFactory; -import org.apache.tuscany.spi.component.AtomicComponent; -import org.apache.tuscany.spi.component.TargetInvokerCreationException; -import org.apache.tuscany.spi.model.Operation; -import org.apache.tuscany.spi.model.Scope; -import org.apache.tuscany.spi.wire.InboundWire; -import org.apache.tuscany.spi.wire.OutboundWire; -import org.apache.tuscany.spi.wire.TargetInvoker; - -import junit.framework.TestCase; -import org.apache.tuscany.core.injection.EventInvoker; -import org.apache.tuscany.core.injection.PojoObjectFactory; -import org.easymock.EasyMock; - -/** - * @version $Rev$ $Date$ - */ -public class PojoAtomicComponentTestCase extends TestCase { - private PojoObjectFactory factory; - - @SuppressWarnings({"unchecked"}) - public void testDestroy() throws Exception { - PojoConfiguration config = new PojoConfiguration(); - config.setInstanceFactory(factory); - EventInvoker invoker = EasyMock.createMock(EventInvoker.class); - invoker.invokeEvent(EasyMock.notNull()); - EasyMock.replay(invoker); - config.setDestroyInvoker(invoker); - AtomicComponent component = new TestAtomicComponent(config); - assertTrue(component.isDestroyable()); - component.destroy(new Object()); - EasyMock.verify(invoker); - } - - @SuppressWarnings({"unchecked"}) - public void testInit() throws Exception { - PojoConfiguration config = new PojoConfiguration(); - config.setInstanceFactory(factory); - EventInvoker invoker = EasyMock.createMock(EventInvoker.class); - invoker.invokeEvent(EasyMock.notNull()); - EasyMock.replay(invoker); - config.setInitInvoker(invoker); - AtomicComponent component = new TestAtomicComponent(config); - component.init(new Object()); - EasyMock.verify(invoker); - } - - public void testOptimizable() throws Exception { - PojoConfiguration config = new PojoConfiguration(); - config.setInstanceFactory(factory); - TestAtomicComponent component = new TestAtomicComponent(config); - assertTrue(component.isOptimizable()); - } - - @SuppressWarnings({"unchecked"}) - public void testDestroyableButOptimizable() throws Exception { - PojoConfiguration config = new PojoConfiguration(); - config.setInstanceFactory(factory); - EventInvoker invoker = EasyMock.createMock(EventInvoker.class); - invoker.invokeEvent(EasyMock.notNull()); - EasyMock.replay(invoker); - config.setDestroyInvoker(invoker); - TestAtomicComponent component = new TestAtomicComponent(config); - assertTrue(component.isOptimizable()); - } - - @SuppressWarnings({"unchecked"}) - public void testStatelessOptimizable() throws Exception { - PojoConfiguration config = new PojoConfiguration(); - config.setInstanceFactory(factory); - TestStatelessAtomicComponent component = new TestStatelessAtomicComponent(config); - assertTrue(component.isOptimizable()); - } - - @SuppressWarnings({"unchecked"}) - public void testNotOptimizable() throws Exception { - PojoConfiguration config = new PojoConfiguration(); - config.setInstanceFactory(factory); - EventInvoker invoker = EasyMock.createMock(EventInvoker.class); - invoker.invokeEvent(EasyMock.notNull()); - EasyMock.replay(invoker); - config.setDestroyInvoker(invoker); - TestStatelessAtomicComponent component = new TestStatelessAtomicComponent(config); - assertFalse(component.isOptimizable()); - } - - protected void setUp() throws Exception { - super.setUp(); - factory = new PojoObjectFactory(Foo.class.getConstructor()); - } - - private class TestAtomicComponent extends PojoAtomicComponent { - - public TestAtomicComponent(PojoConfiguration configuration) { - super(configuration); - } - - public Scope getScope() { - return Scope.COMPOSITE; - } - - protected ObjectFactory createWireFactory(Class interfaze, OutboundWire wire) { - return null; - } - - public TargetInvoker createTargetInvoker(String targetName, Operation operation, InboundWire callbackWire) - throws TargetInvokerCreationException { - return null; - } - } - - private class TestStatelessAtomicComponent extends PojoAtomicComponent { - - public TestStatelessAtomicComponent(PojoConfiguration configuration) { - super(configuration); - } - - public Scope getScope() { - return Scope.STATELESS; - } - - protected ObjectFactory createWireFactory(Class interfaze, OutboundWire wire) { - return null; - } - - public TargetInvoker createTargetInvoker(String targetName, Operation operation, InboundWire callbackWire) - throws TargetInvokerCreationException { - return null; - } - } - - private static class Foo { - public Foo() { - } - } - -} - - diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/TestUtils.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/TestUtils.java deleted file mode 100644 index e18fc99861..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/TestUtils.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.implementation; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.tuscany.spi.component.AtomicComponent; -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.idl.InvalidServiceContractException; -import org.apache.tuscany.spi.idl.java.JavaInterfaceProcessorRegistry; -import org.apache.tuscany.spi.idl.java.JavaServiceContract; -import org.apache.tuscany.spi.wire.InboundWire; - -import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl; -import org.apache.tuscany.core.wire.InboundWireImpl; - -/** - * @version $Rev$ $Date$ - */ -public final class TestUtils { - private static final JavaInterfaceProcessorRegistry REGISTRY = new JavaInterfaceProcessorRegistryImpl(); - - private TestUtils() { - } - - public static List populateInboundWires(AtomicComponent component, List wires) - throws InvalidServiceContractException { - for (InboundWire wire : wires) { - wire.setContainer(component); - } - return wires; - } - - public static List createInboundWires(List> interfazes) - throws InvalidServiceContractException { - List wires = new ArrayList(interfazes.size()); - for (Class interfaze : interfazes) { - InboundWire wire = createInboundWire(interfaze); - wires.add(wire); - } - return wires; - } - - public static InboundWire createInboundWire(Class interfaze) throws InvalidServiceContractException { - InboundWire wire = new InboundWireImpl(); - JavaServiceContract contract = REGISTRY.introspect(interfaze); - wire.setServiceContract(contract); - return wire; - } - - public static InboundWire createInboundWire(Class interfaze, CompositeComponent parent) - throws InvalidServiceContractException { - InboundWire wire = createInboundWire(interfaze); - wire.setContainer(parent); - return wire; - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/AbstractCompositeContextTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/AbstractCompositeContextTestCase.java deleted file mode 100644 index 145d4f8927..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/AbstractCompositeContextTestCase.java +++ /dev/null @@ -1,348 +0,0 @@ -package org.apache.tuscany.core.implementation.composite; - -import javax.xml.namespace.QName; - -import org.osoa.sca.CompositeContext; -import org.osoa.sca.RequestContext; -import org.osoa.sca.ServiceReference; -import org.osoa.sca.ServiceRuntimeException; - -import org.apache.tuscany.spi.component.AtomicComponent; -import org.apache.tuscany.spi.component.CompositeComponent; -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.idl.java.JavaServiceContract; -import org.apache.tuscany.spi.model.ServiceContract; -import org.apache.tuscany.spi.wire.InboundWire; -import org.apache.tuscany.spi.wire.Wire; -import org.apache.tuscany.spi.wire.WireService; - -import junit.framework.TestCase; -import org.apache.tuscany.core.launcher.CompositeContextImpl; -import org.easymock.EasyMock; - -/** - * @version $Rev$ $Date$ - */ -public class AbstractCompositeContextTestCase extends TestCase { - - public void testGetName() throws Exception { - CompositeComponent composite = EasyMock.createMock(CompositeComponent.class); - EasyMock.expect(composite.getName()).andReturn("foo"); - EasyMock.replay(composite); - WireService wireService = EasyMock.createNiceMock(WireService.class); - CompositeContext context = new TestCompositeContext(composite, wireService); - assertEquals("foo", context.getName()); - } - - public void testAtomicLocate() throws Exception { - InboundWire wire = EasyMock.createMock(InboundWire.class); - EasyMock.expect(wire.isOptimizable()).andReturn(false); - EasyMock.replay(wire); - AtomicComponent child = EasyMock.createMock(AtomicComponent.class); - EasyMock.expect(child.getInboundWire(FooService.class.getName())) - .andReturn(wire); - EasyMock.replay(child); - CompositeComponent composite = EasyMock.createMock(CompositeComponent.class); - EasyMock.expect(composite.getChild("Foo")).andReturn(child); - EasyMock.replay(composite); - - WireService wireService = EasyMock.createMock(WireService.class); - EasyMock.expect( - wireService.createProxy(EasyMock.eq(FooService.class), EasyMock.eq(wire))) - .andReturn(new FooService() { - }); - EasyMock.replay(wireService); - CompositeContext context = new TestCompositeContext(composite, wireService); - context.locateService(FooService.class, "Foo"); - EasyMock.verify(wireService); - EasyMock.verify(composite); - EasyMock.verify(wire); - EasyMock.verify(child); - } - - /** - * Verifies the locateService checks for wire optimizations and if possible, avoids proxying the target instance - */ - public void testOptimizedAtomicLocate() throws Exception { - ServiceContract contract = new JavaServiceContract(FooService.class); - InboundWire wire = EasyMock.createMock(InboundWire.class); - EasyMock.expect(wire.isOptimizable()).andReturn(true); - EasyMock.expect(wire.getTargetService()).andReturn(new FooService()); - EasyMock.expect(wire.getServiceContract()).andReturn(contract).atLeastOnce(); - EasyMock.replay(wire); - AtomicComponent child = EasyMock.createMock(AtomicComponent.class); - EasyMock.expect(child.getInboundWire(FooService.class.getName())) - .andReturn(wire); - EasyMock.replay(child); - CompositeComponent composite = EasyMock.createMock(CompositeComponent.class); - EasyMock.expect(composite.getChild("Foo")).andReturn(child); - EasyMock.replay(composite); - - WireService wireService = EasyMock.createMock(WireService.class); - EasyMock.replay(wireService); - CompositeContextImpl context = new CompositeContextImpl(composite, wireService); - context.locateService(FooService.class, "Foo"); - EasyMock.verify(wireService); - EasyMock.verify(composite); - EasyMock.verify(wire); - EasyMock.verify(child); - } - - public void testCannotOptimizeAtomicLocate() throws Exception { - ServiceContract contract = new JavaServiceContract(Object.class); - InboundWire wire = EasyMock.createMock(InboundWire.class); - EasyMock.expect(wire.isOptimizable()).andReturn(true); - EasyMock.expect(wire.getServiceContract()).andReturn(contract).atLeastOnce(); - EasyMock.replay(wire); - AtomicComponent child = EasyMock.createMock(AtomicComponent.class); - EasyMock.expect(child.getInboundWire(FooService.class.getName())) - .andReturn(wire); - EasyMock.replay(child); - CompositeComponent composite = EasyMock.createMock(CompositeComponent.class); - EasyMock.expect(composite.getChild("Foo")).andReturn(child); - EasyMock.replay(composite); - - WireService service = EasyMock.createMock(WireService.class); - EasyMock.expect( - service.createProxy(EasyMock.eq(FooService.class), EasyMock.eq(wire))) - .andReturn(new FooService() { - }); - EasyMock.replay(service); - - CompositeContextImpl context = new CompositeContextImpl(composite, service); - context.locateService(FooService.class, "Foo"); - EasyMock.verify(service); - EasyMock.verify(composite); - EasyMock.verify(wire); - EasyMock.verify(child); - } - - public void testNoWireJavaInterfaceAtomicLocate() throws Exception { - ServiceContract contract = new JavaServiceContract(); - InboundWire wire = EasyMock.createMock(InboundWire.class); - EasyMock.expect(wire.isOptimizable()).andReturn(true); - EasyMock.expect(wire.getServiceContract()).andReturn(contract); - EasyMock.replay(wire); - AtomicComponent child = EasyMock.createMock(AtomicComponent.class); - EasyMock.expect(child.getInboundWire(FooService.class.getName())) - .andReturn(wire); - EasyMock.replay(child); - CompositeComponent composite = EasyMock.createMock(CompositeComponent.class); - EasyMock.expect(composite.getChild("Foo")).andReturn(child); - EasyMock.replay(composite); - - WireService service = EasyMock.createMock(WireService.class); - EasyMock.expect( - service.createProxy(EasyMock.eq(FooService.class), EasyMock.eq(wire))) - .andReturn(new FooService() { - }); - EasyMock.replay(service); - - CompositeContextImpl context = new CompositeContextImpl(composite, service); - context.locateService(FooService.class, "Foo"); - EasyMock.verify(service); - EasyMock.verify(composite); - EasyMock.verify(wire); - EasyMock.verify(child); - } - - public void testServiceLocate() throws Exception { - InboundWire wire = EasyMock.createMock(InboundWire.class); - EasyMock.expect(wire.getBindingType()).andReturn(InboundWire.LOCAL_BINDING); - EasyMock.expect(wire.isOptimizable()).andReturn(false); - EasyMock.replay(wire); - ServiceBinding binding = EasyMock.createMock(ServiceBinding.class); - binding.setService(EasyMock.isA(Service.class)); - EasyMock.expect(binding.getInboundWire()).andReturn(wire).atLeastOnce(); - EasyMock.replay(binding); - Service child = new ServiceImpl("Foo", null, null); - child.addServiceBinding(binding); - CompositeComponent composite = EasyMock.createMock(CompositeComponent.class); - EasyMock.expect(composite.getChild("Foo")).andReturn(child); - EasyMock.replay(composite); - - WireService service = EasyMock.createMock(WireService.class); - EasyMock.expect( - service.createProxy(EasyMock.eq(FooService.class), EasyMock.eq(wire))) - .andReturn(new FooService() { - }); - EasyMock.replay(service); - CompositeContextImpl context = new CompositeContextImpl(composite, service); - context.locateService(FooService.class, "Foo"); - EasyMock.verify(service); - EasyMock.verify(composite); - EasyMock.verify(wire); - EasyMock.verify(binding); - } - - public void testReferenceLocateLocalBinding() throws Exception { - InboundWire wire = EasyMock.createMock(InboundWire.class); - EasyMock.expect(wire.isOptimizable()).andReturn(false); - EasyMock.expect(wire.getBindingType()).andReturn(Wire.LOCAL_BINDING); - EasyMock.replay(wire); - - ReferenceBinding binding = EasyMock.createMock(ReferenceBinding.class); - EasyMock.expect(binding.getInboundWire()).andReturn(wire).atLeastOnce(); - binding.setReference(EasyMock.isA(Reference.class)); - EasyMock.replay(binding); - Reference reference = new ReferenceImpl("Foo", null, null); - reference.addReferenceBinding(binding); - CompositeComponent composite = EasyMock.createMock(CompositeComponent.class); - EasyMock.expect(composite.getChild("Foo")).andReturn(reference); - EasyMock.replay(composite); - WireService service = EasyMock.createMock(WireService.class); - EasyMock.expect( - service.createProxy(EasyMock.eq(FooService.class), EasyMock.eq(wire))) - .andReturn(new FooService() { - }); - EasyMock.replay(service); - CompositeContextImpl context = new CompositeContextImpl(composite, service); - context.locateService(FooService.class, "Foo"); - EasyMock.verify(service); - EasyMock.verify(composite); - EasyMock.verify(wire); - EasyMock.verify(binding); - } - - public void testReferenceLocateNoLocalBinding() throws Exception { - InboundWire wire = EasyMock.createMock(InboundWire.class); - EasyMock.expect(wire.isOptimizable()).andReturn(false); - EasyMock.expect(wire.getBindingType()).andReturn(new QName("foo/foo")); - EasyMock.replay(wire); - - ReferenceBinding binding = EasyMock.createMock(ReferenceBinding.class); - EasyMock.expect(binding.getInboundWire()).andReturn(wire).atLeastOnce(); - binding.setReference(EasyMock.isA(Reference.class)); - EasyMock.replay(binding); - Reference reference = new ReferenceImpl("Foo", null, null); - reference.addReferenceBinding(binding); - CompositeComponent composite = EasyMock.createMock(CompositeComponent.class); - EasyMock.expect(composite.getChild("Foo")).andReturn(reference); - EasyMock.replay(composite); - WireService service = EasyMock.createMock(WireService.class); - EasyMock.expect( - service.createProxy(EasyMock.eq(FooService.class), EasyMock.eq(wire))) - .andReturn(new FooService() { - }); - EasyMock.replay(service); - CompositeContextImpl context = new CompositeContextImpl(composite, service); - context.locateService(FooService.class, "Foo"); - EasyMock.verify(service); - EasyMock.verify(composite); - EasyMock.verify(wire); - EasyMock.verify(binding); - } - - public void testCompositeLocate() throws Exception { - InboundWire wire = EasyMock.createMock(InboundWire.class); - EasyMock.expect(wire.isOptimizable()).andReturn(false); - EasyMock.replay(wire); - CompositeComponent child = EasyMock.createMock(CompositeComponent.class); - EasyMock.expect(child.getInboundWire("Bar")).andReturn(wire); - EasyMock.replay(child); - CompositeComponent composite = EasyMock.createMock(CompositeComponent.class); - EasyMock.expect(composite.getChild("Foo")).andReturn(child); - EasyMock.replay(composite); - - WireService wireService = EasyMock.createMock(WireService.class); - EasyMock.expect( - wireService.createProxy(EasyMock.eq(FooService.class), EasyMock.eq(wire))) - .andReturn(new FooService() { - }); - EasyMock.replay(wireService); - CompositeContextImpl context = new CompositeContextImpl(composite, wireService); - context.locateService(FooService.class, "Foo/Bar"); - EasyMock.verify(wireService); - EasyMock.verify(composite); - EasyMock.verify(wire); - EasyMock.verify(child); - } - - public void testCompositeLocateNoService() throws Exception { - InboundWire wire = EasyMock.createMock(InboundWire.class); - EasyMock.expect(wire.isOptimizable()).andReturn(false); - EasyMock.replay(wire); - CompositeComponent child = EasyMock.createMock(CompositeComponent.class); - EasyMock.expect(child.getInboundWire(FooService.class.getName())).andReturn(wire); - EasyMock.replay(child); - CompositeComponent composite = EasyMock.createMock(CompositeComponent.class); - EasyMock.expect(composite.getChild("Foo")).andReturn(child); - EasyMock.replay(composite); - - WireService wireService = EasyMock.createMock(WireService.class); - EasyMock.expect( - wireService.createProxy(EasyMock.eq(FooService.class), EasyMock.eq(wire))) - .andReturn(new FooService() { - }); - EasyMock.replay(wireService); - CompositeContextImpl context = new CompositeContextImpl(composite, wireService); - context.locateService(FooService.class, "Foo"); - EasyMock.verify(wireService); - EasyMock.verify(composite); - EasyMock.verify(wire); - EasyMock.verify(child); - } - - public void testCompositeLocateNotAService() throws Exception { - CompositeComponent child = EasyMock.createMock(CompositeComponent.class); - EasyMock.expect(child.getInboundWire("Bar")).andReturn(null); - EasyMock.replay(child); - CompositeComponent composite = EasyMock.createMock(CompositeComponent.class); - EasyMock.expect(composite.getChild("Foo")).andReturn(child); - EasyMock.replay(composite); - - WireService wireService = EasyMock.createNiceMock(WireService.class); - CompositeContextImpl context = new CompositeContextImpl(composite, wireService); - try { - context.locateService(FooService.class, "Foo/Bar"); - //fail - } catch (ServiceRuntimeException e) { - //expected - } - EasyMock.verify(composite); - EasyMock.verify(child); - } - - private class FooService { - - } - - private class TestCompositeContext extends AbstractCompositeContext { - - public TestCompositeContext(final CompositeComponent composite, final WireService wireService) { - super(composite, wireService); - } - - public void start() { - - } - - public void stop() { - - } - - public RequestContext getRequestContext() { - return null; - } - - public ServiceReference createServiceReferenceForSession(Object self) { - return null; - } - - public ServiceReference createServiceReferenceForSession(Object self, String serviceName) { - return null; - } - - public ServiceReference newSession(String serviceName) { - return null; - } - - public ServiceReference newSession(String serviceName, Object sessionId) { - return null; - } - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/AutowireResolutionTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/AutowireResolutionTestCase.java deleted file mode 100644 index 463fe8a9b9..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/AutowireResolutionTestCase.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.implementation.composite; - -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.wire.InboundWire; - -import junit.framework.TestCase; -import org.apache.tuscany.core.implementation.TestUtils; -import org.easymock.EasyMock; -import static org.easymock.EasyMock.createMock; -import static org.easymock.EasyMock.eq; -import static org.easymock.EasyMock.replay; -import static org.easymock.EasyMock.verify; - -/** - * Verfies specific autowire resolution scenarios - * - * @version $Rev$ $Date$ - */ -public class AutowireResolutionTestCase extends TestCase { - - public void testConstruction() { - CompositeComponent parent = createMock(CompositeComponent.class); - replay(parent); - CompositeComponent component = new CompositeComponentImpl("test", parent, null, null); - assertEquals("test", component.getName()); - assertSame(parent, component.getParent()); - verify(parent); - } - - public void testResolvedByAutowire() throws Exception { - CompositeComponent parent = createMock(CompositeComponent.class); - InboundWire wire = TestUtils.createInboundWire(Foo.class, parent); - EasyMock.expect(parent.resolveAutowire(eq(Foo.class))).andReturn(wire); - replay(parent); - CompositeComponent component = new CompositeComponentImpl("test", parent, null, null); - assertSame(wire, component.resolveAutowire(Foo.class)); - verify(parent); - } - - public void testSystemResolvedByAutowire() throws Exception { - CompositeComponent parent = createMock(CompositeComponent.class); - InboundWire wire = TestUtils.createInboundWire(Foo.class, parent); - EasyMock.expect(parent.resolveSystemAutowire(eq(Foo.class))).andReturn(wire); - replay(parent); - CompositeComponent component = new CompositeComponentImpl("test", parent, null, null); - assertSame(wire, component.resolveSystemAutowire(Foo.class)); - verify(parent); - } - - /** - * Verify parent resolution strategy for application serviceBindings - */ - public void testNamespaceIsolationAutowire() throws Exception { - Foo foo = new Foo() { - }; - CompositeComponent parent = new CompositeComponentImpl("parent", null, null, null); - parent.registerJavaObject("foo", Foo.class, foo); - CompositeComponent component = new CompositeComponentImpl("test", parent, null, null); - assertNull(component.resolveAutowire(Foo.class)); - } - - protected void setUp() throws Exception { - super.setUp(); - } - - public static interface Foo { - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/AutowireTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/AutowireTestCase.java deleted file mode 100644 index 341efcd09c..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/AutowireTestCase.java +++ /dev/null @@ -1,230 +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.util.ArrayList; -import java.util.List; - -import org.apache.tuscany.spi.component.AtomicComponent; -import org.apache.tuscany.spi.component.CompositeComponent; -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.wire.InboundWire; - -import junit.framework.TestCase; -import org.apache.tuscany.core.implementation.TestUtils; -import org.easymock.EasyMock; - -/** - * Performs basic autowiring tests to composite artifacts - * - * @version $$Rev$$ $$Date$$ - */ -public class AutowireTestCase extends TestCase { - - /** - * Tests autowiring to an system atomic component - */ - public void testSystemAtomicAutowire() throws Exception { - CompositeComponent parent = new CompositeComponentImpl("parent", null, null, true); - parent.start(); - List> interfaces = new ArrayList>(); - interfaces.add(Source.class); - interfaces.add(Source2.class); - AtomicComponent component = EasyMock.createMock(AtomicComponent.class); - EasyMock.expect(component.getName()).andReturn("source").atLeastOnce(); - EasyMock.expect(component.isSystem()).andReturn(true).atLeastOnce(); - List wires = TestUtils.createInboundWires(interfaces); - EasyMock.expect(component.getInboundWires()).andReturn(wires).atLeastOnce(); - TestUtils.populateInboundWires(component, wires); - EasyMock.replay(component); - parent.register(component); - InboundWire source = parent.resolveSystemAutowire(Source.class); - assertNotNull(source); - InboundWire sourceBase = parent.resolveSystemAutowire(SourceBase.class); - assertSame(source, sourceBase); - InboundWire source2 = parent.resolveSystemAutowire(Source2.class); - assertSame(source.getContainer(), source2.getContainer()); - assertNull(parent.resolveSystemExternalAutowire(Source.class)); - EasyMock.verify(component); - } - - /** - * Tests autowiring to an system atomic component - */ - public void testAtomicAutowire() throws Exception { - CompositeComponent parent = new CompositeComponentImpl("parent", null, null, null); - parent.start(); - - List> interfaces = new ArrayList>(); - interfaces.add(Source.class); - interfaces.add(Source2.class); - AtomicComponent component = EasyMock.createMock(AtomicComponent.class); - EasyMock.expect(component.getName()).andReturn("source").atLeastOnce(); - EasyMock.expect(component.isSystem()).andReturn(false).atLeastOnce(); - List wires = TestUtils.createInboundWires(interfaces); - EasyMock.expect(component.getInboundWires()).andReturn(wires).atLeastOnce(); - TestUtils.populateInboundWires(component, wires); - - EasyMock.replay(component); - parent.register(component); - - InboundWire source = parent.resolveAutowire(Source.class); - assertNotNull(source); - InboundWire sourceBase = parent.resolveAutowire(SourceBase.class); - assertSame(source, sourceBase); - InboundWire source2 = parent.resolveAutowire(Source2.class); - assertSame(source.getContainer(), source2.getContainer()); - assertNull(parent.resolveExternalAutowire(Source.class)); - EasyMock.verify(component); - } - - /** - * Tests autowiring to a system service - */ - public void testSystemServiceAutowire() throws Exception { - CompositeComponent parent = new CompositeComponentImpl("parent", null, null, true); - parent.start(); - - ServiceBinding serviceBinding = EasyMock.createMock(ServiceBinding.class); - InboundWire wire = TestUtils.createInboundWire(Source.class); - wire.setContainer(serviceBinding); - EasyMock.expect(serviceBinding.getInboundWire()).andReturn(wire).atLeastOnce(); - EasyMock.replay(serviceBinding); - - List bindings = new ArrayList(); - bindings.add(serviceBinding); - Service service = EasyMock.createMock(Service.class); - EasyMock.expect(service.getName()).andReturn("service").atLeastOnce(); - EasyMock.expect(service.isSystem()).andReturn(true).atLeastOnce(); - - EasyMock.expect(service.getServiceBindings()).andReturn(bindings).atLeastOnce(); - EasyMock.replay(service); - parent.register(service); - - InboundWire source = parent.resolveSystemExternalAutowire(Source.class); - assertSame(serviceBinding, source.getContainer()); - InboundWire sourceBase = parent.resolveSystemExternalAutowire(SourceBase.class); - assertSame(source, sourceBase); - InboundWire source2 = parent.resolveSystemExternalAutowire(Source2.class); - assertNull(source2); - EasyMock.verify(serviceBinding); - } - - /** - * Tests autowiring to a service - */ - public void testServiceAutowire() throws Exception { - CompositeComponent parent = new CompositeComponentImpl("parent", null, null, true); - parent.start(); - - ServiceBinding serviceBinding = EasyMock.createMock(ServiceBinding.class); - InboundWire wire = TestUtils.createInboundWire(Source.class); - wire.setContainer(serviceBinding); - EasyMock.expect(serviceBinding.getInboundWire()).andReturn(wire).atLeastOnce(); - EasyMock.replay(serviceBinding); - - List bindings = new ArrayList(); - bindings.add(serviceBinding); - Service service = EasyMock.createMock(Service.class); - EasyMock.expect(service.getName()).andReturn("service").atLeastOnce(); - EasyMock.expect(service.isSystem()).andReturn(false).atLeastOnce(); - - EasyMock.expect(service.getServiceBindings()).andReturn(bindings).atLeastOnce(); - EasyMock.replay(service); - parent.register(service); - - InboundWire source = parent.resolveExternalAutowire(Source.class); - assertSame(serviceBinding, source.getContainer()); - InboundWire sourceBase = parent.resolveExternalAutowire(SourceBase.class); - assertSame(source, sourceBase); - InboundWire source2 = parent.resolveExternalAutowire(Source2.class); - assertNull(source2); - EasyMock.verify(serviceBinding); - } - - - /** - * Tests autowiring to a system reference - */ - public void testSystemReferenceAutowire() throws Exception { - CompositeComponent parent = new CompositeComponentImpl("parent", null, null, true); - parent.start(); - - ReferenceBinding binding = EasyMock.createMock(ReferenceBinding.class); - binding.setReference(EasyMock.isA(Reference.class)); - InboundWire wire = TestUtils.createInboundWire(Source.class); - wire.setContainer(binding); - EasyMock.expect(binding.getInboundWire()).andReturn(wire).atLeastOnce(); - EasyMock.replay(binding); - - Reference reference = new ReferenceImpl("foo", null, wire.getServiceContract(), true); - reference.addReferenceBinding(binding); - parent.register(reference); - - InboundWire source = parent.resolveSystemAutowire(Source.class); - assertNotNull(source); - InboundWire sourceBase = parent.resolveSystemAutowire(SourceBase.class); - assertSame(source, sourceBase); - EasyMock.verify(binding); - } - - /** - * Tests autowiring to a reference - */ - public void testReferenceAutowire() throws Exception { - CompositeComponent parent = new CompositeComponentImpl("parent", null, null, true); - parent.start(); - - ReferenceBinding binding = EasyMock.createMock(ReferenceBinding.class); - binding.setReference(EasyMock.isA(Reference.class)); - InboundWire wire = TestUtils.createInboundWire(Source.class); - wire.setContainer(binding); - EasyMock.expect(binding.getInboundWire()).andReturn(wire).atLeastOnce(); - EasyMock.replay(binding); - - Reference reference = new ReferenceImpl("foo", null, wire.getServiceContract(), false); - reference.addReferenceBinding(binding); - parent.register(reference); - - InboundWire source = parent.resolveAutowire(Source.class); - assertNotNull(source); - InboundWire sourceBase = parent.resolveAutowire(SourceBase.class); - assertSame(source, sourceBase); - EasyMock.verify(binding); - } - - - public static class SourceImpl implements Source, Source2 { - public SourceImpl() { - } - } - - public static interface SourceBase { - } - - public static interface Source extends SourceBase { - } - - public static interface Source2 { - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeBuilderTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeBuilderTestCase.java deleted file mode 100644 index 0d8f4fc4d2..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeBuilderTestCase.java +++ /dev/null @@ -1,208 +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.AtomicComponent; -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.component.ScopeContainerMonitor; -import org.apache.tuscany.spi.component.Service; -import org.apache.tuscany.spi.deployer.DeploymentContext; -import org.apache.tuscany.spi.idl.java.JavaInterfaceProcessorRegistry; -import org.apache.tuscany.spi.idl.java.JavaServiceContract; -import org.apache.tuscany.spi.implementation.java.ConstructorDefinition; -import org.apache.tuscany.spi.implementation.java.JavaMappedProperty; -import org.apache.tuscany.spi.implementation.java.JavaMappedReference; -import org.apache.tuscany.spi.implementation.java.JavaMappedService; -import org.apache.tuscany.spi.implementation.java.PojoComponentType; -import org.apache.tuscany.spi.model.BoundReferenceDefinition; -import org.apache.tuscany.spi.model.BoundServiceDefinition; -import org.apache.tuscany.spi.model.ComponentDefinition; -import org.apache.tuscany.spi.model.CompositeComponentType; -import org.apache.tuscany.spi.model.CompositeImplementation; -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.WireService; - -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.builder.BuilderRegistryImpl; -import org.apache.tuscany.core.component.scope.CompositeScopeContainer; -import org.apache.tuscany.core.deployer.RootDeploymentContext; -import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl; -import org.apache.tuscany.core.implementation.java.JavaComponentBuilder; -import org.apache.tuscany.core.implementation.java.JavaImplementation; -import org.apache.tuscany.core.mock.component.OtherTarget; -import org.apache.tuscany.core.mock.component.Source; -import org.apache.tuscany.core.mock.component.SourceImpl; -import org.apache.tuscany.core.mock.component.Target; -import org.apache.tuscany.core.mock.component.TargetImpl; -import org.apache.tuscany.core.wire.jdk.JDKWireService; -import org.easymock.EasyMock; - -/** - * @version $$Rev$$ $$Date$$ - */ -public class CompositeBuilderTestCase extends TestCase { - private DeploymentContext deploymentContext; - - @SuppressWarnings("unchecked") - public void testBuild() throws Exception { - CompositeComponent parent = new CompositeComponentImpl(null, null, null, null); - - CompositeBuilder builder = new CompositeBuilder(); - WireService wireService = new JDKWireService(); - builder.setWireService(wireService); - BuilderRegistryImpl builderRegistry = new BuilderRegistryImpl(null, wireService); - JavaComponentBuilder jBuilder = new JavaComponentBuilder(); - jBuilder.setWireService(wireService); - builderRegistry.register(JavaImplementation.class, jBuilder); - builderRegistry.register(CompositeImplementation.class, builder); - builderRegistry.register(LocalBindingDefinition.class, new LocalBindingBuilder()); - builder.setBuilderRegistry(builderRegistry); - CompositeComponent component = - (CompositeComponent) builder.build(parent, createTopComponentDef(), deploymentContext); - - component.start(); - CompositeComponent sourceComponent = (CompositeComponent) component.getChild("SourceComponent"); - assertTrue(sourceComponent.getChild("InnerSourceService") instanceof Service); - AtomicComponent innerSourceComponent = (AtomicComponent) sourceComponent.getChild("InnerSourceComponent"); - Source innerSourceInstance = (Source) deploymentContext.getCompositeScope().getInstance(innerSourceComponent); - assertNotNull(innerSourceInstance); - component.stop(); - } - - private ComponentDefinition createTopComponentDef() throws Exception { - - CompositeComponentType> outerType = - new CompositeComponentType>(); - outerType.add(createSourceComponentDef()); - outerType.add(createTargetComponentDef()); - - CompositeImplementation outerImpl = new CompositeImplementation(); - outerImpl.setComponentType(outerType); - - return new ComponentDefinition(outerImpl); - } - - private ComponentDefinition createSourceComponentDef() throws Exception { - - CompositeComponentType> innerType = - new CompositeComponentType>(); - innerType.add(createInnerSourceComponentDef()); - BoundReferenceDefinition reference = new BoundReferenceDefinition(); - reference.setName("TargetComponentRef"); - JavaInterfaceProcessorRegistry registry = new JavaInterfaceProcessorRegistryImpl(); - JavaServiceContract targetContract = registry.introspect(Target.class); - reference.setServiceContract(targetContract); - innerType.add(reference); - BoundServiceDefinition service = new BoundServiceDefinition(); - service.setName("InnerSourceService"); - JavaServiceContract sourceContract = registry.introspect(Source.class); - service.setServiceContract(sourceContract); - service.setTarget(new URI("InnerSourceComponent")); - innerType.add(service); - - CompositeImplementation innerImpl = new CompositeImplementation(); - innerImpl.setComponentType(innerType); - - ComponentDefinition sourceComponentDefinition = - new ComponentDefinition("SourceComponent", innerImpl); - ReferenceTarget refTarget = new ReferenceTarget(); - refTarget.setReferenceName("TargetComponentRef"); - refTarget.addTarget(new URI("TargetComponent")); - sourceComponentDefinition.add(refTarget); - - return sourceComponentDefinition; - } - - private ComponentDefinition createInnerSourceComponentDef() throws Exception { - - PojoComponentType> sourceType = - new PojoComponentType>(); - sourceType.setImplementationScope(Scope.COMPOSITE); - JavaMappedReference reference = new JavaMappedReference(); - reference.setName("targetReference"); - JavaInterfaceProcessorRegistry registry = new JavaInterfaceProcessorRegistryImpl(); - ServiceContract targetContract = registry.introspect(Target.class); - targetContract.setCallbackClass(OtherTarget.class); - targetContract.setCallbackName("OtherTarget"); - reference.setServiceContract(targetContract); - reference.setMember(SourceImpl.class.getMethod("setTarget", Target.class)); - sourceType.add(reference); - - ServiceContract sourceContract = registry.introspect(Source.class); - - JavaMappedService sourceServiceDefinition = new JavaMappedService(); - sourceServiceDefinition.setName("Source"); - sourceServiceDefinition.setServiceContract(sourceContract); - - sourceType.add(sourceServiceDefinition); - sourceType.setConstructorDefinition(new ConstructorDefinition(SourceImpl.class.getConstructor())); - JavaImplementation sourceImpl = new JavaImplementation(); - sourceImpl.setComponentType(sourceType); - sourceImpl.setImplementationClass(SourceImpl.class); - ComponentDefinition innerSourceComponentDefinition = - new ComponentDefinition("InnerSourceComponent", sourceImpl); - ReferenceTarget refTarget = new ReferenceTarget(); - refTarget.setReferenceName("targetReference"); - refTarget.addTarget(new URI("TargetComponentRef")); - innerSourceComponentDefinition.add(refTarget); - - return innerSourceComponentDefinition; - } - - private ComponentDefinition createTargetComponentDef() throws Exception { - - PojoComponentType> targetType = - new PojoComponentType>(); - targetType.setImplementationScope(Scope.COMPOSITE); - - JavaInterfaceProcessorRegistry registry = new JavaInterfaceProcessorRegistryImpl(); - ServiceContract targetContract = registry.introspect(Target.class); - targetContract.setCallbackClass(OtherTarget.class); - targetContract.setCallbackName("OtherTarget"); - - JavaMappedService serviceDefinition = new JavaMappedService(); - serviceDefinition.setName("Target"); - serviceDefinition.setServiceContract(targetContract); - serviceDefinition.setCallbackReferenceName("otherTarget"); - - targetType.add(serviceDefinition); - targetType.setConstructorDefinition(new ConstructorDefinition(TargetImpl.class.getConstructor())); - JavaImplementation targetImpl = new JavaImplementation(); - targetImpl.setComponentType(targetType); - targetImpl.setImplementationClass(TargetImpl.class); - return new ComponentDefinition("TargetComponent", targetImpl); - } - - protected void setUp() throws Exception { - super.setUp(); - ScopeContainerMonitor monitor = EasyMock.createNiceMock(ScopeContainerMonitor.class); - CompositeScopeContainer container = new CompositeScopeContainer(monitor); - container.start(); - deploymentContext = new RootDeploymentContext(null, null, container, null); - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeComponentImplBasicTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeComponentImplBasicTestCase.java deleted file mode 100644 index 1f7c8618d2..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeComponentImplBasicTestCase.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.implementation.composite; - -import java.util.Collections; - -import org.apache.tuscany.spi.component.AtomicComponent; -import org.apache.tuscany.spi.component.CompositeComponent; -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.event.Event; -import org.apache.tuscany.spi.event.RuntimeEventListener; -import org.apache.tuscany.spi.idl.InvalidServiceContractException; -import org.apache.tuscany.spi.model.Scope; -import org.apache.tuscany.spi.wire.InboundWire; - -import junit.framework.Assert; -import junit.framework.TestCase; -import org.apache.tuscany.core.component.event.CompositeStart; -import org.apache.tuscany.core.implementation.TestUtils; -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.isA; -import static org.easymock.EasyMock.replay; - -/** - * @version $Rev$ $Date$ - */ -public class CompositeComponentImplBasicTestCase extends TestCase { - private AtomicComponent component; - - public void testGetScope() { - CompositeComponent composite = new CompositeComponentImpl("parent", null, null, null); - Assert.assertEquals(Scope.SYSTEM, composite.getScope()); - } - - public void testReferencesServices() throws Exception { - CompositeComponent composite = new CompositeComponentImpl("parent", null, null, null); - Service service = EasyMock.createMock(Service.class); - EasyMock.expect(service.getName()).andReturn("foo").atLeastOnce(); - EasyMock.expect(service.isSystem()).andReturn(false).atLeastOnce(); - service.getServiceBindings(); - EasyMock.expectLastCall().andReturn(Collections.emptyList()).atLeastOnce(); - EasyMock.replay(service); - composite.register(service); - composite.register(getReference("bar")); - } - - public void testOnEvent() { - CompositeComponent composite = new CompositeComponentImpl("parent", null, null, null); - Event event = new Event() { - public Object getSource() { - return null; - } - }; - RuntimeEventListener listener = createMock(RuntimeEventListener.class); - listener.onEvent(isA(CompositeStart.class)); - listener.onEvent(eq(event)); - expectLastCall(); - replay(listener); - composite.addListener(listener); - composite.start(); - composite.onEvent(event); - } - - public void testPrepare() throws Exception { - CompositeComponent composite = new CompositeComponentImpl("parent", null, null, null); - composite.prepare(); - } - - private Reference getReference(String name) throws InvalidServiceContractException { - ReferenceBinding binding = EasyMock.createNiceMock(ReferenceBinding.class); - EasyMock.expect(binding.isSystem()).andReturn(false).atLeastOnce(); - InboundWire wire = TestUtils.createInboundWire(Bar.class); - wire.setContainer(binding); - EasyMock.expect(binding.getInboundWire()).andReturn(wire).atLeastOnce(); - - binding.getName(); - expectLastCall().andReturn(name).anyTimes(); - replay(binding); - - Reference reference = new ReferenceImpl(name, null, wire.getServiceContract()); - reference.addReferenceBinding(binding); - return reference; - } - - protected void setUp() throws Exception { - super.setUp(); - component = EasyMock.createMock(AtomicComponent.class); - EasyMock.expect(component.getName()).andReturn("foo").atLeastOnce(); - EasyMock.expect(component.isSystem()).andReturn(false).atLeastOnce(); - component.getInboundWires(); - EasyMock.expectLastCall().andReturn(Collections.emptyList()).atLeastOnce(); - EasyMock.replay(component); - } - - private interface Bar { - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeComponentImplSystemWireTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeComponentImplSystemWireTestCase.java deleted file mode 100644 index 018e068120..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeComponentImplSystemWireTestCase.java +++ /dev/null @@ -1,170 +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.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.tuscany.spi.QualifiedName; -import org.apache.tuscany.spi.component.AtomicComponent; -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.component.PrepareException; -import org.apache.tuscany.spi.component.SCAObject; -import org.apache.tuscany.spi.idl.java.JavaServiceContract; -import org.apache.tuscany.spi.model.Scope; -import org.apache.tuscany.spi.wire.InboundWire; -import org.apache.tuscany.spi.wire.OutboundWire; - -import junit.framework.TestCase; -import org.apache.tuscany.core.builder.ConnectorImpl; -import org.easymock.EasyMock; - -/** - * @version $Rev$ $Date$ - */ -public class CompositeComponentImplSystemWireTestCase extends TestCase { - - /** - * Verifies system services in a CompositeComponentImpl are wired during the parent composite's prepare callback - */ - public void testSystemServiceWire() throws Exception { - InboundWire inbound = EasyMock.createMock(InboundWire.class); - EasyMock.expect(inbound.getServiceContract()).andReturn(new JavaServiceContract(Foo.class)).atLeastOnce(); - inbound.getInvocationChains(); - EasyMock.expectLastCall().andReturn(Collections.emptyMap()).atLeastOnce(); - - QualifiedName qName = new QualifiedName("target/bar"); - OutboundWire outbound = EasyMock.createMock(OutboundWire.class); - EasyMock.expect(outbound.getTargetName()).andReturn(qName).atLeastOnce(); - EasyMock.expect(outbound.isAutowire()).andReturn(false); - - outbound.setTargetWire(EasyMock.eq(inbound)); - EasyMock.expect(outbound.getServiceContract()).andReturn(new JavaServiceContract(Foo.class)).atLeastOnce(); - List wires = new ArrayList(); - wires.add(outbound); - Map> wireMap = new HashMap>(); - wireMap.put("ref", wires); - CompositeComponent parent = new CompositeComponentImpl("foo", "foo", null, new ConnectorImpl(), null); - AtomicComponent source = EasyMock.createMock(AtomicComponent.class); - EasyMock.expect(source.getScope()).andReturn(Scope.COMPOSITE).atLeastOnce(); - EasyMock.expect(source.getName()).andReturn("source").atLeastOnce(); - EasyMock.expect(source.getOutboundWires()).andReturn(wireMap); - source.getInboundWires(); - EasyMock.expectLastCall().andReturn(Collections.emptyList()).atLeastOnce(); - EasyMock.expect(source.isSystem()).andReturn(true).atLeastOnce(); - EasyMock.expect(source.getParent()).andReturn(parent).atLeastOnce(); - - source.prepare(); - EasyMock.replay(source); - - EasyMock.expect(outbound.getContainer()).andReturn(source).atLeastOnce(); - EasyMock.replay(outbound); - - parent.register(source); - - AtomicComponent target = EasyMock.createMock(AtomicComponent.class); - EasyMock.expect(target.getName()).andReturn("target").atLeastOnce(); - EasyMock.expect(target.getInboundWire("bar")).andReturn(inbound).atLeastOnce(); - List inboundWires = new ArrayList(); - inboundWires.add(inbound); - EasyMock.expect(target.getInboundWires()).andReturn(inboundWires).atLeastOnce(); - EasyMock.expect(target.getScope()).andReturn(Scope.COMPOSITE).atLeastOnce(); - EasyMock.expect(target.getParent()).andReturn(parent).atLeastOnce(); - - target.prepare(); - target.getOutboundWires(); - EasyMock.expectLastCall().andReturn(Collections.emptyMap()); - EasyMock.expect(target.isSystem()).andReturn(true).atLeastOnce(); - EasyMock.replay(target); - - EasyMock.expect(inbound.getContainer()).andReturn(target); - EasyMock.replay(inbound); - - parent.register(target); - parent.prepare(); - EasyMock.verify(source); - EasyMock.verify(target); - EasyMock.verify(inbound); - EasyMock.verify(outbound); - } - - - /** - * Verifies an application component cannot be wired to a system service in the same composite - */ - public void testSystemServiceIsolationWire() throws Exception { - InboundWire inbound = EasyMock.createMock(InboundWire.class); - EasyMock.expect(inbound.getServiceContract()).andReturn(new JavaServiceContract(Foo.class)).atLeastOnce(); - EasyMock.replay(inbound); - - QualifiedName qName = new QualifiedName("target/bar"); - OutboundWire outbound = EasyMock.createMock(OutboundWire.class); - EasyMock.expect(outbound.isAutowire()).andReturn(false); - EasyMock.expect(outbound.getContainer()).andReturn(EasyMock.createNiceMock(SCAObject.class)); - EasyMock.expect(outbound.getReferenceName()).andReturn("foo"); - EasyMock.expect(outbound.getTargetName()).andReturn(qName).atLeastOnce(); - EasyMock.replay(outbound); - - List wires = new ArrayList(); - wires.add(outbound); - Map> wireMap = new HashMap>(); - wireMap.put("ref", wires); - CompositeComponent parent = new CompositeComponentImpl("foo", "foo", null, new ConnectorImpl(), null); - AtomicComponent source = EasyMock.createMock(AtomicComponent.class); - EasyMock.expect(source.getName()).andReturn("source").atLeastOnce(); - List inboundWires = new ArrayList(); - inboundWires.add(inbound); - source.getInboundWires(); - EasyMock.expectLastCall().andReturn(inboundWires).atLeastOnce(); - EasyMock.expect(source.getOutboundWires()).andReturn(wireMap); - EasyMock.expect(source.isSystem()).andReturn(true).atLeastOnce(); - EasyMock.expect(source.getParent()).andReturn(parent).atLeastOnce(); - EasyMock.replay(source); - - parent.register(source); - - AtomicComponent target = EasyMock.createMock(AtomicComponent.class); - EasyMock.expect(target.getName()).andReturn("target").atLeastOnce(); - inboundWires.add(inbound); - EasyMock.expect(target.getInboundWires()).andReturn(inboundWires).atLeastOnce(); - EasyMock.expect(target.isSystem()).andReturn(false).atLeastOnce(); - EasyMock.replay(target); - - parent.register(target); - try { - parent.prepare(); - fail(); - } catch (PrepareException e) { - //expected - } - EasyMock.verify(source); - EasyMock.verify(target); - EasyMock.verify(inbound); - EasyMock.verify(outbound); - } - - - private class Foo { - - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeComponentImplTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeComponentImplTestCase.java deleted file mode 100644 index eb57c6733d..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeComponentImplTestCase.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.implementation.composite; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.tuscany.spi.component.AtomicComponent; -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.wire.InboundWire; - -import junit.framework.TestCase; -import org.apache.tuscany.core.implementation.TestUtils; -import org.easymock.EasyMock; - -/** - * @version $Rev$ $Date$ - */ -public class CompositeComponentImplTestCase extends TestCase { - - public void testSetUri() throws Exception { - CompositeComponentImpl component = new CompositeComponentImpl("foo", "foo/bar", null, null, null); - assertEquals("foo/bar", component.getURI()); - } - - public void testRegisterSystemService() throws Exception { - List> services = new ArrayList>(); - services.add(Foo.class); - CompositeComponent parent = new CompositeComponentImpl("foo", "foo", null, null, null); - AtomicComponent component = EasyMock.createMock(AtomicComponent.class); - EasyMock.expect(component.getName()).andReturn("bar").atLeastOnce(); - EasyMock.expect(component.isSystem()).andReturn(true).atLeastOnce(); - List wires = TestUtils.createInboundWires(services); - EasyMock.expect(component.getInboundWires()).andReturn(wires).atLeastOnce(); - EasyMock.replay(component); - parent.register(component); - assertNull(parent.getChild("bar")); - assertNotNull(parent.getSystemChild("bar")); - EasyMock.verify(component); - } - - public void testRegister() throws Exception { - List> services = new ArrayList>(); - services.add(Foo.class); - CompositeComponent parent = new CompositeComponentImpl("foo", "foo", null, null, null); - AtomicComponent component = EasyMock.createMock(AtomicComponent.class); - EasyMock.expect(component.getName()).andReturn("bar").atLeastOnce(); - EasyMock.expect(component.isSystem()).andReturn(false).atLeastOnce(); - List wires = TestUtils.createInboundWires(services); - EasyMock.expect(component.getInboundWires()).andReturn(wires).atLeastOnce(); - EasyMock.replay(component); - parent.register(component); - assertNull(parent.getSystemChild("bar")); - assertNotNull(parent.getChild("bar")); - EasyMock.verify(component); - } - - /** - * Verifies a system service and application component can be registered with the same name in a composite - */ - public void testSystemServiceApplicationNamespaceIsolation() throws Exception { - List> services = new ArrayList>(); - services.add(Foo.class); - CompositeComponent parent = new CompositeComponentImpl("foo", "foo", null, null, null); - AtomicComponent component = EasyMock.createMock(AtomicComponent.class); - EasyMock.expect(component.getName()).andReturn("bar").atLeastOnce(); - EasyMock.expect(component.isSystem()).andReturn(true).atLeastOnce(); - List wires = TestUtils.createInboundWires(services); - EasyMock.expect(component.getInboundWires()).andReturn(wires).atLeastOnce(); - EasyMock.replay(component); - parent.register(component); - AtomicComponent component2 = EasyMock.createMock(AtomicComponent.class); - EasyMock.expect(component2.getName()).andReturn("bar").atLeastOnce(); - EasyMock.expect(component2.isSystem()).andReturn(false).atLeastOnce(); - EasyMock.expect(component2.getInboundWires()).andReturn(wires).atLeastOnce(); - EasyMock.replay(component2); - parent.register(component2); - EasyMock.verify(component); - EasyMock.verify(component2); - } - - public void testSystemServiceLifecycle() throws Exception { - List> services = new ArrayList>(); - services.add(Foo.class); - CompositeComponent parent = new CompositeComponentImpl("foo", "foo", null, null, null); - AtomicComponent component = EasyMock.createMock(AtomicComponent.class); - component.start(); - EasyMock.expect(component.getName()).andReturn("bar").atLeastOnce(); - EasyMock.expect(component.isSystem()).andReturn(true).atLeastOnce(); - component.stop(); - List wires = TestUtils.createInboundWires(services); - EasyMock.expect(component.getInboundWires()).andReturn(wires).atLeastOnce(); - EasyMock.replay(component); - parent.register(component); - parent.start(); - parent.stop(); - EasyMock.verify(component); - } - - public void testComponentLifecycle() throws Exception { - List> services = new ArrayList>(); - services.add(Foo.class); - CompositeComponent parent = new CompositeComponentImpl("foo", "foo", null, null, null); - AtomicComponent component = EasyMock.createMock(AtomicComponent.class); - component.start(); - EasyMock.expect(component.getName()).andReturn("bar").atLeastOnce(); - EasyMock.expect(component.isSystem()).andReturn(false).atLeastOnce(); - List wires = TestUtils.createInboundWires(services); - EasyMock.expect(component.getInboundWires()).andReturn(wires).atLeastOnce(); - component.stop(); - EasyMock.replay(component); - parent.register(component); - parent.start(); - parent.stop(); - EasyMock.verify(component); - } - - public void testSystemAutowire() throws Exception { - List> services = new ArrayList>(); - services.add(Foo.class); - CompositeComponent parent = new CompositeComponentImpl("foo", "foo", null, null, null); - AtomicComponent component = EasyMock.createMock(AtomicComponent.class); - component.start(); - EasyMock.expect(component.getName()).andReturn("bar").atLeastOnce(); - EasyMock.expect(component.isSystem()).andReturn(true).atLeastOnce(); - List wires = TestUtils.createInboundWires(services); - EasyMock.expect(component.getInboundWires()).andReturn(wires).atLeastOnce(); - component.stop(); - EasyMock.replay(component); - parent.register(component); - parent.start(); - assertNull(parent.resolveSystemExternalAutowire(Foo.class)); - assertNotNull(parent.resolveSystemAutowire(Foo.class)); - parent.stop(); - EasyMock.verify(component); - } - - - public void testAutowire() throws Exception { - List> services = new ArrayList>(); - services.add(Foo.class); - CompositeComponent parent = new CompositeComponentImpl("foo", "foo", null, null, null); - AtomicComponent component = EasyMock.createMock(AtomicComponent.class); - component.start(); - EasyMock.expect(component.getName()).andReturn("bar").atLeastOnce(); - List wires = TestUtils.createInboundWires(services); - TestUtils.populateInboundWires(component, wires); - EasyMock.expect(component.getInboundWires()).andReturn(wires).atLeastOnce(); - EasyMock.expect(component.isSystem()).andReturn(false).atLeastOnce(); - component.stop(); - EasyMock.replay(component); - parent.register(component); - parent.start(); - assertNull(parent.resolveExternalAutowire(Foo.class)); - assertNotNull(parent.resolveAutowire(Foo.class)); - parent.stop(); - EasyMock.verify(component); - } - - private class Foo { - - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeComponentResolutionTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeComponentResolutionTestCase.java deleted file mode 100644 index f24e1f8e94..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeComponentResolutionTestCase.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.implementation.composite; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.tuscany.spi.component.AtomicComponent; -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.wire.InboundWire; - -import junit.framework.TestCase; -import org.apache.tuscany.core.implementation.TestUtils; -import org.apache.tuscany.core.mock.component.Source; -import org.easymock.EasyMock; - -/** - * Verifies an atomic component can be resolved from its parent - * - * @version $$Rev$$ $$Date$$ - */ -public class CompositeComponentResolutionTestCase extends TestCase { - - public void testSystemComponentResolution() throws Exception { - CompositeComponent parent = new CompositeComponentImpl("foo", null, null, true); - parent.start(); - List> interfaces = new ArrayList>(); - interfaces.add(Source.class); - AtomicComponent component = EasyMock.createMock(AtomicComponent.class); - EasyMock.expect(component.getName()).andReturn("source").atLeastOnce(); - EasyMock.expect(component.isSystem()).andReturn(true).atLeastOnce(); - List wires = TestUtils.createInboundWires(interfaces); - TestUtils.populateInboundWires(component, wires); - EasyMock.expect(component.getInboundWires()).andReturn(wires).atLeastOnce(); - EasyMock.replay(component); - parent.register(component); - assertNull(parent.getChild("source")); - assertTrue(parent.getSystemChild("source") instanceof AtomicComponent); - EasyMock.verify(component); - } - - public void testComponentResolution() throws Exception { - CompositeComponent parent = new CompositeComponentImpl("foo", null, null, null); - parent.start(); - List> interfaces = new ArrayList>(); - interfaces.add(Source.class); - AtomicComponent component = EasyMock.createMock(AtomicComponent.class); - EasyMock.expect(component.getName()).andReturn("source").atLeastOnce(); - EasyMock.expect(component.isSystem()).andReturn(false).atLeastOnce(); - List wires = TestUtils.createInboundWires(interfaces); - TestUtils.populateInboundWires(component, wires); - EasyMock.expect(component.getInboundWires()).andReturn(wires).atLeastOnce(); - EasyMock.replay(component); - parent.register(component); - assertNull(parent.getSystemChild("source")); - assertTrue(parent.getChild("source") instanceof AtomicComponent); - EasyMock.verify(component); - } - - - protected void setUp() throws Exception { - super.setUp(); - } - - protected void tearDown() throws Exception { - super.tearDown(); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeLifecycleTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeLifecycleTestCase.java deleted file mode 100644 index f5d209fe4c..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeLifecycleTestCase.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.util.ArrayList; -import java.util.List; - -import org.apache.tuscany.spi.component.AtomicComponent; -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.wire.InboundWire; - -import junit.framework.TestCase; -import org.apache.tuscany.core.implementation.TestUtils; -import org.apache.tuscany.core.mock.component.Source; -import org.easymock.EasyMock; - -/** - * @version $$Rev$$ $$Date$$ - */ -public class CompositeLifecycleTestCase extends TestCase { - - public void testLifecycle() throws Exception { - CompositeComponent composite = new CompositeComponentImpl("foo", null, null, null); - composite.start(); - assertNull(composite.getChild("nothtere")); - composite.stop(); - composite.start(); - assertNull(composite.getChild("nothtere")); - composite.stop(); - } - - public void testSystemRestart() throws Exception { - List> interfaces = new ArrayList>(); - interfaces.add(Source.class); - AtomicComponent component = EasyMock.createMock(AtomicComponent.class); - component.start(); - component.stop(); - EasyMock.expectLastCall().times(2); - EasyMock.expect(component.getName()).andReturn("source").atLeastOnce(); - EasyMock.expect(component.isSystem()).andReturn(true).atLeastOnce(); - - List wires = TestUtils.createInboundWires(interfaces); - TestUtils.populateInboundWires(component, wires); - EasyMock.expect(component.getInboundWires()).andReturn(wires).atLeastOnce(); - - EasyMock.replay(component); - - CompositeComponent composite = new CompositeComponentImpl("foo", null, null, null); - composite.start(); - composite.register(component); - - assertTrue(composite.getSystemChild("source") instanceof AtomicComponent); - composite.stop(); - composite.start(); - assertTrue(composite.getSystemChild("source") instanceof AtomicComponent); - composite.stop(); - EasyMock.verify(component); - } - - public void testRestart() throws Exception { - List> interfaces = new ArrayList>(); - interfaces.add(Source.class); - AtomicComponent component = EasyMock.createMock(AtomicComponent.class); - component.start(); - component.stop(); - EasyMock.expectLastCall().times(2); - EasyMock.expect(component.getName()).andReturn("source").atLeastOnce(); - EasyMock.expect(component.isSystem()).andReturn(false).atLeastOnce(); - - List wires = TestUtils.createInboundWires(interfaces); - TestUtils.populateInboundWires(component, wires); - EasyMock.expect(component.getInboundWires()).andReturn(wires).atLeastOnce(); - - EasyMock.replay(component); - - CompositeComponent composite = new CompositeComponentImpl("foo", null, null, null); - composite.start(); - composite.register(component); - - assertTrue(composite.getChild("source") instanceof AtomicComponent); - composite.stop(); - composite.start(); - assertTrue(composite.getChild("source") instanceof AtomicComponent); - composite.stop(); - EasyMock.verify(component); - } - - public void testChildStoppedBeforeParent() throws Exception { - CompositeComponent parent = new CompositeComponentImpl("parent", null, null, null); - CompositeComponent child = new CompositeComponentImpl("child", null, null, null); - parent.register(child); - parent.start(); - child.stop(); - parent.stop(); - } - - protected void setUp() throws Exception { - super.setUp(); - } - - protected void tearDown() throws Exception { - super.tearDown(); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeLoaderWireResolutionTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeLoaderWireResolutionTestCase.java deleted file mode 100644 index 67ec182154..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeLoaderWireResolutionTestCase.java +++ /dev/null @@ -1,227 +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.URISyntaxException; - -import org.apache.tuscany.spi.implementation.java.PojoComponentType; -import org.apache.tuscany.spi.loader.InvalidWireException; -import org.apache.tuscany.spi.model.BoundServiceDefinition; -import org.apache.tuscany.spi.model.ComponentDefinition; -import org.apache.tuscany.spi.model.CompositeComponentType; -import org.apache.tuscany.spi.model.Property; -import org.apache.tuscany.spi.model.ReferenceDefinition; -import org.apache.tuscany.spi.model.ServiceDefinition; -import org.apache.tuscany.spi.model.WireDefinition; - -import junit.framework.TestCase; -import org.apache.tuscany.core.implementation.java.JavaImplementation; - -/** - * This class tests the wire resolution function of the composite loader - * - * @version $Rev$ $Date$ - */ -public class CompositeLoaderWireResolutionTestCase extends TestCase { - private CompositeComponentType> componentType; - private CompositeLoader compositeLoader = new CompositeLoader(null, null); - - public void setUp() throws Exception { - componentType = new CompositeComponentType>(); - componentType.setName("TestComposite"); - //add a service to the composite - ServiceDefinition serviceDefn = new ServiceDefinition("compositeService1", null, true); - BoundServiceDefinition boundSvcDefn = new BoundServiceDefinition("boundSvc", null, null, true, null); - BoundServiceDefinition boundSvcDefnWithTarget = - new BoundServiceDefinition("boundSvcWithTarget", null, null, true, new URI("orgTarget")); - componentType.add(serviceDefn); - componentType.add(boundSvcDefn); - componentType.add(boundSvcDefnWithTarget); - - ReferenceDefinition compositeReference = new ReferenceDefinition("compositeReference", null); - componentType.add(compositeReference); - - PojoComponentType> pojoComponentType1 = - new PojoComponentType>(); - ServiceDefinition pojoSvc1 = new ServiceDefinition("pojoSvc1", null, false); - pojoComponentType1.add(pojoSvc1); - ReferenceDefinition pojoRef1 = new ReferenceDefinition("pojoRef1", null); - pojoComponentType1.add(pojoRef1); - JavaImplementation pojoImpl1 = new JavaImplementation(); - pojoImpl1.setComponentType(pojoComponentType1); - - ComponentDefinition component1 = - new ComponentDefinition("Component1", pojoImpl1); - componentType.add(component1); - - PojoComponentType> pojoComponentType2 = - new PojoComponentType>(); - ServiceDefinition pojoSvc2 = new ServiceDefinition("pojoSvc2", null, false); - pojoComponentType2.add(pojoSvc2); - ServiceDefinition pojoSvc3 = new ServiceDefinition("pojoSvc3", null, false); - pojoComponentType2.add(pojoSvc3); - ReferenceDefinition pojoRef2 = new ReferenceDefinition("pojoRef2", null); - pojoComponentType2.add(pojoRef2); - ReferenceDefinition pojoRef3 = new ReferenceDefinition("pojoRef3", null); - pojoComponentType2.add(pojoRef3); - JavaImplementation pojoImpl2 = new JavaImplementation(); - pojoImpl2.setComponentType(pojoComponentType2); - - ComponentDefinition component2 = - new ComponentDefinition("Component2", pojoImpl2); - componentType.add(component2); - } - - public void testCompositeSvc2CompositeReferenceWire() throws Exception { - WireDefinition wireDefn = new WireDefinition(); - wireDefn.setSource(new URI("compositeService1")); - wireDefn.setTarget(new URI("compositeReference")); - componentType.add(wireDefn); - compositeLoader.resolveWires(componentType); - } - - public void testCompositeSvc2ComponentValid() throws Exception { - //undefined source and targets - WireDefinition wireDefn = new WireDefinition(); - wireDefn.setSource(new URI("compositeService1")); - wireDefn.setTarget(new URI("Component1")); - componentType.add(wireDefn); - compositeLoader.resolveWires(componentType); - } - - public void testCompositeSvc2ComponentQualifiedValid() throws Exception { - //undefined source and targets - WireDefinition wireDefn = new WireDefinition(); - wireDefn.setSource(new URI("compositeService1")); - wireDefn.setTarget(new URI("Component2/pojoSvc3")); - componentType.add(wireDefn); - compositeLoader.resolveWires(componentType); - } - - public void testCompositeSvc2ComponentQualifiedInvalid() throws URISyntaxException { - //undefined source and targets - WireDefinition wireDefn = new WireDefinition(); - wireDefn.setSource(new URI("compositeService1")); - wireDefn.setTarget(new URI("Component2/pojoSvc5")); - componentType.add(wireDefn); - try { - compositeLoader.resolveWires(componentType); - fail(); - } catch (InvalidWireException e) { - // expected - } - } - - public void testCompositeSvc2ComponentUnQualifiedInvalid() throws URISyntaxException { - //undefined source and targets - WireDefinition wireDefn = new WireDefinition(); - wireDefn.setSource(new URI("compositeService1")); - wireDefn.setTarget(new URI("Component2")); - componentType.add(wireDefn); - try { - compositeLoader.resolveWires(componentType); - fail(); - } catch (InvalidWireException e) { - // expected - } - } - - public void testComponent2CompositeReferenceValid() throws Exception { - //undefined source and targets - WireDefinition wireDefn = new WireDefinition(); - wireDefn.setSource(new URI("Component1")); - wireDefn.setTarget(new URI("compositeReference")); - componentType.add(wireDefn); - compositeLoader.resolveWires(componentType); - } - - public void testComponent2CompositeReferenceQualifiedValid() throws Exception { - //undefined source and targets - WireDefinition wireDefn = new WireDefinition(); - wireDefn.setSource(new URI("Component2/pojoRef3")); - wireDefn.setTarget(new URI("compositeReference")); - componentType.add(wireDefn); - compositeLoader.resolveWires(componentType); - } - - public void testComponent2CompositeReferenceUnQualifiedInvalid() throws URISyntaxException { - //undefined source and targets - WireDefinition wireDefn = new WireDefinition(); - wireDefn.setSource(new URI("Component2")); - wireDefn.setTarget(new URI("compositeReference")); - componentType.add(wireDefn); - - try { - compositeLoader.resolveWires(componentType); - fail(); - } catch (InvalidWireException e) { - // expected - } - } - - public void testComponent2ComponentQualifedValid() throws Exception { - //undefined source and targets - WireDefinition wireDefn = new WireDefinition(); - wireDefn.setSource(new URI("Component1")); - wireDefn.setTarget(new URI("Component2/pojoSvc3")); - componentType.add(wireDefn); - compositeLoader.resolveWires(componentType); - } - - public void testComponent2ComponentUnQualifedInvalid() throws URISyntaxException { - //undefined source and targets - WireDefinition wireDefn = new WireDefinition(); - wireDefn.setSource(new URI("Component1")); - wireDefn.setTarget(new URI("Component2")); - componentType.add(wireDefn); - try { - compositeLoader.resolveWires(componentType); - fail(); - } catch (InvalidWireException e) { - // expected - } - } - - public void testInvalidWireDefinitions() throws URISyntaxException { - //undefined source and targets - WireDefinition wireDefn = new WireDefinition(); - wireDefn.setSource(new URI("undefinedSource")); - wireDefn.setTarget(new URI("compositeReference")); - componentType.add(wireDefn); - - try { - compositeLoader.resolveWires(componentType); - fail(); - } catch (InvalidWireException e) { - // expected - } - - try { - wireDefn.setSource(new URI("compositeService1")); - wireDefn.setTarget(new URI("undefinedTarget")); - componentType.add(wireDefn); - compositeLoader.resolveWires(componentType); - fail(); - } catch (InvalidWireException e) { - // expected - } - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositePropagationTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositePropagationTestCase.java deleted file mode 100644 index 36e6e98809..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositePropagationTestCase.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.implementation.composite; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.tuscany.spi.component.AtomicComponent; -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.wire.InboundWire; - -import junit.framework.TestCase; -import org.apache.tuscany.core.implementation.TestUtils; -import org.apache.tuscany.core.mock.component.Source; -import org.easymock.EasyMock; -import static org.easymock.EasyMock.createMock; -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.replay; -import static org.easymock.EasyMock.verify; - -/** - * @version $Rev$ $Date$ - */ -public class CompositePropagationTestCase extends TestCase { - - private CompositeComponent parent; - private CompositeComponent child2; - - public void testSystemLifecyclePropagation() throws Exception { - parent.start(); - List> interfaces = new ArrayList>(); - interfaces.add(Source.class); - AtomicComponent component = createMock(AtomicComponent.class); - expect(component.getName()).andReturn("source").anyTimes(); - component.stop(); - EasyMock.expect(component.isSystem()).andReturn(true).atLeastOnce(); - List wires = TestUtils.createInboundWires(interfaces); - TestUtils.populateInboundWires(component, wires); - EasyMock.expect(component.getInboundWires()).andReturn(wires).atLeastOnce(); - - replay(component); - child2.register(component); - parent.stop(); - verify(component); - } - - public void testLifecyclePropagation() throws Exception { - parent.start(); - List> interfaces = new ArrayList>(); - interfaces.add(Source.class); - AtomicComponent component = createMock(AtomicComponent.class); - expect(component.getName()).andReturn("source").anyTimes(); - component.stop(); - EasyMock.expect(component.isSystem()).andReturn(false).atLeastOnce(); - List wires = TestUtils.createInboundWires(interfaces); - TestUtils.populateInboundWires(component, wires); - EasyMock.expect(component.getInboundWires()).andReturn(wires).atLeastOnce(); - replay(component); - child2.register(component); - parent.stop(); - verify(component); - } - - - protected void setUp() throws Exception { - super.setUp(); - parent = new CompositeComponentImpl("parent", null, null, null); - CompositeComponent child1 = new CompositeComponentImpl("child1", parent, null, null); - child2 = new CompositeComponentImpl("child2", child1, null, null); - child1.register(child2); - parent.register(child1); - } - - protected void tearDown() throws Exception { - parent.stop(); - super.tearDown(); - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/DuplicateRegistrationTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/DuplicateRegistrationTestCase.java deleted file mode 100644 index 72c2ffd827..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/DuplicateRegistrationTestCase.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.implementation.composite; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.tuscany.spi.component.AtomicComponent; -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.component.DuplicateNameException; -import org.apache.tuscany.spi.wire.InboundWire; - -import junit.framework.TestCase; -import org.apache.tuscany.core.implementation.TestUtils; -import org.apache.tuscany.core.mock.component.Source; -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 testDuplicateRegistration() throws Exception { - CompositeComponent parent = new CompositeComponentImpl(null, null, null, null); - parent.start(); - - List> interfaces = new ArrayList>(); - interfaces.add(Source.class); - AtomicComponent component1 = EasyMock.createMock(AtomicComponent.class); - EasyMock.expect(component1.getName()).andReturn("source").atLeastOnce(); - EasyMock.expect(component1.isSystem()).andReturn(true).atLeastOnce(); - component1.stop(); - List wires = TestUtils.createInboundWires(interfaces); - TestUtils.populateInboundWires(component1, wires); - EasyMock.expect(component1.getInboundWires()).andReturn(wires).atLeastOnce(); - EasyMock.replay(component1); - - AtomicComponent component2 = EasyMock.createMock(AtomicComponent.class); - EasyMock.expect(component2.getName()).andReturn("source").atLeastOnce(); - EasyMock.expect(component2.isSystem()).andReturn(true).atLeastOnce(); - component2.stop(); - EasyMock.replay(component2); - - parent.register(component1); - try { - parent.register(component2); - fail(); - } catch (DuplicateNameException e) { - // ok - } - parent.stop(); - } - - public void testDuplicateNameSystemService() throws Exception { - List> services = new ArrayList>(); - services.add(Source.class); - CompositeComponent parent = new CompositeComponentImpl("foo", "foo", null, null, null); - AtomicComponent component = EasyMock.createMock(AtomicComponent.class); - EasyMock.expect(component.getName()).andReturn("bar").atLeastOnce(); - EasyMock.expect(component.isSystem()).andReturn(true).atLeastOnce(); - List wires = TestUtils.createInboundWires(services); - TestUtils.populateInboundWires(component, wires); - EasyMock.expect(component.getInboundWires()).andReturn(wires).atLeastOnce(); - EasyMock.replay(component); - parent.register(component); - AtomicComponent component2 = EasyMock.createMock(AtomicComponent.class); - EasyMock.expect(component2.getName()).andReturn("bar").atLeastOnce(); - EasyMock.expect(component2.isSystem()).andReturn(true).atLeastOnce(); - EasyMock.replay(component2); - try { - parent.register(component2); - fail(); - } catch (DuplicateNameException e) { - // expected - } - } - - - protected void setUp() throws Exception { - super.setUp(); - } - - protected void tearDown() throws Exception { - super.tearDown(); - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/ImplementationCompositeLoaderTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/ImplementationCompositeLoaderTestCase.java deleted file mode 100644 index e5d8ef23d8..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/ImplementationCompositeLoaderTestCase.java +++ /dev/null @@ -1,194 +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.MalformedURLException; -import java.net.URL; -import javax.xml.namespace.QName; -import static javax.xml.stream.XMLStreamConstants.END_ELEMENT; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; - -import static org.osoa.sca.Version.XML_NAMESPACE_1_0; - -import org.apache.tuscany.spi.deployer.CompositeClassLoader; -import org.apache.tuscany.spi.deployer.DeploymentContext; -import org.apache.tuscany.spi.loader.LoaderException; -import org.apache.tuscany.spi.model.CompositeImplementation; -import org.apache.tuscany.spi.services.artifact.Artifact; -import org.apache.tuscany.spi.services.artifact.ArtifactRepository; - -import junit.framework.TestCase; -import static org.easymock.EasyMock.createMock; -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.replay; -import static org.easymock.EasyMock.reportMatcher; -import static org.easymock.EasyMock.verify; -import org.easymock.IArgumentMatcher; - -/** - * @version $Rev$ $Date$ - */ -public class ImplementationCompositeLoaderTestCase extends TestCase { - private static final QName IMPLEMENTATION_COMPOSITE = new QName(XML_NAMESPACE_1_0, "implementation.composite"); - - private ClassLoader cl; - private ImplementationCompositeLoader loader; - private XMLStreamReader reader; - private DeploymentContext context; - private ArtifactRepository artifactRepository; - - public void testName() throws LoaderException, XMLStreamException, MalformedURLException { - String name = "foo"; - expect(reader.getName()).andReturn(IMPLEMENTATION_COMPOSITE); - expect(reader.getAttributeValue(null, "name")).andReturn(name); - expect(reader.getAttributeValue(null, "group")).andReturn(null); - expect(reader.getAttributeValue(null, "version")).andReturn(null); - expect(reader.getAttributeValue(null, "scdlLocation")).andReturn(null); - expect(reader.getAttributeValue(null, "jarLocation")).andReturn(null); - expect(reader.next()).andReturn(END_ELEMENT); - replay(reader); - - replay(context); - replay(artifactRepository); - - CompositeImplementation impl = loader.load(null, null, reader, context); - verify(reader); - verify(context); - verify(artifactRepository); - assertEquals(name, impl.getName()); - assertNull(impl.getScdlLocation()); - assertNull(impl.getClassLoader()); - } - - public void testWithArtifact() throws LoaderException, XMLStreamException, MalformedURLException { - String name = "foo"; - expect(reader.getName()).andReturn(IMPLEMENTATION_COMPOSITE); - expect(reader.getAttributeValue(null, "name")).andReturn(name); - expect(reader.getAttributeValue(null, "group")).andReturn("com.example"); - expect(reader.getAttributeValue(null, "version")).andReturn("1.0"); - expect(reader.getAttributeValue(null, "scdlLocation")).andReturn(null); - expect(reader.getAttributeValue(null, "jarLocation")).andReturn(null); - expect(reader.next()).andReturn(END_ELEMENT); - replay(reader); - - expect(context.getClassLoader()).andReturn(cl); - replay(context); - URL url = new URL("http://www.example.com/sca/base.jar"); - artifactRepository.resolve(artifactMatcher(url, "com.example", name, "1.0")); - replay(artifactRepository); - - CompositeImplementation impl = loader.load(null, null, reader, context); - verify(reader); - verify(context); - verify(artifactRepository); - assertEquals(name, impl.getName()); - assertEquals(new URL("jar:http://www.example.com/sca/base.jar!/META-INF/sca/default.scdl"), - impl.getScdlLocation()); - assertTrue(impl.getClassLoader() instanceof CompositeClassLoader); - } - - public void testWithScdlLocation() throws LoaderException, XMLStreamException, MalformedURLException { - String name = "foo"; - expect(reader.getName()).andReturn(IMPLEMENTATION_COMPOSITE); - expect(reader.getAttributeValue(null, "name")).andReturn(name); - expect(reader.getAttributeValue(null, "group")).andReturn(null); - expect(reader.getAttributeValue(null, "version")).andReturn(null); - expect(reader.getAttributeValue(null, "scdlLocation")).andReturn("bar.scdl"); - expect(reader.getAttributeValue(null, "jarLocation")).andReturn(null); - expect(reader.next()).andReturn(END_ELEMENT); - replay(reader); - - expect(context.getScdlLocation()).andReturn(new URL("http://www.example.com/sca/base.scdl")); - expect(context.getClassLoader()).andReturn(cl); - replay(context); - replay(artifactRepository); - - CompositeImplementation impl = loader.load(null, null, reader, context); - verify(reader); - verify(context); - verify(artifactRepository); - assertEquals(name, impl.getName()); - assertEquals(new URL("http://www.example.com/sca/bar.scdl"), impl.getScdlLocation()); - assertSame(cl, impl.getClassLoader()); - } - - public void testWithJarLocation() throws LoaderException, XMLStreamException, MalformedURLException { - String name = "foo"; - expect(reader.getName()).andReturn(IMPLEMENTATION_COMPOSITE); - expect(reader.getAttributeValue(null, "name")).andReturn(name); - expect(reader.getAttributeValue(null, "group")).andReturn(null); - expect(reader.getAttributeValue(null, "version")).andReturn(null); - expect(reader.getAttributeValue(null, "scdlLocation")).andReturn(null); - expect(reader.getAttributeValue(null, "jarLocation")).andReturn("bar.jar"); - expect(reader.next()).andReturn(END_ELEMENT); - replay(reader); - - expect(context.getScdlLocation()).andReturn(new URL("http://www.example.com/sca/base.scdl")); - expect(context.getClassLoader()).andReturn(cl); - replay(context); - replay(artifactRepository); - - CompositeImplementation impl = loader.load(null, null, reader, context); - verify(reader); - verify(context); - verify(artifactRepository); - assertEquals(name, impl.getName()); - assertEquals(new URL("jar:http://www.example.com/sca/bar.jar!/META-INF/sca/default.scdl"), - impl.getScdlLocation()); - } - - protected void setUp() throws Exception { - super.setUp(); - artifactRepository = createMock(ArtifactRepository.class); - reader = createMock(XMLStreamReader.class); - context = createMock(DeploymentContext.class); - cl = getClass().getClassLoader(); - loader = new ImplementationCompositeLoader(null, artifactRepository); - } - - protected static Artifact artifactMatcher(final URL url, - final String group, - final String name, - final String version) { - reportMatcher(new IArgumentMatcher() { - - public boolean matches(Object object) { - if (!(object instanceof Artifact)) { - return false; - } - - Artifact artifact = (Artifact) object; - boolean match = group.equals(artifact.getGroup()) - && name.equals(artifact.getName()) - && version.equals(artifact.getVersion()) - && "jar".equals(artifact.getType()); - if (match) { - artifact.setUrl(url); - } - return match; - } - - public void appendTo(StringBuffer stringBuffer) { - stringBuffer.append(group).append(':').append(name).append(':').append(version); - } - }); - return null; - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/JavaObjectRegistrationTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/JavaObjectRegistrationTestCase.java deleted file mode 100644 index 8c0c7470fa..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/JavaObjectRegistrationTestCase.java +++ /dev/null @@ -1,88 +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.AtomicComponent; -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.component.DuplicateNameException; -import org.apache.tuscany.spi.component.SCAObject; - -import junit.framework.TestCase; -import org.apache.tuscany.core.component.event.CompositeStart; -import org.apache.tuscany.core.component.event.CompositeStop; - -/** - * @version $Rev$ $Date$ - */ -public class JavaObjectRegistrationTestCase extends TestCase { - private CompositeComponent composite; - - public void testRegistration() throws Exception { - MockComponent instance = new MockComponent(); - composite.registerJavaObject("foo", MockComponent.class, instance); - SCAObject child = composite.getSystemChild("foo"); - assertTrue(child instanceof AtomicComponent); - MockComponent resolvedInstance = (MockComponent) ((AtomicComponent) child).getTargetInstance(); - assertSame(instance, resolvedInstance); - } - - public void testDuplicateRegistration() throws Exception { - MockComponent instance = new MockComponent(); - composite.registerJavaObject("foo", MockComponent.class, instance); - try { - composite.registerJavaObject("foo", MockComponent.class, instance); - fail(); - } catch (DuplicateNameException e) { - // ok - } - } - - public void testSystemAutowireToObject() throws Exception { - MockComponent instance = new MockComponent(); - composite.registerJavaObject("foo", MockComponent.class, instance); - assertSame(instance, composite.resolveSystemAutowire(MockComponent.class).getTargetService()); - assertNull(composite.resolveSystemExternalAutowire(MockComponent.class)); - } - - public void testApplicationAutowireToObject() throws Exception { - MockComponent instance = new MockComponent(); - composite.registerJavaObject("foo", MockComponent.class, instance); - assertNull(composite.resolveAutowire(MockComponent.class)); - assertNull(composite.resolveExternalAutowire(MockComponent.class)); - } - - protected void setUp() throws Exception { - super.setUp(); - composite = new CompositeComponentImpl(null, null, null, null); - composite.start(); - composite.publish(new CompositeStart(this, null)); - } - - protected void tearDown() throws Exception { - composite.publish(new CompositeStop(this, null)); - composite.stop(); - super.tearDown(); - } - - private static class MockComponent { - public String hello(String message) { - return message; - } - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/ManagedRequestContextTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/ManagedRequestContextTestCase.java deleted file mode 100644 index 12299e762b..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/ReferenceImplTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/ReferenceImplTestCase.java deleted file mode 100644 index 251833a554..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/ReferenceImplTestCase.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.implementation.composite; - -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.setReference(EasyMock.isA(Reference.class)); - binding.start(); - EasyMock.replay(binding); - Reference reference = new ReferenceImpl(null, null, null); - reference.addReferenceBinding(binding); - reference.start(); - EasyMock.verify(binding); - - } - - public void testStop() { - ReferenceBinding binding = EasyMock.createMock(ReferenceBinding.class); - binding.setReference(EasyMock.isA(Reference.class)); - binding.stop(); - EasyMock.replay(binding); - Reference reference = new ReferenceImpl(null, null, null); - reference.addReferenceBinding(binding); - reference.stop(); - EasyMock.verify(binding); - - } - - public void testIsSystem() { - Reference service = new ReferenceImpl(null, null, null, true); - assertTrue(service.isSystem()); - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/ServiceImplTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/ServiceImplTestCase.java deleted file mode 100644 index 88d40a50eb..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/ServiceImplTestCase.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.implementation.composite; - -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.setService(EasyMock.isA(Service.class)); - binding.start(); - EasyMock.replay(binding); - Service service = new ServiceImpl(null, null, null); - service.addServiceBinding(binding); - service.start(); - EasyMock.verify(binding); - - } - - public void testStop() { - ServiceBinding binding = EasyMock.createMock(ServiceBinding.class); - binding.setService(EasyMock.isA(Service.class)); - binding.stop(); - EasyMock.replay(binding); - Service service = new ServiceImpl(null, null, null); - service.addServiceBinding(binding); - service.stop(); - EasyMock.verify(binding); - - } - - public void testIsSystem() { - Service service = new ServiceImpl(null, null, null, null, true); - assertTrue(service.isSystem()); - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/SystemComponentBuilderTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/SystemComponentBuilderTestCase.java deleted file mode 100644 index 4645075a7a..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/SystemComponentBuilderTestCase.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.implementation.composite; - -import java.lang.reflect.Method; - -import org.apache.tuscany.spi.component.AtomicComponent; -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.deployer.DeploymentContext; -import org.apache.tuscany.spi.implementation.java.ConstructorDefinition; -import org.apache.tuscany.spi.implementation.java.JavaMappedProperty; -import org.apache.tuscany.spi.implementation.java.JavaMappedReference; -import org.apache.tuscany.spi.implementation.java.JavaMappedService; -import org.apache.tuscany.spi.implementation.java.PojoComponentType; -import org.apache.tuscany.spi.model.ComponentDefinition; -import org.apache.tuscany.spi.model.PropertyValue; -import org.apache.tuscany.spi.model.Scope; - -import junit.framework.TestCase; -import org.apache.tuscany.core.component.event.CompositeStart; -import org.apache.tuscany.core.component.event.CompositeStop; -import org.apache.tuscany.core.component.scope.CompositeScopeContainer; -import org.apache.tuscany.core.implementation.system.builder.SystemComponentBuilder; -import org.apache.tuscany.core.implementation.system.model.SystemImplementation; -import org.apache.tuscany.core.injection.SingletonObjectFactory; -import org.easymock.EasyMock; - -/** - * @version $Rev$ $Date$ - */ -public class SystemComponentBuilderTestCase extends TestCase { - - CompositeComponent parent; - DeploymentContext deploymentContext; - SystemComponentBuilder builder = new SystemComponentBuilder(); - CompositeScopeContainer container; - - /** - * Verifies lifecycle callbacks are made - */ - public void testLifecycleBuild() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - type.setInitLevel(50); - Method initMethod = FooImpl.class.getMethod("init"); - initMethod.setAccessible(true); - type.setInitMethod(initMethod); - Method destroyMethod = FooImpl.class.getMethod("destroy"); - destroyMethod.setAccessible(true); - type.setDestroyMethod(destroyMethod); - type.setImplementationScope(Scope.COMPOSITE); - ConstructorDefinition ctorDef = new ConstructorDefinition(FooImpl.class.getConstructor()); - type.setConstructorDefinition(ctorDef); - SystemImplementation impl = new SystemImplementation(); - impl.setComponentType(type); - impl.setImplementationClass(FooImpl.class); - ComponentDefinition definition = new ComponentDefinition(impl); - AtomicComponent component = builder.build(parent, definition, deploymentContext); - component.setScopeContainer(container); - component.start(); - container.onEvent(new CompositeStart(this, null)); - FooImpl foo = (FooImpl) component.getTargetInstance(); - assertTrue(foo.initialized); - container.onEvent(new CompositeStop(this, null)); - assertTrue(foo.destroyed); - } - - /** - * Verifies properties are built properly - */ - public void testPropertyBuild() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - type.setInitLevel(50); - Method initMethod = FooImpl.class.getMethod("init"); - initMethod.setAccessible(true); - type.setInitMethod(initMethod); - Method destroyMethod = FooImpl.class.getMethod("destroy"); - destroyMethod.setAccessible(true); - type.setDestroyMethod(destroyMethod); - type.setImplementationScope(Scope.COMPOSITE); - JavaMappedProperty mappedProp = new JavaMappedProperty(); - mappedProp.setName("prop"); - Method propMethod = FooImpl.class.getMethod("setProp", String.class); - propMethod.setAccessible(true); - mappedProp.setMember(propMethod); - type.add(mappedProp); - ConstructorDefinition ctorDef = new ConstructorDefinition(FooImpl.class.getConstructor()); - type.setConstructorDefinition(ctorDef); - SystemImplementation impl = new SystemImplementation(); - impl.setComponentType(type); - impl.setImplementationClass(FooImpl.class); - ComponentDefinition definition = new ComponentDefinition(impl); - PropertyValue propVal = new PropertyValue(); - propVal.setName("prop"); - propVal.setValueFactory(new SingletonObjectFactory("value")); - definition.add(propVal); - AtomicComponent component = builder.build(parent, definition, deploymentContext); - component.setScopeContainer(container); - component.start(); - FooImpl foo = (FooImpl) component.getTargetInstance(); - assertEquals("value", foo.prop); - container.onEvent(new CompositeStop(this, null)); - } - - protected void setUp() throws Exception { - super.setUp(); - parent = EasyMock.createNiceMock(CompositeComponent.class); - container = new CompositeScopeContainer(null); - container.start(); - deploymentContext = EasyMock.createMock(DeploymentContext.class); - EasyMock.expect(deploymentContext.getCompositeScope()).andReturn(container).atLeastOnce(); - EasyMock.replay(deploymentContext); - } - - private static interface Foo { - - } - - private static class FooImpl implements Foo { - private boolean initialized; - private boolean destroyed; - private String prop; - private Foo ref; - - public FooImpl() { - } - - public void init() { - if (initialized) { - fail(); - } - initialized = true; - } - - public void destroy() { - if (destroyed) { - fail(); - } - destroyed = true; - } - - public boolean isInitialized() { - return initialized; - } - - public String getProp() { - return prop; - } - - public void setProp(String prop) { - this.prop = prop; - } - - public Foo getRef() { - return ref; - } - - public void setRef(Foo ref) { - this.ref = ref; - } - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/SystemSingletonAtomicComponentTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/SystemSingletonAtomicComponentTestCase.java deleted file mode 100644 index 9c482b994f..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/SystemSingletonAtomicComponentTestCase.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.implementation.composite; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.tuscany.spi.component.TargetException; - -import junit.framework.TestCase; - -/** - * @version $Rev$ $Date$ - */ -public class SystemSingletonAtomicComponentTestCase extends TestCase { - - public void testGetInstance() throws TargetException { - FooImpl foo = new FooImpl(); - SystemSingletonAtomicComponent component = - new SystemSingletonAtomicComponent("foo", null, Foo.class, foo); - assertEquals(foo, component.getTargetInstance()); - } - - public void testGetInstanceMultipleServices() throws TargetException { - FooImpl foo = new FooImpl(); - List> services = new ArrayList>(); - services.add(Foo.class); - services.add(Bar.class); - SystemSingletonAtomicComponent component = - new SystemSingletonAtomicComponent("foo", null, services, foo); - assertEquals(foo, component.getTargetInstance()); - } - - private interface Foo { - - } - - private interface Bar { - - } - - private class FooImpl implements Foo, Bar { - - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaAtomicComponentMetadataInjectionTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaAtomicComponentMetadataInjectionTestCase.java deleted file mode 100644 index 5186119345..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaAtomicComponentMetadataInjectionTestCase.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.implementation.java; - -import junit.framework.TestCase; - -/** - * Tests SCA metadata such as @ComponentName and @SCAObject are handled properly - * - * @version $Rev$ $Date$ - */ -public class JavaAtomicComponentMetadataInjectionTestCase extends TestCase { - - public void testComponentNameSet() throws Exception { - // TODO implement - } - - public void testCompositeContextSet() throws Exception { - // TODO implement - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaAtomicComponentNegativeMetadataTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaAtomicComponentNegativeMetadataTestCase.java deleted file mode 100644 index dfd62c8c53..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaAtomicComponentNegativeMetadataTestCase.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.implementation.java; - -import junit.framework.TestCase; - - -/** - * Performs rudimentary negative testing by using malformed metadata on a POJO - * - * @version $Rev $Date - */ -public class JavaAtomicComponentNegativeMetadataTestCase extends TestCase { - - /** - * Tests that a pojo with @ComponentName specified on a non-String type generates an error. - *

      - * NB: the test assumes an error with a message containing "@ComponentName" is generated - */ - public void testBadNameType() throws Exception { - // TODO implement - } - - /** - * Tests that a pojo with @Context specified on a non-CompositeContext type generates an error. - *

      - * NB: the test assumes an error with a message containing "@Context" is generated - */ - public void testContextType() throws Exception { - // TODO implement - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaBuilderPropertyTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaBuilderPropertyTestCase.java deleted file mode 100644 index 22b1964d4a..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaBuilderPropertyTestCase.java +++ /dev/null @@ -1,139 +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.java; - -import org.apache.tuscany.spi.ObjectFactory; -import org.apache.tuscany.spi.component.AtomicComponent; -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.component.ScopeContainer; -import org.apache.tuscany.spi.component.ScopeRegistry; -import org.apache.tuscany.spi.deployer.DeploymentContext; -import org.apache.tuscany.spi.implementation.java.ConstructorDefinition; -import org.apache.tuscany.spi.implementation.java.JavaMappedProperty; -import org.apache.tuscany.spi.implementation.java.PojoComponentType; -import org.apache.tuscany.spi.model.ComponentDefinition; -import org.apache.tuscany.spi.model.PropertyValue; -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.apache.tuscany.core.injection.SingletonObjectFactory; -import org.easymock.EasyMock; - -/** - * Verifies that the java component builder handles configured properties correctly - * - * @version $Rev$ $Date$ - */ -public class JavaBuilderPropertyTestCase extends TestCase { - private DeploymentContext deploymentContext; - private CompositeComponent parent; - private ScopeRegistry registry; - - @SuppressWarnings("unchecked") - public void testPropertyHandling() throws Exception { - JavaComponentBuilder builder = new JavaComponentBuilder(); - builder.setScopeRegistry(registry); - PojoComponentType> type = - new PojoComponentType>(); - JavaMappedProperty property = new JavaMappedProperty(); - property.setName("test"); - property.setDefaultValueFactory(new SingletonObjectFactory("foo")); - property.setMember(JavaBuilderPropertyTestCase.Foo.class.getMethod("setTest", String.class)); - type.add(property); - type.setConstructorDefinition(new ConstructorDefinition(Foo.class.getConstructor((Class[]) null))); - type.setImplementationScope(Scope.STATELESS); - JavaImplementation impl = new JavaImplementation(); - impl.setComponentType(type); - impl.setImplementationClass(Foo.class); - ComponentDefinition definition = new ComponentDefinition(impl); - PropertyValue propertyValue = new PropertyValue(property.getName(), property.getDefaultValueFactory()); - definition.getPropertyValues().put(property.getName(), propertyValue); - AtomicComponent component = builder.build(parent, definition, deploymentContext); - JavaBuilderPropertyTestCase.Foo foo = (JavaBuilderPropertyTestCase.Foo) component.createInstance(); - assertEquals("foo", foo.getTest()); - } - - public void testIntPropertyHandling() throws Exception { - JavaComponentBuilder builder = new JavaComponentBuilder(); - builder.setScopeRegistry(registry); - PojoComponentType> type = - new PojoComponentType>(); - JavaMappedProperty property = new JavaMappedProperty(); - property.setName("test"); - property.setDefaultValueFactory(new SingletonObjectFactory(1)); - property.setMember(JavaBuilderPropertyTestCase.FooInt.class.getMethod("setTest", Integer.TYPE)); - type.add(property); - type.setConstructorDefinition(new ConstructorDefinition(FooInt.class.getConstructor((Class[]) null))); - type.setImplementationScope(Scope.STATELESS); - JavaImplementation impl = new JavaImplementation(); - impl.setComponentType(type); - impl.setImplementationClass(Foo.class); - ComponentDefinition definition = new ComponentDefinition(impl); - ObjectFactory defaultValueFactory = property.getDefaultValueFactory(); - PropertyValue propertyValue = new PropertyValue(property.getName(), defaultValueFactory); - definition.getPropertyValues().put(property.getName(), propertyValue); - AtomicComponent component = builder.build(parent, definition, deploymentContext); - FooInt foo = (FooInt) component.createInstance(); - assertEquals(1, foo.getTest()); - } - - protected void setUp() throws Exception { - super.setUp(); - deploymentContext = EasyMock.createMock(DeploymentContext.class); - EasyMock.replay(deploymentContext); - parent = EasyMock.createNiceMock(CompositeComponent.class); - ScopeContainer mockContainer = EasyMock.createNiceMock(ScopeContainer.class); - EasyMock.replay(mockContainer); - registry = EasyMock.createMock(ScopeRegistry.class); - EasyMock.expect(registry.getScopeContainer(EasyMock.isA(Scope.class))).andReturn(mockContainer); - EasyMock.replay(registry); - } - - private static class Foo { - private String test; - - public Foo() { - } - - public String getTest() { - return test; - } - - public void setTest(String test) { - this.test = test; - } - } - - private static class FooInt { - private int test; - - public FooInt() { - } - - public int getTest() { - return test; - } - - public void setTest(int test) { - this.test = test; - } - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaComponentBuilderConversationIDTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaComponentBuilderConversationIDTestCase.java deleted file mode 100644 index 6d9ec8e96b..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaComponentBuilderConversationIDTestCase.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.implementation.java; - -import java.lang.reflect.Field; - -import org.apache.tuscany.core.component.WorkContextImpl; -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.component.ScopeContainer; -import org.apache.tuscany.spi.component.ScopeRegistry; -import org.apache.tuscany.spi.component.WorkContext; -import org.apache.tuscany.spi.implementation.java.ConstructorDefinition; -import org.apache.tuscany.spi.implementation.java.PojoComponentType; -import org.apache.tuscany.spi.model.ComponentDefinition; -import org.apache.tuscany.spi.model.Scope; - -import junit.framework.TestCase; -import org.easymock.EasyMock; -import org.osoa.sca.annotations.ConversationID; - -/** - * @version $Rev: 473859 $ $Date: 2006-11-11 22:31:55 -0500 (Sat, 11 Nov 2006) $ - */ -public class JavaComponentBuilderConversationIDTestCase extends TestCase { - - @SuppressWarnings("unchecked") - public void testResourceInjection() throws Exception { - ScopeContainer container = EasyMock.createNiceMock(ScopeContainer.class); - ScopeRegistry registry = EasyMock.createMock(ScopeRegistry.class); - EasyMock.expect(registry.getScopeContainer(Scope.STATELESS)).andReturn(container); - EasyMock.replay(registry); - JavaComponentBuilder builder = new JavaComponentBuilder(); - builder.setScopeRegistry(registry); - WorkContext workContext = new WorkContextImpl(); - workContext.setIdentifier(Scope.CONVERSATION, "convID"); - builder.setWorkContext(workContext); - - ConstructorDefinition ctorDef = new ConstructorDefinition(Foo.class.getConstructor()); - PojoComponentType type = new PojoComponentType(); - Field field = Foo.class.getDeclaredField("conversationID"); - type.setConversationIDMember(field); - type.setImplementationScope(Scope.STATELESS); - type.setConstructorDefinition(ctorDef); - - JavaImplementation impl = new JavaImplementation(); - impl.setImplementationClass(Foo.class); - impl.setComponentType(type); - ComponentDefinition definition = new ComponentDefinition("foo", impl); - CompositeComponent parent = EasyMock.createMock(CompositeComponent.class); - JavaAtomicComponent component = (JavaAtomicComponent) builder.build(parent, definition, null); - Foo foo = (Foo) component.createInstance(); - assertEquals("convID", foo.conversationID); - } - - private static class Foo { - - @ConversationID - protected String conversationID; - - public Foo() { - } - - } -} - - diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaComponentBuilderMetadataTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaComponentBuilderMetadataTestCase.java deleted file mode 100644 index 0b1445f6ee..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaComponentBuilderMetadataTestCase.java +++ /dev/null @@ -1,114 +0,0 @@ -package org.apache.tuscany.core.implementation.java; - -import java.lang.reflect.Constructor; - -import org.apache.tuscany.spi.component.AtomicComponent; -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.component.ScopeContainer; -import org.apache.tuscany.spi.deployer.DeploymentContext; -import org.apache.tuscany.spi.idl.java.JavaServiceContract; -import org.apache.tuscany.spi.implementation.java.ConstructorDefinition; -import org.apache.tuscany.spi.implementation.java.JavaMappedProperty; -import org.apache.tuscany.spi.implementation.java.JavaMappedReference; -import org.apache.tuscany.spi.implementation.java.JavaMappedService; -import org.apache.tuscany.spi.implementation.java.PojoComponentType; -import org.apache.tuscany.spi.model.ComponentDefinition; -import org.apache.tuscany.spi.model.Scope; -import org.apache.tuscany.spi.model.ServiceContract; - -import junit.framework.TestCase; -import org.apache.tuscany.core.implementation.composite.CompositeComponentImpl; -import org.apache.tuscany.core.mock.component.Source; -import org.apache.tuscany.core.mock.component.SourceImpl; -import org.apache.tuscany.core.mock.component.Target; -import org.easymock.EasyMock; - -/** - * Verifies component type metadata is properly applied to the component - * - * @version $$Rev$$ $$Date$$ - */ -public class JavaComponentBuilderMetadataTestCase extends TestCase { - private DeploymentContext deploymentContext; - private Constructor constructor; - private CompositeComponent parent; - private PojoComponentType> type; - private ComponentDefinition definition; - private ScopeContainer scopeContainer; - - public void testInitLevel() throws Exception { - type.setInitLevel(1); - JavaComponentBuilder builder = new JavaComponentBuilder(); - JavaAtomicComponent component = (JavaAtomicComponent) builder.build(parent, definition, deploymentContext); - assertEquals(1, component.getInitLevel()); - } - - public void testMaxAge() throws Exception { - type.setMaxAge(100); - JavaComponentBuilder builder = new JavaComponentBuilder(); - JavaAtomicComponent component = (JavaAtomicComponent) builder.build(parent, definition, deploymentContext); - assertEquals(100, component.getMaxAge()); - } - - public void testMaxIdleTime() throws Exception { - type.setMaxIdleTime(100); - JavaComponentBuilder builder = new JavaComponentBuilder(); - JavaAtomicComponent component = (JavaAtomicComponent) builder.build(parent, definition, deploymentContext); - assertEquals(100, component.getMaxIdleTime()); - } - - public void testNoMaxAgeNoMaxIdleTime() throws Exception { - JavaComponentBuilder builder = new JavaComponentBuilder(); - JavaAtomicComponent component = (JavaAtomicComponent) builder.build(parent, definition, deploymentContext); - assertEquals(-1, component.getMaxAge()); - assertEquals(-1, component.getMaxIdleTime()); - } - - public void testScope() throws Exception { - JavaComponentBuilder builder = new JavaComponentBuilder(); - JavaAtomicComponent component = (JavaAtomicComponent) builder.build(parent, definition, deploymentContext); - component.setScopeContainer(scopeContainer); - assertEquals(Scope.COMPOSITE, component.getScope()); - } - - protected void setUp() throws Exception { - super.setUp(); - parent = new CompositeComponentImpl(null, null, null, null); - constructor = SourceImpl.class.getConstructor((Class[]) null); - createDeploymentContext(); - createComponentDefinitionAndType(); - } - - - private void createDeploymentContext() { - scopeContainer = EasyMock.createMock(ScopeContainer.class); - scopeContainer.start(); - scopeContainer.stop(); - scopeContainer.register(EasyMock.isA(AtomicComponent.class)); - EasyMock.expectLastCall().atLeastOnce(); - EasyMock.expect(scopeContainer.getScope()).andReturn(Scope.COMPOSITE).atLeastOnce(); - EasyMock.replay(scopeContainer); - deploymentContext = EasyMock.createMock(DeploymentContext.class); - EasyMock.replay(deploymentContext); - } - - private void createComponentDefinitionAndType() throws Exception { - type = new PojoComponentType>(); - type.setImplementationScope(Scope.COMPOSITE); - JavaMappedReference reference = new JavaMappedReference(); - reference.setName("target"); - reference.setMember(SourceImpl.class.getMethod("setTarget", Target.class)); - type.add(reference); - ServiceContract contract = new JavaServiceContract(Source.class); - JavaMappedService serviceDefinition = new JavaMappedService(); - serviceDefinition.setName("Source"); - serviceDefinition.setServiceContract(contract); - type.add(serviceDefinition); - type.setConstructorDefinition(new ConstructorDefinition(constructor)); - JavaImplementation sourceImpl = new JavaImplementation(); - sourceImpl.setComponentType(type); - sourceImpl.setImplementationClass(SourceImpl.class); - definition = new ComponentDefinition(sourceImpl); - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaComponentBuilderReferenceTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaComponentBuilderReferenceTestCase.java deleted file mode 100644 index de91aee6aa..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaComponentBuilderReferenceTestCase.java +++ /dev/null @@ -1,151 +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.java; - -import java.lang.reflect.Constructor; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -import org.apache.tuscany.spi.component.AtomicComponent; -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.component.SCAObject; -import org.apache.tuscany.spi.component.ScopeContainer; -import org.apache.tuscany.spi.deployer.DeploymentContext; -import org.apache.tuscany.spi.idl.java.JavaServiceContract; -import org.apache.tuscany.spi.implementation.java.ConstructorDefinition; -import org.apache.tuscany.spi.implementation.java.JavaMappedProperty; -import org.apache.tuscany.spi.implementation.java.JavaMappedReference; -import org.apache.tuscany.spi.implementation.java.JavaMappedService; -import org.apache.tuscany.spi.implementation.java.PojoComponentType; -import org.apache.tuscany.spi.model.ComponentDefinition; -import org.apache.tuscany.spi.model.InteractionScope; -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.wire.OutboundInvocationChain; -import org.apache.tuscany.spi.wire.OutboundWire; -import org.apache.tuscany.spi.wire.WireService; - -import junit.framework.TestCase; -import org.apache.tuscany.core.implementation.composite.CompositeComponentImpl; -import org.apache.tuscany.core.mock.component.Source; -import org.apache.tuscany.core.mock.component.SourceImpl; -import org.apache.tuscany.core.mock.component.Target; -import org.apache.tuscany.core.wire.jdk.JDKWireService; -import org.easymock.EasyMock; -import org.easymock.IAnswer; - -/** - * @version $$Rev$$ $$Date$$ - */ -public class JavaComponentBuilderReferenceTestCase extends TestCase { - private DeploymentContext deploymentContext; - private WireService wireService; - private Constructor constructor; - private CompositeComponent parent; - private OutboundWire wire; - private ScopeContainer scopeContainer; - - public void testBuildReference() throws Exception { - - PojoComponentType> sourceType = - new PojoComponentType>(); - sourceType.setImplementationScope(Scope.COMPOSITE); - JavaMappedReference reference = new JavaMappedReference(); - reference.setName("target"); - reference.setMember(SourceImpl.class.getMethod("setTarget", Target.class)); - sourceType.add(reference); - ServiceContract contract = new JavaServiceContract(Source.class); - JavaMappedService serviceDefinition = new JavaMappedService(); - serviceDefinition.setName("Source"); - serviceDefinition.setServiceContract(contract); - sourceType.add(serviceDefinition); - sourceType.setConstructorDefinition(new ConstructorDefinition(constructor)); - JavaImplementation sourceImpl = new JavaImplementation(); - sourceImpl.setComponentType(sourceType); - sourceImpl.setImplementationClass(SourceImpl.class); - ComponentDefinition definition = new ComponentDefinition(sourceImpl); - - JavaComponentBuilder builder = new JavaComponentBuilder(); - builder.setWireService(wireService); - JavaAtomicComponent component = (JavaAtomicComponent) builder.build(parent, definition, deploymentContext); - component.setScopeContainer(scopeContainer); - component.addOutboundWire(wire); - deploymentContext.getCompositeScope().start(); - component.start(); - - Source source = (Source) component.getTargetInstance(); - assertNotNull(source.getTarget()); - component.stop(); - } - - protected void setUp() throws Exception { - super.setUp(); - wireService = new JDKWireService(); - parent = new CompositeComponentImpl(null, null, null, null); - constructor = SourceImpl.class.getConstructor((Class[]) null); - createDeploymentContext(); - createWire(); - } - - - private void createDeploymentContext() throws Exception { - scopeContainer = EasyMock.createMock(ScopeContainer.class); - scopeContainer.start(); - scopeContainer.stop(); - scopeContainer.register(EasyMock.isA(AtomicComponent.class)); - EasyMock.expectLastCall().atLeastOnce(); - EasyMock.expect(scopeContainer.getScope()).andReturn(Scope.COMPOSITE).atLeastOnce(); - scopeContainer.getInstance(EasyMock.isA(AtomicComponent.class)); - EasyMock.expectLastCall().andAnswer(new IAnswer() { - private Map cache = new HashMap(); - - public Object answer() throws Throwable { - AtomicComponent component = (AtomicComponent) EasyMock.getCurrentArguments()[0]; - Object instance = cache.get(component); - if (instance == null) { - instance = component.createInstance(); - cache.put(component, instance); - } - return instance; - } - }).anyTimes(); - EasyMock.replay(scopeContainer); - deploymentContext = EasyMock.createMock(DeploymentContext.class); - EasyMock.expect(deploymentContext.getCompositeScope()).andReturn(scopeContainer).atLeastOnce(); - EasyMock.replay(deploymentContext); - } - - private void createWire() { - SCAObject scaObject = EasyMock.createNiceMock(SCAObject.class); - Map, OutboundInvocationChain> chains = Collections.emptyMap(); - wire = EasyMock.createMock(OutboundWire.class); - EasyMock.expect(wire.getReferenceName()).andReturn("target").atLeastOnce(); - EasyMock.expect(wire.getInvocationChains()).andReturn(chains).atLeastOnce(); - EasyMock.expect(wire.isOptimizable()).andReturn(false); - JavaServiceContract targetContract = new JavaServiceContract(Target.class); - targetContract.setInteractionScope(InteractionScope.NONCONVERSATIONAL); - EasyMock.expect(wire.getServiceContract()).andReturn(targetContract).atLeastOnce(); - EasyMock.expect(wire.getContainer()).andReturn(scaObject).atLeastOnce(); - EasyMock.replay(wire); - - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaComponentBuilderResourceTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaComponentBuilderResourceTestCase.java deleted file mode 100644 index 2665ba8da7..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaComponentBuilderResourceTestCase.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.implementation.java; - -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.component.ScopeContainer; -import org.apache.tuscany.spi.component.ScopeRegistry; -import org.apache.tuscany.spi.implementation.java.ConstructorDefinition; -import org.apache.tuscany.spi.implementation.java.PojoComponentType; -import org.apache.tuscany.spi.implementation.java.Resource; -import org.apache.tuscany.spi.model.ComponentDefinition; -import org.apache.tuscany.spi.model.Scope; -import org.apache.tuscany.spi.wire.InboundWire; - -import junit.framework.TestCase; -import org.easymock.EasyMock; - -/** - * @version $Rev$ $Date$ - */ -public class JavaComponentBuilderResourceTestCase extends TestCase { - - @SuppressWarnings("unchecked") - public void testResourceInjection() throws Exception { - ScopeContainer container = EasyMock.createNiceMock(ScopeContainer.class); - ScopeRegistry registry = EasyMock.createMock(ScopeRegistry.class); - EasyMock.expect(registry.getScopeContainer(Scope.STATELESS)).andReturn(container); - EasyMock.replay(registry); - JavaComponentBuilder builder = new JavaComponentBuilder(); - builder.setScopeRegistry(registry); - ConstructorDefinition ctorDef = new ConstructorDefinition(Foo.class.getConstructor()); - PojoComponentType type = new PojoComponentType(); - Resource resource = new Resource(); - resource.setType(String.class); - resource.setName("resource"); - resource.setMember(Foo.class.getDeclaredField("resource")); - type.add(resource); - type.setImplementationScope(Scope.STATELESS); - type.setConstructorDefinition(ctorDef); - JavaImplementation impl = new JavaImplementation(); - impl.setImplementationClass(Foo.class); - impl.setComponentType(type); - ComponentDefinition definition = new ComponentDefinition("foo", impl); - InboundWire resourceWire = EasyMock.createMock(InboundWire.class); - EasyMock.expect(resourceWire.getTargetService()).andReturn("result"); - EasyMock.replay(resourceWire); - - CompositeComponent parent = EasyMock.createMock(CompositeComponent.class); - EasyMock.expect(parent.resolveSystemAutowire(String.class)).andReturn(resourceWire); - EasyMock.replay(parent); - JavaAtomicComponent component = (JavaAtomicComponent) builder.build(parent, definition, null); - Foo foo = (Foo) component.createInstance(); - assertEquals("result", foo.resource); - EasyMock.verify(parent); - } - - private static class Foo { - - protected String resource; - - public Foo() { - } - - } -} - - diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaComponentTypeLoaderTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaComponentTypeLoaderTestCase.java deleted file mode 100644 index ef74c86d2e..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaComponentTypeLoaderTestCase.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.implementation.java; - -import java.net.URL; - -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.deployer.DeploymentContext; -import org.apache.tuscany.spi.implementation.java.IntrospectionRegistry; -import org.apache.tuscany.spi.implementation.java.PojoComponentType; -import org.apache.tuscany.spi.loader.LoaderRegistry; - -import junit.framework.TestCase; -import org.easymock.EasyMock; -import org.easymock.IAnswer; - -/** - * @version $Rev$ $Date$ - */ -public class JavaComponentTypeLoaderTestCase extends TestCase { - - @SuppressWarnings("unchecked") - public void testPojoComponentTypeCreatedForIntrospection() throws Exception { - IntrospectionRegistry registry = EasyMock.createMock(IntrospectionRegistry.class); - registry.introspect( - (CompositeComponent) EasyMock.isNull(), - (Class) EasyMock.isNull(), - EasyMock.isA(PojoComponentType.class), - (DeploymentContext) EasyMock.isNull()); - EasyMock.expectLastCall().andStubAnswer(new IAnswer() { - public Object answer() throws Throwable { - return EasyMock.getCurrentArguments()[2]; - } - }); - EasyMock.replay(registry); - JavaComponentTypeLoader loader = new JavaComponentTypeLoader(null, registry); - loader.loadByIntrospection(null, new JavaImplementation(), null); - EasyMock.verify(registry); - } - - @SuppressWarnings("unchecked") - public void testPojoComponentTypeCreatedForSideFileLoadAndReturned() throws Exception { - LoaderRegistry registry = EasyMock.createMock(LoaderRegistry.class); - registry.load( - (CompositeComponent) EasyMock.isNull(), - EasyMock.isA(PojoComponentType.class), - (URL) EasyMock.isNull(), - EasyMock.eq(PojoComponentType.class), - (DeploymentContext) EasyMock.isNull()); - EasyMock.expectLastCall().andStubAnswer(new IAnswer() { - public Object answer() throws Throwable { - return EasyMock.getCurrentArguments()[1]; - } - }); - EasyMock.replay(registry); - JavaComponentTypeLoader loader = new JavaComponentTypeLoader(registry, null); - assertEquals(PojoComponentType.class, loader.loadFromSidefile(null, null, null).getClass()); - EasyMock.verify(registry); - } - - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaReferenceWireTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaReferenceWireTestCase.java deleted file mode 100644 index 0fe6df8b6b..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaReferenceWireTestCase.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.implementation.java; - -import java.lang.reflect.Constructor; -import java.util.HashMap; -import java.util.Map; - -import org.apache.tuscany.spi.component.AtomicComponent; -import org.apache.tuscany.spi.component.ScopeContainer; -import org.apache.tuscany.spi.component.TargetException; -import org.apache.tuscany.spi.model.Operation; -import org.apache.tuscany.spi.model.Scope; -import org.apache.tuscany.spi.wire.OutboundInvocationChain; -import org.apache.tuscany.spi.wire.OutboundWire; -import org.apache.tuscany.spi.wire.WireService; - -import junit.framework.TestCase; -import org.apache.tuscany.core.implementation.PojoConfiguration; -import org.apache.tuscany.core.injection.PojoObjectFactory; -import org.easymock.EasyMock; -import org.easymock.IAnswer; - -/** - * Validates wiring from a Java atomic context - * - * @version $$Rev$$ $$Date$$ - */ -public class JavaReferenceWireTestCase extends TestCase { - - @SuppressWarnings({"unchecked"}) - public void testReferenceSet() throws Exception { - ScopeContainer scope = createMock(); - scope.start(); - final Target target = new TargetImpl(); - PojoConfiguration configuration = new PojoConfiguration(); - configuration.addReferenceSite("target", SourceImpl.class.getMethod("setTarget", Target.class)); - Constructor ctr = SourceImpl.class.getConstructor(); - configuration.setInstanceFactory(new PojoObjectFactory(ctr)); - OutboundWire wire = EasyMock.createMock(OutboundWire.class); - wire.getInvocationChains(); - EasyMock.expectLastCall().andReturn(new HashMap, OutboundInvocationChain>()).atLeastOnce(); - EasyMock.expect(wire.getReferenceName()).andReturn("target").atLeastOnce(); - EasyMock.expect(wire.isOptimizable()).andReturn(false); - EasyMock.replay(wire); - WireService service = EasyMock.createMock(WireService.class); - EasyMock.expect(service.createProxy(EasyMock.eq(Target.class), EasyMock.eq(wire), EasyMock.isA(Map.class))) - .andAnswer(new IAnswer() { - public Target answer() throws Throwable { - OutboundWire wire = (OutboundWire) EasyMock.getCurrentArguments()[1]; - wire.getInvocationChains(); - return target; - } - - }).atLeastOnce(); - EasyMock.replay(service); - configuration.setWireService(service); - configuration.setName("source"); - JavaAtomicComponent component = new JavaAtomicComponent(configuration); - component.setScopeContainer(scope); - component.addOutboundWire(wire); - component.start(); - Source source = (Source) component.getTargetInstance(); - assertSame(target, source.getTarget()); - scope.stop(); - EasyMock.verify(wire); - EasyMock.verify(scope); - EasyMock.verify(service); - } - - private ScopeContainer createMock() throws TargetException { - ScopeContainer scope = EasyMock.createMock(ScopeContainer.class); - scope.start(); - scope.stop(); - scope.register(EasyMock.isA(AtomicComponent.class)); - EasyMock.expectLastCall().atLeastOnce(); - EasyMock.expect(scope.getScope()).andReturn(Scope.COMPOSITE).atLeastOnce(); - scope.getInstance(EasyMock.isA(AtomicComponent.class)); - EasyMock.expectLastCall().andAnswer(new IAnswer() { - private Map cache = new HashMap(); - - public Object answer() throws Throwable { - AtomicComponent component = (AtomicComponent) EasyMock.getCurrentArguments()[0]; - Object instance = cache.get(component); - if (instance == null) { - instance = component.createInstance(); - cache.put(component, instance); - } - return instance; - } - }).anyTimes(); - EasyMock.replay(scope); - return scope; - } - - private interface Source { - Target getTarget(); - } - - private static class SourceImpl implements Source { - private Target target; - - public SourceImpl() { - } - - public Target getTarget() { - return target; - } - - public void setTarget(Target target) { - this.target = target; - } - } - - private interface Target { - - String getString(); - - void setString(String val); - } - - private static class TargetImpl implements Target { - private String string; - - public TargetImpl() { - } - - public String getString() { - return string; - } - - public void setString(String string) { - this.string = string; - } - - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaTargetInvokerBasicInvocationTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaTargetInvokerBasicInvocationTestCase.java deleted file mode 100644 index 30f7948673..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaTargetInvokerBasicInvocationTestCase.java +++ /dev/null @@ -1,188 +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.java; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - -import org.apache.tuscany.spi.component.WorkContext; -import org.apache.tuscany.spi.extension.ExecutionMonitor; -import org.apache.tuscany.spi.wire.InboundWire; -import static org.apache.tuscany.spi.wire.TargetInvoker.NONE; -import org.apache.tuscany.spi.model.Scope; - -import junit.framework.TestCase; -import org.easymock.classextension.EasyMock; - -public class JavaTargetInvokerBasicInvocationTestCase extends TestCase { - private Method echoMethod; - private Method arrayMethod; - private Method nullParamMethod; - private Method primitiveMethod; - private Method checkedMethod; - private Method runtimeMethod; - private InboundWire wire; - private WorkContext context; - private ExecutionMonitor monitor; - - public JavaTargetInvokerBasicInvocationTestCase(String arg0) { - super(arg0); - } - - public void setUp() throws Exception { - echoMethod = TestBean.class.getDeclaredMethod("echo", String.class); - arrayMethod = TestBean.class.getDeclaredMethod("arrayEcho", String[].class); - nullParamMethod = TestBean.class.getDeclaredMethod("nullParam", (Class[]) null); - primitiveMethod = TestBean.class.getDeclaredMethod("primitiveEcho", Integer.TYPE); - checkedMethod = TestBean.class.getDeclaredMethod("checkedException", (Class[]) null); - runtimeMethod = TestBean.class.getDeclaredMethod("runtimeException", (Class[]) null); - wire = EasyMock.createNiceMock(InboundWire.class); - context = EasyMock.createNiceMock(WorkContext.class); - monitor = EasyMock.createNiceMock(ExecutionMonitor.class); - assertNotNull(echoMethod); - assertNotNull(checkedMethod); - assertNotNull(runtimeMethod); - } - - public void testObjectInvoke() throws Throwable { - TestBean bean = new TestBean(); - JavaAtomicComponent component = EasyMock.createMock(JavaAtomicComponent.class); - EasyMock.expect(component.getTargetInstance()).andReturn(bean); - EasyMock.expect(component.getScope()).andReturn(Scope.COMPOSITE); - EasyMock.replay(component); - JavaTargetInvoker invoker = new JavaTargetInvoker(echoMethod, component, wire, context, monitor); - Object ret = invoker.invokeTarget("foo", NONE); - assertEquals("foo", ret); - } - - public void testArrayInvoke() throws Throwable { - TestBean bean = new TestBean(); - JavaAtomicComponent component = EasyMock.createMock(JavaAtomicComponent.class); - EasyMock.expect(component.getTargetInstance()).andReturn(bean); - EasyMock.expect(component.getScope()).andReturn(Scope.COMPOSITE); - EasyMock.replay(component); - JavaTargetInvoker invoker = new JavaTargetInvoker(arrayMethod, component, wire, context, monitor); - - String[] args = new String[]{"foo", "bar"}; - Object ret = invoker.invokeTarget(new Object[]{args}, NONE); - String[] retA = (String[]) ret; - assertNotNull(retA); - assertEquals(2, retA.length); - assertEquals("foo", retA[0]); - assertEquals("bar", retA[1]); - } - - public void testNullInvoke() throws Throwable { - TestBean bean = new TestBean(); - JavaAtomicComponent component = EasyMock.createMock(JavaAtomicComponent.class); - EasyMock.expect(component.getTargetInstance()).andReturn(bean); - EasyMock.expect(component.getScope()).andReturn(Scope.COMPOSITE); - EasyMock.replay(component); - JavaTargetInvoker invoker = new JavaTargetInvoker(nullParamMethod, component, wire, context, monitor); - Object ret = invoker.invokeTarget(null, NONE); - String retS = (String) ret; - assertEquals("foo", retS); - } - - public void testPrimitiveInvoke() throws Throwable { - TestBean bean = new TestBean(); - JavaAtomicComponent component = EasyMock.createMock(JavaAtomicComponent.class); - EasyMock.expect(component.getTargetInstance()).andReturn(bean); - EasyMock.expect(component.getScope()).andReturn(Scope.COMPOSITE); - EasyMock.replay(component); - JavaTargetInvoker invoker = new JavaTargetInvoker(primitiveMethod, component, wire, context, monitor); - Object ret = invoker.invokeTarget(new Integer[]{1}, NONE); - Integer retI = (Integer) ret; - assertEquals(1, retI.intValue()); - } - - public void testInvokeCheckedException() throws Throwable { - TestBean bean = new TestBean(); - JavaAtomicComponent component = EasyMock.createMock(JavaAtomicComponent.class); - EasyMock.expect(component.getTargetInstance()).andReturn(bean); - EasyMock.expect(component.getScope()).andReturn(Scope.COMPOSITE); - EasyMock.replay(component); - JavaTargetInvoker invoker = new JavaTargetInvoker(checkedMethod, component, wire, context, monitor); - try { - invoker.invokeTarget(null, NONE); - } catch (InvocationTargetException e) { - if (e.getCause() != null && TestException.class.equals(e.getCause().getClass())) { - return; - } - } catch (Throwable e) { - //ok - } - fail(TestException.class.getName() + " should have been thrown"); - } - - public void testInvokeRuntimeException() throws Throwable { - TestBean bean = new TestBean(); - JavaAtomicComponent component = EasyMock.createMock(JavaAtomicComponent.class); - EasyMock.expect(component.getTargetInstance()).andReturn(bean); - EasyMock.expect(component.getScope()).andReturn(Scope.COMPOSITE); - EasyMock.replay(component); - JavaTargetInvoker invoker = new JavaTargetInvoker(runtimeMethod, component, wire, context, monitor); - try { - invoker.invokeTarget(null, NONE); - } catch (InvocationTargetException e) { - if (e.getCause() != null && e.getCause() instanceof TestRuntimeException) { - return; - } - } - fail(TestException.class.getName() + " should have been thrown"); - } - - private class TestBean { - - public String echo(String msg) throws Exception { - assertEquals("foo", msg); - return msg; - } - - public String[] arrayEcho(String[] msg) throws Exception { - assertNotNull(msg); - assertEquals(2, msg.length); - assertEquals("foo", msg[0]); - assertEquals("bar", msg[1]); - return msg; - } - - public String nullParam() throws Exception { - return "foo"; - } - - public int primitiveEcho(int i) throws Exception { - return i; - } - - public void checkedException() throws TestException { - throw new TestException(); - } - - public void runtimeException() throws TestRuntimeException { - throw new TestRuntimeException(); - } - } - - public class TestException extends Exception { - } - - public class TestRuntimeException extends RuntimeException { - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaTargetInvokerMediationTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaTargetInvokerMediationTestCase.java deleted file mode 100644 index 936673d0a6..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaTargetInvokerMediationTestCase.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.implementation.java; - -import java.lang.reflect.Method; - -import static org.apache.tuscany.spi.wire.TargetInvoker.NONE; -import org.apache.tuscany.spi.model.Scope; - -import junit.framework.TestCase; -import org.easymock.classextension.EasyMock; - -/** - * Tests invoking on a different interface from the one actually implemented by the target - * - * @version $Rev$ $Date$ - */ -public class JavaTargetInvokerMediationTestCase extends TestCase { - - private Method hello; - - public void setUp() throws Exception { - hello = Hello.class.getMethod("hello", String.class); - } - - public void testMediation() throws Exception { - Target target = EasyMock.createMock(Target.class); - EasyMock.expect(target.hello("foo")).andReturn("foo"); - EasyMock.replay(target); - JavaAtomicComponent component = EasyMock.createMock(JavaAtomicComponent.class); - EasyMock.expect(component.getTargetInstance()).andReturn(target); - EasyMock.expect(component.getScope()).andReturn(Scope.COMPOSITE); - EasyMock.replay(component); - JavaTargetInvoker invoker = new JavaTargetInvoker(hello, component, null, null, null); - assertEquals("foo", invoker.invokeTarget("foo", NONE)); - } - - public interface Hello { - String hello(String message) throws Exception; - } - - private interface Target { - String hello(String message); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaTargetInvokerNonBlockingInvocationTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaTargetInvokerNonBlockingInvocationTestCase.java deleted file mode 100644 index 25466a01ff..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaTargetInvokerNonBlockingInvocationTestCase.java +++ /dev/null @@ -1,229 +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.java; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - -import org.apache.tuscany.spi.component.WorkContext; -import org.apache.tuscany.spi.extension.ExecutionMonitor; -import org.apache.tuscany.spi.model.Scope; -import org.apache.tuscany.spi.wire.InboundWire; -import org.apache.tuscany.spi.wire.Message; -import org.apache.tuscany.spi.wire.MessageImpl; -import static org.apache.tuscany.spi.wire.TargetInvoker.NONE; - -import junit.framework.TestCase; -import org.easymock.classextension.EasyMock; - -/** - * Verifies dispatching invocations to a Java implementation instance - * - * @version $Rev$ $Date$ - */ -public class JavaTargetInvokerNonBlockingInvocationTestCase extends TestCase { - - private Method echoMethod; - private Method arrayMethod; - private Method nullParamMethod; - private Method primitiveMethod; - private Method checkedMethod; - private Method runtimeMethod; - private InboundWire wire; - private WorkContext context; - private ExecutionMonitor monitor; - - public JavaTargetInvokerNonBlockingInvocationTestCase(String arg0) { - super(arg0); - } - - public void testInvoke() throws Exception { - AsyncTarget target = EasyMock.createMock(AsyncTarget.class); - target.invoke(); - EasyMock.expectLastCall().once(); - EasyMock.replay(target); - JavaAtomicComponent component = EasyMock.createMock(JavaAtomicComponent.class); - EasyMock.expect(component.getTargetInstance()).andReturn(target); - EasyMock.expect(component.getScope()).andReturn(Scope.COMPOSITE); - EasyMock.replay(component); - ExecutionMonitor monitor = EasyMock.createMock(ExecutionMonitor.class); - EasyMock.replay(monitor); - - Message msg = new MessageImpl(); - Object id = new Object(); - msg.setMessageId(id); - - WorkContext context = EasyMock.createMock(WorkContext.class); - context.setCurrentCorrelationId(id); - EasyMock.replay(context); - Method method = AsyncTarget.class.getMethod("invoke"); - method.setAccessible(true); - InboundWire wire = EasyMock.createMock(InboundWire.class); - JavaTargetInvoker invoker = new JavaTargetInvoker(method, component, wire, context, monitor); - invoker.invoke(msg); - EasyMock.verify(target); - EasyMock.verify(component); - } - - public void setUp() throws Exception { - echoMethod = TestBean.class.getDeclaredMethod("echo", String.class); - arrayMethod = TestBean.class.getDeclaredMethod("arrayEcho", String[].class); - nullParamMethod = TestBean.class.getDeclaredMethod("nullParam", (Class[]) null); - primitiveMethod = TestBean.class.getDeclaredMethod("primitiveEcho", Integer.TYPE); - checkedMethod = TestBean.class.getDeclaredMethod("checkedException", (Class[]) null); - runtimeMethod = TestBean.class.getDeclaredMethod("runtimeException", (Class[]) null); - wire = EasyMock.createNiceMock(InboundWire.class); - context = EasyMock.createNiceMock(WorkContext.class); - monitor = EasyMock.createNiceMock(ExecutionMonitor.class); - assertNotNull(echoMethod); - assertNotNull(checkedMethod); - assertNotNull(runtimeMethod); - } - - public void testObjectInvoke() throws Throwable { - TestBean bean = new TestBean(); - JavaAtomicComponent component = EasyMock.createMock(JavaAtomicComponent.class); - EasyMock.expect(component.getTargetInstance()).andReturn(bean); - EasyMock.expect(component.getScope()).andReturn(Scope.COMPOSITE); - EasyMock.replay(component); - JavaTargetInvoker invoker = new JavaTargetInvoker(echoMethod, component, wire, context, monitor); - Object ret = invoker.invokeTarget("foo", NONE); - assertEquals("foo", ret); - } - - public void testArrayInvoke() throws Throwable { - TestBean bean = new TestBean(); - JavaAtomicComponent component = EasyMock.createMock(JavaAtomicComponent.class); - EasyMock.expect(component.getTargetInstance()).andReturn(bean); - EasyMock.expect(component.getScope()).andReturn(Scope.COMPOSITE); - EasyMock.replay(component); - JavaTargetInvoker invoker = new JavaTargetInvoker(arrayMethod, component, wire, context, monitor); - - String[] args = new String[]{"foo", "bar"}; - Object ret = invoker.invokeTarget(new Object[]{args}, NONE); - String[] retA = (String[]) ret; - assertNotNull(retA); - assertEquals(2, retA.length); - assertEquals("foo", retA[0]); - assertEquals("bar", retA[1]); - } - - public void testNullInvoke() throws Throwable { - TestBean bean = new TestBean(); - JavaAtomicComponent component = EasyMock.createMock(JavaAtomicComponent.class); - EasyMock.expect(component.getTargetInstance()).andReturn(bean); - EasyMock.expect(component.getScope()).andReturn(Scope.COMPOSITE); - EasyMock.replay(component); - JavaTargetInvoker invoker = new JavaTargetInvoker(nullParamMethod, component, wire, context, monitor); - Object ret = invoker.invokeTarget(null, NONE); - String retS = (String) ret; - assertEquals("foo", retS); - } - - public void testPrimitiveInvoke() throws Throwable { - TestBean bean = new TestBean(); - JavaAtomicComponent component = EasyMock.createMock(JavaAtomicComponent.class); - EasyMock.expect(component.getTargetInstance()).andReturn(bean); - EasyMock.expect(component.getScope()).andReturn(Scope.COMPOSITE); - EasyMock.replay(component); - JavaTargetInvoker invoker = new JavaTargetInvoker(primitiveMethod, component, wire, context, monitor); - Object ret = invoker.invokeTarget(new Integer[]{1}, NONE); - Integer retI = (Integer) ret; - assertEquals(1, retI.intValue()); - } - - public void testInvokeCheckedException() throws Throwable { - TestBean bean = new TestBean(); - JavaAtomicComponent component = EasyMock.createMock(JavaAtomicComponent.class); - EasyMock.expect(component.getTargetInstance()).andReturn(bean); - EasyMock.expect(component.getScope()).andReturn(Scope.COMPOSITE); - EasyMock.replay(component); - JavaTargetInvoker invoker = new JavaTargetInvoker(checkedMethod, component, wire, context, monitor); - try { - invoker.invokeTarget(null, NONE); - } catch (InvocationTargetException e) { - if (e.getCause() != null && TestException.class.equals(e.getCause().getClass())) { - return; - } - } catch (Throwable e) { - //ok - } - fail(TestException.class.getName() + " should have been thrown"); - } - - public void testInvokeRuntimeException() throws Throwable { - TestBean bean = new TestBean(); - JavaAtomicComponent component = EasyMock.createMock(JavaAtomicComponent.class); - EasyMock.expect(component.getTargetInstance()).andReturn(bean); - EasyMock.expect(component.getScope()).andReturn(Scope.COMPOSITE); - EasyMock.replay(component); - JavaTargetInvoker invoker = new JavaTargetInvoker(runtimeMethod, component, wire, context, monitor); - try { - invoker.invokeTarget(null, NONE); - } catch (InvocationTargetException e) { - if (e.getCause() != null && e.getCause() instanceof TestRuntimeException) { - return; - } - } - fail(TestException.class.getName() + " should have been thrown"); - } - - private class TestBean { - - public String echo(String msg) throws Exception { - assertEquals("foo", msg); - return msg; - } - - public String[] arrayEcho(String[] msg) throws Exception { - assertNotNull(msg); - assertEquals(2, msg.length); - assertEquals("foo", msg[0]); - assertEquals("bar", msg[1]); - return msg; - } - - public String nullParam() throws Exception { - return "foo"; - } - - public int primitiveEcho(int i) throws Exception { - return i; - } - - public void checkedException() throws TestException { - throw new TestException(); - } - - public void runtimeException() throws TestRuntimeException { - throw new TestRuntimeException(); - } - } - - public class TestException extends Exception { - } - - public class TestRuntimeException extends RuntimeException { - } - - public interface AsyncTarget { - void invoke(); - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaTargetInvokerSequenceTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaTargetInvokerSequenceTestCase.java deleted file mode 100644 index acb2ed5e14..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaTargetInvokerSequenceTestCase.java +++ /dev/null @@ -1,117 +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.java; - -import org.apache.tuscany.spi.model.Scope; -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.easymock.classextension.EasyMock; - -/** - * @version $Rev$ $Date$ - */ -public class JavaTargetInvokerSequenceTestCase extends TestCase { - - /** - * Verifies an invocation marked as non-conversational has an existing or new instance returned - */ - public void testNoSequence() throws Exception { - Foo foo = EasyMock.createMock(Foo.class); - foo.invoke(); - EasyMock.replay(foo); - JavaAtomicComponent component = EasyMock.createMock(JavaAtomicComponent.class); - EasyMock.expect(component.getTargetInstance()).andReturn(foo); - EasyMock.expect(component.getScope()).andReturn(Scope.CONVERSATION); - EasyMock.replay(component); - JavaTargetInvoker invoker = new JavaTargetInvoker(Foo.class.getMethod("invoke"), component, null, null, null); - Message msg = new MessageImpl(); - msg.setConversationSequence(TargetInvoker.NONE); - invoker.invoke(msg); - EasyMock.verify(foo); - EasyMock.verify(component); - } - - /** - * Verifies that an invocation marked as starting a conversation has a new instance returned - */ - public void testStartSequence() throws Exception { - Foo foo = EasyMock.createMock(Foo.class); - foo.invoke(); - EasyMock.replay(foo); - JavaAtomicComponent component = EasyMock.createMock(JavaAtomicComponent.class); - EasyMock.expect(component.getTargetInstance()).andReturn(foo); - EasyMock.expect(component.getScope()).andReturn(Scope.CONVERSATION); - EasyMock.replay(component); - JavaTargetInvoker invoker = new JavaTargetInvoker(Foo.class.getMethod("invoke"), component, null, null, null); - Message msg = new MessageImpl(); - msg.setConversationSequence(TargetInvoker.START); - invoker.invoke(msg); - EasyMock.verify(foo); - EasyMock.verify(component); - } - - /** - * Verifies that an invocation marked as continuing a conversation has an associated instance returned - */ - public void testContinueSequence() throws Exception { - Foo foo = EasyMock.createMock(Foo.class); - foo.invoke(); - EasyMock.replay(foo); - JavaAtomicComponent component = EasyMock.createMock(JavaAtomicComponent.class); - EasyMock.expect(component.getAssociatedTargetInstance()).andReturn(foo); - EasyMock.expect(component.getScope()).andReturn(Scope.CONVERSATION); - EasyMock.replay(component); - JavaTargetInvoker invoker = new JavaTargetInvoker(Foo.class.getMethod("invoke"), component, null, null, null); - Message msg = new MessageImpl(); - msg.setConversationSequence(TargetInvoker.CONTINUE); - invoker.invoke(msg); - EasyMock.verify(foo); - EasyMock.verify(component); - } - - /** - * Verifies that an invocation marked as ending a conversation has an associated instance returned and it is removed - * following the dispatch to the instance - */ - public void testEndSequence() throws Exception { - Foo foo = EasyMock.createMock(Foo.class); - foo.invoke(); - EasyMock.replay(foo); - JavaAtomicComponent component = EasyMock.createMock(JavaAtomicComponent.class); - EasyMock.expect(component.getAssociatedTargetInstance()).andReturn(foo); - EasyMock.expect(component.getScope()).andReturn(Scope.CONVERSATION); - component.removeInstance(); - component.destroy(EasyMock.eq(foo)); - EasyMock.replay(component); - JavaTargetInvoker invoker = new JavaTargetInvoker(Foo.class.getMethod("invoke"), component, null, null, null); - Message msg = new MessageImpl(); - msg.setConversationSequence(TargetInvoker.END); - invoker.invoke(msg); - EasyMock.verify(foo); - EasyMock.verify(component); - } - - - private interface Foo { - void invoke(); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaTargetInvokerStatelessDestroyTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaTargetInvokerStatelessDestroyTestCase.java deleted file mode 100644 index c87649f99e..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaTargetInvokerStatelessDestroyTestCase.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.implementation.java; - -import java.lang.reflect.Method; - -import org.apache.tuscany.spi.model.Scope; - -import junit.framework.TestCase; -import org.easymock.classextension.EasyMock; - -public class JavaTargetInvokerStatelessDestroyTestCase extends TestCase { - - public JavaTargetInvokerStatelessDestroyTestCase(String arg0) { - super(arg0); - } - - public void testDestroy() throws Exception { - Method echoMethod = Echo.class.getDeclaredMethod("echo", String.class); - JavaAtomicComponent component = EasyMock.createMock(JavaAtomicComponent.class); - EasyMock.expect(component.getTargetInstance()).andReturn(new JavaTargetInvokerStatelessDestroyTestCase.Echo()); - EasyMock.expect(component.getScope()).andReturn(Scope.STATELESS); - component.destroy(EasyMock.isA(Echo.class)); - EasyMock.replay(component); - JavaTargetInvoker invoker = new JavaTargetInvoker(echoMethod, component, null, null, null); - invoker.setCacheable(false); - assertEquals("foo", invoker.invokeTarget("foo", JavaTargetInvoker.NONE)); - EasyMock.verify(component); - } - - public static class Echo { - public String echo(String message) throws Exception { - return message; - } - - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaTargetInvokerTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaTargetInvokerTestCase.java deleted file mode 100644 index 043af2d891..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaTargetInvokerTestCase.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.implementation.java; - -import java.lang.reflect.Method; - -import org.apache.tuscany.spi.model.Scope; - -import junit.framework.TestCase; -import org.easymock.classextension.EasyMock; - -public class JavaTargetInvokerTestCase extends TestCase { - - public JavaTargetInvokerTestCase(String arg0) { - super(arg0); - } - - public void testInvoke() throws Exception { - Method echoMethod = Echo.class.getDeclaredMethod("echo", String.class); - JavaAtomicComponent component = EasyMock.createMock(JavaAtomicComponent.class); - EasyMock.expect(component.getTargetInstance()).andReturn(new Echo()); - EasyMock.expect(component.getScope()).andReturn(Scope.COMPOSITE); - EasyMock.replay(component); - JavaTargetInvoker invoker = new JavaTargetInvoker(echoMethod, component, null, null, null); - invoker.setCacheable(false); - assertEquals("foo", invoker.invokeTarget("foo", JavaTargetInvoker.NONE)); - EasyMock.verify(component); - } - - public static class Echo { - public String echo(String message) throws Exception { - return message; - } - - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/MultiplicityTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/MultiplicityTestCase.java deleted file mode 100644 index ba478c9634..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/MultiplicityTestCase.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.implementation.java; - -import junit.framework.TestCase; - - -/** - * Tests wires that are configured with a multiplicity - * - * @version $Rev$ $Date$ - */ -public class MultiplicityTestCase extends TestCase { - - public void testMultiplicity() throws Exception { - // TODO implement - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/ResourceInjectionTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/ResourceInjectionTestCase.java deleted file mode 100644 index f4cc56f158..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/ResourceInjectionTestCase.java +++ /dev/null @@ -1,111 +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.java; - -import java.lang.reflect.Constructor; -import java.lang.reflect.Field; -import java.util.ArrayList; -import java.util.List; - -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.component.ScopeContainer; -import org.apache.tuscany.spi.wire.InboundWire; - -import junit.framework.TestCase; -import org.apache.tuscany.core.implementation.PojoConfiguration; -import org.apache.tuscany.core.injection.PojoObjectFactory; -import org.apache.tuscany.core.injection.ResourceObjectFactory; -import org.easymock.EasyMock; - -/** - * @version $Rev$ $Date$ - */ -public class ResourceInjectionTestCase extends TestCase { - - public void testResourceMemberInjection() throws Exception { - ScopeContainer containter = EasyMock.createNiceMock(ScopeContainer.class); - Constructor ctor = Foo.class.getConstructor(); - Field field = Foo.class.getDeclaredField("resource"); - PojoConfiguration configuration = new PojoConfiguration(); - configuration.setName("component"); - configuration.setInstanceFactory(new PojoObjectFactory(ctor)); - configuration.addResourceSite("bar", field); - JavaAtomicComponent component = new JavaAtomicComponent(configuration); - component.setScopeContainer(containter); - - InboundWire wire = EasyMock.createMock(InboundWire.class); - EasyMock.expect(wire.getTargetService()).andReturn("result"); - EasyMock.replay(wire); - - CompositeComponent parent = EasyMock.createMock(CompositeComponent.class); - EasyMock.expect(parent.resolveSystemAutowire(EasyMock.eq(String.class))).andReturn(wire); - EasyMock.replay(parent); - ResourceObjectFactory factory = new ResourceObjectFactory(String.class, false, parent, null); - component.addResourceFactory("bar", factory); - - Foo foo = (Foo) component.createInstance(); - assertEquals("result", foo.resource); - EasyMock.verify(parent); - } - - - public void testResourceConstructorInjection() throws Exception { - ScopeContainer containter = EasyMock.createNiceMock(ScopeContainer.class); - Constructor ctor = FooConstructor.class.getConstructor(String.class); - PojoConfiguration configuration = new PojoConfiguration(); - configuration.setName("component"); - configuration.setInstanceFactory(new PojoObjectFactory(ctor)); - List ctorNames = new ArrayList(); - ctorNames.add("bar"); - configuration.setConstructorParamNames(ctorNames); - JavaAtomicComponent component = new JavaAtomicComponent(configuration); - component.setScopeContainer(containter); - - InboundWire wire = EasyMock.createMock(InboundWire.class); - EasyMock.expect(wire.getTargetService()).andReturn("result"); - EasyMock.replay(wire); - CompositeComponent parent = EasyMock.createMock(CompositeComponent.class); - - EasyMock.expect(parent.resolveSystemAutowire(EasyMock.eq(String.class))).andReturn(wire); - EasyMock.replay(parent); - ResourceObjectFactory factory = new ResourceObjectFactory(String.class, false, parent, null); - component.addResourceFactory("bar", factory); - - FooConstructor foo = (FooConstructor) component.createInstance(); - assertEquals("result", foo.resource); - EasyMock.verify(parent); - } - - public static class Foo { - protected String resource; - - public Foo() { - } - - } - - public static class FooConstructor { - protected String resource; - - public FooConstructor(String resource) { - this.resource = resource; - } - - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/integration/CallbackInvocationTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/integration/CallbackInvocationTestCase.java deleted file mode 100644 index 92b5429ebd..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/integration/CallbackInvocationTestCase.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.implementation.java.integration; - -import java.lang.reflect.Method; -import java.net.URI; -import java.net.URISyntaxException; - -import org.osoa.sca.NoRegisteredCallbackException; -import org.osoa.sca.annotations.Callback; - -import org.apache.tuscany.spi.builder.Connector; -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.component.ScopeContainer; -import org.apache.tuscany.spi.component.WorkContext; -import org.apache.tuscany.spi.deployer.DeploymentContext; -import org.apache.tuscany.spi.idl.InvalidServiceContractException; -import org.apache.tuscany.spi.idl.java.JavaInterfaceProcessorRegistry; -import org.apache.tuscany.spi.implementation.java.ConstructorDefinition; -import org.apache.tuscany.spi.implementation.java.JavaMappedProperty; -import org.apache.tuscany.spi.implementation.java.JavaMappedReference; -import org.apache.tuscany.spi.implementation.java.JavaMappedService; -import org.apache.tuscany.spi.implementation.java.PojoComponentType; -import org.apache.tuscany.spi.model.ComponentDefinition; -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.services.work.WorkScheduler; -import org.apache.tuscany.spi.wire.WireService; - -import junit.framework.TestCase; -import org.apache.tuscany.core.builder.ConnectorImpl; -import org.apache.tuscany.core.component.WorkContextImpl; -import org.apache.tuscany.core.component.scope.CompositeScopeContainer; -import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl; -import org.apache.tuscany.core.implementation.java.JavaAtomicComponent; -import org.apache.tuscany.core.implementation.java.JavaComponentBuilder; -import org.apache.tuscany.core.implementation.java.JavaImplementation; -import org.apache.tuscany.core.wire.jdk.JDKWireService; -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 org.easymock.IAnswer; - -/** - * Verifies callback integration scenarios with Java components. - * - * @version $Rev$ $Date$ - */ -public class CallbackInvocationTestCase extends TestCase { - private ScopeContainer container; - private DeploymentContext context; - private JavaComponentBuilder builder; - private WireService wireService; - private WorkScheduler scheduler; - private WorkContext workContext; - - /** - * Verifies callback wires are built and callback invocations are handled properly - */ - public void testComponentToComponentCallback() throws Exception { - ComponentDefinition targetDefinition = createTarget(); - JavaAtomicComponent fooComponent = - (JavaAtomicComponent) builder.build(null, targetDefinition, context); - fooComponent.setScopeContainer(container); - wireService.createWires(fooComponent, targetDefinition); - container.register(fooComponent); - - CompositeComponent parent = createMock(CompositeComponent.class); - parent.getChild(isA(String.class)); - expectLastCall().andReturn(fooComponent).anyTimes(); - replay(parent); - - ComponentDefinition sourceDefinition = createSource("fooClient"); - JavaAtomicComponent clientComponent = - (JavaAtomicComponent) builder.build(parent, sourceDefinition, context); - clientComponent.setScopeContainer(container); - wireService.createWires(clientComponent, sourceDefinition); - container.register(clientComponent); - - Connector connector = new ConnectorImpl(new JDKWireService(), null, scheduler, workContext); - - connector.connect(clientComponent); - FooClient client = (FooClient) clientComponent.getTargetInstance(); - client.invoke(); - assertTrue(client.invoked); - client.invokeMultiCallback(); - assertTrue(client.count == 2); - } - - /** - * Verifies exception is thrown when callback is not implemented - */ - public void testCallbackNotRegistered() throws Exception { - ComponentDefinition targetDefinition = createTarget(); - JavaAtomicComponent fooComponent = - (JavaAtomicComponent) builder.build(null, targetDefinition, context); - fooComponent.setScopeContainer(container); - wireService.createWires(fooComponent, targetDefinition); - container.register(fooComponent); - - CompositeComponent parent = createMock(CompositeComponent.class); - parent.getChild(isA(String.class)); - expectLastCall().andReturn(fooComponent).anyTimes(); - replay(parent); - - ComponentDefinition sourceDefinition = createPlainSource("fooPlainClient"); - JavaAtomicComponent clientComponent = - (JavaAtomicComponent) builder.build(parent, sourceDefinition, context); - clientComponent.setScopeContainer(container); - wireService.createWires(clientComponent, sourceDefinition); - container.register(clientComponent); - - Connector connector = new ConnectorImpl(new JDKWireService(), null, scheduler, workContext); - - connector.connect(clientComponent); - FooPlainClient client = (FooPlainClient) clientComponent.getTargetInstance(); - try { - client.invoke(); - fail(); - } catch (NoRegisteredCallbackException e) { - // expected - } - } - - /** - * Verifies a callback in response to an invocation from two different client components is routed back to the - * appropriate client. - */ - public void testTwoSourceComponentToComponentCallback() throws Exception { - ComponentDefinition targetDefinition = createTarget(); - JavaAtomicComponent fooComponent = - (JavaAtomicComponent) builder.build(null, targetDefinition, context); - fooComponent.setScopeContainer(container); - wireService.createWires(fooComponent, targetDefinition); - container.register(fooComponent); - - CompositeComponent parent = createMock(CompositeComponent.class); - parent.getChild(isA(String.class)); - expectLastCall().andReturn(fooComponent).anyTimes(); - replay(parent); - - ComponentDefinition sourceDefinition1 = createSource("fooCleint1"); - ComponentDefinition sourceDefinition2 = createSource("fooCleint2"); - JavaAtomicComponent clientComponent1 = - (JavaAtomicComponent) builder.build(parent, sourceDefinition1, context); - clientComponent1.setScopeContainer(container); - wireService.createWires(clientComponent1, sourceDefinition1); - container.register(clientComponent1); - JavaAtomicComponent clientComponent2 = - (JavaAtomicComponent) builder.build(parent, sourceDefinition2, context); - clientComponent2.setScopeContainer(container); - wireService.createWires(clientComponent2, sourceDefinition2); - container.register(clientComponent2); - - Connector connector = new ConnectorImpl(new JDKWireService(), null, scheduler, workContext); - connector.connect(clientComponent1); - connector.connect(clientComponent2); - FooClient client1 = (FooClient) clientComponent1.getTargetInstance(); - client1.invoke(); - assertTrue(client1.invoked); - FooClient client2 = (FooClient) clientComponent2.getTargetInstance(); - client2.invoke(); - assertTrue(client2.invoked); - } - - - private ComponentDefinition createTarget() throws NoSuchMethodException, - InvalidServiceContractException { - ConstructorDefinition ctorDef = new ConstructorDefinition(FooImpl.class.getConstructor()); - PojoComponentType> type = - new PojoComponentType>(); - type.setConstructorDefinition(ctorDef); - type.setImplementationScope(Scope.COMPOSITE); - Method method = FooImpl.class.getMethod("setCallback", FooCallback.class); - JavaInterfaceProcessorRegistry registry = new JavaInterfaceProcessorRegistryImpl(); - ServiceContract contract = registry.introspect(Foo.class); - contract.setCallbackClass(FooCallback.class); - contract.setCallbackName("callback"); - JavaMappedService mappedService = new JavaMappedService("Foo", contract, false, "callback", method); - type.getServices().put("Foo", mappedService); - - JavaImplementation impl = new JavaImplementation(); - impl.setComponentType(type); - impl.setImplementationClass(FooImpl.class); - return new ComponentDefinition("foo", impl); - } - - private ComponentDefinition createSource(String name) - throws NoSuchMethodException, URISyntaxException, InvalidServiceContractException { - ConstructorDefinition ctorDef = - new ConstructorDefinition(FooClient.class.getConstructor()); - PojoComponentType> type = - new PojoComponentType>(); - type.setConstructorDefinition(ctorDef); - type.setImplementationScope(Scope.COMPOSITE); - Method method = FooClient.class.getMethod("setFoo", Foo.class); - JavaInterfaceProcessorRegistry registry = new JavaInterfaceProcessorRegistryImpl(); - ServiceContract contract = registry.introspect(Foo.class); - contract.setCallbackClass(FooCallback.class); - contract.setCallbackName("callback"); - JavaMappedReference mappedReference = new JavaMappedReference("foo", contract, method); - type.getReferences().put("foo", mappedReference); - ReferenceTarget refTarget = new ReferenceTarget(); - refTarget.setReferenceName("foo"); - refTarget.getTargets().add(new URI("foo")); - JavaImplementation impl = new JavaImplementation(); - impl.setComponentType(type); - impl.setImplementationClass(FooClient.class); - ComponentDefinition def = new ComponentDefinition(name, impl); - def.getReferenceTargets().put("foo", refTarget); - return def; - } - - private ComponentDefinition createPlainSource(String name) - throws NoSuchMethodException, URISyntaxException, InvalidServiceContractException { - ConstructorDefinition ctorDef = - new ConstructorDefinition(FooPlainClient.class.getConstructor()); - PojoComponentType> type = - new PojoComponentType>(); - type.setConstructorDefinition(ctorDef); - type.setImplementationScope(Scope.COMPOSITE); - Method method = FooPlainClient.class.getMethod("setFoo", Foo.class); - JavaInterfaceProcessorRegistry registry = new JavaInterfaceProcessorRegistryImpl(); - ServiceContract contract = registry.introspect(Foo.class); - contract.setCallbackClass(FooCallback.class); - contract.setCallbackName("callback"); - JavaMappedReference mappedReference = new JavaMappedReference("foo", contract, method); - type.getReferences().put("foo", mappedReference); - ReferenceTarget refTarget = new ReferenceTarget(); - refTarget.setReferenceName("foo"); - refTarget.getTargets().add(new URI("foo")); - JavaImplementation impl = new JavaImplementation(); - impl.setComponentType(type); - impl.setImplementationClass(FooPlainClient.class); - ComponentDefinition def = new ComponentDefinition(name, impl); - def.getReferenceTargets().put("foo", refTarget); - return def; - } - - @Callback(FooCallback.class) - public static interface Foo { - void call(); - - void callMultiCallback(); - - void callFromPlain(); - } - - public static class FooImpl implements Foo { - private FooCallback callback; - - public FooImpl() { - } - - @Callback - public void setCallback(FooCallback callback) { - this.callback = callback; - } - - public void call() { - callback.callback(); - } - - public void callMultiCallback() { - callback.multiCallback(); - callback.multiCallback(); - } - - public void callFromPlain() { - try { - callback.callback(); - fail(); - } catch (NoRegisteredCallbackException e) { - // expected - } catch (Throwable e) { - e.printStackTrace(); - } - } - } - - public static class FooClient implements FooCallback { - - private Foo foo; - private boolean invoked; - private int count; - - public FooClient() { - } - - public void setFoo(Foo foo) { - this.foo = foo; - } - - public void callback() { - if (invoked) { - fail(); - } - invoked = true; - } - - public void multiCallback() { - count++; - } - - public void invoke() { - foo.call(); - } - - public void invokeMultiCallback() { - foo.callMultiCallback(); - } - } - - public interface FooCallback { - void callback(); - - void multiCallback(); - } - - public static class FooPlainClient /* implements FooCallback */ { // do NOT implement the callback - - private Foo foo; - - public FooPlainClient() { - } - - public void setFoo(Foo foo) { - this.foo = foo; - } - - public void invoke() { - foo.callFromPlain(); - } - - public void callback() { - - } - - public void multiCallback() { - - } - } - - protected void setUp() throws Exception { - super.setUp(); - wireService = new JDKWireService(); - container = new CompositeScopeContainer(null); - container.start(); - context = createMock(DeploymentContext.class); - context.getCompositeScope(); - expectLastCall().andReturn(container).anyTimes(); - replay(context); - - 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); - - builder = new JavaComponentBuilder(); - workContext = new WorkContextImpl(); - builder.setWorkContext(workContext); - builder.setWireService(new JDKWireService(workContext, null)); - builder.setWorkScheduler(scheduler); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/integration/OutboundWireToJavaTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/integration/OutboundWireToJavaTestCase.java deleted file mode 100644 index f2d88955e4..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/integration/OutboundWireToJavaTestCase.java +++ /dev/null @@ -1,233 +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.java.integration; - -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.Executor; -import java.util.concurrent.Executors; -import java.util.concurrent.FutureTask; - -import org.apache.tuscany.spi.QualifiedName; -import org.apache.tuscany.spi.builder.WiringException; -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.component.ScopeContainer; -import org.apache.tuscany.spi.component.WorkContext; -import org.apache.tuscany.spi.idl.InvalidServiceContractException; -import org.apache.tuscany.spi.idl.java.JavaInterfaceProcessorRegistry; -import org.apache.tuscany.spi.idl.java.JavaServiceContract; -import org.apache.tuscany.spi.model.InteractionScope; -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.wire.InboundWire; -import org.apache.tuscany.spi.wire.OutboundInvocationChain; -import org.apache.tuscany.spi.wire.OutboundWire; -import org.apache.tuscany.spi.wire.WireService; - -import junit.framework.TestCase; -import org.apache.tuscany.core.builder.ConnectorImpl; -import org.apache.tuscany.core.component.WorkContextImpl; -import org.apache.tuscany.core.component.event.CompositeStart; -import org.apache.tuscany.core.component.event.CompositeStop; -import org.apache.tuscany.core.component.event.HttpSessionEnd; -import org.apache.tuscany.core.component.event.HttpSessionStart; -import org.apache.tuscany.core.component.event.RequestEnd; -import org.apache.tuscany.core.component.event.RequestStart; -import org.apache.tuscany.core.component.scope.CompositeScopeContainer; -import org.apache.tuscany.core.component.scope.HttpSessionScopeContainer; -import org.apache.tuscany.core.component.scope.RequestScopeContainer; -import org.apache.tuscany.core.component.scope.StatelessScopeContainer; -import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl; -import org.apache.tuscany.core.implementation.PojoConfiguration; -import org.apache.tuscany.core.implementation.java.JavaAtomicComponent; -import org.apache.tuscany.core.injection.PojoObjectFactory; -import org.apache.tuscany.core.integration.mock.MockFactory; -import org.apache.tuscany.core.mock.component.Target; -import org.apache.tuscany.core.mock.component.TargetImpl; -import org.apache.tuscany.core.wire.OutboundInvocationChainImpl; -import org.apache.tuscany.core.wire.OutboundWireImpl; -import org.apache.tuscany.core.wire.jdk.JDKWireService; -import org.easymock.EasyMock; - -/** - * Validates wiring from a wire to Java atomic component by scope - * - * @version $$Rev$$ $$Date$$ - */ -public class OutboundWireToJavaTestCase extends TestCase { - private WorkContext workContext = new WorkContextImpl(); - private WireService wireService = new JDKWireService(new WorkContextImpl(), null); - - public void testToStatelessScope() throws Exception { - StatelessScopeContainer scope = new StatelessScopeContainer(workContext, null); - scope.start(); - final OutboundWire wire = getWire(scope); - Target service = wireService.createProxy(Target.class, wire); - assertNotNull(service); - service.setString("foo"); - assertEquals(null, service.getString()); - scope.stop(); - } - - public void testToRequestScope() throws Exception { - final RequestScopeContainer scope = new RequestScopeContainer(workContext, null); - scope.start(); - - scope.onEvent(new RequestStart(this)); - - final OutboundWire wire = getWire(scope); - Target service = wireService.createProxy(Target.class, wire); - assertNotNull(service); - service.setString("foo"); - - // another request - Executor executor = Executors.newSingleThreadExecutor(); - FutureTask future = new FutureTask(new Runnable() { - public void run() { - scope.onEvent(new RequestStart(this)); - Target service2 = wireService.createProxy(Target.class, wire); - Target target2 = wireService.createProxy(Target.class, wire); - assertEquals(null, service2.getString()); - service2.setString("bar"); - assertEquals("bar", service2.getString()); - assertEquals("bar", target2.getString()); - scope.onEvent(new RequestEnd(this)); - } - }, null); - executor.execute(future); - future.get(); - - assertEquals("foo", service.getString()); - scope.onEvent(new RequestEnd(this)); - scope.stop(); - } - - public void testToSessionScope() throws Exception { - HttpSessionScopeContainer scope = new HttpSessionScopeContainer(workContext, null); - scope.start(); - Object session1 = new Object(); - workContext.setIdentifier(Scope.SESSION, session1); - scope.onEvent(new HttpSessionStart(this, session1)); - - final OutboundWire wire = getWire(scope); - Target service = wireService.createProxy(Target.class, wire); - Target target = wireService.createProxy(Target.class, wire); - assertNotNull(service); - service.setString("foo"); - assertEquals("foo", service.getString()); - assertEquals("foo", target.getString()); - - workContext.clearIdentifier(Scope.SESSION); - - //second session - Object session2 = new Object(); - workContext.setIdentifier(Scope.SESSION, session2); - scope.onEvent(new HttpSessionStart(this, session2)); - - Target service2 = wireService.createProxy(Target.class, wire); - assertNotNull(service2); - assertNull(service2.getString()); - Target target2 = wireService.createProxy(Target.class, wire); - service2.setString("bar"); - assertEquals("bar", service2.getString()); - assertEquals("bar", target2.getString()); - - scope.onEvent(new HttpSessionEnd(this, session2)); - workContext.clearIdentifier(Scope.SESSION); - - workContext.setIdentifier(Scope.SESSION, session1); - assertEquals("foo", service.getString()); - - scope.onEvent(new HttpSessionEnd(this, session1)); - - scope.stop(); - } - - public void testToCompositeScope() throws Exception { - CompositeScopeContainer scope = new CompositeScopeContainer(null); - scope.start(); - scope.onEvent(new CompositeStart(this, null)); - final OutboundWire wire = getWire(scope); - Target service = wireService.createProxy(Target.class, wire); - Target target = wireService.createProxy(Target.class, wire); - assertNotNull(service); - service.setString("foo"); - assertEquals("foo", service.getString()); - assertEquals("foo", target.getString()); - scope.onEvent(new CompositeStop(this, null)); - scope.stop(); - } - - private OutboundWire getWire(ScopeContainer scope) throws NoSuchMethodException, - InvalidServiceContractException, WiringException { - ConnectorImpl connector = new ConnectorImpl(); - CompositeComponent parent = EasyMock.createMock(CompositeComponent.class); - PojoConfiguration configuration = new PojoConfiguration(); - configuration.setInstanceFactory(new PojoObjectFactory(TargetImpl.class.getConstructor())); - configuration.setParent(parent); - configuration.setWorkContext(workContext); - configuration.setName("source"); - - JavaAtomicComponent source = new JavaAtomicComponent(configuration); - source.setScopeContainer(scope); - OutboundWire outboundWire = createOutboundWire(new QualifiedName("target/Target"), Target.class); - outboundWire.setContainer(source); - source.addOutboundWire(outboundWire); - configuration.setName("target"); - JavaAtomicComponent target = new JavaAtomicComponent(configuration); - target.setScopeContainer(scope); - InboundWire targetWire = MockFactory.createInboundWire("Target", Target.class); - targetWire.setContainer(target); - target.addInboundWire(targetWire); - InboundWire inboundWire = target.getInboundWire("Target"); - inboundWire.setContainer(target); - - EasyMock.expect(parent.getChild("target")).andReturn(target); - EasyMock.replay(parent); - - connector.connect(source); - target.start(); - return outboundWire; - } - - private static OutboundWire createOutboundWire(QualifiedName targetName, Class interfaze) - throws InvalidServiceContractException { - OutboundWire wire = new OutboundWireImpl(); - JavaServiceContract contract = new JavaServiceContract(interfaze); - contract.setInteractionScope(InteractionScope.NONCONVERSATIONAL); - wire.setServiceContract(contract); - wire.setTargetName(targetName); - wire.addInvocationChains(createInvocationChains(interfaze)); - return wire; - } - - private static Map, OutboundInvocationChain> createInvocationChains(Class interfaze) - throws InvalidServiceContractException { - Map, OutboundInvocationChain> invocations = new HashMap, OutboundInvocationChain>(); - JavaInterfaceProcessorRegistry registry = new JavaInterfaceProcessorRegistryImpl(); - ServiceContract contract = registry.introspect(interfaze); - for (Operation operation : contract.getOperations().values()) { - OutboundInvocationChain chain = new OutboundInvocationChainImpl(operation); - invocations.put(operation, chain); - } - return invocations; - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/AllowsPassByReferenceProcessorTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/AllowsPassByReferenceProcessorTestCase.java deleted file mode 100644 index 9fd3fbfc9d..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/AllowsPassByReferenceProcessorTestCase.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.implementation.processor; - -import org.osoa.sca.annotations.AllowsPassByReference; - -import org.apache.tuscany.spi.implementation.java.JavaMappedProperty; -import org.apache.tuscany.spi.implementation.java.JavaMappedReference; -import org.apache.tuscany.spi.implementation.java.JavaMappedService; -import org.apache.tuscany.spi.implementation.java.PojoComponentType; - -import junit.framework.TestCase; - -/** - * @version $Rev: 452761 $ $Date: 2006-10-04 12:03:20 +0530 (Wed, 04 Oct 2006) $ - */ -public class AllowsPassByReferenceProcessorTestCase extends TestCase { - - PojoComponentType> type; - AllowsPassByReferenceProcessor processor; - - public void testClassAnnotation() throws Exception { - processor.visitClass(null, Foo.class, type, null); - assertEquals(true, type.isAllowsPassByReference()); - - processor.visitClass(null, Bar.class, type, null); - assertEquals(false, type.isAllowsPassByReference()); - } - - protected void setUp() throws Exception { - super.setUp(); - type = new PojoComponentType>(); - processor = new AllowsPassByReferenceProcessor(); - } - - @AllowsPassByReference - private class Foo { - } - - //no annotation - private class Bar { - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConstructorAutowireTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConstructorAutowireTestCase.java deleted file mode 100644 index c67d226b41..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConstructorAutowireTestCase.java +++ /dev/null @@ -1,154 +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.processor; - -import java.lang.reflect.Constructor; -import java.util.List; - -import org.osoa.sca.annotations.Property; - -import org.apache.tuscany.spi.annotation.Autowire; -import org.apache.tuscany.spi.implementation.java.JavaMappedProperty; -import org.apache.tuscany.spi.implementation.java.JavaMappedReference; -import org.apache.tuscany.spi.implementation.java.JavaMappedService; -import org.apache.tuscany.spi.implementation.java.PojoComponentType; - -import junit.framework.TestCase; -import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl; - -/** - * @version $Rev$ $Date$ - */ -public class ConstructorAutowireTestCase extends TestCase { - - ConstructorProcessor processor = - new ConstructorProcessor(new ImplementationProcessorServiceImpl(new JavaInterfaceProcessorRegistryImpl())); - - public void testAutowire() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - Constructor ctor = Foo.class.getConstructor(Bar.class); - processor.visitConstructor(null, ctor, type, null); - assertNotNull(type.getReferences().get("myRef")); - } - - public void testNamesOnConstructor() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - Constructor ctor = Foo.class.getConstructor(Bar.class, Bar.class); - processor.visitConstructor(null, ctor, type, null); - assertEquals(2, type.getConstructorDefinition().getInjectionNames().size()); - assertNotNull(type.getReferences().get("myRef1")); - assertNotNull(type.getReferences().get("myRef2")); - } - - public void testNoName() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - Constructor ctor = Foo2.class.getConstructor(Bar.class); - processor.visitConstructor(null, ctor, type, null); - assertNotNull(type.getReferences().get(Bar.class.getName() + "0")); - } - - public void testInvalidNumberOfNames() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - Constructor ctor = BadFoo.class.getConstructor(Bar.class, Bar.class); - try { - processor.visitConstructor(null, ctor, type, null); - fail(); - } catch (InvalidAutowireException e) { - // expected - } - } - - public void testNoMatchingNames() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - Constructor ctor = BadFoo.class.getConstructor(List.class, List.class); - try { - processor.visitConstructor(null, ctor, type, null); - fail(); - } catch (InvalidConstructorException e) { - // expected - } - } - - /** - * Verifies processing executes with additional extension annotations - */ - public void testRandomAnnotation() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - Constructor ctor = Foo3.class.getConstructor(String.class, String.class); - processor.visitConstructor(null, ctor, type, null); - assertEquals(1, type.getProperties().size()); - assertNotNull(type.getProperties().get("prop1")); - } - - private static interface Bar { - - } - - private static class Foo { - - @org.osoa.sca.annotations.Constructor() - public Foo(@Autowire(name = "myRef") Bar ref) { - - } - - @org.osoa.sca.annotations.Constructor({"myRef1", "myRef2"}) - public Foo(@Autowire Bar ref1, @Autowire Bar ref2) { - - } - - } - - private static class Foo2 { - @org.osoa.sca.annotations.Constructor() - public Foo2(@Autowire Bar ref) { - - } - } - - private static class BadFoo { - - @org.osoa.sca.annotations.Constructor({"ref1"}) - public BadFoo(@Autowire Bar ref1, @Autowire Bar ref2) { - - } - - @org.osoa.sca.annotations.Constructor({"myRef", "myRef2"}) - public BadFoo(@Autowire List ref, @Autowire(name = "myOtherRef") List ref2) { - - } - - } - - public static class Foo3 { - - @org.osoa.sca.annotations.Constructor - public Foo3(@Property(name = "prop1") String prop, @Baz String baz) { - } - } - - public @interface Baz { - - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConstructorProcessorExtensibilityTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConstructorProcessorExtensibilityTestCase.java deleted file mode 100644 index 25a8ab9a1a..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConstructorProcessorExtensibilityTestCase.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.implementation.processor; - -import java.lang.reflect.Constructor; - -import org.osoa.sca.annotations.Property; - -import org.apache.tuscany.spi.implementation.java.ConstructorDefinition; -import org.apache.tuscany.spi.implementation.java.JavaMappedProperty; -import org.apache.tuscany.spi.implementation.java.JavaMappedReference; -import org.apache.tuscany.spi.implementation.java.JavaMappedService; -import org.apache.tuscany.spi.implementation.java.PojoComponentType; - -import junit.framework.TestCase; -import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl; - -/** - * Verifies the constructor processor works when parameters are marked with custom extension annotations - * - * @version $Rev$ $Date$ - */ -public class ConstructorProcessorExtensibilityTestCase extends TestCase { - private ConstructorProcessor processor = - new ConstructorProcessor(new ImplementationProcessorServiceImpl(new JavaInterfaceProcessorRegistryImpl())); - - public void testProcessFirst() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - Constructor ctor1 = Foo.class.getConstructor(String.class, String.class); - processor.visitConstructor(null, ctor1, type, null); - assertEquals("foo", type.getConstructorDefinition().getInjectionNames().get(0)); - } - - /** - * Verifies the constructor processor can be called after another processor has evaluated the constructor and found - * an annotation - * - * @throws Exception - */ - public void testProcessLast() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - Constructor ctor1 = Foo.class.getConstructor(String.class, String.class); - ConstructorDefinition definition = new ConstructorDefinition(ctor1); - definition.getInjectionNames().add(""); - definition.getInjectionNames().add("mybar"); - type.setConstructorDefinition(definition); - processor.visitConstructor(null, ctor1, type, null); - assertEquals("foo", type.getConstructorDefinition().getInjectionNames().get(0)); - } - - - private @interface Bar { - - } - - private static class Foo { - @org.osoa.sca.annotations.Constructor - public Foo(@Property(name = "foo") String foo, @Bar String bar) { - - } - } - - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConstructorProcessorTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConstructorProcessorTestCase.java deleted file mode 100644 index 364bfcc274..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConstructorProcessorTestCase.java +++ /dev/null @@ -1,148 +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.processor; - -import java.lang.reflect.Constructor; - -import org.osoa.sca.annotations.Property; -import org.osoa.sca.annotations.Reference; - -import org.apache.tuscany.spi.annotation.Autowire; -import org.apache.tuscany.spi.implementation.java.JavaMappedProperty; -import org.apache.tuscany.spi.implementation.java.JavaMappedReference; -import org.apache.tuscany.spi.implementation.java.JavaMappedService; -import org.apache.tuscany.spi.implementation.java.PojoComponentType; - -import junit.framework.TestCase; -import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl; - -/** - * @version $Rev$ $Date$ - */ -public class ConstructorProcessorTestCase extends TestCase { - private ConstructorProcessor processor = - new ConstructorProcessor(new ImplementationProcessorServiceImpl(new JavaInterfaceProcessorRegistryImpl())); - - public void testDuplicateConstructor() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - try { - processor.visitClass(null, BadFoo.class, type, null); - fail(); - } catch (DuplicateConstructorException e) { - // expected - } - } - - public void testConstructorAnnotation() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - Constructor ctor1 = Foo.class.getConstructor(String.class); - processor.visitConstructor(null, ctor1, type, null); - assertEquals("foo", type.getConstructorDefinition().getInjectionNames().get(0)); - } - - public void testNoAnnotation() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - Constructor ctor1 = NoAnnotation.class.getConstructor(); - processor.visitConstructor(null, ctor1, type, null); - assertNull(type.getConstructorDefinition()); - } - - public void testBadAnnotation() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - Constructor ctor1 = BadAnnotation.class.getConstructor(String.class, Foo.class); - try { - processor.visitConstructor(null, ctor1, type, null); - fail(); - } catch (InvalidConstructorException e) { - // expected - } - } - - public void testMixedParameters() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - Constructor ctor1 = Mixed.class.getConstructor(String.class, String.class, String.class); - processor.visitConstructor(null, ctor1, type, null); - assertEquals("java.lang.String0", type.getConstructorDefinition().getInjectionNames().get(0)); - assertEquals("foo", type.getConstructorDefinition().getInjectionNames().get(1)); - assertEquals("bar", type.getConstructorDefinition().getInjectionNames().get(2)); - } - - public void testAllAutowireWithNoNames() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - Constructor ctor1 = - AllAutowireNoName.class.getConstructor(String.class, String.class, String.class); - processor.visitConstructor(null, ctor1, type, null); - assertEquals("java.lang.String0", type.getConstructorDefinition().getInjectionNames().get(0)); - assertEquals("java.lang.String1", type.getConstructorDefinition().getInjectionNames().get(1)); - assertEquals("java.lang.String2", type.getConstructorDefinition().getInjectionNames().get(2)); - } - - private static class BadFoo { - - @org.osoa.sca.annotations.Constructor("foo") - public BadFoo(String foo) { - - } - - @org.osoa.sca.annotations.Constructor({"foo", "bar"}) - public BadFoo(String foo, String bar) { - - } - } - - private static class Foo { - @org.osoa.sca.annotations.Constructor("foo") - public Foo(String foo) { - - } - } - - private static class NoAnnotation { - public NoAnnotation() { - } - } - - private static class BadAnnotation { - @org.osoa.sca.annotations.Constructor("foo") - public BadAnnotation(String foo, Foo ref) { - } - } - - - public static final class Mixed { - @org.osoa.sca.annotations.Constructor - public Mixed(@Autowire String param1, - @Property(name = "foo") String param2, - @Reference(name = "bar") String param3) { - } - } - - public static final class AllAutowireNoName { - @org.osoa.sca.annotations.Constructor - public AllAutowireNoName(@Autowire String param1, @Autowire String param2, @Autowire String param3) { - } - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConstructorPropertyTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConstructorPropertyTestCase.java deleted file mode 100644 index ee461aead7..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConstructorPropertyTestCase.java +++ /dev/null @@ -1,171 +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.processor; - -import java.lang.reflect.Constructor; -import java.util.List; - -import org.osoa.sca.annotations.Property; - -import org.apache.tuscany.spi.implementation.java.DuplicatePropertyException; -import org.apache.tuscany.spi.implementation.java.JavaMappedProperty; -import org.apache.tuscany.spi.implementation.java.JavaMappedReference; -import org.apache.tuscany.spi.implementation.java.JavaMappedService; -import org.apache.tuscany.spi.implementation.java.PojoComponentType; -import org.apache.tuscany.spi.model.OverrideOptions; - -import junit.framework.TestCase; -import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl; - -/** - * @version $Rev$ $Date$ - */ -public class ConstructorPropertyTestCase extends TestCase { - - ConstructorProcessor processor = - new ConstructorProcessor(new ImplementationProcessorServiceImpl(new JavaInterfaceProcessorRegistryImpl())); - - public void testProperty() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - Constructor ctor = Foo.class.getConstructor(String.class); - processor.visitConstructor(null, ctor, type, null); - JavaMappedProperty property = type.getProperties().get("myProp"); - //assertTrue(property.isRequired()); - assertEquals(property.getOverride(), OverrideOptions.MAY); - assertEquals("myProp", property.getName()); - } - - public void testTwoPropertiesSameType() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - Constructor ctor = Foo.class.getConstructor(String.class, String.class); - processor.visitConstructor(null, ctor, type, null); - assertNotNull(type.getProperties().get("myProp1")); - assertNotNull(type.getProperties().get("myProp2")); - } - - public void testDuplicateProperty() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - Constructor ctor = BadFoo.class.getConstructor(String.class, String.class); - try { - processor.visitConstructor(null, ctor, type, null); - fail(); - } catch (DuplicatePropertyException e) { - // expected - } - } - - public void testNoName() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - Constructor ctor = BadFoo.class.getConstructor(String.class); - try { - processor.visitConstructor(null, ctor, type, null); - fail(); - } catch (InvalidPropertyException e) { - // expected - } - } - - public void testNamesOnConstructor() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - Constructor ctor = Foo.class.getConstructor(Integer.class); - processor.visitConstructor(null, ctor, type, null); - assertNotNull(type.getProperties().get("myProp")); - } - - public void testInvalidNumberOfNames() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - Constructor ctor = BadFoo.class.getConstructor(Integer.class, Integer.class); - try { - processor.visitConstructor(null, ctor, type, null); - fail(); - } catch (InvalidPropertyException e) { - // expected - } - } - - public void testNoMatchingNames() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - Constructor ctor = BadFoo.class.getConstructor(List.class, List.class); - try { - processor.visitConstructor(null, ctor, type, null); - fail(); - } catch (InvalidConstructorException e) { - // expected - } - } - -// public void testMultiplicityRequired() throws Exception { - // TODO multiplicity -// } - - private static class Foo { - - @org.osoa.sca.annotations.Constructor() - public Foo(@Property(name = "myProp", override = "may") String prop) { - - } - - @org.osoa.sca.annotations.Constructor("myProp") - public Foo(@Property Integer prop) { - - } - - @org.osoa.sca.annotations.Constructor() - public Foo(@Property(name = "myProp1") String prop1, @Property(name = "myProp2") String prop2) { - - } - - @org.osoa.sca.annotations.Constructor() - public Foo(@Property List prop) { - - } - } - - private static class BadFoo { - - @org.osoa.sca.annotations.Constructor() - public BadFoo(@Property(name = "myProp") String prop1, @Property(name = "myProp") String prop2) { - - } - - @org.osoa.sca.annotations.Constructor() - public BadFoo(@Property String prop) { - - } - - @org.osoa.sca.annotations.Constructor("myProp") - public BadFoo(@Property Integer prop, @Property Integer prop2) { - - } - - @org.osoa.sca.annotations.Constructor({"myRef", "myRef2"}) - public BadFoo(@Property List ref, @Property(name = "myOtherRef") List ref2) { - - } - - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConstructorReferenceTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConstructorReferenceTestCase.java deleted file mode 100644 index 687c95e860..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConstructorReferenceTestCase.java +++ /dev/null @@ -1,173 +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.processor; - -import java.lang.reflect.Constructor; -import java.util.List; - -import org.osoa.sca.annotations.Reference; - -import org.apache.tuscany.spi.implementation.java.JavaMappedProperty; -import org.apache.tuscany.spi.implementation.java.JavaMappedReference; -import org.apache.tuscany.spi.implementation.java.JavaMappedService; -import org.apache.tuscany.spi.implementation.java.PojoComponentType; - -import junit.framework.TestCase; -import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl; - -/** - * @version $Rev$ $Date$ - */ -public class ConstructorReferenceTestCase extends TestCase { - - ConstructorProcessor processor; - - public void testReference() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - Constructor ctor = Foo.class.getConstructor(String.class); - processor.visitConstructor(null, ctor, type, null); - JavaMappedReference reference = type.getReferences().get("myRef"); - assertTrue(reference.isRequired()); - assertEquals("myRef", reference.getName()); - } - - public void testTwoReferencesSameType() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - Constructor ctor = Foo.class.getConstructor(String.class, String.class); - processor.visitConstructor(null, ctor, type, null); - assertNotNull(type.getReferences().get("myRef1")); - assertNotNull(type.getReferences().get("myRef2")); - } - - public void testDuplicateProperty() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - Constructor ctor = BadFoo.class.getConstructor(String.class, String.class); - try { - processor.visitConstructor(null, ctor, type, null); - fail(); - } catch (DuplicateReferenceException e) { - // expected - } - } - - public void testNoName() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - Constructor ctor = BadFoo.class.getConstructor(String.class); - try { - processor.visitConstructor(null, ctor, type, null); - fail(); - } catch (InvalidReferenceException e) { - // expected - } - } - - public void testNamesOnConstructor() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - Constructor ctor = Foo.class.getConstructor(Integer.class); - processor.visitConstructor(null, ctor, type, null); - assertNotNull(type.getReferences().get("myRef")); - } - - public void testInvalidNumberOfNames() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - Constructor ctor = BadFoo.class.getConstructor(Integer.class, Integer.class); - try { - processor.visitConstructor(null, ctor, type, null); - fail(); - } catch (InvalidReferenceException e) { - // expected - } - } - - public void testNoMatchingNames() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - Constructor ctor = BadFoo.class.getConstructor(List.class, List.class); - try { - processor.visitConstructor(null, ctor, type, null); - fail(); - } catch (InvalidConstructorException e) { - // expected - } - } - - protected void setUp() throws Exception { - super.setUp(); - processor = - new ConstructorProcessor(new ImplementationProcessorServiceImpl(new JavaInterfaceProcessorRegistryImpl())); - } - -// public void testMultiplicityRequired() throws Exception { - // TODO multiplicity -// } - - private static class Foo { - - @org.osoa.sca.annotations.Constructor() - public Foo(@Reference(name = "myRef", required = true) String prop) { - - } - - @org.osoa.sca.annotations.Constructor() - public Foo(@Reference(name = "myRef1") String prop1, @Reference(name = "myRef2") String prop2) { - - } - - @org.osoa.sca.annotations.Constructor("myRef") - public Foo(@Reference Integer prop) { - - } - - @org.osoa.sca.annotations.Constructor() - public Foo(@Reference List prop) { - - } - } - - private static class BadFoo { - - @org.osoa.sca.annotations.Constructor - public BadFoo(@Reference(name = "myRef") String prop1, @Reference(name = "myRef") String prop2) { - - } - - @org.osoa.sca.annotations.Constructor - public BadFoo(@Reference String prop) { - - } - - @org.osoa.sca.annotations.Constructor("myRef") - public BadFoo(@Reference Integer ref, @Reference Integer ref2) { - - } - - @org.osoa.sca.annotations.Constructor({"myRef", "myRef2"}) - public BadFoo(@Reference List ref, @Reference(name = "myOtherRef") List ref2) { - - } - - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConstructorResourceTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConstructorResourceTestCase.java deleted file mode 100644 index 17904d3cd8..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConstructorResourceTestCase.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.implementation.processor; - -import java.lang.reflect.Constructor; -import java.util.List; - -import org.osoa.sca.annotations.Resource; - -import org.apache.tuscany.spi.implementation.java.JavaMappedProperty; -import org.apache.tuscany.spi.implementation.java.JavaMappedReference; -import org.apache.tuscany.spi.implementation.java.JavaMappedService; -import org.apache.tuscany.spi.implementation.java.PojoComponentType; - -import junit.framework.TestCase; -import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl; - -/** - * @version $Rev$ $Date$ - */ -public class ConstructorResourceTestCase extends TestCase { - - ConstructorProcessor processor = - new ConstructorProcessor(new ImplementationProcessorServiceImpl(new JavaInterfaceProcessorRegistryImpl())); - - public void testResource() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - Constructor ctor = Foo.class.getConstructor(String.class); - processor.visitConstructor(null, ctor, type, null); - org.apache.tuscany.spi.implementation.java.Resource resource = type.getResources().get("myResource"); - assertFalse(resource.isOptional()); - } - - public void testTwoResourcesSameType() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - Constructor ctor = Foo.class.getConstructor(String.class, String.class); - processor.visitConstructor(null, ctor, type, null); - assertNotNull(type.getResources().get("myResource1")); - assertNotNull(type.getResources().get("myResource2")); - } - - public void testDuplicateResource() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - Constructor ctor = BadFoo.class.getConstructor(String.class, String.class); - try { - processor.visitConstructor(null, ctor, type, null); - fail(); - } catch (DuplicateResourceException e) { - // expected - } - } - - public void testNoName() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - Constructor ctor = - ConstructorResourceTestCase.BadFoo.class.getConstructor(String.class); - try { - processor.visitConstructor(null, ctor, type, null); - fail(); - } catch (InvalidResourceException e) { - // expected - } - } - - public void testNamesOnConstructor() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - Constructor ctor = Foo.class.getConstructor(Integer.class); - processor.visitConstructor(null, ctor, type, null); - assertNotNull(type.getResources().get("myResource")); - } - - public void testInvalidNumberOfNames() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - Constructor ctor = - ConstructorResourceTestCase.BadFoo.class.getConstructor(Integer.class, Integer.class); - try { - processor.visitConstructor(null, ctor, type, null); - fail(); - } catch (InvalidResourceException e) { - // expected - } - } - - public void testNoMatchingNames() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - Constructor ctor = - ConstructorResourceTestCase.BadFoo.class.getConstructor(List.class, List.class); - try { - processor.visitConstructor(null, ctor, type, null); - fail(); - } catch (InvalidConstructorException e) { - // expected - } - } - - private static class Foo { - - @org.osoa.sca.annotations.Constructor - public Foo(@Resource(name = "myResource") String resource) { - - } - - @org.osoa.sca.annotations.Constructor("myResource") - public Foo(@Resource Integer resource) { - - } - - @org.osoa.sca.annotations.Constructor - public Foo(@Resource(name = "myResource1") String res1, @Resource(name = "myResource2") String res2) { - - } - - @org.osoa.sca.annotations.Constructor - public Foo(@Resource List res) { - - } - } - - private static class BadFoo { - - @org.osoa.sca.annotations.Constructor - public BadFoo(@Resource(name = "myResource") String res1, @Resource(name = "myResource") String res2) { - - } - - @org.osoa.sca.annotations.Constructor - public BadFoo(@Resource String res) { - - } - - @org.osoa.sca.annotations.Constructor("myProp") - public BadFoo(@Resource Integer res, @Resource Integer res2) { - - } - - @org.osoa.sca.annotations.Constructor({"myRes", "myRes2"}) - public BadFoo(@Resource List res, @Resource(name = "myOtherRes") List res2) { - - } - - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ContextProcessorTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ContextProcessorTestCase.java deleted file mode 100644 index f5d56f5a34..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ContextProcessorTestCase.java +++ /dev/null @@ -1,192 +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.processor; - -import java.lang.reflect.Field; -import java.lang.reflect.Method; - -import org.osoa.sca.CompositeContext; -import org.osoa.sca.RequestContext; -import org.osoa.sca.annotations.Context; - -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.component.WorkContext; -import org.apache.tuscany.spi.implementation.java.JavaMappedProperty; -import org.apache.tuscany.spi.implementation.java.JavaMappedReference; -import org.apache.tuscany.spi.implementation.java.JavaMappedService; -import org.apache.tuscany.spi.implementation.java.PojoComponentType; -import org.apache.tuscany.spi.wire.WireService; - -import junit.framework.TestCase; -import org.easymock.EasyMock; - -/** - * @version $Rev$ $Date$ - */ -public class ContextProcessorTestCase extends TestCase { - private ContextProcessor processor; - private CompositeComponent composite; - - public void testCompositeContextMethod() throws Exception { - Method method = Foo.class.getMethod("setContext", CompositeContext.class); - PojoComponentType> type = - new PojoComponentType>(); - processor.visitMethod(composite, method, type, null); - assertNotNull(type.getResources().get("context")); - } - - public void testCompositeContextField() throws Exception { - Field field = Foo.class.getDeclaredField("context"); - PojoComponentType> type = - new PojoComponentType>(); - processor.visitField(composite, field, type, null); - assertNotNull(type.getResources().get("context")); - } - - public void testRequestContextMethod() throws Exception { - Method method = Foo.class.getMethod("setRequestContext", RequestContext.class); - PojoComponentType> type = - new PojoComponentType>(); - processor.visitMethod(composite, method, type, null); - assertNotNull(type.getResources().get("requestContext")); - } - - public void testRequestContextField() throws Exception { - Field field = Foo.class.getDeclaredField("requestContext"); - PojoComponentType> type = - new PojoComponentType>(); - processor.visitField(composite, field, type, null); - assertNotNull(type.getResources().get("requestContext")); - } - - public void testInvalidParamType() throws Exception { - Method method = Foo.class.getMethod("setContext", String.class); - PojoComponentType> type = - new PojoComponentType>(); - try { - processor.visitMethod(composite, method, type, null); - fail(); - } catch (UnknownContextTypeException e) { - // expected - } - } - - public void testInvalidParamTypeField() throws Exception { - Field field = Foo.class.getDeclaredField("badContext"); - PojoComponentType> type = - new PojoComponentType>(); - try { - processor.visitField(composite, field, type, null); - fail(); - } catch (UnknownContextTypeException e) { - // expected - } - } - - - public void testInvalidParamNum() throws Exception { - Method method = Foo.class.getMethod("setContext", CompositeContext.class, String.class); - PojoComponentType> type = - new PojoComponentType>(); - try { - processor.visitMethod(composite, method, type, null); - fail(); - } catch (IllegalContextException e) { - // expected - } - } - - public void testInvalidNoParams() throws Exception { - Method method = Foo.class.getMethod("setContext"); - PojoComponentType> type = - new PojoComponentType>(); - try { - processor.visitMethod(composite, method, type, null); - fail(); - } catch (IllegalContextException e) { - // expected - } - } - - public void testNoContext() throws Exception { - Method method = Foo.class.getMethod("noContext", CompositeContext.class); - PojoComponentType> type = - new PojoComponentType>(); - processor.visitMethod(composite, method, type, null); - assertEquals(0, type.getResources().size()); - } - - public void testNoContextField() throws Exception { - Field field = Foo.class.getDeclaredField("noContext"); - PojoComponentType> type = - new PojoComponentType>(); - processor.visitField(composite, field, type, null); - assertEquals(0, type.getResources().size()); - } - - protected void setUp() throws Exception { - super.setUp(); - processor = new ContextProcessor(); - processor.setWireService(EasyMock.createNiceMock(WireService.class)); - processor.setWorkContext(EasyMock.createNiceMock(WorkContext.class)); - composite = EasyMock.createNiceMock(CompositeComponent.class); - } - - private class Foo { - @Context - protected CompositeContext context; - - @Context - protected Object badContext; - - protected CompositeContext noContext; - - @Context - protected RequestContext requestContext; - - @Context - public void setContext(CompositeContext context) { - - } - - @Context - public void setContext(String context) { - - } - - @Context - public void setContext(CompositeContext context, String string) { - - } - - @Context - public void setContext() { - - } - - public void noContext(CompositeContext context) { - - } - - @Context - public void setRequestContext(RequestContext requestContext) { - this.requestContext = requestContext; - } - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConversationProcessorTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConversationProcessorTestCase.java deleted file mode 100644 index 76f59f0841..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConversationProcessorTestCase.java +++ /dev/null @@ -1,152 +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.processor; - -import java.lang.reflect.Field; -import java.lang.reflect.Method; - -import org.osoa.sca.annotations.Conversation; -import org.osoa.sca.annotations.ConversationID; -import org.osoa.sca.annotations.Scope; - -import org.apache.tuscany.spi.implementation.java.JavaMappedProperty; -import org.apache.tuscany.spi.implementation.java.JavaMappedReference; -import org.apache.tuscany.spi.implementation.java.JavaMappedService; -import org.apache.tuscany.spi.implementation.java.PojoComponentType; - -import junit.framework.TestCase; - -/** - * @version $Rev$ $Date$ - */ -public class ConversationProcessorTestCase extends TestCase { - private ConversationProcessor processor = new ConversationProcessor(); - - public void testMaxIdleTime() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - processor.visitClass(null, FooMaxIdle.class, type, null); - assertEquals(10000L, type.getMaxIdleTime()); - assertEquals(-1, type.getMaxAge()); - } - - public void testMaxAge() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - processor.visitClass(null, FooMaxAge.class, type, null); - assertEquals(10000L, type.getMaxAge()); - assertEquals(-1, type.getMaxIdleTime()); - } - - public void testBadFooBoth() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - try { - processor.visitClass(null, BadFooBoth.class, type, null); - fail(); - } catch (InvalidConversationalImplementation e) { - // expected - } - } - - public void testImplicitScope() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - processor.visitClass(null, ImplicitFooScope.class, type, null); - assertEquals(org.apache.tuscany.spi.model.Scope.CONVERSATION, type.getImplementationScope()); - } - - public void testBadFooScope() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - try { - processor.visitClass(null, BadFooScope.class, type, null); - fail(); - } catch (InvalidConversationalImplementation e) { - // expected - } - } - - public void testJustConversation() throws Exception { - // TODO do we want these semantics - PojoComponentType> type = - new PojoComponentType>(); - processor.visitClass(null, FooJustConversation.class, type, null); - assertEquals(org.apache.tuscany.spi.model.Scope.CONVERSATION, type.getImplementationScope()); - assertEquals(-1, type.getMaxAge()); - assertEquals(-1, type.getMaxIdleTime()); - } - - public void testSetConversationIDField() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - Field field = FooWithConversationIDField.class.getDeclaredField("conversationID"); - processor.visitField(null, field, type, null); - assertNotNull(type.getConversationIDMember()); - assertEquals(field, type.getConversationIDMember()); - } - - public void testSetConversationIDMethod() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - Method method = FooWithConversationIDMethod.class.getDeclaredMethods()[0]; - processor.visitMethod(null, method, type, null); - assertNotNull(type.getConversationIDMember()); - assertEquals(method, type.getConversationIDMember()); - } - - @Scope("CONVERSATION") - @Conversation(maxIdleTime = "10 seconds") - private class FooMaxIdle { - } - - @Scope("CONVERSATION") - @Conversation(maxAge = "10 seconds") - private class FooMaxAge { - } - - @Scope("CONVERSATION") - @Conversation(maxAge = "10 seconds", maxIdleTime = "10 seconds") - private class BadFooBoth { - } - - @Conversation(maxAge = "10 seconds") - private class ImplicitFooScope { - } - - @Scope("STATELESS") - @Conversation(maxAge = "10 seconds") - private class BadFooScope { - } - - @Conversation - private class FooJustConversation { - } - - private class FooWithConversationIDField { - @ConversationID - private String conversationID; - } - - private class FooWithConversationIDMethod { - @ConversationID - void setConversationID(String conversationID) { - } - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConvertTimeMillisTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConvertTimeMillisTestCase.java deleted file mode 100644 index 556416a797..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConvertTimeMillisTestCase.java +++ /dev/null @@ -1,110 +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.processor; - -import junit.framework.TestCase; - -/** - * @version $Rev$ $Date$ - */ -public class ConvertTimeMillisTestCase extends TestCase { - private MockProcessor registy; - - public void testConvertSeconds() throws Exception { - assertEquals(10000L, registy.convertTimeMillis("10 seconds")); - assertEquals(10000L, registy.convertTimeMillis("10 SECONDS")); - try { - registy.convertTimeMillis("10seconds"); - fail(); - } catch (NumberFormatException e) { - // expected - } - } - - public void testConvertMinutes() throws Exception { - assertEquals(600000L, registy.convertTimeMillis("10 minutes")); - assertEquals(600000L, registy.convertTimeMillis("10 MINUTES")); - try { - registy.convertTimeMillis("10minutes"); - fail(); - } catch (NumberFormatException e) { - // expected - } - } - - public void testConvertHours() throws Exception { - assertEquals(36000000L, registy.convertTimeMillis("10 hours")); - assertEquals(36000000L, registy.convertTimeMillis("10 HOURS")); - try { - registy.convertTimeMillis("10hours"); - fail(); - } catch (NumberFormatException e) { - // expected - } - } - - public void testConvertDays() throws Exception { - assertEquals(864000000L, registy.convertTimeMillis("10 days")); - assertEquals(864000000L, registy.convertTimeMillis("10 DAYS")); - try { - registy.convertTimeMillis("10days"); - fail(); - } catch (NumberFormatException e) { - // expected - } - } - - public void testConvertYears() throws Exception { - assertEquals(315569260000L, registy.convertTimeMillis("10 years")); - assertEquals(315569260000L, registy.convertTimeMillis("10 YEARS")); - try { - registy.convertTimeMillis("10years"); - fail(); - } catch (NumberFormatException e) { - // expected - } - } - - public void testConvertDefault() throws Exception { - assertEquals(10000L, registy.convertTimeMillis("10 ")); - assertEquals(10000L, registy.convertTimeMillis("10")); - } - - public void testInvalid() throws Exception { - try { - registy.convertTimeMillis("foo"); - fail(); - } catch (NumberFormatException e) { - // expected - } - } - - protected void setUp() throws Exception { - super.setUp(); - registy = new MockProcessor(); - } - - private class MockProcessor extends ConversationProcessor { - - @Override - protected long convertTimeMillis(String expr) throws NumberFormatException { - return super.convertTimeMillis(expr); - } - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/DestroyProcessorTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/DestroyProcessorTestCase.java deleted file mode 100644 index 6929250298..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/DestroyProcessorTestCase.java +++ /dev/null @@ -1,100 +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.processor; - -import java.lang.reflect.Method; - -import org.osoa.sca.annotations.Destroy; - -import org.apache.tuscany.spi.implementation.java.JavaMappedService; - -import junit.framework.TestCase; -import org.apache.tuscany.spi.implementation.java.PojoComponentType; -import org.apache.tuscany.spi.implementation.java.JavaMappedProperty; - -import org.apache.tuscany.spi.implementation.java.JavaMappedReference; - -/** - * @version $Rev$ $Date$ - */ -public class DestroyProcessorTestCase extends TestCase { - - public void testDestroy() throws Exception { - DestroyProcessor processor = new DestroyProcessor(); - PojoComponentType> type = - new PojoComponentType>(); - Method method = Foo.class.getMethod("destroy"); - processor.visitMethod(null, method, type, null); - assertNotNull(type.getDestroyMethod()); - } - - public void testBadDestroy() throws Exception { - DestroyProcessor processor = new DestroyProcessor(); - PojoComponentType> type = - new PojoComponentType>(); - Method method = Bar.class.getMethod("badDestroy", String.class); - try { - processor.visitMethod(null, method, type, null); - fail(); - } catch (IllegalDestructorException e) { - // expected - } - } - - public void testTwoDestroy() throws Exception { - DestroyProcessor processor = new DestroyProcessor(); - PojoComponentType> type = - new PojoComponentType>(); - Method method = Bar.class.getMethod("destroy"); - Method method2 = Bar.class.getMethod("destroy2"); - processor.visitMethod(null, method, type, null); - try { - processor.visitMethod(null, method2, type, null); - fail(); - } catch (DuplicateDestructorException e) { - // expected - } - } - - - private class Foo { - - @Destroy - public void destroy() { - } - } - - - private class Bar { - - @Destroy - public void destroy() { - } - - @Destroy - public void destroy2() { - } - - @Destroy - public void badDestroy(String foo) { - } - - - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/EagerInitProcessorTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/EagerInitProcessorTestCase.java deleted file mode 100644 index 83fe00bbdf..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/EagerInitProcessorTestCase.java +++ /dev/null @@ -1,54 +0,0 @@ -package org.apache.tuscany.core.implementation.processor; - -import org.osoa.sca.annotations.EagerInit; - -import org.apache.tuscany.spi.implementation.java.JavaMappedProperty; -import org.apache.tuscany.spi.implementation.java.JavaMappedReference; -import org.apache.tuscany.spi.implementation.java.JavaMappedService; -import org.apache.tuscany.spi.implementation.java.PojoComponentType; -import org.apache.tuscany.spi.implementation.java.ProcessingException; - -import junit.framework.TestCase; - -/** - * @version $Rev$ $Date$ - */ -public class EagerInitProcessorTestCase extends TestCase { - - public void testNoLevel() throws ProcessingException { - EagerInitProcessor processor = new EagerInitProcessor(); - PojoComponentType> type = - new PojoComponentType>(); - processor.visitClass(null, NoLevel.class, type, null); - assertEquals(50, type.getInitLevel()); - } - - public void testLevel() throws ProcessingException { - EagerInitProcessor processor = new EagerInitProcessor(); - PojoComponentType> type = - new PojoComponentType>(); - processor.visitClass(null, Level.class, type, null); - assertEquals(1, type.getInitLevel()); - } - - public void testSubclass() throws ProcessingException { - EagerInitProcessor processor = new EagerInitProcessor(); - PojoComponentType> type = - new PojoComponentType>(); - processor.visitClass(null, SubClass.class, type, null); - assertEquals(1, type.getInitLevel()); - } - - @EagerInit - private class NoLevel { - } - - @EagerInit(1) - private class Level { - } - - private class SubClass extends Level { - - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/HeuristicAndPropertyTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/HeuristicAndPropertyTestCase.java deleted file mode 100644 index 93de605e33..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/HeuristicAndPropertyTestCase.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.implementation.processor; - -import java.lang.reflect.Constructor; - -import org.osoa.sca.annotations.Property; - -import org.apache.tuscany.spi.implementation.java.ConstructorDefinition; -import org.apache.tuscany.spi.implementation.java.JavaMappedProperty; -import org.apache.tuscany.spi.implementation.java.JavaMappedReference; -import org.apache.tuscany.spi.implementation.java.JavaMappedService; -import org.apache.tuscany.spi.implementation.java.PojoComponentType; - -import junit.framework.TestCase; -import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl; - -/** - * @version $Rev$ $Date$ - */ -public class HeuristicAndPropertyTestCase extends TestCase { - - private PropertyProcessor propertyProcessor; - private HeuristicPojoProcessor heuristicProcessor; - - /** - * Verifies the property and heuristic processors don't collide - */ - @SuppressWarnings("unchecked") - public void testPropertyProcessorWithHeuristicProcessor() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - Constructor ctor = Foo.class.getConstructor(String.class); - type.setConstructorDefinition(new ConstructorDefinition(ctor)); - propertyProcessor.visitConstructor(null, ctor, type, null); - heuristicProcessor.visitEnd(null, Foo.class, type, null); - assertEquals(1, type.getProperties().size()); - assertNotNull(type.getProperties().get("foo")); - } - - protected void setUp() throws Exception { - super.setUp(); - ImplementationProcessorServiceImpl service = - new ImplementationProcessorServiceImpl(new JavaInterfaceProcessorRegistryImpl()); - propertyProcessor = new PropertyProcessor(service); - heuristicProcessor = new HeuristicPojoProcessor(service); - } - - public static class Foo { - public Foo(@Property(name = "foo") String prop) { - } - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/HeuristicConstructorTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/HeuristicConstructorTestCase.java deleted file mode 100644 index 92f6d54366..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/HeuristicConstructorTestCase.java +++ /dev/null @@ -1,330 +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.processor; - -import org.osoa.sca.annotations.Property; -import org.osoa.sca.annotations.Reference; -import org.osoa.sca.annotations.Remotable; - -import org.apache.tuscany.spi.annotation.Autowire; -import org.apache.tuscany.spi.idl.java.JavaServiceContract; -import org.apache.tuscany.spi.implementation.java.JavaMappedProperty; -import org.apache.tuscany.spi.implementation.java.JavaMappedReference; -import org.apache.tuscany.spi.implementation.java.JavaMappedService; -import org.apache.tuscany.spi.implementation.java.PojoComponentType; -import org.apache.tuscany.spi.model.ServiceContract; - -import junit.framework.TestCase; -import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl; - -/** - * @version $Rev$ $Date$ - */ -public class HeuristicConstructorTestCase extends TestCase { - - private HeuristicPojoProcessor processor = - new HeuristicPojoProcessor(new ImplementationProcessorServiceImpl(new JavaInterfaceProcessorRegistryImpl())); - - /** - * Verifies a single constructor is chosen with a parameter as the type - */ - public void testSingleConstructorWithParam() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - JavaMappedProperty prop = new JavaMappedProperty(); - prop.setName("foo"); - prop.setJavaType(String.class); - type.getProperties().put("foo", prop); - processor.visitEnd(null, Foo1.class, type, null); - assertNotNull(type.getConstructorDefinition().getConstructor()); - assertEquals("foo", type.getConstructorDefinition().getInjectionNames().get(0)); - } - - /** - * Verifies a single constructor is chosen with a reference as the type - */ - public void testSingleConstructorWithRef() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - JavaMappedReference ref = new JavaMappedReference(); - ref.setName("foo"); - ServiceContract contract = new JavaServiceContract(String.class); - ref.setServiceContract(contract); - type.getReferences().put("foo", ref); - processor.visitEnd(null, Foo1.class, type, null); - assertNotNull(type.getConstructorDefinition().getConstructor()); - assertEquals("foo", type.getConstructorDefinition().getInjectionNames().get(0)); - } - - /** - * Verifies a single constructor is chosen with a property and a reference as the type - */ - public void testSingleConstructorWithPropRef() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - - JavaMappedProperty prop = new JavaMappedProperty(); - prop.setName("foo"); - prop.setJavaType(String.class); - type.getProperties().put("foo", prop); - - JavaMappedReference ref = new JavaMappedReference(); - ref.setName("ref"); - ServiceContract contract = new JavaServiceContract(Foo1.class); - ref.setServiceContract(contract); - type.getReferences().put("ref", ref); - processor.visitEnd(null, Foo2.class, type, null); - assertNotNull(type.getConstructorDefinition().getConstructor()); - assertEquals(2, type.getConstructorDefinition().getInjectionNames().size()); - } - - - public void testSingleConstructorResolvableParam() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - processor.visitEnd(null, Foo5.class, type, null); - assertEquals(String.class, type.getProperties().get("string").getJavaType()); - } - - public void testSingleConstructorResolvableRef() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - processor.visitEnd(null, Foo6.class, type, null); - assertEquals(Ref.class, - type.getReferences().get("heuristicconstructortestcase$ref").getServiceContract().getInterfaceClass()); - } - - public void testSingleConstructorAmbiguousRef() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - JavaMappedReference ref = new JavaMappedReference(); - ref.setName("ref"); - ServiceContract contract = new JavaServiceContract(Foo1.class); - ref.setServiceContract(contract); - type.getReferences().put("ref", ref); - JavaMappedReference ref2 = new JavaMappedReference(); - ref2.setName("ref2"); - ref2.setServiceContract(contract); - type.getReferences().put("ref2", ref2); - try { - processor.visitEnd(null, Foo4.class, type, null); - fail(); - } catch (AmbiguousConstructorException e) { - // expected - } - } - - public void testConstructorPropertyAnnotatedParamsOnly() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - processor.visitEnd(null, Foo7.class, type, null); - assertNotNull(type.getProperties().get("myProp")); - } - - public void testConstructorReferenceAnnotatedParamsOnly() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - processor.visitEnd(null, Foo8.class, type, null); - assertNotNull(type.getReferences().get("myRef")); - } - - public void testConstructorAutowireAnnotatedParamsOnly() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - processor.visitEnd(null, Foo9.class, type, null); - assertNotNull(type.getReferences().get("myAutowire")); - } - - @SuppressWarnings("unchecked") - public void testDefaultConstructor() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - processor.visitEnd(null, Foo3.class, type, null); - assertNotNull(type.getConstructorDefinition().getConstructor()); - } - - public void testSameTypesButAnnotated() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - processor.visitEnd(null, Foo12.class, type, null); - assertEquals(2, type.getProperties().size()); - assertNotNull(type.getProperties().get("prop1")); - assertNotNull(type.getProperties().get("prop2")); - } - - /** - * Verifies processing executes with additional extension annotations - */ - public void testRandomAnnotation() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - processor.visitEnd(null, Foo11.class, type, null); - assertEquals(1, type.getProperties().size()); - assertNotNull(type.getProperties().get("prop1")); - } - - public void testAutowire() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - processor.visitEnd(null, Foo13.class, type, null); - assertEquals(1, type.getReferences().size()); - assertNotNull(type.getReferences().get(String.class.getName() + "0")); - } - - public void testMultipleAutowire() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - processor.visitEnd(null, Foo15.class, type, null); - assertEquals(2, type.getReferences().size()); - assertNotNull(type.getReferences().get(String.class.getName() + "0")); - assertNotNull(type.getReferences().get(String.class.getName() + "1")); - } - - public void testNoAutowireNameInConstructor() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - processor.visitEnd(null, Foo16.class, type, null); - assertEquals(2, type.getReferences().size()); - assertNotNull(type.getReferences().get(String.class.getName() + "0")); - assertNotNull(type.getReferences().get("bar")); - assertNotNull(type.getProperties().get("foo")); - } - - public void testPrivateConstructor() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - try { - processor.visitEnd(null, Foo14.class, type, null); - fail(); - } catch (NoConstructorException e) { - // expected - } - } - - - public void testMultipleConstructors() throws Exception { - // throw new UnsupportedOperationException("Finish heuristic multiple constructors - Foo10"); - } - - - public static class Foo1 { - public Foo1(String val) { - } - } - - public static class Foo2 { - public Foo2(String val, Foo1 ref) { - } - } - - public static class Foo3 { - } - - public static class Foo4 { - public Foo4(Foo1 ref) { - } - } - - public static class Prop { - - } - - @Remotable - public static interface Ref { - - } - - public static class Foo5 { - public Foo5(String val) { - } - } - - public static class Foo6 { - public Foo6(Ref ref) { - } - } - - public static class Foo7 { - public Foo7(@Property(name = "myProp") String prop) { - } - } - - - public static class Foo8 { - public Foo8(@Reference(name = "myRef") String ref) { - } - } - - public static class Foo9 { - public Foo9(@Autowire(name = "myAutowire") String autowire) { - } - } - - public static class Foo10 { - - public Foo10() { - } - - public Foo10(String prop) { - } - - public Foo10(@Property(name = "prop1") String prop1, @Property(name = "prop2") String prop2) { - - } - } - - public static class Foo11 { - - public Foo11(@Property(name = "prop1") String prop, @Baz String baz) { - } - } - - public static class Foo12 { - - public Foo12(@Property(name = "prop1") String prop, @Property(name = "prop2") String baz) { - } - } - - public @interface Baz { - - } - - public static class Foo13 { - public Foo13(@Autowire String foo) { - } - } - - public static final class Foo14 { - private Foo14() { - } - } - - public static final class Foo15 { - public Foo15(@Autowire String param1, @Autowire String param2) { - } - } - - public static final class Foo16 { - public Foo16(@Autowire String param1, - @Property(name = "foo") String param2, - @Reference(name = "bar") String param3) { - } - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/HeuristicPojoProcessorTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/HeuristicPojoProcessorTestCase.java deleted file mode 100644 index 33a3fa0282..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/HeuristicPojoProcessorTestCase.java +++ /dev/null @@ -1,395 +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.processor; - -import java.lang.reflect.Constructor; -import java.util.Collection; -import java.util.List; - -import org.osoa.sca.annotations.Property; -import org.osoa.sca.annotations.Reference; -import org.osoa.sca.annotations.Remotable; -import org.osoa.sca.annotations.Service; - -import org.apache.tuscany.spi.databinding.extension.SimpleTypeMapperExtension; -import org.apache.tuscany.spi.implementation.java.ConstructorDefinition; -import org.apache.tuscany.spi.implementation.java.JavaMappedProperty; -import org.apache.tuscany.spi.implementation.java.JavaMappedReference; -import org.apache.tuscany.spi.implementation.java.JavaMappedService; -import org.apache.tuscany.spi.implementation.java.PojoComponentType; -import org.apache.tuscany.spi.implementation.java.ProcessingException; - -import junit.framework.TestCase; -import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl; - -/** - * Verfies component type information is properly introspected from an unadorned POJO according to the SCA Java Client - * and Implementation Model Specification - * - * @version $Rev$ $Date$ - */ -public class HeuristicPojoProcessorTestCase extends TestCase { - - private HeuristicPojoProcessor processor = - new HeuristicPojoProcessor(new ImplementationProcessorServiceImpl(new JavaInterfaceProcessorRegistryImpl())); - - /** - * Verifies a single service interface is computed when only one interface is implemented - */ - public void testSingleInterface() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - Constructor ctor = SingleInterfaceImpl.class.getConstructor(); - type.setConstructorDefinition(new ConstructorDefinition(ctor)); - processor.visitEnd(null, SingleInterfaceImpl.class, type, null); - assertEquals(1, type.getServices().size()); - assertEquals(PropertyInterface.class, - type.getServices().get(PropertyInterface.class.getName()) - .getServiceContract().getInterfaceClass()); - assertTrue(type.getProperties().isEmpty()); - assertTrue(type.getReferences().isEmpty()); - } - - /** - * Verifies property and reference setters are computed - */ - public void testPropertyReference() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - Constructor ctor = - SingleInterfaceWithPropertyReferenceImpl.class.getConstructor(); - type.setConstructorDefinition(new ConstructorDefinition(ctor)); - processor.visitEnd(null, SingleInterfaceWithPropertyReferenceImpl.class, type, null); - assertEquals(1, type.getServices().size()); - assertEquals(Interface1.class, - type.getServices().get(Interface1.class.getName()) - .getServiceContract().getInterfaceClass()); - assertEquals(1, type.getProperties().size()); - assertEquals(ComplexProperty.class, type.getProperties().get("property").getJavaType()); - assertEquals(1, type.getReferences().size()); - assertEquals(Ref.class, type.getReferences().get("reference").getServiceContract().getInterfaceClass()); - } - - /** - * Verifies that a property setter is not introspected if an analogous operation is in the service interface - */ - public void testPropertySetterInInterface() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - Constructor ctor = SingleInterfaceImpl.class.getConstructor(); - type.setConstructorDefinition(new ConstructorDefinition(ctor)); - processor.visitEnd(null, SingleInterfaceImpl.class, type, null); - assertEquals(0, type.getProperties().size()); - } - - /** - * Verifies that a reference setter is not introspected if an analogous operation is in the service interface - */ - public void testReferenceSetterInInterface() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - Constructor ctor = RefInterfaceImpl.class.getConstructor(); - type.setConstructorDefinition(new ConstructorDefinition(ctor)); - processor.visitEnd(null, RefInterfaceImpl.class, type, null); - assertEquals(0, type.getReferences().size()); - } - - /** - * Verifies collection generic types or array types are introspected as references according to spec rules - */ - public void testReferenceCollectionType() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - Constructor ctor = ReferenceCollectionImpl.class.getConstructor(); - type.setConstructorDefinition(new ConstructorDefinition(ctor)); - processor.visitEnd(null, ReferenceCollectionImpl.class, type, null); - assertEquals(0, type.getProperties().size()); - assertEquals(4, type.getReferences().size()); - } - - /** - * Verifies collection generic types or array types are introspected as properties according to spec rules - */ - public void testPropertyCollectionType() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - Constructor ctor = PropertyCollectionImpl.class.getConstructor(); - type.setConstructorDefinition(new ConstructorDefinition(ctor)); - processor.visitEnd(null, PropertyCollectionImpl.class, type, null); - assertEquals(0, type.getReferences().size()); - assertEquals(4, type.getProperties().size()); - } - - /** - * Verifies references are calculated when the type marked with is @Remotable - */ - public void testRemotableRef() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - Constructor ctor = RemotableRefImpl.class.getConstructor(); - type.setConstructorDefinition(new ConstructorDefinition(ctor)); - processor.visitEnd(null, RemotableRefImpl.class, type, null); - assertEquals(2, type.getReferences().size()); - assertEquals(0, type.getProperties().size()); - } - - public void testParentInterface() throws ProcessingException, NoSuchMethodException { - PojoComponentType> type = - new PojoComponentType>(); - Constructor ctor = Child.class.getConstructor(); - type.setConstructorDefinition(new ConstructorDefinition(ctor)); - processor.visitEnd(null, Child.class, type, null); - assertTrue(type.getServices().containsKey(Interface1.class.getName())); - } - - /** - * Verifies a service inteface is calculated when only props and refs are given - */ - public void testExcludedPropertyAndReference() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - JavaMappedReference ref = new JavaMappedReference(); - ref.setName("reference"); - type.add(ref); - JavaMappedReference ref2 = new JavaMappedReference(); - ref2.setName("reference2"); - type.add(ref2); - JavaMappedProperty prop1 = new JavaMappedProperty(); - prop1.setName("string1"); - type.add(prop1); - JavaMappedProperty prop2 = new JavaMappedProperty(); - prop2.setName("string2"); - type.add(prop2); - processor.visitEnd(null, MockService.class, type, null); - assertEquals(1, type.getServices().size()); - } - - public void testProtectedRemotableRefField() throws ProcessingException, NoSuchMethodException { - PojoComponentType> type = - new PojoComponentType>(); - Constructor ctor = ProtectedRemotableRefFieldImpl.class.getConstructor(); - type.setConstructorDefinition(new ConstructorDefinition(ctor)); - processor.visitEnd(null, ProtectedRemotableRefFieldImpl.class, type, null); - assertNotNull(type.getReferences().get("otherRef")); - } - - public void testProtectedRemotableRefMethod() throws ProcessingException, NoSuchMethodException { - PojoComponentType> type = - new PojoComponentType>(); - Constructor ctor = ProtectedRemotableRefMethodImpl.class.getConstructor(); - type.setConstructorDefinition(new ConstructorDefinition(ctor)); - processor.visitEnd(null, ProtectedRemotableRefMethodImpl.class, type, null); - assertNotNull(type.getReferences().get("otherRef")); - } - - public void testSetDataTypes() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - Constructor ctor = PropertyIntTypeOnConstructor.class.getConstructor(int.class); - type.setConstructorDefinition(new ConstructorDefinition(ctor)); - processor.visitEnd(null, ProtectedRemotableRefMethodImpl.class, type, null); - org.apache.tuscany.spi.model.Property foo = type.getProperties().get("foo"); - assertEquals(int.class, foo.getJavaType()); - assertEquals(SimpleTypeMapperExtension.XSD_INT, foo.getXmlType()); - } - - private static class PropertyIntTypeOnConstructor { - private int foo; - - public PropertyIntTypeOnConstructor(@Property(name = "foo")int foo) { - this.foo = foo; - } - - public int getFoo() { - return foo; - } - } - - private interface PropertyInterface { - void setString1(String val); - } - - private interface Interface1 { - } - - private static class Parent implements Interface1 { - - } - - private static class Child extends Parent { - public Child() { - } - - } - - private static class SingleInterfaceImpl implements PropertyInterface { - public SingleInterfaceImpl() { - } - - public void setString1(String val) { - } - - } - - private interface HeuristicServiceInterface { - void fooOperation(String ref); - - void setInvalid1(); // No parameter - - void setInvalid2(String str, int i); // More than one parameter - - String setInvalid3(String str); // return should be void - } - - public static class MockService implements PropertyInterface, RefInterface, HeuristicServiceInterface { - - @Property - public void setString1(String val) { - } - - @Property - public void setString2(String val) { - } - - @Reference - public void setReference(Ref ref) { - } - - @Reference - public void setReference2(Ref ref) { - } - - public void fooOperation(String ref) { - - } - - public void setInvalid1() { - } - - public void setInvalid2(String str, int i) { - } - - public String setInvalid3(String str) { - return null; - } - - } - - @Service - private interface Ref { - } - - private class ComplexProperty { - } - - private interface RefInterface { - void setReference(Ref ref); - } - - private static class RefInterfaceImpl implements RefInterface { - public RefInterfaceImpl() { - } - - public void setReference(Ref ref) { - } - } - - private static class SingleInterfaceWithPropertyReferenceImpl implements Interface1 { - public SingleInterfaceWithPropertyReferenceImpl() { - } - - public void setReference(Ref ref) { - } - - public void setProperty(ComplexProperty prop) { - } - } - - private static class ReferenceCollectionImpl implements Interface1 { - public ReferenceCollectionImpl() { - } - - public void setCollectionReference(Collection ref) { - } - - public void setNonGenericCollectionReference(Collection ref) { - } - - public void setListReference(List ref) { - } - - public void setArrayReference(Ref[] ref) { - } - } - - private static class PropertyCollectionImpl implements Interface1 { - public PropertyCollectionImpl() { - } - - public void setCollectionProperty(Collection prop) { - } - - public void setCollectionProperty2(Collection prop) { - } - - public void setArrayProperty(ComplexProperty[] prop) { - } - - public void setArrayProperty2(String[] prop) { - } - } - - @Remotable - private interface RemotableRef { - } - - private static class RemotableRefImpl implements Interface1 { - protected RemotableRef otherRef; - - public RemotableRefImpl() { - } - - public void setRef(RemotableRef ref) { - - } - } - - private static class ProtectedRemotableRefFieldImpl implements Interface1 { - protected RemotableRef otherRef; - - public ProtectedRemotableRefFieldImpl() { - } - - public ProtectedRemotableRefFieldImpl(RemotableRef otherRef) { - this.otherRef = otherRef; - } - - } - - private static class ProtectedRemotableRefMethodImpl implements Interface1 { - public ProtectedRemotableRefMethodImpl() { - } - - protected void setOtherRef(RemotableRef otherRef) { - } - - } - - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/HeutisticExtensibleConstructorTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/HeutisticExtensibleConstructorTestCase.java deleted file mode 100644 index 4e6c1063d8..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/HeutisticExtensibleConstructorTestCase.java +++ /dev/null @@ -1,129 +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.processor; - -import java.lang.reflect.Constructor; -import java.util.List; - -import org.apache.tuscany.spi.implementation.java.ConstructorDefinition; -import org.apache.tuscany.spi.implementation.java.JavaMappedProperty; -import org.apache.tuscany.spi.implementation.java.JavaMappedReference; -import org.apache.tuscany.spi.implementation.java.JavaMappedService; -import org.apache.tuscany.spi.implementation.java.PojoComponentType; - -import junit.framework.TestCase; -import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl; - -/** - * Verifies constructors that have extensible annotation types, i.e. that have parameters marked by annotations which - * are themselves processed by some other implementation processor - * - * @version $Rev$ $Date$ - */ -public class HeutisticExtensibleConstructorTestCase extends TestCase { - - private HeuristicPojoProcessor processor = - new HeuristicPojoProcessor(new ImplementationProcessorServiceImpl(new JavaInterfaceProcessorRegistryImpl())); - - /** - * Verifies heuristic processing can be called priot to an extension annotation processors being called. - */ - public void testBarAnnotationProcessedFirst() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - Constructor ctor = Foo.class.getConstructor(String.class, String.class); - ConstructorDefinition definition = new ConstructorDefinition(ctor); - type.setConstructorDefinition(definition); - JavaMappedProperty property = new JavaMappedProperty(); - property.setName("myBar"); - definition.getInjectionNames().add("myBar"); - type.getProperties().put("myBar", property); - processor.visitEnd(null, Foo.class, type, null); - assertEquals(2, type.getProperties().size()); - } - - /** - * Verifies heuristic processing can be called before an extension annotation processors is called. - *

      - * For example, given: - *

       Foo(@Bar String prop, @org.osoa.sca.annotations.Property(name = "foo") String prop2)
      - *

      - * Heuristic evaluation of @Property can occur prior to another implementation processor evaluating @Bar - * - * @throws Exception - */ - public void testBarAnnotationProcessedLast() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - processor.visitEnd(null, Foo.class, type, null); - - // now simulate process the bar impl - ConstructorDefinition definition = type.getConstructorDefinition(); - List injectionNames = definition.getInjectionNames(); - injectionNames.remove(0); - injectionNames.add(0, "mybar"); - type.getProperties().put("mybar", new JavaMappedProperty()); - - assertEquals(2, type.getProperties().size()); - assertEquals("foo", definition.getInjectionNames().get(1)); - } - - /** - * Verifies heuristic processing can be called before an extension annotation processors is called with the - * extension parameter in a middle position. Specifically, verifies that the heuristic processor updates injection - * names and preserves their ordering. - */ - public void testBarAnnotationProcessedFirstInMiddle() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - Constructor ctor = Foo2.class.getConstructor(String.class, String.class, String.class); - ConstructorDefinition definition = new ConstructorDefinition(ctor); - type.setConstructorDefinition(definition); - // insert placeholder for first param, which would be done by a processor - definition.getInjectionNames().add(""); - JavaMappedProperty property = new JavaMappedProperty(); - property.setName("myBar"); - definition.getInjectionNames().add("myBar"); - type.getProperties().put("myBar", property); - processor.visitEnd(null, Foo2.class, type, null); - assertEquals("baz", definition.getInjectionNames().get(0)); - assertEquals(2, type.getProperties().size()); - assertEquals(1, type.getReferences().size()); - } - - public @interface Bar { - - } - - public static class Foo { - public Foo(@Bar String prop, @org.osoa.sca.annotations.Property(name = "foo") String prop2) { - } - } - - public static class Foo2 { - public Foo2(@org.osoa.sca.annotations.Reference(name = "baz") String prop1, - @Bar String prop2, - @org.osoa.sca.annotations.Property(name = "foo") String prop3) { - } - } - - -} - - diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ImplementationProcessorServiceTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ImplementationProcessorServiceTestCase.java deleted file mode 100644 index 0ba3f20519..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ImplementationProcessorServiceTestCase.java +++ /dev/null @@ -1,108 +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.processor; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Constructor; -import java.util.ArrayList; -import java.util.List; - -import org.osoa.sca.annotations.Callback; -import org.osoa.sca.annotations.Property; -import org.osoa.sca.annotations.Remotable; -import org.osoa.sca.annotations.Scope; - -import org.apache.tuscany.spi.databinding.extension.SimpleTypeMapperExtension; -import org.apache.tuscany.spi.implementation.java.ImplementationProcessorService; -import org.apache.tuscany.spi.implementation.java.JavaMappedProperty; -import org.apache.tuscany.spi.implementation.java.JavaMappedReference; -import org.apache.tuscany.spi.implementation.java.JavaMappedService; -import org.apache.tuscany.spi.implementation.java.PojoComponentType; -import org.apache.tuscany.spi.model.InteractionScope; -import org.apache.tuscany.spi.model.ServiceContract; - -import junit.framework.TestCase; -import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl; - -/** - * @version $Rev$ $Date$ - */ -public class ImplementationProcessorServiceTestCase extends TestCase { - - private ImplementationProcessorService implService = - new ImplementationProcessorServiceImpl(new JavaInterfaceProcessorRegistryImpl()); - - public void testCreateConversationalService() throws Exception { - JavaMappedService service = implService.createService(Foo.class); - assertTrue(Foo.class.equals(service.getServiceContract().getInterfaceClass())); - assertTrue(service.isRemotable()); - assertEquals(InteractionScope.CONVERSATIONAL, service.getServiceContract().getInteractionScope()); - ServiceContract serviceContract = service.getServiceContract(); - assertTrue(Bar.class.equals(serviceContract.getCallbackClass())); - assertTrue("ImplementationProcessorServiceTestCase$Bar".equals(serviceContract.getCallbackName())); - } - - public void testCreateDefaultService() throws Exception { - JavaMappedService service = implService.createService(Baz.class); - assertTrue(Baz.class.equals(service.getServiceContract().getInterfaceClass())); - assertTrue(!service.isRemotable()); - assertEquals(InteractionScope.NONCONVERSATIONAL, service.getServiceContract().getInteractionScope()); - } - - public void testProcessParamProperty() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - Constructor ctor = PropertyClass.class.getConstructor(int.class); - Annotation[] paramAnnotations = ctor.getParameterAnnotations()[0]; - List injectionNames = new ArrayList(); - String[] names = new String[]{"foo"}; - implService.processParam(int.class, paramAnnotations, names, 0, type, injectionNames); - org.apache.tuscany.spi.model.Property property = type.getProperties().get("foo"); - assertEquals(int.class, property.getJavaType()); - assertEquals(SimpleTypeMapperExtension.XSD_INT, property.getXmlType()); - } - - - @Callback(Bar.class) - @Remotable - @Scope("CONVERSATION") - public interface Foo { - - } - - public interface Bar { - - } - - public interface Baz { - - } - - public static class PropertyClass { - private int foo; - - public PropertyClass(@Property(name = "foo") int foo) { - this.foo = foo; - } - - public int getFoo() { - return foo; - } - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ImplementationProcessorServiceUniqueTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ImplementationProcessorServiceUniqueTestCase.java deleted file mode 100644 index da45ed2d46..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ImplementationProcessorServiceUniqueTestCase.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.implementation.processor; - -import org.apache.tuscany.spi.implementation.java.ImplementationProcessorService; - -import junit.framework.TestCase; -import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl; - -/** - * @version $Rev$ $Date$ - */ -public class ImplementationProcessorServiceUniqueTestCase extends TestCase { - - private ImplementationProcessorService service = - new ImplementationProcessorServiceImpl(new JavaInterfaceProcessorRegistryImpl()); - - public void testUniquess1() throws Exception { - Class[] classes = new Class[2]; - classes[0] = String.class; - classes[1] = Integer.class; - assertTrue(service.areUnique(classes)); - } - - public void testUniquess2() throws Exception { - Class[] classes = new Class[2]; - classes[0] = String.class; - classes[1] = String.class; - assertFalse(service.areUnique(classes)); - } - - public void testUniquess3() throws Exception { - Class[] classes = new Class[1]; - classes[0] = String.class; - assertTrue(service.areUnique(classes)); - } - - public void testUniquess4() throws Exception { - Class[] classes = new Class[3]; - classes[0] = String.class; - classes[1] = Integer.class; - classes[2] = String.class; - assertFalse(service.areUnique(classes)); - } - - public void testUniquess5() throws Exception { - Class[] classes = new Class[0]; - assertTrue(service.areUnique(classes)); - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/InitProcessorTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/InitProcessorTestCase.java deleted file mode 100644 index 13fe7d003a..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/InitProcessorTestCase.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.implementation.processor; - -import java.lang.reflect.Method; - -import org.osoa.sca.annotations.Init; - -import org.apache.tuscany.spi.implementation.java.JavaMappedProperty; -import org.apache.tuscany.spi.implementation.java.JavaMappedReference; -import org.apache.tuscany.spi.implementation.java.JavaMappedService; -import org.apache.tuscany.spi.implementation.java.PojoComponentType; - -import junit.framework.TestCase; - -/** - * @version $Rev$ $Date$ - */ -public class InitProcessorTestCase extends TestCase { - - public void testInit() throws Exception { - InitProcessor processor = new InitProcessor(); - PojoComponentType> type = - new PojoComponentType>(); - Method method = InitProcessorTestCase.Foo.class.getMethod("init"); - processor.visitMethod(null, method, type, null); - assertNotNull(type.getInitMethod()); - assertEquals(0, type.getInitLevel()); - } - - public void testBadInit() throws Exception { - InitProcessor processor = new InitProcessor(); - PojoComponentType> type = - new PojoComponentType>(); - Method method = InitProcessorTestCase.Bar.class.getMethod("badInit", String.class); - try { - processor.visitMethod(null, method, type, null); - fail(); - } catch (IllegalInitException e) { - // expected - } - } - - public void testTwoInit() throws Exception { - InitProcessor processor = new InitProcessor(); - PojoComponentType> type = - new PojoComponentType>(); - Method method = InitProcessorTestCase.Bar.class.getMethod("init"); - Method method2 = InitProcessorTestCase.Bar.class.getMethod("init2"); - processor.visitMethod(null, method, type, null); - try { - processor.visitMethod(null, method2, type, null); - fail(); - } catch (DuplicateInitException e) { - // expected - } - } - - - private class Foo { - @Init - public void init() { - } - } - - - private class Bar { - @Init - public void init() { - } - - @Init - public void init2() { - } - - @Init - public void badInit(String foo) { - } - - - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/MonitorProcessorTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/MonitorProcessorTestCase.java deleted file mode 100644 index 8982fa3991..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/MonitorProcessorTestCase.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.implementation.processor; - -import java.lang.reflect.Constructor; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.util.Map; - -import org.apache.tuscany.spi.implementation.java.ConstructorDefinition; -import org.apache.tuscany.spi.implementation.java.JavaMappedProperty; -import org.apache.tuscany.spi.implementation.java.JavaMappedReference; -import org.apache.tuscany.spi.implementation.java.JavaMappedService; -import org.apache.tuscany.spi.implementation.java.PojoComponentType; -import org.apache.tuscany.spi.implementation.java.IllegalPropertyException; - -import junit.framework.TestCase; -import org.apache.tuscany.api.annotation.Monitor; -import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl; -import org.apache.tuscany.core.injection.SingletonObjectFactory; -import org.apache.tuscany.host.MonitorFactory; -import org.easymock.EasyMock; - -/** - * @version $Rev$ $Date$ - */ -public class MonitorProcessorTestCase extends TestCase { - - private MonitorProcessor processor; - private MonitorFactory monitorFactory; - - public void testSetter() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - Method method = Foo.class.getMethod("setMonitor", Foo.class); - EasyMock.expect(monitorFactory.getMonitor(EasyMock.eq(Foo.class))).andReturn(null); - EasyMock.replay(monitorFactory); - processor.visitMethod(null, method, type, null); - Map> properties = type.getProperties(); - assertTrue(properties.get("monitor").getDefaultValueFactory() instanceof SingletonObjectFactory); - EasyMock.verify(monitorFactory); - } - - - public void testBadSetter() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - Method method = BadMonitor.class.getMethod("setMonitor"); - try { - processor.visitMethod(null, method, type, null); - fail(); - } catch (IllegalPropertyException e) { - // expected - } - } - - public void testField() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - Field field = Foo.class.getDeclaredField("bar"); - EasyMock.expect(monitorFactory.getMonitor(EasyMock.eq(Foo.class))).andReturn(null); - EasyMock.replay(monitorFactory); - processor.visitField(null, field, type, null); - Map> properties = type.getProperties(); - assertTrue(properties.get("bar").getDefaultValueFactory() instanceof SingletonObjectFactory); - EasyMock.verify(monitorFactory); - } - - public void testConstructor() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - Constructor ctor = Bar.class.getConstructor(BazMonitor.class); - EasyMock.expect(monitorFactory.getMonitor(EasyMock.eq(BazMonitor.class))).andReturn(null); - EasyMock.replay(monitorFactory); - processor.visitConstructor(null, ctor, type, null); - Map> properties = type.getProperties(); - assertTrue( - properties.get(BazMonitor.class.getName()).getDefaultValueFactory() instanceof SingletonObjectFactory); - EasyMock.verify(monitorFactory); - } - - /** - * Verifies calling the monitor processor to evaluate a constructor can be done after a property parameter is - * processed - */ - public void testConstructorAfterProperty() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - Constructor ctor = Bar.class.getConstructor(String.class, BazMonitor.class); - EasyMock.expect(monitorFactory.getMonitor(EasyMock.eq(BazMonitor.class))).andReturn(null); - EasyMock.replay(monitorFactory); - ConstructorDefinition definition = new ConstructorDefinition(ctor); - JavaMappedProperty prop = new JavaMappedProperty(); - definition.getInjectionNames().add("prop"); - type.setConstructorDefinition(definition); - type.getProperties().put("prop", prop); - processor.visitConstructor(null, ctor, type, null); - Map> properties = type.getProperties(); - assertEquals(BazMonitor.class.getName(), definition.getInjectionNames().get(1)); - assertEquals(2, type.getProperties().size()); - String name = BazMonitor.class.getName(); - assertTrue(properties.get(name).getDefaultValueFactory() instanceof SingletonObjectFactory); - EasyMock.verify(monitorFactory); - } - - /** - * Verifies calling the monitor processor to evaluate a constructor can be done before a property parameter is - * processed - */ - public void testConstructorBeforeProperty() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - Constructor ctor = Bar.class.getConstructor(String.class, BazMonitor.class); - EasyMock.expect(monitorFactory.getMonitor(EasyMock.eq(BazMonitor.class))).andReturn(null); - EasyMock.replay(monitorFactory); - processor.visitConstructor(null, ctor, type, null); - Map> properties = type.getProperties(); - ConstructorDefinition definition = type.getConstructorDefinition(); - assertEquals(2, definition.getInjectionNames().size()); - assertEquals(BazMonitor.class.getName(), definition.getInjectionNames().get(1)); - String name = BazMonitor.class.getName(); - assertTrue(properties.get(name).getDefaultValueFactory() instanceof SingletonObjectFactory); - EasyMock.verify(monitorFactory); - } - - protected void setUp() throws Exception { - super.setUp(); - monitorFactory = EasyMock.createMock(MonitorFactory.class); - JavaInterfaceProcessorRegistryImpl registry = new JavaInterfaceProcessorRegistryImpl(); - ImplementationProcessorServiceImpl processor = new ImplementationProcessorServiceImpl(registry); - this.processor = new MonitorProcessor(monitorFactory, processor); - } - - private class Foo { - - @Monitor - protected Foo bar; - - @Monitor - public void setMonitor(Foo foo) { - } - } - - - private class BadMonitor { - - @Monitor - public void setMonitor() { - } - } - - private interface BazMonitor { - - } - - private static class Bar { - - public Bar(@Monitor BazMonitor monitor) { - } - - public Bar(String prop, @Monitor BazMonitor monitor) { - } - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/PropertyProcessorTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/PropertyProcessorTestCase.java deleted file mode 100644 index 412c9f9d36..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/PropertyProcessorTestCase.java +++ /dev/null @@ -1,156 +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.processor; - -import static org.apache.tuscany.spi.model.OverrideOptions.MUST; -import junit.framework.TestCase; - -import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl; -import org.apache.tuscany.spi.implementation.java.DuplicatePropertyException; -import org.apache.tuscany.spi.implementation.java.IllegalPropertyException; -import org.apache.tuscany.spi.implementation.java.JavaMappedProperty; -import org.apache.tuscany.spi.implementation.java.JavaMappedReference; -import org.apache.tuscany.spi.implementation.java.JavaMappedService; -import org.apache.tuscany.spi.implementation.java.PojoComponentType; -import org.apache.tuscany.spi.model.OverrideOptions; -import org.osoa.sca.annotations.Property; - -/** - * @version $Rev$ $Date$ - */ -public class PropertyProcessorTestCase extends TestCase { - - PojoComponentType> type; - PropertyProcessor processor; - - public void testMethodAnnotation() throws Exception { - processor.visitMethod(null, Foo.class.getMethod("setFoo", String.class), type, null); - assertNotNull(type.getProperties().get("foo")); - } - - public void testMethodRequired() throws Exception { - processor.visitMethod(null, Foo.class.getMethod("setFooRequired", String.class), type, null); - JavaMappedProperty prop = type.getProperties().get("fooRequired"); - assertNotNull(prop); - assertEquals(prop.getOverride(), MUST); - } - - public void testMethodName() throws Exception { - processor.visitMethod(null, Foo.class.getMethod("setBarMethod", String.class), type, null); - assertNotNull(type.getProperties().get("bar")); - } - - public void testFieldAnnotation() throws Exception { - processor.visitField(null, Foo.class.getDeclaredField("baz"), type, null); - assertNotNull(type.getProperties().get("baz")); - } - - public void testFieldRequired() throws Exception { - processor.visitField(null, Foo.class.getDeclaredField("bazRequired"), type, null); - JavaMappedProperty prop = type.getProperties().get("bazRequired"); - assertNotNull(prop); - assertEquals(prop.getOverride(), OverrideOptions.MUST); - } - - public void testFieldName() throws Exception { - processor.visitField(null, Foo.class.getDeclaredField("bazField"), type, null); - assertNotNull(type.getProperties().get("theBaz")); - } - - public void testDuplicateFields() throws Exception { - processor.visitField(null, Bar.class.getDeclaredField("dup"), type, null); - try { - processor.visitField(null, Bar.class.getDeclaredField("baz"), type, null); - fail(); - } catch (DuplicatePropertyException e) { - // expected - } - } - - public void testDuplicateMethods() throws Exception { - processor.visitMethod(null, Bar.class.getMethod("dupMethod", String.class), type, null); - try { - processor.visitMethod(null, Bar.class.getMethod("dupSomeMethod", String.class), type, null); - fail(); - } catch (DuplicatePropertyException e) { - // expected - } - } - - public void testInvalidProperty() throws Exception { - try { - processor.visitMethod(null, Bar.class.getMethod("badMethod"), type, null); - fail(); - } catch (IllegalPropertyException e) { - // expected - } - } - - protected void setUp() throws Exception { - super.setUp(); - type = new PojoComponentType>(); - JavaInterfaceProcessorRegistryImpl registry = new JavaInterfaceProcessorRegistryImpl(); - processor = new PropertyProcessor(new ImplementationProcessorServiceImpl(registry)); - } - - private class Foo { - - @Property - protected String baz; - @Property(override = "must") - protected String bazRequired; - @Property(name = "theBaz") - protected String bazField; - - @Property - public void setFoo(String string) { - } - - @Property(override = "must") - public void setFooRequired(String string) { - } - - @Property(name = "bar") - public void setBarMethod(String string) { - } - - } - - private class Bar { - - @Property - protected String dup; - - @Property(name = "dup") - protected String baz; - - @Property - public void dupMethod(String s) { - } - - @Property(name = "dupMethod") - public void dupSomeMethod(String s) { - } - - @Property - public void badMethod() { - } - - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ReferenceProcessorTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ReferenceProcessorTestCase.java deleted file mode 100644 index e60cf58fb5..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ReferenceProcessorTestCase.java +++ /dev/null @@ -1,173 +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.processor; - -import org.osoa.sca.annotations.Reference; - -import org.apache.tuscany.spi.implementation.java.JavaMappedProperty; -import org.apache.tuscany.spi.implementation.java.JavaMappedReference; -import org.apache.tuscany.spi.implementation.java.JavaMappedService; -import org.apache.tuscany.spi.implementation.java.PojoComponentType; -import org.apache.tuscany.spi.model.ServiceContract; - -import junit.framework.TestCase; -import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl; - -/** - * @version $Rev$ $Date$ - */ -public class ReferenceProcessorTestCase extends TestCase { - - PojoComponentType> type = - new PojoComponentType>(); - ReferenceProcessor processor = - new ReferenceProcessor(new JavaInterfaceProcessorRegistryImpl()); - - public void testMethodAnnotation() throws Exception { - processor.visitMethod(null, ReferenceProcessorTestCase.Foo.class.getMethod("setFoo", Ref.class), type, null); - JavaMappedReference reference = type.getReferences().get("foo"); - assertNotNull(reference); - ServiceContract contract = reference.getServiceContract(); - assertEquals(Ref.class, contract.getInterfaceClass()); - assertEquals("ReferenceProcessorTestCase$Ref", contract.getInterfaceName()); - } - - public void testMethodRequired() throws Exception { - processor - .visitMethod(null, ReferenceProcessorTestCase.Foo.class.getMethod("setFooRequired", Ref.class), type, null); - JavaMappedReference prop = type.getReferences().get("fooRequired"); - assertNotNull(prop); - assertTrue(prop.isRequired()); - } - - public void testMethodName() throws Exception { - processor - .visitMethod(null, ReferenceProcessorTestCase.Foo.class.getMethod("setBarMethod", Ref.class), type, null); - assertNotNull(type.getReferences().get("bar")); - } - - public void testFieldAnnotation() throws Exception { - processor.visitField(null, ReferenceProcessorTestCase.Foo.class.getDeclaredField("baz"), type, null); - JavaMappedReference reference = type.getReferences().get("baz"); - assertNotNull(reference); - ServiceContract contract = reference.getServiceContract(); - assertEquals(Ref.class, contract.getInterfaceClass()); - assertEquals("ReferenceProcessorTestCase$Ref", contract.getInterfaceName()); - } - - public void testFieldRequired() throws Exception { - processor.visitField(null, ReferenceProcessorTestCase.Foo.class.getDeclaredField("bazRequired"), type, null); - JavaMappedReference prop = type.getReferences().get("bazRequired"); - assertNotNull(prop); - assertTrue(prop.isRequired()); - } - - public void testFieldName() throws Exception { - processor.visitField(null, ReferenceProcessorTestCase.Foo.class.getDeclaredField("bazField"), type, null); - assertNotNull(type.getReferences().get("theBaz")); - } - - public void testDuplicateFields() throws Exception { - processor.visitField(null, ReferenceProcessorTestCase.Bar.class.getDeclaredField("dup"), type, null); - try { - processor.visitField(null, ReferenceProcessorTestCase.Bar.class.getDeclaredField("baz"), type, null); - fail(); - } catch (DuplicateReferenceException e) { - //expected - } - } - - public void testDuplicateMethods() throws Exception { - processor.visitMethod(null, ReferenceProcessorTestCase.Bar.class.getMethod("dupMethod", Ref.class), type, null); - try { - processor - .visitMethod(null, ReferenceProcessorTestCase.Bar.class.getMethod("dupSomeMethod", Ref.class), type, - null); - fail(); - } catch (DuplicateReferenceException e) { - //expected - } - } - - public void testInvalidProperty() throws Exception { - try { - processor.visitMethod(null, ReferenceProcessorTestCase.Bar.class.getMethod("badMethod"), type, null); - fail(); - } catch (IllegalReferenceException e) { - //expected - } - } - - protected void setUp() throws Exception { - super.setUp(); - type = new PojoComponentType>(); - processor = new ReferenceProcessor(new JavaInterfaceProcessorRegistryImpl()); - } - - private interface Ref { - } - - private class Foo { - - @Reference - protected Ref baz; - @Reference(required = true) - protected Ref bazRequired; - @Reference(name = "theBaz") - protected Ref bazField; - - - @Reference - public void setFoo(Ref ref) { - } - - @Reference(required = true) - public void setFooRequired(Ref ref) { - } - - @Reference(name = "bar") - public void setBarMethod(Ref ref) { - } - - } - - - private class Bar { - - @Reference - protected Ref dup; - - @Reference(name = "dup") - protected Ref baz; - - @Reference - public void dupMethod(Ref s) { - } - - @Reference(name = "dupMethod") - public void dupSomeMethod(Ref s) { - } - - @Reference - public void badMethod() { - } - - - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ResourceProcessorTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ResourceProcessorTestCase.java deleted file mode 100644 index 809a50f702..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ResourceProcessorTestCase.java +++ /dev/null @@ -1,99 +0,0 @@ -package org.apache.tuscany.core.implementation.processor; - -import java.lang.reflect.Field; -import java.lang.reflect.Method; - -import org.apache.tuscany.spi.implementation.java.JavaMappedProperty; -import org.apache.tuscany.spi.implementation.java.JavaMappedReference; -import org.apache.tuscany.spi.implementation.java.JavaMappedService; -import org.apache.tuscany.spi.implementation.java.PojoComponentType; -import org.apache.tuscany.spi.implementation.java.Resource; - -import junit.framework.TestCase; - -/** - * @version $Rev$ $Date$ - */ -public class ResourceProcessorTestCase extends TestCase { - - PojoComponentType> type; - ResourceProcessor processor = new ResourceProcessor(); - - public void testVisitField() throws Exception { - Field field = Foo.class.getDeclaredField("bar"); - processor.visitField(null, field, type, null); - Resource resource = type.getResources().get("bar"); - assertFalse(resource.isOptional()); - assertNull(resource.getMappedName()); - assertEquals(field.getType(), resource.getType()); - } - - public void testVisitMethod() throws Exception { - Method method = Foo.class.getMethod("setBar", Bar.class); - processor.visitMethod(null, method, type, null); - Resource resource = type.getResources().get("bar"); - assertFalse(resource.isOptional()); - assertNull(resource.getMappedName()); - assertEquals(method.getParameterTypes()[0], resource.getType()); - } - - public void testVisitNamedMethod() throws Exception { - Method method = Foo.class.getMethod("setBar2", Bar.class); - processor.visitMethod(null, method, type, null); - Resource resource = type.getResources().get("someName"); - assertFalse(resource.isOptional()); - assertEquals("mapped", resource.getMappedName()); - } - - public void testVisitBadMethod() throws Exception { - Method method = Foo.class.getMethod("setBad"); - try { - processor.visitMethod(null, method, type, null); - fail(); - } catch (IllegalResourceException e) { - // expected - } - } - - public void testDuplicateResources() throws Exception { - Field field = Foo.class.getDeclaredField("bar"); - processor.visitField(null, field, type, null); - try { - processor.visitField(null, field, type, null); - fail(); - } catch (DuplicateResourceException e) { - //expected - } - } - - protected void setUp() throws Exception { - super.setUp(); - type = new PojoComponentType>(); - } - - private class Foo { - - @org.osoa.sca.annotations.Resource - protected Bar bar; - - @org.osoa.sca.annotations.Resource(optional = true) - protected Bar barNotRequired; - - @org.osoa.sca.annotations.Resource - public void setBar(Bar bar) { - } - - @org.osoa.sca.annotations.Resource(name = "someName", mappedName = "mapped") - public void setBar2(Bar bar) { - } - - @org.osoa.sca.annotations.Resource - public void setBad() { - } - - } - - private interface Bar { - - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ScopeProcessorTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ScopeProcessorTestCase.java deleted file mode 100644 index dc65dc44f4..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ScopeProcessorTestCase.java +++ /dev/null @@ -1,128 +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.processor; - -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.implementation.java.JavaMappedProperty; -import org.apache.tuscany.spi.implementation.java.JavaMappedReference; -import org.apache.tuscany.spi.implementation.java.JavaMappedService; -import org.apache.tuscany.spi.implementation.java.PojoComponentType; -import org.apache.tuscany.spi.implementation.java.ProcessingException; -import org.apache.tuscany.spi.model.Scope; - -import junit.framework.TestCase; -import org.easymock.EasyMock; - -/** - * @version $Rev$ $Date$ - */ -public class ScopeProcessorTestCase extends TestCase { - - CompositeComponent parent; - - public void testCompositeScope() throws ProcessingException { - ScopeProcessor processor = new ScopeProcessor(); - PojoComponentType> type = - new PojoComponentType>(); - - processor.visitClass(parent, Composite.class, type, null); - assertEquals(Scope.COMPOSITE, type.getImplementationScope()); - } - - public void testSessionScope() throws ProcessingException { - ScopeProcessor processor = new ScopeProcessor(); - PojoComponentType> type = - new PojoComponentType>(); - processor.visitClass(parent, Session.class, type, null); - assertEquals(Scope.SESSION, type.getImplementationScope()); - } - - public void testConversationalScope() throws ProcessingException { - ScopeProcessor processor = new ScopeProcessor(); - PojoComponentType> type = - new PojoComponentType>(); - processor.visitClass(parent, Conversation.class, type, null); - assertEquals(Scope.CONVERSATION, type.getImplementationScope()); - } - - public void testRequestScope() throws ProcessingException { - ScopeProcessor processor = new ScopeProcessor(); - PojoComponentType> type = - new PojoComponentType>(); - processor.visitClass(parent, Request.class, type, null); - assertEquals(Scope.REQUEST, type.getImplementationScope()); - } - - public void testSystemScope() throws ProcessingException { - ScopeProcessor processor = new ScopeProcessor(); - PojoComponentType> type = - new PojoComponentType>(); - processor.visitClass(parent, System.class, type, null); - assertEquals(Scope.SYSTEM, type.getImplementationScope()); - } - - public void testStatelessScope() throws ProcessingException { - ScopeProcessor processor = new ScopeProcessor(); - PojoComponentType> type = - new PojoComponentType>(); - processor.visitClass(parent, Stateless.class, type, null); - assertEquals(Scope.STATELESS, type.getImplementationScope()); - } - - public void testNoScope() throws ProcessingException { - ScopeProcessor processor = new ScopeProcessor(); - PojoComponentType> type = - new PojoComponentType>(); - processor.visitClass(parent, None.class, type, null); - assertEquals(Scope.STATELESS, type.getImplementationScope()); - } - - protected void setUp() throws Exception { - super.setUp(); - parent = EasyMock.createNiceMock(CompositeComponent.class); - } - - @org.osoa.sca.annotations.Scope("COMPOSITE") - private class Composite { - } - - @org.osoa.sca.annotations.Scope("SESSION") - private class Session { - } - - @org.osoa.sca.annotations.Scope("CONVERSATION") - private class Conversation { - } - - @org.osoa.sca.annotations.Scope("REQUEST") - private class Request { - } - - @org.osoa.sca.annotations.Scope("SYSTEM") - private class System { - } - - @org.osoa.sca.annotations.Scope("STATELESS") - private class Stateless { - } - - private class None { - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ServiceCallbackTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ServiceCallbackTestCase.java deleted file mode 100644 index 3489c364e0..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ServiceCallbackTestCase.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.implementation.processor; - -import java.lang.reflect.Field; -import java.lang.reflect.Method; - -import org.osoa.sca.annotations.Callback; -import org.osoa.sca.annotations.Service; - -import org.apache.tuscany.spi.implementation.java.JavaMappedProperty; -import org.apache.tuscany.spi.implementation.java.JavaMappedReference; -import org.apache.tuscany.spi.implementation.java.JavaMappedService; -import org.apache.tuscany.spi.implementation.java.PojoComponentType; -import org.apache.tuscany.spi.implementation.java.ProcessingException; - -import junit.framework.TestCase; -import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl; -import org.apache.tuscany.core.idl.java.IllegalCallbackException; - -/** - * @version $Rev$ $Date$ - */ -public class ServiceCallbackTestCase extends TestCase { - - ServiceProcessor processor = - new ServiceProcessor(new ImplementationProcessorServiceImpl(new JavaInterfaceProcessorRegistryImpl())); - - public void testMethodCallbackInterface() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - processor.visitClass(null, FooImpl.class, type, null); - JavaMappedService service = type.getServices().get(Foo.class.getName()); - assertNotNull(service); - Method method = FooImpl.class.getMethod("setCallback", FooCallback.class); - processor.visitMethod(null, method, type, null); - assertEquals(method, service.getCallbackMember()); - } - - public void testFieldCallbackInterface() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - processor.visitClass(null, FooImpl.class, type, null); - JavaMappedService service = type.getServices().get(Foo.class.getName()); - assertNotNull(service); - Field field = FooImpl.class.getDeclaredField("callback"); - processor.visitField(null, field, type, null); - assertEquals(field, service.getCallbackMember()); - } - - public void testMethodDoesNotMatchCallback() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - processor.visitClass(null, BadBarImpl.class, type, null); - Method method = BadBarImpl.class.getMethod("setWrongInterfaceCallback", String.class); - try { - processor.visitMethod(null, method, type, null); - fail(); - } catch (IllegalCallbackReferenceException e) { - // expected - } - } - - public void testNoParamCallback() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - processor.visitClass(null, BadBarImpl.class, type, null); - Method method = BadBarImpl.class.getMethod("setNoParamCallback"); - try { - processor.visitMethod(null, method, type, null); - fail(); - } catch (IllegalCallbackReferenceException e) { - // expected - } - } - - public void testFieldDoesNotMatchCallback() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - processor.visitClass(null, BadBarImpl.class, type, null); - Field field = BadBarImpl.class.getDeclaredField("wrongInterfaceCallback"); - try { - processor.visitField(null, field, type, null); - fail(); - } catch (IllegalCallbackReferenceException e) { - // expected - } - } - - public void testBadCallbackInterfaceAnnotation() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - try { - processor.visitClass(null, BadFooImpl.class, type, null); - fail(); - } catch (ProcessingException e) { - // expected - assertTrue(e.getCause() instanceof IllegalCallbackException); - } - } - - @Callback(FooCallback.class) - private interface Foo { - - } - - private interface FooCallback { - - } - - @Service(Foo.class) - private static class FooImpl implements Foo { - - @Callback - protected FooCallback callback; - - @Callback - public void setCallback(FooCallback cb) { - - } - } - - private static class BadBarImpl implements Foo { - @Callback - protected String wrongInterfaceCallback; - - @Callback - public void setWrongInterfaceCallback(String cb) { - - } - - @Callback - public void setNoParamCallback() { - - } - - } - - @Callback - private interface BadFoo { - - } - - @Service(BadFoo.class) - private static class BadFooImpl implements BadFoo { - - } - - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ServiceProcessorTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ServiceProcessorTestCase.java deleted file mode 100644 index 2ec1620eb6..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ServiceProcessorTestCase.java +++ /dev/null @@ -1,136 +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.processor; - -import org.osoa.sca.annotations.Callback; -import org.osoa.sca.annotations.Remotable; -import org.osoa.sca.annotations.Service; - -import org.apache.tuscany.spi.implementation.java.JavaMappedProperty; -import org.apache.tuscany.spi.implementation.java.JavaMappedReference; -import org.apache.tuscany.spi.implementation.java.JavaMappedService; -import org.apache.tuscany.spi.implementation.java.PojoComponentType; -import org.apache.tuscany.spi.model.ServiceContract; - -import junit.framework.TestCase; -import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl; - -/** - * @version $Rev$ $Date$ - */ -public class ServiceProcessorTestCase extends TestCase { - private ServiceProcessor processor; - private PojoComponentType> type; - - public void testMultipleInterfaces() throws Exception { - processor.visitClass(null, FooMultiple.class, type, null); - assertEquals(2, type.getServices().size()); - JavaMappedService service = type.getServices().get(Baz.class.getName()); - ServiceContract contract = service.getServiceContract(); - assertEquals(Baz.class, contract.getInterfaceClass()); - assertEquals(Bar.class, contract.getCallbackClass()); - assertEquals("ServiceProcessorTestCase$Bar", contract.getCallbackName()); - assertNotNull(type.getServices().get(Bar.class.getName())); - } - - public void testSingleInterfaces() throws Exception { - processor.visitClass(null, FooSingle.class, type, null); - assertEquals(1, type.getServices().size()); - assertNotNull(type.getServices().get(Baz.class.getName())); - } - - public void testMultipleNoService() throws Exception { - processor.visitClass(null, FooMultipleNoService.class, type, null); - assertEquals(0, type.getServices().size()); - } - - public void testRemotableNoService() throws Exception { - processor.visitClass(null, FooRemotableNoService.class, type, null); - assertEquals(1, type.getServices().size()); - JavaMappedService service = type.getServices().get(BazRemotable.class.getName()); - ServiceContract contract = service.getServiceContract(); - assertEquals(BazRemotable.class, contract.getInterfaceClass()); - } - - public void testNonInterface() throws Exception { - try { - processor.visitClass(null, BadImpl.class, type, null); - fail(); - } catch (InvalidServiceType e) { - //expected - } - } - - public void testNoInterfaces() throws Exception { - try { - processor.visitClass(null, BadDefinition.class, type, null); - fail(); - } catch (IllegalServiceDefinitionException e) { - //expected - } - } - - protected void setUp() throws Exception { - super.setUp(); - JavaInterfaceProcessorRegistryImpl registry = new JavaInterfaceProcessorRegistryImpl(); - processor = new ServiceProcessor(new ImplementationProcessorServiceImpl(registry)); - type = new PojoComponentType>(); - } - - @Callback(Bar.class) - private interface Baz { - } - - private interface Bar { - } - - @Remotable - private interface BazRemotable { - } - - @Service(interfaces = {Baz.class, Bar.class}) - private class FooMultiple implements Baz, Bar { - - } - - @Service(Baz.class) - private class FooSingle implements Baz, Bar { - - } - - private class FooMultipleNoService implements Baz, Bar { - - } - - private class FooRemotableNoService implements BazRemotable, Bar { - - } - - @Service(FooSingle.class) - private class BadImpl extends FooSingle { - - } - - - @Service() - private class BadDefinition extends FooSingle { - - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/system/builder/SystemComponentBuilderResourceTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/system/builder/SystemComponentBuilderResourceTestCase.java deleted file mode 100644 index 1199e5fc06..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/system/builder/SystemComponentBuilderResourceTestCase.java +++ /dev/null @@ -1,75 +0,0 @@ -package org.apache.tuscany.core.implementation.system.builder; - -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.component.ScopeContainer; -import org.apache.tuscany.spi.component.ScopeRegistry; -import org.apache.tuscany.spi.component.AtomicComponent; -import org.apache.tuscany.spi.deployer.DeploymentContext; -import org.apache.tuscany.spi.implementation.java.ConstructorDefinition; -import org.apache.tuscany.spi.implementation.java.PojoComponentType; -import org.apache.tuscany.spi.implementation.java.Resource; -import org.apache.tuscany.spi.model.ComponentDefinition; -import org.apache.tuscany.spi.model.Property; -import org.apache.tuscany.spi.model.ReferenceDefinition; -import org.apache.tuscany.spi.model.Scope; -import org.apache.tuscany.spi.model.ServiceDefinition; -import org.apache.tuscany.spi.wire.InboundWire; - -import junit.framework.TestCase; -import org.apache.tuscany.core.implementation.system.model.SystemImplementation; -import org.easymock.EasyMock; - -/** - * @version $Rev$ $Date$ - */ -public class SystemComponentBuilderResourceTestCase extends TestCase { - - @SuppressWarnings("uncjecked") - public void testResourceInjection() throws Exception { - ScopeContainer container = EasyMock.createNiceMock(ScopeContainer.class); - DeploymentContext ctx = EasyMock.createNiceMock(DeploymentContext.class); - ScopeRegistry registry = EasyMock.createMock(ScopeRegistry.class); - EasyMock.expect(registry.getScopeContainer(Scope.STATELESS)).andReturn(container); - EasyMock.replay(registry); - SystemComponentBuilder builder = new SystemComponentBuilder(); - builder.setScopeRegistry(registry); - ConstructorDefinition ctorDef = new ConstructorDefinition( - SystemComponentBuilderResourceTestCase.Foo.class.getConstructor()); - PojoComponentType> type = - new PojoComponentType>(); - Resource resource = new Resource(); - resource.setType(String.class); - resource.setName("resource"); - resource.setMember(SystemComponentBuilderResourceTestCase.Foo.class.getDeclaredField("resource")); - type.add(resource); - type.setImplementationScope(Scope.STATELESS); - type.setConstructorDefinition(ctorDef); - SystemImplementation impl = new SystemImplementation(); - impl.setImplementationClass(SystemComponentBuilderResourceTestCase.Foo.class); - impl.setComponentType(type); - ComponentDefinition definition = - new ComponentDefinition("foo", impl); - - InboundWire wire = EasyMock.createMock(InboundWire.class); - EasyMock.expect(wire.getTargetService()).andReturn("result"); - EasyMock.replay(wire); - - CompositeComponent parent = EasyMock.createMock(CompositeComponent.class); - EasyMock.expect(parent.resolveSystemAutowire(String.class)).andReturn(wire); - EasyMock.replay(parent); - AtomicComponent component = builder.build(parent, definition, ctx); - SystemComponentBuilderResourceTestCase.Foo foo = - (SystemComponentBuilderResourceTestCase.Foo) component.createInstance(); - assertEquals("result", foo.resource); - EasyMock.verify(parent); - } - - private static class Foo { - - protected String resource; - - public Foo() { - } - - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/system/component/SystemAtomicComponentTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/system/component/SystemAtomicComponentTestCase.java deleted file mode 100644 index b8789cb8b4..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/system/component/SystemAtomicComponentTestCase.java +++ /dev/null @@ -1,124 +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.system.component; - -import org.apache.tuscany.spi.wire.OutboundWire; - -import junit.framework.TestCase; -import org.apache.tuscany.core.implementation.PojoConfiguration; -import org.apache.tuscany.core.injection.EventInvoker; -import org.apache.tuscany.core.injection.MethodEventInvoker; -import org.apache.tuscany.core.injection.PojoObjectFactory; -import org.apache.tuscany.core.injection.SingletonObjectFactory; -import org.easymock.EasyMock; - -/** - * Verifies a system atomic component can be started and initialized - * - * @version $$Rev$$ $$Date$$ - */ -public class SystemAtomicComponentTestCase extends TestCase { - - private EventInvoker initInvoker; - private EventInvoker destroyInvoker; - - public void testDefaultCreationAndInit() throws Exception { - PojoObjectFactory factory = new PojoObjectFactory(Foo.class.getConstructor((Class[]) null)); - PojoConfiguration configuration = new PojoConfiguration(); - configuration.setInstanceFactory(factory); - configuration.setInitInvoker(initInvoker); - configuration.setName("foo"); - SystemAtomicComponentImpl component = new SystemAtomicComponentImpl(configuration); - Foo foo = (Foo) component.createInstance(); - component.init(foo); - assertTrue(foo.initialized); - } - - public void testDestroy() throws Exception { - PojoObjectFactory factory = new PojoObjectFactory(Foo.class.getConstructor((Class[]) null)); - PojoConfiguration configuration = new PojoConfiguration(); - configuration.setInstanceFactory(factory); - configuration.setDestroyInvoker(destroyInvoker); - configuration.setName("foo"); - SystemAtomicComponentImpl component = new SystemAtomicComponentImpl(configuration); - Foo foo = (Foo) component.createInstance(); - component.destroy(foo); - assertTrue(foo.destroyed); - } - - public void testReferenceAndPropertyConstructor() throws Exception { - PojoObjectFactory factory = new PojoObjectFactory(Bar.class.getConstructor(String.class, Foo.class)); - PojoConfiguration configuration = new PojoConfiguration(); - configuration.setInstanceFactory(factory); - configuration.setInitInvoker(initInvoker); - configuration.addConstructorParamName("foo"); - configuration.addConstructorParamType(String.class); - configuration.addConstructorParamName("ref"); - configuration.addConstructorParamType(Foo.class); - configuration.setName("foo"); - SystemAtomicComponentImpl component = new SystemAtomicComponentImpl(configuration); - component.addPropertyFactory("foo", new SingletonObjectFactory("baz")); - Foo target = new Foo(); - OutboundWire wire = EasyMock.createMock(OutboundWire.class); - EasyMock.expect(wire.getTargetService()).andReturn(target); - EasyMock.expect(wire.getReferenceName()).andReturn("ref").anyTimes(); - EasyMock.replay(wire); - component.addOutboundWire(wire); - Bar bar = (Bar) component.createInstance(); - assertEquals("baz", bar.foo); - assertEquals(target, bar.ref); - EasyMock.verify(wire); - } - - protected void setUp() throws Exception { - super.setUp(); - initInvoker = new MethodEventInvoker(Foo.class.getMethod("init")); - destroyInvoker = new MethodEventInvoker(Foo.class.getMethod("destroy")); - } - - protected void tearDown() throws Exception { - super.tearDown(); - } - - public static class Foo { - private boolean initialized; - private boolean destroyed; - - public void init() { - initialized = true; - } - - public void destroy() { - destroyed = true; - } - } - - public static class Bar { - - private String foo; - private Foo ref; - - public Bar(String foo, Foo ref) { - this.foo = foo; - this.ref = ref; - } - } - - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/system/component/SystemAtomicComponentWireInvocationTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/system/component/SystemAtomicComponentWireInvocationTestCase.java deleted file mode 100644 index c4a2664228..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/system/component/SystemAtomicComponentWireInvocationTestCase.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.implementation.system.component; - -import org.apache.tuscany.spi.component.AtomicComponent; -import org.apache.tuscany.spi.wire.OutboundWire; - -import junit.framework.TestCase; -import org.apache.tuscany.core.component.scope.CompositeScopeContainer; -import org.apache.tuscany.core.implementation.PojoConfiguration; -import org.apache.tuscany.core.injection.PojoObjectFactory; -import org.apache.tuscany.core.mock.component.Source; -import org.apache.tuscany.core.mock.component.SourceImpl; -import org.apache.tuscany.core.mock.component.Target; -import org.apache.tuscany.core.mock.component.TargetImpl; -import org.easymock.EasyMock; - -/** - * Tests reference wires are injected properly into system component instances - * - * @version $$Rev$$ $$Date$$ - */ -public class SystemAtomicComponentWireInvocationTestCase extends TestCase { - - public void testWireResolution() throws Exception { - CompositeScopeContainer scope = new CompositeScopeContainer(null); - scope.start(); - Target target = new TargetImpl(); - PojoConfiguration configuration = new PojoConfiguration(); - configuration.addReferenceSite("setTarget", SourceImpl.class.getMethod("setTarget", Target.class)); - configuration.setInstanceFactory(new PojoObjectFactory(SourceImpl.class.getConstructor())); - configuration.setName("source"); - AtomicComponent component = new SystemAtomicComponentImpl(configuration); - component.setScopeContainer(scope); - OutboundWire outboundWire = EasyMock.createMock(OutboundWire.class); - EasyMock.expect(outboundWire.getReferenceName()).andReturn("setTarget").atLeastOnce(); - EasyMock.expect(outboundWire.getTargetService()).andReturn(target); - EasyMock.replay(outboundWire); - component.addOutboundWire(outboundWire); - component.start(); - assertSame(((Source) component.getTargetInstance()).getTarget(), target); - EasyMock.verify(outboundWire); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/system/loader/SystemComponentTypeLoaderTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/system/loader/SystemComponentTypeLoaderTestCase.java deleted file mode 100644 index 3c3de5f047..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/system/loader/SystemComponentTypeLoaderTestCase.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.implementation.system.loader; - -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.implementation.java.PojoComponentType; -import org.apache.tuscany.spi.implementation.java.ProcessingException; -import org.apache.tuscany.spi.model.Property; -import org.apache.tuscany.spi.model.ReferenceDefinition; -import org.apache.tuscany.spi.model.ServiceDefinition; - -import junit.framework.TestCase; -import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl; -import org.apache.tuscany.core.implementation.IntrospectionRegistryImpl; -import org.apache.tuscany.core.implementation.processor.ConstructorProcessor; -import org.apache.tuscany.core.implementation.processor.DestroyProcessor; -import org.apache.tuscany.core.implementation.processor.HeuristicPojoProcessor; -import org.apache.tuscany.spi.implementation.java.ImplementationProcessorService; -import org.apache.tuscany.core.implementation.processor.ImplementationProcessorServiceImpl; -import org.apache.tuscany.core.implementation.processor.InitProcessor; -import org.apache.tuscany.core.implementation.processor.PropertyProcessor; -import org.apache.tuscany.core.implementation.processor.ReferenceProcessor; -import org.apache.tuscany.core.implementation.processor.ScopeProcessor; -import org.apache.tuscany.core.implementation.processor.ServiceProcessor; -import org.apache.tuscany.core.implementation.system.model.SystemImplementation; -import org.apache.tuscany.core.mock.component.BasicInterface; -import org.apache.tuscany.core.mock.component.BasicInterfaceImpl; -import org.apache.tuscany.core.monitor.NullMonitorFactory; -import org.easymock.EasyMock; - -/** - * @version $Rev$ $Date$ - */ -public class SystemComponentTypeLoaderTestCase extends TestCase { - private SystemComponentTypeLoader loader; - - public void testIntrospectUnannotatedClass() throws ProcessingException { - CompositeComponent parent = EasyMock.createNiceMock(CompositeComponent.class); - SystemImplementation impl = new SystemImplementation(BasicInterfaceImpl.class); - PojoComponentType componentType = loader.loadByIntrospection(parent, impl, null); - ServiceDefinition service = componentType.getServices().get(BasicInterface.class.getName()); - assertEquals(BasicInterface.class, service.getServiceContract().getInterfaceClass()); - Property property = componentType.getProperties().get("publicProperty"); - assertEquals(String.class, property.getJavaType()); - ReferenceDefinition referenceDefinition = componentType.getReferences().get("protectedReference"); - assertEquals(BasicInterface.class, referenceDefinition.getServiceContract().getInterfaceClass()); - } - - protected void setUp() throws Exception { - super.setUp(); - JavaInterfaceProcessorRegistryImpl interfaceProcessorRegistry = new JavaInterfaceProcessorRegistryImpl(); - ImplementationProcessorService service = - new ImplementationProcessorServiceImpl(interfaceProcessorRegistry); - IntrospectionRegistryImpl registry = new IntrospectionRegistryImpl(); - registry.setMonitor(new NullMonitorFactory().getMonitor(IntrospectionRegistryImpl.Monitor.class)); - registry.registerProcessor(new ConstructorProcessor(service)); - registry.registerProcessor(new DestroyProcessor()); - registry.registerProcessor(new InitProcessor()); - registry.registerProcessor(new ScopeProcessor()); - registry.registerProcessor(new PropertyProcessor(service)); - registry.registerProcessor(new ReferenceProcessor(interfaceProcessorRegistry)); - registry.registerProcessor(new ServiceProcessor(service)); - registry.registerProcessor(new HeuristicPojoProcessor(service)); - loader = new SystemComponentTypeLoader(registry); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/system/loader/SystemImplementationLoaderTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/system/loader/SystemImplementationLoaderTestCase.java deleted file mode 100644 index 6cb059d629..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/implementation/system/loader/SystemImplementationLoaderTestCase.java +++ /dev/null @@ -1,106 +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.system.loader; - -import javax.xml.namespace.QName; -import javax.xml.stream.Location; -import javax.xml.stream.XMLStreamConstants; -import javax.xml.stream.XMLStreamReader; - -import org.apache.tuscany.spi.deployer.DeploymentContext; -import org.apache.tuscany.spi.loader.LoaderRegistry; -import org.apache.tuscany.spi.loader.UnrecognizedElementException; - -import junit.framework.TestCase; -import org.apache.tuscany.core.implementation.system.model.SystemImplementation; -import org.easymock.EasyMock; - -/** - * @version $Rev$ $Date$ - */ -public class SystemImplementationLoaderTestCase extends TestCase { - - public static final QName SYSTEM_IMPLEMENTATION = - new QName("http://tuscany.apache.org/xmlns/system/1.0-SNAPSHOT", "implementation.system"); - - public void testLoad() throws Exception { - LoaderRegistry registry = EasyMock.createNiceMock(LoaderRegistry.class); - EasyMock.replay(registry); - DeploymentContext context = EasyMock.createMock(DeploymentContext.class); - EasyMock.expect(context.getClassLoader()).andReturn(getClass().getClassLoader()); - EasyMock.replay(context); - XMLStreamReader reader = EasyMock.createMock(XMLStreamReader.class); - EasyMock.expect(reader.getName()).andReturn(SYSTEM_IMPLEMENTATION); - EasyMock.expect(reader.getAttributeValue((String) EasyMock.isNull(), EasyMock.eq("class"))) - .andReturn(getClass().getName()); - EasyMock.expect(reader.next()).andReturn(XMLStreamConstants.END_ELEMENT); - EasyMock.replay(reader); - SystemImplementationLoader loader = new SystemImplementationLoader(registry); - SystemImplementation impl = loader.load(null, null, reader, context); - assertEquals(getClass(), impl.getImplementationClass()); - EasyMock.verify(reader); - EasyMock.verify(context); - } - - public void testUnrecognizedElement() throws Exception { - LoaderRegistry registry = EasyMock.createNiceMock(LoaderRegistry.class); - EasyMock.replay(registry); - DeploymentContext context = EasyMock.createMock(DeploymentContext.class); - EasyMock.expect(context.getClassLoader()).andReturn(getClass().getClassLoader()); - EasyMock.replay(context); - XMLStreamReader reader = EasyMock.createMock(XMLStreamReader.class); - EasyMock.expect(reader.getName()).andReturn(SYSTEM_IMPLEMENTATION).atLeastOnce(); - EasyMock.expect(reader.getAttributeValue((String) EasyMock.isNull(), EasyMock.eq("class"))) - .andReturn(getClass().getName()); - EasyMock.expect(reader.next()).andReturn(XMLStreamConstants.START_ELEMENT); - EasyMock.expect(reader.getLocation()).andReturn(new MockLocation()); - EasyMock.replay(reader); - SystemImplementationLoader loader = new SystemImplementationLoader(registry); - try { - loader.load(null, null, reader, context); - fail(); - } catch (UnrecognizedElementException e) { - // expected - } - } - - private class MockLocation implements Location { - - public int getLineNumber() { - return 0; - } - - public int getColumnNumber() { - return 0; - } - - public int getCharacterOffset() { - return 0; - } - - public String getPublicId() { - return null; - } - - public String getSystemId() { - return null; - } - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/injection/CallbackWireObjectFactoryTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/injection/CallbackWireObjectFactoryTestCase.java deleted file mode 100644 index 0a3a052024..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/injection/CallbackWireObjectFactoryTestCase.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.injection; - -import org.apache.tuscany.spi.wire.WireService; - -import junit.framework.TestCase; -import static org.easymock.EasyMock.createMock; -import static org.easymock.EasyMock.expectLastCall; -import static org.easymock.EasyMock.replay; -import static org.easymock.EasyMock.verify; - -/** - * @version $Rev$ $Date$ - */ -public class CallbackWireObjectFactoryTestCase extends TestCase { - - public void testCreateInstance() throws Exception { - WireService service = createMock(WireService.class); - service.createCallbackProxy(Foo.class, null); - expectLastCall().andReturn(null); - replay(service); - CallbackWireObjectFactory factory = new CallbackWireObjectFactory(Foo.class, service, null); - factory.getInstance(); - verify(service); - } - - private interface Foo { - - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/injection/ContextObjectFactoryTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/injection/ContextObjectFactoryTestCase.java deleted file mode 100644 index 31216d2a51..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/injection/ContextObjectFactoryTestCase.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.injection; - -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.wire.WireService; - -import junit.framework.TestCase; -import org.easymock.EasyMock; - -/** - * @version $Rev$ $Date$ - */ -public class ContextObjectFactoryTestCase extends TestCase { - - public void testCreation() throws Exception { - CompositeComponent composite = EasyMock.createNiceMock(CompositeComponent.class); - WireService wireService = EasyMock.createNiceMock(WireService.class); - CompositeContextObjectFactory factory = new CompositeContextObjectFactory(composite, wireService); - assertNotNull(factory.getInstance()); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/injection/FieldInjectorTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/injection/FieldInjectorTestCase.java deleted file mode 100644 index d31347f7e6..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/injection/FieldInjectorTestCase.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.injection; - -import java.lang.reflect.Field; - -import junit.framework.TestCase; - -/** - * @version $Rev$ $Date$ - */ -public class FieldInjectorTestCase extends TestCase { - - protected Field protectedField; - - public void testIllegalAccess() throws Exception { - FieldInjector injector = new FieldInjector(protectedField, new SingletonObjectFactory("foo")); - Foo foo = new Foo(); - injector.inject(foo); - assertEquals("foo", foo.hidden); - } - - - protected void setUp() throws Exception { - super.setUp(); - protectedField = Foo.class.getDeclaredField("hidden"); - } - - private class Foo { - private String hidden; - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/injection/JNDIObjectFactoryTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/injection/JNDIObjectFactoryTestCase.java deleted file mode 100644 index 91214fd02d..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/injection/JNDIObjectFactoryTestCase.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.injection; - -import javax.naming.Context; -import javax.naming.NamingException; - -import org.apache.tuscany.spi.ObjectCreationException; - -import junit.framework.TestCase; -import org.easymock.EasyMock; - -/** - * @version $Rev$ $Date$ - */ -public class JNDIObjectFactoryTestCase extends TestCase { - - public void testGetInstance() throws Exception { - Context ctx = EasyMock.createMock(Context.class); - EasyMock.expect(ctx.lookup(EasyMock.eq("foo"))).andReturn(new Foo()); - EasyMock.replay(ctx); - JNDIObjectFactory factory = new JNDIObjectFactory(ctx, "foo"); - assertTrue(factory.getInstance() instanceof Foo); // must do an instanceof b/c of type erasure - EasyMock.verify(ctx); - } - - public void testGetInstanceError() throws Exception { - Context ctx = EasyMock.createMock(Context.class); - EasyMock.expect(ctx.lookup(EasyMock.eq("foo"))).andThrow(new NamingException()); - EasyMock.replay(ctx); - JNDIObjectFactory factory = new JNDIObjectFactory(ctx, "foo"); - try { - factory.getInstance(); - fail(); - } catch (ObjectCreationException e) { - //expected - } - EasyMock.verify(ctx); - } - - - private class Foo { - - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/injection/MethodEventInvokerTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/injection/MethodEventInvokerTestCase.java deleted file mode 100644 index 3bb882da2d..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/injection/MethodEventInvokerTestCase.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.injection; - -import java.lang.reflect.Method; - -import junit.framework.TestCase; - -/** - * @version $Rev$ $Date$ - */ -public class MethodEventInvokerTestCase extends TestCase { - private Method privateMethod; - private Method exceptionMethod; - - public void testIllegalAccess() throws Exception { - MethodEventInvoker injector = new MethodEventInvoker(privateMethod); - try { - injector.invokeEvent(new Foo()); - fail(); - } catch (AssertionError e) { - // expected - } - } - - public void testException() throws Exception { - MethodEventInvoker injector = new MethodEventInvoker(exceptionMethod); - try { - injector.invokeEvent(new Foo()); - fail(); - } catch (RuntimeException e) { - // expected - } - } - - protected void setUp() throws Exception { - super.setUp(); - privateMethod = MethodEventInvokerTestCase.Foo.class.getDeclaredMethod("hidden"); - exceptionMethod = MethodEventInvokerTestCase.Foo.class.getDeclaredMethod("exception"); - - } - - private class Foo { - - public void foo() { - } - - private void hidden() { - } - - public void exception() { - throw new RuntimeException(); - } - - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/injection/MethodInjectorTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/injection/MethodInjectorTestCase.java deleted file mode 100644 index b21ba4ccfa..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/injection/MethodInjectorTestCase.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.injection; - -import java.lang.reflect.Method; - -import org.apache.tuscany.spi.ObjectCreationException; -import org.apache.tuscany.spi.ObjectFactory; - -import junit.framework.TestCase; - -/** - * @version $Rev$ $Date$ - */ -public class MethodInjectorTestCase extends TestCase { - private Method fooMethod; - private Method privateMethod; - private Method exceptionMethod; - - public void testIllegalArgument() throws Exception { - ObjectFactory factory = new SingletonObjectFactory(new Object()); - MethodInjector injector = new MethodInjector(fooMethod, factory); - try { - injector.inject(new Foo()); - fail(); - } catch (ObjectCreationException e) { - // expected - } - } - - public void testException() throws Exception { - ObjectFactory factory = new SingletonObjectFactory("foo"); - MethodInjector injector = new MethodInjector(exceptionMethod, factory); - try { - injector.inject(new Foo()); - fail(); - } catch (RuntimeException e) { - // expected - } - } - - protected void setUp() throws Exception { - super.setUp(); - fooMethod = Foo.class.getMethod("foo", String.class); - privateMethod = Foo.class.getDeclaredMethod("hidden", String.class); - exceptionMethod = Foo.class.getDeclaredMethod("exception", String.class); - - } - - private class Foo { - - public void foo(String bar) { - } - - private void hidden(String bar) { - } - - public void exception(String bar) { - throw new RuntimeException(); - } - - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/injection/PojoObjectFactoryTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/injection/PojoObjectFactoryTestCase.java deleted file mode 100644 index 7aba6dbab3..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/injection/PojoObjectFactoryTestCase.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.injection; - -import java.lang.reflect.Constructor; -import java.util.List; -import java.util.ArrayList; - -import org.apache.tuscany.spi.ObjectFactory; - -import junit.framework.TestCase; - -/** - * @version $Rev$ $Date$ - */ -public class PojoObjectFactoryTestCase extends TestCase { - - private Constructor ctor; - - public void testConstructorInjection() throws Exception { - List initializers = new ArrayList(); - initializers.add(new SingletonObjectFactory("foo")); - PojoObjectFactory factory = new PojoObjectFactory(ctor, initializers); - Foo foo = factory.getInstance(); - assertEquals("foo", foo.foo); - } - - public void testConstructorInitializerInjection() throws Exception { - PojoObjectFactory factory = new PojoObjectFactory(ctor); - factory.setInitializerFactory(0, new SingletonObjectFactory("foo")); - Foo foo = factory.getInstance(); - assertEquals("foo", foo.foo); - } - - protected void setUp() throws Exception { - super.setUp(); - ctor = Foo.class.getConstructor(String.class); - } - - private static class Foo { - - private String foo; - - public Foo(String foo) { - this.foo = foo; - } - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/injection/RequestContextObjectFactoryTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/injection/RequestContextObjectFactoryTestCase.java deleted file mode 100644 index a1a41bbada..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/injection/RequestContextObjectFactoryTestCase.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.injection; - -import org.apache.tuscany.spi.component.WorkContext; - -import junit.framework.TestCase; -import org.easymock.EasyMock; - -/** - * @version $Rev$ $Date$ - */ -public class RequestContextObjectFactoryTestCase extends TestCase { - - public void testInstanceCreate() { - WorkContext workContext = EasyMock.createNiceMock(WorkContext.class); - RequestContextObjectFactory factory = new RequestContextObjectFactory(workContext); - assertNotNull(factory.getInstance()); - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/injection/ResourceObjectFactoryTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/injection/ResourceObjectFactoryTestCase.java deleted file mode 100644 index 073bda1458..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/injection/ResourceObjectFactoryTestCase.java +++ /dev/null @@ -1,152 +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.component.AtomicComponent; -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.host.ResourceHost; -import org.apache.tuscany.spi.wire.InboundWire; - -import junit.framework.TestCase; -import org.easymock.EasyMock; - -/** - * @version $Rev$ $Date$ - */ -public class ResourceObjectFactoryTestCase extends TestCase { - - public void testResolveFromHostByType() throws Exception { - ResourceHost host = EasyMock.createMock(ResourceHost.class); - EasyMock.expect(host.resolveResource(EasyMock.eq(String.class))).andReturn("foo"); - EasyMock.replay(host); - CompositeComponent parent = EasyMock.createMock(CompositeComponent.class); - EasyMock.expect(parent.resolveSystemAutowire(EasyMock.eq(String.class))).andReturn(null); - EasyMock.replay(parent); - ResourceObjectFactory factory = new ResourceObjectFactory(String.class, false, parent, host); - assertEquals("foo", factory.getInstance()); - EasyMock.verify(host); - EasyMock.verify(parent); - } - - public void testResolveFromHostByName() throws Exception { - ResourceHost host = EasyMock.createMock(ResourceHost.class); - EasyMock.expect(host.resolveResource(EasyMock.eq(String.class), - EasyMock.eq("sca://localhost/bar"))).andReturn("foo"); - EasyMock.replay(host); - ResourceObjectFactory factory = - new ResourceObjectFactory(String.class, "sca://localhost/bar", false, null, host); - assertEquals("foo", factory.getInstance()); - EasyMock.verify(host); - } - - public void testResolveFromParentByType() throws Exception { - CompositeComponent parent = EasyMock.createMock(CompositeComponent.class); - InboundWire wire = EasyMock.createMock(InboundWire.class); - EasyMock.expect(wire.getTargetService()).andReturn("foo"); - EasyMock.replay(wire); - - EasyMock.expect(parent.resolveSystemAutowire(EasyMock.eq(String.class))).andReturn(wire); - EasyMock.replay(parent); - ResourceObjectFactory factory = new ResourceObjectFactory(String.class, false, parent, null); - assertEquals("foo", factory.getInstance()); - EasyMock.verify(parent); - } - - public void testResolveFromParentByName() throws Exception { - AtomicComponent component = EasyMock.createMock(AtomicComponent.class); - EasyMock.expect(component.getTargetInstance()).andReturn("foo"); - EasyMock.replay(component); - CompositeComponent parent = EasyMock.createMock(CompositeComponent.class); - EasyMock.expect(parent.getSystemChild(EasyMock.eq("bar"))).andReturn(component); - EasyMock.replay(parent); - ResourceObjectFactory factory = - new ResourceObjectFactory(String.class, "bar", false, parent, null); - assertEquals("foo", factory.getInstance()); - EasyMock.verify(parent); - EasyMock.verify(component); - } - - /** - * Verifies if a resource is not found as a child of the parent, the host namespace will be searched - */ - public void testResolveFromParentThenResolveFromHost() throws Exception { - ResourceHost host = EasyMock.createMock(ResourceHost.class); - EasyMock.expect(host.resolveResource(EasyMock.eq(String.class))).andReturn("foo"); - EasyMock.replay(host); - - CompositeComponent parent = EasyMock.createMock(CompositeComponent.class); - EasyMock.expect(parent.resolveSystemAutowire(EasyMock.eq(String.class))).andReturn(null); - EasyMock.replay(parent); - ResourceObjectFactory factory = new ResourceObjectFactory(String.class, false, parent, host); - assertEquals("foo", factory.getInstance()); - EasyMock.verify(parent); - EasyMock.verify(host); - } - - public void testResolveFromParentThenResolveFromHostNotFound() throws Exception { - ResourceHost host = EasyMock.createMock(ResourceHost.class); - EasyMock.expect(host.resolveResource(EasyMock.eq(String.class))).andReturn(null); - EasyMock.replay(host); - CompositeComponent parent = EasyMock.createMock(CompositeComponent.class); - EasyMock.expect(parent.resolveSystemAutowire(EasyMock.eq(String.class))).andReturn(null); - EasyMock.replay(parent); - ResourceObjectFactory factory = new ResourceObjectFactory(String.class, true, parent, host); - assertNull(factory.getInstance()); - EasyMock.verify(parent); - EasyMock.verify(host); - } - - public void testResolveByTypeNotFound() throws Exception { - ResourceHost host = EasyMock.createMock(ResourceHost.class); - EasyMock.expect(host.resolveResource(EasyMock.eq(String.class))).andReturn(null); - EasyMock.replay(host); - - InboundWire wire = EasyMock.createMock(InboundWire.class); - EasyMock.expect(wire.getTargetService()).andReturn(null); - EasyMock.replay(wire); - - CompositeComponent parent = EasyMock.createMock(CompositeComponent.class); - EasyMock.expect(parent.resolveSystemAutowire(EasyMock.eq(String.class))).andReturn(null); - EasyMock.replay(parent); - ResourceObjectFactory factory = new ResourceObjectFactory(String.class, false, parent, host); - try { - factory.getInstance(); - fail(); - } catch (ResourceNotFoundException e) { - //expected - } - EasyMock.verify(parent); - EasyMock.verify(host); - } - - public void testResolveByTypeNotFoundOptional() throws Exception { - ResourceHost host = EasyMock.createMock(ResourceHost.class); - EasyMock.expect(host.resolveResource(EasyMock.eq(String.class))).andReturn(null); - EasyMock.replay(host); - CompositeComponent parent = EasyMock.createMock(CompositeComponent.class); - EasyMock.expect(parent.resolveSystemAutowire(EasyMock.eq(String.class))).andReturn(null); - EasyMock.replay(parent); - ResourceObjectFactory factory = new ResourceObjectFactory(String.class, true, parent, host); - assertNull(factory.getInstance()); - EasyMock.verify(parent); - EasyMock.verify(host); - } - - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/injection/SingletonObjectFactoryTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/injection/SingletonObjectFactoryTestCase.java deleted file mode 100644 index 876e68d5b3..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/integration/conversation/AbstractConversationTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/integration/conversation/AbstractConversationTestCase.java deleted file mode 100644 index f9135e2eb9..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/integration/conversation/AbstractConversationTestCase.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.integration.conversation; - -import org.apache.tuscany.spi.component.ScopeContainer; -import org.apache.tuscany.spi.component.WorkContext; -import org.apache.tuscany.spi.services.store.StoreMonitor; -import org.apache.tuscany.spi.wire.WirePostProcessorRegistry; - -import junit.framework.TestCase; -import org.apache.tuscany.core.builder.ConnectorImpl; -import org.apache.tuscany.core.builder.WirePostProcessorRegistryImpl; -import org.apache.tuscany.core.component.WorkContextImpl; -import org.apache.tuscany.core.component.scope.ConversationalScopeContainer; -import org.apache.tuscany.core.implementation.java.JavaAtomicComponent; -import org.apache.tuscany.core.services.store.memory.MemoryStore; -import org.easymock.classextension.EasyMock; - -/** - * Provides helper methods for setting up a partial runtime for conversational test cases. - * - * @version $Rev$ $Date$ - */ -public abstract class AbstractConversationTestCase extends TestCase { - protected ScopeContainer container; - protected MemoryStore store; - protected WorkContext workContext; - protected ConnectorImpl connector; - protected JavaAtomicComponent target; - - - protected void createRuntime() { - workContext = new WorkContextImpl(); - WirePostProcessorRegistry processorRegistry = new WirePostProcessorRegistryImpl(); - connector = new ConnectorImpl(null, processorRegistry, null, workContext); - store = new MemoryStore(EasyMock.createNiceMock(StoreMonitor.class)); - container = new ConversationalScopeContainer(store, workContext, null); - - } - - protected void initializeRuntime() { - store.init(); - container.start(); - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/integration/conversation/ConversationIdleExpireTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/integration/conversation/ConversationIdleExpireTestCase.java deleted file mode 100644 index 450b1016d1..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/integration/conversation/ConversationIdleExpireTestCase.java +++ /dev/null @@ -1,142 +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.integration.conversation; - -import java.lang.reflect.Constructor; -import java.lang.reflect.Method; - -import org.osoa.sca.annotations.EndConversation; -import org.osoa.sca.annotations.Scope; - -import org.apache.tuscany.spi.ObjectCreationException; -import org.apache.tuscany.spi.QualifiedName; -import org.apache.tuscany.spi.component.TargetNotFoundException; -import org.apache.tuscany.spi.wire.InboundWire; -import org.apache.tuscany.spi.wire.OutboundWire; - -import org.apache.tuscany.core.implementation.PojoConfiguration; -import org.apache.tuscany.core.implementation.java.JavaAtomicComponent; -import org.apache.tuscany.core.injection.PojoObjectFactory; -import org.apache.tuscany.core.integration.mock.MockFactory; -import org.apache.tuscany.core.wire.jdk.JDKOutboundInvocationHandler; -import org.easymock.classextension.EasyMock; - -/** - * Verifies conversational resources are cleaned up if the maximum idle time is exceeded - * - * @version $Rev$ $Date$ - */ -public class ConversationIdleExpireTestCase extends AbstractConversationTestCase { - private JDKOutboundInvocationHandler handler; - private OutboundWire owire; - private Foo targetInstance; - private Method operation1; - private Method operation2; - private final Object mutex = new Object(); - - public void testConversationExpire() throws Throwable { - workContext.setIdentifier(org.apache.tuscany.spi.model.Scope.CONVERSATION, "12345A"); - // start the conversation - handler.invoke(operation1, null); - // verify the instance was persisted - assertEquals(targetInstance, store.readRecord(target, "12345A")); - synchronized (mutex) { - mutex.wait(100); - } - // verify the instance was expired - assertNull(store.readRecord(target, "12345A")); - // continue the conversation - should throw an error - try { - handler.invoke(operation2, null); - fail(); - } catch (TargetNotFoundException e) { - // expected - } - } - - - protected void setUp() throws Exception { - super.setUp(); - createRuntime(); - store.setReaperInterval(10); - initializeRuntime(); - - targetInstance = EasyMock.createMock(Foo.class); - targetInstance.operation1(); - targetInstance.operation2(); - targetInstance.end(); - EasyMock.replay(targetInstance); - target = createMaxIdleTimeAtomicComponent(); - // create source component mock - JavaAtomicComponent source = EasyMock.createMock(JavaAtomicComponent.class); - EasyMock.expect(source.getName()).andReturn("source").atLeastOnce(); - EasyMock.expect(source.isSystem()).andReturn(false).atLeastOnce(); - EasyMock.replay(source); - - owire = MockFactory.createOutboundWire("foo", Foo.class); - owire.setContainer(source); - owire.setTargetName(new QualifiedName("foo/bar")); - InboundWire iwire = MockFactory.createInboundWire("foo", Foo.class); - iwire.setContainer(target); - connector.connect(owire, iwire, false); - handler = new JDKOutboundInvocationHandler(Foo.class, owire, workContext); - operation1 = Foo.class.getMethod("operation1"); - operation2 = Foo.class.getMethod("operation2"); - } - - protected void tearDown() throws Exception { - super.tearDown(); - container.stop(); - store.destroy(); - } - - private JavaAtomicComponent createMaxIdleTimeAtomicComponent() throws Exception { - PojoConfiguration configuration = new PojoConfiguration(); - configuration.setName("target"); - configuration.setMaxIdleTime(50); - configuration.setInstanceFactory(new MockPojoFactory(Object.class.getConstructor())); - JavaAtomicComponent component = new JavaAtomicComponent(configuration); - component.setScopeContainer(container); - component.start(); - return component; - } - - private class MockPojoFactory extends PojoObjectFactory { - public MockPojoFactory(Constructor ctr) { - super(ctr); - } - - public Foo getInstance() throws ObjectCreationException { - return targetInstance; - } - } - - @Scope("CONVERSATION") - public static interface Foo { - - void operation1(); - - void operation2(); - - @EndConversation - void end(); - - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/integration/conversation/ConversationMaxAgeExpireTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/integration/conversation/ConversationMaxAgeExpireTestCase.java deleted file mode 100644 index 96dd08e8c2..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/integration/conversation/ConversationMaxAgeExpireTestCase.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.integration.conversation; - -import java.lang.reflect.Constructor; -import java.lang.reflect.Method; - -import org.osoa.sca.annotations.EndConversation; -import org.osoa.sca.annotations.Scope; - -import org.apache.tuscany.spi.ObjectCreationException; -import org.apache.tuscany.spi.QualifiedName; -import org.apache.tuscany.spi.component.TargetNotFoundException; -import org.apache.tuscany.spi.wire.InboundWire; -import org.apache.tuscany.spi.wire.OutboundWire; - -import org.apache.tuscany.core.implementation.PojoConfiguration; -import org.apache.tuscany.core.implementation.java.JavaAtomicComponent; -import org.apache.tuscany.core.injection.PojoObjectFactory; -import org.apache.tuscany.core.integration.mock.MockFactory; -import org.apache.tuscany.core.wire.jdk.JDKOutboundInvocationHandler; -import org.easymock.classextension.EasyMock; - -/** - * Verifies conversational resources are cleaned up if the maximum age is exceeded - * - * @version $Rev$ $Date$ - */ -public class ConversationMaxAgeExpireTestCase extends AbstractConversationTestCase { - private JDKOutboundInvocationHandler handler; - private OutboundWire owire; - private Foo targetInstance; - private Method operation1; - private Method operation2; - private final Object mutex = new Object(); - - public void testConversationExpire() throws Throwable { - workContext.setIdentifier(org.apache.tuscany.spi.model.Scope.CONVERSATION, "12345A"); - // start the conversation - handler.invoke(operation1, null); - // verify the instance was persisted - assertEquals(targetInstance, store.readRecord(target, "12345A")); - synchronized (mutex) { - mutex.wait(100); - } - // verify the instance was expired - assertNull(store.readRecord(target, "12345A")); - // continue the conversation - should throw an error - try { - handler.invoke(operation2, null); - fail(); - } catch (TargetNotFoundException e) { - // expected - } - } - - - protected void setUp() throws Exception { - super.setUp(); - createRuntime(); - store.setReaperInterval(10); - initializeRuntime(); - - targetInstance = EasyMock.createMock(ConversationMaxAgeExpireTestCase.Foo.class); - targetInstance.operation1(); - targetInstance.operation2(); - targetInstance.end(); - EasyMock.replay(targetInstance); - target = createMaxIdleTimeAtomicComponent(); - // create source component mock - JavaAtomicComponent source = EasyMock.createMock(JavaAtomicComponent.class); - EasyMock.expect(source.getName()).andReturn("source").atLeastOnce(); - EasyMock.expect(source.isSystem()).andReturn(false).atLeastOnce(); - EasyMock.replay(source); - - owire = MockFactory.createOutboundWire("foo", Foo.class); - owire.setContainer(source); - owire.setTargetName(new QualifiedName("foo/bar")); - InboundWire iwire = MockFactory.createInboundWire("foo", Foo.class); - iwire.setContainer(target); - connector.connect(owire, iwire, false); - handler = new JDKOutboundInvocationHandler(Foo.class, owire, workContext); - operation1 = Foo.class.getMethod("operation1"); - operation2 = Foo.class.getMethod("operation2"); - } - - protected void tearDown() throws Exception { - super.tearDown(); - container.stop(); - store.destroy(); - } - - private JavaAtomicComponent createMaxIdleTimeAtomicComponent() throws Exception { - PojoConfiguration configuration = new PojoConfiguration(); - configuration.setName("target"); - configuration.setMaxAge(50); - Constructor ctor = Object.class.getConstructor(); - configuration.setInstanceFactory(new ConversationMaxAgeExpireTestCase.MockPojoFactory(ctor)); - JavaAtomicComponent component = new JavaAtomicComponent(configuration); - component.setScopeContainer(container); - component.start(); - return component; - } - - private class MockPojoFactory extends PojoObjectFactory { - public MockPojoFactory(Constructor ctr) { - super(ctr); - } - - public ConversationMaxAgeExpireTestCase.Foo getInstance() throws ObjectCreationException { - return targetInstance; - } - } - - @Scope("CONVERSATION") - public static interface Foo { - - void operation1(); - - void operation2(); - - @EndConversation - void end(); - - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/integration/conversation/ConversationStartStopEndTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/integration/conversation/ConversationStartStopEndTestCase.java deleted file mode 100644 index 7c722943b0..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/integration/conversation/ConversationStartStopEndTestCase.java +++ /dev/null @@ -1,142 +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.integration.conversation; - -import java.lang.reflect.Constructor; -import java.lang.reflect.Method; - -import org.osoa.sca.annotations.EndConversation; -import org.osoa.sca.annotations.Scope; - -import org.apache.tuscany.spi.ObjectCreationException; -import org.apache.tuscany.spi.QualifiedName; -import static org.apache.tuscany.spi.model.Scope.CONVERSATION; -import org.apache.tuscany.spi.wire.InboundWire; -import org.apache.tuscany.spi.wire.OutboundWire; - -import org.apache.tuscany.core.implementation.PojoConfiguration; -import org.apache.tuscany.core.implementation.java.JavaAtomicComponent; -import org.apache.tuscany.core.injection.PojoObjectFactory; -import org.apache.tuscany.core.integration.mock.MockFactory; -import org.apache.tuscany.core.wire.jdk.JDKOutboundInvocationHandler; -import org.easymock.classextension.EasyMock; - -/** - * Verifies start, continue and end conversation invocations are processed properly. Checks that a target instance is - * properly instantiated and persisted in the store. Additionally verifies that invocations are dispatched to a target - * instance, and that start, continue, and end operations are performed correctly. Finally, verfies that the target - * instance is removed from the store when the conversation ends. - * - * @version $Rev$ $Date$ - */ -public class ConversationStartStopEndTestCase extends AbstractConversationTestCase { - private OutboundWire owire; - private Foo targetInstance; - private JDKOutboundInvocationHandler handler; - private Method operation1; - private Method operation2; - private Method endOperation; - - public void testConversationStartContinueEnd() throws Throwable { - workContext.setIdentifier(CONVERSATION, "12345A"); - // start the conversation - handler.invoke(operation1, null); - // verify the instance was persisted - assertEquals(targetInstance, store.readRecord(target, "12345A")); - // continue the conversation - handler.invoke(operation2, null); - // verify the instance was persisted - assertEquals(targetInstance, store.readRecord(target, "12345A")); - // end the conversation - handler.invoke(endOperation, null); - workContext.clearIdentifier(CONVERSATION); - EasyMock.verify(targetInstance); - // verify the store has removed the instance - assertNull(store.readRecord(target, "12345A")); - } - - - protected void setUp() throws Exception { - super.setUp(); - createRuntime(); - initializeRuntime(); - targetInstance = EasyMock.createMock(Foo.class); - targetInstance.operation1(); - targetInstance.operation2(); - targetInstance.end(); - EasyMock.replay(targetInstance); - // create target component mock - target = createAtomicComponent(); - // create source component mock - JavaAtomicComponent source = EasyMock.createMock(JavaAtomicComponent.class); - EasyMock.expect(source.getName()).andReturn("source").atLeastOnce(); - EasyMock.expect(source.isSystem()).andReturn(false).atLeastOnce(); - EasyMock.replay(source); - - owire = MockFactory.createOutboundWire("foo", Foo.class); - owire.setContainer(source); - owire.setTargetName(new QualifiedName("foo/bar")); - InboundWire iwire = MockFactory.createInboundWire("foo", Foo.class); - iwire.setContainer(target); - connector.connect(owire, iwire, false); - handler = new JDKOutboundInvocationHandler(Foo.class, owire, workContext); - operation1 = Foo.class.getMethod("operation1"); - operation2 = Foo.class.getMethod("operation2"); - endOperation = Foo.class.getMethod("end"); - } - - protected void tearDown() throws Exception { - super.tearDown(); - container.stop(); - store.destroy(); - } - - private JavaAtomicComponent createAtomicComponent() throws Exception { - PojoConfiguration configuration = new PojoConfiguration(); - configuration.setName("target"); - configuration.setInstanceFactory(new MockPojoFactory(Object.class.getConstructor())); - JavaAtomicComponent component = new JavaAtomicComponent(configuration); - component.setScopeContainer(container); - component.start(); - return component; - } - - private class MockPojoFactory extends PojoObjectFactory { - public MockPojoFactory(Constructor ctr) { - super(ctr); - } - - public Foo getInstance() throws ObjectCreationException { - return targetInstance; - } - } - - @Scope("CONVERSATION") - public static interface Foo { - - void operation1(); - - void operation2(); - - @EndConversation - void end(); - - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/integration/implementation/IntrospectionRegistryIntegrationTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/integration/implementation/IntrospectionRegistryIntegrationTestCase.java deleted file mode 100644 index 24dc2ff399..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/integration/implementation/IntrospectionRegistryIntegrationTestCase.java +++ /dev/null @@ -1,131 +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.integration.implementation; - -import org.osoa.sca.annotations.Destroy; -import org.osoa.sca.annotations.Init; -import org.osoa.sca.annotations.Property; -import org.osoa.sca.annotations.Reference; -import org.osoa.sca.annotations.Scope; -import org.osoa.sca.annotations.Resource; - -import org.apache.tuscany.spi.implementation.java.ImplementationProcessorService; -import org.apache.tuscany.spi.implementation.java.JavaMappedProperty; -import org.apache.tuscany.spi.implementation.java.JavaMappedReference; -import org.apache.tuscany.spi.implementation.java.JavaMappedService; -import org.apache.tuscany.spi.implementation.java.PojoComponentType; -import static org.apache.tuscany.spi.model.Scope.COMPOSITE; - -import junit.framework.TestCase; -import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl; -import org.apache.tuscany.core.implementation.IntrospectionRegistryImpl; -import org.apache.tuscany.core.implementation.processor.DestroyProcessor; -import org.apache.tuscany.core.implementation.processor.ImplementationProcessorServiceImpl; -import org.apache.tuscany.core.implementation.processor.InitProcessor; -import org.apache.tuscany.core.implementation.processor.PropertyProcessor; -import org.apache.tuscany.core.implementation.processor.ReferenceProcessor; -import org.apache.tuscany.core.implementation.processor.ResourceProcessor; -import org.apache.tuscany.core.implementation.processor.ScopeProcessor; -import org.apache.tuscany.core.monitor.NullMonitorFactory; - -/** - * Sanity check of the IntegrationRegistry to verify operation with processors - * - * @version $Rev$ $Date$ - */ -public class IntrospectionRegistryIntegrationTestCase extends TestCase { - - private IntrospectionRegistryImpl registry; - - public void testSimpleComponentTypeParsing() throws Exception { - PojoComponentType> type = - new PojoComponentType>(); - registry.introspect(null, Foo.class, type, null); - assertEquals(Foo.class.getMethod("init"), type.getInitMethod()); - assertEquals(Foo.class.getMethod("destroy"), type.getDestroyMethod()); - assertEquals(COMPOSITE, type.getImplementationScope()); - assertEquals(Foo.class.getMethod("setBar", String.class), type.getProperties().get("bar").getMember()); - assertEquals(Foo.class.getMethod("setTarget", Foo.class), type.getReferences().get("target").getMember()); - assertEquals(Foo.class.getMethod("setResource", Foo.class), type.getResources().get("resource").getMember()); - } - - protected void setUp() throws Exception { - super.setUp(); - registry = new IntrospectionRegistryImpl(); - registry.setMonitor(new NullMonitorFactory().getMonitor(IntrospectionRegistryImpl.Monitor.class)); - registry.registerProcessor(new DestroyProcessor()); - registry.registerProcessor(new InitProcessor()); - registry.registerProcessor(new ScopeProcessor()); - JavaInterfaceProcessorRegistryImpl interfaceProcessorRegistry = new JavaInterfaceProcessorRegistryImpl(); - ImplementationProcessorService service = new ImplementationProcessorServiceImpl(interfaceProcessorRegistry); - registry.registerProcessor(new PropertyProcessor(service)); - registry.registerProcessor(new ReferenceProcessor(interfaceProcessorRegistry)); - registry.registerProcessor(new ResourceProcessor()); - } - - @Scope("COMPOSITE") - private static class Foo { - protected Foo target; - protected String bar; - protected Foo resource; - private boolean initialized; - private boolean destroyed; - - - @Init - public void init() { - if (initialized) { - fail(); - } - initialized = true; - } - - @Destroy - public void destroy() { - if (destroyed) { - fail(); - } - destroyed = true; - } - - public Foo getTarget() { - return target; - } - - @Reference - public void setTarget(Foo target) { - this.target = target; - } - - public String getBar() { - return bar; - } - - @Property - public void setBar(String bar) { - this.bar = bar; - } - - @Resource - public void setResource(Foo resource) { - this.resource = resource; - } - - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/integration/implementation/system/builder/SystemBuilderPropertyTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/integration/implementation/system/builder/SystemBuilderPropertyTestCase.java deleted file mode 100644 index a7d580bbcb..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/integration/implementation/system/builder/SystemBuilderPropertyTestCase.java +++ /dev/null @@ -1,88 +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.integration.implementation.system.builder; - -import org.apache.tuscany.spi.component.AtomicComponent; -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.deployer.DeploymentContext; -import org.apache.tuscany.spi.implementation.java.ConstructorDefinition; -import org.apache.tuscany.spi.implementation.java.JavaMappedProperty; -import org.apache.tuscany.spi.implementation.java.PojoComponentType; -import org.apache.tuscany.spi.model.ComponentDefinition; -import org.apache.tuscany.spi.model.ReferenceDefinition; -import org.apache.tuscany.spi.model.ServiceDefinition; - -import junit.framework.TestCase; -import org.apache.tuscany.core.deployer.RootDeploymentContext; -import org.apache.tuscany.core.implementation.system.builder.SystemComponentBuilder; -import org.apache.tuscany.core.implementation.system.model.SystemImplementation; -import org.apache.tuscany.core.injection.SingletonObjectFactory; -import org.easymock.EasyMock; - -/** - * Verifies that the system builder handles configured properties correctly - * - * @version $Rev$ $Date$ - */ -public class SystemBuilderPropertyTestCase extends TestCase { - - DeploymentContext deploymentContext; - CompositeComponent parent; - - @SuppressWarnings("unchecked") - public void testPropertyHandling() throws Exception { - SystemComponentBuilder builder = new SystemComponentBuilder(); - PojoComponentType> type = - new PojoComponentType>(); - type.setConstructorDefinition(new ConstructorDefinition(Foo.class.getConstructor((Class[]) null))); - JavaMappedProperty property = new JavaMappedProperty(); - property.setName("test"); - property.setDefaultValueFactory(new SingletonObjectFactory("foo")); - property.setMember(Foo.class.getMethod("setTest", String.class)); - type.add(property); - SystemImplementation impl = new SystemImplementation(); - impl.setComponentType(type); - impl.setImplementationClass(Foo.class); - ComponentDefinition definition = new ComponentDefinition(impl); - AtomicComponent component = builder.build(parent, definition, deploymentContext); - Foo foo = (Foo) component.createInstance(); - assertEquals("foo", foo.getTest()); - } - - protected void setUp() throws Exception { - super.setUp(); - deploymentContext = new RootDeploymentContext(null, null, null, null); - parent = EasyMock.createNiceMock(CompositeComponent.class); - } - - private static class Foo { - private String test; - - public Foo() { - } - - public String getTest() { - return test; - } - - public void setTest(String test) { - this.test = test; - } - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/integration/mock/MockFactory.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/integration/mock/MockFactory.java deleted file mode 100644 index 0c331ae7d7..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/integration/mock/MockFactory.java +++ /dev/null @@ -1,278 +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.integration.mock; - -import java.lang.reflect.Member; -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.AtomicComponent; -import org.apache.tuscany.spi.component.ScopeContainer; -import org.apache.tuscany.spi.idl.InvalidServiceContractException; -import org.apache.tuscany.spi.idl.java.JavaInterfaceProcessorRegistry; -import org.apache.tuscany.spi.model.Operation; -import org.apache.tuscany.spi.model.ServiceContract; -import org.apache.tuscany.spi.wire.InboundInvocationChain; -import org.apache.tuscany.spi.wire.InboundWire; -import org.apache.tuscany.spi.wire.Interceptor; -import org.apache.tuscany.spi.wire.OutboundInvocationChain; -import org.apache.tuscany.spi.wire.OutboundWire; -import org.apache.tuscany.spi.wire.WireService; - -import org.apache.tuscany.core.builder.ConnectorImpl; -import org.apache.tuscany.core.component.WorkContextImpl; -import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl; -import org.apache.tuscany.core.implementation.PojoConfiguration; -import org.apache.tuscany.core.implementation.java.JavaAtomicComponent; -import org.apache.tuscany.core.injection.PojoObjectFactory; -import org.apache.tuscany.core.wire.InboundInvocationChainImpl; -import org.apache.tuscany.core.wire.InboundWireImpl; -import org.apache.tuscany.core.wire.InvokerInterceptor; -import org.apache.tuscany.core.wire.OutboundInvocationChainImpl; -import org.apache.tuscany.core.wire.OutboundWireImpl; -import org.apache.tuscany.core.wire.jdk.JDKWireService; - -/** - * @version $$Rev$$ $$Date$$ - */ -public final class MockFactory { - - private static final WireService WIRE_SERVICE = new JDKWireService(new WorkContextImpl(), null); - private static final JavaInterfaceProcessorRegistry REGISTRY = new JavaInterfaceProcessorRegistryImpl(); - private static final ConnectorImpl CONNECTOR = new ConnectorImpl(); - - private MockFactory() { - } - - /** - * Wires two components together where the reference interface is the same as target service - * - * @param sourceName - * @param sourceClass - * @param sourceScope - * @param members - * @param targetName - * @param targetService - * @param targetClass - * @param targetScope - * @return - * @throws Exception - */ - public static Map createWiredComponents(String sourceName, - Class sourceClass, - ScopeContainer sourceScope, - Map members, - String targetName, - Class targetService, - Class targetClass, - ScopeContainer targetScope) throws Exception { - return createWiredComponents(sourceName, - sourceClass, - targetService, - sourceScope, - null, - members, - targetName, - targetService, - targetClass, - targetScope, - null); - - } - - @SuppressWarnings("unchecked") - public static Map createWiredComponents(String sourceName, Class sourceClass, - Class sourceReferenceClass, - ScopeContainer sourceScope, - Interceptor sourceHeadInterceptor, - Map members, - String targetName, Class targetService, - Class targetClass, - ScopeContainer targetScope, - Interceptor targetHeadInterceptor) - throws Exception { - - JavaAtomicComponent targetComponent = - createJavaComponent(targetName, targetScope, targetClass); - String serviceName = targetService.getName().substring(targetService.getName().lastIndexOf('.') + 1); - InboundWire inboundWire = createInboundWire(serviceName, targetService, targetHeadInterceptor); - targetComponent.addInboundWire(inboundWire); - inboundWire.setContainer(targetComponent); - PojoConfiguration configuration = new PojoConfiguration(); - configuration.setInstanceFactory(new PojoObjectFactory(sourceClass.getConstructor())); - configuration.setWireService(WIRE_SERVICE); - for (Map.Entry entry : members.entrySet()) { - configuration.addReferenceSite(entry.getKey(), entry.getValue()); - } - configuration.setWorkContext(new WorkContextImpl()); - configuration.setName(sourceName); - JavaAtomicComponent sourceComponent = new JavaAtomicComponent(configuration); - sourceComponent.setScopeContainer(sourceScope); - OutboundWire outboundWire = createOutboundWire(targetName, sourceReferenceClass, sourceHeadInterceptor); - sourceComponent.addOutboundWire(outboundWire); - outboundWire.setContainer(sourceComponent); - outboundWire.setTargetName(new QualifiedName(targetName + "/" + serviceName)); - targetScope.register(targetComponent); - sourceScope.register(sourceComponent); - CONNECTOR.connect(outboundWire, inboundWire, false); - Map contexts = new HashMap(); - contexts.put(sourceName, sourceComponent); - contexts.put(targetName, targetComponent); - return contexts; - } - - - /** - * Wires two contexts using a multiplicity reference - * - * @param sourceName - * @param sourceClass - * @param sourceReferenceClass - * @param sourceScope - * @param targetName - * @param targetService - * @param targetClass - * @param members - * @param targetScope - * @return - * @throws Exception - */ - @SuppressWarnings("unchecked") - public static Map createWiredMultiplicity(String sourceName, Class sourceClass, - Class sourceReferenceClass, - ScopeContainer sourceScope, - String targetName, Class targetService, - Class targetClass, - Map members, - ScopeContainer targetScope) throws Exception { - JavaAtomicComponent targetComponent = - createJavaComponent(targetName, targetScope, targetClass); - String serviceName = targetService.getName().substring(targetService.getName().lastIndexOf('.') + 1); - InboundWire inboundWire = createInboundWire(serviceName, targetService, null); - targetComponent.addInboundWire(inboundWire); - inboundWire.setContainer(targetComponent); - PojoConfiguration configuration = new PojoConfiguration(); - configuration.setInstanceFactory(new PojoObjectFactory(sourceClass.getConstructor())); - configuration.setWireService(WIRE_SERVICE); - for (Map.Entry entry : members.entrySet()) { - configuration.addReferenceSite(entry.getKey(), entry.getValue()); - } - configuration.setWorkContext(new WorkContextImpl()); - configuration.setName(sourceName); - - JavaAtomicComponent sourceComponent = new JavaAtomicComponent(configuration); - sourceComponent.setScopeContainer(sourceScope); - OutboundWire outboundWire = createOutboundWire(targetName, sourceReferenceClass, null); - outboundWire.setContainer(sourceComponent); - outboundWire.setTargetName(new QualifiedName(targetName + "/" + serviceName)); - List factories = new ArrayList(); - factories.add(outboundWire); - sourceComponent.addOutboundWires(factories); - targetScope.register(targetComponent); - sourceScope.register(sourceComponent); - CONNECTOR.connect(outboundWire, inboundWire, false); - Map components = new HashMap(); - components.put(sourceName, sourceComponent); - components.put(targetName, targetComponent); - return components; - } - - public static InboundWire createInboundWire(String serviceName, Class interfaze) - throws InvalidServiceContractException { - return createInboundWire(serviceName, interfaze, null); - } - - public static InboundWire createInboundWire(String serviceName, Class interfaze, Interceptor interceptor) - throws InvalidServiceContractException { - InboundWire wire = new InboundWireImpl(); - ServiceContract contract = REGISTRY.introspect(interfaze); - wire.setServiceContract(contract); - wire.setServiceName(serviceName); - wire.addInvocationChains(createInboundChains(interfaze, interceptor)); - return wire; - } - - public static OutboundWire createOutboundWire(String refName, Class interfaze) - throws InvalidServiceContractException { - return createOutboundWire(refName, interfaze, null); - } - - public static OutboundWire createOutboundWire(String refName, Class interfaze, Interceptor interceptor) - throws InvalidServiceContractException { - - OutboundWire wire = new OutboundWireImpl(); - wire.setReferenceName(refName); - Map, OutboundInvocationChain> outboundChains = createOutboundChains(interfaze, interceptor); - wire.addInvocationChains(outboundChains); - ServiceContract contract = REGISTRY.introspect(interfaze); - wire.setServiceContract(contract); - return wire; - } - - - @SuppressWarnings("unchecked") - private static JavaAtomicComponent createJavaComponent(String name, ScopeContainer scope, Class clazz) - throws NoSuchMethodException { - PojoConfiguration configuration = new PojoConfiguration(); - configuration.setInstanceFactory(new PojoObjectFactory(clazz.getConstructor())); - configuration.setWireService(WIRE_SERVICE); - configuration.setWorkContext(new WorkContextImpl()); - configuration.setName(name); - JavaAtomicComponent component = new JavaAtomicComponent(configuration); - component.setScopeContainer(scope); - return component; - } - - private static Map, OutboundInvocationChain> createOutboundChains(Class interfaze, - Interceptor interceptor) - throws InvalidServiceContractException { - Map, OutboundInvocationChain> invocations = new HashMap, OutboundInvocationChain>(); - ServiceContract contract = REGISTRY.introspect(interfaze); - for (Operation operation : contract.getOperations().values()) { - OutboundInvocationChain chain = new OutboundInvocationChainImpl(operation); - if (interceptor != null) { - chain.addInterceptor(interceptor); - } - invocations.put(operation, chain); - } - return invocations; - } - - private static Map, InboundInvocationChain> createInboundChains(Class interfaze, - Interceptor interceptor) - throws InvalidServiceContractException { - - Map, InboundInvocationChain> invocations = new HashMap, InboundInvocationChain>(); - ServiceContract contract = REGISTRY.introspect(interfaze); - for (Operation method : contract.getOperations().values()) { - InboundInvocationChain chain = new InboundInvocationChainImpl(method); - if (interceptor != null) { - chain.addInterceptor(interceptor); - } - // add tail interceptor - chain.addInterceptor(new InvokerInterceptor()); - invocations.put(method, chain); - } - return invocations; - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/integration/scope/ScopeReferenceTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/integration/scope/ScopeReferenceTestCase.java deleted file mode 100644 index 4cd5ac8d9b..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/integration/scope/ScopeReferenceTestCase.java +++ /dev/null @@ -1,781 +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.integration.scope; - -import java.lang.reflect.Member; -import java.lang.reflect.Method; -import java.lang.reflect.Proxy; -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.Executor; -import java.util.concurrent.Executors; -import java.util.concurrent.FutureTask; - -import org.apache.tuscany.spi.component.AtomicComponent; -import org.apache.tuscany.spi.component.ScopeContainer; -import org.apache.tuscany.spi.component.TargetException; -import org.apache.tuscany.spi.component.WorkContext; -import org.apache.tuscany.spi.model.Scope; - -import junit.framework.TestCase; -import org.apache.tuscany.core.component.WorkContextImpl; -import org.apache.tuscany.core.component.event.CompositeStart; -import org.apache.tuscany.core.component.event.CompositeStop; -import org.apache.tuscany.core.component.event.HttpSessionEnd; -import org.apache.tuscany.core.component.event.HttpSessionStart; -import org.apache.tuscany.core.component.event.RequestEnd; -import org.apache.tuscany.core.component.event.RequestStart; -import org.apache.tuscany.core.component.scope.CompositeScopeContainer; -import org.apache.tuscany.core.component.scope.HttpSessionScopeContainer; -import org.apache.tuscany.core.component.scope.RequestScopeContainer; -import org.apache.tuscany.core.component.scope.StatelessScopeContainer; -import org.apache.tuscany.core.integration.mock.MockFactory; -import org.apache.tuscany.core.mock.component.Source; -import org.apache.tuscany.core.mock.component.SourceImpl; -import org.apache.tuscany.core.mock.component.Target; -import org.apache.tuscany.core.mock.component.TargetImpl; -import org.apache.tuscany.core.util.JavaIntrospectionHelper; - -/** - * Tests scoping is properly handled for service references - * - * @version $Rev$ $Date$ - */ -public class ScopeReferenceTestCase extends TestCase { - - private Map members; - - /** - * Tests a composite-to-composite scoped wire - */ - public void testCompositeToComposite() throws Exception { - ScopeContainer scope = new CompositeScopeContainer(null); - scope.start(); - - Map contexts = MockFactory.createWiredComponents("source", SourceImpl.class, - scope, members, "target", Target.class, TargetImpl.class, scope); - scope.onEvent(new CompositeStart(this, null)); - AtomicComponent sourceComponent = contexts.get("source"); - AtomicComponent targetComponent = contexts.get("target"); - Source source = (Source) sourceComponent.getTargetInstance(); - Target target = (Target) targetComponent.getTargetInstance(); - assertNull(source.getTarget().getString()); - assertNull(target.getString()); - target.setString("foo"); - assertTrue(Proxy.isProxyClass(source.getTarget().getClass())); - assertEquals("foo", source.getTarget().getString()); - scope.onEvent(new CompositeStop(this, null)); - scope.stop(); - } - - /** - * Tests a composite-to-session scoped wire is setup properly by the runtime - */ - public void testCompositeToSession() throws Exception { - WorkContext ctx = new WorkContextImpl(); - ScopeContainer compositeScope = new CompositeScopeContainer(null); - compositeScope.start(); - ScopeContainer sessionScope = new HttpSessionScopeContainer(ctx, null); - sessionScope.start(); - - Map contexts = MockFactory.createWiredComponents("source", SourceImpl.class, - compositeScope, members, "target", Target.class, TargetImpl.class, sessionScope); - compositeScope.onEvent(new CompositeStart(this, null)); - Object session1 = new Object(); - ctx.setIdentifier(Scope.SESSION, session1); - sessionScope.onEvent(new HttpSessionStart(this, session1)); - AtomicComponent sourceComponent = contexts.get("source"); - AtomicComponent targetComponent = contexts.get("target"); - Source source = (Source) sourceComponent.getTargetInstance(); - Target target = (Target) targetComponent.getTargetInstance(); - assertNull(source.getTarget().getString()); - assertNull(target.getString()); - target.setString("foo"); - assertTrue(Proxy.isProxyClass(source.getTarget().getClass())); - assertEquals("foo", source.getTarget().getString()); - ctx.clearIdentifier(Scope.SESSION); - sessionScope.onEvent(new HttpSessionEnd(this, session1)); - - //second session - Object session2 = new Object(); - ctx.setIdentifier(Scope.SESSION, session2); - sessionScope.onEvent(new HttpSessionStart(this, session2)); - - Target target2 = (Target) targetComponent.getTargetInstance(); - assertFalse("foo".equals(target2.getString())); - - assertFalse("foo".equals(source.getTarget().getString())); - source.getTarget().setString("bar"); - assertEquals("bar", target2.getString()); - assertEquals("bar", source.getTarget().getString()); - sessionScope.onEvent(new HttpSessionEnd(this, session2)); - - ctx.clearIdentifier(Scope.SESSION); - compositeScope.onEvent(new CompositeStop(this, null)); - sessionScope.stop(); - compositeScope.stop(); - } - - /** - * Tests a composite-to-request scoped wire - */ - public void testCompositeToRequest() throws Exception { - WorkContext ctx = new WorkContextImpl(); - ScopeContainer compositeScope = new CompositeScopeContainer(null); - compositeScope.start(); - final ScopeContainer requestScope = new RequestScopeContainer(ctx, null); - requestScope.start(); - - Map contexts = MockFactory.createWiredComponents("source", SourceImpl.class, - compositeScope, members, "target", Target.class, TargetImpl.class, requestScope); - compositeScope.onEvent(new CompositeStart(this, null)); - requestScope.onEvent(new RequestStart(this)); - - AtomicComponent sourceComponent = contexts.get("source"); - final AtomicComponent targetComponent = contexts.get("target"); - final Source source = (Source) sourceComponent.getTargetInstance(); - Target target = (Target) targetComponent.getTargetInstance(); - assertNull(source.getTarget().getString()); - assertNull(target.getString()); - target.setString("foo"); - assertTrue(Proxy.isProxyClass(source.getTarget().getClass())); - assertEquals("foo", source.getTarget().getString()); - - // spin off another request - Executor executor = Executors.newSingleThreadExecutor(); - FutureTask future = new FutureTask(new Runnable() { - public void run() { - requestScope.onEvent(new RequestStart(this)); - Target target2 = null; - try { - target2 = (Target) targetComponent.getTargetInstance(); - } catch (TargetException e) { - fail(e.getMessage()); - } - assertFalse("foo".equals(target2.getString())); - assertFalse("foo".equals(source.getTarget().getString())); - source.getTarget().setString("bar"); - assertEquals("bar", target2.getString()); - assertEquals("bar", source.getTarget().getString()); - requestScope.onEvent(new RequestEnd(this)); - } - }, null); - executor.execute(future); - future.get(); - assertEquals("foo", source.getTarget().getString()); - requestScope.onEvent(new RequestEnd(this)); - compositeScope.onEvent(new CompositeStop(this, null)); - requestScope.stop(); - compositeScope.stop(); - } - - /** - * Tests a composite-to-stateless scoped wire is setup properly by the runtime - */ - public void testCompositeToStateless() throws Exception { - WorkContext ctx = new WorkContextImpl(); - ScopeContainer compositeScope = new CompositeScopeContainer(null); - compositeScope.start(); - ScopeContainer statelessScope = new StatelessScopeContainer(ctx, null); - statelessScope.start(); - - Map contexts = MockFactory.createWiredComponents("source", SourceImpl.class, - compositeScope, members, "target", Target.class, TargetImpl.class, statelessScope); - compositeScope.onEvent(new CompositeStart(this, null)); - - AtomicComponent sourceComponent = contexts.get("source"); - AtomicComponent targetComponent = contexts.get("target"); - Source source = (Source) sourceComponent.getTargetInstance(); - Target target = (Target) targetComponent.getTargetInstance(); - assertTrue(Proxy.isProxyClass(source.getTarget().getClass())); - assertNull(source.getTarget().getString()); - assertNull(target.getString()); - target.setString("foo"); - assertFalse("foo".equals(source.getTarget().getString())); - Target target2 = (Target) targetComponent.getTargetInstance(); - assertFalse("foo".equals(target2.getString())); - source.getTarget().setString("bar"); - assertFalse("bar".equals(source.getTarget().getString())); - compositeScope.onEvent(new CompositeStop(this, null)); - compositeScope.stop(); - statelessScope.stop(); - } - - - /** - * Tests a session-to-session scoped wire - */ - public void testSessionToSession() throws Exception { - WorkContext ctx = new WorkContextImpl(); - ScopeContainer sessionScope = new HttpSessionScopeContainer(ctx, null); - sessionScope.start(); - - Map contexts = MockFactory.createWiredComponents("source", SourceImpl.class, - sessionScope, members, "target", Target.class, TargetImpl.class, sessionScope); - - Object session1 = new Object(); - ctx.setIdentifier(Scope.SESSION, session1); - sessionScope.onEvent(new HttpSessionStart(this, session1)); - AtomicComponent sourceComponent = contexts.get("source"); - AtomicComponent targetComponent = contexts.get("target"); - Source source = (Source) sourceComponent.getTargetInstance(); - Target target = (Target) targetComponent.getTargetInstance(); - source.getTarget().setString("foo"); - source.getTarget().setString("foo"); - assertEquals("foo", target.getString()); - - ctx.clearIdentifier(Scope.SESSION); - sessionScope.onEvent(new HttpSessionEnd(this, session1)); - - //second session - Object session2 = new Object(); - ctx.setIdentifier(Scope.SESSION, session2); - sessionScope.onEvent(new HttpSessionStart(this, session2)); - - Source source2 = (Source) sourceComponent.getTargetInstance(); - assertNotNull(source2); - Target target2 = (Target) targetComponent.getTargetInstance(); - - assertNotNull(target2); - assertNull(target2.getString()); - assertEquals(null, source2.getTarget().getString()); - source2.getTarget().setString("baz"); - assertEquals("baz", source2.getTarget().getString()); - assertEquals("baz", target2.getString()); - ctx.clearIdentifier(Scope.SESSION); - sessionScope.onEvent(new HttpSessionEnd(this, session2)); - sessionScope.stop(); - } - - - /** - * Tests a session-to-composite scoped wire - */ - public void testSessionToComposite() throws Exception { - WorkContext ctx = new WorkContextImpl(); - ScopeContainer compositeScope = new CompositeScopeContainer(null); - compositeScope.start(); - ScopeContainer sessionScope = new HttpSessionScopeContainer(ctx, null); - sessionScope.start(); - - Map contexts = MockFactory.createWiredComponents("source", SourceImpl.class, - sessionScope, members, "target", Target.class, TargetImpl.class, compositeScope); - compositeScope.onEvent(new CompositeStart(this, null)); - Object session1 = new Object(); - ctx.setIdentifier(Scope.SESSION, session1); - sessionScope.onEvent(new HttpSessionStart(this, session1)); - AtomicComponent sourceComponent = contexts.get("source"); - AtomicComponent targetComponent = contexts.get("target"); - Source source = (Source) sourceComponent.getTargetInstance(); - Target target = (Target) targetComponent.getTargetInstance(); - assertNull(source.getTarget().getString()); - assertNull(target.getString()); - target.setString("foo"); - assertTrue(Proxy.isProxyClass(source.getTarget().getClass())); - assertEquals("foo", source.getTarget().getString()); - ctx.clearIdentifier(Scope.SESSION); - sessionScope.onEvent(new HttpSessionEnd(this, session1)); - - //second session - Object session2 = new Object(); - ctx.setIdentifier(Scope.SESSION, session2); - sessionScope.onEvent(new HttpSessionStart(this, session2)); - - Target target2 = (Target) targetComponent.getTargetInstance(); - Source source2 = (Source) sourceComponent.getTargetInstance(); - assertEquals("foo", target2.getString()); - assertEquals("foo", source2.getTarget().getString()); - source2.getTarget().setString("baz"); - assertEquals("baz", source2.getTarget().getString()); - assertEquals("baz", target2.getString()); - assertEquals("baz", target.getString()); - ctx.clearIdentifier(Scope.SESSION); - sessionScope.onEvent(new HttpSessionEnd(this, session2)); - compositeScope.stop(); - sessionScope.stop(); - } - - /** - * Tests a session-to-request scoped wire is setup properly by the runtime - */ - public void testSessionToRequest() throws Exception { - WorkContext ctx = new WorkContextImpl(); - final ScopeContainer requestScope = new RequestScopeContainer(ctx, null); - requestScope.start(); - ScopeContainer sessionScope = new HttpSessionScopeContainer(ctx, null); - sessionScope.start(); - - Map contexts = MockFactory.createWiredComponents("source", SourceImpl.class, - sessionScope, members, "target", Target.class, TargetImpl.class, requestScope); - Object session1 = new Object(); - ctx.setIdentifier(Scope.SESSION, session1); - sessionScope.onEvent(new HttpSessionStart(this, session1)); - requestScope.onEvent(new RequestStart(this)); - AtomicComponent sourceComponent = contexts.get("source"); - final AtomicComponent targetComponent = contexts.get("target"); - final Source source = (Source) sourceComponent.getTargetInstance(); - Target target = (Target) targetComponent.getTargetInstance(); - assertNull(source.getTarget().getString()); - assertNull(target.getString()); - target.setString("foo"); - assertTrue(Proxy.isProxyClass(source.getTarget().getClass())); - assertEquals("foo", source.getTarget().getString()); - - // spin off another request - Executor executor = Executors.newSingleThreadExecutor(); - FutureTask future = new FutureTask(new Runnable() { - public void run() { - requestScope.onEvent(new RequestStart(this)); - Target target2 = null; - try { - target2 = (Target) targetComponent.getTargetInstance(); - } catch (TargetException e) { - fail(e.getMessage()); - } - assertFalse("foo".equals(target2.getString())); - assertFalse("foo".equals(source.getTarget().getString())); - source.getTarget().setString("bar"); - assertEquals("bar", target2.getString()); - assertEquals("bar", source.getTarget().getString()); - requestScope.onEvent(new RequestEnd(this)); - } - }, null); - executor.execute(future); - future.get(); - assertEquals("foo", source.getTarget().getString()); - requestScope.onEvent(new RequestEnd(this)); - ctx.clearIdentifier(Scope.SESSION); - sessionScope.onEvent(new HttpSessionEnd(this, session1)); - requestScope.stop(); - sessionScope.stop(); - } - - - /** - * Tests a session-to-stateless scoped wire is setup properly by the runtime - */ - public void testSessionToStateless() throws Exception { - WorkContext ctx = new WorkContextImpl(); - ScopeContainer sessionScope = new HttpSessionScopeContainer(ctx, null); - sessionScope.start(); - ScopeContainer statelessScope = new StatelessScopeContainer(ctx, null); - statelessScope.start(); - - Map contexts = MockFactory.createWiredComponents("source", SourceImpl.class, - sessionScope, members, "target", Target.class, TargetImpl.class, statelessScope); - - Object session1 = new Object(); - ctx.setIdentifier(Scope.SESSION, session1); - sessionScope.onEvent(new HttpSessionStart(this, session1)); - - AtomicComponent sourceComponent = contexts.get("source"); - AtomicComponent targetComponent = contexts.get("target"); - Source source = (Source) sourceComponent.getTargetInstance(); - Target target = (Target) targetComponent.getTargetInstance(); - assertTrue(Proxy.isProxyClass(source.getTarget().getClass())); - assertNull(source.getTarget().getString()); - assertNull(target.getString()); - target.setString("foo"); - assertFalse("foo".equals(source.getTarget().getString())); - Target target2 = (Target) targetComponent.getTargetInstance(); - assertFalse("foo".equals(target2.getString())); - source.getTarget().setString("bar"); - assertFalse("bar".equals(source.getTarget().getString())); - - ctx.clearIdentifier(Scope.SESSION); - sessionScope.onEvent(new HttpSessionEnd(this, session1)); - sessionScope.stop(); - statelessScope.stop(); - } - - /** - * Tests a request-to-request scoped wire is setup properly by the runtime - */ - public void testRequestToRequest() throws Exception { - WorkContext ctx = new WorkContextImpl(); - final ScopeContainer requestScope = new RequestScopeContainer(ctx, null); - requestScope.start(); - - Map contexts = MockFactory.createWiredComponents("source", SourceImpl.class, - requestScope, members, "target", Target.class, TargetImpl.class, requestScope); - requestScope.onEvent(new RequestStart(this)); - - final AtomicComponent sourceComponent = contexts.get("source"); - final AtomicComponent targetComponent = contexts.get("target"); - Source source = (Source) sourceComponent.getTargetInstance(); - Target target = (Target) targetComponent.getTargetInstance(); - assertNull(source.getTarget().getString()); - assertNull(target.getString()); - target.setString("foo"); - assertTrue(Proxy.isProxyClass(source.getTarget().getClass())); - assertEquals("foo", source.getTarget().getString()); - - // spin off another request - Executor executor = Executors.newSingleThreadExecutor(); - FutureTask future = new FutureTask(new Runnable() { - public void run() { - requestScope.onEvent(new RequestStart(this)); - Source source2 = null; - Target target2 = null; - try { - source2 = (Source) sourceComponent.getTargetInstance(); - target2 = (Target) targetComponent.getTargetInstance(); - } catch (TargetException e) { - fail(e.getMessage()); - } - assertFalse("foo".equals(target2.getString())); - assertFalse("foo".equals(source2.getTarget().getString())); - source2.getTarget().setString("bar"); - assertEquals("bar", target2.getString()); - assertEquals("bar", source2.getTarget().getString()); - requestScope.onEvent(new RequestEnd(this)); - } - }, null); - executor.execute(future); - future.get(); - requestScope.onEvent(new RequestEnd(this)); - requestScope.stop(); - } - - /** - * Tests a request-to-composite scoped wire - */ - public void testRequestToComposite() throws Exception { - WorkContext ctx = new WorkContextImpl(); - final ScopeContainer requestScope = new RequestScopeContainer(ctx, null); - final ScopeContainer compositeScope = new CompositeScopeContainer(null); - requestScope.start(); - compositeScope.start(); - compositeScope.onEvent(new CompositeStart(this, null)); - - Map contexts = MockFactory.createWiredComponents("source", SourceImpl.class, - requestScope, members, "target", Target.class, TargetImpl.class, compositeScope); - requestScope.onEvent(new RequestStart(this)); - - final AtomicComponent sourceComponent = contexts.get("source"); - final AtomicComponent targetComponent = contexts.get("target"); - Source source = (Source) sourceComponent.getTargetInstance(); - Target target = (Target) targetComponent.getTargetInstance(); - assertNull(source.getTarget().getString()); - assertNull(target.getString()); - target.setString("foo"); - assertTrue(Proxy.isProxyClass(source.getTarget().getClass())); - assertEquals("foo", source.getTarget().getString()); - - // spin off another request - Executor executor = Executors.newSingleThreadExecutor(); - FutureTask future = new FutureTask(new Runnable() { - public void run() { - requestScope.onEvent(new RequestStart(this)); - Source source2 = null; - Target target2 = null; - try { - source2 = (Source) sourceComponent.getTargetInstance(); - target2 = (Target) targetComponent.getTargetInstance(); - } catch (TargetException e) { - fail(e.getMessage()); - } - assertEquals("foo", target2.getString()); - assertEquals("foo", source2.getTarget().getString()); - source2.getTarget().setString("bar"); - assertEquals("bar", target2.getString()); - assertEquals("bar", source2.getTarget().getString()); - requestScope.onEvent(new RequestEnd(this)); - } - }, null); - executor.execute(future); - future.get(); - assertEquals("bar", target.getString()); - - requestScope.onEvent(new RequestEnd(this)); - requestScope.stop(); - compositeScope.onEvent(new CompositeStop(this, null)); - compositeScope.stop(); - } - - /** - * Tests a request-to-session scoped wire is setup properly by the runtime - */ - public void testRequestToSession() throws Exception { - WorkContext ctx = new WorkContextImpl(); - final ScopeContainer requestScope = new RequestScopeContainer(ctx, null); - final ScopeContainer sessionScope = new HttpSessionScopeContainer(ctx, null); - requestScope.start(); - sessionScope.start(); - - Object session1 = new Object(); - ctx.setIdentifier(Scope.SESSION, session1); - sessionScope.onEvent(new HttpSessionStart(this, session1)); - Map contexts = MockFactory.createWiredComponents("source", SourceImpl.class, - requestScope, members, "target", Target.class, TargetImpl.class, sessionScope); - - final AtomicComponent sourceComponent = contexts.get("source"); - final AtomicComponent targetComponent = contexts.get("target"); - requestScope.onEvent(new RequestStart(this)); - Source source = (Source) sourceComponent.getTargetInstance(); - Target target = (Target) targetComponent.getTargetInstance(); - assertNull(source.getTarget().getString()); - assertNull(target.getString()); - target.setString("foo"); - assertTrue(Proxy.isProxyClass(source.getTarget().getClass())); - assertEquals("foo", source.getTarget().getString()); - - // spin off another request - Executor executor = Executors.newSingleThreadExecutor(); - FutureTask future = new FutureTask(new Runnable() { - public void run() { - requestScope.onEvent(new RequestStart(this)); - Source source2 = null; - Target target2 = null; - try { - source2 = (Source) sourceComponent.getTargetInstance(); - target2 = (Target) targetComponent.getTargetInstance(); - } catch (TargetException e) { - fail(e.getMessage()); - } - assertEquals("foo", target2.getString()); - assertEquals("foo", source2.getTarget().getString()); - source2.getTarget().setString("bar"); - assertEquals("bar", target2.getString()); - assertEquals("bar", source2.getTarget().getString()); - requestScope.onEvent(new RequestEnd(this)); - } - }, null); - executor.execute(future); - future.get(); - assertEquals("bar", target.getString()); - - requestScope.onEvent(new RequestEnd(this)); - requestScope.stop(); - ctx.clearIdentifier(Scope.SESSION); - sessionScope.onEvent(new HttpSessionEnd(this, session1)); - sessionScope.stop(); - } - - - /** - * Tests a request-to-stateless scoped wire is setup properly by the runtime - */ - public void testRequestToStateless() throws Exception { - WorkContext ctx = new WorkContextImpl(); - ScopeContainer requestScope = new RequestScopeContainer(ctx, null); - requestScope.start(); - ScopeContainer statelessScope = new StatelessScopeContainer(ctx, null); - statelessScope.start(); - - Map contexts = MockFactory.createWiredComponents("source", SourceImpl.class, - requestScope, members, "target", Target.class, TargetImpl.class, statelessScope); - - AtomicComponent sourceComponent = contexts.get("source"); - AtomicComponent targetComponent = contexts.get("target"); - requestScope.onEvent(new RequestStart(this)); - Source source = (Source) sourceComponent.getTargetInstance(); - Target target = (Target) targetComponent.getTargetInstance(); - assertTrue(Proxy.isProxyClass(source.getTarget().getClass())); - assertNull(source.getTarget().getString()); - assertNull(target.getString()); - target.setString("foo"); - assertFalse("foo".equals(source.getTarget().getString())); - Target target2 = (Target) targetComponent.getTargetInstance(); - assertFalse("foo".equals(target2.getString())); - source.getTarget().setString("bar"); - assertFalse("bar".equals(source.getTarget().getString())); - requestScope.onEvent(new RequestEnd(this)); - requestScope.stop(); - statelessScope.stop(); - } - - - /** - * Tests a stateless-to-stateless scoped wire is setup properly by the runtime - */ - public void testStatelessToStateless() throws Exception { - WorkContext ctx = new WorkContextImpl(); - ScopeContainer statelessScope = new StatelessScopeContainer(ctx, null); - statelessScope.start(); - - Map contexts = MockFactory.createWiredComponents("source", SourceImpl.class, - statelessScope, members, "target", Target.class, TargetImpl.class, statelessScope); - - AtomicComponent sourceComponent = contexts.get("source"); - AtomicComponent targetComponent = contexts.get("target"); - Source source = (Source) sourceComponent.getTargetInstance(); - Target target = (Target) targetComponent.getTargetInstance(); - assertTrue(Proxy.isProxyClass(source.getTarget().getClass())); - assertNull(source.getTarget().getString()); - assertNull(target.getString()); - target.setString("foo"); - assertFalse("foo".equals(source.getTarget().getString())); - Target target2 = (Target) targetComponent.getTargetInstance(); - assertFalse("foo".equals(target2.getString())); - source.getTarget().setString("bar"); - assertFalse("bar".equals(source.getTarget().getString())); - statelessScope.stop(); - } - - /** - * Tests a stateless-to-request scoped wire is setup properly by the runtime - */ - public void testStatelessToRequest() throws Exception { - WorkContext ctx = new WorkContextImpl(); - final ScopeContainer requestScope = new RequestScopeContainer(ctx, null); - requestScope.start(); - ScopeContainer statelessScope = new StatelessScopeContainer(ctx, null); - statelessScope.start(); - - Map contexts = MockFactory.createWiredComponents("source", SourceImpl.class, - statelessScope, members, "target", Target.class, TargetImpl.class, requestScope); - requestScope.onEvent(new RequestStart(this)); - AtomicComponent sourceComponent = contexts.get("source"); - final AtomicComponent targetComponent = contexts.get("target"); - final Source source = (Source) sourceComponent.getTargetInstance(); - Target target = (Target) targetComponent.getTargetInstance(); - assertNull(source.getTarget().getString()); - assertNull(target.getString()); - target.setString("foo"); - assertTrue(Proxy.isProxyClass(source.getTarget().getClass())); - assertEquals("foo", source.getTarget().getString()); - - // spin off another request - Executor executor = Executors.newSingleThreadExecutor(); - FutureTask future = new FutureTask(new Runnable() { - public void run() { - requestScope.onEvent(new RequestStart(this)); - Target target2 = null; - try { - target2 = (Target) targetComponent.getTargetInstance(); - } catch (TargetException e) { - fail(e.getMessage()); - } - assertFalse("foo".equals(target2.getString())); - assertFalse("foo".equals(source.getTarget().getString())); - source.getTarget().setString("bar"); - assertEquals("bar", target2.getString()); - assertEquals("bar", source.getTarget().getString()); - requestScope.onEvent(new RequestEnd(this)); - } - }, null); - executor.execute(future); - future.get(); - requestScope.stop(); - statelessScope.stop(); - } - - /** - * Tests a stateless-to-session scoped wire is setup properly by the runtime - */ - public void testStatelessToSession() throws Exception { - WorkContext ctx = new WorkContextImpl(); - ScopeContainer statelessScope = new StatelessScopeContainer(ctx, null); - statelessScope.start(); - ScopeContainer sessionScope = new HttpSessionScopeContainer(ctx, null); - sessionScope.start(); - - Map contexts = MockFactory.createWiredComponents("source", SourceImpl.class, - statelessScope, members, "target", Target.class, TargetImpl.class, sessionScope); - Object session1 = new Object(); - ctx.setIdentifier(Scope.SESSION, session1); - sessionScope.onEvent(new HttpSessionStart(this, session1)); - AtomicComponent sourceComponent = contexts.get("source"); - AtomicComponent targetComponent = contexts.get("target"); - Source source = (Source) sourceComponent.getTargetInstance(); - Target target = (Target) targetComponent.getTargetInstance(); - assertNull(source.getTarget().getString()); - assertNull(target.getString()); - target.setString("foo"); - assertTrue(Proxy.isProxyClass(source.getTarget().getClass())); - assertEquals("foo", source.getTarget().getString()); - ctx.clearIdentifier(Scope.SESSION); - sessionScope.onEvent(new HttpSessionEnd(this, session1)); - - //second session - Object session2 = new Object(); - ctx.setIdentifier(Scope.SESSION, session2); - sessionScope.onEvent(new HttpSessionStart(this, session2)); - - Target target2 = (Target) targetComponent.getTargetInstance(); - assertFalse("foo".equals(target2.getString())); - - assertFalse("foo".equals(source.getTarget().getString())); - source.getTarget().setString("bar"); - assertEquals("bar", target2.getString()); - assertEquals("bar", source.getTarget().getString()); - sessionScope.onEvent(new HttpSessionEnd(this, session2)); - - ctx.clearIdentifier(Scope.SESSION); - sessionScope.stop(); - statelessScope.stop(); - } - - - /** - * Tests a stateless-to-composite scoped wire is setup properly by the runtime - */ - public void testStatelessToComposite() throws Exception { - WorkContext ctx = new WorkContextImpl(); - ScopeContainer statelessScope = new StatelessScopeContainer(ctx, null); - statelessScope.start(); - ScopeContainer compositeScope = new CompositeScopeContainer(null); - compositeScope.start(); - - Map contexts = MockFactory.createWiredComponents("source", SourceImpl.class, - statelessScope, members, "target", Target.class, TargetImpl.class, compositeScope); - compositeScope.onEvent(new CompositeStart(this, null)); - AtomicComponent sourceComponent = contexts.get("source"); - AtomicComponent targetComponent = contexts.get("target"); - Source source = (Source) sourceComponent.getTargetInstance(); - Target target = (Target) targetComponent.getTargetInstance(); - assertNull(source.getTarget().getString()); - assertNull(target.getString()); - target.setString("foo"); - assertTrue(Proxy.isProxyClass(source.getTarget().getClass())); - assertEquals("foo", source.getTarget().getString()); - - //second session - Object session2 = new Object(); - ctx.setIdentifier(Scope.SESSION, session2); - compositeScope.onEvent(new HttpSessionStart(this, session2)); - - Target target2 = (Target) targetComponent.getTargetInstance(); - assertEquals("foo", target2.getString()); - - assertEquals("foo", source.getTarget().getString()); - source.getTarget().setString("bar"); - assertEquals("bar", target2.getString()); - assertEquals("bar", source.getTarget().getString()); - - compositeScope.onEvent(new CompositeStop(this, null)); - compositeScope.stop(); - statelessScope.stop(); - } - - protected void setUp() throws Exception { - super.setUp(); - members = new HashMap(); - Method[] methods = SourceImpl.class.getMethods(); - for (Method method : methods) { - if (method.getName().startsWith("set")) { - members.put(JavaIntrospectionHelper.toPropertyName(method.getName()), method); - } - } - } - - -} - diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/integration/wire/DifferentInterfaceWireTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/integration/wire/DifferentInterfaceWireTestCase.java deleted file mode 100644 index 431f47b5bf..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/integration/wire/DifferentInterfaceWireTestCase.java +++ /dev/null @@ -1,137 +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.integration.wire; - -import java.lang.reflect.Member; -import java.lang.reflect.Method; -import java.lang.reflect.Proxy; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.tuscany.spi.component.AtomicComponent; -import org.apache.tuscany.spi.component.ScopeContainer; -import org.apache.tuscany.spi.component.TargetException; -import org.apache.tuscany.spi.model.Scope; - -import junit.framework.TestCase; -import org.apache.tuscany.core.integration.mock.MockFactory; -import org.apache.tuscany.core.mock.component.OtherTarget; -import org.apache.tuscany.core.mock.component.OtherTargetImpl; -import org.apache.tuscany.core.mock.component.Target; -import org.apache.tuscany.core.mock.component.SourceImpl; -import org.apache.tuscany.core.mock.component.Source; -import org.easymock.EasyMock; -import org.easymock.IAnswer; - - -/** - * Tests wires that have different interfaces on the source and target side - * - * @version $Rev$ $Date$ - */ -public class DifferentInterfaceWireTestCase extends TestCase { - - public void testDifferentInterfaceInjection() throws Exception { - Map members = new HashMap(); - Method m = SourceImpl.class.getMethod("setTarget", Target.class); - members.put("target", m); - ScopeContainer scope = createMock(); - scope.start(); - Map contexts = - MockFactory.createWiredComponents("source", - SourceImpl.class, - Target.class, - scope, - null, - members, - "target", - OtherTarget.class, - OtherTargetImpl.class, - scope, - null); - AtomicComponent sourceComponent = contexts.get("source"); - Source source = (Source) sourceComponent.getTargetInstance(); - Target target = source.getTarget(); - assertTrue(Proxy.isProxyClass(target.getClass())); - assertNotNull(target); - scope.stop(); - EasyMock.verify(scope); - } - - public void testDifferentInterfaceMultiplicityInjection() throws Exception { - Map members = new HashMap(); - Method m = SourceImpl.class.getMethod("setTargets", List.class); - members.put("target", m); - ScopeContainer scope = createMock(); - scope.start(); - Map components = MockFactory.createWiredMultiplicity("source", - SourceImpl.class, - Target.class, - scope, - "target", - OtherTarget.class, - OtherTargetImpl.class, - members, - scope); - AtomicComponent sourceComponent = components.get("source"); - Source source = (Source) sourceComponent.getTargetInstance(); - List targets = source.getTargets(); - assertEquals(1, targets.size()); - Target target = targets.get(0); - target.setString("foo"); - assertEquals("foo", target.getString()); - assertTrue(Proxy.isProxyClass(target.getClass())); - scope.stop(); - EasyMock.verify(scope); - } - - protected void setUp() throws Exception { - super.setUp(); - } - - protected void tearDown() throws Exception { - super.tearDown(); - } - - private ScopeContainer createMock() throws TargetException { - ScopeContainer scope = EasyMock.createMock(ScopeContainer.class); - scope.start(); - scope.stop(); - scope.register(EasyMock.isA(AtomicComponent.class)); - EasyMock.expectLastCall().atLeastOnce(); - EasyMock.expect(scope.getScope()).andReturn(Scope.COMPOSITE).atLeastOnce(); - scope.getInstance(EasyMock.isA(AtomicComponent.class)); - EasyMock.expectLastCall().andAnswer(new IAnswer() { - private Map cache = new HashMap(); - - public Object answer() throws Throwable { - AtomicComponent component = (AtomicComponent) EasyMock.getCurrentArguments()[0]; - Object instance = cache.get(component); - if (instance == null) { - instance = component.createInstance(); - cache.put(component, instance); - } - return instance; - } - }).anyTimes(); - EasyMock.replay(scope); - return scope; - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/integration/wire/ReferenceInjectionTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/integration/wire/ReferenceInjectionTestCase.java deleted file mode 100644 index 603e334fe9..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/integration/wire/ReferenceInjectionTestCase.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.integration.wire; - -import java.lang.reflect.Member; -import java.lang.reflect.Method; -import java.lang.reflect.Proxy; -import java.util.HashMap; -import java.util.Map; - -import org.apache.tuscany.spi.component.AtomicComponent; -import org.apache.tuscany.spi.component.ScopeContainer; - -import junit.framework.TestCase; -import org.apache.tuscany.core.component.scope.CompositeScopeContainer; -import org.apache.tuscany.core.integration.mock.MockFactory; -import org.apache.tuscany.core.mock.component.Source; -import org.apache.tuscany.core.mock.component.SourceImpl; -import org.apache.tuscany.core.mock.component.TargetImpl; -import org.apache.tuscany.core.mock.component.Target; - -/** - * @version $$Rev$$ $$Date$$ - */ -public class ReferenceInjectionTestCase extends TestCase { - - private Map members; - - public void testProxiedReferenceInjection() throws Exception { - ScopeContainer scope = new CompositeScopeContainer(null); - scope.start(); - Map components = - MockFactory.createWiredComponents("source", SourceImpl.class, scope, - members, "target", Target.class, TargetImpl.class, scope); - AtomicComponent sourceComponent = components.get("source"); - Source source = (Source) sourceComponent.getTargetInstance(); - Target target = source.getTarget(); - assertTrue(Proxy.isProxyClass(target.getClass())); - - assertNotNull(target); - scope.stop(); - } - - protected void setUp() throws Exception { - super.setUp(); - members = new HashMap(); - Method m = SourceImpl.class.getMethod("setTarget", Target.class); - members.put("target", m); - } - - protected void tearDown() throws Exception { - super.tearDown(); - } - - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/integration/wire/oneway/OneWayWireToJavaInvocationTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/integration/wire/oneway/OneWayWireToJavaInvocationTestCase.java deleted file mode 100644 index 78e349b788..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/integration/wire/oneway/OneWayWireToJavaInvocationTestCase.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.integration.wire.oneway; - -import java.lang.reflect.Method; -import java.lang.reflect.Type; -import java.util.concurrent.CountDownLatch; - -import org.apache.tuscany.spi.component.WorkContext; -import org.apache.tuscany.spi.extension.ExecutionMonitor; -import org.apache.tuscany.spi.model.Operation; -import org.apache.tuscany.spi.model.Scope; -import org.apache.tuscany.spi.services.work.WorkScheduler; -import org.apache.tuscany.spi.wire.InboundInvocationChain; -import org.apache.tuscany.spi.wire.InboundWire; -import org.apache.tuscany.spi.wire.Interceptor; -import org.apache.tuscany.spi.wire.Message; -import org.apache.tuscany.spi.wire.MessageImpl; -import org.apache.tuscany.spi.wire.OutboundInvocationChain; -import org.apache.tuscany.spi.wire.TargetInvoker; - -import junit.framework.TestCase; -import org.apache.tuscany.core.component.WorkContextImpl; -import org.apache.tuscany.core.implementation.java.JavaAtomicComponent; -import org.apache.tuscany.core.implementation.java.JavaTargetInvoker; -import org.apache.tuscany.core.services.work.jsr237.Jsr237WorkScheduler; -import org.apache.tuscany.core.services.work.jsr237.workmanager.ThreadPoolWorkManager; -import org.apache.tuscany.core.wire.InboundInvocationChainImpl; -import org.apache.tuscany.core.wire.InvokerInterceptor; -import org.apache.tuscany.core.wire.NonBlockingBridgingInterceptor; -import org.apache.tuscany.core.wire.OutboundInvocationChainImpl; -import org.easymock.classextension.EasyMock; - -/** - * Verifies non-blocking invocations are properly made through a wire to a Java component - * - * @version $Rev$ $Date$ - */ -public class OneWayWireToJavaInvocationTestCase extends TestCase { - private WorkScheduler scheduler; - private WorkContext context; - private CountDownLatch latch; - private OutboundInvocationChain ochain; - private JavaTargetInvoker invoker; - private JavaAtomicComponent component; - private AsyncTarget target; - - public void testOneWay() throws Exception { - MessageImpl msg = new MessageImpl(); - msg.setTargetInvoker(invoker); - ochain.getHeadInterceptor().invoke(msg); - latch.await(); - EasyMock.verify(target); - EasyMock.verify(component); - } - - protected void setUp() throws Exception { - super.setUp(); - latch = new CountDownLatch(1); - context = new WorkContextImpl(); - scheduler = new Jsr237WorkScheduler(new ThreadPoolWorkManager(1)); - target = EasyMock.createMock(AsyncTarget.class); - target.invoke(); - EasyMock.expectLastCall().once(); - EasyMock.replay(target); - component = EasyMock.createMock(JavaAtomicComponent.class); - EasyMock.expect(component.getScope()).andReturn(Scope.COMPOSITE); - EasyMock.expect(component.getTargetInstance()).andReturn(target); - EasyMock.replay(component); - Method method = AsyncTarget.class.getMethod("invoke"); - method.setAccessible(true); - InboundWire inboundWire = EasyMock.createMock(InboundWire.class); - ExecutionMonitor monitor = EasyMock.createNiceMock(ExecutionMonitor.class); - invoker = new JavaTargetInvoker(method, component, inboundWire, context, monitor); - Operation operation = new Operation("invoke", null, null, null, false, null, TargetInvoker.NONE); - ochain = new OutboundInvocationChainImpl(operation); - NonBlockingBridgingInterceptor bridgeInterceptor = new NonBlockingBridgingInterceptor(scheduler, context); - ochain.addInterceptor(bridgeInterceptor); - InboundInvocationChain ichain = new InboundInvocationChainImpl(operation); - WaitInterceptor waitInterceptor = new WaitInterceptor(); - InvokerInterceptor invokerInterceptor = new InvokerInterceptor(); - ichain.addInterceptor(waitInterceptor); - ichain.addInterceptor(invokerInterceptor); - bridgeInterceptor.setNext(waitInterceptor); - ochain.setTargetInvoker(invoker); - } - - public interface AsyncTarget { - void invoke(); - } - - - private class WaitInterceptor implements Interceptor { - private Interceptor next; - - public Message invoke(Message msg) { - msg = next.invoke(msg); - latch.countDown(); - return msg; - } - - public Interceptor getNext() { - return next; - } - - public void setNext(Interceptor next) { - this.next = next; - } - - public boolean isOptimizable() { - return false; - } - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/loader/ComponentLoaderNoBindingTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/loader/ComponentLoaderNoBindingTestCase.java deleted file mode 100644 index 627351b250..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/loader/ComponentLoaderNoBindingTestCase.java +++ /dev/null @@ -1,91 +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.stream.XMLStreamConstants; -import javax.xml.stream.XMLStreamReader; - -import static org.osoa.sca.Version.XML_NAMESPACE_1_0; - -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.deployer.DeploymentContext; -import org.apache.tuscany.spi.implementation.java.PojoComponentType; -import org.apache.tuscany.spi.loader.LoaderRegistry; -import org.apache.tuscany.spi.model.BoundReferenceDefinition; -import org.apache.tuscany.spi.model.BoundServiceDefinition; -import org.apache.tuscany.spi.model.Implementation; -import org.apache.tuscany.spi.model.ModelObject; -import org.apache.tuscany.spi.model.Property; -import org.apache.tuscany.spi.model.ReferenceDefinition; - -import junit.framework.TestCase; -import org.apache.tuscany.core.implementation.java.JavaImplementation; -import org.easymock.EasyMock; - -/** - * @version $Rev$ $Date$ - */ -public class ComponentLoaderNoBindingTestCase extends TestCase { - private static final QName COMPONENT = new QName(XML_NAMESPACE_1_0, "component"); - private ComponentLoader loader; - private XMLStreamReader reader; - private BoundServiceDefinition service; - private BoundReferenceDefinition reference; - - public void testNoServiceBinding() throws Exception { - loader.load(null, null, reader, null); - assert service.getBindings().isEmpty(); - } - - public void testNoReferenceBinding() throws Exception { - loader.load(null, null, reader, null); - assert reference.getBindings().isEmpty(); - } - - protected void setUp() throws Exception { - super.setUp(); - service = new BoundServiceDefinition(); - reference = new BoundReferenceDefinition(); - PojoComponentType> type = - new PojoComponentType>(); - type.add(service); - type.add(reference); - JavaImplementation impl = new JavaImplementation(); - impl.setComponentType(type); - LoaderRegistry registry = EasyMock.createMock(LoaderRegistry.class); - EasyMock.expect(registry.load((CompositeComponent) EasyMock.isNull(), - (ModelObject) EasyMock.isNull(), - EasyMock.isA(XMLStreamReader.class), - (DeploymentContext) EasyMock.isNull())).andReturn(impl); - registry.loadComponentType((CompositeComponent) EasyMock.isNull(), - EasyMock.isA(Implementation.class), - (DeploymentContext) EasyMock.isNull()); - EasyMock.replay(registry); - loader = new ComponentLoader(registry, null); - reader = EasyMock.createMock(XMLStreamReader.class); - EasyMock.expect(reader.getName()).andReturn(COMPONENT).atLeastOnce(); - EasyMock.expect(reader.next()).andReturn(XMLStreamConstants.END_ELEMENT); - EasyMock.expect(reader.getAttributeValue(null, "name")).andReturn("foo"); - EasyMock.expect(reader.getAttributeValue(null, "initLevel")).andReturn("0"); - EasyMock.expect(reader.nextTag()).andReturn(1); - EasyMock.replay(reader); - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/loader/ComponentLoaderPropertyTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/loader/ComponentLoaderPropertyTestCase.java deleted file mode 100644 index 2c31de1df3..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/loader/ComponentLoaderPropertyTestCase.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.loader; - -import javax.xml.stream.XMLStreamException; - -import org.apache.tuscany.spi.implementation.java.PojoComponentType; -import org.apache.tuscany.spi.loader.LoaderException; -import org.apache.tuscany.spi.loader.LoaderRegistry; -import org.apache.tuscany.spi.loader.MissingMustOverridePropertyException; -import org.apache.tuscany.spi.loader.PropertyObjectFactory; -import org.apache.tuscany.spi.model.ComponentDefinition; -import org.apache.tuscany.spi.model.Implementation; -import org.apache.tuscany.spi.model.OverrideOptions; -import org.apache.tuscany.spi.model.Property; -import org.apache.tuscany.spi.model.ReferenceDefinition; -import org.apache.tuscany.spi.model.ServiceDefinition; - -import junit.framework.TestCase; -import org.apache.tuscany.core.implementation.java.JavaImplementation; -import org.easymock.EasyMock; - -/** - * @version $Rev$ $Date$ - */ -public class ComponentLoaderPropertyTestCase extends TestCase { - - private TestLoader loader; - - /** - * Verifies that an optional property not cofigured in an assembly will avoid having a PropertyValue created for it - * so that the runtime does not erroneously inject null values - */ - public void testOptionalPropertyNotConfigured() throws LoaderException, XMLStreamException { - PojoComponentType> type = - new PojoComponentType>(); - Property property = new Property(); - property.setName("name"); - property.setOverride(OverrideOptions.MAY); - type.add(property); - JavaImplementation impl = new JavaImplementation(); - impl.setComponentType(type); - ComponentDefinition> defn = new ComponentDefinition>(impl); - loader.populatePropertyValues(defn); - assertTrue(defn.getPropertyValues().isEmpty()); - } - - protected void setUp() throws Exception { - super.setUp(); - LoaderRegistry mockRegistry = EasyMock.createMock(LoaderRegistry.class); - PropertyObjectFactory mockPropertyFactory = EasyMock.createMock(PropertyObjectFactory.class); - loader = new TestLoader(mockRegistry, mockPropertyFactory); - } - - private class TestLoader extends ComponentLoader { - - public TestLoader(LoaderRegistry registry, PropertyObjectFactory propertyFactory) { - super(registry, propertyFactory); - } - - @Override - public void populatePropertyValues(ComponentDefinition> componentDefinition) - throws MissingMustOverridePropertyException { - super.populatePropertyValues(componentDefinition); - } - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/loader/ComponentLoaderReferenceTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/loader/ComponentLoaderReferenceTestCase.java deleted file mode 100644 index dcfc211fd2..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/loader/ComponentLoaderReferenceTestCase.java +++ /dev/null @@ -1,85 +0,0 @@ -package org.apache.tuscany.core.loader; - -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamConstants; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; - -import static org.osoa.sca.Version.XML_NAMESPACE_1_0; - -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.deployer.DeploymentContext; -import org.apache.tuscany.spi.implementation.java.PojoComponentType; -import org.apache.tuscany.spi.loader.LoaderException; -import org.apache.tuscany.spi.loader.LoaderRegistry; -import org.apache.tuscany.spi.loader.UndefinedReferenceException; -import org.apache.tuscany.spi.model.Implementation; -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; - -import junit.framework.TestCase; -import org.apache.tuscany.core.implementation.java.JavaImplementation; -import org.easymock.EasyMock; -import static org.easymock.EasyMock.isNull; - -/** - * @version $Rev$ $Date$ - */ -public class ComponentLoaderReferenceTestCase extends TestCase { - private static final QName COMPONENT = new QName(XML_NAMESPACE_1_0, "component"); - private static final QName REFERENCE = new QName(XML_NAMESPACE_1_0, "reference"); - private static final String NAME = "testComponent"; - private static final JavaImplementation IMPL = new JavaImplementation(); - private ComponentLoader loader; - private XMLStreamReader reader; - - /** - * Verifies an error is thrown when an attempt to configure a non-existent reference in SCDL is made - */ - public void testNoReferenceOnComponentType() throws LoaderException, XMLStreamException { - try { - loader.load(null, null, reader, null); - fail(); - } catch (UndefinedReferenceException e) { - // expected - } - } - - protected void setUp() throws Exception { - super.setUp(); - PojoComponentType> type = - new PojoComponentType>(); - IMPL.setComponentType(type); - reader = EasyMock.createMock(XMLStreamReader.class); - EasyMock.expect(reader.getName()).andReturn(COMPONENT); - EasyMock.expect(reader.getAttributeValue((String) EasyMock.isNull(), EasyMock.isA(String.class))) - .andReturn(NAME); - EasyMock.expect(reader.getAttributeValue((String) EasyMock.isNull(), EasyMock.eq("initLevel"))) - .andReturn(null); - EasyMock.expect(reader.getAttributeValue(EasyMock.isA(String.class), EasyMock.isA(String.class))) - .andReturn(null); - EasyMock.expect(reader.nextTag()).andReturn(0); - EasyMock.expect(reader.next()).andReturn(XMLStreamConstants.START_ELEMENT); - EasyMock.expect(reader.getName()).andReturn(REFERENCE); - EasyMock.expect(reader.getAttributeValue((String) isNull(), EasyMock.eq("name"))) - .andReturn("noreference"); - EasyMock.expect(reader.getElementText()).andReturn("text"); - - EasyMock.expect(reader.next()).andReturn(XMLStreamConstants.END_ELEMENT); - EasyMock.replay(reader); - LoaderRegistry mockRegistry = EasyMock.createMock(LoaderRegistry.class); - mockRegistry.loadComponentType((CompositeComponent) isNull(), - EasyMock.isA(Implementation.class), - (DeploymentContext) isNull()); - EasyMock.expect(mockRegistry.load((CompositeComponent) isNull(), - (ModelObject) isNull(), - EasyMock.isA(XMLStreamReader.class), - (DeploymentContext) isNull())).andReturn(IMPL); - EasyMock.replay(mockRegistry); - loader = new ComponentLoader(mockRegistry, null); - - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/loader/ComponentLoaderTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/loader/ComponentLoaderTestCase.java deleted file mode 100644 index d02d367f75..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/loader/ComponentLoaderTestCase.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 javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamConstants; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; - -import static org.osoa.sca.Version.XML_NAMESPACE_1_0; - -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.deployer.DeploymentContext; -import org.apache.tuscany.spi.implementation.java.PojoComponentType; -import org.apache.tuscany.spi.loader.LoaderException; -import org.apache.tuscany.spi.loader.LoaderRegistry; -import org.apache.tuscany.spi.loader.PropertyObjectFactory; -import org.apache.tuscany.spi.loader.UnrecognizedElementException; -import org.apache.tuscany.spi.model.ComponentDefinition; -import org.apache.tuscany.spi.model.Implementation; -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; - -import junit.framework.TestCase; -import org.apache.tuscany.core.implementation.java.JavaImplementation; -import org.easymock.EasyMock; -import static org.easymock.EasyMock.createMock; -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.isNull; -import static org.easymock.EasyMock.replay; -import org.easymock.IAnswer; - -/** - * @version $Rev$ $Date$ - */ -public class ComponentLoaderTestCase extends TestCase { - private static final QName COMPONENT = new QName(XML_NAMESPACE_1_0, "component"); - private static final String NAME = "testComponent"; - private static final Implementation IMPL = new JavaImplementation(); - - private XMLStreamReader mockReader; - private LoaderRegistry mockRegistry; - private PropertyObjectFactory mockPropertyFactory; - private ComponentLoader loader; - - public void testEmptyComponent() throws LoaderException, XMLStreamException { - EasyMock.expect(mockReader.getName()).andReturn(COMPONENT).atLeastOnce(); - EasyMock.expect(mockReader.getAttributeValue((String) EasyMock.isNull(), EasyMock.isA(String.class))) - .andReturn(NAME); - EasyMock.expect(mockReader.getAttributeValue((String) EasyMock.isNull(), EasyMock.eq("initLevel"))) - .andReturn(null); - EasyMock.expect(mockReader.getAttributeValue(EasyMock.isA(String.class), EasyMock.isA(String.class))) - .andReturn(null); - EasyMock.expect(mockReader.nextTag()).andReturn(0); - EasyMock.expect(mockReader.next()).andReturn(XMLStreamConstants.END_ELEMENT); - EasyMock.replay(mockReader); - mockRegistry.loadComponentType(EasyMock.isA(CompositeComponent.class), - EasyMock.isA(Implementation.class), - EasyMock.isA(DeploymentContext.class)); - EasyMock.expectLastCall().andStubAnswer(new IAnswer() { - @SuppressWarnings("unchecked") - public Object answer() throws Throwable { - Implementation impl = (Implementation) EasyMock.getCurrentArguments()[1]; - impl.setComponentType(new PojoComponentType()); - return impl; - } - }); - - EasyMock.expect(mockRegistry.load(EasyMock.isA(CompositeComponent.class), - (ModelObject) isNull(), - EasyMock.eq(mockReader), - EasyMock.isA(DeploymentContext.class))).andReturn(IMPL); - EasyMock.replay(mockRegistry); - ComponentDefinition component = loader.load(EasyMock.createNiceMock(CompositeComponent.class), - null, mockReader, - EasyMock.createNiceMock(DeploymentContext.class)); - assertEquals(NAME, component.getName()); - assertNull(component.getInitLevel()); - } - - public void testInitValue20() throws LoaderException, XMLStreamException { - EasyMock.expect(mockReader.getName()).andReturn(COMPONENT).atLeastOnce(); - EasyMock.expect(mockReader.getAttributeValue((String) EasyMock.isNull(), EasyMock.isA(String.class))) - .andReturn(NAME); - EasyMock.expect(mockReader.getAttributeValue((String) EasyMock.isNull(), EasyMock.eq("initLevel"))) - .andReturn("20"); - EasyMock.expect(mockReader.nextTag()).andReturn(0); - EasyMock.expect(mockReader.next()).andReturn(XMLStreamConstants.END_ELEMENT); - EasyMock.replay(mockReader); - - mockRegistry.loadComponentType(EasyMock.isA(CompositeComponent.class), - EasyMock.isA(Implementation.class), - EasyMock.isA(DeploymentContext.class)); - - EasyMock.expectLastCall().andStubAnswer(new IAnswer() { - @SuppressWarnings("unchecked") - public Object answer() throws Throwable { - Implementation impl = (Implementation) EasyMock.getCurrentArguments()[1]; - impl.setComponentType(new PojoComponentType()); - return impl; - } - }); - EasyMock.expect(mockRegistry.load(EasyMock.isA(CompositeComponent.class), - (ModelObject) isNull(), - EasyMock.eq(mockReader), - EasyMock.isA(DeploymentContext.class))).andReturn(IMPL); - EasyMock.replay(mockRegistry); - ComponentDefinition component = loader.load(EasyMock.createNiceMock(CompositeComponent.class), - null, mockReader, - EasyMock.createNiceMock(DeploymentContext.class)); - assertEquals(NAME, component.getName()); - assertEquals(Integer.valueOf(20), component.getInitLevel()); - } - - public void testLoadPropertyWithSource() throws LoaderException, XMLStreamException { - PojoComponentType> type = - new PojoComponentType>(); - Property property = new Property(); - property.setName("name"); - type.add(property); - JavaImplementation impl = new JavaImplementation(); - impl.setComponentType(type); - ComponentDefinition defn = new ComponentDefinition(impl); - XMLStreamReader reader = createMock(XMLStreamReader.class); - expect(reader.getAttributeValue(null, "name")).andReturn("name"); - expect(reader.getAttributeValue(null, "source")).andReturn("$source"); - expect(reader.getAttributeValue(null, "file")).andReturn(null); - expect(reader.next()).andReturn(XMLStreamConstants.END_ELEMENT); - replay(reader); - loader.loadProperty(reader, null, defn); - assertEquals("$source", defn.getPropertyValues().get("name").getSource()); - EasyMock.verify(reader); - } - - public void testUnrecognizedElement() throws LoaderException, XMLStreamException { - EasyMock.expect(mockReader.getName()).andReturn(COMPONENT); - EasyMock.expect(mockReader.getAttributeValue((String) EasyMock.isNull(), EasyMock.isA(String.class))) - .andReturn(NAME); - EasyMock.expect(mockReader.getAttributeValue((String) EasyMock.isNull(), EasyMock.eq("initLevel"))) - .andReturn(null); - EasyMock.expect(mockReader.getAttributeValue(EasyMock.isA(String.class), EasyMock.isA(String.class))) - .andReturn(null); - EasyMock.expect(mockReader.nextTag()).andReturn(0); - EasyMock.expect(mockReader.next()).andReturn(XMLStreamConstants.START_ELEMENT); - EasyMock.expect(mockReader.getName()).andReturn(new QName("foo", "bar")); - EasyMock.replay(mockReader); - mockRegistry.loadComponentType(EasyMock.isA(CompositeComponent.class), - EasyMock.isA(Implementation.class), - EasyMock.isA(DeploymentContext.class)); - - EasyMock.expect(mockRegistry.load(EasyMock.isA(CompositeComponent.class), - (ModelObject) isNull(), - EasyMock.eq(mockReader), - EasyMock.isA(DeploymentContext.class))).andReturn(IMPL); - EasyMock.replay(mockRegistry); - try { - loader.load(EasyMock.createNiceMock(CompositeComponent.class), - null, mockReader, - EasyMock.createNiceMock(DeploymentContext.class)); - fail(); - } catch (UnrecognizedElementException e) { - // expected - } - } - - protected void setUp() throws Exception { - super.setUp(); - mockReader = EasyMock.createMock(XMLStreamReader.class); - mockRegistry = EasyMock.createMock(LoaderRegistry.class); - mockPropertyFactory = EasyMock.createMock(PropertyObjectFactory.class); - loader = new ComponentLoader(mockRegistry, mockPropertyFactory); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/loader/ComponentLoaderValidationTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/loader/ComponentLoaderValidationTestCase.java deleted file mode 100644 index f4663ab4d7..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/loader/ComponentLoaderValidationTestCase.java +++ /dev/null @@ -1,105 +0,0 @@ -package org.apache.tuscany.core.loader; - -import javax.xml.stream.XMLStreamException; - -import org.apache.tuscany.spi.implementation.java.PojoComponentType; -import org.apache.tuscany.spi.loader.LoaderException; -import org.apache.tuscany.spi.loader.LoaderRegistry; -import org.apache.tuscany.spi.loader.MissingReferenceException; -import org.apache.tuscany.spi.loader.PropertyObjectFactory; -import org.apache.tuscany.spi.model.ComponentDefinition; -import org.apache.tuscany.spi.model.Implementation; -import org.apache.tuscany.spi.model.Property; -import org.apache.tuscany.spi.model.ReferenceDefinition; -import org.apache.tuscany.spi.model.ServiceDefinition; -import org.apache.tuscany.spi.model.ReferenceTarget; - -import junit.framework.TestCase; -import org.apache.tuscany.core.implementation.java.JavaImplementation; -import org.easymock.EasyMock; - -/** - * @version $Rev$ $Date$ - */ -public class ComponentLoaderValidationTestCase extends TestCase { - - private ComponentLoaderValidationTestCase.TestLoader loader; - - public void testValidation() throws LoaderException, XMLStreamException { - PojoComponentType> type = - new PojoComponentType>(); - ReferenceDefinition refDefinition = new ReferenceDefinition(); - refDefinition.setName("name"); - type.add(refDefinition); - JavaImplementation impl = new JavaImplementation(); - impl.setComponentType(type); - ComponentDefinition> defn = new ComponentDefinition>(impl); - ReferenceTarget target = new ReferenceTarget(); - target.setReferenceName("name"); - defn.add(target); - loader.validate(defn); - } - - public void testReferenceNotSet() throws LoaderException, XMLStreamException { - PojoComponentType> type = - new PojoComponentType>(); - ReferenceDefinition refDefinition = new ReferenceDefinition(); - refDefinition.setName("name"); - refDefinition.setRequired(true); - type.add(refDefinition); - JavaImplementation impl = new JavaImplementation(); - impl.setComponentType(type); - ComponentDefinition> defn = new ComponentDefinition>(impl); - try { - loader.validate(defn); - fail(); - } catch (MissingReferenceException e) { - // expected - } - } - - public void testNotRequiredReference() throws LoaderException, XMLStreamException { - PojoComponentType> type = - new PojoComponentType>(); - ReferenceDefinition refDefinition = new ReferenceDefinition(); - refDefinition.setName("name"); - refDefinition.setRequired(false); - type.add(refDefinition); - JavaImplementation impl = new JavaImplementation(); - impl.setComponentType(type); - ComponentDefinition> defn = new ComponentDefinition>(impl); - loader.validate(defn); - } - - public void testAutowire() throws LoaderException, XMLStreamException { - PojoComponentType> type = - new PojoComponentType>(); - ReferenceDefinition refDefinition = new ReferenceDefinition(); - refDefinition.setName("name"); - refDefinition.setAutowire(true); - type.add(refDefinition); - JavaImplementation impl = new JavaImplementation(); - impl.setComponentType(type); - ComponentDefinition> defn = new ComponentDefinition>(impl); - loader.validate(defn); - } - - protected void setUp() throws Exception { - super.setUp(); - LoaderRegistry mockRegistry = EasyMock.createMock(LoaderRegistry.class); - PropertyObjectFactory mockPropertyFactory = EasyMock.createMock(PropertyObjectFactory.class); - loader = new ComponentLoaderValidationTestCase.TestLoader(mockRegistry, mockPropertyFactory); - } - - private class TestLoader extends ComponentLoader { - - public TestLoader(LoaderRegistry registry, PropertyObjectFactory propertyFactory) { - super(registry, propertyFactory); - } - - @Override - protected void validate(ComponentDefinition> definition) throws LoaderException { - super.validate(definition); - } - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/loader/ComponentTypeElementLoaderTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/loader/ComponentTypeElementLoaderTestCase.java deleted file mode 100644 index eb69b7b768..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/loader/ComponentTypeElementLoaderTestCase.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.loader; - -import javax.xml.stream.XMLStreamConstants; -import javax.xml.stream.XMLStreamReader; -import javax.xml.namespace.QName; - -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.deployer.DeploymentContext; -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; - -import junit.framework.TestCase; -import org.easymock.EasyMock; - -/** - * @version $Rev$ $Date$ - */ -public class ComponentTypeElementLoaderTestCase extends TestCase { - - public void testSpecializedComponentTypePassedIn() throws Exception { - ComponentType> type = - new ComponentType>(); - ComponentTypeElementLoader loader = new ComponentTypeElementLoader(null); - XMLStreamReader reader = EasyMock.createMock(XMLStreamReader.class); - EasyMock.expect(reader.getName()).andReturn(ComponentTypeElementLoader.COMPONENT_TYPE); - EasyMock.expect(reader.next()).andReturn(XMLStreamConstants.END_ELEMENT); - EasyMock.replay(reader); - // verify that the exact component type instance is returned. Some StAXElementLoader implementations may chose - // to copy the original instance but ComponentTypeElementLoader does not since it has no knowledge of the - // specialized instance - ModelObject object = loader.load(null, type, reader, null); - assertEquals(object, type); - } - - public void testComponentTypePassedAsContext() throws Exception { - ComponentType> type = - new ComponentType>(); - LoaderRegistry registry = EasyMock.createMock(LoaderRegistry.class); - EasyMock.expect(registry.load((CompositeComponent) EasyMock.isNull(), - EasyMock.isA(ComponentType.class), - EasyMock.isA(XMLStreamReader.class), - (DeploymentContext) EasyMock.isNull())).andReturn(type); - EasyMock.replay(registry); - ComponentTypeElementLoader loader = new ComponentTypeElementLoader(registry); - XMLStreamReader reader = EasyMock.createMock(XMLStreamReader.class); - EasyMock.expect(reader.getName()).andReturn(ComponentTypeElementLoader.COMPONENT_TYPE); - EasyMock.expect(reader.next()).andReturn(XMLStreamConstants.START_ELEMENT); - EasyMock.expect(reader.getName()).andReturn(new QName("foo", "foo")); - EasyMock.expect(reader.next()).andReturn(XMLStreamConstants.END_ELEMENT); - EasyMock.replay(reader); - - loader.load(null, type, reader, null); - EasyMock.verify(registry); - } - - public void testNonSpecializedComponentTypePassedIn() throws Exception { - ComponentTypeElementLoader loader = new ComponentTypeElementLoader(null); - XMLStreamReader reader = EasyMock.createMock(XMLStreamReader.class); - EasyMock.expect(reader.getName()).andReturn(ComponentTypeElementLoader.COMPONENT_TYPE); - EasyMock.expect(reader.next()).andReturn(XMLStreamConstants.END_ELEMENT); - EasyMock.replay(reader); - ModelObject object = loader.load(null, null, reader, null); - assertEquals(ComponentType.class, object.getClass()); - } - - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/loader/DependencyLoaderTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/loader/DependencyLoaderTestCase.java deleted file mode 100644 index 753289f4a6..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/loader/DependencyLoaderTestCase.java +++ /dev/null @@ -1,124 +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.stream.Location; -import javax.xml.stream.XMLStreamConstants; -import javax.xml.stream.XMLStreamReader; - -import org.apache.tuscany.spi.loader.LoaderRegistry; -import org.apache.tuscany.spi.loader.UnrecognizedElementException; - -import junit.framework.TestCase; -import org.easymock.EasyMock; -import org.apache.tuscany.core.implementation.composite.Dependency; - -/** - * @version $Rev$ $Date$ - */ -public class DependencyLoaderTestCase extends TestCase { - private static final String NS = "http://tuscany.apache.org/xmlns/1.0-SNAPSHOT"; - private static final QName DEPENDENCY = new QName(NS, "dependency"); - private static final QName GROUP = new QName(NS, "group"); - private static final QName NAME = new QName(NS, "name"); - private static final QName VERSION = new QName(NS, "version"); - private static final QName CLASSIFIER = new QName(NS, "classifier"); - private static final QName TYPE = new QName(NS, "type"); - - public void testLoad() throws Exception { - LoaderRegistry registry = EasyMock.createNiceMock(LoaderRegistry.class); - EasyMock.replay(registry); - XMLStreamReader reader = EasyMock.createMock(XMLStreamReader.class); - EasyMock.expect(reader.nextTag()).andReturn(XMLStreamConstants.START_ELEMENT); - EasyMock.expect(reader.getName()).andReturn(GROUP); - EasyMock.expect(reader.getElementText()).andReturn("group"); - EasyMock.expect(reader.nextTag()).andReturn(XMLStreamConstants.START_ELEMENT); - EasyMock.expect(reader.getName()).andReturn(NAME); - EasyMock.expect(reader.getElementText()).andReturn("name"); - EasyMock.expect(reader.nextTag()).andReturn(XMLStreamConstants.START_ELEMENT); - EasyMock.expect(reader.getName()).andReturn(VERSION); - EasyMock.expect(reader.getElementText()).andReturn("1"); - EasyMock.expect(reader.nextTag()).andReturn(XMLStreamConstants.START_ELEMENT); - EasyMock.expect(reader.getName()).andReturn(CLASSIFIER); - EasyMock.expect(reader.getElementText()).andReturn("classifier"); - EasyMock.expect(reader.nextTag()).andReturn(XMLStreamConstants.START_ELEMENT); - EasyMock.expect(reader.getName()).andReturn(TYPE); - EasyMock.expect(reader.getElementText()).andReturn("type"); - EasyMock.expect(reader.nextTag()).andReturn(XMLStreamConstants.END_ELEMENT); - EasyMock.replay(reader); - DependencyLoader loader = new DependencyLoader(registry); - Dependency dependency = loader.load(null, null, reader, null); - assertEquals("group", dependency.getArtifact().getGroup()); - assertEquals("name", dependency.getArtifact().getName()); - assertEquals("1", dependency.getArtifact().getVersion()); - assertEquals("classifier", dependency.getArtifact().getClassifier()); - assertEquals("type", dependency.getArtifact().getType()); - } - - public void testLoaderRegister() { - LoaderRegistry registry = EasyMock.createMock(LoaderRegistry.class); - registry.registerLoader(EasyMock.eq(DEPENDENCY), EasyMock.isA(DependencyLoader.class)); - EasyMock.replay(registry); - DependencyLoader loader = new DependencyLoader(registry); - loader.start(); - EasyMock.verify(registry); - } - - public void testUnrecognizedElement() throws Exception { - LoaderRegistry registry = EasyMock.createNiceMock(LoaderRegistry.class); - EasyMock.replay(registry); - XMLStreamReader reader = EasyMock.createMock(XMLStreamReader.class); - EasyMock.expect(reader.nextTag()).andReturn(XMLStreamConstants.START_ELEMENT); - EasyMock.expect(reader.getName()).andReturn(new QName("foo", "bar")); - EasyMock.expect(reader.getElementText()).andReturn("foo"); - EasyMock.expect(reader.getLocation()).andReturn(new MockLocation()); - EasyMock.replay(reader); - DependencyLoader loader = new DependencyLoader(registry); - try { - loader.load(null, null, reader, null); - fail(); - } catch (UnrecognizedElementException e) { - // expected - } - } - - private class MockLocation implements Location { - - public int getLineNumber() { - return 0; - } - - public int getColumnNumber() { - return 0; - } - - public int getCharacterOffset() { - return 0; - } - - public String getPublicId() { - return null; - } - - public String getSystemId() { - return null; - } - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/loader/IncludeLoaderTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/loader/IncludeLoaderTestCase.java deleted file mode 100644 index 2c0c3eaf14..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/loader/IncludeLoaderTestCase.java +++ /dev/null @@ -1,169 +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.URL; -import javax.xml.namespace.QName; -import static javax.xml.stream.XMLStreamConstants.END_ELEMENT; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; - -import org.osoa.sca.Version; - -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.deployer.DeploymentContext; -import org.apache.tuscany.spi.loader.LoaderException; -import org.apache.tuscany.spi.loader.LoaderRegistry; -import org.apache.tuscany.spi.loader.MissingIncludeException; -import org.apache.tuscany.spi.model.CompositeComponentType; -import org.apache.tuscany.spi.model.Include; -import org.apache.tuscany.spi.model.ModelObject; - -import junit.framework.TestCase; -import static org.easymock.EasyMock.createMock; -import static org.easymock.EasyMock.eq; -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.isA; -import static org.easymock.EasyMock.isNull; -import static org.easymock.EasyMock.replay; -import static org.easymock.EasyMock.verify; - -/** - * @version $Rev$ $Date$ - */ -public class IncludeLoaderTestCase extends TestCase { - private static final QName INCLUDE = new QName(Version.XML_NAMESPACE_1_0, "include"); - - private LoaderRegistry registry; - private IncludeLoader loader; - private XMLStreamReader reader; - private DeploymentContext context; - private URL base; - private URL includeURL; - private ClassLoader cl; - - public void testNoLocation() throws LoaderException, XMLStreamException { - String name = "foo"; - expect(reader.getName()).andReturn(INCLUDE); - expect(reader.getAttributeValue(null, "name")).andReturn(name); - expect(reader.getAttributeValue(null, "scdlLocation")).andReturn(null); - expect(reader.getAttributeValue(null, "scdlResource")).andReturn(null); - expect(reader.next()).andReturn(END_ELEMENT); - - expect(context.getClassLoader()).andReturn(cl); - replay(registry, reader, context); - - try { - loader.load(null, null, reader, context); - fail(); - } catch (MissingIncludeException e) { - // OK expected - } - verify(registry, reader, context); - } - - public void testWithAbsoluteScdlLocation() throws LoaderException, XMLStreamException { - String name = "foo"; - expect(reader.getName()).andReturn(INCLUDE); - expect(reader.getAttributeValue(null, "name")).andReturn(name); - expect(reader.getAttributeValue(null, "scdlLocation")).andReturn("http://example.com/include.scdl"); - expect(reader.getAttributeValue(null, "scdlResource")).andReturn(null); - expect(reader.next()).andReturn(END_ELEMENT); - - expect(context.getScdlLocation()).andReturn(base); - expect(context.getClassLoader()).andReturn(cl); - - expect(registry.load((CompositeComponent) isNull(), - (ModelObject) isNull(), - eq(includeURL), - eq(CompositeComponentType.class), - isA(DeploymentContext.class))) - .andReturn(null); - replay(registry, reader, context); - - Include include = loader.load(null, null, reader, context); - assertEquals(name, include.getName()); - assertEquals(includeURL, include.getScdlLocation()); - verify(registry, reader, context); - } - - public void testWithRelativeScdlLocation() throws LoaderException, XMLStreamException { - String name = "foo"; - expect(reader.getName()).andReturn(INCLUDE); - expect(reader.getAttributeValue(null, "name")).andReturn(name); - expect(reader.getAttributeValue(null, "scdlLocation")).andReturn("include.scdl"); - expect(reader.getAttributeValue(null, "scdlResource")).andReturn(null); - expect(reader.next()).andReturn(END_ELEMENT); - - expect(context.getScdlLocation()).andReturn(base); - expect(context.getClassLoader()).andReturn(cl); - - expect(registry.load((CompositeComponent) isNull(), - (ModelObject) isNull(), - eq(includeURL), - eq(CompositeComponentType.class), - isA(DeploymentContext.class))) - .andReturn(null); - replay(registry, reader, context); - - Include include = loader.load(null, null, reader, context); - assertEquals(name, include.getName()); - assertEquals(includeURL, include.getScdlLocation()); - verify(registry, reader, context); - } - - public void testWithScdlResource() throws LoaderException, XMLStreamException { - String name = "foo"; - String resource = "org/apache/tuscany/core/loader/test-include.scdl"; - includeURL = cl.getResource(resource); - assertNotNull(includeURL); - - expect(reader.getName()).andReturn(INCLUDE); - expect(reader.getAttributeValue(null, "name")).andReturn(name); - expect(reader.getAttributeValue(null, "scdlLocation")).andReturn(null); - expect(reader.getAttributeValue(null, "scdlResource")).andReturn(resource); - expect(reader.next()).andReturn(END_ELEMENT); - - expect(context.getClassLoader()).andReturn(cl); - - expect(registry.load((CompositeComponent) isNull(), - (ModelObject) isNull(), - eq(includeURL), - eq(CompositeComponentType.class), - isA(DeploymentContext.class))) - .andReturn(null); - replay(registry, reader, context); - - Include include = loader.load(null, null, reader, context); - assertEquals(name, include.getName()); - assertEquals(includeURL, include.getScdlLocation()); - verify(registry, reader, context); - } - - protected void setUp() throws Exception { - super.setUp(); - registry = createMock(LoaderRegistry.class); - reader = createMock(XMLStreamReader.class); - context = createMock(DeploymentContext.class); - cl = getClass().getClassLoader(); - base = new URL("http://example.com/test.scdl"); - includeURL = new URL("http://example.com/include.scdl"); - loader = new IncludeLoader(registry); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/loader/JNDIPropertyFactoryTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/loader/JNDIPropertyFactoryTestCase.java deleted file mode 100644 index 4f64237725..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/loader/JNDIPropertyFactoryTestCase.java +++ /dev/null @@ -1,63 +0,0 @@ -package org.apache.tuscany.core.loader; - -import java.lang.reflect.Type; -import java.util.Hashtable; -import javax.naming.Context; -import javax.naming.NamingException; -import javax.naming.spi.InitialContextFactory; - -import org.w3c.dom.Document; -import org.w3c.dom.Element; - -import org.apache.tuscany.spi.model.PropertyValue; - -import junit.framework.TestCase; -import org.apache.tuscany.core.injection.JNDIObjectFactory; -import org.easymock.EasyMock; - -/** - * @version $Rev$ $Date$ - */ -public class JNDIPropertyFactoryTestCase extends TestCase { - - public void testCreate() throws Exception { - String old = System.getProperty(Context.INITIAL_CONTEXT_FACTORY); - try { - System.setProperty(Context.INITIAL_CONTEXT_FACTORY, MockInitialContextFactory.class.getName()); - JNDIPropertyFactory factory = new JNDIPropertyFactory(); - Element element = EasyMock.createMock(Element.class); - EasyMock.expect(element.getTextContent()).andReturn("foo"); - EasyMock.replay(element); - Document doc = EasyMock.createMock(Document.class); - EasyMock.expect(doc.getDocumentElement()).andReturn(element); - EasyMock.replay(doc); - PropertyValue value = new MockPropertyValue(); - value.setValue(doc); - JNDIObjectFactory jndiFactory = (JNDIObjectFactory) factory.createObjectFactory(null, value); - assertEquals("bar", jndiFactory.getInstance()); - } finally { - System.clearProperty(Context.INITIAL_CONTEXT_FACTORY); - if (old != null) { - System.setProperty(Context.INITIAL_CONTEXT_FACTORY, old); - } - } - - } - - private class MockPropertyValue extends PropertyValue { - - } - - public static class MockInitialContextFactory implements InitialContextFactory { - public MockInitialContextFactory() { - } - - public Context getInitialContext(Hashtable environment) throws NamingException { - Context context = EasyMock.createMock(Context.class); - EasyMock.expect(context.lookup("foo")).andReturn("bar"); - EasyMock.replay(context); - return context; - } - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/loader/LoaderExceptionFormatterTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/loader/LoaderExceptionFormatterTestCase.java deleted file mode 100644 index 49c53935dc..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/loader/LoaderExceptionFormatterTestCase.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.loader; - -import java.io.PrintWriter; -import java.io.StringWriter; - -import org.apache.tuscany.spi.loader.LoaderException; - -import junit.framework.TestCase; -import org.easymock.EasyMock; -import org.apache.tuscany.host.monitor.FormatterRegistry; - -/** - * @version $Rev$ $Date$ - */ -public class LoaderExceptionFormatterTestCase extends TestCase { - - public void testLog() { - FormatterRegistry registry = EasyMock.createNiceMock(FormatterRegistry.class); - LoaderExceptionFormatter formatter = new LoaderExceptionFormatter(registry); - LoaderException e = new LoaderException("test"); - StringWriter writer = new StringWriter(); - PrintWriter pw = new PrintWriter(writer); - formatter.write(pw, e); - pw.close(); - assertTrue(!"message".equals(writer.toString())); - } - - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/loader/PolicySetLoaderTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/loader/PolicySetLoaderTestCase.java deleted file mode 100644 index 398e3118d7..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/loader/PolicySetLoaderTestCase.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.loader; - -import java.util.Collection; -import java.util.Iterator; -import javax.xml.namespace.QName; -import javax.xml.stream.XMLInputFactory; -import static javax.xml.stream.XMLStreamConstants.START_ELEMENT; -import javax.xml.stream.XMLStreamReader; - -import static org.osoa.sca.Version.XML_NAMESPACE_1_0; - -import org.apache.tuscany.spi.model.IntentMap; -import org.apache.tuscany.spi.model.PolicySet; -import org.apache.tuscany.spi.model.Qualifier; - -import junit.framework.TestCase; - -public class PolicySetLoaderTestCase extends TestCase { - private static final QName POLICYSET = new QName(XML_NAMESPACE_1_0, "policySet"); - - public void testLoader() throws Exception { - PolicySetLoader loader = new PolicySetLoader(null); - XMLInputFactory factory = XMLInputFactory.newInstance(); - XMLStreamReader reader = factory.createXMLStreamReader(this.getClass().getResourceAsStream("TestPolicy.scdl")); - while (true) { - int state = reader.next(); - if (START_ELEMENT == state && reader.getName().equals(POLICYSET)) { - break; - } - } - PolicySet policySet = loader.load(null, null, reader, null); - assertNotNull(policySet); - assertEquals(2, policySet.getAppliedArtifacts().size()); - assertTrue(policySet.getAppliedArtifacts().contains(new QName(XML_NAMESPACE_1_0, "binding.ws"))); - assertTrue(policySet.getAppliedArtifacts().contains(new QName(XML_NAMESPACE_1_0, "binding.jms"))); - Collection intentMaps = policySet.getIntentMaps(); - assertEquals(1, intentMaps.size()); - IntentMap intentMap = intentMaps.iterator().next(); - assertEquals("transport", intentMap.getDefaultProvideIntent()); - assertTrue(intentMap.getProvideIntents().contains("sec.confidentiality")); - Collection qualifiers = intentMap.getQualifiers(); - assertEquals(2, qualifiers.size()); - Iterator qit = qualifiers.iterator(); - Qualifier qualifier1 = (Qualifier) qit.next(); - assertEquals(2, qualifier1.getWsPolicyAttachments().size()); - assertEquals("transport", qualifier1.getName()); - Qualifier qualifier2 = (Qualifier) qit.next(); - assertEquals("message", qualifier2.getName()); - IntentMap messageMap = qualifier2.getIntentMap(); - assertEquals(2, messageMap.getQualifiers().size()); - - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/loader/PropertyParsingTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/loader/PropertyParsingTestCase.java deleted file mode 100644 index 080bc25039..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/loader/PropertyParsingTestCase.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.loader; - -import java.io.StringReader; -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLStreamReader; -import javax.xml.stream.XMLStreamException; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.DocumentBuilder; - -import junit.framework.TestCase; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.NodeList; - -/** - * @version $Rev$ $Date$ - */ -public class PropertyParsingTestCase extends TestCase { - private XMLInputFactory xmlFactory; - private DocumentBuilder docBuilder; - private Element root; - - public void testComplexProperty() throws XMLStreamException { - String xml = "" - + "aValue" - + "InterestingURI" - + ""; - - XMLStreamReader reader = getReader(xml); - StAXUtil.loadPropertyValue(reader, root); - NodeList childNodes = root.getChildNodes(); - assertEquals(2, childNodes.getLength()); - - Element e = (Element) childNodes.item(0); - assertEquals("http://foo.com", e.getNamespaceURI()); - assertEquals("a", e.getLocalName()); - assertEquals("aValue", e.getTextContent()); - e = (Element) childNodes.item(1); - assertEquals("http://foo.com", e.getNamespaceURI()); - assertEquals("b", e.getLocalName()); - assertEquals("InterestingURI", e.getTextContent()); - } - - public XMLStreamReader getReader(String xml) throws XMLStreamException { - XMLStreamReader reader = xmlFactory.createXMLStreamReader(new StringReader(xml)); - reader.next(); - return reader; - } - - protected void setUp() throws Exception { - super.setUp(); - xmlFactory = XMLInputFactory.newInstance(); - DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); - docBuilder = docFactory.newDocumentBuilder(); - Document doc = docBuilder.newDocument(); - root = doc.createElement("value"); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/loader/ReferenceLoaderTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/loader/ReferenceLoaderTestCase.java deleted file mode 100644 index 7ef95fd56c..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/loader/ReferenceLoaderTestCase.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.loader; - -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamConstants; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; - -import org.osoa.sca.Version; - -import org.apache.tuscany.spi.deployer.DeploymentContext; -import org.apache.tuscany.spi.loader.LoaderException; -import org.apache.tuscany.spi.loader.LoaderRegistry; -import org.apache.tuscany.spi.model.BindingDefinition; -import org.apache.tuscany.spi.model.BoundReferenceDefinition; -import org.apache.tuscany.spi.model.ComponentType; -import org.apache.tuscany.spi.model.Property; -import org.apache.tuscany.spi.model.ReferenceDefinition; -import org.apache.tuscany.spi.model.ServiceContract; -import org.apache.tuscany.spi.model.ServiceDefinition; - -import junit.framework.TestCase; -import org.apache.tuscany.core.deployer.RootDeploymentContext; -import org.easymock.EasyMock; - -/** - * Verifies loading of a reference definition from an XML-based assembly - * - * @version $Rev$ $Date$ - */ -public class ReferenceLoaderTestCase extends TestCase { - private static final QName REFERENCE = new QName(Version.XML_NAMESPACE_1_0, "reference"); - - private ReferenceLoader loader; - private DeploymentContext deploymentContext; - private XMLStreamReader mockReader; - private LoaderRegistry mockRegistry; - - public void testWithNoInterface() throws LoaderException, XMLStreamException { - String name = "referenceDefinition"; - EasyMock.expect(mockReader.getName()).andReturn(REFERENCE).anyTimes(); - EasyMock.expect(mockReader.getAttributeValue(null, "name")).andReturn(name); - EasyMock.expect(mockReader.getAttributeValue(null, "multiplicity")).andReturn("0..1"); - EasyMock.expect(mockReader.next()).andReturn(XMLStreamConstants.END_ELEMENT); - EasyMock.expect(mockReader.getName()).andReturn(REFERENCE).anyTimes(); - EasyMock.replay(mockReader); - ReferenceDefinition referenceDefinition = loader.load(null, null, mockReader, null); - assertNotNull(referenceDefinition); - assertEquals(name, referenceDefinition.getName()); - } - - public void testComponentTypeService() throws LoaderException, XMLStreamException { - String name = "reference"; - EasyMock.expect(mockReader.getName()).andReturn(REFERENCE).anyTimes(); - EasyMock.expect(mockReader.getAttributeValue(null, "name")).andReturn(name); - EasyMock.expect(mockReader.getAttributeValue(null, "multiplicity")).andReturn("0..1"); - EasyMock.expect(mockReader.next()).andReturn(XMLStreamConstants.END_ELEMENT); - EasyMock.expect(mockReader.getName()).andReturn(REFERENCE).anyTimes(); - EasyMock.replay(mockReader); - ComponentType> type = - new ComponentType>(); - ReferenceDefinition referenceDefinition = loader.load(null, type, mockReader, null); - assertTrue(ReferenceDefinition.class.equals(referenceDefinition.getClass())); - } - - public void testMultipleBindings() throws LoaderException, XMLStreamException { - String name = "referenceDefinition"; - EasyMock.expect(mockReader.getName()).andReturn(REFERENCE).anyTimes(); - EasyMock.expect(mockReader.getAttributeValue(null, "name")).andReturn(name); - EasyMock.expect(mockReader.getAttributeValue(null, "multiplicity")).andReturn("0..1"); - EasyMock.expect(mockReader.next()).andReturn(XMLStreamConstants.START_ELEMENT).times(2); - EasyMock.expect(mockReader.next()).andReturn(XMLStreamConstants.END_ELEMENT); - EasyMock.expect(mockReader.getName()).andReturn(REFERENCE).anyTimes(); - EasyMock.replay(mockReader); - - BindingDefinition binding = new BindingDefinition() { - }; - EasyMock.expect(mockRegistry.load(null, null, mockReader, null)).andReturn(binding).times(2); - EasyMock.replay(mockRegistry); - - BoundReferenceDefinition referenceDefinition = - (BoundReferenceDefinition) loader.load(null, null, mockReader, null); - assertEquals(2, referenceDefinition.getBindings().size()); - } - - public void testWithInterface() throws LoaderException, XMLStreamException { - String name = "referenceDefinition"; - ServiceContract sc = new ServiceContract() { - }; - EasyMock.expect(mockReader.getName()).andReturn(REFERENCE).anyTimes(); - EasyMock.expect(mockReader.getAttributeValue(null, "name")).andReturn(name); - EasyMock.expect(mockReader.getAttributeValue(null, "multiplicity")).andReturn("0..1"); - EasyMock.expect(mockReader.next()).andReturn(XMLStreamConstants.START_ELEMENT); - EasyMock.expect(mockRegistry.load(null, null, mockReader, deploymentContext)).andReturn(sc); - EasyMock.expect(mockReader.next()).andReturn(XMLStreamConstants.END_ELEMENT); - - EasyMock.replay(mockReader); - EasyMock.replay(mockRegistry); - - ReferenceDefinition referenceDefinition = loader.load(null, null, mockReader, deploymentContext); - assertNotNull(referenceDefinition); - assertEquals(name, referenceDefinition.getName()); - assertSame(sc, referenceDefinition.getServiceContract()); - } - - protected void setUp() throws Exception { - super.setUp(); - mockReader = EasyMock.createStrictMock(XMLStreamReader.class); - mockRegistry = EasyMock.createMock(LoaderRegistry.class); - loader = new ReferenceLoader(mockRegistry); - deploymentContext = new RootDeploymentContext(null, null, null, null); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/loader/ServiceLoaderTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/loader/ServiceLoaderTestCase.java deleted file mode 100644 index 20600ce63b..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/loader/ServiceLoaderTestCase.java +++ /dev/null @@ -1,163 +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.Version.XML_NAMESPACE_1_0; - -import org.apache.tuscany.spi.deployer.DeploymentContext; -import org.apache.tuscany.spi.loader.LoaderException; -import org.apache.tuscany.spi.loader.LoaderRegistry; -import org.apache.tuscany.spi.model.BindingDefinition; -import org.apache.tuscany.spi.model.BoundServiceDefinition; -import org.apache.tuscany.spi.model.ComponentType; -import org.apache.tuscany.spi.model.Property; -import org.apache.tuscany.spi.model.ReferenceDefinition; -import org.apache.tuscany.spi.model.ServiceContract; -import org.apache.tuscany.spi.model.ServiceDefinition; - -import junit.framework.TestCase; -import org.apache.tuscany.core.deployer.RootDeploymentContext; -import org.easymock.EasyMock; -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.replay; - -/** - * Verifies loading of a service definition from an XML-based assembly - * - * @version $Rev$ $Date$ - */ -public class ServiceLoaderTestCase extends TestCase { - private static final QName SERVICE = new QName(XML_NAMESPACE_1_0, "service"); - private static final QName BINDING = new QName(XML_NAMESPACE_1_0, "binding.foo"); - private static final QName REFERENCE = new QName(XML_NAMESPACE_1_0, "reference"); - private static final QName INTERFACE_JAVA = new QName(XML_NAMESPACE_1_0, "interface.java"); - - private ServiceLoader loader; - private DeploymentContext deploymentContext; - private XMLStreamReader mockReader; - private LoaderRegistry mockRegistry; - - public void testWithNoInterface() throws LoaderException, XMLStreamException { - String name = "serviceDefinition"; - expect(mockReader.getName()).andReturn(SERVICE).anyTimes(); - expect(mockReader.getAttributeValue(null, "name")).andReturn(name); - expect(mockReader.next()).andReturn(END_ELEMENT); - expect(mockReader.getName()).andReturn(SERVICE).anyTimes(); - replay(mockReader); - ServiceDefinition serviceDefinition = loader.load(null, null, mockReader, null); - assertNotNull(serviceDefinition); - assertEquals(name, serviceDefinition.getName()); - } - - public void testComponentTypeService() throws LoaderException, XMLStreamException { - String name = "service"; - expect(mockReader.getName()).andReturn(SERVICE).anyTimes(); - expect(mockReader.getAttributeValue(null, "name")).andReturn(name); - expect(mockReader.next()).andReturn(END_ELEMENT); - expect(mockReader.getName()).andReturn(SERVICE).anyTimes(); - replay(mockReader); - ComponentType> type = - new ComponentType>(); - ServiceDefinition serviceDefinition = loader.load(null, type, mockReader, null); - assertTrue(ServiceDefinition.class.equals(serviceDefinition.getClass())); - } - - public void testMultipleBindings() throws LoaderException, XMLStreamException { - String name = "serviceDefinition"; - expect(mockReader.getName()).andReturn(SERVICE).anyTimes(); - expect(mockReader.getAttributeValue(null, "name")).andReturn(name); - expect(mockReader.next()).andReturn(START_ELEMENT); - expect(mockReader.getName()).andReturn(BINDING); - expect(mockReader.next()).andReturn(START_ELEMENT); - expect(mockReader.getName()).andReturn(BINDING); - expect(mockReader.next()).andReturn(END_ELEMENT); - expect(mockReader.getName()).andReturn(SERVICE).anyTimes(); - replay(mockReader); - - BindingDefinition binding = new BindingDefinition() { - }; - expect(mockRegistry.load(null, null, mockReader, null)).andReturn(binding).times(2); - replay(mockRegistry); - - BoundServiceDefinition serviceDefinition = (BoundServiceDefinition) loader.load(null, null, mockReader, null); - assertEquals(2, serviceDefinition.getBindings().size()); - } - - public void testWithInterface() throws LoaderException, XMLStreamException { - String name = "serviceDefinition"; - String target = "target"; - ServiceContract sc = new ServiceContract() { - }; - expect(mockReader.getName()).andReturn(SERVICE).anyTimes(); - expect(mockReader.getAttributeValue(null, "name")).andReturn(name); - expect(mockReader.next()).andReturn(START_ELEMENT); - expect(mockReader.getName()).andReturn(INTERFACE_JAVA); - expect(mockRegistry.load(null, null, mockReader, deploymentContext)).andReturn(sc); - expect(mockReader.next()).andReturn(START_ELEMENT); - expect(mockReader.getName()).andReturn(REFERENCE); - expect(mockReader.getElementText()).andReturn(target); - expect(mockReader.next()).andReturn(END_ELEMENT); - expect(mockReader.getName()).andReturn(REFERENCE); - expect(mockReader.next()).andReturn(END_ELEMENT); - expect(mockReader.getName()).andReturn(SERVICE); - - replay(mockReader); - replay(mockRegistry); - - ServiceDefinition serviceDefinition = loader.load(null, null, mockReader, deploymentContext); - assertNotNull(serviceDefinition); - assertEquals(name, serviceDefinition.getName()); - assertSame(sc, serviceDefinition.getServiceContract()); - } - - public void testWithNoReference() throws LoaderException, XMLStreamException { - String name = "serviceDefinition"; - ServiceContract sc = new ServiceContract() { - }; - expect(mockReader.getName()).andReturn(SERVICE).anyTimes(); - expect(mockReader.getAttributeValue(null, "name")).andReturn(name); - expect(mockReader.next()).andReturn(START_ELEMENT); - expect(mockReader.getName()).andReturn(INTERFACE_JAVA); - expect(mockRegistry.load(null, null, mockReader, deploymentContext)).andReturn(sc); - expect(mockReader.next()).andReturn(END_ELEMENT); - expect(mockReader.getName()).andReturn(SERVICE); - - replay(mockReader); - replay(mockRegistry); - - ServiceDefinition serviceDefinition = loader.load(null, null, mockReader, deploymentContext); - assertNotNull(serviceDefinition); - assertEquals(name, serviceDefinition.getName()); - assertSame(sc, serviceDefinition.getServiceContract()); - } - - protected void setUp() throws Exception { - super.setUp(); - mockReader = EasyMock.createStrictMock(XMLStreamReader.class); - mockRegistry = EasyMock.createMock(LoaderRegistry.class); - loader = new ServiceLoader(mockRegistry); - deploymentContext = new RootDeploymentContext(null, null, null, null); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/loader/StAXLoaderRegistryImplTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/loader/StAXLoaderRegistryImplTestCase.java deleted file mode 100644 index 74a40c80a9..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/loader/StAXLoaderRegistryImplTestCase.java +++ /dev/null @@ -1,131 +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.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; - -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.deployer.DeploymentContext; -import org.apache.tuscany.spi.loader.LoaderException; -import org.apache.tuscany.spi.loader.StAXElementLoader; -import org.apache.tuscany.spi.loader.UnrecognizedElementException; -import org.apache.tuscany.spi.model.ModelObject; - -import junit.framework.TestCase; -import org.apache.tuscany.core.deployer.RootDeploymentContext; -import static org.easymock.EasyMock.isNull; -import org.easymock.classextension.EasyMock; - -/** - * Verifies the default loader registry - * - * @version $Rev$ $Date$ - */ -public class StAXLoaderRegistryImplTestCase extends TestCase { - private LoaderRegistryImpl registry; - private QName name; - private LoaderRegistryImpl.Monitor mockMonitor; - private StAXElementLoader mockLoader; - private XMLStreamReader mockReader; - private DeploymentContext deploymentContext; - private ModelObject modelObject; - - public void testLoaderRegistration() { - mockMonitor.registeringLoader(EasyMock.eq(name)); - EasyMock.replay(mockMonitor); - registry.registerLoader(name, mockLoader); - EasyMock.verify(mockMonitor); - } - - public void testLoaderUnregistration() { - mockMonitor.unregisteringLoader(EasyMock.eq(name)); - EasyMock.replay(mockMonitor); - registry.unregisterLoader(name, (StAXElementLoader) mockLoader); - EasyMock.verify(mockMonitor); - } - - public void testSuccessfulDispatch() throws LoaderException, XMLStreamException { - EasyMock.expect(mockReader.getName()).andReturn(name); - EasyMock.replay(mockReader); - mockMonitor.registeringLoader(EasyMock.eq(name)); - mockMonitor.elementLoad(EasyMock.eq(name)); - EasyMock.replay(mockMonitor); - EasyMock.expect(mockLoader.load(EasyMock.isA(CompositeComponent.class), - (ModelObject) isNull(), - EasyMock.eq(mockReader), - EasyMock.eq(deploymentContext))).andReturn(modelObject); - EasyMock.replay(mockLoader); - registry.registerLoader(name, (StAXElementLoader) mockLoader); - CompositeComponent parent = EasyMock.createNiceMock(CompositeComponent.class); - assertSame(modelObject, registry.load(parent, null, mockReader, deploymentContext)); - EasyMock.verify(mockLoader); - EasyMock.verify(mockMonitor); - EasyMock.verify(mockReader); - - } - - public void testUnsuccessfulDispatch() throws LoaderException, XMLStreamException { - EasyMock.expect(mockReader.getName()).andReturn(name); - EasyMock.replay(mockReader); - mockMonitor.elementLoad(EasyMock.eq(name)); - EasyMock.replay(mockMonitor); - try { - registry.load(null, null, mockReader, deploymentContext); - fail(); - } catch (UnrecognizedElementException e) { - assertSame(name, e.getElement()); - } - EasyMock.verify(mockReader); - EasyMock.verify(mockMonitor); - } - - public void testPregivenModelObject() throws Exception { - EasyMock.expect(mockReader.getName()).andReturn(name); - EasyMock.replay(mockReader); - mockMonitor.registeringLoader(EasyMock.eq(name)); - mockMonitor.elementLoad(EasyMock.eq(name)); - EasyMock.replay(mockMonitor); - EasyMock.expect(mockLoader.load(EasyMock.isA(CompositeComponent.class), - EasyMock.eq(modelObject), - EasyMock.eq(mockReader), - EasyMock.eq(deploymentContext))).andReturn(modelObject); - EasyMock.replay(mockLoader); - registry.registerLoader(name, (StAXElementLoader) mockLoader); - CompositeComponent parent = EasyMock.createNiceMock(CompositeComponent.class); - assertSame(modelObject, registry.load(parent, modelObject, mockReader, deploymentContext)); - EasyMock.verify(mockLoader); - } - - @SuppressWarnings("unchecked") - protected void setUp() throws Exception { - super.setUp(); - name = new QName("http://mock", "test"); - deploymentContext = new RootDeploymentContext(null, null, null, null); - mockMonitor = EasyMock.createMock(LoaderRegistryImpl.Monitor.class); - registry = new LoaderRegistryImpl(mockMonitor); - - mockLoader = EasyMock.createMock(StAXElementLoader.class); - mockReader = EasyMock.createMock(XMLStreamReader.class); - modelObject = new ModelObject() { - }; - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/loader/StringParserPropertyFactoryTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/loader/StringParserPropertyFactoryTestCase.java deleted file mode 100644 index 4445dfad2c..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/loader/StringParserPropertyFactoryTestCase.java +++ /dev/null @@ -1,128 +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 org.w3c.dom.Document; -import org.w3c.dom.Element; - -import org.apache.tuscany.spi.ObjectFactory; -import org.apache.tuscany.spi.model.Property; -import org.apache.tuscany.spi.model.PropertyValue; - -import junit.framework.TestCase; -import org.easymock.EasyMock; - -/** - * @version $Rev$ $Date$ - */ -public class StringParserPropertyFactoryTestCase extends TestCase { - - private PropertyValue mock(String value) { - Document document = EasyMock.createMock(Document.class); - Element element = EasyMock.createMock(Element.class); - EasyMock.expect(document.getDocumentElement()).andReturn(element); - EasyMock.expect(element.getTextContent()).andReturn(value); - EasyMock.replay(document, element); - return new PropertyValue(null, document); - } - - public void testInteger() throws Exception { - - StringParserPropertyFactory factory = new StringParserPropertyFactory(); - Property property = new Property(); - property.setJavaType(Integer.class); - PropertyValue propertyValue = mock("1"); - ObjectFactory oFactory = factory.createObjectFactory(property, propertyValue); - assertEquals(1, oFactory.getInstance().intValue()); - } - - public void testPrimitiveInt() throws Exception { - StringParserPropertyFactory factory = new StringParserPropertyFactory(); - Property property = new Property(); - property.setJavaType(Integer.TYPE); - PropertyValue propertyValue = mock("1"); - ObjectFactory oFactory = factory.createObjectFactory(property, propertyValue); - assertEquals(1, oFactory.getInstance().intValue()); - } - - public void testString() throws Exception { - StringParserPropertyFactory factory = new StringParserPropertyFactory(); - Property property = new Property(); - property.setJavaType(String.class); - PropertyValue propertyValue = mock("1"); - ObjectFactory oFactory = factory.createObjectFactory(property, propertyValue); - assertEquals("1", oFactory.getInstance()); - } - - public void testByteArray() throws Exception { - StringParserPropertyFactory factory = new StringParserPropertyFactory(); - Property property = new Property(); - property.setJavaType(byte[].class); - PropertyValue propertyValue = mock("1"); - ObjectFactory oFactory = factory.createObjectFactory(property, propertyValue); - byte[] result = oFactory.getInstance(); - byte[] expected = "1".getBytes(); - for (int i = 0; i < result.length; i++) { - byte b = result[i]; - if (b != expected[i]) { - fail(); - } - } - } - - public void testBoolean() throws Exception { - StringParserPropertyFactory factory = new StringParserPropertyFactory(); - Property property = new Property(); - property.setJavaType(Boolean.class); - PropertyValue propertyValue = mock("true"); - ObjectFactory oFactory = factory.createObjectFactory(property, propertyValue); - assertTrue(oFactory.getInstance()); - } - - public void testPrimitiveBoolean() throws Exception { - StringParserPropertyFactory factory = new StringParserPropertyFactory(); - Property property = new Property(); - property.setJavaType(Boolean.TYPE); - PropertyValue propertyValue = mock("true"); - ObjectFactory oFactory = factory.createObjectFactory(property, propertyValue); - assertTrue(oFactory.getInstance()); - } - - public void testStringConstructor() throws Exception { - StringParserPropertyFactory factory = new StringParserPropertyFactory(); - Property property = new Property(); - property.setJavaType(Foo.class); - PropertyValue propertyValue = mock("test"); - ObjectFactory oFactory = factory.createObjectFactory(property, propertyValue); - assertEquals("test", oFactory.getInstance().getFoo()); - } - - private static class Foo { - private String foo; - - public Foo(String foo) { - this.foo = foo; - } - - public String getFoo() { - return foo; - } - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/loader/WireLoaderTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/loader/WireLoaderTestCase.java deleted file mode 100644 index a9fbcaaa4c..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/loader/WireLoaderTestCase.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.loader; - -import static javax.xml.stream.XMLStreamConstants.END_ELEMENT; -import static javax.xml.stream.XMLStreamConstants.START_ELEMENT; -import static org.easymock.EasyMock.createMock; -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.replay; -import static org.easymock.EasyMock.verify; -import org.easymock.EasyMock; - -import static org.osoa.sca.Version.XML_NAMESPACE_1_0; - -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import javax.xml.stream.Location; - -import junit.framework.TestCase; - -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.deployer.DeploymentContext; -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.WireDefinition; - -/** - * @version $Rev: 471504 $ $Date: 2006-11-06 01:10:40 +0530 (Mon, 06 Nov 2006) $ - */ -public class WireLoaderTestCase extends TestCase { - private static final QName WIRE = new QName(XML_NAMESPACE_1_0, "wire"); - private static final QName SOURCE_URI = new QName(XML_NAMESPACE_1_0, "source.uri"); - private static final QName TARGET_URI = new QName(XML_NAMESPACE_1_0, "target.uri"); - - private LoaderRegistry registry; - private WireLoader loader; - private XMLStreamReader reader; - private DeploymentContext context; - private CompositeComponent composite; - - public void testValidWire() throws LoaderException, XMLStreamException { - expect(reader.getName()).andReturn(WIRE); - expect(reader.next()).andReturn(START_ELEMENT); - expect(reader.getName()).andReturn(SOURCE_URI).times(1); - expect(reader.getElementText()).andReturn("source").times(1); - expect(reader.next()).andReturn(END_ELEMENT); - expect(reader.next()).andReturn(START_ELEMENT); - expect(reader.getName()).andReturn(TARGET_URI).times(2); - expect(reader.getElementText()).andReturn("target").times(1); - expect(reader.next()).andReturn(END_ELEMENT); - expect(reader.next()).andReturn(END_ELEMENT); - expect(reader.getName()).andReturn(WIRE).anyTimes(); - replay(registry, reader, context); - WireDefinition wireDef = loader.load(composite, null, reader, context); - assertNotNull(wireDef); - verify(registry, reader, context); - } - - public void testInValidWireNoSourceElement() throws LoaderException, XMLStreamException { - expect(reader.getName()).andReturn(WIRE).times(1); - expect(reader.next()).andReturn(START_ELEMENT); - expect(reader.getName()).andReturn(TARGET_URI).times(2); - expect(reader.getElementText()).andReturn("target").times(1); - expect(reader.next()).andReturn(END_ELEMENT); - expect(reader.next()).andReturn(END_ELEMENT); - expect(reader.getName()).andReturn(WIRE).anyTimes(); - replay(registry, reader, context); - try { - loader.load(composite, null, reader, context); - fail(); - } catch (InvalidWireException e) { - //expected behaviour - } - verify(registry, reader, context); - } - - public void testInValidWireNoTargetElement() throws LoaderException, XMLStreamException { - expect(reader.getName()).andReturn(WIRE).times(1); - expect(reader.next()).andReturn(START_ELEMENT); - expect(reader.getName()).andReturn(SOURCE_URI).times(1); - expect(reader.getElementText()).andReturn("source").times(1); - expect(reader.next()).andReturn(END_ELEMENT); - expect(reader.next()).andReturn(END_ELEMENT); - expect(reader.getName()).andReturn(WIRE).anyTimes(); - replay(registry, reader, context); - try { - loader.load(composite, null, reader, context); - fail(); - } catch (InvalidWireException e) { - //expected behaviour - } - verify(registry, reader, context); - } - - public void testInValidWireNoSourceSpecified() throws LoaderException, XMLStreamException { - expect(reader.getName()).andReturn(WIRE).times(1); - expect(reader.next()).andReturn(START_ELEMENT); - expect(reader.getName()).andReturn(SOURCE_URI).times(1); - expect(reader.getElementText()).andReturn("").times(1); - replay(registry, reader, context); - try { - loader.load(composite, null, reader, context); - fail(); - } catch (InvalidWireException e) { - //expected behaviour - } - verify(registry, reader, context); - } - - public void testInValidWireNoTargetSpecified() throws LoaderException, XMLStreamException { - expect(reader.getName()).andReturn(WIRE).times(1); - expect(reader.next()).andReturn(START_ELEMENT); - expect(reader.getName()).andReturn(SOURCE_URI).times(1); - expect(reader.getElementText()).andReturn("source").times(1); - expect(reader.next()).andReturn(END_ELEMENT); - expect(reader.next()).andReturn(START_ELEMENT); - expect(reader.getName()).andReturn(TARGET_URI).times(2); - expect(reader.getElementText()).andReturn("").times(1); - expect(reader.getName()).andReturn(WIRE).anyTimes(); - replay(registry, reader, context); - try { - loader.load(composite, null, reader, context); - fail(); - } catch (InvalidWireException e) { - //expected behaviour - } - verify(registry, reader, context); - } - - protected void setUp() throws Exception { - super.setUp(); - registry = createMock(LoaderRegistry.class); - reader = createMock(XMLStreamReader.class); - Location location = EasyMock.createNiceMock(Location.class); - EasyMock.replay(location); - EasyMock.expect(reader.getLocation()).andReturn(location).anyTimes(); - context = createMock(DeploymentContext.class); - composite = createMock(CompositeComponent.class); - loader = new WireLoader(registry); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/binding/MockServiceBinding.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/binding/MockServiceBinding.java deleted file mode 100644 index 8a38665584..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/binding/MockServiceBinding.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.mock.binding; - -import javax.xml.namespace.QName; - -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.component.TargetInvokerCreationException; -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.wire.InboundWire; -import org.apache.tuscany.spi.wire.OutboundWire; -import org.apache.tuscany.spi.wire.TargetInvoker; - -/** - * @version $Rev$ $Date$ - */ -public class MockServiceBinding extends AbstractSCAObject implements ServiceBinding { - private InboundWire inboundWire; - private OutboundWire outboundWire; - private ServiceContract bindingServiceContract; - - - public MockServiceBinding() { - super("foo", null); - } - - public QName getBindingType() { - return null; - } - - public void setService(Service service) { - } - - public ServiceContract getBindingServiceContract() { - return bindingServiceContract; - } - - public InboundWire getInboundWire() { - return inboundWire; - } - - public void setInboundWire(InboundWire inboundWire) { - this.inboundWire = inboundWire; - } - - public OutboundWire getOutboundWire() { - return outboundWire; - } - - public void setOutboundWire(OutboundWire outboundWire) { - this.outboundWire = outboundWire; - } - - public TargetInvoker createTargetInvoker(ServiceContract contract, Operation operation) - throws TargetInvokerCreationException { - return null; - } - - public Scope getScope() { - return null; - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/AsyncTarget.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/AsyncTarget.java deleted file mode 100644 index 653d5d7335..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/BadContextPojo.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/BadContextPojo.java deleted file mode 100644 index 066acc346d..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/BadNamePojo.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/BadNamePojo.java deleted file mode 100644 index 77ec37f9e4..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/BasicInterface.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/BasicInterface.java deleted file mode 100644 index b7921c248f..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/BasicInterfaceImpl.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/BasicInterfaceImpl.java deleted file mode 100644 index f7d7bb38cf..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/CompositeScopeComponent.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/CompositeScopeComponent.java deleted file mode 100644 index 88b97216cd..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/CompositeScopeComponentImpl.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/CompositeScopeComponentImpl.java deleted file mode 100644 index 93ee1f707a..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/CompositeScopeDestroyOnlyComponent.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/CompositeScopeDestroyOnlyComponent.java deleted file mode 100644 index 16ce3b5569..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/CompositeScopeInitDestroyComponent.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/CompositeScopeInitDestroyComponent.java deleted file mode 100644 index 05b938a87c..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/CompositeScopeInitOnlyComponent.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/CompositeScopeInitOnlyComponent.java deleted file mode 100644 index f9f80ca15c..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/ConversationalScopeComponent.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/ConversationalScopeComponent.java deleted file mode 100644 index c71ac0586f..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/ConversationalScopeComponentImpl.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/ConversationalScopeComponentImpl.java deleted file mode 100644 index 5ea7278e1f..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/ConversationalScopeDestroyOnlyComponent.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/ConversationalScopeDestroyOnlyComponent.java deleted file mode 100644 index 8cea9efa49..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/ConversationalScopeInitDestroyComponent.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/ConversationalScopeInitDestroyComponent.java deleted file mode 100644 index 40dbfedf2c..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/ConversationalScopeInitOnlyComponent.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/ConversationalScopeInitOnlyComponent.java deleted file mode 100644 index caaa0c39e7..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/OrderException.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/OrderException.java deleted file mode 100644 index af257c226d..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/OrderedDependentPojo.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/OrderedDependentPojo.java deleted file mode 100644 index 2033f0eca5..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/OrderedDependentPojoImpl.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/OrderedDependentPojoImpl.java deleted file mode 100644 index 439c3d143c..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/OrderedEagerInitPojo.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/OrderedEagerInitPojo.java deleted file mode 100644 index 1986952747..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/OrderedInitPojo.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/OrderedInitPojo.java deleted file mode 100644 index 0b891cfa42..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/OrderedInitPojoImpl.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/OrderedInitPojoImpl.java deleted file mode 100644 index a7063f6353..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/OtherTarget.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/OtherTarget.java deleted file mode 100644 index 0b897daa40..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/OtherTargetImpl.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/OtherTargetImpl.java deleted file mode 100644 index a3b2bbf098..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/RequestScopeComponent.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/RequestScopeComponent.java deleted file mode 100644 index 8c7dc107ee..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/RequestScopeDestroyOnlyComponent.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/RequestScopeDestroyOnlyComponent.java deleted file mode 100644 index 5224ceda5f..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/RequestScopeInitDestroyComponent.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/RequestScopeInitDestroyComponent.java deleted file mode 100644 index 38b188a4b5..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/RequestScopeInitOnlyComponent.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/RequestScopeInitOnlyComponent.java deleted file mode 100644 index 707f8ab50f..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/SessionScopeComponent.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/SessionScopeComponent.java deleted file mode 100644 index 827ba804f2..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/SessionScopeComponentImpl.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/SessionScopeComponentImpl.java deleted file mode 100644 index e547bf6113..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/SessionScopeInitDestroyComponent.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/SessionScopeInitDestroyComponent.java deleted file mode 100644 index c11bd1bd49..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/SessionScopeInitOnlyComponent.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/SessionScopeInitOnlyComponent.java deleted file mode 100644 index 095cc916ec..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/SimpleTarget.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/SimpleTarget.java deleted file mode 100644 index c78ba00a7a..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/SimpleTargetImpl.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/SimpleTargetImpl.java deleted file mode 100644 index 634a07a401..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/Source.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/Source.java deleted file mode 100644 index f7969f748b..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/SourceImpl.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/SourceImpl.java deleted file mode 100644 index 187e33b2bd..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/StatelessComponent.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/StatelessComponent.java deleted file mode 100644 index c16ac942a3..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/StatelessComponentImpl.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/StatelessComponentImpl.java deleted file mode 100644 index 64a23c12c8..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/Target.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/Target.java deleted file mode 100644 index 778c14665d..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/TargetImpl.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/TargetImpl.java deleted file mode 100644 index 037dd3a37c..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/wire/MockStaticInvoker.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/wire/MockStaticInvoker.java deleted file mode 100644 index cdd0de7a6d..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/wire/MockStaticInvoker.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.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; - -/** - * 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) 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); - 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/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/wire/MockSyncInterceptor.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/wire/MockSyncInterceptor.java deleted file mode 100644 index 1fe2c027ab..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/wire/MockTargetInvoker.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/mock/wire/MockTargetInvoker.java deleted file mode 100644 index 3fcc75bdb4..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/monitor/DefaultExceptionFormatterTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/monitor/DefaultExceptionFormatterTestCase.java deleted file mode 100644 index 2d3f01422d..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/monitor/DefaultExceptionFormatterTestCase.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.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") { - }; - e.addContextName("somecontext"); - formatter.write(pw, e); - assertTrue(writer.toString().indexOf("somemessage") >= 0); - assertTrue(writer.toString().indexOf("somecontext") >= 0); - } - - public void testTuscanyRuntimeExceptionFormat() throws Exception { - StringWriter writer = new StringWriter(); - PrintWriter pw = new PrintWriter(writer); - TuscanyRuntimeException e = new TuscanyRuntimeException("somemessage") { - }; - e.addContextName("somecontext"); - formatter.write(pw, e); - assertTrue(writer.toString().indexOf("somemessage") >= 0); - assertTrue(writer.toString().indexOf("somecontext") >= 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/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/monitor/JavaLoggingTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/monitor/JavaLoggingTestCase.java deleted file mode 100644 index 5fdf035c7a..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/policy/IntentRegistryImplTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/policy/IntentRegistryImplTestCase.java deleted file mode 100644 index f6f813a7a5..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/policy/IntentRegistryImplTestCase.java +++ /dev/null @@ -1,152 +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.policy; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import javax.xml.namespace.QName; - -import static org.osoa.sca.Version.XML_NAMESPACE_1_0; - -import org.apache.tuscany.spi.model.Intent; -import org.apache.tuscany.spi.model.IntentName; -import org.apache.tuscany.spi.policy.IntentRegistry; - -import junit.framework.TestCase; - -/** - * @version $Rev$ $Date$ - */ -public class IntentRegistryImplTestCase extends TestCase { - private static final QName WS_BINDING = new QName(XML_NAMESPACE_1_0, "binding.ws"); - private static final QName JMS_BINDING = new QName(XML_NAMESPACE_1_0, "binding.jms"); - private IntentRegistry intentReg; - - @Override - protected void setUp() throws Exception { - intentReg = new IntentRegistryImpl(); - - Intent bodyintent = new Intent(new IntentName("sec.confidentiality/message/body"), "test"); - bodyintent.addAppliedArtifacts(WS_BINDING); - bodyintent.addAppliedArtifacts(JMS_BINDING); - intentReg.register(bodyintent); - - Intent headintent = new Intent(new IntentName("sec.confidentiality/message/head"), "test"); - headintent.addAppliedArtifacts(WS_BINDING); - headintent.addAppliedArtifacts(JMS_BINDING); - intentReg.register(headintent); - - Intent confidentialityintent = new Intent(new IntentName("sec.confidentiality"), "test"); - confidentialityintent.addAppliedArtifacts(WS_BINDING); - confidentialityintent.addAppliedArtifacts(JMS_BINDING); - intentReg.register(confidentialityintent); - - Intent messageintent = new Intent(new IntentName("sec.confidentiality/message"), null); - messageintent.addAppliedArtifacts(WS_BINDING); - messageintent.addAppliedArtifacts(JMS_BINDING); - intentReg.register(messageintent); - } - - @Override - protected void tearDown() throws Exception { - intentReg = null; - } - -// public void testGetQualifiedIntent() { -// List intentNameList = new ArrayList(); -// intentReg.get -// //intentReg.getConcretIntents(intentNameList, artifact) -// } - - public void testGetConcretIntents() { - Intent messageintent = new Intent(new IntentName("sec.confidentiality/transport"), null); - messageintent.addAppliedArtifacts(WS_BINDING); - messageintent.addAppliedArtifacts(JMS_BINDING); - intentReg.register(messageintent); - - Intent allintent = new Intent(new IntentName("sec.confidentiality/all"), null); - allintent.addAppliedArtifacts(WS_BINDING); - allintent.addRequriedIntents(new IntentName("sec.confidentiality/message")); - allintent.addRequriedIntents(new IntentName("sec.confidentiality/transport")); - - - intentReg.register(allintent); - List intents = new ArrayList(); - intents.add(new IntentName("sec.confidentiality/all")); - Collection concreteIntents = intentReg.inlineProfileIntent(intents, WS_BINDING); - assertEquals(2, concreteIntents.size()); - assertTrue(concreteIntents.contains(new IntentName("sec.confidentiality/message"))); - assertTrue(concreteIntents.contains(new IntentName("sec.confidentiality/transport"))); - //fail("Not yet implemented"); - } - - public void testGetQualifiedIntents() { - IntentName message = new IntentName("sec.confidentiality/message"); - Collection qualifiedIntents = intentReg.getQualifiedIntents(message, JMS_BINDING); - assertEquals(2, qualifiedIntents.size()); - assertTrue(qualifiedIntents.contains(new IntentName("sec.confidentiality/message/body"))); - assertTrue(qualifiedIntents.contains(new IntentName("sec.confidentiality/message/head"))); - assertFalse(qualifiedIntents.contains(new IntentName("sec.confidentiality/message"))); - assertFalse(qualifiedIntents.contains(new IntentName("sec.confidentiality"))); - } - - public void testIsApplicable() { - assertTrue(intentReg.isApplicable(new IntentName("sec.confidentiality/message"), WS_BINDING)); - assertFalse(intentReg.isApplicable(new IntentName("sec.confidentiality/transport"), WS_BINDING)); - assertFalse(intentReg.isApplicable(new IntentName("test.confidentiality/transport"), WS_BINDING)); - } - - public void testRegister() { - Intent messageintent = new Intent(new IntentName("sec.confidentiality/transport"), null); - messageintent.addAppliedArtifacts(WS_BINDING); - messageintent.addAppliedArtifacts(JMS_BINDING); - intentReg.register(messageintent); - assertTrue(intentReg.isApplicable(new IntentName("sec.confidentiality/transport"), WS_BINDING)); - assertTrue(intentReg.isApplicable(new IntentName("sec.confidentiality/transport"), JMS_BINDING)); - - } - - public void testIsQualifiedIntent() { - Intent messageintent = new Intent(new IntentName("sec.confidentiality/transport"), null); - messageintent.addAppliedArtifacts(WS_BINDING); - messageintent.addAppliedArtifacts(JMS_BINDING); - intentReg.register(messageintent); - Intent allintent = new Intent(new IntentName("sec.confidentiality/all"), null); - allintent.addAppliedArtifacts(WS_BINDING); - - assertTrue(intentReg.isQualifiedIntent(new IntentName("sec.confidentiality/transport"))); - assertTrue(intentReg.isQualifiedIntent(new IntentName("sec.confidentiality/message/body"))); - assertTrue(intentReg.isQualifiedIntent(new IntentName("sec.confidentiality/message/body"))); - assertFalse(intentReg.isQualifiedIntent(new IntentName("sec.confidentiality/message"))); - assertFalse(intentReg.isQualifiedIntent(new IntentName("sec.confidentiality"))); - } - - public void testUnRegister() { - Intent messageintent = new Intent(new IntentName("sec.confidentiality/transport"), null); - messageintent.addAppliedArtifacts(WS_BINDING); - messageintent.addAppliedArtifacts(JMS_BINDING); - intentReg.register(messageintent); - intentReg.unRegister(messageintent); - assertFalse(intentReg.isApplicable(new IntentName("sec.confidentiality/transport"), WS_BINDING)); - assertFalse(intentReg.isApplicable(new IntentName("sec.confidentiality/transport"), JMS_BINDING)); - - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/policy/PolicyEngineImplTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/policy/PolicyEngineImplTestCase.java deleted file mode 100644 index ce04a3e740..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/policy/PolicyEngineImplTestCase.java +++ /dev/null @@ -1,140 +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.policy; - -import java.io.InputStream; -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; -import javax.xml.namespace.QName; -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLStreamConstants; -import javax.xml.stream.XMLStreamReader; - -import static org.osoa.sca.Version.XML_NAMESPACE_1_0; - -import org.apache.tuscany.spi.model.Intent; -import org.apache.tuscany.spi.model.IntentName; -import org.apache.tuscany.spi.model.PolicyModel; -import org.apache.tuscany.spi.model.PolicySet; -import org.apache.tuscany.spi.policy.IntentRegistry; -import org.apache.tuscany.spi.policy.PolicyEngine; -import org.apache.tuscany.spi.policy.PolicySetContainer; -import org.apache.tuscany.spi.policy.SCATypeManager; - -import junit.framework.TestCase; -import org.apache.tuscany.core.loader.PolicySetLoader; - -public class PolicyEngineImplTestCase extends TestCase { - private static final QName POLICYSET = new QName(XML_NAMESPACE_1_0, "policySet"); - private static final QName WS_BINDING = new QName(XML_NAMESPACE_1_0, "binding.ws"); - private IntentRegistry intentReg; - private PolicyEngine policyEngine; - - - public void testgetPolicy() throws Exception { - Collection policies = - policyEngine.getPolicy(new IntentName[]{new IntentName("sec.authentication/cert")}, null, WS_BINDING); - assertEquals(2, policies.size()); - policies = - policyEngine.getPolicy(new IntentName[]{new IntentName("sec.authentication/basic")}, null, WS_BINDING); - assertEquals(1, policies.size()); - - //test for unqualified intent with default value on intentMap - policies = policyEngine.getPolicy(new IntentName[]{new IntentName("sec.authentication")}, null, WS_BINDING); - assertEquals(2, policies.size()); - } - - @Override - protected void setUp() throws Exception { - PolicySetLoader loader = new PolicySetLoader(null); - XMLInputFactory factory = XMLInputFactory.newInstance(); - InputStream resourceAsStream = this.getClass().getResourceAsStream("PolicySet.scdl"); - XMLStreamReader reader = factory.createXMLStreamReader(resourceAsStream); - PolicySetContainerImpl psc = new PolicySetContainerImpl(); - while (true) { - int state = reader.next(); - if (state == XMLStreamConstants.END_DOCUMENT) { - break; - } - if (XMLStreamConstants.START_ELEMENT == state && reader.getName().equals(POLICYSET)) { - psc.addPolicySet(loader.load(null, null, reader, null)); - } - - } - resourceAsStream.close(); - intentReg = new IntentRegistryImpl(); - policyEngine = new PolicyEngineImpl(intentReg, psc, new SCATypeManagerImpl()); - - Intent bodyintent = new Intent(new IntentName("sec.confidentiality/message/body"), "test"); - bodyintent.addAppliedArtifacts(WS_BINDING); - intentReg.register(bodyintent); - - Intent allintent = new Intent(new IntentName("sec.confidentiality/message/all"), "test"); - allintent.addAppliedArtifacts(WS_BINDING); - intentReg.register(allintent); - - Intent confidentialityintent = new Intent(new IntentName("sec.confidentiality"), "test"); - confidentialityintent.addAppliedArtifacts(WS_BINDING); - intentReg.register(confidentialityintent); - - Intent messageintent = new Intent(new IntentName("sec.confidentiality/message"), null); - messageintent.addAppliedArtifacts(WS_BINDING); - intentReg.register(messageintent); - - Intent authintent = new Intent(new IntentName("sec.authentication"), null); - authintent.addAppliedArtifacts(WS_BINDING); - intentReg.register(authintent); - - Intent certintent = new Intent(new IntentName("sec.authentication/cert"), null); - certintent.addAppliedArtifacts(WS_BINDING); - intentReg.register(certintent); - - Intent basicintent = new Intent(new IntentName("sec.authentication/basic"), null); - basicintent.addAppliedArtifacts(WS_BINDING); - intentReg.register(basicintent); - - } - - private class PolicySetContainerImpl implements PolicySetContainer { - - private Map sets = new HashMap(); - - public Collection getAllPolicySet() { - return sets.values(); - } - - public PolicySet getPolicySet(QName name) { - return sets.get(name); - } - - public void addPolicySet(PolicySet pset) { - sets.put(pset.getName(), pset); - } - - } - - private class SCATypeManagerImpl implements SCATypeManager { - - public boolean isTypeOf(QName subType, QName type) { - return subType.equals(type); - } - - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/property/PropertyHelperTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/property/PropertyHelperTestCase.java deleted file mode 100644 index 4f2e2fbf42..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/property/PropertyHelperTestCase.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.property; - -import java.net.URL; -import javax.xml.namespace.NamespaceContext; - -import org.w3c.dom.Document; -import org.w3c.dom.Node; - -import org.apache.tuscany.spi.deployer.DeploymentContext; - -import junit.framework.TestCase; -import org.apache.tuscany.core.databinding.xml.String2Node; -import org.easymock.EasyMock; - -/** - * - */ -public class PropertyHelperTestCase extends TestCase { - private static final String IPO_XML = - "" + "" - + " " - + " 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" - + " " - + " " - + ""; - - /** - * @see junit.framework.TestCase#setUp() - */ - protected void setUp() throws Exception { - super.setUp(); - } - - public void testXPath() throws Exception { - String2Node t = new String2Node(); - Node node = t.transform(IPO_XML, null); - - Document doc = PropertyHelper.evaluate(null, node, "/ipo:purchaseOrder/billTo"); - assertNotNull(doc); - - NamespaceContext context = EasyMock.createMock(NamespaceContext.class); - EasyMock.expect(context.getNamespaceURI("ipo")).andReturn("http://www.example.com/IPO").anyTimes(); - EasyMock.replay(context); - doc = PropertyHelper.evaluate(context, node, "/ipo:purchaseOrder/items"); - assertNotNull(doc); - doc = PropertyHelper.evaluate(context, node, "/ipo:purchaseOrder/billTo"); - assertNotNull(doc); - doc = PropertyHelper.evaluate(context, node, "/"); - assertNotNull(doc); - doc = PropertyHelper.evaluate(context, node, "/ipo:purchaseOrder/billTo1"); - assertNull(doc); - } - - public void testFile() throws Exception { - URL url = getClass().getResource("ipo.xml"); - Document doc = PropertyHelper.loadFromFile(url.toExternalForm(), null); - assertNotNull(doc); - - DeploymentContext context = EasyMock.createMock(DeploymentContext.class); - EasyMock.expect(context.getClassLoader()).andReturn(getClass().getClassLoader()); - EasyMock.replay(context); - doc = PropertyHelper.loadFromFile("org/apache/tuscany/core/property/ipo.xml", context); - assertNotNull(doc); - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/property/SimplePropertyObjectFactoryTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/property/SimplePropertyObjectFactoryTestCase.java deleted file mode 100644 index 9ef1faccfe..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/property/SimplePropertyObjectFactoryTestCase.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.property; - -import org.w3c.dom.Document; -import org.w3c.dom.Element; - -import org.apache.tuscany.spi.ObjectFactory; -import org.apache.tuscany.spi.model.Property; -import org.apache.tuscany.spi.model.PropertyValue; - -import junit.framework.TestCase; -import org.easymock.EasyMock; - -/** - * @version $Rev$ $Date$ - */ -public class SimplePropertyObjectFactoryTestCase extends TestCase { - - private PropertyValue mock(String value) { - Document document = EasyMock.createMock(Document.class); - Element element = EasyMock.createMock(Element.class); - EasyMock.expect(document.getDocumentElement()).andReturn(element); - EasyMock.expect(element.getTextContent()).andReturn(value); - EasyMock.replay(document, element); - return new PropertyValue(null, document); - } - - public void testInteger() throws Exception { - - PropertyObjectFactoryImpl factory = new PropertyObjectFactoryImpl(); - Property property = new Property(); - property.setJavaType(Integer.class); - PropertyValue propertyValue = mock("1"); - ObjectFactory oFactory = factory.createObjectFactory(property, propertyValue); - assertEquals(1, oFactory.getInstance().intValue()); - } - - public void testPrimitiveInt() throws Exception { - PropertyObjectFactoryImpl factory = new PropertyObjectFactoryImpl(); - Property property = new Property(); - property.setJavaType(Integer.TYPE); - PropertyValue propertyValue = mock("1"); - ObjectFactory oFactory = factory.createObjectFactory(property, propertyValue); - assertEquals(1, oFactory.getInstance().intValue()); - } - - public void testString() throws Exception { - PropertyObjectFactoryImpl factory = new PropertyObjectFactoryImpl(); - Property property = new Property(); - property.setJavaType(String.class); - PropertyValue propertyValue = mock("1"); - ObjectFactory oFactory = factory.createObjectFactory(property, propertyValue); - assertEquals("1", oFactory.getInstance()); - } - - public void testByteArray() throws Exception { - PropertyObjectFactoryImpl factory = new PropertyObjectFactoryImpl(); - Property property = new Property(); - property.setJavaType(byte[].class); - PropertyValue propertyValue = mock("TWFu"); // BASE64 for "Man" - ObjectFactory oFactory = factory.createObjectFactory(property, propertyValue); - byte[] result = oFactory.getInstance(); - byte[] expected = "Man".getBytes(); - for (int i = 0; i < result.length; i++) { - byte b = result[i]; - if (b != expected[i]) { - fail(); - } - } - } - - public void testBoolean() throws Exception { - PropertyObjectFactoryImpl factory = new PropertyObjectFactoryImpl(); - Property property = new Property(); - property.setJavaType(Boolean.class); - PropertyValue propertyValue = mock("true"); - ObjectFactory oFactory = factory.createObjectFactory(property, propertyValue); - assertTrue(oFactory.getInstance()); - } - - public void testPrimitiveBoolean() throws Exception { - PropertyObjectFactoryImpl factory = new PropertyObjectFactoryImpl(); - Property property = new Property(); - property.setJavaType(Boolean.TYPE); - PropertyValue propertyValue = mock("true"); - ObjectFactory oFactory = factory.createObjectFactory(property, propertyValue); - assertTrue(oFactory.getInstance()); - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/services/artifact/LocalMavenRepositoryTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/services/artifact/LocalMavenRepositoryTestCase.java deleted file mode 100644 index 0efecb9302..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/services/artifact/LocalMavenRepositoryTestCase.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.services.artifact; - -import java.io.File; -import java.io.UnsupportedEncodingException; -import java.net.MalformedURLException; -import java.net.URL; - -import junit.framework.TestCase; - -import org.apache.tuscany.spi.services.artifact.Artifact; - -/** - * This testcase assumes that there is a maven repo in the default location. - * - * @version $Rev$ $Date$ - */ -public class LocalMavenRepositoryTestCase extends TestCase { - private static final String VERSION = "3.8.1"; - private LocalMavenRepository repo; - private Artifact artifact; - private String path; - - public void testPathWithNoClassifier() { - assertEquals(path, repo.getPath(artifact)); - } - - public void testPathWithClassifier() { - artifact.setClassifier("x86"); - path = "junit/junit/" + VERSION + "/junit-" + VERSION + "-x86.jar"; - assertEquals(path, repo.getPath(artifact)); - } - - public void testArtifactFoundInRepo() throws MalformedURLException, UnsupportedEncodingException { - String home = System.getProperty("user.home"); - File file = new File(home + "/.m2/repository", path); - repo.resolve(artifact); - assertEquals(file.toURI().toURL(), artifact.getUrl()); - } - - public void testArtifactNotFoundInRepo() throws MalformedURLException { - artifact.setClassifier("x86"); - repo.resolve(artifact); - assertNull(artifact.getUrl()); - } - - public void testNonNullURLIsUnmodified() throws MalformedURLException { - URL url = new URL("http://www.apache.org"); - artifact.setUrl(url); - repo.resolve(artifact); - assertSame(url, artifact.getUrl()); - } - - protected void setUp() throws Exception { - super.setUp(); - repo = new LocalMavenRepository(".m2/repository"); - - artifact = new Artifact(); - artifact.setGroup("junit"); - artifact.setName("junit"); - artifact.setVersion(VERSION); - artifact.setType("jar"); - path = "junit/junit/" + VERSION + "/junit-" + VERSION + ".jar"; - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/services/deployment/AssemblyServiceImplTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/services/deployment/AssemblyServiceImplTestCase.java deleted file mode 100644 index 357eee9f93..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/services/deployment/AssemblyServiceImplTestCase.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.services.deployment; - -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.net.URLConnection; -import java.net.URLStreamHandler; - -import junit.framework.TestCase; -import org.easymock.classextension.EasyMock; - -import org.apache.tuscany.host.deployment.UnsupportedContentTypeException; - -/** - * @version $Rev$ $Date$ - */ -public class AssemblyServiceImplTestCase extends TestCase { - private AssemblyServiceImpl service; - - public void testApplyChangesWithNullURL() { - try { - service.applyChanges(null); - fail(); - } catch (IllegalArgumentException e) { - //ok - } catch (Throwable t) { - fail(); - } - } - - public void testApplyChangesWhenURLContentTypeIsNull() throws Exception { - final URLConnection urlConnection = EasyMock.createMock(URLConnection.class); - EasyMock.expect(urlConnection.getContentType()).andReturn(null); - EasyMock.replay(urlConnection); - URLStreamHandler handler = new MockURLStreamHandler(urlConnection); - - URL url = new URL(null, "file:/tmp/foo.xml", handler); - try { - service.applyChanges(url); - } catch (UnsupportedContentTypeException e) { - assertNull(e.getMessage()); - assertEquals(url.toString(), e.getIdentifier()); - EasyMock.verify(urlConnection); - } catch (Throwable t) { - fail(); - } - } - - public void testApplyChangesWithNullStream() { - try { - service.applyChanges(null, "xxx/xxx"); - fail(); - } catch (IllegalArgumentException e) { - //ok - } catch (Throwable t) { - fail(); - } - } - - public void testApplyChangesWithNullContentType() { - InputStream is = EasyMock.createMock(InputStream.class); - EasyMock.replay(is); - try { - service.applyChanges(is, null); - fail(); - } catch (IllegalArgumentException e) { - EasyMock.verify(is); - } catch (Throwable t) { - fail(); - } - } - - protected void setUp() throws Exception { - super.setUp(); - service = new AssemblyServiceImpl(); - } - - private static class MockURLStreamHandler extends URLStreamHandler { - private final URLConnection urlConnection; - - public MockURLStreamHandler(URLConnection urlConnection) { - this.urlConnection = urlConnection; - } - - protected URLConnection openConnection(URL url) throws IOException { - return urlConnection; - } - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/services/host/DelegatingResourceHostRegistryTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/services/host/DelegatingResourceHostRegistryTestCase.java deleted file mode 100644 index c3eb2fa1bf..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/services/host/DelegatingResourceHostRegistryTestCase.java +++ /dev/null @@ -1,147 +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.host; - -import org.apache.tuscany.spi.host.ResourceHost; -import org.apache.tuscany.spi.host.ResourceResolutionException; - -import junit.framework.TestCase; -import org.easymock.EasyMock; - -/** - * @version $Rev$ $Date$ - */ -public class DelegatingResourceHostRegistryTestCase extends TestCase { - - public void testResolveByType() throws Exception { - Object ret = new Object(); - DelegatingResourceHostRegistry registry = new DelegatingResourceHostRegistry(); - registry.registerResource(Object.class, ret); - assertEquals(ret, registry.resolveResource(Object.class)); - } - - public void testResolveByUri() throws Exception { - ResourceHost host = EasyMock.createMock(ResourceHost.class); - EasyMock.expect(host.resolveResource(String.class, "Foo://foo")).andReturn("result"); - EasyMock.replay(host); - DelegatingResourceHostRegistry registry = new DelegatingResourceHostRegistry(); - registry.registerResourceHost("Foo://", host); - assertEquals("result", registry.resolveResource(String.class, "Foo://foo")); - EasyMock.verify(host); - } - - public void testResolveBySCAUri() throws Exception { - ResourceHost host = EasyMock.createMock(ResourceHost.class); - EasyMock.replay(host); - DelegatingResourceHostRegistry registry = new DelegatingResourceHostRegistry(); - registry.registerResourceHost("Foo://", host); - Object ret = new Object(); - registry.registerResource(Object.class, "foo", ret); - assertEquals(ret, registry.resolveResource(Object.class, "SCA://foo")); - EasyMock.verify(host); - } - - public void testResolveByUriNotFound() throws Exception { - ResourceHost host = EasyMock.createMock(ResourceHost.class); - EasyMock.replay(host); - DelegatingResourceHostRegistry registry = new DelegatingResourceHostRegistry(); - registry.registerResourceHost("Foo://", host); - try { - assertEquals("result", registry.resolveResource(String.class, "Bar://bar")); - fail(); - } catch (ResourceResolutionException e) { - //expected - } - EasyMock.verify(host); - } - - public void testUnregisterHost() throws Exception { - ResourceHost host = EasyMock.createMock(ResourceHost.class); - EasyMock.replay(host); - DelegatingResourceHostRegistry registry = new DelegatingResourceHostRegistry(); - registry.registerResourceHost("Foo://", host); - registry.unregisterResourceHost("Foo://"); - try { - registry.resolveResource(String.class, "Foo://foo"); - fail(); - } catch (ResourceResolutionException e) { - //expected - } - EasyMock.verify(host); - } - - public void testUnregisterResource() throws Exception { - DelegatingResourceHostRegistry registry = new DelegatingResourceHostRegistry(); - registry.registerResource(Object.class, new Object()); - registry.unregisterResource(Object.class); - assertNull(registry.resolveResource(Object.class)); - } - - public void testUnregisterMappedResource() throws Exception { - DelegatingResourceHostRegistry registry = new DelegatingResourceHostRegistry(); - registry.registerResource(Object.class, "foo", new Object()); - registry.registerResource(Object.class, new Object()); - registry.unregisterResource(Object.class); - assertNull(registry.resolveResource(Object.class)); - assertNotNull(registry.resolveResource(Object.class, "foo")); - registry.unregisterResource(Object.class, "foo"); - assertNull(registry.resolveResource(Object.class)); - } - - public void testReolvedByTypeToMappedResource() throws Exception { - DelegatingResourceHostRegistry registry = new DelegatingResourceHostRegistry(); - registry.registerResource(Object.class, "foo", new Object()); - assertNull(registry.resolveResource(Object.class)); - } - - public void testDelegatingResolveResource() throws Exception { - Object ret = new Object(); - ResourceHost host = EasyMock.createMock(ResourceHost.class); - EasyMock.expect(host.resolveResource(Object.class)).andReturn(ret); - EasyMock.replay(host); - DelegatingResourceHostRegistry registry = new DelegatingResourceHostRegistry(); - registry.registerResourceHost("Foo://", host); - assertEquals(ret, registry.resolveResource(Object.class)); - EasyMock.verify(host); - } - - public void testDelegatingResolveResourceByTypeandName() throws Exception { - Object ret = new Object(); - ResourceHost host = EasyMock.createMock(ResourceHost.class); - EasyMock.expect(host.resolveResource(EasyMock.eq(Object.class), EasyMock.eq("Foo://bar"))).andReturn(ret); - EasyMock.replay(host); - DelegatingResourceHostRegistry registry = new DelegatingResourceHostRegistry(); - registry.registerResourceHost("Foo://", host); - assertEquals(ret, registry.resolveResource(Object.class, "Foo://bar")); - EasyMock.verify(host); - } - - public void testResolveLocalResourceFirst() throws Exception { - Object local = new Object(); - ResourceHost host = EasyMock.createMock(ResourceHost.class); - EasyMock.replay(host); - DelegatingResourceHostRegistry registry = new DelegatingResourceHostRegistry(); - registry.registerResourceHost("Foo://", host); - registry.registerResource(Object.class, local); - assertEquals(local, registry.resolveResource(Object.class)); - EasyMock.verify(host); - } - - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/services/store/memory/MemoryStoreTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/services/store/memory/MemoryStoreTestCase.java deleted file mode 100644 index 5ec1643b47..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/services/store/memory/MemoryStoreTestCase.java +++ /dev/null @@ -1,164 +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.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.createNiceMock(AtomicComponent.class); - 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/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/services/work/jsr237/Jsr237WorkSchedulerTest.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/services/work/jsr237/Jsr237WorkSchedulerTest.java deleted file mode 100644 index 1a5cb4ebe1..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/services/work/jsr237/Jsr237WorkSchedulerTest.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.services.work.jsr237; - -import org.apache.tuscany.spi.services.work.NotificationListener; -import org.apache.tuscany.spi.services.work.WorkScheduler; - -import commonj.work.WorkManager; -import junit.framework.TestCase; -import org.apache.tuscany.core.services.work.jsr237.workmanager.ThreadPoolWorkManager; - -public class Jsr237WorkSchedulerTest extends TestCase { - - /* - * Test method for 'org.apache.tuscany.core.services.work.jsr237.Jsr237WorkScheduler.scheduleWork(T) ' - */ - public void testScheduleWorkT() { - - - WorkManager workManager = new ThreadPoolWorkManager(1); - WorkScheduler workScheduler = new Jsr237WorkScheduler(workManager); - - workScheduler.scheduleWork(new MyRunnable(), new MyNotificationListener()); - - } - - /* - * Test method for 'org.apache.tuscany.core.services.work.jsr237.Jsr237WorkScheduler.scheduleWork(T, - * NotificationListener) ' - */ - public void testScheduleWorkTNotificationListenerOfT() { - - } - - private class MyRunnable implements Runnable { - public void run() { - System.err.println("Test executed"); - } - } - - private class MyNotificationListener implements NotificationListener { - - public void workAccepted(MyRunnable work) { - System.err.println("Work accepted"); - } - - public void workCompleted(MyRunnable work) { - System.err.println("Work completed"); - } - - public void workStarted(MyRunnable work) { - System.err.println("Work started"); - } - - public void workRejected(MyRunnable work) { - System.err.println("Work rejected"); - } - - public void workFailed(MyRunnable work, Throwable error) { - System.err.println("Work failed"); - } - - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/services/work/jsr237/Jsr237WorkSchedulerTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/services/work/jsr237/Jsr237WorkSchedulerTestCase.java deleted file mode 100644 index 3966f65683..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/services/work/jsr237/Jsr237WorkSchedulerTestCase.java +++ /dev/null @@ -1,100 +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.work.jsr237; - -import org.apache.tuscany.spi.services.work.NotificationListener; -import org.apache.tuscany.spi.services.work.WorkSchedulerException; - -import commonj.work.Work; -import commonj.work.WorkItem; -import commonj.work.WorkListener; -import commonj.work.WorkManager; -import commonj.work.WorkRejectedException; -import junit.framework.TestCase; -import static org.easymock.EasyMock.createMock; -import static org.easymock.EasyMock.expectLastCall; -import static org.easymock.EasyMock.isA; -import static org.easymock.EasyMock.replay; -import static org.easymock.EasyMock.verify; - -/** - * @version $Rev$ $Date$ - */ -public class Jsr237WorkSchedulerTestCase extends TestCase { - - public void testSchedule() throws Exception { - WorkItem item = createMock(WorkItem.class); - WorkManager mgr = createMock(WorkManager.class); - mgr.schedule(isA(Work.class)); - expectLastCall().andReturn(item); - replay(mgr); - Jsr237WorkScheduler scheduler = new Jsr237WorkScheduler(mgr); - Work work = createMock(Work.class); - scheduler.scheduleWork(work); - verify(mgr); - } - - @SuppressWarnings("unchecked") - public void testListener() throws Exception { - WorkItem item = createMock(WorkItem.class); - WorkManager mgr = createMock(WorkManager.class); - mgr.schedule(isA(Work.class), isA(WorkListener.class)); - expectLastCall().andReturn(item); - replay(mgr); - Jsr237WorkScheduler scheduler = new Jsr237WorkScheduler(mgr); - Work work = createMock(Work.class); - NotificationListener listener = createMock(NotificationListener.class); - scheduler.scheduleWork(work, listener); - verify(mgr); - } - - @SuppressWarnings("unchecked") - public void testWorkRejectedListener() throws Exception { - WorkManager mgr = createMock(WorkManager.class); - mgr.schedule(isA(Work.class), isA(WorkListener.class)); - expectLastCall().andThrow(new WorkRejectedException()); - replay(mgr); - Jsr237WorkScheduler scheduler = new Jsr237WorkScheduler(mgr); - Work work = createMock(Work.class); - NotificationListener listener = createMock(NotificationListener.class); - listener.workRejected(isA(Runnable.class)); - expectLastCall(); - replay(listener); - scheduler.scheduleWork(work, listener); - verify(mgr); - } - - @SuppressWarnings("unchecked") - public void testWorkRejectedNoListener() throws Exception { - WorkManager mgr = createMock(WorkManager.class); - mgr.schedule(isA(Work.class)); - expectLastCall().andThrow(new WorkRejectedException()); - replay(mgr); - Jsr237WorkScheduler scheduler = new Jsr237WorkScheduler(mgr); - Work work = createMock(Work.class); - try { - scheduler.scheduleWork(work); - fail(); - } catch (WorkSchedulerException e) { - // expected - } - verify(mgr); - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/services/work/jsr237/workmanager/ThreadPoolWorkManagerTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/services/work/jsr237/workmanager/ThreadPoolWorkManagerTestCase.java deleted file mode 100644 index 33ecd66fdc..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/services/work/jsr237/workmanager/ThreadPoolWorkManagerTestCase.java +++ /dev/null @@ -1,132 +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.work.jsr237.workmanager; - -import java.util.concurrent.CountDownLatch; - -import commonj.work.Work; -import commonj.work.WorkEvent; -import commonj.work.WorkListener; -import junit.framework.TestCase; -import static org.easymock.EasyMock.createMock; -import static org.easymock.EasyMock.createStrictMock; -import static org.easymock.EasyMock.expectLastCall; -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 ThreadPoolWorkManagerTestCase extends TestCase { - - public void testSchedule() throws Exception { - final CountDownLatch latch = new CountDownLatch(1); - Work work = createMock(Work.class); - work.run(); - expectLastCall().andStubAnswer(new IAnswer() { - public Object answer() throws Throwable { - latch.countDown(); - return null; - } - }); - replay(work); - ThreadPoolWorkManager mgr = new ThreadPoolWorkManager(1); - mgr.schedule(work); - latch.await(); - verify(work); - } - - public void testListener() throws Exception { - final CountDownLatch latch = new CountDownLatch(1); - WorkListener listener = createStrictMock(WorkListener.class); - listener.workAccepted(isA(WorkEvent.class)); - listener.workStarted(isA(WorkEvent.class)); - listener.workCompleted(isA(WorkEvent.class)); - expectLastCall(); - replay(listener); - Work work = createMock(Work.class); - work.run(); - expectLastCall().andStubAnswer(new IAnswer() { - public Object answer() throws Throwable { - latch.countDown(); - return null; - } - }); - replay(work); - ThreadPoolWorkManager mgr = new ThreadPoolWorkManager(1); - mgr.schedule(work, listener); - latch.await(); - verify(work); - } - - public void testDelayListener() throws Exception { - final CountDownLatch latch = new CountDownLatch(1); - final CountDownLatch latch2 = new CountDownLatch(1); - WorkListener listener = createStrictMock(WorkListener.class); - listener.workAccepted(isA(WorkEvent.class)); - listener.workStarted(isA(WorkEvent.class)); - listener.workCompleted(isA(WorkEvent.class)); - expectLastCall().andStubAnswer(new IAnswer() { - public Object answer() throws Throwable { - latch2.countDown(); - return null; - } - }); - replay(listener); - Work work = createMock(Work.class); - work.run(); - expectLastCall().andStubAnswer(new IAnswer() { - public Object answer() throws Throwable { - latch.await(); - return null; - } - }); - replay(work); - ThreadPoolWorkManager mgr = new ThreadPoolWorkManager(1); - mgr.schedule(work, listener); - latch.countDown(); - verify(work); - } - - public void testErrorListener() throws Exception { - final CountDownLatch latch = new CountDownLatch(1); - WorkListener listener = createStrictMock(WorkListener.class); - listener.workAccepted(isA(WorkEvent.class)); - listener.workStarted(isA(WorkEvent.class)); - listener.workCompleted(isA(WorkEvent.class)); - replay(listener); - Work work = createMock(Work.class); - work.run(); - expectLastCall().andStubAnswer(new IAnswer() { - public Object answer() throws Throwable { - latch.countDown(); - throw new RuntimeException(); - } - }); - replay(work); - ThreadPoolWorkManager mgr = new ThreadPoolWorkManager(1); - mgr.schedule(work, listener); - latch.await(); - verify(work); - } - -} - diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/util/Bean1.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/util/Bean1.java deleted file mode 100644 index 79fad549aa..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/util/Bean2.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/util/Bean2.java deleted file mode 100644 index 7f7f03da9e..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/util/JavaIntrospectionHelperTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/util/JavaIntrospectionHelperTestCase.java deleted file mode 100644 index 797b147b54..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/util/SuperBean.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/util/SuperBean.java deleted file mode 100644 index 83aef7fb5e..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/BasicReferenceInvocationHandlerTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/BasicReferenceInvocationHandlerTestCase.java deleted file mode 100644 index b62741a7e7..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/BasicReferenceInvocationHandlerTestCase.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 org.apache.tuscany.spi.idl.java.JavaInterfaceProcessorRegistry; -import org.apache.tuscany.spi.model.Operation; -import org.apache.tuscany.spi.model.ServiceContract; -import org.apache.tuscany.spi.wire.OutboundInvocationChain; -import org.apache.tuscany.spi.wire.OutboundWire; - -import junit.framework.TestCase; -import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl; -import org.apache.tuscany.core.mock.component.SimpleTarget; -import org.apache.tuscany.core.mock.component.SimpleTargetImpl; -import org.apache.tuscany.core.mock.wire.MockStaticInvoker; -import org.apache.tuscany.core.mock.wire.MockSyncInterceptor; -import org.apache.tuscany.core.wire.jdk.JDKOutboundInvocationHandler; - -/** - * @version $$Rev$$ $$Date$$ - */ -public class BasicReferenceInvocationHandlerTestCase extends TestCase { - - private Method echo; - - public void testInterceptorInvoke() throws Throwable { - JavaInterfaceProcessorRegistry registry = new JavaInterfaceProcessorRegistryImpl(); - ServiceContract contract = registry.introspect(SimpleTarget.class); - Operation operation = contract.getOperations().get("echo"); - MockStaticInvoker invoker = new MockStaticInvoker(echo, new SimpleTargetImpl()); - OutboundInvocationChain chain = new OutboundInvocationChainImpl(operation); - MockSyncInterceptor interceptor = new MockSyncInterceptor(); - chain.addInterceptor(interceptor); - chain.setTargetInterceptor(new InvokerInterceptor()); - chain.setTargetInvoker(invoker); - chain.prepare(); - //chains.put(echo, chain); - OutboundWire wire = new OutboundWireImpl(); - wire.addInvocationChain(operation, chain); - wire.setServiceContract(contract); - JDKOutboundInvocationHandler handler = new JDKOutboundInvocationHandler(SimpleTarget.class, wire, null); - assertEquals("foo", handler.invoke(null, echo, new String[]{"foo"})); - assertEquals(1, interceptor.getCount()); - } - - public void setUp() throws Exception { - super.setUp(); - echo = SimpleTarget.class.getMethod("echo", String.class); - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/CallbackInterfaceInterceptorTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/CallbackInterfaceInterceptorTestCase.java deleted file mode 100644 index 6c50cb406f..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/ContractCompatibilityTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/ContractCompatibilityTestCase.java deleted file mode 100644 index d200b983b3..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/ContractCompatibilityTestCase.java +++ /dev/null @@ -1,401 +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.AtomicComponent; -import org.apache.tuscany.spi.component.ReferenceBinding; -import org.apache.tuscany.spi.component.ServiceBinding; -import org.apache.tuscany.spi.model.ComponentDefinition; -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.model.ServiceDefinition; -import org.apache.tuscany.spi.wire.InboundInvocationChain; -import org.apache.tuscany.spi.wire.InboundWire; -import org.apache.tuscany.spi.wire.IncompatibleServiceContractException; -import org.apache.tuscany.spi.wire.OutboundChainHolder; -import org.apache.tuscany.spi.wire.OutboundInvocationChain; -import org.apache.tuscany.spi.wire.ProxyCreationException; -import org.apache.tuscany.spi.wire.Wire; -import org.apache.tuscany.spi.wire.WireInvocationHandler; -import org.apache.tuscany.spi.wire.WireService; - -import junit.framework.TestCase; - -/** - * TODO some tests commented out due to DataType.equals() needing to be strict - * - * @version $Rev$ $Date$ - */ -public class ContractCompatibilityTestCase extends TestCase { - - private WireService wireService = new MockWireService(); - - public void testNoOperation() throws Exception { - ServiceContract source = new MockContract("FooContract"); - ServiceContract target = new MockContract("FooContract"); - wireService.checkCompatibility(source, target, 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); - wireService.checkCompatibility(source, target, 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 { - wireService.checkCompatibility(source, target, 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); - wireService.checkCompatibility(source, target, 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 { - wireService.checkCompatibility(source, target, 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); - wireService.checkCompatibility(source, target, 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 { - wireService.checkCompatibility(source, target, 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); - wireService.checkCompatibility(source, target, 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); - wireService.checkCompatibility(source, target, 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 MockWireService extends WireServiceExtension { - public MockWireService() { - super(null, null); - } - - public T createProxy(Class interfaze, Wire wire) throws ProxyCreationException { - throw new UnsupportedOperationException(); - } - - public T createProxy(Class interfaze, Wire wire, Map mapping) - throws ProxyCreationException { - throw new UnsupportedOperationException(); - } - - public Object createCallbackProxy(Class interfaze, InboundWire wire) throws ProxyCreationException { - throw new UnsupportedOperationException(); - } - - - public WireInvocationHandler createHandler(Class interfaze, Wire wire) { - throw new UnsupportedOperationException(); - } - - public OutboundInvocationChain createOutboundChain(Operation operation) { - throw new UnsupportedOperationException(); - } - - public InboundInvocationChain createInboundChain(Operation operation) { - throw new UnsupportedOperationException(); - } - - public InboundWire createWire(ServiceDefinition service) { - throw new UnsupportedOperationException(); - } - - public void createWires(AtomicComponent component, ComponentDefinition definition) { - throw new UnsupportedOperationException(); - } - - public void createWires(ReferenceBinding referenceBinding, ServiceContract contract, - QualifiedName targetName) { - throw new UnsupportedOperationException(); - } - - public void createWires(ServiceBinding serviceBinding, ServiceContract contract, String targetName) { - throw new UnsupportedOperationException(); - } - - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/InboundInvocationErrorTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/InboundInvocationErrorTestCase.java deleted file mode 100644 index 39e1bf0b46..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/InboundInvocationErrorTestCase.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.wire; - -import java.lang.reflect.Method; -import java.lang.reflect.Proxy; -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.Map; - -import org.apache.tuscany.spi.component.WorkContext; -import org.apache.tuscany.spi.idl.InvalidServiceContractException; -import org.apache.tuscany.spi.idl.java.JavaInterfaceProcessorRegistry; -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.InboundInvocationChain; -import org.apache.tuscany.spi.wire.InboundWire; - -import junit.framework.TestCase; -import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl; -import org.apache.tuscany.core.mock.wire.MockStaticInvoker; -import org.apache.tuscany.core.mock.wire.MockSyncInterceptor; -import org.apache.tuscany.core.wire.jdk.JDKInboundInvocationHandler; -import org.easymock.classextension.EasyMock; - -/** - * Tests handling of exceptions thrown during an inbound wire invocation - * - * @version $Rev$ $Date$ - */ -public class InboundInvocationErrorTestCase extends TestCase { - private Method checkedMethod; - private Method runtimeMethod; - private Operation checkedOperation; - private Operation runtimeOperation; - - public InboundInvocationErrorTestCase() { - super(); - } - - public InboundInvocationErrorTestCase(String arg0) { - super(arg0); - } - - public void setUp() throws Exception { - super.setUp(); - checkedMethod = - TestBean.class.getDeclaredMethod("checkedException", (Class[]) null); - runtimeMethod = - TestBean.class.getDeclaredMethod("runtimeException", (Class[]) null); - assertNotNull(checkedMethod); - assertNotNull(runtimeMethod); - JavaInterfaceProcessorRegistry registry = new JavaInterfaceProcessorRegistryImpl(); - ServiceContract contract; - try { - contract = registry.introspect(TestBean.class); - } catch (InvalidServiceContractException e) { - throw new AssertionError(); - } - - checkedOperation = contract.getOperations().get("checkedException"); - runtimeOperation = contract.getOperations().get("runtimeException"); - } - - public void testCheckedException() throws Exception { - WorkContext workContext = EasyMock.createNiceMock(WorkContext.class); - EasyMock.replay(workContext); - - Operation operation = - new Operation("checkedException", null, null, null, false, null, NO_CONVERSATION); - Map, InboundInvocationChain> chains = new HashMap, InboundInvocationChain>(); - chains.put(operation, createChain(checkedMethod, checkedOperation)); - InboundWire wire = new InboundWireImpl(); - wire.addInvocationChains(chains); - wire.setServiceContract(new ServiceContract(TestBean.class) { - }); - - JDKInboundInvocationHandler handler = new JDKInboundInvocationHandler(TestBean.class, wire, workContext); - try { - ClassLoader ccl = Thread.currentThread().getContextClassLoader(); - TestBean proxy = (TestBean) Proxy.newProxyInstance(ccl, new Class[]{TestBean.class}, handler); - proxy.checkedException(); - } catch (InboundInvocationErrorTestCase.TestException e) { - return; - } - fail(InboundInvocationErrorTestCase.TestException.class.getName() + " should have been thrown"); - } - - public void testRuntimeException() throws Exception { - WorkContext workContext = EasyMock.createNiceMock(WorkContext.class); - EasyMock.replay(workContext); - - Operation operation = - new Operation("runtimeException", null, null, null, false, null, NO_CONVERSATION); - Map, InboundInvocationChain> chains = new HashMap, InboundInvocationChain>(); - chains.put(operation, createChain(runtimeMethod, runtimeOperation)); - InboundWire wire = new InboundWireImpl(); - wire.addInvocationChains(chains); - wire.setServiceContract(new ServiceContract(TestBean.class) { - }); - - JDKInboundInvocationHandler handler = new JDKInboundInvocationHandler(TestBean.class, wire, workContext); - try { - InboundInvocationErrorTestCase.TestBean proxy = (InboundInvocationErrorTestCase.TestBean) Proxy - .newProxyInstance(Thread.currentThread().getContextClassLoader(), - new Class[]{InboundInvocationErrorTestCase.TestBean.class}, handler); - proxy.runtimeException(); - } catch (InboundInvocationErrorTestCase.TestRuntimeException e) { - return; - } - fail(InboundInvocationErrorTestCase.TestException.class.getName() + " should have been thrown"); - } - - private InboundInvocationChain createChain(Method m, Operation operation) { - MockStaticInvoker invoker = new MockStaticInvoker(m, new TestBeanImpl()); - InboundInvocationChain chain = new InboundInvocationChainImpl(operation); - chain.addInterceptor(new MockSyncInterceptor()); - chain.setTargetInvoker(invoker); - chain.addInterceptor(new InvokerInterceptor()); - chain.prepare(); - return chain; - } - - public interface TestBean { - - void checkedException() throws TestException; - - void runtimeException() throws TestRuntimeException; - - } - - public class TestBeanImpl implements TestBean { - - public void checkedException() throws InboundInvocationErrorTestCase.TestException { - throw new TestException(); - } - - public void runtimeException() throws TestRuntimeException { - throw new TestRuntimeException(); - } - } - - public class TestException extends Exception { - } - - public class TestRuntimeException extends RuntimeException { - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/IncompatibleServiceContractExceptionFormatterTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/IncompatibleServiceContractExceptionFormatterTestCase.java deleted file mode 100644 index a9f455bc62..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/InvocationChainImplTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/InvocationChainImplTestCase.java deleted file mode 100644 index 294e98997f..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/InvocationChainImplTestCase.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.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 junit.framework.TestCase; - -/** - * @version $Rev$ $Date$ - */ -public class InvocationChainImplTestCase extends TestCase { - - public void testInsertAtPos() throws Exception { - MockChain chain = new MockChain(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 { - MockChain chain = new MockChain(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 MockChain extends InvocationChainImpl { - - public MockChain(Operation operation) { - super(operation); - } - - public void prepare() { - - } - } - - 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/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/InvocationConfigurationErrorTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/InvocationConfigurationErrorTestCase.java deleted file mode 100644 index aca68a0f25..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/InvocationConfigurationErrorTestCase.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.wire; - -import java.lang.reflect.Method; - -import org.apache.tuscany.spi.idl.java.JavaInterfaceProcessorRegistry; -import org.apache.tuscany.spi.model.Operation; -import org.apache.tuscany.spi.model.ServiceContract; -import org.apache.tuscany.spi.wire.InboundInvocationChain; -import org.apache.tuscany.spi.wire.Message; -import org.apache.tuscany.spi.wire.MessageImpl; -import org.apache.tuscany.spi.wire.OutboundInvocationChain; - -import junit.framework.TestCase; -import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl; -import org.apache.tuscany.core.mock.component.SimpleTarget; -import org.apache.tuscany.core.mock.component.SimpleTargetImpl; -import org.apache.tuscany.core.mock.wire.MockStaticInvoker; -import org.apache.tuscany.core.mock.wire.MockSyncInterceptor; - -/** - * Tests error propagation through an innvocation - * - * @version $Rev$ $Date$ - */ -public class InvocationConfigurationErrorTestCase extends TestCase { - - private ServiceContract contract; - private Method hello; - - public InvocationConfigurationErrorTestCase() { - super(); - } - - public InvocationConfigurationErrorTestCase(String arg0) { - super(arg0); - } - - public void setUp() throws Exception { - super.setUp(); - JavaInterfaceProcessorRegistry registry = new JavaInterfaceProcessorRegistryImpl(); - contract = registry.introspect(SimpleTarget.class); - hello = SimpleTarget.class.getMethod("hello", String.class); - } - - /** - * Tests basic wiring of a source to a target, including handlers and interceptors - */ - public void testInvokeWithInterceptors() throws Exception { - Operation operation = contract.getOperations().get("hello"); - OutboundInvocationChain source = new OutboundInvocationChainImpl(operation); - MockSyncInterceptor sourceInterceptor = new MockSyncInterceptor(); - source.addInterceptor(sourceInterceptor); - - InboundInvocationChain target = new InboundInvocationChainImpl(operation); - MockSyncInterceptor targetInterceptor = new MockSyncInterceptor(); - target.addInterceptor(targetInterceptor); - target.addInterceptor(new InvokerInterceptor()); - - // connect the source to the target - source.setTargetInterceptor(target.getHeadInterceptor()); - source.prepare(); - target.prepare(); - MockStaticInvoker invoker = new MockStaticInvoker(hello, new SimpleTargetImpl()); - source.setTargetInvoker(invoker); - - Message msg = new MessageImpl(); - msg.setTargetInvoker(invoker); - Message response = source.getHeadInterceptor().invoke(msg); - assertTrue(response.isFault()); - assertTrue(response.getBody() instanceof IllegalArgumentException); - assertEquals(1, sourceInterceptor.getCount()); - assertEquals(1, targetInterceptor.getCount()); - - } - -} - diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/InvocationConfigurationTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/InvocationConfigurationTestCase.java deleted file mode 100644 index 62df732a9e..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/InvocationConfigurationTestCase.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.wire; - -import java.lang.reflect.Method; - -import org.apache.tuscany.spi.idl.InvalidServiceContractException; -import org.apache.tuscany.spi.idl.java.JavaInterfaceProcessorRegistry; -import org.apache.tuscany.spi.model.Operation; -import org.apache.tuscany.spi.model.ServiceContract; -import org.apache.tuscany.spi.wire.InboundInvocationChain; -import org.apache.tuscany.spi.wire.Message; -import org.apache.tuscany.spi.wire.MessageImpl; -import org.apache.tuscany.spi.wire.OutboundInvocationChain; - -import junit.framework.TestCase; -import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl; -import org.apache.tuscany.core.mock.component.SimpleTarget; -import org.apache.tuscany.core.mock.component.SimpleTargetImpl; -import org.apache.tuscany.core.mock.wire.MockStaticInvoker; -import org.apache.tuscany.core.mock.wire.MockSyncInterceptor; - -public class InvocationConfigurationTestCase extends TestCase { - - private Method hello; - private Operation operation; - - - public InvocationConfigurationTestCase() { - super(); - } - - public InvocationConfigurationTestCase(String arg0) { - super(arg0); - } - - public void setUp() throws Exception { - super.setUp(); - JavaInterfaceProcessorRegistry registry = new JavaInterfaceProcessorRegistryImpl(); - ServiceContract contract; - try { - contract = registry.introspect(SimpleTarget.class); - } catch (InvalidServiceContractException e) { - throw new AssertionError(); - } - - operation = contract.getOperations().get("echo"); - hello = SimpleTarget.class.getMethod("hello", String.class); - } - - /** - * Tests basic wiring of a source to a target, including handlers and interceptors - */ - public void testInvokeWithInterceptors() throws Exception { - OutboundInvocationChain source = new OutboundInvocationChainImpl(operation); - MockSyncInterceptor sourceInterceptor = new MockSyncInterceptor(); - source.addInterceptor(sourceInterceptor); - - InboundInvocationChain target = new InboundInvocationChainImpl(operation); - MockSyncInterceptor targetInterceptor = new MockSyncInterceptor(); - target.addInterceptor(targetInterceptor); - target.addInterceptor(new InvokerInterceptor()); - - // connect the source to the target - source.setTargetInterceptor(target.getHeadInterceptor()); - source.prepare(); - target.prepare(); - MockStaticInvoker invoker = new MockStaticInvoker(hello, new SimpleTargetImpl()); - source.setTargetInvoker(invoker); - - Message msg = new MessageImpl(); - msg.setBody("foo"); - msg.setTargetInvoker(invoker); - Message response = source.getHeadInterceptor().invoke(msg); - assertEquals("foo", response.getBody()); - assertEquals(1, sourceInterceptor.getCount()); - assertEquals(1, targetInterceptor.getCount()); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/NonBlockingBridgingInterceptorTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/NonBlockingBridgingInterceptorTestCase.java deleted file mode 100644 index 1755fe9d15..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/NonBlockingBridgingInterceptorTestCase.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 NonBlockingBridgingInterceptorTestCase 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.setCurrentCorrelationId(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 NonBlockingBridgingInterceptor(scheduler, context, next); - interceptor.invoke(msg); - verify(context); - verify(next); - } - - public void testOptimizable() { - NonBlockingBridgingInterceptor interceptor = new NonBlockingBridgingInterceptor(null, null); - assertFalse(interceptor.isOptimizable()); - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/OptimizedWireObjectFactoryTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/OptimizedWireObjectFactoryTestCase.java deleted file mode 100644 index e0f094a83e..0000000000 --- a/branches/pre-spec-changes/kernel/core/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.OutboundWire; - -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(); - OutboundWire wire = EasyMock.createMock(OutboundWire.class); - EasyMock.expect(wire.getTargetService()).andReturn(foo); - EasyMock.replay(wire); - OptimizedWireObjectFactory factory = new OptimizedWireObjectFactory(wire); - assertEquals(foo, factory.getInstance()); - EasyMock.verify(wire); - } - - private class Foo { - - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/OutboundInvocationErrorTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/OutboundInvocationErrorTestCase.java deleted file mode 100644 index 42caa6eed7..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/OutboundInvocationErrorTestCase.java +++ /dev/null @@ -1,133 +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.Proxy; - -import org.apache.tuscany.spi.idl.java.JavaInterfaceProcessorRegistry; -import org.apache.tuscany.spi.model.Operation; -import org.apache.tuscany.spi.model.ServiceContract; -import org.apache.tuscany.spi.wire.OutboundInvocationChain; -import org.apache.tuscany.spi.wire.OutboundWire; - -import junit.framework.TestCase; -import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl; -import org.apache.tuscany.core.mock.wire.MockStaticInvoker; -import org.apache.tuscany.core.mock.wire.MockSyncInterceptor; -import org.apache.tuscany.core.wire.jdk.JDKOutboundInvocationHandler; - -/** - * Tests handling of exceptions thrown during an outbound wire invocation - * - * @version $Rev$ $Date$ - */ -public class OutboundInvocationErrorTestCase extends TestCase { - - private Method checkedMethod; - private Method runtimeMethod; - private JavaInterfaceProcessorRegistry registry = new JavaInterfaceProcessorRegistryImpl(); - - public OutboundInvocationErrorTestCase() { - super(); - } - - public OutboundInvocationErrorTestCase(String arg0) { - super(arg0); - } - - public void setUp() throws Exception { - super.setUp(); - checkedMethod = TestBean.class.getDeclaredMethod("checkedException", (Class[]) null); - runtimeMethod = TestBean.class.getDeclaredMethod("runtimeException", (Class[]) null); - assertNotNull(checkedMethod); - assertNotNull(runtimeMethod); - } - - public void testCheckedException() throws Exception { - OutboundWire wire = new OutboundWireImpl(); - ServiceContract contract = registry.introspect(TestBean.class); - wire.setServiceContract(contract); - Operation operation = contract.getOperations().get("checkedException"); - wire.addInvocationChain(operation, createChain(checkedMethod, operation)); - JDKOutboundInvocationHandler handler = new JDKOutboundInvocationHandler(TestBean.class, wire, null); - try { - TestBean proxy = (TestBean) Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), - new Class[]{TestBean.class}, handler); - proxy.checkedException(); - } catch (TestException e) { - return; - } - fail(TestException.class.getName() + " should have been thrown"); - } - - public void testRuntimeException() throws Exception { - OutboundWire wire = new OutboundWireImpl(); - ServiceContract contract = registry.introspect(TestBean.class); - wire.setServiceContract(contract); - Operation operation = contract.getOperations().get("runtimeException"); - OutboundInvocationChain chain = createChain(runtimeMethod, operation); - wire.addInvocationChain(operation, chain); - JDKOutboundInvocationHandler handler = new JDKOutboundInvocationHandler(TestBean.class, wire, null); - try { - TestBean proxy = (TestBean) Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), - new Class[]{TestBean.class}, handler); - proxy.runtimeException(); - } catch (TestRuntimeException e) { - return; - } - fail(TestException.class.getName() + " should have been thrown"); - } - - private OutboundInvocationChain createChain(Method m, Operation operation) { - MockStaticInvoker invoker = new MockStaticInvoker(m, new TestBeanImpl()); - OutboundInvocationChain chain = new OutboundInvocationChainImpl(operation); - chain.addInterceptor(new MockSyncInterceptor()); - chain.setTargetInvoker(invoker); - chain.setTargetInterceptor(new InvokerInterceptor()); - chain.prepare(); - return chain; - } - - public interface TestBean { - - void checkedException() throws TestException; - - void runtimeException() throws TestRuntimeException; - - } - - public class TestBeanImpl implements TestBean { - - public void checkedException() throws TestException { - throw new TestException(); - } - - public void runtimeException() throws TestRuntimeException { - throw new TestRuntimeException(); - } - } - - public class TestException extends Exception { - } - - public class TestRuntimeException extends RuntimeException { - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/OutboundInvocationHandlerTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/OutboundInvocationHandlerTestCase.java deleted file mode 100644 index 70d85445ed..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/OutboundInvocationHandlerTestCase.java +++ /dev/null @@ -1,132 +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 org.apache.tuscany.spi.idl.java.JavaIDLUtils; -import org.apache.tuscany.spi.idl.java.JavaInterfaceProcessorRegistry; -import org.apache.tuscany.spi.model.Operation; -import org.apache.tuscany.spi.model.ServiceContract; -import org.apache.tuscany.spi.wire.InboundInvocationChain; -import org.apache.tuscany.spi.wire.OutboundInvocationChain; -import org.apache.tuscany.spi.wire.OutboundWire; - -import junit.framework.TestCase; -import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl; -import org.apache.tuscany.core.mock.component.SimpleTarget; -import org.apache.tuscany.core.mock.component.SimpleTargetImpl; -import org.apache.tuscany.core.mock.wire.MockStaticInvoker; -import org.apache.tuscany.core.mock.wire.MockSyncInterceptor; -import org.apache.tuscany.core.wire.jdk.JDKOutboundInvocationHandler; - -public class OutboundInvocationHandlerTestCase extends TestCase { - - private Method hello; - private ServiceContract contract; - - public OutboundInvocationHandlerTestCase() { - super(); - } - - public OutboundInvocationHandlerTestCase(String arg0) { - super(arg0); - } - - public void setUp() throws Exception { - super.setUp(); - JavaInterfaceProcessorRegistry registry = new JavaInterfaceProcessorRegistryImpl(); - contract = registry.introspect(SimpleTarget.class); - hello = SimpleTarget.class.getMethod("hello", String.class); - } - - public void testBasicInvoke() throws Throwable { - OutboundWire wire = new OutboundWireImpl(); - Operation operation = contract.getOperations().get("hello"); - wire.addInvocationChain(operation, createChain(operation)); - wire.setServiceContract(contract); - JDKOutboundInvocationHandler handler = new JDKOutboundInvocationHandler(SimpleTarget.class, wire, null); - assertEquals("foo", handler.invoke(hello, new Object[]{"foo"})); - } - - public void testErrorInvoke() throws Throwable { - OutboundWire wire = new OutboundWireImpl(); - Operation operation = contract.getOperations().get("hello"); - wire.addInvocationChain(operation, createChain(operation)); - wire.setServiceContract(contract); - JDKOutboundInvocationHandler handler = new JDKOutboundInvocationHandler(SimpleTarget.class, wire, null); - try { - handler.invoke(hello, new Object[]{}); - fail("Expected " + IllegalArgumentException.class.getName()); - } catch (IllegalArgumentException e) { - // should throw - } - } - - public void testDirectErrorInvoke() throws Throwable { - Operation operation = contract.getOperations().get("hello"); - OutboundInvocationChain source = new OutboundInvocationChainImpl(operation); - MockStaticInvoker invoker = new MockStaticInvoker(hello, new SimpleTargetImpl()); - source.setTargetInvoker(invoker); - - OutboundWire wire = new OutboundWireImpl(); - wire.setServiceContract(contract); - wire.addInvocationChain(operation, source); - JDKOutboundInvocationHandler handler = new JDKOutboundInvocationHandler(SimpleTarget.class, wire, null); - try { - assertEquals("foo", handler.invoke(hello, new Object[]{})); - fail("Expected " + IllegalArgumentException.class.getName()); - } catch (IllegalArgumentException e) { - // should throw - } - } - - public void testDirectInvoke() throws Throwable { - Operation operation = contract.getOperations().get("hello"); - OutboundInvocationChain source = new OutboundInvocationChainImpl(operation); - MockStaticInvoker invoker = new MockStaticInvoker(hello, new SimpleTargetImpl()); - source.setTargetInvoker(invoker); - - OutboundWire wire = new OutboundWireImpl(); - wire.setServiceContract(contract); - wire.addInvocationChain(operation, source); - JDKOutboundInvocationHandler handler = new JDKOutboundInvocationHandler(SimpleTarget.class, wire, null); - assertEquals("foo", handler.invoke(hello, new Object[]{"foo"})); - } - - private OutboundInvocationChain createChain(Operation operation) { - OutboundInvocationChain source = new OutboundInvocationChainImpl(operation); - MockSyncInterceptor sourceInterceptor = new MockSyncInterceptor(); - source.addInterceptor(sourceInterceptor); - - InboundInvocationChain target = new InboundInvocationChainImpl(operation); - MockSyncInterceptor targetInterceptor = new MockSyncInterceptor(); - target.addInterceptor(targetInterceptor); - target.addInterceptor(new InvokerInterceptor()); - - // connect the source to the target - source.setTargetInterceptor(targetInterceptor); - source.prepare(); - target.prepare(); - Method method = JavaIDLUtils.findMethod(operation, SimpleTarget.class.getMethods()); - MockStaticInvoker invoker = new MockStaticInvoker(method, new SimpleTargetImpl()); - source.setTargetInvoker(invoker); - return source; - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/OutboundWireTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/OutboundWireTestCase.java deleted file mode 100644 index 9d0de99ed2..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/OutboundWireTestCase.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 org.apache.tuscany.spi.wire.OutboundWire; - -import junit.framework.TestCase; - -/** - * @version $Rev$ $Date$ - */ -public class OutboundWireTestCase extends TestCase { - - /** - * Tests that the target wire returns null if there is no connected wire. This behavior is needed for optional - * autowires. - */ - public void testGetNonExistentTargetService() throws Exception { - OutboundWire wire = new OutboundWireImpl(); - assertNull(wire.getTargetService()); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/SynchronousBridgingInterceptorTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/SynchronousBridgingInterceptorTestCase.java deleted file mode 100644 index f1631fc555..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/SynchronousBridgingInterceptorTestCase.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.Interceptor; -import org.apache.tuscany.spi.wire.Message; -import org.apache.tuscany.spi.wire.MessageImpl; - -import org.easymock.EasyMock; -import static org.easymock.EasyMock.verify; -import junit.framework.TestCase; - -/** - * @version $Rev$ $Date$ - */ -public class SynchronousBridgingInterceptorTestCase extends TestCase { - - public void testInvoke() throws Exception { - 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 SynchronousBridgingInterceptor(next); - interceptor.invoke(msg); - verify(next); - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/WireObjectFactoryTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/WireObjectFactoryTestCase.java deleted file mode 100644 index 537ca21656..0000000000 --- a/branches/pre-spec-changes/kernel/core/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.OutboundInvocationChain; -import org.apache.tuscany.spi.wire.OutboundWire; -import org.apache.tuscany.spi.wire.WireService; - -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); - OutboundInvocationChain chain = new OutboundInvocationChainImpl(op); - OutboundWire wire = EasyMock.createMock(OutboundWire.class); - Map, OutboundInvocationChain> chains = new HashMap, OutboundInvocationChain>(); - chains.put(op, chain); - EasyMock.expect(wire.getInvocationChains()).andReturn(chains); - EasyMock.expect(wire.isOptimizable()).andReturn(false); - EasyMock.replay(wire); - WireService service = EasyMock.createMock(WireService.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); - OutboundWire wire = EasyMock.createMock(OutboundWire.class); - EasyMock.expect(wire.isOptimizable()).andReturn(true); - EasyMock.expect(wire.getServiceContract()).andReturn(contract).atLeastOnce(); - EasyMock.expect(wire.getInvocationChains()).andReturn((Map) Collections.emptyMap()); - EasyMock.expect(wire.getTargetService()).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); - OutboundWire wire = EasyMock.createMock(OutboundWire.class); - EasyMock.expect(wire.isOptimizable()).andReturn(true); - EasyMock.expect(wire.getServiceContract()).andReturn(contract).atLeastOnce(); - EasyMock.expect(wire.getInvocationChains()).andReturn((Map) Collections.emptyMap()); - EasyMock.replay(wire); - WireService service = EasyMock.createMock(WireService.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(); - OutboundWire wire = EasyMock.createMock(OutboundWire.class); - EasyMock.expect(wire.isOptimizable()).andReturn(true); - EasyMock.expect(wire.getServiceContract()).andReturn(contract).atLeastOnce(); - EasyMock.expect(wire.getInvocationChains()).andReturn((Map) Collections.emptyMap()); - EasyMock.replay(wire); - WireService service = EasyMock.createMock(WireService.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/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/WireOptimizationTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/WireOptimizationTestCase.java deleted file mode 100644 index c0d40c6369..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/WireOptimizationTestCase.java +++ /dev/null @@ -1,154 +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.component.Component; -import org.apache.tuscany.spi.model.Operation; -import static org.apache.tuscany.spi.model.Operation.NO_CONVERSATION; -import org.apache.tuscany.spi.wire.InboundInvocationChain; -import org.apache.tuscany.spi.wire.InboundWire; -import org.apache.tuscany.spi.wire.Interceptor; -import org.apache.tuscany.spi.wire.Message; -import org.apache.tuscany.spi.wire.OutboundInvocationChain; -import org.apache.tuscany.spi.wire.OutboundWire; - -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 testSourceWireInterceptorOptimization() throws Exception { - AtomicComponent component = EasyMock.createNiceMock(AtomicComponent.class); - EasyMock.replay(component); - OutboundWire wire = new OutboundWireImpl(); - wire.setContainer(component); - OutboundInvocationChain chain = new OutboundInvocationChainImpl(operation); - chain.addInterceptor(new OptimizableInterceptor()); - wire.addInvocationChain(operation, chain); - assertTrue(WireUtils.isOptimizable(wire)); - } - - public void testSourceWireNonInterceptorOptimization() throws Exception { - AtomicComponent component = EasyMock.createNiceMock(AtomicComponent.class); - EasyMock.replay(component); - OutboundWire wire = new OutboundWireImpl(); - wire.setContainer(component); - OutboundInvocationChain chain = new OutboundInvocationChainImpl(operation); - chain.addInterceptor(new NonOptimizableInterceptor()); - wire.addInvocationChain(operation, chain); - assertFalse(WireUtils.isOptimizable(wire)); - } - - public void testTargetWireInterceptorOptimization() throws Exception { - AtomicComponent component = EasyMock.createNiceMock(AtomicComponent.class); - EasyMock.expect(component.isOptimizable()).andReturn(true); - EasyMock.replay(component); - InboundWire wire = new InboundWireImpl(); - wire.setContainer(component); - InboundInvocationChain chain = new InboundInvocationChainImpl(operation); - chain.addInterceptor(new OptimizableInterceptor()); - wire.addInvocationChain(operation, chain); - assertTrue(WireUtils.isOptimizable(wire)); - - } - - public void testTargetWireNoOptimizationNonAtomicContainer() throws Exception { - Component component = EasyMock.createNiceMock(Component.class); - EasyMock.expect(component.isOptimizable()).andReturn(true); - EasyMock.replay(component); - InboundWire wire = new InboundWireImpl(); - wire.setContainer(component); - InboundInvocationChain chain = new InboundInvocationChainImpl(operation); - chain.addInterceptor(new OptimizableInterceptor()); - wire.addInvocationChain(operation, chain); - assertTrue(WireUtils.isOptimizable(wire)); - } - - public void testTargetWireNonInterceptorOptimization() throws Exception { - AtomicComponent component = EasyMock.createNiceMock(AtomicComponent.class); - EasyMock.replay(component); - InboundWire wire = new InboundWireImpl(); - wire.setContainer(component); - InboundInvocationChain chain = new InboundInvocationChainImpl(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/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/WireServiceExtensionTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/WireServiceExtensionTestCase.java deleted file mode 100644 index 32c4fffe56..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/WireServiceExtensionTestCase.java +++ /dev/null @@ -1,307 +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.net.URI; -import java.util.HashMap; -import java.util.Map; - -import javax.xml.namespace.QName; - -import org.apache.tuscany.spi.QualifiedName; -import org.apache.tuscany.spi.component.AbstractSCAObject; -import org.apache.tuscany.spi.component.AtomicComponent; -import org.apache.tuscany.spi.component.Reference; -import org.apache.tuscany.spi.component.ReferenceBinding; -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.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.InboundInvocationChain; -import org.apache.tuscany.spi.wire.InboundWire; -import org.apache.tuscany.spi.wire.Message; -import org.apache.tuscany.spi.wire.MessageImpl; -import org.apache.tuscany.spi.wire.OutboundChainHolder; -import org.apache.tuscany.spi.wire.OutboundInvocationChain; -import org.apache.tuscany.spi.wire.OutboundWire; -import org.apache.tuscany.spi.wire.ProxyCreationException; -import org.apache.tuscany.spi.wire.TargetInvoker; -import org.apache.tuscany.spi.wire.Wire; -import org.apache.tuscany.spi.wire.WireInvocationHandler; - -import junit.framework.TestCase; -import org.apache.tuscany.core.component.WorkContextImpl; -import org.apache.tuscany.core.mock.binding.MockServiceBinding; -import org.easymock.EasyMock; - -/** - * @version $Rev$ $Date$ - */ -public class WireServiceExtensionTestCase extends TestCase { - private TestWireService wireService; - private Operation operation; - private ServiceContract contract; - private Operation callbackOperation; - - public void testCreateInboundChain() throws Exception { - InboundInvocationChain chain = wireService.createInboundChain(operation); - assertEquals(operation, chain.getOperation()); - } - - public void testCreateOutboundChain() throws Exception { - OutboundInvocationChain chain = wireService.createOutboundChain(operation); - assertEquals(operation, chain.getOperation()); - } - - public void testCreateServiceWire() throws Exception { - ServiceDefinition definition = new ServiceDefinition("foo", contract, false); - TargetInvoker invoker = EasyMock.createMock(TargetInvoker.class); - MessageImpl resp = new MessageImpl(); - EasyMock.expect(invoker.invoke(EasyMock.isA(Message.class))).andReturn(resp); - EasyMock.replay(invoker); - InboundWire wire = wireService.createWire(definition); - assertEquals("foo", wire.getServiceName()); - assertEquals(1, wire.getInvocationChains().size()); - assertEquals(contract, wire.getServiceContract()); - InboundInvocationChain chain = wire.getInvocationChains().get(operation); - assertEquals(operation, chain.getOperation()); - // verify the chain is invokable - MessageImpl msg = new MessageImpl(); - msg.setTargetInvoker(invoker); - assertNotNull(chain.getHeadInterceptor().invoke(msg)); - EasyMock.verify(invoker); - } - - public void testCreateReferenceWire() throws Exception { - ReferenceDefinition definition = new ReferenceDefinition("foo", contract); - ReferenceTarget target = new ReferenceTarget(); - target.addTarget(new URI("bar")); - target.setReferenceName("refName"); - - OutboundWire wire = wireService.createWire(target, definition); - assertEquals("refName", wire.getReferenceName()); - assertEquals("bar", wire.getTargetName().toString()); - assertFalse(wire.isAutowire()); - assertEquals(1, wire.getInvocationChains().size()); - assertEquals(contract, wire.getServiceContract()); - OutboundInvocationChain chain = wire.getInvocationChains().get(operation); - assertEquals(operation, chain.getOperation()); - assertNull(chain.getHeadInterceptor()); - assertEquals(Callback.class, wire.getCallbackInterface()); - assertEquals(1, wire.getTargetCallbackInvocationChains().size()); - InboundInvocationChain callbackChain = wire.getTargetCallbackInvocationChains().get(callbackOperation); - assertEquals(callbackOperation, callbackChain.getOperation()); - - TargetInvoker invoker = EasyMock.createMock(TargetInvoker.class); - MessageImpl resp = new MessageImpl(); - EasyMock.expect(invoker.invoke(EasyMock.isA(Message.class))).andReturn(resp); - EasyMock.replay(invoker); - // verify the callback chain is invokable - MessageImpl msg = new MessageImpl(); - msg.setTargetInvoker(invoker); - assertNotNull(callbackChain.getHeadInterceptor().invoke(msg)); - EasyMock.verify(invoker); - } - - public void testCreateAutowireReferenceWire() throws Exception { - ReferenceDefinition definition = new ReferenceDefinition("foo", contract); - definition.setAutowire(true); - ReferenceTarget target = new ReferenceTarget(); - target.setReferenceName("refName"); - OutboundWire wire = wireService.createWire(target, definition); - assertTrue(wire.isAutowire()); - assertEquals("refName", wire.getReferenceName()); - assertEquals(contract, wire.getServiceContract()); - assertEquals(Callback.class, wire.getCallbackInterface()); - } - - public void testCreateComponentWires() throws Exception { - ComponentType> type = - new ComponentType>(); - ReferenceDefinition referenceDefinition = new ReferenceDefinition("refName", contract); - type.add(referenceDefinition); - ServiceDefinition serviceDefinition = new ServiceDefinition("foo", contract, false); - type.add(serviceDefinition); - - Implementation impl = new Implementation() { - }; - impl.setComponentType(type); - - ComponentDefinition> definition = - new ComponentDefinition>("Foo", impl); - ReferenceTarget target = new ReferenceTarget(); - target.addTarget(new URI("bar")); - target.setReferenceName("refName"); - definition.add(target); - - AtomicComponent component = EasyMock.createMock(AtomicComponent.class); - component.addInboundWire(EasyMock.isA(InboundWire.class)); - component.addOutboundWire(EasyMock.isA(OutboundWire.class)); - EasyMock.replay(component); - - wireService.createWires(component, definition); - EasyMock.verify(component); - } - - public void testCreateReferenceBindingWire() throws Exception { - ReferenceBinding binding = new MockReferenceBinding(); - QualifiedName qName = new QualifiedName("target"); - - wireService.createWires(binding, contract, qName); - - InboundWire inboundWire = binding.getInboundWire(); - assertEquals(1, inboundWire.getInvocationChains().size()); - assertEquals(contract, inboundWire.getServiceContract()); - assertEquals(binding, inboundWire.getContainer()); - - OutboundWire outboundWire = binding.getOutboundWire(); - assertEquals("target", outboundWire.getTargetName().toString()); - assertEquals(1, outboundWire.getInvocationChains().size()); - assertEquals(contract, outboundWire.getServiceContract()); - assertEquals(binding, outboundWire.getContainer()); - } - - public void testCreateServiceBindingWire() throws Exception { - ServiceBinding binding = new MockServiceBinding(); - - wireService.createWires(binding, contract, "target"); - - InboundWire inboundWire = binding.getInboundWire(); - assertEquals(1, inboundWire.getInvocationChains().size()); - assertEquals(contract, inboundWire.getServiceContract()); - assertEquals(binding, inboundWire.getContainer()); - - OutboundWire outboundWire = binding.getOutboundWire(); - assertEquals("target", outboundWire.getTargetName().toString()); - assertEquals(1, outboundWire.getInvocationChains().size()); - assertEquals(contract, outboundWire.getServiceContract()); - assertEquals(binding, outboundWire.getContainer()); - assertEquals(1, outboundWire.getTargetCallbackInvocationChains().size()); - } - - protected void setUp() throws Exception { - super.setUp(); - wireService = new TestWireService(new WorkContextImpl()); - - operation = new Operation("foo", null, null, null); - callbackOperation = new Operation("foo", null, null, null); - Map> operations = new HashMap>(); - operations.put("foo", operation); - Map> callbackOperations = new HashMap>(); - callbackOperations.put("foo", callbackOperation); - contract = new ServiceContract() { - }; - contract.setOperations(operations); - contract.setCallbackClass(Callback.class); - contract.setCallbackName(Callback.class.getName()); - contract.setCallbackOperations(callbackOperations); - } - - private interface Callback { - - } - - private class TestWireService extends WireServiceExtension { - protected TestWireService(WorkContext context) { - super(context, null); - } - - public T createProxy(Class interfaze, Wire wire) throws ProxyCreationException { - return null; - } - - public T createProxy(Class interfaze, Wire wire, Map mapping) - throws ProxyCreationException { - return null; - } - - public Object createCallbackProxy(Class interfaze, InboundWire wire) throws ProxyCreationException { - return null; - } - - public WireInvocationHandler createHandler(Class interfaze, Wire wire) { - return null; - } - - - public OutboundWire createWire(ReferenceTarget reference, ReferenceDefinition def) { - return super.createWire(reference, def); - } - } - - private class MockReferenceBinding extends AbstractSCAObject implements ReferenceBinding { - private ServiceContract bindingServiceContract; - private InboundWire inboundWire; - private OutboundWire outboundWire; - - public MockReferenceBinding() { - super("foo", null); - } - - public ServiceContract getBindingServiceContract() { - return bindingServiceContract; - } - - public QName getBindingType() { - return null; - } - - public void setReference(Reference reference) { - - } - - public InboundWire getInboundWire() { - return inboundWire; - } - - public void setInboundWire(InboundWire inboundWire) { - this.inboundWire = inboundWire; - } - - public OutboundWire getOutboundWire() { - return outboundWire; - } - - public void setOutboundWire(OutboundWire outboundWire) { - this.outboundWire = outboundWire; - } - - public TargetInvoker createTargetInvoker(ServiceContract contract, Operation operation) - throws TargetInvokerCreationException { - return null; - } - - public Scope getScope() { - return null; - } - } - - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/WireUtilsTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/WireUtilsTestCase.java deleted file mode 100644 index 331c0760d9..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/WireUtilsTestCase.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.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.InboundInvocationChain; -import org.apache.tuscany.spi.wire.InboundWire; -import org.apache.tuscany.spi.wire.OutboundChainHolder; -import org.apache.tuscany.spi.wire.OutboundInvocationChain; -import org.apache.tuscany.spi.wire.OutboundWire; - -import junit.framework.TestCase; - -/** - * @version $Rev$ $Date$ - */ -public class WireUtilsTestCase extends TestCase { - private Method m; - - public void testCreateInterfaceToWireMapping() throws Exception { - OutboundWire wire = new OutboundWireImpl(); - Operation op = new Operation("hello", null, null, null); - OutboundInvocationChain chain = new OutboundInvocationChainImpl(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 { - OutboundWire wire = new OutboundWireImpl(); - Operation op = new Operation("goodbye", null, null, null); - OutboundInvocationChain chain = new OutboundInvocationChainImpl(op); - wire.addInvocationChain(op, chain); - try { - WireUtils.createInterfaceToWireMapping(Foo.class, wire); - fail(); - } catch (NoMethodForOperationException e) { - // expected - } - } - - public void testCreateInboundMapping() throws Exception { - InboundWire wire = new InboundWireImpl(); - Operation op = new Operation("hello", null, null, null); - InboundInvocationChain chain = new InboundInvocationChainImpl(op); - wire.addInvocationChain(op, chain); - Map chains = WireUtils.createInboundMapping(wire, new Method[]{m}); - assertEquals(1, chains.size()); - assertNotNull(chains.get(m)); - } - - public void testCreateInboundMappingNoOperation() throws Exception { - InboundWire wire = new InboundWireImpl(); - Operation op = new Operation("goodbye", null, null, null); - InboundInvocationChain chain = new InboundInvocationChainImpl(op); - wire.addInvocationChain(op, chain); - try { - WireUtils.createInboundMapping(wire, new Method[]{m}); - 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/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/jdk/JDKCallbackInvocationHandlerSerializationTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/jdk/JDKCallbackInvocationHandlerSerializationTestCase.java deleted file mode 100644 index df4dc63ea4..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/jdk/JDKCallbackInvocationHandlerSerializationTestCase.java +++ /dev/null @@ -1,54 +0,0 @@ -package org.apache.tuscany.core.wire.jdk; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; - -import org.apache.tuscany.spi.component.AtomicComponent; -import org.apache.tuscany.spi.component.SCAExternalizable; -import org.apache.tuscany.spi.component.WorkContext; -import org.apache.tuscany.spi.wire.InboundWire; - -import junit.framework.TestCase; -import org.apache.tuscany.core.component.WorkContextImpl; -import org.easymock.EasyMock; - -/** - * @version $Rev$ $Date$ - */ -public class JDKCallbackInvocationHandlerSerializationTestCase extends TestCase { - private InboundWire wire; - private WorkContext workContext; - - public void testSerializeDeserialize() throws Exception { - JDKCallbackInvocationHandler handler = new JDKCallbackInvocationHandler(wire, workContext); - ByteArrayOutputStream stream = new ByteArrayOutputStream(); - ObjectOutputStream ostream = new ObjectOutputStream(stream); - ostream.writeObject(handler); - - ObjectInputStream istream = new ObjectInputStream(new ByteArrayInputStream(stream.toByteArray())); - SCAExternalizable externalizable = (SCAExternalizable) istream.readObject(); - - externalizable.setWorkContext(workContext); - externalizable.reactivate(); - EasyMock.verify(wire); - } - - protected void setUp() throws Exception { - super.setUp(); - wire = EasyMock.createMock(InboundWire.class); - EasyMock.expect(wire.getServiceName()).andReturn("foo").atLeastOnce(); - EasyMock.replay(wire); - AtomicComponent component = EasyMock.createMock(AtomicComponent.class); - EasyMock.expect(component.getInboundWire(EasyMock.eq("foo"))).andReturn(wire); - EasyMock.replay(component); - workContext = new WorkContextImpl(); - workContext.setCurrentAtomicComponent(component); - } - - protected void tearDown() throws Exception { - super.tearDown(); - workContext.setCurrentAtomicComponent(null); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/jdk/JDKCallbackInvocationHandlerTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/jdk/JDKCallbackInvocationHandlerTestCase.java deleted file mode 100644 index b8cbde687d..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/jdk/JDKCallbackInvocationHandlerTestCase.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.wire.jdk; - -import java.lang.reflect.Proxy; - -import org.apache.tuscany.spi.idl.java.JavaServiceContract; - -import junit.framework.TestCase; - -import org.apache.tuscany.core.component.WorkContextImpl; -import org.apache.tuscany.core.wire.InboundWireImpl; - -/** - * @version $Rev$ $Date$ - */ -public class JDKCallbackInvocationHandlerTestCase extends TestCase { - - public void testToString() { - InboundWireImpl wire = new InboundWireImpl(); - wire.setServiceContract(new JavaServiceContract(Foo.class)); - JDKCallbackInvocationHandler handler = new JDKCallbackInvocationHandler(wire, new WorkContextImpl()); - Foo foo = (Foo) Proxy.newProxyInstance(getClass().getClassLoader(), new Class[]{Foo.class}, handler); - assertNotNull(foo.toString()); - } - - public void testHashCode() { - InboundWireImpl wire = new InboundWireImpl(); - wire.setServiceContract(new JavaServiceContract(Foo.class)); - JDKCallbackInvocationHandler handler = new JDKCallbackInvocationHandler(wire, new WorkContextImpl()); - Foo foo = (Foo) Proxy.newProxyInstance(getClass().getClassLoader(), new Class[]{Foo.class}, handler); - assertNotNull(foo.hashCode()); - } - - private interface Foo { - - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/jdk/JDKInboundInvocationHandlerSerializationTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/jdk/JDKInboundInvocationHandlerSerializationTestCase.java deleted file mode 100644 index a631982958..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/jdk/JDKInboundInvocationHandlerSerializationTestCase.java +++ /dev/null @@ -1,110 +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.jdk; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.util.HashMap; -import java.util.Map; - -import org.apache.tuscany.spi.component.AtomicComponent; -import org.apache.tuscany.spi.component.WorkContext; -import org.apache.tuscany.spi.model.Operation; -import static org.apache.tuscany.spi.model.Operation.NO_CONVERSATION; -import org.apache.tuscany.spi.wire.InboundInvocationChain; -import org.apache.tuscany.spi.wire.InboundWire; -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.component.WorkContextImpl; -import org.apache.tuscany.core.wire.InboundInvocationChainImpl; -import org.apache.tuscany.core.wire.InvokerInterceptor; -import org.easymock.EasyMock; - -/** - * @version $Rev$ $Date$ - */ -public class JDKInboundInvocationHandlerSerializationTestCase extends TestCase { - private InboundWire wire; - private WorkContext workContext; - private TargetInvoker invoker; - - public void testSerializeDeserialize() throws Throwable { - JDKInboundInvocationHandler handler = new JDKInboundInvocationHandler(Foo.class, wire, workContext); - handler.invoke(Foo.class.getMethod("invoke"), null); - - ByteArrayOutputStream stream = new ByteArrayOutputStream(); - ObjectOutputStream ostream = new ObjectOutputStream(stream); - ostream.writeObject(handler); - - ObjectInputStream istream = new ObjectInputStream(new ByteArrayInputStream(stream.toByteArray())); - JDKInboundInvocationHandler externalizable = (JDKInboundInvocationHandler) istream.readObject(); - - externalizable.setWorkContext(workContext); - externalizable.reactivate(); - externalizable.invoke(Foo.class.getMethod("invoke"), null); - EasyMock.verify(wire); - EasyMock.verify(invoker); - } - - protected void setUp() throws Exception { - super.setUp(); - wire = EasyMock.createMock(InboundWire.class); - Map, InboundInvocationChain> map = new HashMap, InboundInvocationChain>(); - Operation operation = new Operation("invoke", null, null, null, false, null, NO_CONVERSATION); - map.put(operation, createChain(operation)); - - EasyMock.expect(wire.getServiceName()).andReturn("foo").atLeastOnce(); - EasyMock.expect(wire.getInvocationChains()).andReturn(map).times(2); - EasyMock.replay(wire); - AtomicComponent component = EasyMock.createMock(AtomicComponent.class); - EasyMock.expect(component.getInboundWire(EasyMock.eq("foo"))).andReturn(wire); - EasyMock.replay(component); - workContext = new WorkContextImpl(); - workContext.setCurrentAtomicComponent(component); - } - - protected void tearDown() throws Exception { - super.tearDown(); - workContext.setCurrentAtomicComponent(null); - } - - private InboundInvocationChain createChain(Operation operation) { - invoker = EasyMock.createMock(TargetInvoker.class); - EasyMock.expect(invoker.invoke(EasyMock.isA(Message.class))).andReturn(new MessageImpl()).times(2); - EasyMock.expect(invoker.isCacheable()).andReturn(false).atLeastOnce(); - EasyMock.replay(invoker); - InboundInvocationChain chain = new InboundInvocationChainImpl(operation); - chain.setTargetInvoker(invoker); - chain.addInterceptor(new InvokerInterceptor()); - chain.prepare(); - return chain; - } - - public class Foo { - public void invoke() { - } - } - - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/jdk/JDKInboundInvocationHandlerTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/jdk/JDKInboundInvocationHandlerTestCase.java deleted file mode 100644 index 1a4238c589..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/jdk/JDKInboundInvocationHandlerTestCase.java +++ /dev/null @@ -1,162 +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.jdk; - -import java.lang.reflect.Method; -import java.lang.reflect.Proxy; -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.component.WorkContext; -import org.apache.tuscany.spi.idl.InvalidServiceContractException; -import org.apache.tuscany.spi.idl.java.JavaInterfaceProcessorRegistry; -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.InboundInvocationChain; -import org.apache.tuscany.spi.wire.InboundWire; - -import junit.framework.TestCase; -import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl; -import org.apache.tuscany.core.mock.component.SimpleTarget; -import org.apache.tuscany.core.mock.component.SimpleTargetImpl; -import org.apache.tuscany.core.mock.wire.MockStaticInvoker; -import org.apache.tuscany.core.mock.wire.MockSyncInterceptor; -import org.apache.tuscany.core.wire.InboundInvocationChainImpl; -import org.apache.tuscany.core.wire.InboundWireImpl; -import org.apache.tuscany.core.wire.InvokerInterceptor; -import org.easymock.classextension.EasyMock; - -/** - * Verifies invocations on inbound wires - * - * @version $$Rev$$ $$Date$$ - */ -public class JDKInboundInvocationHandlerTestCase extends TestCase { - - private Method echo; - private Operation operation; - - public void testInterceptorInvoke() throws Throwable { - MockStaticInvoker invoker = new MockStaticInvoker(echo, new SimpleTargetImpl()); - InboundInvocationChain chain = new InboundInvocationChainImpl(operation); - MockSyncInterceptor interceptor = new MockSyncInterceptor(); - chain.addInterceptor(interceptor); - chain.addInterceptor(new InvokerInterceptor()); - chain.setTargetInvoker(invoker); - chain.prepare(); - InboundWire wire = createWire(chain); - - WorkContext workContext = EasyMock.createNiceMock(WorkContext.class); - EasyMock.replay(workContext); - JDKInboundInvocationHandler handler = new JDKInboundInvocationHandler(SimpleTarget.class, wire, workContext); - assertEquals("foo", handler.invoke(echo, new String[]{"foo"})); - assertEquals(1, interceptor.getCount()); - } - - public void testDirectErrorInvoke() throws Throwable { - InboundInvocationChain source = new InboundInvocationChainImpl(operation); - MockStaticInvoker invoker = new MockStaticInvoker(echo, new SimpleTargetImpl()); - source.setTargetInvoker(invoker); - InboundWire wire = createWire(source); - - WorkContext workContext = EasyMock.createNiceMock(WorkContext.class); - EasyMock.replay(workContext); - JDKInboundInvocationHandler handler = new JDKInboundInvocationHandler(SimpleTarget.class, wire, workContext); - try { - assertEquals("foo", handler.invoke(echo, new Object[]{})); - fail("Expected " + IllegalArgumentException.class.getName()); - } catch (IllegalArgumentException e) { - // should throw - } - } - - public void testDirectInvoke() throws Throwable { - InboundInvocationChain source = new InboundInvocationChainImpl(operation); - MockStaticInvoker invoker = new MockStaticInvoker(echo, new SimpleTargetImpl()); - source.setTargetInvoker(invoker); - InboundWire wire = createWire(source); - - WorkContext workContext = EasyMock.createNiceMock(WorkContext.class); - EasyMock.replay(workContext); - JDKInboundInvocationHandler handler = new JDKInboundInvocationHandler(SimpleTarget.class, wire, workContext); - assertEquals("foo", handler.invoke(echo, new Object[]{"foo"})); - } - - public void testToString() { - WorkContext workContext = EasyMock.createNiceMock(WorkContext.class); - EasyMock.replay(workContext); - InboundWireImpl wire = new InboundWireImpl(); - wire.setServiceContract(new ServiceContract(Foo.class) { - }); - JDKInboundInvocationHandler handler = new JDKInboundInvocationHandler(SimpleTarget.class, wire, workContext); - Foo foo = (Foo) Proxy.newProxyInstance(getClass().getClassLoader(), new Class[]{Foo.class}, handler); - assertNotNull(foo.toString()); - } - - public void testHashCode() { - WorkContext workContext = EasyMock.createNiceMock(WorkContext.class); - EasyMock.replay(workContext); - InboundWireImpl wire = new InboundWireImpl(); - wire.setServiceContract(new ServiceContract(Foo.class) { - }); - JDKInboundInvocationHandler handler = new JDKInboundInvocationHandler(SimpleTarget.class, wire, workContext); - Foo foo = (Foo) Proxy.newProxyInstance(getClass().getClassLoader(), new Class[]{Foo.class}, handler); - assertNotNull(foo.hashCode()); - } - - public void setUp() throws Exception { - super.setUp(); - JavaInterfaceProcessorRegistry registry = new JavaInterfaceProcessorRegistryImpl(); - ServiceContract contract; - try { - contract = registry.introspect(SimpleTarget.class); - } catch (InvalidServiceContractException e) { - throw new AssertionError(); - } - operation = contract.getOperations().get("echo"); - echo = SimpleTarget.class.getMethod("echo", String.class); - } - - - private InboundWire createWire(InboundInvocationChain chain) { - DataType type = new DataType(String.class, String.class); - List> types = new ArrayList>(); - types.add(type); - DataType>> inputType = - new DataType>>(Object[].class, types); - Operation operation = new Operation("echo", inputType, null, null, false, null, NO_CONVERSATION); - Map, InboundInvocationChain> chains = new HashMap, InboundInvocationChain>(); - chains.put(operation, chain); - InboundWire wire = new InboundWireImpl(); - wire.addInvocationChains(chains); - wire.setServiceContract(new ServiceContract(SimpleTarget.class) { - }); - return wire; - } - - private interface Foo { - - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/jdk/JDKOutboundInvocationHandlerProxyTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/jdk/JDKOutboundInvocationHandlerProxyTestCase.java deleted file mode 100644 index 39d8113584..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/jdk/JDKOutboundInvocationHandlerProxyTestCase.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.wire.jdk; - -import java.lang.reflect.Method; - -import org.apache.tuscany.spi.idl.java.JavaInterfaceProcessorRegistry; -import org.apache.tuscany.spi.idl.java.JavaServiceContract; -import org.apache.tuscany.spi.model.Operation; -import org.apache.tuscany.spi.wire.MessageImpl; -import org.apache.tuscany.spi.wire.OutboundInvocationChain; -import org.apache.tuscany.spi.wire.OutboundWire; -import org.apache.tuscany.spi.wire.TargetInvoker; - -import junit.framework.TestCase; -import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl; -import org.apache.tuscany.core.wire.OutboundInvocationChainImpl; -import org.apache.tuscany.core.wire.OutboundWireImpl; -import org.easymock.EasyMock; - -/** - * @version $Rev$ $Date$ - */ -public class JDKOutboundInvocationHandlerProxyTestCase extends TestCase { - - private JavaInterfaceProcessorRegistry registry = new JavaInterfaceProcessorRegistryImpl(); - private OutboundWire wire; - private Method clientHello; - private TargetInvoker targetInvoker; - - public void testDifferentInterface() throws Throwable { - JDKOutboundInvocationHandler handler = new JDKOutboundInvocationHandler(Client.class, wire, null); - handler.invoke(null, clientHello, null); - EasyMock.verify(targetInvoker); - } - - protected void setUp() throws Exception { - super.setUp(); - wire = new OutboundWireImpl(); - JavaServiceContract contract = registry.introspect(Target.class); - for (Operation operation : contract.getOperations().values()) { - OutboundInvocationChain chain = new OutboundInvocationChainImpl(operation); - wire.addInvocationChain(operation, chain); - targetInvoker = EasyMock.createMock(TargetInvoker.class); - EasyMock.expect(targetInvoker.invokeTarget(EasyMock.isNull(), EasyMock.eq(TargetInvoker.NONE))) - .andReturn(new MessageImpl()); - EasyMock.expect(targetInvoker.isCacheable()).andReturn(false); - EasyMock.replay(targetInvoker); - chain.setTargetInvoker(targetInvoker); - } - wire.setServiceContract(contract); - clientHello = Client.class.getMethod("hello"); - - } - - private interface Target { - String hello(); - } - - private interface Client { - String hello(); - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/jdk/JDKOutboundInvocationHandlerSerializationTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/jdk/JDKOutboundInvocationHandlerSerializationTestCase.java deleted file mode 100644 index c6e449d291..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/jdk/JDKOutboundInvocationHandlerSerializationTestCase.java +++ /dev/null @@ -1,132 +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.jdk; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.tuscany.spi.component.AtomicComponent; -import org.apache.tuscany.spi.component.SCAObject; -import org.apache.tuscany.spi.component.WorkContext; -import org.apache.tuscany.spi.model.InteractionScope; -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.Message; -import org.apache.tuscany.spi.wire.MessageImpl; -import org.apache.tuscany.spi.wire.OutboundInvocationChain; -import org.apache.tuscany.spi.wire.OutboundWire; -import org.apache.tuscany.spi.wire.TargetInvoker; - -import junit.framework.TestCase; -import org.apache.tuscany.core.component.WorkContextImpl; -import org.apache.tuscany.core.wire.InvokerInterceptor; -import org.apache.tuscany.core.wire.OutboundInvocationChainImpl; -import org.easymock.EasyMock; - -/** - * @version $Rev$ $Date$ - */ -public class JDKOutboundInvocationHandlerSerializationTestCase extends TestCase { - private OutboundWire wire; - private WorkContext workContext; - private TargetInvoker invoker; - - public void testSerializeDeserialize() throws Throwable { - JDKOutboundInvocationHandler handler = - new JDKOutboundInvocationHandler(Foo.class, wire, workContext); - handler.invoke(Foo.class.getMethod("invoke"), null); - ByteArrayOutputStream stream = new ByteArrayOutputStream(); - ObjectOutputStream ostream = new ObjectOutputStream(stream); - ostream.writeObject(handler); - - ObjectInputStream istream = new ObjectInputStream(new ByteArrayInputStream(stream.toByteArray())); - JDKOutboundInvocationHandler externalizable = (JDKOutboundInvocationHandler) istream.readObject(); - - externalizable.setWorkContext(workContext); - externalizable.reactivate(); - externalizable.invoke(Foo.class.getMethod("invoke"), null); - EasyMock.verify(invoker); - EasyMock.verify(wire); - } - - protected void setUp() throws Exception { - super.setUp(); - SCAObject container = EasyMock.createMock(SCAObject.class); - ServiceContract contract = new ServiceContract() { - }; - contract.setInterfaceClass(Foo.class); - contract.setInteractionScope(InteractionScope.NONCONVERSATIONAL); - EasyMock.expect(container.getName()).andReturn("bar").atLeastOnce(); - EasyMock.replay(container); - wire = EasyMock.createMock(OutboundWire.class); - Map, OutboundInvocationChain> map = new HashMap, OutboundInvocationChain>(); - Operation operation = new Operation("invoke", null, null, null, false, null, NO_CONVERSATION); - ServiceContract opContract = new ServiceContract() { - }; - contract.setInterfaceClass(Foo.class); - contract.setInteractionScope(InteractionScope.NONCONVERSATIONAL); - operation.setServiceContract(opContract); - map.put(operation, createChain(operation)); - EasyMock.expect(wire.getContainer()).andReturn(container).atLeastOnce(); - EasyMock.expect(wire.getServiceContract()).andReturn(contract).atLeastOnce(); - EasyMock.expect(wire.getReferenceName()).andReturn("foo").atLeastOnce(); - EasyMock.expect(wire.getInvocationChains()).andReturn(map).times(2); - EasyMock.replay(wire); - Map> wires = new HashMap>(); - List list = new ArrayList(); - list.add(wire); - wires.put("foo", list); - AtomicComponent component = EasyMock.createMock(AtomicComponent.class); - EasyMock.expect(component.getOutboundWires()).andReturn(wires); - EasyMock.replay(component); - workContext = new WorkContextImpl(); - workContext.setCurrentAtomicComponent(component); - } - - protected void tearDown() throws Exception { - super.tearDown(); - workContext.setCurrentAtomicComponent(null); - } - - private OutboundInvocationChain createChain(Operation operation) { - invoker = EasyMock.createMock(TargetInvoker.class); - EasyMock.expect(invoker.invoke(EasyMock.isA(Message.class))).andReturn(new MessageImpl()).times(2); - EasyMock.expect(invoker.isCacheable()).andReturn(false).atLeastOnce(); - EasyMock.replay(invoker); - OutboundInvocationChain chain = new OutboundInvocationChainImpl(operation); - chain.setTargetInvoker(invoker); - chain.addInterceptor(new InvokerInterceptor()); - chain.prepare(); - return chain; - } - - public class Foo { - - public void invoke() { - } - } - -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/jdk/JDKOutboundInvocationHandlerTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/jdk/JDKOutboundInvocationHandlerTestCase.java deleted file mode 100644 index 4d2af8acf9..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/jdk/JDKOutboundInvocationHandlerTestCase.java +++ /dev/null @@ -1,176 +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.jdk; - -import java.lang.reflect.Array; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Proxy; -import java.lang.reflect.Type; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; - -import org.apache.tuscany.spi.component.WorkContext; -import org.apache.tuscany.spi.idl.java.JavaServiceContract; -import org.apache.tuscany.spi.model.DataType; -import org.apache.tuscany.spi.model.InteractionScope; -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.wire.InvocationRuntimeException; -import org.apache.tuscany.spi.wire.Message; -import org.apache.tuscany.spi.wire.OutboundInvocationChain; -import org.apache.tuscany.spi.wire.OutboundWire; -import org.apache.tuscany.spi.wire.TargetInvoker; - -import junit.framework.TestCase; -import org.apache.tuscany.core.component.WorkContextImpl; -import org.apache.tuscany.core.wire.OutboundWireImpl; -import static org.easymock.EasyMock.createMock; -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.replay; - -/** - * @version $Rev$ $Date$ - */ -public class JDKOutboundInvocationHandlerTestCase extends TestCase { - - public void testToString() { - OutboundWireImpl wire = new OutboundWireImpl(); - ServiceContract contract = new JavaServiceContract(Foo.class); - contract.setInteractionScope(InteractionScope.NONCONVERSATIONAL); - wire.setServiceContract(contract); - JDKOutboundInvocationHandler handler = new JDKOutboundInvocationHandler(Foo.class, wire, null); - Foo foo = (Foo) Proxy.newProxyInstance(getClass().getClassLoader(), new Class[]{Foo.class}, handler); - assertNotNull(foo.toString()); - } - - public void testHashCode() { - OutboundWireImpl wire = new OutboundWireImpl(); - ServiceContract contract = new JavaServiceContract(Foo.class); - contract.setInteractionScope(InteractionScope.NONCONVERSATIONAL); - wire.setServiceContract(contract); - JDKOutboundInvocationHandler handler = new JDKOutboundInvocationHandler(Foo.class, wire, null); - Foo foo = (Foo) Proxy.newProxyInstance(getClass().getClassLoader(), new Class[]{Foo.class}, handler); - assertNotNull(foo.hashCode()); - } - - public void testConversational() throws Throwable { - OutboundWire outboundWire = createMock(OutboundWire.class); - Map, OutboundInvocationChain> outboundChains = - new HashMap, OutboundInvocationChain>(); - DataType type1 = new DataType(String.class, String.class); - List> types = new ArrayList>(); - types.add(type1); - DataType>> inputType1 = new DataType>>(Object[].class, types); - DataType outputType1 = new DataType(String.class, String.class); - Operation op1 = new Operation("test", inputType1, outputType1, null); - ServiceContract outboundContract = new JavaServiceContract(Foo.class); - outboundContract.setInteractionScope(InteractionScope.CONVERSATIONAL); - op1.setServiceContract(outboundContract); - - WorkContext wc = new WorkContextImpl(); - MockInvoker invoker = new MockInvoker(wc); - OutboundInvocationChain outboundChain = createMock(OutboundInvocationChain.class); - expect(outboundChain.getTargetInvoker()).andReturn(invoker).anyTimes(); - expect(outboundChain.getHeadInterceptor()).andReturn(null).anyTimes(); - replay(outboundChain); - outboundChains.put(op1, outboundChain); - expect(outboundWire.getInvocationChains()).andReturn(outboundChains).anyTimes(); - expect(outboundWire.getReferenceName()).andReturn("fooRef").atLeastOnce(); - expect(outboundWire.getContainer()).andReturn(null).anyTimes(); - expect(outboundWire.getServiceContract()).andReturn(outboundContract).anyTimes(); - replay(outboundWire); - - String convID = UUID.randomUUID().toString(); - wc.setIdentifier(Scope.CONVERSATION, convID); - invoker.setCurrentConversationID(convID); - - outboundContract.setRemotable(true); - invoker.setRemotableTest(true); - JDKOutboundInvocationHandler handler = new JDKOutboundInvocationHandler(Foo.class, outboundWire, wc); - handler.invoke(Foo.class.getMethod("test", String.class), new Object[]{"bar"}); - String currentConvID = (String) wc.getIdentifier(Scope.CONVERSATION); - assertSame(convID, currentConvID); - - outboundContract.setRemotable(false); - invoker.setRemotableTest(false); - JDKOutboundInvocationHandler handler2 = new JDKOutboundInvocationHandler(Foo.class, outboundWire, wc); - handler2.invoke(Foo.class.getMethod("test", String.class), new Object[]{"bar"}); - currentConvID = (String) wc.getIdentifier(Scope.CONVERSATION); - assertSame(convID, currentConvID); - } - - private interface Foo { - String test(String s); - } - - private class MockInvoker implements TargetInvoker { - - private WorkContext wc; - private String currentConversationID; - private boolean remotableTest; - - public MockInvoker(WorkContext wc) { - this.wc = wc; - } - - public void setCurrentConversationID(String id) { - currentConversationID = id; - } - - public void setRemotableTest(boolean remotableTest) { - this.remotableTest = remotableTest; - } - - public Object invokeTarget(final Object payload, final short sequence) throws InvocationTargetException { - assertEquals("bar", Array.get(payload, 0)); - String convID = (String) wc.getIdentifier(Scope.CONVERSATION); - if (remotableTest) { - assertNotSame(convID, currentConversationID); - } else { - assertSame(convID, currentConversationID); - } - return "response"; - } - - public Message invoke(Message msg) throws InvocationRuntimeException { - fail(); - return null; - } - - public boolean isCacheable() { - return false; - } - - public void setCacheable(boolean cacheable) { - - } - - public boolean isOptimizable() { - return false; - } - - public Object clone() throws CloneNotSupportedException { - return super.clone(); - } - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/jdk/JDKProxyTestCase.java b/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/jdk/JDKProxyTestCase.java deleted file mode 100644 index 994d944d98..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/java/org/apache/tuscany/core/wire/jdk/JDKProxyTestCase.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.wire.jdk; - -import java.lang.reflect.Proxy; -import java.util.HashMap; -import java.util.Map; - -import org.apache.tuscany.spi.model.Operation; -import org.apache.tuscany.spi.wire.InboundInvocationChain; -import org.apache.tuscany.spi.wire.InboundWire; - -import junit.framework.TestCase; -import org.easymock.EasyMock; - -/** - * @version $Rev$ $Date$ - */ -public class JDKProxyTestCase extends TestCase { - private JDKWireService wireService; - private InboundWire inboundWire; - private Map, InboundInvocationChain> chains; - - public void testCreateProxy() { - EasyMock.expect(inboundWire.getServiceName()).andReturn("service"); - EasyMock.expect(inboundWire.getInvocationChains()).andReturn(chains); - EasyMock.replay(inboundWire); - TestInterface intf = wireService.createProxy(TestInterface.class, inboundWire); - assertTrue(Proxy.isProxyClass(intf.getClass())); - EasyMock.verify(inboundWire); - } - - protected void setUp() throws Exception { - super.setUp(); - wireService = new JDKWireService(); - inboundWire = EasyMock.createMock(InboundWire.class); - chains = new HashMap, InboundInvocationChain>(); - } - - public static interface TestInterface { - int primitives(int i); - - String objects(String object); - } -} diff --git a/branches/pre-spec-changes/kernel/core/src/test/resources/org/apache/tuscany/core/databinding/impl/ipo.xsd b/branches/pre-spec-changes/kernel/core/src/test/resources/org/apache/tuscany/core/databinding/impl/ipo.xsd deleted file mode 100644 index 92a576fb98..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/resources/org/apache/tuscany/core/databinding/impl/ipo.xsd +++ /dev/null @@ -1,136 +0,0 @@ - - - - - - International Purchase order schema for Example.com - Copyright 2000 Example.com. All rights reserved. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/branches/pre-spec-changes/kernel/core/src/test/resources/org/apache/tuscany/core/databinding/impl/order.wsdl b/branches/pre-spec-changes/kernel/core/src/test/resources/org/apache/tuscany/core/databinding/impl/order.wsdl deleted file mode 100644 index 100890e10b..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/resources/org/apache/tuscany/core/databinding/impl/order.wsdl +++ /dev/null @@ -1,76 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/branches/pre-spec-changes/kernel/core/src/test/resources/org/apache/tuscany/core/databinding/xml/foo.xml b/branches/pre-spec-changes/kernel/core/src/test/resources/org/apache/tuscany/core/databinding/xml/foo.xml deleted file mode 100644 index 0ba8ade1e0..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/resources/org/apache/tuscany/core/databinding/xml/foo.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - bar - \ No newline at end of file diff --git a/branches/pre-spec-changes/kernel/core/src/test/resources/org/apache/tuscany/core/deployer/boot1-include.scdl b/branches/pre-spec-changes/kernel/core/src/test/resources/org/apache/tuscany/core/deployer/boot1-include.scdl deleted file mode 100644 index 5ffd69dc28..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/resources/org/apache/tuscany/core/deployer/boot1-include.scdl +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - component2 - - - diff --git a/branches/pre-spec-changes/kernel/core/src/test/resources/org/apache/tuscany/core/deployer/boot1.scdl b/branches/pre-spec-changes/kernel/core/src/test/resources/org/apache/tuscany/core/deployer/boot1.scdl deleted file mode 100644 index 3911e54e86..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/resources/org/apache/tuscany/core/deployer/boot1.scdl +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - component - - - - - propval - component2 - - - - diff --git a/branches/pre-spec-changes/kernel/core/src/test/resources/org/apache/tuscany/core/deployer/boot2.scdl b/branches/pre-spec-changes/kernel/core/src/test/resources/org/apache/tuscany/core/deployer/boot2.scdl deleted file mode 100644 index 66449f39c3..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/resources/org/apache/tuscany/core/deployer/boot2.scdl +++ /dev/null @@ -1,136 +0,0 @@ - - - - - - - - - deployerImpl - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - .m2/repository - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/branches/pre-spec-changes/kernel/core/src/test/resources/org/apache/tuscany/core/loader/TestPolicy.scdl b/branches/pre-spec-changes/kernel/core/src/test/resources/org/apache/tuscany/core/loader/TestPolicy.scdl deleted file mode 100644 index 2ec1a2ed0e..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/test/resources/org/apache/tuscany/core/loader/test-include.scdl b/branches/pre-spec-changes/kernel/core/src/test/resources/org/apache/tuscany/core/loader/test-include.scdl deleted file mode 100644 index 584846504b..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/test/resources/org/apache/tuscany/core/policy/PolicySet.scdl b/branches/pre-spec-changes/kernel/core/src/test/resources/org/apache/tuscany/core/policy/PolicySet.scdl deleted file mode 100644 index 77c6b5edd9..0000000000 --- a/branches/pre-spec-changes/kernel/core/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/branches/pre-spec-changes/kernel/core/src/test/resources/org/apache/tuscany/core/property/ipo.xml b/branches/pre-spec-changes/kernel/core/src/test/resources/org/apache/tuscany/core/property/ipo.xml deleted file mode 100644 index 58058dbe1a..0000000000 --- a/branches/pre-spec-changes/kernel/core/src/test/resources/org/apache/tuscany/core/property/ipo.xml +++ /dev/null @@ -1,33 +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/branches/pre-spec-changes/kernel/host-api/.checkstyle b/branches/pre-spec-changes/kernel/host-api/.checkstyle deleted file mode 100644 index 3e57539570..0000000000 --- a/branches/pre-spec-changes/kernel/host-api/.checkstyle +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - diff --git a/branches/pre-spec-changes/kernel/host-api/.pmd b/branches/pre-spec-changes/kernel/host-api/.pmd deleted file mode 100644 index ffc4fe2bbb..0000000000 --- a/branches/pre-spec-changes/kernel/host-api/.pmd +++ /dev/null @@ -1,20 +0,0 @@ - - -true diff --git a/branches/pre-spec-changes/kernel/host-api/.ruleset b/branches/pre-spec-changes/kernel/host-api/.ruleset deleted file mode 100644 index 3886f07f2d..0000000000 --- a/branches/pre-spec-changes/kernel/host-api/.ruleset +++ /dev/null @@ -1,190 +0,0 @@ - - - - PMD Plugin preferences rule set - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/branches/pre-spec-changes/kernel/host-api/LICENSE.txt b/branches/pre-spec-changes/kernel/host-api/LICENSE.txt deleted file mode 100644 index 0084319535..0000000000 --- a/branches/pre-spec-changes/kernel/host-api/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/branches/pre-spec-changes/kernel/host-api/NOTICE.txt b/branches/pre-spec-changes/kernel/host-api/NOTICE.txt deleted file mode 100644 index d83ebbe236..0000000000 --- a/branches/pre-spec-changes/kernel/host-api/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/branches/pre-spec-changes/kernel/host-api/pom.xml b/branches/pre-spec-changes/kernel/host-api/pom.xml deleted file mode 100644 index a4f91fc834..0000000000 --- a/branches/pre-spec-changes/kernel/host-api/pom.xml +++ /dev/null @@ -1,49 +0,0 @@ - - - - - org.apache.tuscany.sca.kernel - parent - 0.1-pre-spec-SNAPSHOT - - 4.0.0 - tuscany-host-api - jar - Apache Tuscany Host API - Tuscany Host Programming Interfaces. - - - - org.apache.tuscany.sca.kernel - tuscany-api - ${pom.version} - compile - - - javax.servlet - servlet-api - - - - junit - junit - - - diff --git a/branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/AbstractRuntimeInfo.java b/branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/AbstractRuntimeInfo.java deleted file mode 100644 index 513d02232a..0000000000 --- a/branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/AbstractRuntimeInfo.java +++ /dev/null @@ -1,125 +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.host; - -import java.io.File; -import java.net.URL; -import java.net.URI; - -/** - * Abstract runtime info implementation. - * - * @version $Revision$ $Date$ - */ -public abstract class AbstractRuntimeInfo implements RuntimeInfo { - - /** - * This SCA Domain this runtime belongs to. - */ - private final URI domain; - - /** - * Application root directory. - */ - private final File applicationRootDirectory; - - /** - * Base URL. - */ - private final URL baseUrl; - - /** - * Online indicator. - */ - private final boolean online; - - /** - * Runtime Id. - */ - private String runtimeId; - - /** - * Initializes the runtime info instance. - * - * @param domain the SCA Domain that this runtime belongs to - * @param applicationRootDirectory Application root directory. - * @param baseUrl Base Url. - * @param online Onlne indicator. - * @param runtimeId Runtime Id. - */ - public AbstractRuntimeInfo(final URI domain, - final File applicationRootDirectory, - final URL baseUrl, - final boolean online, - final String runtimeId) { - this.domain = domain; - this.applicationRootDirectory = applicationRootDirectory; - this.baseUrl = baseUrl; - this.online = online; - this.runtimeId = runtimeId; - } - - /** - * Returns the SCA domain associated with this runtime. - * A null domain indicates that this is a standalone runtime with a self-contained assembly. - * - * @return the SCA domain associated with this runtime; may be null - */ - public URI getDomain() { - return domain; - } - - /** - * Returns the unique runtime is in the SCA domain. - * - * @return the SCA domain associated with this runtime; may be null - */ - public String getRuntimeId() { - return runtimeId; - } - - /** - * Return the root directory used to resolve application file paths. - * - * @return the directory used to resolve application file paths. - */ - public final File getApplicationRootDirectory() { - return applicationRootDirectory; - } - - /** - * Gets the base URL for the runtime. - * - * @return The base URL for the runtime. - */ - public final URL getBaseURL() { - return baseUrl; - } - - /** - * Returns whether the runtime considers itself "online" or connected to the internet. - * This can be used by services to enable access to remote resources. - * - * @return true if the runtime is online. - */ - public final boolean isOnline() { - return online; - } - -} diff --git a/branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/Launcher.java b/branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/Launcher.java deleted file mode 100644 index 64f2e8b9a0..0000000000 --- a/branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/Launcher.java +++ /dev/null @@ -1,57 +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.host; - -import java.net.URL; - -import org.osoa.sca.CompositeContext; - -import org.apache.tuscany.api.TuscanyException; - -/** - * Interface that allows a host to launch a runtime. - * - * @version $Rev$ $Date$ - */ -public interface Launcher { - /** - * Boot the Tuscany runtime. - * - * @param systemScdl the SCDL defining the runtime's system configuration - * @param systemClassLoader the root classloader to use to deploy the system SCDL - * @param monitorFactory the monitor factory initialize the runtime with - * @throws TuscanyException if there was a problem booting the runtimr - */ - void bootRuntime(URL systemScdl, ClassLoader systemClassLoader, MonitorFactory monitorFactory) - throws TuscanyException; - - /** - * Shutdown the Tuscany runtime. - */ - void shutdownRuntime(); - - /** - * Boot a default application into the runtime. - * - * @param applicationScdl the application's SCDL - * @param applicationClassLoader the classloader to use to deploy the application - * @return the CompositeContext for the application - */ - CompositeContext bootApplication(URL applicationScdl, ClassLoader applicationClassLoader); -} diff --git a/branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/MonitorFactory.java b/branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/MonitorFactory.java deleted file mode 100644 index d338681641..0000000000 --- a/branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/MonitorFactory.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.host; - -import java.util.Map; - -/** - * A MonitorFactory creates implementations of components' monitor interfaces that interface with a its monitoring - * scheme. For example, a implementation may create versions that emit appropriate logging events or which send - * notifications to a management API. - * - * MonitorFactory implementations must provide a no-arg constructor and implement the {@link #initialize} method - * to perform configuration of instances created using that constructor. Additional constructors may be defined; - * typically their implementations delegate to {@link #initialize}. - * - * @version $Rev$ $Date$ - */ -public interface MonitorFactory { - /** - * Initializes MonitorFactory instances with implementation-specific configuration properties. - * - * @param configProperties a map of named configuration properties. May be null. - * @throws IllegalArgumentException if the instance can't be configured using the supplied properties - */ - void initialize(Map configProperties); - /** - * Return a monitor for a component's monitor interface. - * - * @param monitorInterface the component's monitoring interface - * @return an implementation of the monitoring interface; will not be null - */ - T getMonitor(Class monitorInterface); -} diff --git a/branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/RuntimeInfo.java b/branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/RuntimeInfo.java deleted file mode 100644 index c75e325256..0000000000 --- a/branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/RuntimeInfo.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.host; - -import java.io.File; -import java.net.URI; -import java.net.URL; - -/** - * Interface that provides information on the runtime environment. - * - * @version $Rev$ $Date$ - */ -public interface RuntimeInfo { - /** - * The default name that the runtime should assign to the component providing this service. - */ - String COMPONENT_NAME = "RuntimeInfo"; - - /** - * Returns the SCA domain associated with this runtime. - * A null domain indicates that this is a standalone runtime with a self-contained assembly. - * - * @return the SCA domain associated with this runtime; may be null - */ - URI getDomain(); - - /** - * Returns the unique runtime is in the SCA domain. - * - * @return the SCA domain associated with this runtime; may be null - */ - String getRuntimeId(); - - /** - * Return the root directory used to resolve application file paths. - * - * @return the directory used to resolve application file paths. - */ - File getApplicationRootDirectory(); - - /** - * Gets the base URL for the runtime. - * - * @return The base URL for the runtime. - */ - URL getBaseURL(); - - /** - * Returns whether the runtime considers itself "online" or connected to the internet. - * This can be used by services to enable access to remote resources. - * - * @return true if the runtime is online. - */ - boolean isOnline(); -} diff --git a/branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/deployment/AssemblyService.java b/branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/deployment/AssemblyService.java deleted file mode 100644 index 50eb24fded..0000000000 --- a/branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/deployment/AssemblyService.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.host.deployment; - -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; - -/** - * Service interface for managing the logical assembly for a Tuscany runtime. - * - * @version $Rev$ $Date$ - */ -public interface AssemblyService { - /** - * Apply a set of changes to the SCA Domain's logical assembly. - * - * @param changeSet the location of a resource containing a set of changes - * @throws DeploymentException if there was a problem making the changes - * @throws IOException if there was a problem accessing the resource - */ - void applyChanges(URL changeSet) throws DeploymentException, IOException; - - /** - * Apply a set of changes to the SCA Domain's logical assembly. - * - * @param changeSet a stream for reading a resource containing a set of changes; the stream will not be closed - * but no guarantee is made on the position the stream is left in - * @param contentType the type of changeSet on the stream; must be a valid Content-Type value - * as specified by RFC2045 - * and must not be null - * @throws DeploymentException if there was a problem making the changes - * @throws IOException if there was a problem reading the stream - */ - void applyChanges(InputStream changeSet, String contentType) throws DeploymentException, IOException; -} diff --git a/branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/deployment/ContentTypes.java b/branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/deployment/ContentTypes.java deleted file mode 100644 index a1f0b26b40..0000000000 --- a/branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/deployment/ContentTypes.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.host.deployment; - -/** - * Definitions of common Content-Type values. - * - * @version $Rev$ $Date$ - */ -public final class ContentTypes { - /** - * An Assembly changeSet represented as XML. - */ - public static final String CHANGESET_XML = "application/x-apache.tuscany.changeSet+xml"; - - private ContentTypes() { - } - -} diff --git a/branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/deployment/ContributionService.java b/branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/deployment/ContributionService.java deleted file mode 100644 index 23cff119fc..0000000000 --- a/branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/deployment/ContributionService.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.host.deployment; - -import java.io.IOException; -import java.io.InputStream; -import java.net.URI; -import java.net.URL; - -/** - * Service interface that manages artifacts contributed to a Tuscany runtime. - * - * @version $Rev$ $Date$ - */ -public interface ContributionService { - /** - * Contribute an artifact to the SCA Domain. - * The type of the contribution is determined by the Content-Type of the resource - * or, if that is undefined, by some implementation-specific means (such as - * mapping an extension in the URL's path). - * - * @param contribution the location of the resource containing the artifact - * @return a URI that uniquely identifies this contribution within the SCA Domain - * @throws DeploymentException if there was a problem with the contribution - * @throws IOException if there was a problem reading the resource - */ - URI contribute(URL contribution) throws DeploymentException, IOException; - - /** - * Contribute an artifact to the SCA Domain. - * - * @param source an identifier for the source of this contribution - * @param contribution a stream containing the resource being contributed; the stream will not be closed - * but the read position after the call is undefined - * @param contentType the type of contribution being made; must be a valid Content-Type value - * as specified by RFC2045 - * and must not be null @return a URI that uniquely identifies this contribution within the SCA Domain - * @throws DeploymentException if there was a problem with the contribution - * @throws IOException if there was a problem reading the stream - */ - URI contribute(URI source, InputStream contribution, String contentType) throws DeploymentException, IOException; -} diff --git a/branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/deployment/DeploymentException.java b/branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/deployment/DeploymentException.java deleted file mode 100644 index 95ebb50b5c..0000000000 --- a/branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/deployment/DeploymentException.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.host.deployment; - -import org.apache.tuscany.api.TuscanyException; - -/** - * Base class for exceptions raised during deployment. - * - * @version $Rev$ $Date$ - */ -public abstract class DeploymentException extends TuscanyException { - protected DeploymentException() { - } - - protected DeploymentException(String message) { - super(message); - } - - protected DeploymentException(String message, String identifier) { - super(message, identifier); - } - - protected DeploymentException(String message, Throwable cause) { - super(message, cause); - } - - protected DeploymentException(String message, String identifier, Throwable cause) { - super(message, identifier, cause); - } - - protected DeploymentException(Throwable cause) { - super(cause); - } -} diff --git a/branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/deployment/UnsupportedContentTypeException.java b/branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/deployment/UnsupportedContentTypeException.java deleted file mode 100644 index d79fe3258a..0000000000 --- a/branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/deployment/UnsupportedContentTypeException.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.host.deployment; - -/** - * Exception thrown to indicate that a Content-Type is not supported by this SCA Domain. - * The Content-Type value supplied will be returned as the message text for this exception. - * - * @version $Rev$ $Date$ - */ -public class UnsupportedContentTypeException extends DeploymentException { - - /** - * Constructor specifying the Content-Type value that is not supported. - * - * @param contentType the type that is not supported - */ - public UnsupportedContentTypeException(String contentType) { - super(contentType); - } - - /** - * Constructor specifying the Content-Type value that is not supported - * and an identifier to use with this exception (typically the resource being processed). - * - * @param contentType the type that is not supported - * @param identifier an identifier for this exception - */ - public UnsupportedContentTypeException(String contentType, String identifier) { - super(contentType, identifier); - } -} diff --git a/branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/management/ManagementService.java b/branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/management/ManagementService.java deleted file mode 100644 index 1b62d3bbed..0000000000 --- a/branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/management/ManagementService.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.host.management; - -/** - * - * @version $Revision$ $Date$ - */ -public interface ManagementService { - - /** - * Registers the object for management. - * - * @param name Name under which the object is registered. - * @param managedObject Managed object to be registered. - */ - void registerComponent(String name, T managedObject); - -} diff --git a/branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/monitor/ExceptionFormatter.java b/branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/monitor/ExceptionFormatter.java deleted file mode 100644 index 4c1e04ecb9..0000000000 --- a/branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/monitor/ExceptionFormatter.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.host.monitor; - -import java.io.PrintWriter; - -/** - * Formats exception data during a monitor event - * - * @version $Rev$ $Date$ - */ -public interface ExceptionFormatter { - - boolean canFormat(Class type); - - PrintWriter write(PrintWriter writer, Throwable exception); - -} diff --git a/branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/monitor/FormatterRegistry.java b/branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/monitor/FormatterRegistry.java deleted file mode 100644 index 277abb63a7..0000000000 --- a/branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/monitor/FormatterRegistry.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.host.monitor; - -/** - * A registry for exception formatters - * - * @version $Rev$ $Date$ - */ -public interface FormatterRegistry { - - /** - * Registers the given formatter - * - * @param formatter the formatter to register - */ - void register(ExceptionFormatter formatter); - - /** - * De-registers the given formatter - * - * @param formatter the formatter to de-register - */ - void unregister(ExceptionFormatter formatter); - -} diff --git a/branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/rmi/RMIHost.java b/branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/rmi/RMIHost.java deleted file mode 100644 index 3dc68f430d..0000000000 --- a/branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/rmi/RMIHost.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.host.rmi; - -import java.rmi.Remote; - -/* RMI Service hosting interface to be implemented by host environments that allows SCA Components - * to register RMI Services to handle inbound service requests over RMI to SCA Components - */ - -public interface RMIHost { - int RMI_DEFAULT_PORT = 1299; - - // registers an RMI service with the given name and port - void registerService(String serviceName, int port, Remote serviceObject) throws RMIHostException, - RMIHostRuntimeException; - - // registers an RMI service with the given name and default port (1099) - void registerService(String serviceName, Remote serviceObject) throws RMIHostException, - RMIHostRuntimeException; - - // unregister a service registered under the given service name and port number - void unregisterService(String serviceName, int port) throws RMIHostException, - RMIHostRuntimeException; - - // unregister a service registered under the given service name and defalut port number (1099) - void unregisterService(String serviceName) throws RMIHostException, - RMIHostRuntimeException; - - //find a remote service hosted on the given host, port and service name - Remote findService(String host, String port, String svcName) throws RMIHostException, - RMIHostRuntimeException; -} diff --git a/branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/rmi/RMIHostAdmin.java b/branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/rmi/RMIHostAdmin.java deleted file mode 100644 index dedfff1cdd..0000000000 --- a/branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/rmi/RMIHostAdmin.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.host.rmi; - -import java.rmi.registry.Registry; -import java.util.List; - -/* RMI Service hosting Admin Interface to be implemented by host environments that allows SCA Components - * to register RMI Services to handle inbound service requests over RMI to SCA Components. This interface - * can be used by admin functions to obtain information on RMI registries started and running in the host - * environment - */ - -public interface RMIHostAdmin { - //gets all RMI registries running on the host. Each element of the list is an object of type - //java.rmi.registry - List getAllRegistries() throws RMIHostRuntimeException; - - //gets a registry that is running at a particular port - Registry getRegistry(int port) throws RMIHostRuntimeException; - - //more methods to be added -} diff --git a/branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/rmi/RMIHostException.java b/branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/rmi/RMIHostException.java deleted file mode 100644 index 5d7733927d..0000000000 --- a/branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/rmi/RMIHostException.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.host.rmi; - -import org.apache.tuscany.api.TuscanyException; - -/** - * This exception will relate to situations where the end applicaition's input is the cause of the exception - * - * @version $Rev$ $Date$ - */ -public class RMIHostException extends TuscanyException { - private static final long serialVersionUID = 8031031440259175970L; - - public RMIHostException() { - } - - public RMIHostException(String message) { - super(message); - } - - public RMIHostException(Throwable e) { - super(e); - } - - public RMIHostException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/rmi/RMIHostRuntimeException.java b/branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/rmi/RMIHostRuntimeException.java deleted file mode 100644 index 35b207b5d2..0000000000 --- a/branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/rmi/RMIHostRuntimeException.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.host.rmi; - -import org.apache.tuscany.api.TuscanyRuntimeException; - -/** - * This exception relates to cases where there is a problem with the - * Host runtime - * - */ -public class RMIHostRuntimeException extends TuscanyRuntimeException { - private static final long serialVersionUID = -1L; - - public RMIHostRuntimeException() { - } - - public RMIHostRuntimeException(String message) { - super(message); - } - - public RMIHostRuntimeException(Throwable e) { - super(e); - } - - public RMIHostRuntimeException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/runtime/InitializationException.java b/branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/runtime/InitializationException.java deleted file mode 100644 index 20b518609e..0000000000 --- a/branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/runtime/InitializationException.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.host.runtime; - -import org.apache.tuscany.api.TuscanyException; - -/** - * Denotes an error starting the runtime - * - * @version $Rev$ $Date$ - */ -public class InitializationException extends TuscanyException { - - public InitializationException(String message) { - super(message); - } - - public InitializationException(Throwable cause) { - super(cause); - } -} diff --git a/branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/runtime/ShutdownException.java b/branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/runtime/ShutdownException.java deleted file mode 100644 index 769c928471..0000000000 --- a/branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/runtime/ShutdownException.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.host.runtime; - -import org.apache.tuscany.api.TuscanyException; - -/** - * Denotes an error during runtime shutdown - * - * @version $Rev$ $Date$ - */ -public class ShutdownException extends TuscanyException { - - public ShutdownException(Throwable cause) { - super(cause); - } -} diff --git a/branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/runtime/TuscanyRuntime.java b/branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/runtime/TuscanyRuntime.java deleted file mode 100644 index fcbe4a829f..0000000000 --- a/branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/runtime/TuscanyRuntime.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.host.runtime; - -import java.net.URL; - -import org.osoa.sca.CompositeContext; - -import org.apache.tuscany.host.MonitorFactory; -import org.apache.tuscany.host.RuntimeInfo; -import org.apache.tuscany.host.management.ManagementService; - -/** - * @version $Rev$ $Date$ - */ -public interface TuscanyRuntime { - /** - * Returns the location of the SCDL used to boot this runtime. - * - * @return the location of the SCDL used to boot this runtime - */ - URL getSystemScdl(); - - /** - * Sets the location of the SCDL used to boot this runtime. - * - * @param systemScdl the location of the SCDL used to boot this runtime - */ - void setSystemScdl(URL systemScdl); - - /** - * Returns the host ClassLoader that is parent to all Tuscany classloaders. - * - * @return the host's ClassLoader - */ - ClassLoader getHostClassLoader(); - - /** - * Sets the host ClassLoader; this will be a parent for all Tuscany classloaders. - * - * @param classLoader the host's ClassLoader - */ - void setHostClassLoader(ClassLoader classLoader); - - /** - * Returns the info this runtime will make available to service components. - * - * @return the info this runtime will make available to service components - */ - RuntimeInfo getRuntimeInfo(); - - /** - * Sets the info this runtime should make available to service components. The instance supplied here should be - * registered in the system composite with the name {@link RuntimeInfo#COMPONENT_NAME "RuntimeInfo"}. - * - * @param runtimeInfo the information this runtime should make available to service components - */ - void setRuntimeInfo(RuntimeInfo runtimeInfo); - - /** - * Returns the MonitorFactory that this runtime is using. - * - * @return the MonitorFactory that this runtime is using - */ - MonitorFactory getMonitorFactory(); - - /** - * Sets the MonitorFactory that this runtime should use. - * - * @param monitorFactory the MonitorFactory that this runtime should use - */ - void setMonitorFactory(MonitorFactory monitorFactory); - - /** - * Sets the ManagementService that this runtime should use. - * - * @param managementService the ManagementService that this runtime should use - */ - void setManagementService(ManagementService managementService); - - /** - * Returns the ManagementService that this runtime is using. - * - * @return the ManagementService that this runtime is using - */ - ManagementService getManagementService(); - - /** - * Initialize a runtime. - * - * @throws InitializationException if there is an error initializing the runtime - */ - void initialize() throws InitializationException; - - /** - * Destroy the runtime. Any further invocations should result in an error. - * - * @throws ShutdownException if there is an error destroying the runtime - */ - void destroy() throws ShutdownException; - - /** - * Returns the current SCA context - */ - @Deprecated - CompositeContext getContext(); - - /** - * Returns the name of the component associated with the application SCDL. - * - * @return the name of the component associated with the application SCDL - */ - @Deprecated - String getApplicationName(); - - /** - * Sets the name of the component associated with the application SCDL. - * - * @param applicationName the name of the component associated with the application SCDL - */ - @Deprecated - void setApplicationName(String applicationName); - - /** - * Returns the location of the default application's SCDL. - * - * @return the location of the default application's SCDL - */ - @Deprecated - URL getApplicationScdl(); - - /** - * Sets the location of the default application's SCDL - * - * @param applicationScdl the location of the default application's SCDL - */ - @Deprecated - void setApplicationScdl(URL applicationScdl); - - /** - * Get the application classloader - */ - @Deprecated - ClassLoader getApplicationClassLoader(); - - /** - * Set the application classloader - */ - @Deprecated - void setApplicationClassLoader(ClassLoader applicationClassLoader); - - /** - * Temporary API to allow and application to be deployed until we get the proper deployment services running. - * - * @param name the name of the component for the application - * @param scdlLocation the location of a SCDL composite document to use as the component's implementation - * @param classLoader the classloader to associated with the application component - * @return the context for the application's composite component - */ - @Deprecated - CompositeContext deployApplication(String name, URL scdlLocation, ClassLoader classLoader) - throws InitializationException; -} diff --git a/branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/servlet/ServletRequestInjector.java b/branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/servlet/ServletRequestInjector.java deleted file mode 100644 index e4b11aee90..0000000000 --- a/branches/pre-spec-changes/kernel/host-api/src/main/java/org/apache/tuscany/host/servlet/ServletRequestInjector.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.host.servlet; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; - -/** - * Interface to a system component that dispatches servlet requests to the Tuscany runtime - */ -public interface ServletRequestInjector { - - /** - * Dispatch servlet requests to the Tuscany runtime - * - * @param req the ServletRequest object that contains the request the client made of the servlet - * @param res the ServletResponse object that contains the response the servlet returns to the client - * @throws ServletException if the request cannot be handled - * @throws IOException if an input or output error occurs while handling the request - */ - void service(ServletRequest req, ServletResponse res) throws ServletException, IOException; - -} diff --git a/branches/pre-spec-changes/kernel/host-api/src/test/java/org/apache/tuscany/host/rmi/RMIHostExceptionTestCase.java b/branches/pre-spec-changes/kernel/host-api/src/test/java/org/apache/tuscany/host/rmi/RMIHostExceptionTestCase.java deleted file mode 100644 index 0e62dbb3e1..0000000000 --- a/branches/pre-spec-changes/kernel/host-api/src/test/java/org/apache/tuscany/host/rmi/RMIHostExceptionTestCase.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.host.rmi; - -import junit.framework.TestCase; - -/** - * @version $Rev$ $Date$ - */ -public class RMIHostExceptionTestCase extends TestCase { - private static final Throwable CAUSE = new Throwable("Cause"); - private static final String MESSAGE = "Message"; - - public void testNoArgConstructor() { - Exception ex = new RMIHostException(); - assertNull(ex.getMessage()); - assertNull(ex.getCause()); - } - - public void testMessageConstructor() { - Exception ex = new RMIHostException(MESSAGE); - assertEquals(MESSAGE, ex.getMessage()); - assertNull(ex.getCause()); - } - - public void testThrowableConstructor() { - Exception ex = new RMIHostException(CAUSE); - assertEquals(CAUSE.getClass().getName() + ": " + CAUSE.getMessage(), ex.getMessage()); - assertEquals(CAUSE, ex.getCause()); - } - - public void testMessageThrowableConstructor() { - Exception ex = new RMIHostException(MESSAGE, CAUSE); - assertEquals(MESSAGE, ex.getMessage()); - assertEquals(CAUSE, ex.getCause()); - } - -} diff --git a/branches/pre-spec-changes/kernel/host-api/src/test/java/org/apache/tuscany/host/rmi/RMIHostRuntimeExceptionTestCase.java b/branches/pre-spec-changes/kernel/host-api/src/test/java/org/apache/tuscany/host/rmi/RMIHostRuntimeExceptionTestCase.java deleted file mode 100644 index 5071a68132..0000000000 --- a/branches/pre-spec-changes/kernel/host-api/src/test/java/org/apache/tuscany/host/rmi/RMIHostRuntimeExceptionTestCase.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.host.rmi; - -import junit.framework.TestCase; - -/** - * @version $Rev$ $Date$ - */ -public class RMIHostRuntimeExceptionTestCase extends TestCase { - private static final Throwable CAUSE = new Throwable("Cause"); - private static final String MESSAGE = "Message"; - - public void testNoArgConstructor() { - Exception ex = new RMIHostRuntimeException(); - assertNull(ex.getMessage()); - assertNull(ex.getCause()); - } - - public void testMessageConstructor() { - Exception ex = new RMIHostRuntimeException(MESSAGE); - assertSame(MESSAGE, ex.getMessage()); - assertNull(ex.getCause()); - } - - public void testThrowableConstructor() { - Exception ex = new RMIHostRuntimeException(CAUSE); - assertEquals(CAUSE.getClass().getName() + ": " + CAUSE.getMessage(), ex.getMessage()); - assertSame(CAUSE, ex.getCause()); - } - - public void testMessageThrowableConstructor() { - Exception ex = new RMIHostRuntimeException(MESSAGE, CAUSE); - assertSame(MESSAGE, ex.getMessage()); - assertSame(CAUSE, ex.getCause()); - } - -} diff --git a/branches/pre-spec-changes/kernel/pom.xml b/branches/pre-spec-changes/kernel/pom.xml deleted file mode 100644 index adca03452d..0000000000 --- a/branches/pre-spec-changes/kernel/pom.xml +++ /dev/null @@ -1,97 +0,0 @@ - - - - 4.0.0 - - org.apache.tuscany.sca - parent - 0.1-pre-spec-SNAPSHOT - - org.apache.tuscany.sca.kernel - parent - pom - Apache Tuscany SCA Kernel Sub-Project - 0.1-pre-spec-SNAPSHOT - - - - - apache.snapshots - Apache Snapshot Repository - http://people.apache.org/repo/m2-snapshot-repository - - false - - - true - - - - apache.incubator - Apache Incubator Repository - http://people.apache.org/repo/m2-incubating-repository/ - - true - - - false - - - - - - install - - - - - default - - true - - - api - host-api - spi - core - - - - - javadoc - - api - host-api - spi - - - - - org.apache.maven.plugins - maven-javadoc-plugin - - true - - - - - - - diff --git a/branches/pre-spec-changes/kernel/spi/.checkstyle b/branches/pre-spec-changes/kernel/spi/.checkstyle deleted file mode 100644 index 3e57539570..0000000000 --- a/branches/pre-spec-changes/kernel/spi/.checkstyle +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - diff --git a/branches/pre-spec-changes/kernel/spi/.pmd b/branches/pre-spec-changes/kernel/spi/.pmd deleted file mode 100644 index ffc4fe2bbb..0000000000 --- a/branches/pre-spec-changes/kernel/spi/.pmd +++ /dev/null @@ -1,20 +0,0 @@ - - -true diff --git a/branches/pre-spec-changes/kernel/spi/.ruleset b/branches/pre-spec-changes/kernel/spi/.ruleset deleted file mode 100644 index 3886f07f2d..0000000000 --- a/branches/pre-spec-changes/kernel/spi/.ruleset +++ /dev/null @@ -1,190 +0,0 @@ - - - - PMD Plugin preferences rule set - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/branches/pre-spec-changes/kernel/spi/LICENSE.txt b/branches/pre-spec-changes/kernel/spi/LICENSE.txt deleted file mode 100644 index 0084319535..0000000000 --- a/branches/pre-spec-changes/kernel/spi/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/branches/pre-spec-changes/kernel/spi/NOTICE.txt b/branches/pre-spec-changes/kernel/spi/NOTICE.txt deleted file mode 100644 index d83ebbe236..0000000000 --- a/branches/pre-spec-changes/kernel/spi/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/branches/pre-spec-changes/kernel/spi/pom.xml b/branches/pre-spec-changes/kernel/spi/pom.xml deleted file mode 100644 index 48d2479b41..0000000000 --- a/branches/pre-spec-changes/kernel/spi/pom.xml +++ /dev/null @@ -1,58 +0,0 @@ - - - - - org.apache.tuscany.sca.kernel - parent - 0.1-pre-spec-SNAPSHOT - - 4.0.0 - tuscany-spi - jar - Apache Tuscany SCA SPI - Tuscany Service Provider Interfaces. - - - - org.apache.tuscany.sca.kernel - tuscany-host-api - ${pom.version} - compile - - - - stax - stax-api - - - javax.servlet - servlet-api - - - - junit - junit - - - org.easymock - easymock - - - diff --git a/branches/pre-spec-changes/kernel/spi/src/doc/Context Model.emx b/branches/pre-spec-changes/kernel/spi/src/doc/Context Model.emx deleted file mode 100644 index 0445ea5a6b..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/doc/Context Model.emx +++ /dev/null @@ -1,673 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      - - - - - - -
      - - - - - - -
      - - - - - - -
      - - - - - - -
      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/AbstractLifecycle.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/AbstractLifecycle.java deleted file mode 100644 index e8597a55fc..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/AbstractLifecycle.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.spi; - -/** - * Base class providing a simple implementation of Lifecycle. - * - * @version $Rev$ $Date$ - */ -public abstract class AbstractLifecycle implements Lifecycle { - protected volatile int lifecycleState = UNINITIALIZED; - - public int getLifecycleState() { - return lifecycleState; - } - - /** - * Set the current state of the Lifecycle. - * - * @param lifecycleState the new state - */ - protected void setLifecycleState(int lifecycleState) { - this.lifecycleState = lifecycleState; - } - - public void start() { - setLifecycleState(RUNNING); - } - - public void stop() { - setLifecycleState(STOPPED); - } - - /** - * Returns the current lifecycle as a String (for example, "RUNNING"). - * - * @return the current lifecycle as a String - */ - public String toString() { - switch (lifecycleState) { - case Lifecycle.CONFIG_ERROR: - return "CONFIG_ERROR"; - case Lifecycle.ERROR: - return "ERROR"; - case Lifecycle.INITIALIZING: - return "INITIALIZING"; - case Lifecycle.INITIALIZED: - return "INITIALIZED"; - case Lifecycle.RUNNING: - return "RUNNING"; - case Lifecycle.STOPPING: - return "STOPPING"; - case Lifecycle.STOPPED: - return "STOPPED"; - case Lifecycle.UNINITIALIZED: - return "UNINITIALIZED"; - default: - return "UNKNOWN"; - } - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/CoreRuntimeException.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/CoreRuntimeException.java deleted file mode 100644 index 641a4e5d21..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/CoreRuntimeException.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.spi; - -import org.apache.tuscany.api.TuscanyRuntimeException; - -/** - * The root exception for the runtime package. Exceptions occurring in the runtime are generally non-recoverable - * - * @version $Rev$ $Date$ - */ -public abstract class CoreRuntimeException extends TuscanyRuntimeException { - - public CoreRuntimeException() { - super(); - } - - public CoreRuntimeException(String message) { - super(message); - } - - - protected CoreRuntimeException(String message, String identifier) { - super(message, identifier); - } - - public CoreRuntimeException(String message, Throwable cause) { - super(message, cause); - } - - - protected CoreRuntimeException(String message, String identifier, Throwable cause) { - super(message, identifier, cause); - } - - public CoreRuntimeException(Throwable cause) { - super(cause); - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/InvalidNameException.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/InvalidNameException.java deleted file mode 100644 index 28bc8652b2..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/InvalidNameException.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.spi; - -/** - * Denotes an invalid name - * - * @version $Rev$ $Date$ - */ -public class InvalidNameException extends CoreRuntimeException { - - public InvalidNameException() { - super(); - } - - public InvalidNameException(String message) { - super(message); - } - - public InvalidNameException(String message, Throwable cause) { - super(message, cause); - } - - public InvalidNameException(Throwable cause) { - super(cause); - } - -} - diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/Lifecycle.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/Lifecycle.java deleted file mode 100644 index e8a0448e44..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/Lifecycle.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.spi; - -/** - * Implementations adhere to runtime lifecycle semantics - * - * @version $Rev$ $Date$ - */ -public interface Lifecycle { - /* A configuration error state */ - int CONFIG_ERROR = -1; - /* Has not been initialized */ - int UNINITIALIZED = 0; - /* In the process of being configured and initialized */ - int INITIALIZING = 1; - /* Instantiated and configured */ - int INITIALIZED = 2; - /* Configured and initialized */ - int RUNNING = 4; - /* In the process of being shutdown */ - int STOPPING = 5; - /* Has been shutdown and removed from the composite */ - int STOPPED = 6; - /* In an error state */ - int ERROR = 7; - - /** - * Returns the lifecycle state - * - * @see #UNINITIALIZED - * @see #INITIALIZING - * @see #INITIALIZED - * @see #RUNNING - * @see #STOPPING - * @see #STOPPED - */ - int getLifecycleState(); - - /** - * Starts the Lifecycle. - * - * @throws CoreRuntimeException - */ - void start() throws CoreRuntimeException; - - /** - * Stops the Lifecycle. - * - * @throws CoreRuntimeException - */ - void stop() throws CoreRuntimeException; -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/ObjectCreationException.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/ObjectCreationException.java deleted file mode 100644 index 580e928000..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/ObjectCreationException.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.spi; - -import org.apache.tuscany.api.TuscanyRuntimeException; - -/** - * Denotes an error creating a new object instance - * - * @version $Rev$ $Date$ - */ -public class ObjectCreationException extends TuscanyRuntimeException { - private static final long serialVersionUID = -6423113430265944499L; - - public ObjectCreationException() { - super(); - } - - public ObjectCreationException(String message) { - super(message); - } - - public ObjectCreationException(String message, String identifier) { - super(message, identifier); - } - - public ObjectCreationException(String message, Throwable cause) { - super(message, cause); - } - - public ObjectCreationException(String message, String identifier, Throwable cause) { - super(message, identifier, cause); - } - - public ObjectCreationException(Throwable cause) { - super(cause); - } - -} - diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/ObjectFactory.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/ObjectFactory.java deleted file mode 100644 index d505e14f61..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/ObjectFactory.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.spi; - -/** - * Implementations create new instances of a particular type - * - * @version $Rev$ $Date$ - */ -public interface ObjectFactory { - - /** - * Return a instance of the type that this factory creates. - * - * @return a instance from this factory - */ - T getInstance() throws ObjectCreationException; - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/QualifiedName.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/QualifiedName.java deleted file mode 100644 index 575f69db18..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/QualifiedName.java +++ /dev/null @@ -1,96 +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.spi; - -/** - * An evaluated name consisting of a part/port pair. In the runtime, a part generally 'contains' or 'provides' ports - * such as a component/service point or a component/reference pair. - * - * @version $Rev$ $Date$ - */ -public class QualifiedName { - public static final String NAME_SEPARATOR = "/"; - - private String qName; - private String partName; - private String portName; - - /** - * Constructs a new qualified name in the form of part/port where part is the parent context and port represents a - * child, which is either a service in the case of an atomic context or a contained context in the case of a - * composite. - * - * @throws InvalidNameException if the name is in an invalid format - */ - public QualifiedName(String qualifiedName) throws InvalidNameException { - if (qualifiedName == null) { - return; - } - int pos = qualifiedName.indexOf(QualifiedName.NAME_SEPARATOR); - switch (pos) { - case-1: - partName = qualifiedName; - break; - case 0: - throw new InvalidNameException(qualifiedName); - default: - partName = qualifiedName.substring(0, pos); - portName = qualifiedName.substring(pos + 1); - break; - } - qName = qualifiedName; - } - - /** - * Constructs a qualified name using the given part/port combination - * - * @param partName the part name - * @param portName the port name - */ - public QualifiedName(String partName, String portName) { - this.partName = partName; - this.portName = portName; - this.qName = partName + '/' + portName; - } - - /** - * Returns the parsed part name - */ - public String getPartName() { - return partName; - } - - /** - * Returns the parsed port name if the original is of the compound for part/port - */ - public String getPortName() { - return portName; - } - - /** - * Returns the full part/port name pair - */ - public String getQualifiedName() { - return qName; - } - - public String toString() { - return qName; - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/annotation/Autowire.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/annotation/Autowire.java deleted file mode 100644 index 0e48f1bc1b..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/annotation/Autowire.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.spi.annotation; - -import static java.lang.annotation.ElementType.FIELD; -import static java.lang.annotation.ElementType.METHOD; -import static java.lang.annotation.ElementType.PARAMETER; -import java.lang.annotation.Retention; -import static java.lang.annotation.RetentionPolicy.RUNTIME; -import java.lang.annotation.Target; - -/** - * A system annotation to inject an autowired instance - * - * @version $Rev$ $Date$ - */ -@Target({METHOD, FIELD, PARAMETER}) -@Retention(RUNTIME) -public @interface Autowire { - /** - * The name of the autowire. If not specified then the name will be derived from the annotated field. - */ - String name() default ""; - - /** - * Indicates if a reference must be specified. - */ - boolean required() default true; - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/bootstrap/ComponentNames.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/bootstrap/ComponentNames.java deleted file mode 100644 index fb207a35d5..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/bootstrap/ComponentNames.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.spi.bootstrap; - -/** - * Class that defines the names of well known component - * - * @version $Rev$ $Date$ - */ -public final class ComponentNames { - /** - * The name of the component that forms the root of the runtime tree. - */ - public static final String TUSCANY_RUNTIME = "tuscany.runtime"; - - /** - * The name of the component that is the root of the application composite tree. - */ - public static final String TUSCANY_APPLICATION_ROOT = "tuscany.root.application"; - - /** - * The name of the component that is the root of the system composite tree. - */ - public static final String TUSCANY_SYSTEM_ROOT = "tuscany.root.system"; - - /** - * The name of the top-level component in the system composite tree. - */ - public static final String TUSCANY_SYSTEM = "tuscany.system"; - - /** - * The name of the component that contains the deployer. - */ - public static final String TUSCANY_DEPLOYER = "deployer"; - - /** - * The name of the component that contains the deployer. - */ - public static final String TUSCANY_WIRE_SERVICE = "wireService"; - - private ComponentNames() { - } - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/bootstrap/RuntimeComponent.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/bootstrap/RuntimeComponent.java deleted file mode 100644 index 6e0184fbd6..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/bootstrap/RuntimeComponent.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.spi.bootstrap; - -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.component.TargetException; -import org.apache.tuscany.spi.deployer.Deployer; - -/** - * Interface that represents the Tuscany runtime. - * - * @version $Rev$ $Date$ - */ -public interface RuntimeComponent extends CompositeComponent { - /** - * Returns the component that forms the root of the user component tree. All user components will be managed by - * composites that are children of this root. - * - * @return the root of the user component tree - */ - CompositeComponent getRootComponent(); - - /** - * Returns the component that forms the root of the system component tree. All system components, components that - * provide system services needed by the Tuscany runtime itself, will be managed by composites that are children of - * this root. - * - * @return the root of the system component tree - */ - CompositeComponent getSystemComponent(); - - /** - * Returns the deployer for this runtime. This interface can be used to deploy new SCA bundles to the runtime. - * - * @return the deployer for this runtime - * @throws TargetException if there is an error returning the deployer - */ - Deployer getDeployer() throws TargetException; -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/BindingBuilder.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/BindingBuilder.java deleted file mode 100644 index 50c7cae857..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/BindingBuilder.java +++ /dev/null @@ -1,57 +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.spi.builder; - -import org.apache.tuscany.spi.component.CompositeComponent; -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.model.BindingDefinition; -import org.apache.tuscany.spi.model.BoundReferenceDefinition; -import org.apache.tuscany.spi.model.BoundServiceDefinition; - -/** - * Responsible for processing a service or reference in an assembly configured with a particular binding. The builder - * will create and return corresponding {@link org.apache.tuscany.spi.component.ServiceBinding} or {@link - * org.apache.tuscany.spi.component.ReferenceBinding} - * - * @version $Rev$ $Date$ - */ -public interface BindingBuilder { - - /** - * Creates a service binding - * - * @param parent the containing composite component - * @param boundServiceDefinition the service the binding is configured for - * @param bindingDefinition the binding definition - * @param deploymentContext the current deployment context - * @return a service binding - * @throws BuilderException - */ - ServiceBinding build(CompositeComponent parent, - BoundServiceDefinition boundServiceDefinition, - B bindingDefinition, - DeploymentContext deploymentContext) throws BuilderException; - - ReferenceBinding build(CompositeComponent parent, - BoundReferenceDefinition boundReferenceDefinition, - B bindingDefinition, - DeploymentContext deploymentContext) throws BuilderException; -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/Builder.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/Builder.java deleted file mode 100644 index f0d2a5f4e5..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/Builder.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.spi.builder; - -import org.apache.tuscany.spi.component.Component; -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.component.Reference; -import org.apache.tuscany.spi.component.Service; -import org.apache.tuscany.spi.deployer.DeploymentContext; -import org.apache.tuscany.spi.model.BoundReferenceDefinition; -import org.apache.tuscany.spi.model.BoundServiceDefinition; -import org.apache.tuscany.spi.model.ComponentDefinition; -import org.apache.tuscany.spi.model.Implementation; - -/** - * Implementations build SCAObject types from model objects. - * - * @version $Rev$ $Date$ - */ -public interface Builder { - /** - * Builds a Component from a ComponentDefinition - * - * @param parent the composite that will be the parent of the newly built component - * @param definition the component definition as parsed from an SCA assembly - * @param context the current deployment context - * @return the newly created component - * @throws BuilderException - */ - > Component build(CompositeComponent parent, - ComponentDefinition definition, - DeploymentContext context) throws BuilderException; - - /** - * Builds a Service and its bindings from a BoundServiceDefinition - * - * @param parent the composite that will be the parent of the newly built service - * @param definition the service definition as parsed from an SCA assembly - * @param context the current deployment context - * @return the newly created service - * @throws BuilderException - */ - Service build(CompositeComponent parent, BoundServiceDefinition definition, DeploymentContext context) - throws BuilderException; - - /** - * Builds a Reference and its bindings from a BoundReferenceDefinition - * - * @param parent the composite that will be the parent of the newly built reference - * @param definition the reference definition as parsed from an SCA assembly - * @param context the current deployment context - * @return the newly created reference - * @throws BuilderException - */ - Reference build(CompositeComponent parent, BoundReferenceDefinition definition, DeploymentContext context) - throws BuilderException; - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/BuilderConfigException.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/BuilderConfigException.java deleted file mode 100644 index 6e9f2ef95d..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/BuilderConfigException.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.spi.builder; - -/** - * Represents an error processing an assembly model - * - * @version $Rev$ $Date$ - */ -public class BuilderConfigException extends BuilderException { - - public BuilderConfigException() { - super(); - } - - public BuilderConfigException(String message) { - super(message); - } - - public BuilderConfigException(String message, String identifier) { - super(message, identifier); - } - - public BuilderConfigException(String message, Throwable cause) { - super(message, cause); - } - - public BuilderConfigException(Throwable cause) { - super(cause); - } - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/BuilderException.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/BuilderException.java deleted file mode 100644 index 846d52492c..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/BuilderException.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.spi.builder; - -import org.apache.tuscany.api.TuscanyException; - -/** - * The root exception for the builder package. Builder exceptions denote a non-recoverable failure. - * - * @version $Rev$ $Date$ - */ -public abstract class BuilderException extends TuscanyException { - - public BuilderException() { - super(); - } - - public BuilderException(String message) { - super(message); - } - - - protected BuilderException(String message, String identifier) { - super(message, identifier); - } - - public BuilderException(String message, Throwable cause) { - super(message, cause); - } - - protected BuilderException(String message, String identifier, Throwable cause) { - super(message, identifier, cause); - } - - public BuilderException(Throwable cause) { - super(cause); - } - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/BuilderInstantiationException.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/BuilderInstantiationException.java deleted file mode 100644 index 30957635db..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/BuilderInstantiationException.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.spi.builder; - -/** - * Denotes an error instantiating an SCAObject - * - * @version $Rev$ $Date$ - */ -public class BuilderInstantiationException extends BuilderException { - - public BuilderInstantiationException(String message, String identifier) { - super(message, identifier); - } - - public BuilderInstantiationException(String message, Throwable cause) { - super(message, cause); - } - - public BuilderInstantiationException(String message, String identifier, Throwable cause) { - super(message, identifier, cause); - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/BuilderRegistry.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/BuilderRegistry.java deleted file mode 100644 index c4ecdfa35b..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/BuilderRegistry.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.spi.builder; - -import org.apache.tuscany.spi.model.BindingDefinition; -import org.apache.tuscany.spi.model.Implementation; - -/** - * Maintains a registry of builders in the runtime, dispatching to the appropriate one as an assembly model is processed - * into runtime artifacts - * - * @version $Rev$ $Date$ - */ -public interface BuilderRegistry extends Builder { - - /** - * Register a builder for an implementation type. - * - * @param implClass the type of implementation that this builder can handle - * @param builder the builder to be registered - */ - > void register(Class implClass, ComponentBuilder builder); - - /** - * Unregister a builder for an implementation type. - * - * @param implClass the implementation whose builder should be unregistered - */ - > void unregister(Class implClass); - - /** - * Register a binding builder for a binding type - * - * @param implClass the binding type - * @param builder the buinder to be registered - */ - void register(Class implClass, BindingBuilder builder); - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/ComponentBuilder.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/ComponentBuilder.java deleted file mode 100644 index 668cee77e6..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/ComponentBuilder.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.spi.builder; - -import org.apache.tuscany.spi.component.Component; -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.deployer.DeploymentContext; -import org.apache.tuscany.spi.model.ComponentDefinition; -import org.apache.tuscany.spi.model.Implementation; - -/** - * Responsible for building a {@link Component} from an atomic or composite component configured in an assembly - * - * @version $Rev$ $Date$ - */ -public interface ComponentBuilder> { - Component build(CompositeComponent parent, - ComponentDefinition componentDefinition, - DeploymentContext deploymentContext) throws BuilderException; -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/Connector.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/Connector.java deleted file mode 100644 index b11aacc47e..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/Connector.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.spi.builder; - -import org.apache.tuscany.spi.component.SCAObject; -import org.apache.tuscany.spi.wire.InboundWire; -import org.apache.tuscany.spi.wire.OutboundWire; - -/** - * Implementations are responsible for bridging invocation chains as an assembly is converted to runtime artifacts - * - * @version $$Rev$$ $$Date$$ - */ -public interface Connector { - - /** - * Connects the given source's wires to corresponding wires to a target. Wires are connected by bridging invocation - * chains. - * - * @param source the source, i.e. a ServiceBinding, Component, or Reference - * @throws WiringException - */ - void connect(SCAObject source) throws WiringException; - - /** - * Bridges the invocation chains associated with an inbound and outbound wire. - * - * @param inbound the wire to bridge from - * @param outbound the target wire - * @param optimizable if the bridge may be optimized - * @throws WiringException - */ - void connect(InboundWire inbound, OutboundWire outbound, boolean optimizable) - throws WiringException; - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/InvalidServiceInterfaceException.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/InvalidServiceInterfaceException.java deleted file mode 100644 index 78bb5a5cc8..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/InvalidServiceInterfaceException.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.spi.builder; - -/** - * @version $Rev$ $Date$ - */ -public class InvalidServiceInterfaceException extends BuilderConfigException { - private final Class interfaceClass; - - public InvalidServiceInterfaceException(String message, Class interfaceClass) { - super(message); - this.interfaceClass = interfaceClass; - } - - public Class getInterfaceClass() { - return interfaceClass; - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/MissingWireTargetException.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/MissingWireTargetException.java deleted file mode 100644 index 5a0b046430..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/MissingWireTargetException.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.spi.builder; - -/** - * Denotes a missing wire target in an assembly - * - * @version $Rev$ $Date$ - */ -public class MissingWireTargetException extends WiringException { - - public MissingWireTargetException(String message) { - super(message); - } - - public MissingWireTargetException(String message, String identifier) { - super(message, identifier); - } - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/ScopeNotFoundException.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/ScopeNotFoundException.java deleted file mode 100644 index acf8dadda6..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/ScopeNotFoundException.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.spi.builder; - -/** - * @version $Rev$ $Date$ - */ -public class ScopeNotFoundException extends BuilderConfigException { - - public ScopeNotFoundException(String scope) { - super("Scope not found", scope); - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/WiringException.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/WiringException.java deleted file mode 100644 index d5e17919fd..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/WiringException.java +++ /dev/null @@ -1,124 +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.spi.builder; - -/** - * Denotes a general error raised during wiring - * - * @version $Rev$ $Date$ - */ -public abstract class WiringException extends BuilderException { - private String sourceName; - private String referenceName; - private String targetName; - private String targetServiceName; - - protected WiringException(String message) { - super(message); - } - - protected WiringException(String message, String identifier) { - super(message, identifier); - } - - protected WiringException(String message, Throwable cause) { - super(message, cause); - } - - protected WiringException(String message, String identifier, Throwable cause) { - super(message, identifier, cause); - } - - protected WiringException(Throwable cause) { - super(cause); - } - - /** - * Returns the source name for the wire - * - * @return the source name the source name for the wire - */ - public String getSourceName() { - return sourceName; - } - - /** - * Sets the source name for the wire - * - * @param sourceName the source name for the wire - */ - public void setSourceName(String sourceName) { - this.sourceName = sourceName; - } - - /** - * Returns the target name for the wire - * - * @return the target name the source name for the wire - */ - public String getTargetName() { - return targetName; - } - - /** - * Sets the target name for the wire - * - * @param targetName the source name for the wire - */ - public void setTargetName(String targetName) { - this.targetName = targetName; - } - - - /** - * Returns the source reference name for the wire - * - * @return the source reference name for the wire - */ - public String getReferenceName() { - return referenceName; - } - - /** - * Sets the source reference name for the wire - * - * @param referenceName the source reference name for the wire - */ - public void setReferenceName(String referenceName) { - this.referenceName = referenceName; - } - - /** - * Returns the target service name for the wire - * - * @return the target service name for the wire - */ - public String getTargetServiceName() { - return targetServiceName; - } - - /** - * Sets the target service name for the wire - * - * @param targetServiceName the target service name for the wire - */ - public void setTargetServiceName(String targetServiceName) { - this.targetServiceName = targetServiceName; - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/AbstractSCAObject.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/AbstractSCAObject.java deleted file mode 100644 index de98aa4437..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/AbstractSCAObject.java +++ /dev/null @@ -1,134 +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.spi.component; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.CopyOnWriteArrayList; - -import org.apache.tuscany.spi.AbstractLifecycle; -import org.apache.tuscany.spi.event.Event; -import org.apache.tuscany.spi.event.EventFilter; -import org.apache.tuscany.spi.event.RuntimeEventListener; -import org.apache.tuscany.spi.event.TrueFilter; - -/** - * Functionality common to all SCAObject implementations - * - * @version $Rev$ $Date$ - */ -public abstract class AbstractSCAObject extends AbstractLifecycle implements SCAObject { - protected static final EventFilter TRUE_FILTER = new TrueFilter(); - - protected Map> listeners; - protected final CompositeComponent parent; - private final String name; - private final Map extensions = new HashMap(); - private String canonicalName; - - public AbstractSCAObject(String name, CompositeComponent parent) { - this.name = name; - this.parent = parent; - } - - public String getName() { - return name; - } - - public String getCanonicalName() { - if (canonicalName == null) { - StringBuffer b = new StringBuffer(name); - if (parent != null) { - b.insert(0, parent.getCanonicalName() + "/"); - } - canonicalName = b.toString(); - } - return canonicalName; - } - - public CompositeComponent getParent() { - return parent; - } - - public void addListener(RuntimeEventListener listener) { - addListener(TRUE_FILTER, listener); - } - - public void removeListener(RuntimeEventListener listener) { - assert listener != null : "Listener cannot be null"; - synchronized (getListeners()) { - for (List currentList : getListeners().values()) { - for (RuntimeEventListener current : currentList) { - if (current == listener) { - currentList.remove(current); - return; - } - } - } - } - } - - public void addListener(EventFilter filter, RuntimeEventListener listener) { - assert listener != null : "Listener cannot be null"; - synchronized (getListeners()) { - List list = getListeners().get(filter); - if (list == null) { - list = new CopyOnWriteArrayList(); - listeners.put(filter, list); - } - list.add(listener); - } - } - - public void publish(Event event) { - assert event != null : "Event object was null"; - for (Map.Entry> entry : getListeners().entrySet()) { - if (entry.getKey().match(event)) { - for (RuntimeEventListener listener : entry.getValue()) { - listener.onEvent(event); - } - } - } - } - - protected Map> getListeners() { - if (listeners == null) { - listeners = new ConcurrentHashMap>(); - } - return listeners; - } - - public void prepare() throws PrepareException { - - } - - public String toString() { - return "[" + name + "] in state [" + super.toString() + ']'; - } - - public Map getExtensions() { - return extensions; - } - - public boolean isSystem() { - return false; - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/AtomicComponent.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/AtomicComponent.java deleted file mode 100644 index aa4c41889b..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/AtomicComponent.java +++ /dev/null @@ -1,126 +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.spi.component; - -import java.util.List; - -import org.apache.tuscany.spi.ObjectCreationException; -import org.apache.tuscany.spi.wire.InboundWire; -import org.apache.tuscany.spi.wire.OutboundWire; - -/** - * The runtime instantiation of an SCA atomic, or leaf-type, component - * - * @version $Rev$ $Date$ - */ -public interface AtomicComponent extends Component { - - /** - * Returns true if component instances should be eagerly initialized. - * - * @return true if component instances should be eagerly initialized - */ - boolean isEagerInit(); - - /** - * Returns true if component instances receive destroy events. - * - * @return true if component instances receive destroy events - */ - boolean isDestroyable(); - - /** - * Returns the initialization level for this component. - * - * @return the initialization level for this component - */ - int getInitLevel(); - - /** - * Returns the idle time allowed between operations in milliseconds if the implementation is conversational. - * - * @return the idle time allowed between operations in milliseconds if the implementation is conversational - */ - long getMaxIdleTime(); - - /** - * Returns the maximum age a conversation may remain active in milliseconds if the implementation is - * conversational. - * - * @return the maximum age a conversation may remain active in milliseconds if the implementation is conversational - */ - long getMaxAge(); - - /** - * Adds a target-side wire. Target-side wire factories contain the invocation chains associated with the destination - * service of a wire - */ - void addInboundWire(InboundWire wire); - - /** - * Adds a source-side wire for the given reference. Source-side wires contain the invocation chains for a reference - * in the implementation associated with the instance wrapper created by this configuration. - */ - void addOutboundWire(OutboundWire wire); - - /** - * Adds a set of source-side multiplicity wires for the given reference. Source-side wires contain the invocation - * chains for a reference in the implementation associated with the instance wrapper created by this configuration. - */ - void addOutboundWires(List wires); - - /** - * Notifies the given instance of an initialization event. - * - * @throws TargetInitializationException - */ - void init(Object instance) throws TargetInitializationException; - - /** - * Notifies the given instance of a destroy event. - * - * @throws TargetDestructionException - */ - void destroy(Object instance) throws TargetDestructionException; - - /** - * Creates a new implementation instance, generally used as a callback by a {@link - * org.apache.tuscany.spi.component.ScopeContainer}. - * - * @return the instance - * @throws ObjectCreationException - */ - Object createInstance() throws ObjectCreationException; - - /** - * Removes an implementation instance associated with the current invocation context. - * - * @throws ComponentException - */ - void removeInstance() throws ComponentException; - - /** - * Returns the target instance associated with the component. A target instance is the actual object a request is - * dispatched to sans wire chain. - * - * @throws TargetResolutionException - */ - Object getTargetInstance() throws TargetResolutionException; - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/Component.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/Component.java deleted file mode 100644 index ec4eedfe90..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/Component.java +++ /dev/null @@ -1,100 +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.spi.component; - -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import org.apache.tuscany.spi.model.Operation; -import org.apache.tuscany.spi.model.PropertyValue; -import org.apache.tuscany.spi.wire.InboundWire; -import org.apache.tuscany.spi.wire.OutboundWire; -import org.apache.tuscany.spi.wire.TargetInvoker; - -/** - * The runtime instantiation of an SCA component - * - * @version $$Rev$$ $$Date$$ - */ -public interface Component extends SCAObject { - - /** - * Sets the scope container associated with the component - * - * @param scopeContainer the scope container associated with the component - */ - void setScopeContainer(ScopeContainer scopeContainer); - - /** - * Returns the default property values associated with the component. - * - * @return default property values associated with the component. - */ - Map> getDefaultPropertyValues(); - - /** - * Sets the default property values associated with the component. - * - * @param defaultPropertyValues Default property values associated with the component. - */ - void setDefaultPropertyValues(Map> defaultPropertyValues); - - /** - * Returns true if invocation dispatching can be optimized, i.e. invocation chains are not required - * - * @return true if invocation dispatching can be optimized, i.e. invocation chains are not required - */ - boolean isOptimizable(); - - /** - * Returns the wire associated with the given service name or null if not found. - * - * @return the wire associated with the given service name or null if not found. - */ - InboundWire getInboundWire(String serviceName); - - /** - * Returns a map of inbound wires. - * - * @return a map of inbound wires. - */ - Collection getInboundWires(); - - /** - * Returns a map of source-side wires for references. There may be 1..n wires per reference. - * - * @return a map of source-side wires for references. - */ - Map> getOutboundWires(); - - /** - * Callback to create a {@link org.apache.tuscany.spi.wire.TargetInvoker} which dispatches to a service offered by - * the component - * - * @param targetName the service name - * @param operation the operation to invoke - * @param callbackWire the callback wire or null if the associated wire is unidirectional - * @return the target invoker - * @throws TargetInvokerCreationException - */ - TargetInvoker createTargetInvoker(String targetName, Operation operation, InboundWire callbackWire) - throws TargetInvokerCreationException; - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ComponentException.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ComponentException.java deleted file mode 100644 index 2007cbb6bc..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ComponentException.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.spi.component; - -import org.apache.tuscany.api.TuscanyException; - -/** - * An checked exception encountered by an {@link org.apache.tuscany.spi.component.Component} - * - * @version $Rev$ $Date$ - */ -public abstract class ComponentException extends TuscanyException { - - protected ComponentException() { - } - - protected ComponentException(String message) { - super(message); - } - - protected ComponentException(String message, String identifier) { - super(message, identifier); - } - - protected ComponentException(String message, Throwable cause) { - super(message, cause); - } - - protected ComponentException(String message, String identifier, Throwable cause) { - super(message, identifier, cause); - } - - protected ComponentException(Throwable cause) { - super(cause); - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ComponentRegistrationException.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ComponentRegistrationException.java deleted file mode 100644 index f34fda47a2..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ComponentRegistrationException.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.spi.component; - -/** - * Thrown when an error is encountered registering a component - * - * @version $$Rev$$ $$Date$$ - */ -public abstract class ComponentRegistrationException extends ComponentException { - public ComponentRegistrationException() { - } - - public ComponentRegistrationException(String message) { - super(message); - } - - public ComponentRegistrationException(String message, String identifier) { - super(message, identifier); - } - - public ComponentRegistrationException(String message, Throwable cause) { - super(message, cause); - } - - public ComponentRegistrationException(Throwable cause) { - super(cause); - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ComponentRuntimeException.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ComponentRuntimeException.java deleted file mode 100644 index 8479681c75..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ComponentRuntimeException.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.spi.component; - -import org.apache.tuscany.spi.CoreRuntimeException; - -/** - * An unchecked exception encountered by an {@link org.apache.tuscany.spi.component.Component} - * - * @version $Rev$ $Date$ - */ -public abstract class ComponentRuntimeException extends CoreRuntimeException { - - public ComponentRuntimeException() { - super(); - } - - public ComponentRuntimeException(String message) { - super(message); - } - - public ComponentRuntimeException(String message, String identifier) { - super(message, identifier); - } - - public ComponentRuntimeException(String message, Throwable cause) { - super(message, cause); - } - - public ComponentRuntimeException(String message, String identifier, Throwable cause) { - super(message, identifier, cause); - } - - public ComponentRuntimeException(Throwable cause) { - super(cause); - } - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/CompositeComponent.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/CompositeComponent.java deleted file mode 100644 index 0f73fbfac5..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/CompositeComponent.java +++ /dev/null @@ -1,156 +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.spi.component; - -import java.util.List; -import java.util.Collection; - -import org.w3c.dom.Document; - -import org.apache.tuscany.spi.event.RuntimeEventListener; -import org.apache.tuscany.spi.services.management.TuscanyManagementService; -import org.apache.tuscany.spi.wire.InboundWire; - -/** - * The runtime instantiation of an SCA composite component. Composites may contain child components, offer services, and - * have references. Children are contained in two namespaces, an application namespace for end-user components deployed - * to a runtime, and a system namespace for components that provide system services. - * - * @version $Rev$ $Date$ - */ -public interface CompositeComponent extends Component, RuntimeEventListener { - - /** - * Sets the management service associated with the composite - * - * @param managementService the management service associated with the composite - */ - void setManagementService(TuscanyManagementService managementService); - - /** - * Returns the value of a Property of this composite. - * - * @param name the name of the Property - * @return its value, or null if there is not such property or if it has no defined value - */ - Document getPropertyValue(String name); - - /** - * Registers a child of this composite. - * - * @param object the object to add as a child - * @throws ComponentRegistrationException - */ - void register(SCAObject object) throws ComponentRegistrationException; - - /** - * Returns the internal system wire associated with the given service name or null if not found - * - * @param serviceName the service name - * @return the system wire or null if not found - */ - InboundWire getInboundSystemWire(String serviceName); - - /** - * Returns a map of inbound system wires. - * - * @return a map of inbound system wires. - */ - Collection getInboundSystemWires(); - - - /** - * Register a simple Java Object as a system component. This is primarily intended for use by bootstrap code to - * create the initial configuration components. - * - * @param name the name of the resulting component - * @param service the service interface the component should expose - * @param instance the Object that will become the component's implementation - * @throws ComponentRegistrationException - */ - void registerJavaObject(String name, Class service, I instance) - throws ComponentRegistrationException; - - /** - * Register a simple Java Object as a system component. This is primarily intended for use by bootstrap code to - * create the initial configuration components. - * - * @param name the name of the resulting component - * @param services the service interfaces the component should expose - * @param instance the Object that will become the component's implementation - * @throws ComponentRegistrationException - */ - void registerJavaObject(String name, List> services, I instance) - throws ComponentRegistrationException; - - /** - * Returns the child associated with a given name - */ - SCAObject getChild(String name); - - /** - * Returns the system child associated with a given name - */ - SCAObject getSystemChild(String name); - - /** - * Invoked by child components to return an wire to a target based on matching type. Resolved targets may be - * serviceBindings or components in the parent or its ancestors, or references in a sibling component - * - * @param instanceInterface the type of service being requested - * @return a reference to the requested service or null if one is not be found - * @throws TargetResolutionException - */ - InboundWire resolveAutowire(Class instanceInterface) throws TargetResolutionException; - - /** - * Invoked by system child components to return a wire to a system target based on matching type. Resolved targets - * may be system serviceBindings or components in the parent or its ancestors, or references in a sibling component - * - * @param instanceInterface the type of service being requested - * @return a reference to the requested service or null if one is not be found - * @throws TargetResolutionException - */ - InboundWire resolveSystemAutowire(Class instanceInterface) throws TargetResolutionException; - - /** - * Invoked by a parent component to return an wire to a target in a child based on matching type. Resolved targets - * must be serviceBindings. For example, given a parent P and two siblings, A and B, A would request an autowire by - * invoking {@link #resolveAutowire(Class)} on P, which in turn could invoke the present method on B in order to - * resolve a target. - * - * @param instanceInterface the type of service being requested - * @return a reference to the requested service or null if one is not be found - * @throws TargetResolutionException - */ - InboundWire resolveExternalAutowire(Class instanceInterface) throws TargetResolutionException; - - /** - * Invoked by a parent component to return a wire to a system target in a child based on matching type. Resolved - * targets must be system serviceBindings. For example, given a parent P and two siblings, A and B, A would request - * an autowire by invoking {@link #resolveAutowire(Class)} on P, which in turn could invoke the present method on - * B in order to resolve a target. - * - * @param instanceInterface the type of service being requested - * @return a reference to the requested service or null if one is not be found - * @throws TargetResolutionException - */ - InboundWire resolveSystemExternalAutowire(Class instanceInterface) throws TargetResolutionException; - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/DuplicateNameException.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/DuplicateNameException.java deleted file mode 100644 index 128f301256..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/DuplicateNameException.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.spi.component; - -/** - * Denotes an attempt to add an child to a composite component with a name equal to an existing child - * - * @version $Rev$ $Date$ - */ -public class DuplicateNameException extends ComponentRegistrationException { - - public DuplicateNameException(String message) { - super(message); - } - - public DuplicateNameException(String message, String identifier) { - super(message, identifier); - } - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/IllegalTargetException.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/IllegalTargetException.java deleted file mode 100644 index 7eb37c3639..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/IllegalTargetException.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.spi.component; - -/** - * Thrown when a target for an operation is not of the required type - * - * @version $$Rev$$ $$Date$$ - */ -public class IllegalTargetException extends TargetResolutionException { - - public IllegalTargetException(String message, String identifier) { - super(message, identifier); - } - - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/InvalidAutowireInterface.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/InvalidAutowireInterface.java deleted file mode 100644 index ffda730a27..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/InvalidAutowireInterface.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.spi.component; - -/** - * Thrown when an invalid interface is specified during autowire registration - * - * @version $Rev$ $Date$ - */ -public class InvalidAutowireInterface extends ComponentRegistrationException { - - public InvalidAutowireInterface(String message, String identifier) { - super(message, identifier); - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/InvalidConversationSequenceException.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/InvalidConversationSequenceException.java deleted file mode 100644 index 21a1712e1a..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/InvalidConversationSequenceException.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.spi.component; - -/** - * Denotes an unknown operation sequence in a conversation - * - * @version $Rev$ $Date$ - */ -public class InvalidConversationSequenceException extends TargetInvocationException { - - public InvalidConversationSequenceException(String message, String identifier) { - super(message, identifier); - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/PersistenceException.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/PersistenceException.java deleted file mode 100644 index 06940aaff7..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/PersistenceException.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.spi.component; - -/** - * Raised when an error persisting a component implementation instance is encountered - * - * @version $Rev$ $Date$ - */ -public class PersistenceException extends ComponentException { - public PersistenceException() { - } - - public PersistenceException(String message) { - super(message); - } - - public PersistenceException(String message, Throwable cause) { - super(message, cause); - } - - public PersistenceException(Throwable cause) { - super(cause); - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/PrepareException.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/PrepareException.java deleted file mode 100644 index d2be6daadf..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/PrepareException.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.spi.component; - -/** - * Denotes an exception preparing a component - * - * @version $Rev$ $Date$ - */ -public class PrepareException extends ComponentException { - - public PrepareException(String message, String identifier) { - super(message, identifier); - } - - public PrepareException(String message, String identifier, Throwable cause) { - super(message, identifier, cause); - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ReactivationException.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ReactivationException.java deleted file mode 100644 index 4ef0929422..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ReactivationException.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.spi.component; - -/** - * Raised when an error is encountered reactivating a serialized instance - * - * @version $Rev$ $Date$ - */ -public class ReactivationException extends ComponentRuntimeException { - private String owner; - - public ReactivationException(String message) { - super(message); - } - - public ReactivationException(String message, String identifier, String ower) { - super(message, identifier); - this.owner = ower; - } - - public ReactivationException(Throwable cause) { - super(cause); - } - - public String getOwner() { - return owner; - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/Reference.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/Reference.java deleted file mode 100644 index 2b3ef4be30..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/Reference.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.apache.tuscany.spi.component; - -import java.util.List; - -import org.apache.tuscany.spi.model.ServiceContract; - -/** - * The runtime instantiation of an SCA reference - * - * @version $Rev$ $Date$ - */ -public interface Reference extends SCAObject { - - /** - * Returns the contract for the reference. - * - * @return the contract for the reference. - */ - ServiceContract getServiceContract(); - - /** - * Returns the collection of bindings configured for the reference. - * - * @return the collection of bindings configured for the reference. - */ - List getReferenceBindings(); - - /** - * Adds a binding the reference is configured with. - * - * @param binding the binding the reference is configured with. - */ - void addReferenceBinding(ReferenceBinding binding); -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ReferenceBinding.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ReferenceBinding.java deleted file mode 100644 index 82a2105a36..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ReferenceBinding.java +++ /dev/null @@ -1,88 +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.spi.component; - -import javax.xml.namespace.QName; - -import org.apache.tuscany.spi.model.Operation; -import org.apache.tuscany.spi.model.ServiceContract; -import org.apache.tuscany.spi.wire.InboundWire; -import org.apache.tuscany.spi.wire.OutboundWire; -import org.apache.tuscany.spi.wire.TargetInvoker; - -/** - * Manages an SCA reference configured with a binding - * - * @version $Rev$ $Date$ - */ -public interface ReferenceBinding extends SCAObject { - - /** - * Returns the binding qualified name - * - * @return the binding qualified name - */ - QName getBindingType(); - - /** - * Sets the parent reference for the binding - * - * @param reference the parent reference for the binding - */ - void setReference(Reference reference); - - /** - * Returns the inbound wire for flowing a request through the reference - */ - InboundWire getInboundWire(); - - /** - * Sets the inbound wire for flowing a request through the reference - */ - void setInboundWire(InboundWire wire); - - /** - * Returns the outbound wire used by the reference to connect to a target - */ - OutboundWire getOutboundWire(); - - /** - * Sets the outbound wire used by the reference to connect to a target - */ - void setOutboundWire(OutboundWire wire); - - /** - * Callback to create a {@link org.apache.tuscany.spi.wire.TargetInvoker} which dispatches to the target service of - * the reference - * - * @param contract the service contract to invoke on - * @param operation the operation to invoke - * @throws TargetInvokerCreationException - */ - TargetInvoker createTargetInvoker(ServiceContract contract, Operation operation) - throws TargetInvokerCreationException; - - /** - * Returns the service contract for the binding - * - * @return the service contract for the binding - */ - ServiceContract getBindingServiceContract(); - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/SCAExternalizable.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/SCAExternalizable.java deleted file mode 100644 index 6454e66369..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/SCAExternalizable.java +++ /dev/null @@ -1,43 +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.spi.component; - -/** - * A serialization contract for runtime SCA artifacts. When an instance is deserialized, runtime services defined in - * this contract must be set before reactivating the instance - * - * @version $Rev$ $Date$ - */ -public interface SCAExternalizable { - - /** - * Sets the current work context - * - * @param context the current work context - */ - void setWorkContext(WorkContext context); - - /** - * Callback after all values have been set prior to making the instance available in the runtime - * - * @throws org.apache.tuscany.spi.component.ReactivationException - * - */ - void reactivate() throws ReactivationException; -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/SCAObject.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/SCAObject.java deleted file mode 100644 index 668eb1f90a..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/SCAObject.java +++ /dev/null @@ -1,73 +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.spi.component; - -import java.util.Map; - -import org.apache.tuscany.spi.Lifecycle; -import org.apache.tuscany.spi.event.EventPublisher; -import org.apache.tuscany.spi.model.Scope; - -/** - * Represents the base SCA artifact type in an assembly - * - * @version $Rev$ $Date$ - */ -public interface SCAObject extends EventPublisher, Lifecycle { - - /** - * Returns the artifact name - */ - String getName(); - - /** - * Returns the canonical artifact name - */ - String getCanonicalName(); - - /** - * Returns the parent composite, or null if the artifact does not have one - */ - CompositeComponent getParent(); - - /** - * Returns the artifact scope - */ - Scope getScope(); - - /** - * Returns true if the artifact is a system artifact - * - * @return true if the artifact is a system artifact - */ - boolean isSystem(); - - /** - * The extensions map contains other runtime context such as type systems for various databindings - * - * @return A live map of extended context - */ - Map getExtensions(); - - /** - * Called to signal that the composite should perform any initizalization - */ - void prepare() throws PrepareException; - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/SCAObjectStartException.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/SCAObjectStartException.java deleted file mode 100644 index a712b1b0eb..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/SCAObjectStartException.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.spi.component; - -import org.apache.tuscany.spi.CoreRuntimeException; - -/** - * Denotes an error starting an SCAObject - * - * @version $Rev$ $Date$ - */ -public class SCAObjectStartException extends CoreRuntimeException { - - public SCAObjectStartException(Throwable cause) { - super(cause); - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/SCAObjectStopException.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/SCAObjectStopException.java deleted file mode 100644 index 9f430bc414..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/SCAObjectStopException.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.spi.component; - -import org.apache.tuscany.spi.CoreRuntimeException; - -/** - * Denotes an error stopping an SCAObject - * - * @version $Rev$ $Date$ - */ -public class SCAObjectStopException extends CoreRuntimeException { - - public SCAObjectStopException(Throwable cause) { - super(cause); - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ScopeContainer.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ScopeContainer.java deleted file mode 100644 index 8b67dfa696..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ScopeContainer.java +++ /dev/null @@ -1,87 +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.spi.component; - -import org.apache.tuscany.spi.Lifecycle; -import org.apache.tuscany.spi.event.RuntimeEventListener; -import org.apache.tuscany.spi.model.Scope; - - -/** - * Manages the lifecycle and visibility of instances associated with a an {@link AtomicComponent}. - * - * @version $Rev$ $Date$ - */ -public interface ScopeContainer extends Lifecycle, RuntimeEventListener { - - /** - * Returns the scope value representing the scope context - */ - Scope getScope(); - - /** - * Registers a component with the scope component - */ - void register(AtomicComponent component); - - /** - * Returns an implementation instance associated with the current request context, creating one if necessary - * - * @throws TargetResolutionException - */ - Object getInstance(AtomicComponent component) throws TargetResolutionException; - - /** - * Returns an implementation instance associated with the current context. If no instance is found, a {@link - * TargetNotFoundException} is thrown - * - * @throws TargetResolutionException - */ - Object getAssociatedInstance(AtomicComponent component) throws TargetResolutionException; - - /** - * Persists a new component implementation instance, equivalent to an insert or append operation - * - * @param component the owning component - * @param id the id associated with the instance - * @param instance the instance to persist - * @param expiration the expiration in milliseconds - * @throws PersistenceException - */ - void persistNew(AtomicComponent component, String id, Object instance, long expiration) throws PersistenceException; - - /** - * Persists a component implementation instance, equivalent to an update operation - * - * @param component the owning component - * @param id the id associated with the instance - * @param instance the instance to persist - * @param expiration the expiration in milliseconds - * @throws PersistenceException - */ - void persist(AtomicComponent component, String id, Object instance, long expiration) throws PersistenceException; - - /** - * Removes a component implementation instance associated with the current context from persistent storage - * - * @param component the owning component - * @throws PersistenceException - */ - void remove(AtomicComponent component) throws PersistenceException; -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ScopeContainerMonitor.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ScopeContainerMonitor.java deleted file mode 100644 index 3e7649d59e..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ScopeContainerMonitor.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.spi.component; - -import org.apache.tuscany.api.annotation.LogLevel; - -/** - * Defines monitor events for scope containers - * - * @version $Rev$ $Date$ - */ -public interface ScopeContainerMonitor { - - @LogLevel("SEVERE") - void eagerInitializationError(Exception e); - - @LogLevel("SEVERE") - void destructionError(TargetDestructionException e); - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ScopeRegistry.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ScopeRegistry.java deleted file mode 100644 index 181b094403..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ScopeRegistry.java +++ /dev/null @@ -1,43 +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.spi.component; - -import org.apache.tuscany.spi.ObjectFactory; -import org.apache.tuscany.spi.model.Scope; - -/** - * Manages {@link ScopeContainer}s in the runtime - * - * @version $$Rev$$ $$Date$$ - */ -public interface ScopeRegistry { - - /** - * Returns the scope container for the given scope or null if one not found - * - * @param scope the scope - * @return the scope container for the given scope or null if one not found - */ - ScopeContainer getScopeContainer(Scope scope); - - void registerFactory(Scope scope, ObjectFactory factory); - - void deregisterFactory(Scope scope); - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/Service.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/Service.java deleted file mode 100644 index 714a0a4313..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/Service.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.spi.component; - -import java.util.List; - -import org.apache.tuscany.spi.model.ServiceContract; - -/** - * The runtime instantiation of an SCA service - * - * @version $Rev$ $Date$ - */ -public interface Service extends SCAObject { - - /** - * Returns the contract for the service. - * - * @return the contract for the service. - */ - ServiceContract getServiceContract(); - - /** - * Returns the collection of bindings configured for the service. - * - * @return the collection of bindings configured for the service. - */ - List getServiceBindings(); - - /** - * Adds a binding the service is exposed over. - * - * @param binding the binding the service is exposed over. - */ - void addServiceBinding(ServiceBinding binding); -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ServiceBinding.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ServiceBinding.java deleted file mode 100644 index 3912c3bb60..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ServiceBinding.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.spi.component; - -import javax.xml.namespace.QName; - -import org.apache.tuscany.spi.model.Operation; -import org.apache.tuscany.spi.model.ServiceContract; -import org.apache.tuscany.spi.wire.InboundWire; -import org.apache.tuscany.spi.wire.OutboundWire; -import org.apache.tuscany.spi.wire.TargetInvoker; - -/** - * The runtime instantiation of an SCA service binding. - * - * @version $Rev$ $Date$ - */ -public interface ServiceBinding extends SCAObject { - - /** - * Returns the binding qualified name - * - * @return the binding qualified name - */ - QName getBindingType(); - - /** - * Sets the parent service for the binding - * - * @param service the parent service for the binding - */ - void setService(Service service); - - /** - * Get the ServiceContract for the binding - * - * @return the ServiceContract for the binding - */ - ServiceContract getBindingServiceContract(); - - /** - * Returns the inbound wire for flowing a request through the service - * - * @return the inbound wire for flowing a request through the service - */ - InboundWire getInboundWire(); - - /** - * Sets the inbound wire for flowing a request through the service - * - * @param wire the inbound wire for flowing a request through the service - */ - void setInboundWire(InboundWire wire); - - /** - * Returns the outbound wire for flowing a request out of the service - * - * @return the outbound wire for flowing a request out of the service - */ - OutboundWire getOutboundWire(); - - /** - * Sets the outbound wire for flowing a request out of the service - * - * @param wire the outbound wire for flowing a request out of the service - */ - void setOutboundWire(OutboundWire wire); - - /** - * Returns the target invoker for dispatching callback invocations - * - * @param contract the callback contract - * @param operation the callback operation the target invoker dispatches to - * @throws TargetInvokerCreationException - */ - TargetInvoker createTargetInvoker(ServiceContract contract, Operation operation) - throws TargetInvokerCreationException; - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/TargetDestructionException.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/TargetDestructionException.java deleted file mode 100644 index 5f521f9b0a..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/TargetDestructionException.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.spi.component; - -/** - * Denotes an error destroying a target - * - * @version $Rev$ $Date$ - */ -public class TargetDestructionException extends TargetResolutionException { - - public TargetDestructionException(String message, String identifier) { - super(message, identifier); - } - - public TargetDestructionException(String message, String identifier, Throwable cause) { - super(message, identifier, cause); - } - - - public TargetDestructionException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/TargetException.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/TargetException.java deleted file mode 100644 index 6b8278cf8b..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/TargetException.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.spi.component; - -/** - * Denotes an error while performing an operation on a target component implementation instance - * - * @version $Rev$ $Date$ - */ -public abstract class TargetException extends ComponentException { - - public TargetException(String message) { - super(message); - } - - - public TargetException(String message, String identifier) { - super(message, identifier); - } - - public TargetException(String message, Throwable cause) { - super(message, cause); - } - - - public TargetException(String message, String identifier, Throwable cause) { - super(message, identifier, cause); - } - - public TargetException(Throwable cause) { - super(cause); - } - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/TargetInitializationException.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/TargetInitializationException.java deleted file mode 100644 index eaea4c3bc9..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/TargetInitializationException.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.spi.component; - -/** - * Denotes an error initializing a target - * - * @version $Rev$ $Date$ - */ -public class TargetInitializationException extends TargetResolutionException { - - public TargetInitializationException(String message, String identifier) { - super(message, identifier); - } - - public TargetInitializationException(String message, String identifier, Throwable cause) { - super(message, identifier, cause); - } - - public TargetInitializationException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/TargetInvocationException.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/TargetInvocationException.java deleted file mode 100644 index 1fc2b24f5b..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/TargetInvocationException.java +++ /dev/null @@ -1,43 +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.spi.component; - -/** - * Raised when an error is encountered during a target invocation - * - * @version $Rev$ $Date$ - */ -public class TargetInvocationException extends TargetException { - - public TargetInvocationException(String message) { - super(message); - } - - public TargetInvocationException(String message, String identifier) { - super(message, identifier); - } - - public TargetInvocationException(String message, Throwable cause) { - super(message, cause); - } - - public TargetInvocationException(String message, String identifier, Throwable cause) { - super(message, identifier, cause); - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/TargetInvokerCreationException.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/TargetInvokerCreationException.java deleted file mode 100644 index ac914401cf..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/TargetInvokerCreationException.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.spi.component; - -/** - * Denotes an error creating a {@link org.apache.tuscany.spi.wire.TargetInvoker} - * - * @version $Rev$ $Date$ - */ -public abstract class TargetInvokerCreationException extends ComponentException { - - public TargetInvokerCreationException() { - } - - public TargetInvokerCreationException(String message) { - super(message); - } - - public TargetInvokerCreationException(String message, String identifier) { - super(message, identifier); - } - - public TargetInvokerCreationException(String message, Throwable cause) { - super(message, cause); - } - - public TargetInvokerCreationException(String message, String identifier, Throwable cause) { - super(message, identifier, cause); - } - - public TargetInvokerCreationException(Throwable cause) { - super(cause); - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/TargetNotFoundException.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/TargetNotFoundException.java deleted file mode 100644 index cd6996789c..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/TargetNotFoundException.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.spi.component; - -/** - * Thrown when a target of an operation cannot be found - * - * @version $$Rev$$ $$Date$$ - */ -public class TargetNotFoundException extends TargetResolutionException { - - public TargetNotFoundException(String message) { - super(message); - } - - public TargetNotFoundException(String message, String identifier) { - super(message, identifier); - } - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/TargetResolutionException.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/TargetResolutionException.java deleted file mode 100644 index 858fa9415d..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/TargetResolutionException.java +++ /dev/null @@ -1,43 +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.spi.component; - -/** - * Denotes an error retrieving a target instance - * - * @version $Rev$ $Date$ - */ -public class TargetResolutionException extends TargetException { - - public TargetResolutionException(String message) { - super(message); - } - - public TargetResolutionException(String message, String identifier) { - super(message, identifier); - } - - public TargetResolutionException(String message, Throwable cause) { - super(message, cause); - } - - public TargetResolutionException(String message, String identifier, Throwable cause) { - super(message, identifier, cause); - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/WorkContext.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/WorkContext.java deleted file mode 100644 index 3e244873c8..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/WorkContext.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.spi.component; - -import java.util.LinkedList; - -/** - * Implementations track information associated with a request as it is processed by the runtime - * - * @version $Rev$ $Date$ - */ -public interface WorkContext { - - Object getCurrentCorrelationId(); - - void setCurrentCorrelationId(Object correlationId); - - /** - * Returns the current atomic component as a request is processed or null if it is not being tracked. Note that the - * current atomic component is typically only tracked during persistence operations involving implementation - * instances - * - * @return the current atomic component as a request is processed or null - */ - AtomicComponent getCurrentAtomicComponent(); - - /** - * Sets the current atomic component that is handling processing of a request. Note that in most cases it will not - * be necessary to track this in the rumtime - * - * @param component the current atomic component - */ - void setCurrentAtomicComponent(AtomicComponent component); - - /** - * Returns the current chain of SCAObject addresses - */ - LinkedList getCurrentCallbackRoutingChain(); - - /** - * Sets the current stack of SCAObject addresses - */ - void setCurrentCallbackRoutingChain(LinkedList callbackRoutingChain); - - /** - * Returns the composite where a remote request came in - */ - CompositeComponent getRemoteComponent(); - - /** - * Sets the composite where a remote request came in - */ - void setRemoteComponent(CompositeComponent component); - - /** - * Returns the unique key for the given identifier associated with the current request - */ - Object getIdentifier(Object type); - - /** - * Sets the unique key for the given identifier associated with the current request - */ - void setIdentifier(Object type, Object identifier); - - /** - * Clears the unique key for the given identifier associated with the current request - */ - void clearIdentifier(Object type); - - /** - * Clears all identifiers associated with the current request - */ - void clearIdentifiers(); - - /** - * Removes and returns the name of the last remotable service to handle the current request - * - * @return the name of the last remotable service to handle the current request or null - */ - String popServiceName(); - - /** - * Returns the name of the last remotable service to handle the current request - * - * @return the name of the last remotable service to handle the current request or null - */ - String getCurrentServiceName(); - - /** - * Adds the name of the last remotable service to handle the current request - * - * @param name the name of the last remotable service to handle the current request or null - */ - void pushServiceName(String name); - - /** - * Clears the stack of current service names - */ - void clearServiceNames(); -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/DataBinding.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/DataBinding.java deleted file mode 100644 index ceb72baefb..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/DataBinding.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.spi.databinding; - -import org.apache.tuscany.spi.model.DataType; - -/** - * DataBinding represents a data representation, for example, SDO, JAXB and AXIOM - */ -public interface DataBinding { - /** - * The name of a databinding should be case-insensitive and unique - * - * @return The name of the databinding - */ - String getName(); - - /** - * Introspect a java class or interface to create a DataType model - * - * @param javaType The java class or interface to be introspected - * @return The DataType or null if the java type is not supported by this databinding - */ - DataType introspect(Class javaType); - - /** - * Introspect the data to figure out the corresponding data type - * - * @param value The object to be checked - * @return The DataType or null if the java type is not supported by this databinding - */ - DataType introspect(Object value); - - /** - * Provide a WrapperHandler for this databinding - * @return A wrapper handler which can handle wrapping/wrapping for this databinding - */ - WrapperHandler getWrapperHandler(); - - /** - * make a copy of the input object - * @param source object to copy - * @return copy of the object passed in as argument - */ - Object copy(Object object); -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/DataBindingRegistry.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/DataBindingRegistry.java deleted file mode 100644 index ba47401cc2..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/DataBindingRegistry.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.spi.databinding; - -import org.apache.tuscany.spi.model.DataType; - -/** - * The registry for data bindings - */ -public interface DataBindingRegistry { - /** - * Register a data binding - * - * @param dataBinding - */ - void register(DataBinding dataBinding); - - /** - * Look up a data binding by id - * - * @param id The name of the databinding - * @return The databinding - */ - DataBinding getDataBinding(String id); - - /** - * Unregister a data binding - * - * @param id - * @return The unregistered databinding - */ - DataBinding unregister(String id); - - /** - * Introspect the java class to figure out what DataType supports it - * - * @param javaType The java class or interface - * @return A DataType representing the java type or null if no databinding - * recognizes the java type - */ - DataType introspectType(Class javaType); - - /** - * Introspect the value to figure out the corresponding DataType - * - * @param value The object value - * @return A DataType representing the value or null if no databinding - * recognizes the value - */ - DataType introspectType(Object value); -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/DataPipe.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/DataPipe.java deleted file mode 100755 index a0eb7ac10d..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/DataPipe.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.spi.databinding; - -/** - * Data pipe allows a data source pushes data into its sink and pipe the data into its result - * - * @param The data binding type of the sink - * @param The data binding type of the result - */ -public interface DataPipe extends Transformer { - - /** - * Returns a sink (for example, java.io.OutputStream, java.io.Writer or org.xml.sax.ContentHandler) to receive data - * pushed by the source - * - * @return The sink to consume data - */ - S getSink(); - - /** - * Returns the data populated by the sink - * - * @return - */ - R getResult(); - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/Mediator.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/Mediator.java deleted file mode 100755 index ba936b46db..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/Mediator.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.spi.databinding; - -import java.util.Map; - -import org.apache.tuscany.spi.model.DataType; - -/** - * This interface will be used as a Tuscany system service to perform data mediations - * - * Mediate the data from one type to the other one - * - */ -public interface Mediator { - - /** - * Mediate the data from the source type to the target type - * @param source The data to be mediated - * @param sourceDataType Data type for the source data - * @param targetDataType Data type for the target data - * @param context - * @return - */ - Object mediate(Object source, DataType sourceDataType, DataType targetDataType, Map, Object> context); - /** - * Mediate the source data into the target which is a sink to receive the data - * @param source The data to be mediated - * @param target The sink to receive data - * @param sourceDataType Data type for the source data - * @param targetDataType Data type for the target data - */ - void mediate( - Object source, - Object target, - DataType sourceDataType, - DataType targetDataType, - Map, Object> context); - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/PullTransformer.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/PullTransformer.java deleted file mode 100644 index 21e8cc2750..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/PullTransformer.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.spi.databinding; - -/** - * PullTransformer transforms data from one binding format to the other one which can be directly consumed - * - * @param The source data type - * @param the target data type - */ -public interface PullTransformer extends Transformer { - /** - * Transform source data into the result type. - * - * @param source The source data - * @param context The context for the transformation - * @return The transformed result - */ - R transform(S source, TransformationContext context); -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/PushTransformer.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/PushTransformer.java deleted file mode 100644 index d68b6aa772..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/PushTransformer.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.spi.databinding; - -/** - * A transformer that pushes data from its source into the sink - * - * @param - * @param - */ -public interface PushTransformer extends Transformer { - /** - * @param source The source data - * @param sink The sink to receive the data - * @param context - */ - void transform(S source, R sink, TransformationContext context); -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/SimpleTypeMapper.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/SimpleTypeMapper.java deleted file mode 100644 index 7c0bf4d01a..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/SimpleTypeMapper.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.spi.databinding; - -import org.apache.tuscany.spi.idl.TypeInfo; - -/** - * Type Mapper between XML schema simple data types and java objects - */ -public interface SimpleTypeMapper { - /** - * Parse the XML lexical representation into a java object - * @param simpleType The XSD simple type - * @param value the XML lexical representation - * @param context The context of the transformation - * @return A java object for the XML value - */ - Object toJavaObject(TypeInfo simpleType, String value, TransformationContext context); - /** - * Create the XML lexical representation for a java object - * @param simpleType The XSD simple type - * @param obj The java object - * @param context The context of the transformation - * @return The XML lexical representation - */ - String toXMLLiteral(TypeInfo simpleType, Object obj, TransformationContext context); -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/TransformationContext.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/TransformationContext.java deleted file mode 100755 index 8287de1707..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/TransformationContext.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.spi.databinding; - -import java.util.Map; - -import org.apache.tuscany.spi.model.DataType; - -/** - * Context for data transformation - * - */ -public interface TransformationContext { - /** - * Get the source data type - * - * @return - */ - DataType getSourceDataType(); - - /** - * Get the target data type - * - * @return - */ - DataType getTargetDataType(); - - /** - * Set the source data type - * - * @param sourceDataType - */ - void setSourceDataType(DataType sourceDataType); - - /** - * Set the target data type - * - * @param targetDataType - */ - void setTargetDataType(DataType targetDataType); - - /** - * Get the classloader - * - * @return - */ - ClassLoader getClassLoader(); - - /** - * Get a map of metadata - * - * @return - */ - Map, Object> getMetadata(); - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/TransformationException.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/TransformationException.java deleted file mode 100755 index 9b57e1cf70..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/TransformationException.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.spi.databinding; - -import org.apache.tuscany.api.TuscanyRuntimeException; - -/** - * Reports problems during data transformation - */ -public class TransformationException extends TuscanyRuntimeException { - - private static final long serialVersionUID = 7662385613693006428L; - - public TransformationException() { - super(); - } - - public TransformationException(String message, Throwable cause) { - super(message, cause); - } - - public TransformationException(String message) { - super(message); - } - - public TransformationException(Throwable cause) { - super(cause); - } - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/Transformer.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/Transformer.java deleted file mode 100755 index 2f969e979d..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/Transformer.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.spi.databinding; - -/** - * A transformer provides the data transformation from source type to target type. The cost of the transformation is - * modeled as weight. - */ -public interface Transformer { - /** - * Get the source type that this transformer transforms data from. The type is used as the key when the transformer - * is registered with TransformerRegistry. - * - * @return A key indentifying the source type - */ - String getSourceDataBinding(); - - /** - * Get the target type that this transformer transforms data into. The type is used as the key when the transformer - * is registered with TransformerRegistry. - * - * @return A key indentifying the target type - */ - String getTargetDataBinding(); - - /** - * Get the cost of the transformation. The weight can be used to choose the most efficient path if there are more - * than one available from the source to the target. - * - * @return An integer representing the cost of the transformation - */ - int getWeight(); -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/TransformerRegistry.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/TransformerRegistry.java deleted file mode 100755 index 5381dfa081..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/TransformerRegistry.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.spi.databinding; - -import java.util.List; - -/** - * Registry for data transformers - */ -public interface TransformerRegistry { - /** - * Register a transformer - * - * @param sourceDataBinding - * @param targetDataBinding - * @param weight - * @param transformer - */ - void registerTransformer(String sourceDataBinding, - String targetDataBinding, - int weight, - Transformer transformer); - - /** - * Register a transformer - * - * @param transformer - */ - void registerTransformer(Transformer transformer); - - /** - * Unregister a transformer - * - * @param sourceDataBinding - * @param targetDataBinding - * @return - */ - boolean unregisterTransformer(String sourceDataBinding, String targetDataBinding); - - /** - * Get the direct Transformer which can transform data from source type to - * result type - * - * @param sourceDataBinding - * @param targetDataBinding - * @return - */ - Transformer getTransformer(String sourceDataBinding, String targetDataBinding); - - /** - * Get the a chain of Transformers which can transform data from source type - * to result type - * - * @param sourceDataBinding - * @param targetDataBinding - * @return - */ - List getTransformerChain(String sourceDataBinding, String targetDataBinding); -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/WrapperHandler.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/WrapperHandler.java deleted file mode 100644 index e60cb2af92..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/WrapperHandler.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.spi.databinding; - -import org.apache.tuscany.spi.idl.ElementInfo; - -/** - * A contract for transformers to deal with wrapping/unwrapping for WSDL wrapper style operations - */ -public interface WrapperHandler { - /** - * Create a wrapper element - * - * @param element The XSD element - * @param context The transformation context - * @return An object representing the wrapper element - */ - T create(ElementInfo element, TransformationContext context); - - /** - * Set child element for the wrapper - * - * @param wrapper The wrapper - * @param i The index - * @param childElement The XSD element - * @param value The value of the child - */ - void setChild(T wrapper, int i, ElementInfo childElement, Object value); - - /** - * Get child element from the wrapper - * - * @param wrapper The wrapper - * @param i The index - * @param element The XSD element - * @return The value of the child - */ - Object getChild(T wrapper, int i, ElementInfo element); -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/DOMHelper.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/DOMHelper.java deleted file mode 100644 index 2b927b8e55..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/DOMHelper.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.spi.databinding.extension; - -import javax.xml.namespace.QName; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; - -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; - -/** - * Helper for DOM - */ -public final class DOMHelper { - private static final DocumentBuilderFactory FACTORY = DocumentBuilderFactory.newInstance(); - static { - FACTORY.setNamespaceAware(true); - } - - private DOMHelper() { - } - - public static Document newDocument() throws ParserConfigurationException { - return newDocumentBuilder().newDocument(); - } - - public static DocumentBuilder newDocumentBuilder() throws ParserConfigurationException { - return FACTORY.newDocumentBuilder(); - } - - public static QName getQName(Node node) { - String ns = node.getNamespaceURI(); - if (ns == null) { - ns = ""; - } - // node.getLocalName() will return null if it is created using DOM Level - // 1 method - // such as createElement() - return new QName(ns, node.getNodeName()); - } - - public static Element createElement(Document document, QName name) { - String prefix = name.getPrefix(); - String qname = - (prefix != null && prefix.length() > 0) ? prefix + ":" + name.getLocalPart() : name - .getLocalPart(); - return document.createElementNS(name.getNamespaceURI(), qname); - } - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/DataBindingExtension.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/DataBindingExtension.java deleted file mode 100644 index 95dcd9d1a4..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/DataBindingExtension.java +++ /dev/null @@ -1,174 +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.spi.databinding.extension; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.ObjectStreamClass; -import java.io.OutputStream; -import java.io.Serializable; - -import org.osoa.sca.annotations.EagerInit; -import org.osoa.sca.annotations.Init; -import org.osoa.sca.annotations.Scope; -import org.osoa.sca.annotations.Service; - -import org.apache.tuscany.spi.annotation.Autowire; -import org.apache.tuscany.spi.databinding.DataBinding; -import org.apache.tuscany.spi.databinding.DataBindingRegistry; -import org.apache.tuscany.spi.databinding.WrapperHandler; -import org.apache.tuscany.spi.model.DataType; - -/** - * Base Implementation of DataBinding - * - * @version $Rev$ $Date$ - */ -@Service(DataBinding.class) -@Scope("COMPOSITE") -@EagerInit -public abstract class DataBindingExtension implements DataBinding { - - protected DataBindingRegistry registry; - - protected Class baseType; - - protected String name; - - /** - * Create a databinding with the base java type whose name will be used as the name of the databinding - * - * @param baseType The base java class or interface representing the databinding, for example, org.w3c.dom.Node - */ - protected DataBindingExtension(Class baseType) { - this(baseType.getName(), baseType); - } - - /** - * Create a databinding with the name and base java type - * - * @param name The name of the databinding - * @param baseType The base java class or interface representing the databinding, for example, org.w3c.dom.Node - */ - protected DataBindingExtension(String name, Class baseType) { - this.name = name; - this.baseType = baseType; - } - - @Autowire - public void setDataBindingRegistry(DataBindingRegistry registry) { - this.registry = registry; - } - - @Init - public void init() { - registry.register(this); - } - - public DataType introspect(Class javaType) { - if (baseType == null || javaType == null) { - return null; - } - if (baseType.isAssignableFrom(javaType)) { - return new DataType(name, javaType, baseType); - } else { - return null; - } - } - - public DataType introspect(Object value) { - if (value == null) { - return null; - } else { - return introspect(value.getClass()); - } - } - - public final String getName() { - return name; - } - - /** - * @see org.apache.tuscany.spi.databinding.DataBinding#getWrapperHandler() - */ - public WrapperHandler getWrapperHandler() { - return null; - } - - public Object copy(Object arg) { - if (arg == null) { - return null; - } - final Class clazz = arg.getClass(); - if (String.class == clazz || clazz.isPrimitive() || Number.class.isAssignableFrom(clazz) - || Boolean.class.isAssignableFrom(clazz) || Character.class.isAssignableFrom(clazz) - || Byte.class.isAssignableFrom(clazz)) { - // Immutable classes - return arg; - } - try { - if (arg instanceof Serializable) { - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - ObjectOutputStream oos = getObjectOutputStream(bos); - oos.writeObject(arg); - oos.close(); - bos.close(); - - ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray()); - ObjectInputStream ois = getObjectInputStream(bis, clazz.getClassLoader()); - Object objectCopy = ois.readObject(); - ois.close(); - bis.close(); - return objectCopy; - } else { - //return arg; - throw new IllegalArgumentException( - "Pass-by-value is not supported for the given object"); - } - } catch (Exception e) { - throw new IllegalArgumentException( - "Pass-by-value is not supported for the given object", e); - } - } - - protected ObjectOutputStream getObjectOutputStream(OutputStream os) throws IOException { - return new ObjectOutputStream(os); - } - - protected ObjectInputStream getObjectInputStream(InputStream is, final ClassLoader cl) - throws IOException { - ObjectInputStream ois = new ObjectInputStream(is) { - @Override - protected Class resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException { - try { - return Class.forName(desc.getName(), false, cl); - } catch (ClassNotFoundException e) { - return super.resolveClass(desc); - } - } - - }; - return ois; - } - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/Java2SimpleTypeTransformer.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/Java2SimpleTypeTransformer.java deleted file mode 100644 index 4605f945e2..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/Java2SimpleTypeTransformer.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.spi.databinding.extension; - -import org.apache.tuscany.spi.databinding.PullTransformer; -import org.apache.tuscany.spi.databinding.SimpleTypeMapper; -import org.apache.tuscany.spi.databinding.TransformationContext; -import org.apache.tuscany.spi.idl.ElementInfo; -import org.apache.tuscany.spi.idl.TypeInfo; - -/** - * Transformer to convert data from a simple java object to a databinding's representation - */ -public abstract class Java2SimpleTypeTransformer extends TransformerExtension implements - PullTransformer { - - protected SimpleTypeMapper mapper; - - public Java2SimpleTypeTransformer() { - this.mapper = new SimpleTypeMapperExtension(); - } - - public Java2SimpleTypeTransformer(SimpleTypeMapper mapper) { - this.mapper = (mapper != null) ? mapper : new SimpleTypeMapperExtension(); - } - - public T transform(Object source, TransformationContext context) { - ElementInfo element = - (ElementInfo) context.getTargetDataType().getMetadata(ElementInfo.class.getName()); - TypeInfo simpleType = (TypeInfo) element.getType(); - String text = mapper.toXMLLiteral(simpleType, source, context); - return createElement(element, text, context); - } - - public Class getSourceType() { - return Object.class; - } - - public int getWeight() { - return 10000; - } - - protected abstract T createElement(ElementInfo element, String literal, TransformationContext context); - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/SimpleType2JavaTransformer.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/SimpleType2JavaTransformer.java deleted file mode 100644 index d861bdce92..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/SimpleType2JavaTransformer.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.spi.databinding.extension; - -import org.apache.tuscany.spi.databinding.PullTransformer; -import org.apache.tuscany.spi.databinding.SimpleTypeMapper; -import org.apache.tuscany.spi.databinding.TransformationContext; -import org.apache.tuscany.spi.idl.ElementInfo; -import org.apache.tuscany.spi.idl.TypeInfo; - -/** - * Transformer to convert data from a databinding's representation of simple - * types to Java Objects - */ -public abstract class SimpleType2JavaTransformer extends TransformerExtension implements - PullTransformer { - - protected SimpleTypeMapper mapper; - - public SimpleType2JavaTransformer() { - this.mapper = new SimpleTypeMapperExtension(); - } - - public SimpleType2JavaTransformer(SimpleTypeMapper mapper) { - this.mapper = (mapper != null) ? mapper : new SimpleTypeMapperExtension(); - } - - public Object transform(T source, TransformationContext context) { - TypeInfo simpleType = (TypeInfo)context.getSourceDataType().getMetadata(TypeInfo.class.getName()); - if (simpleType == null) { - ElementInfo element = - (ElementInfo)context.getSourceDataType().getMetadata(ElementInfo.class.getName()); - simpleType = (TypeInfo)element.getType(); - } - return mapper.toJavaObject(simpleType, getText(source), context); - } - - public Class getTargetType() { - return Object.class; - } - - public int getWeight() { - // Cannot be used for imtermediate - return 10000; - } - - /** - * Get the string value from the source - * @param source - * @return A string - */ - protected abstract String getText(T source); -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/SimpleTypeMapperExtension.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/SimpleTypeMapperExtension.java deleted file mode 100644 index 843ac0591d..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/SimpleTypeMapperExtension.java +++ /dev/null @@ -1,391 +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.spi.databinding.extension; - -import java.util.Date; -import java.util.GregorianCalendar; -import java.util.HashMap; -import java.util.Map; - -import javax.xml.datatype.DatatypeConfigurationException; -import javax.xml.datatype.DatatypeFactory; -import javax.xml.datatype.XMLGregorianCalendar; -import javax.xml.namespace.NamespaceContext; -import javax.xml.namespace.QName; - -import org.apache.tuscany.spi.databinding.SimpleTypeMapper; -import org.apache.tuscany.spi.databinding.TransformationContext; -import org.apache.tuscany.spi.idl.TypeInfo; - -public class SimpleTypeMapperExtension extends XSDDataTypeConverter implements SimpleTypeMapper { - public static final Map JAVA2XML = new HashMap(); - - public static final String URI_2001_SCHEMA_XSD = "http://www.w3.org/2001/XMLSchema"; - - public static final Map XML2JAVA = new HashMap(); - - public static final QName XSD_ANY = new QName(URI_2001_SCHEMA_XSD, "any"); - - public static final QName XSD_ANYSIMPLETYPE = new QName(URI_2001_SCHEMA_XSD, "anySimpleType"); - - public static final QName XSD_ANYTYPE = new QName(URI_2001_SCHEMA_XSD, "anyType"); - - public static final QName XSD_ANYURI = new QName(URI_2001_SCHEMA_XSD, "anyURI"); - - public static final QName XSD_BASE64 = new QName(URI_2001_SCHEMA_XSD, "base64Binary"); - - public static final QName XSD_BOOLEAN = new QName(URI_2001_SCHEMA_XSD, "boolean"); - - public static final QName XSD_BYTE = new QName(URI_2001_SCHEMA_XSD, "byte"); - - public static final QName XSD_DATE = new QName(URI_2001_SCHEMA_XSD, "date"); - - public static final QName XSD_DATETIME = new QName(URI_2001_SCHEMA_XSD, "dateTime"); - - public static final QName XSD_DAY = new QName(URI_2001_SCHEMA_XSD, "gDay"); - - public static final QName XSD_DECIMAL = new QName(URI_2001_SCHEMA_XSD, "decimal"); - - public static final QName XSD_DOUBLE = new QName(URI_2001_SCHEMA_XSD, "double"); - - public static final QName XSD_DURATION = new QName(URI_2001_SCHEMA_XSD, "duration"); - - public static final QName XSD_ENTITIES = new QName(URI_2001_SCHEMA_XSD, "ENTITIES"); - - public static final QName XSD_ENTITY = new QName(URI_2001_SCHEMA_XSD, "ENTITY"); - - public static final QName XSD_FLOAT = new QName(URI_2001_SCHEMA_XSD, "float"); - - public static final QName XSD_HEXBIN = new QName(URI_2001_SCHEMA_XSD, "hexBinary"); - - public static final QName XSD_IDREF = new QName(URI_2001_SCHEMA_XSD, "IDREF"); - - public static final QName XSD_IDREFS = new QName(URI_2001_SCHEMA_XSD, "IDREFS"); - - public static final QName XSD_INT = new QName(URI_2001_SCHEMA_XSD, "int"); - - public static final QName XSD_INTEGER = new QName(URI_2001_SCHEMA_XSD, "integer"); - - public static final QName XSD_LONG = new QName(URI_2001_SCHEMA_XSD, "long"); - - public static final QName XSD_MONTH = new QName(URI_2001_SCHEMA_XSD, "gMonth"); - - public static final QName XSD_MONTHDAY = new QName(URI_2001_SCHEMA_XSD, "gMonthDay"); - - public static final QName XSD_NAME = new QName(URI_2001_SCHEMA_XSD, "Name"); - - public static final QName XSD_NCNAME = new QName(URI_2001_SCHEMA_XSD, "NCName"); - - public static final QName XSD_NEGATIVEINTEGER = new QName(URI_2001_SCHEMA_XSD, "negativeInteger"); - - public static final QName XSD_NMTOKEN = new QName(URI_2001_SCHEMA_XSD, "NMTOKEN"); - - public static final QName XSD_NMTOKENS = new QName(URI_2001_SCHEMA_XSD, "NMTOKENS"); - - public static final QName XSD_NONNEGATIVEINTEGER = new QName(URI_2001_SCHEMA_XSD, "nonNegativeInteger"); - - public static final QName XSD_NONPOSITIVEINTEGER = new QName(URI_2001_SCHEMA_XSD, "nonPositiveInteger"); - - public static final QName XSD_NORMALIZEDSTRING = new QName(URI_2001_SCHEMA_XSD, "normalizedString"); - - public static final QName XSD_NOTATION = new QName(URI_2001_SCHEMA_XSD, "NOTATION"); - - public static final QName XSD_POSITIVEINTEGER = new QName(URI_2001_SCHEMA_XSD, "positiveInteger"); - - public static final QName XSD_QNAME = new QName(URI_2001_SCHEMA_XSD, "QName"); - - public static final QName XSD_SHORT = new QName(URI_2001_SCHEMA_XSD, "short"); - - public static final Map XSD_SIMPLE_TYPES = new HashMap(); - - public static final QName XSD_STRING = new QName(URI_2001_SCHEMA_XSD, "string"); - - public static final QName XSD_TIME = new QName(URI_2001_SCHEMA_XSD, "time"); - - public static final QName XSD_TOKEN = new QName(URI_2001_SCHEMA_XSD, "token"); - - public static final QName XSD_UNSIGNEDBYTE = new QName(URI_2001_SCHEMA_XSD, "unsignedByte"); - - public static final QName XSD_UNSIGNEDINT = new QName(URI_2001_SCHEMA_XSD, "unsignedInt"); - - public static final QName XSD_UNSIGNEDLONG = new QName(URI_2001_SCHEMA_XSD, "unsignedLong"); - - public static final QName XSD_UNSIGNEDSHORT = new QName(URI_2001_SCHEMA_XSD, "unsignedShort"); - - public static final QName XSD_YEAR = new QName(URI_2001_SCHEMA_XSD, "gYear"); - - public static final QName XSD_YEARMONTH = new QName(URI_2001_SCHEMA_XSD, "gYearMonth"); - - private static final String[] XSD_TYPE_NAMES = - {"string", "boolean", "double", "float", "int", "integer", "long", "short", "byte", "decimal", - "base64Binary", "hexBinary", "anySimpleType", "anyType", "any", "QName", "dateTime", "date", "time", - "normalizedString", "token", "unsignedLong", "unsignedInt", "unsignedShort", "unsignedByte", - "positiveInteger", "negativeInteger", "nonNegativeInteger", "nonPositiveInteger", "gYearMonth", - "gMonthDay", "gYear", "gMonth", "gDay", "duration", "Name", "NCName", "NMTOKEN", "NMTOKENS", - "NOTATION", "ENTITY", "ENTITIES", "IDREF", "IDREFS", "anyURI", "language", "ID"}; - - static { - for (String type : XSD_TYPE_NAMES) { - TypeInfo simpleType = new TypeInfo(new QName(URI_2001_SCHEMA_XSD, type), true, null); - XSD_SIMPLE_TYPES.put(type, simpleType); - } - } - - static { - JAVA2XML.put(boolean.class, "boolean"); - JAVA2XML.put(byte.class, "byte"); - JAVA2XML.put(short.class, "short"); - JAVA2XML.put(int.class, "int"); - JAVA2XML.put(long.class, "long"); - JAVA2XML.put(float.class, "float"); - JAVA2XML.put(double.class, "double"); - JAVA2XML.put(Boolean.class, "boolean"); - JAVA2XML.put(Byte.class, "byte"); - JAVA2XML.put(Short.class, "short"); - JAVA2XML.put(Integer.class, "int"); - JAVA2XML.put(Long.class, "long"); - JAVA2XML.put(Float.class, "float"); - JAVA2XML.put(Double.class, "double"); - JAVA2XML.put(java.lang.String.class, "string"); - JAVA2XML.put(java.math.BigInteger.class, "integer"); - JAVA2XML.put(java.math.BigDecimal.class, "decimal"); - JAVA2XML.put(java.util.Calendar.class, "dateTime"); - JAVA2XML.put(java.util.Date.class, "dateTime"); - JAVA2XML.put(javax.xml.namespace.QName.class, "QName"); - JAVA2XML.put(java.net.URI.class, "string"); - JAVA2XML.put(javax.xml.datatype.XMLGregorianCalendar.class, "anySimpleType"); - JAVA2XML.put(javax.xml.datatype.Duration.class, "duration"); - JAVA2XML.put(java.lang.Object.class, "anyType"); - JAVA2XML.put(java.awt.Image.class, "base64Binary"); - JAVA2XML.put(byte[].class, "base64Binary"); - // java2XSD.put(javax.activation.DataHandler.class, "base64Binary"); - JAVA2XML.put(javax.xml.transform.Source.class, "base64Binary"); - JAVA2XML.put(java.util.UUID.class, "string"); - } - - static { - XML2JAVA.put("string", java.lang.String.class); - XML2JAVA.put("integer", java.math.BigInteger.class); - XML2JAVA.put("int", int.class); - XML2JAVA.put("long", long.class); - XML2JAVA.put("short", short.class); - XML2JAVA.put("decimal", java.math.BigDecimal.class); - XML2JAVA.put("float", float.class); - XML2JAVA.put("double", double.class); - XML2JAVA.put("boolean", boolean.class); - XML2JAVA.put("byte", byte.class); - XML2JAVA.put("QName", javax.xml.namespace.QName.class); - XML2JAVA.put("dateTime", javax.xml.datatype.XMLGregorianCalendar.class); - XML2JAVA.put("base64Binary", byte[].class); - XML2JAVA.put("hexBinary", byte[].class); - XML2JAVA.put("unsignedInt", long.class); - XML2JAVA.put("unsignedShort", int.class); - XML2JAVA.put("unsignedByte", short.class); - XML2JAVA.put("time", javax.xml.datatype.XMLGregorianCalendar.class); - XML2JAVA.put("date", javax.xml.datatype.XMLGregorianCalendar.class); - XML2JAVA.put("gDay", javax.xml.datatype.XMLGregorianCalendar.class); - XML2JAVA.put("gMonth", javax.xml.datatype.XMLGregorianCalendar.class); - XML2JAVA.put("gYear", javax.xml.datatype.XMLGregorianCalendar.class); - XML2JAVA.put("gYearMonth", javax.xml.datatype.XMLGregorianCalendar.class); - XML2JAVA.put("gMonthDay", javax.xml.datatype.XMLGregorianCalendar.class); - XML2JAVA.put("anySimpleType", java.lang.Object.class); // For elements - // XML2JAVA.put("anySimpleType", java.lang.String.class); // For - // attributes - XML2JAVA.put("duration", javax.xml.datatype.Duration.class); - XML2JAVA.put("NOTATION", javax.xml.namespace.QName.class); - } - - private DatatypeFactory factory; - - public SimpleTypeMapperExtension() { - super(); - try { - this.factory = DatatypeFactory.newInstance(); - } catch (DatatypeConfigurationException e) { - throw new IllegalArgumentException(e); - } - } - - public Class getJavaType(TypeInfo xmlType) { - TypeInfo baseType = xmlType; - while (baseType.getBaseType() != null) { - baseType = baseType.getBaseType(); - } - return XML2JAVA.get(baseType.getQName().getLocalPart()); - } - - public TypeInfo getXMLType(Class javaType) { - return XSD_SIMPLE_TYPES.get(JAVA2XML.get(javaType)); - } - - public Object toJavaObject(TypeInfo simpleType, String literal, TransformationContext context) { - /** - *
        - *
      • xsd:string --- java.lang.String - *
      • xsd:integer --- java.math.BigInteger - *
      • xsd:int --- int - *
      • xsd:long --- long - *
      • xsd:short --- short - *
      • xsd:decimal --- java.math.BigDecimal - *
      • xsd:float --- float - *
      • xsd:double --- double - *
      • xsd:boolean --- boolean - *
      • xsd:byte --- byte - *
      • xsd:QName --- javax.xml.namespace.QName - *
      • xsd:dateTime --- javax.xml.datatype.XMLGregorianCalendar - *
      • xsd:base64Binary --- byte[] - *
      • xsd:hexBinary --- byte[] - *
      • xsd:unsignedInt --- long - *
      • xsd:unsignedShort --- int - *
      • xsd:unsignedByte --- short - *
      • xsd:time --- javax.xml.datatype.XMLGregorianCalendar - *
      • xsd:date --- javax.xml.datatype.XMLGregorianCalendar - *
      • xsd:g* --- javax.xml.datatype.XMLGregorianCalendar - *
      • xsd:anySimpleType (for xsd:element of this type)a - * java.lang.Object - *
      • xsd:anySimpleType (for xsd:attribute of this type) - * java.lang.String - *
      • xsd:duration javax.xml.datatype.Duration - *
      • xsd:NOTATION javax.xml.namespace.QName - *
      - */ - - if (literal == null) { - return null; - } - String value = literal.trim(); - if (!simpleType.isSimpleType()) { - throw new IllegalArgumentException("Complex type is not supported for simple java databinding."); - } - TypeInfo baseType = simpleType; - while (baseType.getBaseType() != null) { - baseType = (TypeInfo)baseType.getBaseType(); - } - - QName type = baseType.getQName(); - if (type.equals(XSD_STRING)) { - return parseString(value); - } else if (type.equals(XSD_INT)) { - return parseInt(value); - } else if (type.equals(XSD_INTEGER)) { - return parseInteger(value); - } else if (type.equals(XSD_INT)) { - return parseInt(value); - } else if (type.equals(XSD_FLOAT)) { - return parseFloat(value); - } else if (type.equals(XSD_DOUBLE)) { - return parseDouble(value); - } else if (type.equals(XSD_SHORT)) { - return parseShort(value); - } else if (type.equals(XSD_DECIMAL)) { - return parseDecimal(value); - } else if (type.equals(XSD_BOOLEAN)) { - return parseBoolean(value); - } else if (type.equals(XSD_BYTE)) { - return parseByte(value); - } else if (type.equals(XSD_LONG)) { - return parseLong(value); - } else if (type.equals(XSD_UNSIGNEDBYTE)) { - return parseUnsignedShort(value); - } else if (type.equals(XSD_UNSIGNEDSHORT)) { - return parseUnsignedShort(value); - } else if (type.equals(XSD_UNSIGNEDINT)) { - return parseUnsignedInt(value); - } else if (type.equals(XSD_UNSIGNEDLONG)) { - return parseUnsignedInt(value); - } else if (type.equals(XSD_DATETIME)) { - return parseDateTime(value); - } else if (type.equals(XSD_DATE)) { - return parseDate(value); - } else if (type.equals(XSD_TIME)) { - return parseTime(value); - } else if (type.equals(XSD_DURATION)) { - return parseDuration(value); - } else if (type.equals(XSD_HEXBIN)) { - return parseHexBinary(value); - } else if (type.equals(XSD_BASE64)) { - return parseBase64Binary(value); - } else if (type.equals(XSD_QNAME)) { - NamespaceContext namespaceContext = - (NamespaceContext)((context != null) ? context.getMetadata().get(NamespaceContext.class) - : null); - return parseQName(value, namespaceContext); - } else if (type.equals(XSD_NOTATION)) { - NamespaceContext namespaceContext = - (NamespaceContext)((context != null) ? context.getMetadata().get(NamespaceContext.class) - : null); - return parseQName(value, namespaceContext); - } else if (type.equals(XSD_YEAR)) { - return factory.newXMLGregorianCalendar(value); - } else if (type.equals(XSD_MONTH)) { - return factory.newXMLGregorianCalendar(value); - } else if (type.equals(XSD_DAY)) { - return factory.newXMLGregorianCalendar(value); - } else if (type.equals(XSD_YEARMONTH)) { - return factory.newXMLGregorianCalendar(value); - } else if (type.equals(XSD_MONTHDAY)) { - return factory.newXMLGregorianCalendar(value); - } else { - return value; - } - } - - @SuppressWarnings("deprecation") - private XMLGregorianCalendar toXMLGregorianCalendar(Date date) { - GregorianCalendar c = - new GregorianCalendar(date.getYear(), date.getMonth(), date.getDate(), date.getHours(), date - .getMinutes(), date.getSeconds()); - return factory.newXMLGregorianCalendar(c); - } - - private XMLGregorianCalendar toXMLGregorianCalendar(GregorianCalendar calendar) { - return factory.newXMLGregorianCalendar(calendar); - } - - public String toXMLLiteral(TypeInfo simpleType, Object obj, TransformationContext context) { - if (obj instanceof Float || obj instanceof Double) { - if (obj instanceof Float) { - return printDouble(((Float)obj).floatValue()); - } else { - return printDouble(((Double)obj).doubleValue()); - } - } else if (obj instanceof GregorianCalendar) { - GregorianCalendar calendar = (GregorianCalendar)obj; - return toXMLGregorianCalendar(calendar).toXMLFormat(); - } else if (obj instanceof Date) { - return toXMLGregorianCalendar((Date)obj).toXMLFormat(); - } else if (obj instanceof XMLGregorianCalendar) { - return ((XMLGregorianCalendar)obj).toXMLFormat(); - } else if (obj instanceof byte[]) { - if (simpleType.getQName().equals(XSD_BASE64)) { - return printBase64Binary((byte[])obj); - } else if (simpleType.getQName().equals(XSD_HEXBIN)) { - return printHexBinary((byte[])obj); - } - } else if (obj instanceof QName) { - NamespaceContext namespaceContext = - (NamespaceContext)((context != null) ? context.getMetadata().get(NamespaceContext.class) - : null); - return printQName((QName)obj, namespaceContext); - } - return obj.toString(); - } - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/TransformerExtension.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/TransformerExtension.java deleted file mode 100644 index d54dbca1d1..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/TransformerExtension.java +++ /dev/null @@ -1,73 +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.spi.databinding.extension; - -import org.osoa.sca.annotations.EagerInit; -import org.osoa.sca.annotations.Init; -import org.osoa.sca.annotations.Scope; -import org.osoa.sca.annotations.Service; - -import org.apache.tuscany.spi.annotation.Autowire; -import org.apache.tuscany.spi.databinding.Transformer; -import org.apache.tuscany.spi.databinding.TransformerRegistry; - -/** - * Base Implementation of Transformer which provides the registration to the transformer registry - * - * @version $Rev$ $Date$ - */ -@Service(Transformer.class) -@Scope("COMPOSITE") -@EagerInit -public abstract class TransformerExtension implements Transformer { - - protected TransformerRegistry registry; - - protected TransformerExtension() { - super(); - } - - @Autowire - public void setTransformerRegistry(TransformerRegistry registry) { - this.registry = registry; - } - - @Init - public void init() { - registry.registerTransformer(this); - } - - protected abstract Class getSourceType(); - - protected abstract Class getTargetType(); - - public String getSourceDataBinding() { - return getSourceType().getName(); - } - - public String getTargetDataBinding() { - return getTargetType().getName(); - } - - public int getWeight() { - // default to 50 - return 50; - } - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/XSDDataTypeConverter.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/XSDDataTypeConverter.java deleted file mode 100644 index a0c75570bd..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/XSDDataTypeConverter.java +++ /dev/null @@ -1,940 +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.spi.databinding.extension; - -import java.io.IOException; -import java.io.OutputStream; -import java.io.Writer; -import java.math.BigDecimal; -import java.math.BigInteger; -import java.text.FieldPosition; -import java.text.Format; -import java.text.ParsePosition; -import java.util.Calendar; -import java.util.TimeZone; -import javax.xml.XMLConstants; -import javax.xml.datatype.DatatypeConfigurationException; -import javax.xml.datatype.DatatypeFactory; -import javax.xml.datatype.Duration; -import javax.xml.namespace.NamespaceContext; -import javax.xml.namespace.QName; - -/** - * Utility class for XSD data type conversions - */ -public class XSDDataTypeConverter { - public static final class Base64Binary { - private static final char[] S_BASE64CHAR = - {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', - 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', - 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', - '5', '6', '7', '8', '9', '+', '/'}; - - private static final char S_BASE64PAD = '='; - - private static final byte[] S_DECODETABLE = new byte[128]; - - static { - for (int i = 0; i < S_DECODETABLE.length; i++) { - S_DECODETABLE[i] = Byte.MAX_VALUE; // 127 - } - for (int i = 0; i < S_BASE64CHAR.length; i++) { - // 0 to 63 - S_DECODETABLE[S_BASE64CHAR[i]] = (byte) i; - } - } - - private Base64Binary() { - } - - /** - * - */ - public static byte[] decode(char[] data, int off, int len) { - char[] ibuf = new char[4]; - int ibufcount = 0; - byte[] obuf = new byte[len / 4 * 3 + 3]; - int obufcount = 0; - for (int i = off; i < off + len; i++) { - char ch = data[i]; - if (ch == S_BASE64PAD || ch < S_DECODETABLE.length && S_DECODETABLE[ch] != Byte.MAX_VALUE) { - ibuf[ibufcount++] = ch; - if (ibufcount == ibuf.length) { - ibufcount = 0; - obufcount += decode0(ibuf, obuf, obufcount); - } - } - } - if (obufcount == obuf.length) { - return obuf; - } - byte[] ret = new byte[obufcount]; - System.arraycopy(obuf, 0, ret, 0, obufcount); - return ret; - } - - /** - * - */ - public static void decode(char[] data, int off, int len, OutputStream ostream) throws IOException { - char[] ibuf = new char[4]; - int ibufcount = 0; - byte[] obuf = new byte[3]; - for (int i = off; i < off + len; i++) { - char ch = data[i]; - if (ch == S_BASE64PAD || ch < S_DECODETABLE.length && S_DECODETABLE[ch] != Byte.MAX_VALUE) { - ibuf[ibufcount++] = ch; - if (ibufcount == ibuf.length) { - ibufcount = 0; - int obufcount = decode0(ibuf, obuf, 0); - ostream.write(obuf, 0, obufcount); - } - } - } - } - - /** - * - */ - public static byte[] decode(String data) { - char[] ibuf = new char[4]; - int ibufcount = 0; - byte[] obuf = new byte[data.length() / 4 * 3 + 3]; - int obufcount = 0; - for (int i = 0; i < data.length(); i++) { - char ch = data.charAt(i); - if (ch == S_BASE64PAD || ch < S_DECODETABLE.length && S_DECODETABLE[ch] != Byte.MAX_VALUE) { - ibuf[ibufcount++] = ch; - if (ibufcount == ibuf.length) { - ibufcount = 0; - obufcount += decode0(ibuf, obuf, obufcount); - } - } - } - if (obufcount == obuf.length) { - return obuf; - } - byte[] ret = new byte[obufcount]; - System.arraycopy(obuf, 0, ret, 0, obufcount); - return ret; - } - - /** - * - */ - public static void decode(String data, OutputStream ostream) throws IOException { - char[] ibuf = new char[4]; - int ibufcount = 0; - byte[] obuf = new byte[3]; - for (int i = 0; i < data.length(); i++) { - char ch = data.charAt(i); - if (ch == S_BASE64PAD || ch < S_DECODETABLE.length && S_DECODETABLE[ch] != Byte.MAX_VALUE) { - ibuf[ibufcount++] = ch; - if (ibufcount == ibuf.length) { - ibufcount = 0; - int obufcount = decode0(ibuf, obuf, 0); - ostream.write(obuf, 0, obufcount); - } - } - } - } - - private static int decode0(char[] ibuf, byte[] obuf, int index) { - int wp = index; - int outlen = 3; - if (ibuf[3] == S_BASE64PAD) { - outlen = 2; - } - if (ibuf[2] == S_BASE64PAD) { - outlen = 1; - } - int b0 = S_DECODETABLE[ibuf[0]]; - int b1 = S_DECODETABLE[ibuf[1]]; - int b2 = S_DECODETABLE[ibuf[2]]; - int b3 = S_DECODETABLE[ibuf[3]]; - switch (outlen) { - case 1: - obuf[wp] = (byte) (b0 << 2 & 0xfc | b1 >> 4 & 0x3); - return 1; - case 2: - obuf[wp++] = (byte) (b0 << 2 & 0xfc | b1 >> 4 & 0x3); - obuf[wp] = (byte) (b1 << 4 & 0xf0 | b2 >> 2 & 0xf); - return 2; - case 3: - obuf[wp++] = (byte) (b0 << 2 & 0xfc | b1 >> 4 & 0x3); - obuf[wp++] = (byte) (b1 << 4 & 0xf0 | b2 >> 2 & 0xf); - obuf[wp] = (byte) (b2 << 6 & 0xc0 | b3 & 0x3f); - return 3; - default: - throw new IllegalArgumentException("The character sequence is not base64 encoded."); - } - } - - /** - * Returns base64 representation of specified byte array. - */ - public static String encode(byte[] data) { - return encode(data, 0, data.length); - } - - /** - * Returns base64 representation of specified byte array. - */ - public static String encode(byte[] data, int off, int len) { - if (len <= 0) { - return ""; - } - char[] out = new char[len / 3 * 4 + 4]; - int rindex = off; - int windex = 0; - int rest = len - off; - while (rest >= 3) { - int i = - ((data[rindex] & 0xff) << 16) + ((data[rindex + 1] & 0xff) << 8) - + (data[rindex + 2] & 0xff); - out[windex++] = S_BASE64CHAR[i >> 18]; - out[windex++] = S_BASE64CHAR[(i >> 12) & 0x3f]; - out[windex++] = S_BASE64CHAR[(i >> 6) & 0x3f]; - out[windex++] = S_BASE64CHAR[i & 0x3f]; - rindex += 3; - rest -= 3; - } - if (rest == 1) { - int i = data[rindex] & 0xff; - out[windex++] = S_BASE64CHAR[i >> 2]; - out[windex++] = S_BASE64CHAR[(i << 4) & 0x3f]; - out[windex++] = S_BASE64PAD; - out[windex++] = S_BASE64PAD; - } else if (rest == 2) { - int i = ((data[rindex] & 0xff) << 8) + (data[rindex + 1] & 0xff); - out[windex++] = S_BASE64CHAR[i >> 10]; - out[windex++] = S_BASE64CHAR[(i >> 4) & 0x3f]; - out[windex++] = S_BASE64CHAR[(i << 2) & 0x3f]; - out[windex++] = S_BASE64PAD; - } - return new String(out, 0, windex); - } - - /** - * Outputs base64 representation of the specified byte array to a byte stream. - */ - public static void encode(byte[] data, int off, int len, OutputStream ostream) throws IOException { - if (len <= 0) { - return; - } - byte[] out = new byte[4]; - int rindex = off; - int rest = len - off; - while (rest >= 3) { - int i = - ((data[rindex] & 0xff) << 16) + ((data[rindex + 1] & 0xff) << 8) - + (data[rindex + 2] & 0xff); - out[0] = (byte) S_BASE64CHAR[i >> 18]; - out[1] = (byte) S_BASE64CHAR[(i >> 12) & 0x3f]; - out[2] = (byte) S_BASE64CHAR[(i >> 6) & 0x3f]; - out[3] = (byte) S_BASE64CHAR[i & 0x3f]; - ostream.write(out, 0, 4); - rindex += 3; - rest -= 3; - } - if (rest == 1) { - int i = data[rindex] & 0xff; - out[0] = (byte) S_BASE64CHAR[i >> 2]; - out[1] = (byte) S_BASE64CHAR[(i << 4) & 0x3f]; - out[2] = (byte) S_BASE64PAD; - out[3] = (byte) S_BASE64PAD; - ostream.write(out, 0, 4); - } else if (rest == 2) { - int i = ((data[rindex] & 0xff) << 8) + (data[rindex + 1] & 0xff); - out[0] = (byte) S_BASE64CHAR[i >> 10]; - out[1] = (byte) S_BASE64CHAR[(i >> 4) & 0x3f]; - out[2] = (byte) S_BASE64CHAR[(i << 2) & 0x3f]; - out[3] = (byte) S_BASE64PAD; - ostream.write(out, 0, 4); - } - } - - /** - * Outputs base64 representation of the specified byte array to a character stream. - */ - public static void encode(byte[] data, int off, int len, Writer writer) throws IOException { - if (len <= 0) { - return; - } - char[] out = new char[4]; - int rindex = off; - int rest = len - off; - int output = 0; - while (rest >= 3) { - int i = - ((data[rindex] & 0xff) << 16) + ((data[rindex + 1] & 0xff) << 8) - + (data[rindex + 2] & 0xff); - out[0] = S_BASE64CHAR[i >> 18]; - out[1] = S_BASE64CHAR[(i >> 12) & 0x3f]; - out[2] = S_BASE64CHAR[(i >> 6) & 0x3f]; - out[3] = S_BASE64CHAR[i & 0x3f]; - writer.write(out, 0, 4); - rindex += 3; - rest -= 3; - output += 4; - if (output % 76 == 0) { - writer.write("\n"); - } - } - if (rest == 1) { - int i = data[rindex] & 0xff; - out[0] = S_BASE64CHAR[i >> 2]; - out[1] = S_BASE64CHAR[(i << 4) & 0x3f]; - out[2] = S_BASE64PAD; - out[3] = S_BASE64PAD; - writer.write(out, 0, 4); - } else if (rest == 2) { - int i = ((data[rindex] & 0xff) << 8) + (data[rindex + 1] & 0xff); - out[0] = S_BASE64CHAR[i >> 10]; - out[1] = S_BASE64CHAR[(i >> 4) & 0x3f]; - out[2] = S_BASE64CHAR[(i << 2) & 0x3f]; - out[3] = S_BASE64PAD; - writer.write(out, 0, 4); - } - } - } - - /** - *

      - * Utility class for xs:hexbinary.

      - */ - public static final class HexBinary { - private HexBinary() { - } - - /** - * Converts the string pValue into an array of hex bytes. - */ - public static byte[] decode(String pValue) { - if ((pValue.length() % 2) != 0) { - throw new IllegalArgumentException("A HexBinary string must have even length."); - } - byte[] result = new byte[pValue.length() / 2]; - int j = 0; - int i = 0; - while (i < pValue.length()) { - byte b; - char c = pValue.charAt(i++); - char d = pValue.charAt(i++); - if (c >= '0' && c <= '9') { - b = (byte) ((c - '0') << 4); - } else if (c >= 'A' && c <= 'F') { - b = (byte) ((c - 'A' + 10) << 4); - } else if (c >= 'a' && c <= 'f') { - b = (byte) ((c - 'a' + 10) << 4); - } else { - throw new IllegalArgumentException("Invalid hex digit: " + c); - } - if (d >= '0' && d <= '9') { - b += (byte) (d - '0'); - } else if (d >= 'A' && d <= 'F') { - b += (byte) (d - 'A' + 10); - } else if (d >= 'a' && d <= 'f') { - b += (byte) (d - 'a' + 10); - } else { - throw new IllegalArgumentException("Invalid hex digit: " + d); - } - result[j++] = b; - } - return result; - } - - /** - * Converts the byte array pHexBinary into a string. - */ - public static String encode(byte[] pHexBinary) { - StringBuffer result = new StringBuffer(); - for (int i = 0; i < pHexBinary.length; i++) { - byte b = pHexBinary[i]; - byte c = (byte) ((b & 0xf0) >> 4); - if (c <= 9) { - result.append((char) ('0' + c)); - } else { - result.append((char) ('A' + c - 10)); - } - c = (byte) (b & 0x0f); - if (c <= 9) { - result.append((char) ('0' + c)); - } else { - result.append((char) ('A' + c - 10)); - } - } - return result.toString(); - } - - /** - * Creates a clone of the given byte array. - */ - public static byte[] getClone(byte[] pHexBinary) { - byte[] result = new byte[pHexBinary.length]; - System.arraycopy(pHexBinary, 0, result, 0, pHexBinary.length); - return result; - } - } - - public class XSDDateFormat extends XSDDateTimeFormat { - private static final long serialVersionUID = -1629412916827246627L; - - /** - * Creates a new instance. - */ - public XSDDateFormat() { - super(true, false); - } - } - - /** - *

      - * An instance of {@link java.text.Format}, which may be used to parse and format xs:dateTime values. - *

      - */ - public static class XSDDateTimeFormat extends Format { - private static final long serialVersionUID = -1148332471737068969L; - - final boolean parseDate; - - final boolean parseTime; - - /** - * Creates a new instance. - */ - public XSDDateTimeFormat() { - this(true, true); - } - - XSDDateTimeFormat(boolean pParseDate, boolean pParseTime) { - parseDate = pParseDate; - parseTime = pParseTime; - } - - private void append(StringBuffer pBuffer, int pNum, int pMinLen) { - String s = Integer.toString(pNum); - for (int i = s.length(); i < pMinLen; i++) { - pBuffer.append('0'); - } - pBuffer.append(s); - } - - public StringBuffer format(Object pCalendar, StringBuffer pBuffer, FieldPosition pPos) { - assert pCalendar != null : "The Calendar argument must not be null."; - assert pBuffer != null : "The StringBuffer argument must not be null."; - assert pPos != null : "The FieldPosition argument must not be null."; - - Calendar cal = (Calendar) pCalendar; - if (parseDate) { - int year = cal.get(Calendar.YEAR); - if (year < 0) { - pBuffer.append('-'); - year = -year; - } - append(pBuffer, year, 4); - pBuffer.append('-'); - append(pBuffer, cal.get(Calendar.MONTH) + 1, 2); - pBuffer.append('-'); - append(pBuffer, cal.get(Calendar.DAY_OF_MONTH), 2); - if (parseTime) { - pBuffer.append('T'); - } - } - if (parseTime) { - append(pBuffer, cal.get(Calendar.HOUR_OF_DAY), 2); - pBuffer.append(':'); - append(pBuffer, cal.get(Calendar.MINUTE), 2); - pBuffer.append(':'); - append(pBuffer, cal.get(Calendar.SECOND), 2); - int millis = cal.get(Calendar.MILLISECOND); - if (millis > 0) { - pBuffer.append('.'); - append(pBuffer, millis, 3); - } - } - TimeZone tz = cal.getTimeZone(); - // JDK 1.4: int offset = tz.getOffset(cal.getTimeInMillis()); - int offset = cal.get(Calendar.ZONE_OFFSET); - if (tz.inDaylightTime(cal.getTime())) { - offset += cal.get(Calendar.DST_OFFSET); - } - if (offset == 0) { - pBuffer.append('Z'); - } else { - if (offset < 0) { - pBuffer.append('-'); - offset = -offset; - } else { - pBuffer.append('+'); - } - int minutes = offset / (60 * 1000); - int hours = minutes / 60; - minutes -= hours * 60; - append(pBuffer, hours, 2); - pBuffer.append(':'); - append(pBuffer, minutes, 2); - } - return pBuffer; - } - - private int parseInt(String pString, int offset, StringBuffer pDigits) { - int length = pString.length(); - int pOffset = offset; - pDigits.setLength(0); - while (pOffset < length) { - char c = pString.charAt(pOffset); - if (Character.isDigit(c)) { - pDigits.append(c); - ++pOffset; - } else { - break; - } - } - return pOffset; - } - - public Object parseObject(String pString, ParsePosition pParsePosition) { - assert pString != null : "The String argument must not be null."; - assert pParsePosition != null : "The ParsePosition argument must not be null."; - int offset = pParsePosition.getIndex(); - int length = pString.length(); - - boolean isMinus = false; - StringBuffer digits = new StringBuffer(); - int year = 0; - int month = 0; - int mday = 0; - if (parseDate) { - // Sign - if (offset < length) { - char c = pString.charAt(offset); - if (c == '+') { - ++offset; - } else if (c == '-') { - ++offset; - isMinus = true; - } - } - - offset = parseInt(pString, offset, digits); - if (digits.length() < 4) { - pParsePosition.setErrorIndex(offset); - return null; - } - year = Integer.parseInt(digits.toString()); - - if (offset < length && pString.charAt(offset) == '-') { - ++offset; - } else { - pParsePosition.setErrorIndex(offset); - return null; - } - - offset = parseInt(pString, offset, digits); - if (digits.length() != 2) { - pParsePosition.setErrorIndex(offset); - return null; - } - month = Integer.parseInt(digits.toString()); - - if (offset < length && pString.charAt(offset) == '-') { - ++offset; - } else { - pParsePosition.setErrorIndex(offset); - return null; - } - - offset = parseInt(pString, offset, digits); - if (digits.length() != 2) { - pParsePosition.setErrorIndex(offset); - return null; - } - mday = Integer.parseInt(digits.toString()); - - if (parseTime) { - if (offset < length && pString.charAt(offset) == 'T') { - ++offset; - } else { - pParsePosition.setErrorIndex(offset); - return null; - } - } - } else { - year = month = mday = 0; - } - - int hour = 0; - int minute = 0; - int second = 0; - int millis = 0; - if (parseTime) { - offset = parseInt(pString, offset, digits); - if (digits.length() != 2) { - pParsePosition.setErrorIndex(offset); - return null; - } - hour = Integer.parseInt(digits.toString()); - - if (offset < length && pString.charAt(offset) == ':') { - ++offset; - } else { - pParsePosition.setErrorIndex(offset); - return null; - } - - offset = parseInt(pString, offset, digits); - if (digits.length() != 2) { - pParsePosition.setErrorIndex(offset); - return null; - } - minute = Integer.parseInt(digits.toString()); - - if (offset < length && pString.charAt(offset) == ':') { - ++offset; - } else { - pParsePosition.setErrorIndex(offset); - return null; - } - - offset = parseInt(pString, offset, digits); - if (digits.length() != 2) { - pParsePosition.setErrorIndex(offset); - return null; - } - second = Integer.parseInt(digits.toString()); - - if (offset < length && pString.charAt(offset) == '.') { - ++offset; - offset = parseInt(pString, offset, digits); - if (digits.length() > 0) { - millis = Integer.parseInt(digits.toString()); - } else { - millis = 0; - } - } else { - millis = 0; - } - } else { - hour = minute = second = millis = 0; - } - - digits.setLength(0); - digits.append("GMT"); - if (offset < length) { - char c = pString.charAt(offset); - if (c == 'Z') { - // Ignore UTC, it is the default - ++offset; - } else if (c == '+' || c == '-') { - digits.append(c); - ++offset; - for (int i = 0; i < 5; i++) { - if (offset >= length) { - pParsePosition.setErrorIndex(offset); - return null; - } - c = pString.charAt(offset); - if ((i != 2 && Character.isDigit(c)) || (i == 2 && c == ':')) { - digits.append(c); - } else { - pParsePosition.setErrorIndex(offset); - return null; - } - ++offset; - } - } - } - - Calendar cal = Calendar.getInstance(TimeZone.getTimeZone(digits.toString())); - cal.set(isMinus ? -year : year, parseDate ? month - 1 : month, mday, hour, minute, second); - cal.set(Calendar.MILLISECOND, millis); - pParsePosition.setIndex(offset); - return cal; - } - } - - public static class XSDTimeFormat extends XSDDateTimeFormat { - private static final long serialVersionUID = 1346506860724640517L; - - /** - * Creates a new instance. - */ - public XSDTimeFormat() { - super(false, true); - } - } - - private static final long MAX_UNSIGNED_INT = (((long) Integer.MAX_VALUE) * 2) + 1; - - private static final int MAX_UNSIGNED_SHORT = Short.MAX_VALUE * 2 + 1; - - public String parseAnySimpleType(String value) { - return value; - } - - public byte[] parseBase64Binary(String value) { - return Base64Binary.decode(value); - } - - public boolean parseBoolean(String value) { - return Boolean.valueOf(value).booleanValue(); - } - - public byte parseByte(String value) { - return Byte.parseByte(value); - } - - public Calendar parseDate(String value) { - XSDDateFormat format = new XSDDateFormat(); - ParsePosition pos = new ParsePosition(0); - Calendar cal = (Calendar) format.parseObject(value, pos); - if (cal == null) { - throw new IllegalArgumentException("Failed to parse date " + value + " at:" - + value.substring(pos.getErrorIndex())); - } - return cal; - } - - public Calendar parseDateTime(String value) { - XSDDateTimeFormat format = new XSDDateTimeFormat(); - ParsePosition pos = new ParsePosition(0); - Calendar cal = (Calendar) format.parseObject(value, pos); - if (cal == null) { - throw new IllegalArgumentException("Failed to parse dateTime " + value + " at:" - + value.substring(pos.getErrorIndex())); - } - return cal; - } - - public BigDecimal parseDecimal(String value) { - return new BigDecimal(value); - } - - public double parseDouble(String value) { - if ("INF".equals(value)) { - return Double.POSITIVE_INFINITY; - } else if ("-INF".equals(value)) { - return Double.NEGATIVE_INFINITY; - } else if ("NaN".equals(value)) { - return Double.NaN; - } else { - return Double.parseDouble(value); - } - } - - public Duration parseDuration(String pDuration) { - try { - return DatatypeFactory.newInstance().newDuration(pDuration); - } catch (DatatypeConfigurationException e) { - throw new IllegalArgumentException(e); - } - } - - public float parseFloat(String value) { - if ("INF".equals(value)) { - return Float.POSITIVE_INFINITY; - } else if ("-INF".equals(value)) { - return Float.NEGATIVE_INFINITY; - } else if ("NaN".equals(value)) { - return Float.NaN; - } else { - return Float.parseFloat(value); - } - } - - public byte[] parseHexBinary(String value) { - return HexBinary.decode(value); - } - - public int parseInt(String value) { - return Integer.parseInt(value); - } - - public BigInteger parseInteger(String value) { - return new BigInteger(value); - } - - public long parseLong(String value) { - return Long.parseLong(value); - } - - public QName parseQName(String value, NamespaceContext context) { - int offset = value.indexOf(':'); - String uri; - String localName; - switch (offset) { - case -1: - localName = value; - uri = context.getNamespaceURI(""); - if (uri == null) { - // Should not happen, indicates an error in the - // NamespaceContext - // implementation - throw new IllegalArgumentException("The default prefix is not bound."); - } - break; - case 0: - throw new IllegalArgumentException("Default prefix must be indicated by not using a colon: " - + value); - default: - String prefix = value.substring(0, offset); - localName = value.substring(offset + 1); - uri = context.getNamespaceURI(prefix); - if (uri == null) { - throw new IllegalArgumentException("The prefix " + prefix + " is not bound."); - } - } - return new QName(uri, localName); - } - - public short parseShort(String value) { - return Short.parseShort(value); - } - - public String parseString(String value) { - return value; - } - - public Calendar parseTime(String value) { - XSDTimeFormat format = new XSDTimeFormat(); - ParsePosition pos = new ParsePosition(0); - Calendar cal = (Calendar) format.parseObject(value, pos); - if (cal == null) { - throw new IllegalArgumentException("Failed to parse time " + value + " at:" - + value.substring(pos.getErrorIndex())); - } - return cal; - } - - public long parseUnsignedInt(String value) { - long l = Long.parseLong(value); - if (l < 0) { - throw new IllegalArgumentException("Failed to parse UnsignedInt " + value - + ": result is negative"); - } - if (l > MAX_UNSIGNED_INT) { - throw new IllegalArgumentException("Failed to parse UnsignedInt " + value - + ": result exceeds maximum value " + MAX_UNSIGNED_INT); - } - return l; - } - - public int parseUnsignedShort(String value) { - int i = Integer.parseInt(value); - if (i < 0) { - throw new IllegalArgumentException("Failed to parse UnsignedShort " + value - + ": result is negative"); - } - if (i > MAX_UNSIGNED_SHORT) { - throw new IllegalArgumentException("Failed to parse UnsignedShort " + value - + ": result exceeds maximum value " + MAX_UNSIGNED_SHORT); - } - return i; - } - - public String printAnySimpleType(String value) { - return value; - } - - public String printBase64Binary(byte[] value) { - return Base64Binary.encode(value); - } - - public String printBoolean(boolean value) { - return (value ? Boolean.TRUE : Boolean.FALSE).toString(); - } - - public String printByte(byte value) { - return Byte.toString(value); - } - - public String printDate(Calendar value) { - return new XSDDateFormat().format(value); - } - - public String printDateTime(Calendar value) { - return new XSDDateTimeFormat().format(value); - } - - public String printDecimal(BigDecimal value) { - return value.toString(); - } - - public String printDouble(double value) { - return Double.toString(value); - } - - public String printDuration(Duration pDuration) { - return pDuration.toString(); - } - - public String printFloat(float value) { - return Float.toString(value); - } - - public String printHexBinary(byte[] value) { - return HexBinary.encode(value); - } - - public String printInt(int value) { - return Integer.toString(value); - } - - public String printInteger(BigInteger value) { - return value.toString(); - } - - public String printLong(long value) { - return Long.toString(value); - } - - public String printQName(QName value, NamespaceContext context) { - String prefix = context.getPrefix(value.getNamespaceURI()); - if (prefix == null) { - throw new IllegalArgumentException("The namespace URI " + value.getNamespaceURI() - + " is not bound."); - } else if (XMLConstants.DEFAULT_NS_PREFIX.equals(prefix)) { - return value.getLocalPart(); - } else { - return prefix + ":" + value.getLocalPart(); - } - } - - public String printShort(short value) { - return Short.toString(value); - } - - public String printString(String value) { - return value; - } - - public String printTime(Calendar value) { - return new XSDTimeFormat().format(value); - } - - public String printUnsignedInt(long value) { - return Long.toString(value); - } - - public String printUnsignedShort(int value) { - return Integer.toString(value); - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/ChangeSetHandler.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/ChangeSetHandler.java deleted file mode 100644 index fead0453be..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/ChangeSetHandler.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.spi.deployer; - -import java.io.IOException; -import java.io.InputStream; - -import org.apache.tuscany.host.deployment.DeploymentException; - -/** - * Interface implemented by services that process assembly change sets. - * - * @version $Rev$ $Date$ - */ -public interface ChangeSetHandler { - /** - * Returns the content type that this implementation can handle. - * - * @return the content type that this implementation can handle - */ - String getContentType(); - - /** - * Apply the changes in the supplied changeSet stream to an Assembly. - * The content on the stream must match the content type this implementation can handle. - * - * @param changeSet the set of changes to apply represented as the supported content type - * @throws DeploymentException if there was a problem applying the changes - * @throws IOException if there was a problem reading the stream - */ - void applyChanges(InputStream changeSet) throws DeploymentException, IOException; -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/ChangeSetHandlerRegistry.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/ChangeSetHandlerRegistry.java deleted file mode 100644 index df0bf4109b..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/ChangeSetHandlerRegistry.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.spi.deployer; - -/** - * Registry for ChangeSetHandler implementations. - * - * @version $Rev$ $Date$ - */ -public interface ChangeSetHandlerRegistry { - void register(ChangeSetHandler handler); -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/CompositeClassLoader.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/CompositeClassLoader.java deleted file mode 100644 index 63db5b9e24..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/CompositeClassLoader.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.spi.deployer; - -import java.net.URLClassLoader; -import java.net.URL; -import java.net.URLStreamHandlerFactory; - -/** - * ClassLoader associated with a composite. - * - * @version $Rev$ $Date$ - */ -public class CompositeClassLoader extends URLClassLoader { - private static final URL[] NOURLS = {}; - - public CompositeClassLoader(ClassLoader classLoader) { - super(NOURLS, classLoader); - } - - public CompositeClassLoader(URL[] urls, ClassLoader classLoader) { - super(urls, classLoader); - } - - public CompositeClassLoader(URL[] urls) { - super(urls); - } - - public CompositeClassLoader(URL[] urls, ClassLoader classLoader, URLStreamHandlerFactory urlStreamHandlerFactory) { - super(urls, classLoader, urlStreamHandlerFactory); - } - - public void addURL(URL url) { - super.addURL(url); - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/ContributionProcessor.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/ContributionProcessor.java deleted file mode 100644 index 4ec57b8fc1..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/ContributionProcessor.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.spi.deployer; - -/** - * Interface for services that can process contributions. - * - * @version $Rev$ $Date$ - */ -public interface ContributionProcessor { - /** - * Returns the content type that this implementation can handle. - * - * @return the content type that this implementation can handle - */ - String getContentType(); -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/ContributionProcessorRegistry.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/ContributionProcessorRegistry.java deleted file mode 100644 index 410c6dd61d..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/ContributionProcessorRegistry.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.spi.deployer; - -/** - * @version $Rev$ $Date$ - */ -public interface ContributionProcessorRegistry { - void register(ContributionProcessor processor); -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/Deployer.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/Deployer.java deleted file mode 100644 index 796416188f..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/Deployer.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.spi.deployer; - -import org.apache.tuscany.spi.builder.BuilderException; -import org.apache.tuscany.spi.component.Component; -import org.apache.tuscany.spi.component.ComponentException; -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.loader.LoaderException; -import org.apache.tuscany.spi.model.ComponentDefinition; -import org.apache.tuscany.spi.model.Implementation; - -/** - * Interface that can be used to deploy SCA bundles to a runtime. - * - * @version $Rev$ $Date$ - */ -public interface Deployer { - /** - * Deploy a component as a child of the supplied parent. This operation creates a new component in the runtime to - * represent the supplied component definition. The type of component created will depend on the component - * definition implementation; for example, if the implementation of the component definition is a composite then - * typically a CompositeComponent would be returned. - * - * @param parent the parent context - * @param componentDefinition the component definition as parsed from an assembly - * @return the newly deployed component - */ - > Component deploy(CompositeComponent parent, - ComponentDefinition componentDefinition) - throws LoaderException, BuilderException, ComponentException; -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/DeploymentContext.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/DeploymentContext.java deleted file mode 100644 index 921781c484..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/DeploymentContext.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.spi.deployer; - -import java.net.URL; -import javax.xml.stream.XMLInputFactory; - -import org.apache.tuscany.spi.component.ScopeContainer; - -/** - * 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 interface DeploymentContext { - /** - * Returns the parent of this deployment context. - * Will be null for the context created at the root of a deployment. - * - * @return the parent of this deployment context; may be null - */ - DeploymentContext getParent(); - - /** - * Returns a class loader that can be used to load application resources. - * - * @return a class loader that can be used to load application resources - */ - ClassLoader getClassLoader(); - - /** - * Returns a factory that can be used to obtain an StAX XMLStreamReader. - * - * @return a factory that can be used to obtain an StAX XMLStreamReader - */ - XMLInputFactory getXmlFactory(); - - /** - * Returns the ScopeContainer for the COMPOSITE scope that will be associated with this deployment unit. - * - * @return the ScopeContainer for the COMPOSITE scope that will be associated with this deployment unit - */ - ScopeContainer getCompositeScope(); - - /** - * Returns the location of the SCDL definition being deployed. - * - * @return the location of the SCDL definition being deployed - */ - URL getScdlLocation(); - - /** - * Return the extension property with the supplied name. - * - * @param name the name of the property - * @return the property value; if null indicates that no property is present - */ - Object getExtension(String name); - - /** - * Set the value of an extension property. - * - * @param name the name of the property - * @param value the property value; if null then the extension property is removed - */ - void putExtension(String name, Object value); -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/DeploymentMonitor.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/DeploymentMonitor.java deleted file mode 100644 index 8485a2a6fc..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/DeploymentMonitor.java +++ /dev/null @@ -1,20 +0,0 @@ -package org.apache.tuscany.spi.deployer; - -import org.apache.tuscany.api.TuscanyException; -import org.apache.tuscany.api.annotation.LogLevel; - -/** - * @version $Rev$ $Date$ - */ -public interface DeploymentMonitor { - - @LogLevel("DEBUG") - void startDeployment(); - - @LogLevel("DEBUG") - void endDeployment(); - - @LogLevel("SEVERE") - void deploymentError(TuscanyException e); - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/event/AbstractEventPublisher.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/event/AbstractEventPublisher.java deleted file mode 100644 index cc20866cbb..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/event/AbstractEventPublisher.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.spi.event; - -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.CopyOnWriteArrayList; - -/** - * Base implementation of an EventPublisher - * - * @version $Rev$ $Date$ - */ -public abstract class AbstractEventPublisher implements EventPublisher { - protected static final EventFilter TRUE_FILTER = new TrueFilter(); - protected Map> listeners; - - public void addListener(RuntimeEventListener listener) { - addListener(TRUE_FILTER, listener); - } - - public void removeListener(RuntimeEventListener listener) { - assert listener != null : "Listener cannot be null"; - synchronized (getListeners()) { - for (List currentList : getListeners().values()) { - for (RuntimeEventListener current : currentList) { - if (current == listener) { - currentList.remove(current); - return; - } - } - } - } - } - - public void addListener(EventFilter filter, RuntimeEventListener listener) { - assert listener != null : "Listener cannot be null"; - synchronized (getListeners()) { - List list = getListeners().get(filter); - if (list == null) { - list = new CopyOnWriteArrayList(); - listeners.put(filter, list); - } - list.add(listener); - } - } - - public void publish(Event event) { - assert event != null : "Event object was null"; - for (Map.Entry> entry : getListeners().entrySet()) { - if (entry.getKey().match(event)) { - for (RuntimeEventListener listener : entry.getValue()) { - listener.onEvent(event); - } - } - } - } - - protected Map> getListeners() { - if (listeners == null) { - listeners = new ConcurrentHashMap>(); - } - return listeners; - } - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/event/Event.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/event/Event.java deleted file mode 100644 index b874ca43c9..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/event/Event.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.spi.event; - -/** - * Represents an event that is propagated in the runtime - * - * @version $$Rev$$ $$Date$$ - */ -public interface Event { - - /** - * Returns the source of the event - */ - Object getSource(); - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/event/EventFilter.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/event/EventFilter.java deleted file mode 100644 index d61d04cdc8..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/event/EventFilter.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.spi.event; - -/** - * Evaluates whether a {@link RuntimeEventListener} is applicable to a given runtime event - * - * @version $$Rev$$ $$Date$$ - */ -public interface EventFilter { - - /** - * Performs the actual evaluation on an event - */ - boolean match(Event event); - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/event/EventPublisher.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/event/EventPublisher.java deleted file mode 100644 index 35df22fb9c..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/event/EventPublisher.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.spi.event; - -/** - * Publishes events in the runtime - * - * @version $$Rev$$ $$Date$$ - */ -public interface EventPublisher { - - /** - * Publish an event - */ - void publish(Event object); - - /** - * Registers a listener to receive notifications for the context - */ - void addListener(RuntimeEventListener listener); - - /** - * Registers a listener to receive notifications for the context - */ - void addListener(EventFilter filter, RuntimeEventListener listener); - - - /** - * Removes a previously registered listener - */ - void removeListener(RuntimeEventListener listener); - - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/event/RuntimeEventListener.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/event/RuntimeEventListener.java deleted file mode 100644 index 5146559098..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/event/RuntimeEventListener.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.spi.event; - -import java.util.EventListener; - -/** - * Listeners observe events fired in the SCA runtime. - * - * @version $Rev$ $Date$ - */ -public interface RuntimeEventListener extends EventListener { - - void onEvent(Event event); -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/event/TrueFilter.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/event/TrueFilter.java deleted file mode 100644 index 81382b86ac..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/event/TrueFilter.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.spi.event; - -/** - * An event filter that always returns a true condition - * - * @version $$Rev$$ $$Date$$ - */ -public class TrueFilter implements EventFilter { - - public boolean match(Event event) { - return true; - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/AbstractComponentExtension.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/AbstractComponentExtension.java deleted file mode 100644 index a6c1ff086f..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/AbstractComponentExtension.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.spi.extension; - -import java.util.Map; - -import org.apache.tuscany.spi.component.AbstractSCAObject; -import org.apache.tuscany.spi.component.Component; -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.component.ScopeContainer; -import org.apache.tuscany.spi.model.PropertyValue; - -/** - * @version Provides support for property accessors. - */ -public abstract class AbstractComponentExtension extends AbstractSCAObject implements Component { - protected ScopeContainer scopeContainer; - - /** - * Default property values. - */ - private Map> defaultPropertyValues; - - /** - * Initializes component name and parent. - * - * @param name Name of the component. - * @param parent Parent of the component. - */ - public AbstractComponentExtension(String name, CompositeComponent parent) { - super(name, parent); - } - - public void setScopeContainer(ScopeContainer scopeContainer) { - this.scopeContainer = scopeContainer; - } - - public Map> getDefaultPropertyValues() { - return defaultPropertyValues; - } - - public void setDefaultPropertyValues(Map> defaultPropertyValues) { - this.defaultPropertyValues = defaultPropertyValues; - } - - public boolean isOptimizable() { - return false; - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/AtomicComponentExtension.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/AtomicComponentExtension.java deleted file mode 100644 index b2b49757fb..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/AtomicComponentExtension.java +++ /dev/null @@ -1,216 +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.spi.extension; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.tuscany.spi.CoreRuntimeException; -import org.apache.tuscany.spi.component.AtomicComponent; -import org.apache.tuscany.spi.component.ComponentException; -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.component.PrepareException; -import org.apache.tuscany.spi.component.ScopeContainer; -import org.apache.tuscany.spi.component.TargetDestructionException; -import org.apache.tuscany.spi.component.TargetInitializationException; -import org.apache.tuscany.spi.component.TargetInvokerCreationException; -import org.apache.tuscany.spi.component.WorkContext; -import org.apache.tuscany.spi.model.Operation; -import org.apache.tuscany.spi.model.Scope; -import org.apache.tuscany.spi.services.work.WorkScheduler; -import org.apache.tuscany.spi.wire.InboundInvocationChain; -import org.apache.tuscany.spi.wire.InboundWire; -import org.apache.tuscany.spi.wire.OutboundWire; -import org.apache.tuscany.spi.wire.TargetInvoker; -import org.apache.tuscany.spi.wire.WireService; - -/** - * An extension point for atomic component type, which new implementation types may extend - * - * @version $$Rev$$ $$Date$$ - */ -public abstract class AtomicComponentExtension extends AbstractComponentExtension implements AtomicComponent { - protected ScopeContainer scopeContainer; - protected Scope scope; - protected Map serviceWires = new HashMap(); - protected Map> referenceWires = new HashMap>(); - protected WireService wireService; - protected WorkContext workContext; - protected WorkScheduler workScheduler; - protected ExecutionMonitor monitor; - private final int initLevel; - private final long maxIdleTime; - private final long maxAge; - private boolean allowsPassByReference; - - protected AtomicComponentExtension(String name, - CompositeComponent parent, - WireService wireService, - WorkContext workContext, - WorkScheduler workScheduler, - ExecutionMonitor monitor, - int initLevel) { - this(name, parent, wireService, workContext, workScheduler, monitor, initLevel, -1, -1); - - } - - protected AtomicComponentExtension(String name, - CompositeComponent parent, - WireService wireService, - WorkContext workContext, - WorkScheduler workScheduler, - ExecutionMonitor monitor, - int initLevel, - long maxIdleTime, - long maxAge) { - super(name, parent); - assert !(maxIdleTime > 0 && maxAge > 0); - this.wireService = wireService; - this.workContext = workContext; - this.workScheduler = workScheduler; - this.monitor = monitor; - this.initLevel = initLevel; - this.maxIdleTime = maxIdleTime; - this.maxAge = maxAge; - } - - public Scope getScope() { - return scope; - } - - public int getInitLevel() { - return initLevel; - } - - public boolean isEagerInit() { - return initLevel > 0; - } - - public boolean isDestroyable() { - return false; - } - - public long getMaxIdleTime() { - return maxIdleTime; - } - - public long getMaxAge() { - return maxAge; - } - - public boolean isAllowsPassByReference() { - return allowsPassByReference; - } - - public void setAllowsPassByReference(boolean allowsPassByReference) { - this.allowsPassByReference = allowsPassByReference; - } - - - public void setScopeContainer(ScopeContainer scopeContainer) { - this.scopeContainer = scopeContainer; - scope = scopeContainer.getScope(); - } - - public void start() throws CoreRuntimeException { - super.start(); - scopeContainer.register(this); - } - - public void init(Object instance) throws TargetInitializationException { - - } - - public void destroy(Object instance) throws TargetDestructionException { - - } - - public void addInboundWire(InboundWire wire) { - serviceWires.put(wire.getServiceName(), wire); - onServiceWire(wire); - } - - public InboundWire getInboundWire(String serviceName) { - if (serviceName == null) { - if (serviceWires.size() < 1) { - return null; - } - return serviceWires.values().iterator().next(); - } else { - return serviceWires.get(serviceName); - } - } - - public Collection getInboundWires() { - return Collections.unmodifiableCollection(serviceWires.values()); - } - - public void addOutboundWire(OutboundWire wire) { - List list = new ArrayList(); - list.add(wire); - referenceWires.put(wire.getReferenceName(), list); - onReferenceWire(wire); - } - - public Map> getOutboundWires() { - return Collections.unmodifiableMap(referenceWires); - } - - public void addOutboundWires(List wires) { - assert wires != null && wires.size() > 0; - referenceWires.put(wires.get(0).getReferenceName(), wires); - onReferenceWires(wires); - } - - public void removeInstance() throws ComponentException { - scopeContainer.remove(this); - } - - protected void onReferenceWire(OutboundWire wire) { - } - - protected void onReferenceWires(List wires) { - } - - protected void onServiceWire(InboundWire wire) { - } - - - public void prepare() throws PrepareException { - // connect inbound wires for atomic components - for (InboundWire inboundWire : getInboundWires()) { - for (InboundInvocationChain chain : inboundWire.getInvocationChains().values()) { - Operation operation = chain.getOperation(); - String serviceName = inboundWire.getServiceName(); - TargetInvoker invoker; - try { - invoker = createTargetInvoker(serviceName, operation, null); - } catch (TargetInvokerCreationException e) { - throw new PrepareException("Error processing inbound wire", serviceName, e); - } - chain.setTargetInvoker(invoker); - chain.prepare(); - } - } - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/BindingBuilderExtension.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/BindingBuilderExtension.java deleted file mode 100644 index 6f7859e689..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/BindingBuilderExtension.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.spi.extension; - -import org.osoa.sca.annotations.EagerInit; -import org.osoa.sca.annotations.Init; - -import org.apache.tuscany.spi.annotation.Autowire; -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.component.CompositeComponent; -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.model.BindingDefinition; -import org.apache.tuscany.spi.model.BoundReferenceDefinition; -import org.apache.tuscany.spi.model.BoundServiceDefinition; -import org.apache.tuscany.spi.wire.WireService; - -/** - * An extension point for binding builders. When adding support for new serviceBindings, implementations may extend this - * class as a convenience. - * - * @version $$Rev$$ $$Date$$ - */ -@EagerInit -public abstract class BindingBuilderExtension implements BindingBuilder { - - protected BuilderRegistry builderRegistry; - protected WireService wireService; - - @Autowire - public void setBuilderRegistry(BuilderRegistry registry) { - this.builderRegistry = registry; - } - - @Autowire - public void setWireService(WireService wireService) { - this.wireService = wireService; - } - - @Init - public void init() { - builderRegistry.register(getBindingType(), this); - } - - public ServiceBinding build(CompositeComponent parent, - BoundServiceDefinition boundServiceDefinition, - B bindingDefinition, - DeploymentContext deploymentContext) throws BuilderException { - return null; - } - - public ReferenceBinding build(CompositeComponent parent, - BoundReferenceDefinition boundReferenceDefinition, - B bindingDefinition, - DeploymentContext deploymentContext) throws BuilderException { - return null; - } - - protected abstract Class getBindingType(); -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/ComponentBuilderExtension.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/ComponentBuilderExtension.java deleted file mode 100644 index d58cb55131..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/ComponentBuilderExtension.java +++ /dev/null @@ -1,100 +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.spi.extension; - -import org.osoa.sca.annotations.EagerInit; -import org.osoa.sca.annotations.Init; - -import org.apache.tuscany.spi.annotation.Autowire; -import org.apache.tuscany.spi.builder.BuilderRegistry; -import org.apache.tuscany.spi.builder.ComponentBuilder; -import org.apache.tuscany.spi.builder.Connector; -import org.apache.tuscany.spi.component.ScopeRegistry; -import org.apache.tuscany.spi.component.WorkContext; -import org.apache.tuscany.spi.model.Implementation; -import org.apache.tuscany.spi.policy.PolicyBuilderRegistry; -import org.apache.tuscany.spi.services.work.WorkScheduler; -import org.apache.tuscany.spi.wire.WireService; - -import org.apache.tuscany.api.annotation.Monitor; - -/** - * An extension point for component builders. When adding support for new component types, implementations may extend - * this class as a convenience. - * - * @version $$Rev$$ $$Date$$ - */ -@EagerInit -public abstract class ComponentBuilderExtension> implements ComponentBuilder { - protected BuilderRegistry builderRegistry; - protected ScopeRegistry scopeRegistry; - protected WireService wireService; - protected WorkScheduler workScheduler; - protected WorkContext workContext; - protected PolicyBuilderRegistry policyBuilderRegistry; - protected Connector connector; - protected ExecutionMonitor monitor; - - @Autowire - public void setBuilderRegistry(BuilderRegistry registry) { - this.builderRegistry = registry; - } - - @Autowire - public void setScopeRegistry(ScopeRegistry scopeRegistry) { - this.scopeRegistry = scopeRegistry; - } - - @Autowire - public void setWireService(WireService wireService) { - this.wireService = wireService; - } - - @Autowire - public void setWorkScheduler(WorkScheduler workScheduler) { - this.workScheduler = workScheduler; - } - - @Autowire - public void setWorkContext(WorkContext workContext) { - this.workContext = workContext; - } - - @Autowire - public void setPolicyBuilderRegistry(PolicyBuilderRegistry registry) { - policyBuilderRegistry = registry; - } - - @Autowire - public void setConnector(Connector connector) { - this.connector = connector; - } - - @Monitor - public void setMonitor(ExecutionMonitor monitor) { - this.monitor = monitor; - } - - @Init - public void init() { - builderRegistry.register(getImplementationType(), this); - } - - protected abstract Class getImplementationType(); -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/ComponentTypeLoaderExtension.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/ComponentTypeLoaderExtension.java deleted file mode 100644 index ceebcbc490..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/ComponentTypeLoaderExtension.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.spi.extension; - -import org.osoa.sca.annotations.Destroy; -import org.osoa.sca.annotations.Init; -import org.osoa.sca.annotations.Scope; -import org.osoa.sca.annotations.EagerInit; - -import org.apache.tuscany.spi.annotation.Autowire; -import org.apache.tuscany.spi.loader.ComponentTypeLoader; -import org.apache.tuscany.spi.loader.LoaderRegistry; -import org.apache.tuscany.spi.model.Implementation; - -/** - * @version $Rev$ $Date$ - */ -@Scope("COMPOSITE") -@EagerInit -public abstract class ComponentTypeLoaderExtension implements ComponentTypeLoader { - protected LoaderRegistry loaderRegistry; - - protected ComponentTypeLoaderExtension() { - } - - protected ComponentTypeLoaderExtension(LoaderRegistry loaderRegistry) { - this.loaderRegistry = loaderRegistry; - } - - @Autowire - public void setLoaderRegistry(LoaderRegistry loaderRegistry) { - this.loaderRegistry = loaderRegistry; - } - - @Init - public void start() { - loaderRegistry.registerLoader(getImplementationClass(), this); - } - - @Destroy - public void stop() { - loaderRegistry.unregisterLoader(getImplementationClass()); - } - - protected abstract Class getImplementationClass(); - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/CompositeComponentExtension.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/CompositeComponentExtension.java deleted file mode 100644 index bb3e224012..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/CompositeComponentExtension.java +++ /dev/null @@ -1,557 +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.spi.extension; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -import org.w3c.dom.Document; - -import org.apache.tuscany.spi.annotation.Autowire; -import org.apache.tuscany.spi.builder.Connector; -import org.apache.tuscany.spi.builder.WiringException; -import org.apache.tuscany.spi.component.AtomicComponent; -import org.apache.tuscany.spi.component.Component; -import org.apache.tuscany.spi.component.ComponentRegistrationException; -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.component.DuplicateNameException; -import org.apache.tuscany.spi.component.InvalidAutowireInterface; -import org.apache.tuscany.spi.component.PrepareException; -import org.apache.tuscany.spi.component.Reference; -import org.apache.tuscany.spi.component.ReferenceBinding; -import org.apache.tuscany.spi.component.SCAObject; -import org.apache.tuscany.spi.component.Service; -import org.apache.tuscany.spi.component.ServiceBinding; -import org.apache.tuscany.spi.component.TargetResolutionException; -import org.apache.tuscany.spi.event.Event; -import org.apache.tuscany.spi.model.Scope; -import org.apache.tuscany.spi.services.management.TuscanyManagementService; -import org.apache.tuscany.spi.wire.InboundWire; -import org.apache.tuscany.spi.wire.OutboundWire; -import org.apache.tuscany.spi.wire.Wire; - -/** - * An extension point for composite components, which new types may extend - * - * @version $$Rev$$ $$Date$$ - */ -public abstract class CompositeComponentExtension extends AbstractComponentExtension implements CompositeComponent { - protected final Map children = new ConcurrentHashMap(); - protected final List services = new ArrayList(); - protected final List references = new ArrayList(); - - protected final Map propertyValues; - protected final Connector connector; - - protected final Map systemChildren = new ConcurrentHashMap(); - protected final List systemServices = new ArrayList(); - protected final List systemReferenceBindings = new ArrayList(); - - // autowire mappings - protected final Map autowireInternal = new ConcurrentHashMap(); - protected final Map autowireExternal = new ConcurrentHashMap(); - protected final Map systemAutowireInternal = new ConcurrentHashMap(); - protected final Map systemAutowireExternal = new ConcurrentHashMap(); - - /** - * Management service to use. - */ - private TuscanyManagementService managementService; - - protected CompositeComponentExtension(String name, - CompositeComponent parent, - Connector connector, - Map propertyValues) { - super(name, parent); - this.propertyValues = propertyValues; - this.connector = connector; - } - - /** - * Autowires the management service. - * - * @param managementService Management service used for registering components. - */ - @Autowire - public final void setManagementService(TuscanyManagementService managementService) { - this.managementService = managementService; - } - - public Scope getScope() { - return Scope.SYSTEM; - } - - public void onEvent(Event event) { - publish(event); - } - - public void registerJavaObject(String name, Class service, I instance) - throws ComponentRegistrationException { - throw new UnsupportedOperationException(); - } - - public void registerJavaObject(String name, List> services, I instance) - throws ComponentRegistrationException { - throw new UnsupportedOperationException(); - } - - public Document getPropertyValue(String name) { - return propertyValues.get(name); - } - - public SCAObject getChild(String name) { - assert name != null; - return children.get(name); - } - - public SCAObject getSystemChild(String name) { - assert name != null; - return systemChildren.get(name); - } - - public void register(SCAObject child) throws ComponentRegistrationException { - assert child instanceof Service || child instanceof Reference || child instanceof Component; - if (child.isSystem()) { - if (systemChildren.get(child.getName()) != null) { - throw new DuplicateNameException("A system child is already registered with the name", child.getName()); - } - systemChildren.put(child.getName(), child); - } else { - if (children.get(child.getName()) != null) { - throw new DuplicateNameException("A child is already registered with the name", child.getName()); - } - children.put(child.getName(), child); - } - if (child instanceof Service) { - Service service = (Service) child; - synchronized (services) { - if (service.isSystem()) { - systemServices.add(service); - } else { - services.add(service); - } - } - registerAutowire(service); - } else if (child instanceof Reference) { - Reference reference = (Reference) child; - synchronized (references) { - if (reference.isSystem()) { - systemReferenceBindings.add(reference); - } else { - references.add(reference); - } - } - registerAutowire(reference); - } else if (child instanceof AtomicComponent) { - AtomicComponent atomic = (AtomicComponent) child; - registerAutowire(atomic); - if (managementService != null) { - managementService.registerComponent(atomic.getName(), atomic); - } - } else if (child instanceof CompositeComponent) { - CompositeComponent component = (CompositeComponent) child; - if (lifecycleState == RUNNING && component.getLifecycleState() == UNINITIALIZED) { - component.start(); - } - registerAutowire(component); - addListener(component); - } - } - - public Map> getOutboundWires() { - synchronized (references) { - Map> map = new HashMap>(); - for (Reference reference : references) { - List wires = new ArrayList(); - map.put(reference.getName(), wires); - for (ReferenceBinding binding : reference.getReferenceBindings()) { - OutboundWire wire = binding.getOutboundWire(); - if (Wire.LOCAL_BINDING.equals(wire.getBindingType())) { - wires.add(wire); - } - } - } - return map; - } - } - - public InboundWire getInboundWire(String serviceName) { - Service service; - if (serviceName == null) { - if (services.size() != 1) { - return null; - } - service = services.get(0); - } else { - SCAObject object = children.get(serviceName); - if (!(object instanceof Service)) { - return null; - } - service = (Service) object; - } - for (ServiceBinding binding : service.getServiceBindings()) { - InboundWire wire = binding.getInboundWire(); - if (Wire.LOCAL_BINDING.equals(wire.getBindingType())) { - return wire; - } - } - return null; - } - - public InboundWire getInboundSystemWire(String serviceName) { - Service service; - if (serviceName == null) { - if (systemServices.size() != 1) { - return null; - } - service = systemServices.get(0); - } else { - SCAObject object = systemChildren.get(serviceName); - if (!(object instanceof Service)) { - return null; - } - service = (Service) object; - } - for (ServiceBinding binding : service.getServiceBindings()) { - InboundWire wire = binding.getInboundWire(); - if (Wire.LOCAL_BINDING.equals(wire.getBindingType())) { - return wire; - } - } - return null; - } - - public Collection getInboundWires() { - synchronized (services) { - List map = new ArrayList(); - for (Service service : services) { - for (ServiceBinding binding : service.getServiceBindings()) { - InboundWire wire = binding.getInboundWire(); - if (Wire.LOCAL_BINDING.equals(wire.getBindingType())) { - map.add(wire); - } - } - } - return map; - } - } - - public Collection getInboundSystemWires() { - synchronized (systemServices) { - List map = new ArrayList(); - for (Service service : systemServices) { - for (ServiceBinding binding : service.getServiceBindings()) { - InboundWire wire = binding.getInboundWire(); - if (Wire.LOCAL_BINDING.equals(wire.getBindingType())) { - map.add(wire); - } - } - } - return map; - } - } - - public InboundWire resolveAutowire(Class instanceInterface) throws TargetResolutionException { - // FIXME JNB make this faster and thread safe - for (Map.Entry service : autowireInternal.entrySet()) { - if (instanceInterface.isAssignableFrom(service.getKey())) { - return service.getValue(); - } - } - if (getParent() != null) { - return getParent().resolveAutowire(instanceInterface); - } - return null; - } - - public InboundWire resolveSystemAutowire(Class instanceInterface) throws TargetResolutionException { - // FIXME JNB make this faster and thread safe - for (Map.Entry service : systemAutowireInternal.entrySet()) { - if (instanceInterface.isAssignableFrom(service.getKey())) { - return service.getValue(); - } - } - if (getParent() != null) { - return getParent().resolveSystemAutowire(instanceInterface); - } - return null; - } - - public InboundWire resolveExternalAutowire(Class instanceInterface) throws TargetResolutionException { - // FIXME JNB make this faster and thread safe - for (Map.Entry service : autowireExternal.entrySet()) { - if (instanceInterface.isAssignableFrom(service.getKey())) { - return service.getValue(); - } - } - if (getParent() != null) { - return getParent().resolveAutowire(instanceInterface); - } - return null; - } - - public InboundWire resolveSystemExternalAutowire(Class instanceInterface) throws TargetResolutionException { - // FIXME JNB make this faster and thread safe - for (Map.Entry service : systemAutowireExternal.entrySet()) { - if (instanceInterface.isAssignableFrom(service.getKey())) { - return service.getValue(); - } - } - if (getParent() != null) { - return getParent().resolveAutowire(instanceInterface); - } - return null; - } - - public void prepare() throws PrepareException { - // Connect services and references first so that their wires are linked first - List childList = new ArrayList(); - for (SCAObject child : systemChildren.values()) { - if (child instanceof Component) { - childList.add(child); - } else { - childList.add(0, child); - } - } - // connect system artifacts - for (SCAObject child : childList) { - // connect all children - // TODO for composite wires, should delegate down - try { - connector.connect(child); - child.prepare(); - } catch (PrepareException e) { - e.addContextName(getName()); - } catch (WiringException e) { - throw new PrepareException("Error preparing composite", getName(), e); - } - } - - // connect application artifacts - childList.clear(); - for (SCAObject child : children.values()) { - if (child instanceof Component) { - childList.add(child); - } else { - childList.add(0, child); - } - } - for (SCAObject child : childList) { - // connect all children - // TODO for composite wires, should delegate down - try { - connector.connect(child); - child.prepare(); - } catch (PrepareException e) { - e.addContextName(getName()); - throw e; - } catch (WiringException e) { - throw new PrepareException("Error preparing composite", getName(), e); - } - } - } - - protected void registerAutowireExternal(Class interfaze, Service service) throws InvalidAutowireInterface { - if (interfaze == null) { - // The ServiceContract is not from Java - return; - } - if (service.isSystem()) { - if (systemAutowireExternal.containsKey(interfaze)) { - return; - } - // TODO autowire should allow multiple interfaces - List bindings = service.getServiceBindings(); - if (bindings.size() == 0) { - return; - } - // pick the first binding until autowire allows multiple interfaces - InboundWire wire = bindings.get(0).getInboundWire(); - if (!interfaze.isAssignableFrom(wire.getServiceContract().getInterfaceClass())) { - throw new InvalidAutowireInterface("Matching inbound wire not found for interface", - interfaze.getName()); - } - systemAutowireExternal.put(interfaze, wire); - } else { - if (autowireExternal.containsKey(interfaze)) { - return; - } - // TODO autowire should allow multiple interfaces - List bindings = service.getServiceBindings(); - if (bindings.size() == 0) { - return; - } - // pick the first binding until autowire allows multiple interfaces - InboundWire wire = bindings.get(0).getInboundWire(); - if (!interfaze.isAssignableFrom(wire.getServiceContract().getInterfaceClass())) { - String iName = interfaze.getName(); - throw new InvalidAutowireInterface("Matching inbound wire not found for interface", iName); - } - autowireExternal.put(interfaze, wire); - } - } - - protected void registerAutowireInternal(Class interfaze, InboundWire wire, boolean system) - throws InvalidAutowireInterface { - if (interfaze == null) { - // The ServiceContract is not from Java - return; - } - if (system) { - if (systemAutowireInternal.containsKey(interfaze)) { - return; - } - systemAutowireInternal.put(interfaze, wire); - } else { - if (autowireInternal.containsKey(interfaze)) { - return; - } - if (!interfaze.isAssignableFrom(wire.getServiceContract().getInterfaceClass())) { - String iName = interfaze.getName(); - throw new InvalidAutowireInterface("Matching inbound wire not found for interface", iName); - } - autowireInternal.put(interfaze, wire); - } - } - - protected void registerAutowireInternal(Class interfaze, Reference reference) throws InvalidAutowireInterface { - if (interfaze == null) { - // The ServiceContract is not from Java - return; - } - if (reference.isSystem()) { - if (systemAutowireInternal.containsKey(interfaze)) { - return; - } - List bindings = reference.getReferenceBindings(); - if (bindings.size() == 0) { - return; - } - // pick the first binding until autowire allows multiple interfaces - InboundWire wire = bindings.get(0).getInboundWire(); - if (!interfaze.isAssignableFrom(wire.getServiceContract().getInterfaceClass())) { - throw new InvalidAutowireInterface("Matching inbound wire not found for interface", - interfaze.getName()); - } - systemAutowireInternal.put(interfaze, wire); - } else { - if (autowireInternal.containsKey(interfaze)) { - return; - } - List bindings = reference.getReferenceBindings(); - if (bindings.size() == 0) { - return; - } - // pick the first binding until autowire allows multiple interfaces - InboundWire wire = bindings.get(0).getInboundWire(); - if (!interfaze.isAssignableFrom(wire.getServiceContract().getInterfaceClass())) { - String iName = interfaze.getName(); - throw new InvalidAutowireInterface("Matching inbound wire not found for interface", iName); - } - autowireInternal.put(interfaze, wire); - } - } - - protected void registerAutowireInternal(Class interfaze, AtomicComponent component) - throws InvalidAutowireInterface { - if (interfaze == null) { - // The ServiceContract is not from Java - return; - } - if (component.isSystem()) { - if (systemAutowireInternal.containsKey(interfaze) || component.getInboundWires().size() == 0) { - return; - } - for (InboundWire wire : component.getInboundWires()) { - Class clazz = wire.getServiceContract().getInterfaceClass(); - if (clazz.isAssignableFrom(interfaze)) { - systemAutowireInternal.put(interfaze, wire); - return; - } - } - throw new InvalidAutowireInterface("Matching inbound wire not found for interface", interfaze.getName()); - } else { - if (autowireInternal.containsKey(interfaze) || component.getInboundWires().size() == 0) { - return; - } - for (InboundWire wire : component.getInboundWires()) { - if (interfaze.isAssignableFrom(wire.getServiceContract().getInterfaceClass())) { - autowireInternal.put(interfaze, wire); - return; - } - } - throw new InvalidAutowireInterface("Matching inbound wire not found for interface", interfaze.getName()); - } - } - - protected void registerAutowire(CompositeComponent component) throws InvalidAutowireInterface { - if (component.isSystem()) { - // the composite is under the system hierarchy so only register its system services - Collection wires = component.getInboundSystemWires(); - for (InboundWire wire : wires) { - Class clazz = wire.getServiceContract().getInterfaceClass(); - registerAutowireInternal(clazz, wire, true); - } - - } else { - // the composite is under the application hierarchy so only register its non-system services - Collection wires = component.getInboundWires(); - for (InboundWire wire : wires) { - Class clazz = wire.getServiceContract().getInterfaceClass(); - registerAutowireInternal(clazz, wire, false); - } - } - } - - protected void registerAutowire(AtomicComponent component) throws InvalidAutowireInterface { - for (InboundWire wire : component.getInboundWires()) { - registerAutowireInternal(wire.getServiceContract().getInterfaceClass(), component); - } - } - - protected void registerAutowire(Reference reference) throws InvalidAutowireInterface { - // TODO autowire should allow multiple interfaces - List bindings = reference.getReferenceBindings(); - if (bindings.size() == 0) { - return; - } - // pick the first binding until autowire allows multiple interfaces - InboundWire wire = bindings.get(0).getInboundWire(); - Class clazz = wire.getServiceContract().getInterfaceClass(); - registerAutowireInternal(clazz, reference); - - - } - - protected void registerAutowire(Service service) throws InvalidAutowireInterface { - // TODO autowire should allow multiple interfaces - List bindings = service.getServiceBindings(); - if (bindings.size() == 0) { - return; - } - // pick the first binding until autowire allows multiple interfaces - InboundWire wire = bindings.get(0).getInboundWire(); - Class clazz = wire.getServiceContract().getInterfaceClass(); - registerAutowireExternal(clazz, service); - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/ExecutionMonitor.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/ExecutionMonitor.java deleted file mode 100644 index fc6e5b7a14..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/ExecutionMonitor.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.spi.extension; - -/** - * A monitor used to log events during an invocation - * - * @version $$Rev$$ $$Date$$ - */ -public interface ExecutionMonitor { - - /** - * Logs an exception thrown during an invocation - */ - void executionError(Throwable e); - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/LoaderExtension.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/LoaderExtension.java deleted file mode 100644 index d256ef1fdd..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/LoaderExtension.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.spi.extension; - -import javax.xml.namespace.QName; - -import org.osoa.sca.annotations.Destroy; -import org.osoa.sca.annotations.Init; -import org.osoa.sca.annotations.EagerInit; - -import org.apache.tuscany.spi.annotation.Autowire; -import org.apache.tuscany.spi.loader.LoaderRegistry; -import org.apache.tuscany.spi.loader.StAXElementLoader; -import org.apache.tuscany.spi.model.ModelObject; - -/** - * Support class for extending the Loader mechanism. - * - * @version $Rev$ $Date$ - */ -@EagerInit -public abstract class LoaderExtension implements StAXElementLoader { - /** - * The LoaderRegistry that this loader should register with; usually set by injection. This registry may also be - * used to load sub-elements. - */ - protected LoaderRegistry registry; - - /** - * Constructor specifies the registry to register with. - * - * @param registry the LoaderRegistry this loader should register with - */ - protected LoaderExtension(@Autowire LoaderRegistry registry) { - this.registry = registry; - } - - /** - * Initialize the loader. The base implementation registers this loader with the registry as a handler for the XML - * type returned by {@link #getXMLType()}. Implementations may override this to register the loader as a handler for - * multiple XML types. - */ - @Init - public void start() { - registry.registerLoader(getXMLType(), this); - } - - /** - * Destroy the loader. The base implementation unregisters the loader from the regsitry based on the type returned - * by {@link #getXMLType()}. - */ - @Destroy - public void stop() { - registry.unregisterLoader(getXMLType(), this); - } - - /** - * Returns the QName of the element that this implementation handles. - * - * @return the QName of the element that this implementation handles - */ - public abstract QName getXMLType(); -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/ReferenceBindingExtension.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/ReferenceBindingExtension.java deleted file mode 100644 index 1653e87dc2..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/ReferenceBindingExtension.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.spi.extension; - -import org.apache.tuscany.spi.component.AbstractSCAObject; -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.component.Reference; -import org.apache.tuscany.spi.component.ReferenceBinding; -import org.apache.tuscany.spi.model.Scope; -import org.apache.tuscany.spi.model.ServiceContract; -import org.apache.tuscany.spi.wire.InboundWire; -import org.apache.tuscany.spi.wire.OutboundWire; - -/** - * The default implementation of an SCA reference - * - * @version $Rev$ $Date$ - */ -public abstract class ReferenceBindingExtension extends AbstractSCAObject implements ReferenceBinding { - protected Reference reference; - protected InboundWire inboundWire; - protected OutboundWire outboundWire; - protected ServiceContract bindingServiceContract; - - protected ReferenceBindingExtension(String name, CompositeComponent parent) { - super(name, parent); - } - - public Scope getScope() { - return Scope.SYSTEM; - } - - public void setReference(Reference reference) { - this.reference = reference; - } - - public void setInboundWire(InboundWire wire) { - this.inboundWire = wire; - } - - public InboundWire getInboundWire() { - return inboundWire; - } - - public OutboundWire getOutboundWire() { - return outboundWire; - } - - public void setOutboundWire(OutboundWire outboundWire) { - this.outboundWire = outboundWire; - } - - public ServiceContract getBindingServiceContract() { - return bindingServiceContract; - } - - @Override - public boolean isSystem() { - return reference != null && reference.isSystem(); - } - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/ServiceBindingExtension.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/ServiceBindingExtension.java deleted file mode 100644 index 76859a65de..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/ServiceBindingExtension.java +++ /dev/null @@ -1,87 +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.spi.extension; - -import org.apache.tuscany.spi.CoreRuntimeException; -import org.apache.tuscany.spi.component.AbstractSCAObject; -import org.apache.tuscany.spi.component.CompositeComponent; -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.model.Operation; -import org.apache.tuscany.spi.model.Scope; -import org.apache.tuscany.spi.model.ServiceContract; -import org.apache.tuscany.spi.wire.InboundWire; -import org.apache.tuscany.spi.wire.OutboundWire; -import org.apache.tuscany.spi.wire.TargetInvoker; - -/** - * The default implementation of an SCA service - * - * @version $Rev$ $Date$ - */ -public abstract class ServiceBindingExtension extends AbstractSCAObject implements ServiceBinding { - protected Service service; - protected InboundWire inboundWire; - protected OutboundWire outboundWire; - protected ServiceContract bindingServiceContract; - - public ServiceBindingExtension(String name, CompositeComponent parent) throws CoreRuntimeException { - super(name, parent); - } - - public Scope getScope() { - return Scope.SYSTEM; - } - - public void setService(Service service) { - this.service = service; - } - - public InboundWire getInboundWire() { - return inboundWire; - } - - public void setInboundWire(InboundWire wire) { - inboundWire = wire; - } - - public OutboundWire getOutboundWire() { - return outboundWire; - } - - public void setOutboundWire(OutboundWire outboundWire) { - this.outboundWire = outboundWire; - } - - public TargetInvoker createTargetInvoker(ServiceContract contract, Operation operation) - throws TargetInvokerCreationException { - throw new UnsupportedOperationException(); - } - - public ServiceContract getBindingServiceContract() { - return bindingServiceContract; - } - - @Override - public boolean isSystem() { - return service != null && service.isSystem(); - } - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/SystemAtomicComponentExtension.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/SystemAtomicComponentExtension.java deleted file mode 100644 index 6c502702e9..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/SystemAtomicComponentExtension.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.spi.extension; - -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.model.Operation; -import org.apache.tuscany.spi.wire.InboundWire; -import org.apache.tuscany.spi.wire.TargetInvoker; - -/** - * @version $Rev$ $Date$ - */ -public abstract class SystemAtomicComponentExtension extends AtomicComponentExtension { - - public SystemAtomicComponentExtension(String name, - CompositeComponent parent, - int initLevel) { - super(name, parent, null, null, null, null, initLevel); - } - - public TargetInvoker createTargetInvoker(String targetName, Operation operation, InboundWire callbackWire) { - throw new UnsupportedOperationException(); - } - - public boolean isSystem() { - return true; - } - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/TargetInvokerExtension.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/TargetInvokerExtension.java deleted file mode 100644 index 88949646ff..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/TargetInvokerExtension.java +++ /dev/null @@ -1,96 +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.spi.extension; - -import java.lang.reflect.InvocationTargetException; -import java.util.LinkedList; - -import org.apache.tuscany.spi.component.WorkContext; -import org.apache.tuscany.spi.wire.InboundWire; -import org.apache.tuscany.spi.wire.InvocationRuntimeException; -import org.apache.tuscany.spi.wire.Message; -import org.apache.tuscany.spi.wire.TargetInvoker; - -/** - * The default implementation of a TargetInvoker - * - * @version $Rev$ $Date$ - */ -public abstract class TargetInvokerExtension implements TargetInvoker { - - protected InboundWire wire; - protected WorkContext workContext; - protected ExecutionMonitor monitor; - protected boolean cacheable; - - /** - * Creates a new invoker - * - * @param wire the callback wire - * @param workContext the work context to use for setting correlation information - * @param monitor the event monitor - */ - public TargetInvokerExtension(InboundWire wire, WorkContext workContext, ExecutionMonitor monitor) { - this.wire = wire; - this.workContext = workContext; - this.monitor = monitor; - } - - public Message invoke(Message msg) throws InvocationRuntimeException { - try { - Object messageId = msg.getMessageId(); - if (messageId != null) { - workContext.setCurrentCorrelationId(messageId); - } - if (wire != null) { - LinkedList callbackRoutingChain = msg.getCallbackRoutingChain(); - if (callbackRoutingChain != null) { - workContext.setCurrentCallbackRoutingChain(callbackRoutingChain); - } - } - Object resp = invokeTarget(msg.getBody(), msg.getConversationSequence()); - msg.setBody(resp); - } catch (InvocationTargetException e) { - msg.setBodyWithFault(e.getCause()); - } - return msg; - } - - public boolean isCacheable() { - return cacheable; - } - - public void setCacheable(boolean cacheable) { - this.cacheable = cacheable; - } - - public boolean isOptimizable() { - return isCacheable(); - } - - public Object clone() throws CloneNotSupportedException { - try { - return super.clone(); - } catch (CloneNotSupportedException e) { - // TargetInvoker extends Cloneable so this should not have been thrown - throw new AssertionError(e); - } - } - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/host/ResourceHost.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/host/ResourceHost.java deleted file mode 100644 index b273ec6729..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/host/ResourceHost.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.spi.host; - -/** - * Interface implemented by host environments that allow for resolution of component implementation resources, e.g. - * items bound in a JNDI tree. - * - * @version $Rev$ $Date$ - */ -public interface ResourceHost { - - /** - * Resolve a resource matching the given type - * - * @param type the type of the resources - * @throws ResourceResolutionException if an error is encountered during resolution - */ - T resolveResource(Class type) throws ResourceResolutionException; - - /** - * Resolve a resource matching the given type and name - * - * @param type the type of the resources - * @param mappedName the mapped name of the resource - * @throws ResourceResolutionException if an error is encountered during resolution - */ - T resolveResource(Class type, String mappedName) throws ResourceResolutionException; - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/host/ResourceHostRegistry.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/host/ResourceHostRegistry.java deleted file mode 100644 index b4964cce3b..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/host/ResourceHostRegistry.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.spi.host; - -/** - * Implementations manage a registry of resources and resource hosts in the runtime - * - * @version $Rev$ $Date$ - */ -public interface ResourceHostRegistry { - /** - * Registers a resource host for the given uri prefix - * - * @param uri the uri prefix the host resolves resources for - * @param host the resource host - */ - void registerResourceHost(String uri, ResourceHost host); - - /** - * Removes a resource host registered for the given uri prefix - */ - void unregisterResourceHost(String uri); - - /** - * Register a resource by type - * - * @param type the type of the resource - * @param resource the resource - */ - void registerResource(Class type, Object resource); - - /** - * Register a resource by type and name - * - * @param type the type of the resource - * @param name the mapped resource name - * @param resource the resource - */ - void registerResource(Class type, String name, Object resource); - - /** - * Unregister a resource - * - * @param type the type the resource was registered with - * @param name the mapped name the resource was registered with - */ - void unregisterResource(Class type, String name); - - /** - * Unregister a resource - * - * @param type the type the resource was registered with - */ - void unregisterResource(Class type); - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/host/ResourceResolutionException.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/host/ResourceResolutionException.java deleted file mode 100644 index 23c18f5115..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/host/ResourceResolutionException.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.spi.host; - -import org.apache.tuscany.api.TuscanyException; - -/** - * @version $Rev$ $Date$ - */ -public class ResourceResolutionException extends TuscanyException { - - public ResourceResolutionException(String message, String identifier) { - super(message, identifier); - } - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/host/ServletHost.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/host/ServletHost.java deleted file mode 100644 index 37937808d4..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/host/ServletHost.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.spi.host; - -import javax.servlet.Servlet; - -/** - * Interface implemented by host environments that allow Servlets to be registered. - *

      - * This interface allows an SCA system service to register a servlet to handle inbound requests. - * - * @version $Rev$ $Date$ - */ -public interface ServletHost { - /** - * Register a mapping for an instance of a Servlet. This requests that the servlet container direct all requests to - * the designated mapping to the supplied Servlet instance. - * - * @param mapping the uri-mapping for the Servlet - * @param servlet the Servlet that should be invoked - */ - void registerMapping(String mapping, Servlet servlet); - - /** - * Unregister a servlet mapping. This directs the servlet contain not to direct any more requests to a previously - * registered Servlet. - * - * @param mapping the uri-mapping for the Servlet - * @return the servlet that was registered to the mapping, null if nothing was registered to the mapping - */ - Servlet unregisterMapping(String mapping); - - /** - * Check to see if a mapping exists. - * - * @param mapping the uri-mapping for the Servlet - * @return true if mapping is registered, false otherwise - */ - boolean isMappingRegistered(String mapping); - - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/ElementInfo.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/ElementInfo.java deleted file mode 100644 index 5a0bd3bb5f..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/ElementInfo.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.spi.idl; - -import javax.xml.namespace.QName; - -/** - * An abstraction of XML schema elements - */ -public class ElementInfo { - private QName name; - private TypeInfo type; - - /** - * @param name - * @param type - */ - public ElementInfo(QName name, TypeInfo type) { - super(); - this.name = name; - this.type = type; - } - - /** - * @return the name - */ - public QName getQName() { - return name; - } - - /** - * @return the type - */ - public TypeInfo getType() { - return type; - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/InvalidConversationalOperationException.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/InvalidConversationalOperationException.java deleted file mode 100644 index e2b4acec24..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/InvalidConversationalOperationException.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.spi.idl; - -import java.lang.reflect.Method; - -/** - * Denotes an invalid conversational interface definition - * - * @version $Rev$ $Date$ - */ -public class InvalidConversationalOperationException extends InvalidServiceContractException { - private final Method operation; - - public InvalidConversationalOperationException(String message, String identifier, Method operation) { - super(message, identifier); - this.operation = operation; - } - - public Method getOperation() { - return operation; - } - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/InvalidServiceContractException.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/InvalidServiceContractException.java deleted file mode 100644 index e977592df0..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/InvalidServiceContractException.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.spi.idl; - -import org.apache.tuscany.api.TuscanyException; - -/** - * @version $Rev$ $Date$ - */ -public abstract class InvalidServiceContractException extends TuscanyException { - - public InvalidServiceContractException() { - } - - public InvalidServiceContractException(String message) { - super(message); - } - - protected InvalidServiceContractException(String message, String identifier) { - super(message, identifier); - } - - public InvalidServiceContractException(String message, Throwable cause) { - super(message, cause); - } - - protected InvalidServiceContractException(String message, String identifier, Throwable cause) { - super(message, identifier, cause); - } - - public InvalidServiceContractException(Throwable cause) { - super(cause); - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/OverloadedOperationException.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/OverloadedOperationException.java deleted file mode 100644 index b1d4cb4e7c..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/OverloadedOperationException.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.spi.idl; - -import java.lang.reflect.Method; - -/** - * Exception thrown to indicate that a service contract specification contains an overloaded method. - * - * @version $Rev$ $Date$ - */ -public class OverloadedOperationException extends InvalidServiceContractException { - private static final long serialVersionUID = -4658711318608885638L; - private final Method operation; - - public OverloadedOperationException(Method operation) { - super(null, operation.getDeclaringClass().getName()); - this.operation = operation; - } - - public Method getOperation() { - return operation; - } - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/TypeInfo.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/TypeInfo.java deleted file mode 100644 index 9bb107812c..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/TypeInfo.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.spi.idl; - -import javax.xml.namespace.QName; - -/** - * An abstraction of XML schema types - */ -public class TypeInfo { - private QName name; - - private boolean isSimpleType; - - private TypeInfo baseType; - - /** - * @param name - * @param isSimpleType - */ - public TypeInfo(QName name, boolean isSimpleType, TypeInfo baseType) { - super(); - this.name = name; - this.isSimpleType = isSimpleType; - this.baseType = baseType; - } - - /** - * @return the isSimpleType - */ - public boolean isSimpleType() { - return isSimpleType; - } - - /** - * @return the name - */ - public QName getQName() { - return name; - } - - /** - * @return the baseType - */ - public TypeInfo getBaseType() { - return baseType; - } - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/java/InterfaceJavaIntrospector.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/java/InterfaceJavaIntrospector.java deleted file mode 100644 index 08f22147b5..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/java/InterfaceJavaIntrospector.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.spi.idl.java; - -import org.apache.tuscany.spi.idl.InvalidServiceContractException; - -/** - * Processor for creating JavaServiceContract definitions from Java Classes. - * - * @version $Rev$ $Date$ - */ -public interface InterfaceJavaIntrospector { - - /** - * Introspect a Java interface and return a service contract definition. - * - * @param type the interface to inspect - * @return a JavaServiceContract corresponding to the Java interface - */ - JavaServiceContract introspect(Class type) throws InvalidServiceContractException; - - /** - * Introspect a Java interface and return a service contract definition. - * - * @param type the interface to inspect - * @param callback the callback interface to inspec - * @return a JavaServiceContract corresponding to the Java interface - */ - JavaServiceContract introspect(Class type, Class callback) throws InvalidServiceContractException; -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/java/JavaIDLUtils.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/java/JavaIDLUtils.java deleted file mode 100644 index c7c7cb2aa8..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/java/JavaIDLUtils.java +++ /dev/null @@ -1,96 +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.spi.idl.java; - -import java.lang.reflect.Method; -import java.util.Collection; -import java.util.List; - -import org.apache.tuscany.spi.model.DataType; -import org.apache.tuscany.spi.model.Operation; - -/** - * Contains methods for mapping between an operation in a {@link org.apache.tuscany.spi.model.ServiceContract} and a - * method defined by a Java interface - * - * @version $Rev$ $Date$ - */ -public final class JavaIDLUtils { - - private JavaIDLUtils() { - } - - /** - * Searches an array of methods for a match against the given operation - * - * @param operation the operation to match - * @param methods the methods to match against - * @return a matching method or null - */ - public static Method findMethod(Operation operation, Method[] methods) { - for (Method method : methods) { - if (match(operation, method)) { - return method; - } - } - return null; - } - - /** - * Searches a collection of operations for a match against the given method - * - * @param method the method to match - * @param operations the operations to match against - * @return a matching operation or null - */ - public static Operation findOperation(Method method, Collection> operations) { - for (Operation operation : operations) { - if (match(operation, method)) { - return operation; - } - } - return null; - } - - /** - * Determines if the given operation matches the given method - * - * @return true if the operation matches, false if does not - */ - private static boolean match(Operation operation, Method method) { - Class[] params = method.getParameterTypes(); - DataType>> inputType = operation.getInputType(); - List> types = inputType.getLogical(); - boolean found = true; - if (types.size() == params.length && method.getName().equals(operation.getName())) { - for (int i = 0; i < params.length; i++) { - Class clazz = params[i]; - if (!clazz.equals(operation.getInputType().getLogical().get(i).getPhysical())) { - found = false; - } - } - } else { - found = false; - } - return found; - - } - - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/java/JavaInterfaceProcessor.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/java/JavaInterfaceProcessor.java deleted file mode 100644 index afe98f0773..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/java/JavaInterfaceProcessor.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.spi.idl.java; - -import org.apache.tuscany.spi.idl.InvalidServiceContractException; - -/** - * Implementations introspect metadata on a Java interface, populating the - * corresponding {@link JavaServiceContract} - * - * @version $Rev$ $Date$ - */ -public interface JavaInterfaceProcessor { - - void visitInterface(Class clazz, Class callbackClass, JavaServiceContract contract) - throws InvalidServiceContractException; - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/java/JavaInterfaceProcessorExtension.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/java/JavaInterfaceProcessorExtension.java deleted file mode 100644 index 950ce1858c..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/java/JavaInterfaceProcessorExtension.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.spi.idl.java; - -import org.osoa.sca.annotations.EagerInit; -import org.osoa.sca.annotations.Init; - -import org.apache.tuscany.spi.annotation.Autowire; - -/** - * A convenience class for JavaInterfaceProcessor extensions that performs autowiring - * - * @version $Rev$ $Date$ - */ -@EagerInit -public abstract class JavaInterfaceProcessorExtension implements JavaInterfaceProcessor { - - protected JavaInterfaceProcessorRegistry registry; - - @Autowire - public void setRegistry(JavaInterfaceProcessorRegistry registry) { - this.registry = registry; - } - - @Init - public void init() { - registry.registerProcessor(this); - } - - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/java/JavaInterfaceProcessorRegistry.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/java/JavaInterfaceProcessorRegistry.java deleted file mode 100644 index 38c64e6f88..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/java/JavaInterfaceProcessorRegistry.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.spi.idl.java; - -/** - * A registry of {@link JavaInterfaceProcessor}s. Interface processors update a service contract definition based on a - * Java interface - * - * @version $Rev$ $Date$ - */ -public interface JavaInterfaceProcessorRegistry extends InterfaceJavaIntrospector { - - /** - * Registers the given processor - */ - void registerProcessor(JavaInterfaceProcessor processor); - - /** - * Deregisters the given processor - */ - void unregisterProcessor(JavaInterfaceProcessor processor); - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/java/JavaServiceContract.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/java/JavaServiceContract.java deleted file mode 100644 index ee29846e26..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/java/JavaServiceContract.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.spi.idl.java; - -import java.lang.reflect.Type; - -import org.apache.tuscany.spi.model.ServiceContract; - -/** - * Represents a service contract specified using a Java interface - * - * @version $Rev$ $Date$ - */ -public class JavaServiceContract extends ServiceContract { - - public JavaServiceContract() { - } - - public JavaServiceContract(Class interfaceClass) { - super(interfaceClass); - } - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/AbstractPropertyProcessor.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/AbstractPropertyProcessor.java deleted file mode 100644 index 999fd9a49d..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/AbstractPropertyProcessor.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.spi.implementation.java; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Constructor; -import java.lang.reflect.Field; -import java.lang.reflect.Member; -import java.lang.reflect.Method; -import java.util.Map; - -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.deployer.DeploymentContext; - -/** - * Base class for ImplementationProcessors that handle annotations that add Properties. - * - * @version $Rev$ $Date$ - */ -public abstract class AbstractPropertyProcessor extends ImplementationProcessorExtension { - private final Class annotationClass; - private ImplementationProcessorService service; - - protected AbstractPropertyProcessor(Class annotationClass, ImplementationProcessorService service) { - this.annotationClass = annotationClass; - this.service = service; - } - - public void visitMethod(CompositeComponent parent, - Method method, - PojoComponentType> type, - DeploymentContext context) throws ProcessingException { - A annotation = method.getAnnotation(annotationClass); - if (annotation == null) { - return; - } - - if (!Void.TYPE.equals(method.getReturnType())) { - throw new IllegalPropertyException("Method does not have void return type", method.toString()); - } - Class[] paramTypes = method.getParameterTypes(); - if (paramTypes.length != 1) { - throw new IllegalPropertyException("Method must have a single parameter", method.toString()); - } - Class javaType = paramTypes[0]; - - String name = getName(annotation); - if (name == null || name.length() == 0) { - name = method.getName(); - if (name.startsWith("set")) { - name = toPropertyName(method.getName()); - } - } - - Map> properties = type.getProperties(); - if (properties.containsKey(name)) { - throw new DuplicatePropertyException(name); - } - - JavaMappedProperty property = createProperty(name, javaType, method); - initProperty(property, annotation, parent, context); - properties.put(name, property); - } - - public void visitField(CompositeComponent parent, - Field field, - PojoComponentType> type, - DeploymentContext context) throws ProcessingException { - A annotation = field.getAnnotation(annotationClass); - if (annotation == null) { - return; - } - - Class javaType = field.getType(); - - String name = getName(annotation); - if (name == null || name.length() == 0) { - name = field.getName(); - } - - Map> properties = type.getProperties(); - if (properties.containsKey(name)) { - throw new DuplicatePropertyException(name); - } - - JavaMappedProperty property = createProperty(name, javaType, field); - initProperty(property, annotation, parent, context); - properties.put(name, property); - } - - public void visitConstructor(CompositeComponent parent, Constructor constructor, - PojoComponentType> type, - DeploymentContext context) throws ProcessingException { - - ConstructorDefinition definition = type.getConstructorDefinition(); - Class[] params = constructor.getParameterTypes(); - Map> properties = type.getProperties(); - Annotation[][] annotations = constructor.getParameterAnnotations(); - for (int i = 0; i < params.length; i++) { - Class param = params[i]; - Annotation[] paramAnnotations = annotations[i]; - for (Annotation annotation : paramAnnotations) { - if (annotation.annotationType().equals(annotationClass)) { - if (definition == null) { - definition = new ConstructorDefinition(constructor); - type.setConstructorDefinition(definition); - } - A monitorAnnot = annotationClass.cast(annotation); - String name = getName(monitorAnnot); - if (name == null || name.length() == 0) { - name = param.getName(); - } - JavaMappedProperty property = createProperty(name, param, constructor); - initProperty(property, monitorAnnot, parent, context); - properties.put(name, property); - service.addName(definition.getInjectionNames(), i, name); - } - } - } - } - - protected abstract String getName(A annotation); - - protected void initProperty(JavaMappedProperty property, - A annotation, - CompositeComponent parent, - DeploymentContext context) throws ProcessingException { - } - - protected JavaMappedProperty createProperty(String name, Class javaType, Member member) - throws ProcessingException { - return new JavaMappedProperty(name, null, javaType, member); - } - - - public static String toPropertyName(String name) { - if (!name.startsWith("set")) { - return name; - } - return Character.toLowerCase(name.charAt(3)) + name.substring(4); - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/ConstructorDefinition.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/ConstructorDefinition.java deleted file mode 100644 index 94c185966f..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/ConstructorDefinition.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.spi.implementation.java; - -import java.lang.reflect.Constructor; -import java.util.ArrayList; -import java.util.List; - -/** - * Hold injection information for the constructor used to instantiate a component implementation instance - * - * @version $Rev$ $Date$ - */ -public class ConstructorDefinition { - - private Constructor constructor; - private List injectionNames; - - public ConstructorDefinition(Constructor constructor) { - this.constructor = constructor; - injectionNames = new ArrayList(); - } - - public Constructor getConstructor() { - return constructor; - } - - public List getInjectionNames() { - return injectionNames; - } - - public void setInjectionNames(List injectionNames) { - this.injectionNames = injectionNames; - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/DuplicatePropertyException.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/DuplicatePropertyException.java deleted file mode 100644 index 87c4074fe7..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/DuplicatePropertyException.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.spi.implementation.java; - -/** - * Thrown when an implementation has more than one property injection site with the same name - * - * @version $Rev$ $Date$ - */ -public class DuplicatePropertyException extends ProcessingException { - - public DuplicatePropertyException(String message) { - super(message); - } - - public DuplicatePropertyException(String message, String identifier) { - super(message, identifier); - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/IllegalPropertyException.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/IllegalPropertyException.java deleted file mode 100644 index f251f60630..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/IllegalPropertyException.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.spi.implementation.java; - -/** - * Denotes an illegal property definition in a component type - * - * @version $Rev$ $Date$ - */ -public class IllegalPropertyException extends ProcessingException { - - public IllegalPropertyException(String message) { - super(message); - } - - - public IllegalPropertyException(String message, String identifier) { - super(message, identifier); - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/ImplementationProcessor.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/ImplementationProcessor.java deleted file mode 100644 index fb9beca53c..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/ImplementationProcessor.java +++ /dev/null @@ -1,128 +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.spi.implementation.java; - -import java.lang.reflect.Constructor; -import java.lang.reflect.Field; -import java.lang.reflect.Method; - -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.deployer.DeploymentContext; - -/** - * Implementations process class-level metadata, typically parsing annotations and updating the corresponding - * ComponentType. A processor may, for example, create a {@link JavaMappedProperty} which is responsible - * for injecting a complex type on a component implementation instance when it is instantiated. - *

      - * Processors will receive callbacks as the implementation class is walked while evalauting an assembly. It is the - * responsibility of the parser to determine whether to perform an action during the callback. - * - * @version $Rev$ $Date$ - */ -public interface ImplementationProcessor { - - /** - * A callback received when the component implementation class is first loaded - * - * @param parent the parent composite - * @param clazz the component implementation class - * @param type the incomplete component type associated with the implementation class - * @param context the current deployment context - * @throws ProcessingException if an error is encountered while processing metadata - */ - void visitClass(CompositeComponent parent, - Class clazz, - PojoComponentType> type, - DeploymentContext context) throws ProcessingException; - - /** - * A callback received as the component implementation class hierarchy is evaluated - * - * @param parent the parent composite - * @param clazz the superclass in the component implmentation's class hierarchy - * @param type the incomplete component type associated with the implementation class - * @param context the current deployment context - * @throws ProcessingException if an error is encountered while processing metadata - */ - void visitSuperClass(CompositeComponent parent, - Class clazz, - PojoComponentType> type, - DeploymentContext context) throws ProcessingException; - - /** - * A callback received as the component implementation's public and protected methods are evaluated - * - * @param parent the parent composite - * @param method the current public or protected method being evaluated - * @param type the incomplete component type associated with the implementation class - * @param context the current deployment context - * @throws ProcessingException if an error is encountered while processing metadata - */ - void visitMethod(CompositeComponent parent, - Method method, - PojoComponentType> type, - DeploymentContext context) throws ProcessingException; - - /** - * A callback received as the component implementation's constructor used for instantiation by the runtime is - * evaluated. If an implementation contains more than one constructor, the constructor passed to the callback will - * be chosen according to the algorithm described in the SCA Java Client and Implementation Model Specification. - * - * @param parent the parent composite - * @param constructor the constructor used for instantiating component implementation instances - * @param type the incomplete component type associated with the implementation class - * @param context the current deployment context - * @throws ProcessingException if an error is encountered while processing metadata - */ - void visitConstructor(CompositeComponent parent, - Constructor constructor, - PojoComponentType> type, - DeploymentContext context) - throws ProcessingException; - - /** - * A callback received as the component implementation's public and protected fields are evaluated - * - * @param parent the parent composite - * @param field the current public or protected field being evaluated - * @param type the incomplete component type associated with the implementation class - * @param context the current deployment context - * @throws ProcessingException if an error is encountered while processing metadata - */ - void visitField(CompositeComponent parent, - Field field, - PojoComponentType> type, - DeploymentContext context) throws ProcessingException; - - /** - * The final callback received when all other callbacks during evaluation of the component implementation have been - * issued - * - * @param parent the parent composite - * @param clazz the component implementation class - * @param type the incomplete component type associated with the implementation class - * @param context the current deployment context - * @throws ProcessingException if an error is encountered while processing metadata - */ - void visitEnd(CompositeComponent parent, - Class clazz, - PojoComponentType> type, - DeploymentContext context) throws ProcessingException; - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/ImplementationProcessorExtension.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/ImplementationProcessorExtension.java deleted file mode 100644 index a7a92e20a7..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/ImplementationProcessorExtension.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.spi.implementation.java; - -import java.lang.reflect.Constructor; -import java.lang.reflect.Field; -import java.lang.reflect.Method; - -import org.osoa.sca.annotations.Destroy; -import org.osoa.sca.annotations.EagerInit; -import org.osoa.sca.annotations.Init; - -import org.apache.tuscany.spi.annotation.Autowire; -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.deployer.DeploymentContext; - -/** - * A convenience class for annotation processors which alleviates the need to implement unused callbacks - * - * @version $Rev$ $Date$ - */ -@EagerInit -public abstract class ImplementationProcessorExtension implements ImplementationProcessor { - private IntrospectionRegistry registry; - - @Autowire - public void setRegistry(IntrospectionRegistry registry) { - this.registry = registry; - } - - @Init - public void init() { - registry.registerProcessor(this); - } - - @Destroy - public void destroy() { - registry.unregisterProcessor(this); - } - - public void visitClass(CompositeComponent parent, Class clazz, - PojoComponentType> type, - DeploymentContext context) - throws ProcessingException { - } - - public void visitSuperClass(CompositeComponent parent, Class clazz, - PojoComponentType> type, - DeploymentContext context) - throws ProcessingException { - } - - public void visitMethod(CompositeComponent parent, Method method, - PojoComponentType> type, - DeploymentContext context) - throws ProcessingException { - } - - public void visitConstructor(CompositeComponent parent, Constructor constructor, - PojoComponentType> type, - DeploymentContext context) - throws ProcessingException { - } - - public void visitField(CompositeComponent parent, Field field, - PojoComponentType> type, - DeploymentContext context) throws ProcessingException { - } - - public void visitEnd(CompositeComponent parent, Class clazz, - PojoComponentType> type, - DeploymentContext context) throws ProcessingException { - - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/ImplementationProcessorService.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/ImplementationProcessorService.java deleted file mode 100644 index 59d37e8d59..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/ImplementationProcessorService.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.spi.implementation.java; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Member; -import java.util.List; - -import org.apache.tuscany.spi.idl.InvalidServiceContractException; -import org.apache.tuscany.spi.model.ServiceContract; - -/** - * Provides utility methods for Java implementation processing - * - * @version $Rev$ $Date$ - */ -public interface ImplementationProcessorService { - - /** - * Introspects the given interface to produce a mapped service - */ - JavaMappedService createService(Class interfaze) throws InvalidServiceContractException; - - JavaMappedReference createReference(String name, Member member, Class paramType) throws ProcessingException; - - /** - * Processes the callback contract for a given interface type - * - * @param interfaze the interface type to examine - * @param contract the service contract the callback is associated wth - * @throws InvalidServiceContractException - * - */ - void processCallback(Class interfaze, ServiceContract contract) throws InvalidServiceContractException; - - /** - * Determines if all the members of a collection have unique types - * - * @param collection the collection to analyze - * @return true if the types are unique - */ - boolean areUnique(Class[] collection); - - /** - * Inserts a name at the specified position, paddiling the list if its size is less than the position - */ - void addName(List names, int pos, String name); - - /** - * Processes a constructor parameter by introspecting its annotations - * - * @param param the parameter to process - * @param paramAnnotations the parameter annotations - * @param constructorNames the array of constructorNames specified by - * @param pos the declaration position of the constructor parameter - * @param type the component type associated with implementation being reflected - * @param injectionNames the list of parameter constructorNames specified on parameter annotations - * @throws ProcessingException - */ - boolean processParam( - Class param, - Annotation[] paramAnnotations, - String[] constructorNames, - int pos, - PojoComponentType> type, - List injectionNames) throws ProcessingException; - - /** - * Returns true if {@link @Autowire}, {@link @Property}, or {@link @Reference} are present in the given array - */ - boolean injectionAnnotationsPresent(Annotation[][] annots); - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/IntrospectionRegistry.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/IntrospectionRegistry.java deleted file mode 100644 index a6122a6ff1..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/IntrospectionRegistry.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.spi.implementation.java; - -/** - * A system service which tracks {@link ImplementationProcessor}s - * - * @version $Rev$ $Date$ - */ -public interface IntrospectionRegistry extends Introspector { - - /** - * Registers the given processor and makes it available during assembly evaluation (i.e. build) - */ - void registerProcessor(ImplementationProcessor processor); - - /** - * Deregisters the given processor - */ - void unregisterProcessor(ImplementationProcessor processor); - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/Introspector.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/Introspector.java deleted file mode 100644 index 66abc1f686..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/Introspector.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.spi.implementation.java; - -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.deployer.DeploymentContext; - -/** - * Implementations are responsible for walking a component implementation class, adding additional component type - * information as appropriate - * - * @version $Rev$ $Date$ - */ -public interface Introspector { - - /** - * Walks the given component implementation class - * - * @param parent the parent composite - * @param clazz the component implementation class - * @param type the component type associated with the implementation class - * @return the updated component type - * @throws ProcessingException if an error is encountered evaluating the implementation class - */ - PojoComponentType introspect(CompositeComponent parent, - Class clazz, - PojoComponentType> type, - DeploymentContext context) - throws ProcessingException; - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/JavaMappedComponentType.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/JavaMappedComponentType.java deleted file mode 100644 index 34ac8f53f9..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/JavaMappedComponentType.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.spi.implementation.java; - -import org.apache.tuscany.spi.model.ComponentType; - -/** - * A specialized component type definition whose services, references and properties can be mapped to the Java - * programming model. - * - * @version $Rev$ $Date$ - */ -public class JavaMappedComponentType< - S extends JavaMappedService, - R extends JavaMappedReference, - P extends JavaMappedProperty - > extends ComponentType { - - private Class implClass; - - public JavaMappedComponentType() { - } - - public JavaMappedComponentType(Class implClass) { - this.implClass = implClass; - } - - /** - * Returns the implementation class associated with this component type. - * - * @return the implementation class associated with this component type - */ - public Class getImplClass() { - return implClass; - } - - /** - * Sets the implementation class associated with this component type. - * - * @param implClass the implementation class associated with this component type - */ - public void setImplClass(Class implClass) { - this.implClass = implClass; - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/JavaMappedProperty.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/JavaMappedProperty.java deleted file mode 100644 index 6d1715a035..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/JavaMappedProperty.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.spi.implementation.java; - -import java.lang.reflect.Member; -import javax.xml.namespace.QName; - -import org.apache.tuscany.spi.model.Property; - -/** - * A Property definition that is mapped to a specific location in the implementation class. This location will typically - * be used to inject property values. - * - * @version $Rev$ $Date$ - */ -public class JavaMappedProperty extends Property { - private Member member; - - public JavaMappedProperty() { - } - - public JavaMappedProperty(String name, QName xmlType, Class javaType) { - super(name, xmlType, javaType); - } - - public JavaMappedProperty(String name, QName xmlType, Class javaType, Member member) { - super(name, xmlType, javaType); - this.member = member; - } - - /** - * Returns the Member that this property is mapped to. - * - * @return the Member that this property is mapped to - */ - public Member getMember() { - return member; - } - - /** - * Sets the Member that this property is mapped to - * - * @param member the Member that this property is mapped to - */ - public void setMember(Member member) { - this.member = member; - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/JavaMappedReference.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/JavaMappedReference.java deleted file mode 100644 index 8c718a831b..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/JavaMappedReference.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.spi.implementation.java; - -import java.lang.reflect.Member; - -import org.apache.tuscany.spi.model.ReferenceDefinition; -import org.apache.tuscany.spi.model.ServiceContract; - -/** - * A ReferenceDefinition definition that is mapped to a specific location in the implementation class. This location - * will typically be used to inject reference values. - * - * @version $Rev$ $Date$ - */ -public class JavaMappedReference extends ReferenceDefinition { - private Member member; - - public JavaMappedReference() { - } - - public JavaMappedReference(String name, ServiceContract serviceContract, Member member) { - super(name, serviceContract); - this.member = member; - } - - /** - * Returns the Member that this reference is mapped to. - * - * @return the Member that this reference is mapped to - */ - public Member getMember() { - return member; - } - - /** - * Sets the Member that this reference is mapped to - * - * @param member the Member that this reference is mapped to - */ - public void setMember(Member member) { - this.member = member; - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/JavaMappedService.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/JavaMappedService.java deleted file mode 100644 index ee5e0bb2a7..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/JavaMappedService.java +++ /dev/null @@ -1,91 +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.spi.implementation.java; - -import java.lang.reflect.Member; - -import org.apache.tuscany.spi.model.ServiceContract; -import org.apache.tuscany.spi.model.ServiceDefinition; - -/** - * A ServiceDefinition definition that is mapped to a Java interface. The mapped interface is not required to be the - * same as the interface specified in the service contract. This is to allow the service contract to be specified using - * different interface definition languages or, in the case were the IDL is Java, to allow the service definition to be - * loaded from a different classloader. - * - * @version $Rev$ $Date$ - */ -public class JavaMappedService extends ServiceDefinition { - private Class serviceInterface; - private Member callbackMember; - - public JavaMappedService() { - } - - public JavaMappedService(Class serviceInterface) { - this.serviceInterface = serviceInterface; - } - - public JavaMappedService(String name, ServiceContract contract, boolean remotable) { - super(name, contract, remotable); - } - - public JavaMappedService(String name, - ServiceContract contract, - boolean remotable, - String callbackRefName, - Member callbackMember) { - super(name, contract, remotable, callbackRefName); - this.callbackMember = callbackMember; - } - - public JavaMappedService(String name, ServiceContract contract, Class serviceInterface, boolean remotable) { - super(name, contract, remotable); - this.serviceInterface = serviceInterface; - } - - /** - * Returns the Java interface for this service. This may be different from the interface that defines the service - * contract. - * - * @return the Java interface for this service - */ - public Class getServiceInterface() { - return serviceInterface; - } - - /** - * Sets the Java interface for this service. This may be different from the interface used to define the service - * contract. - * - * @param serviceInterface the Java interface for this service - */ - public void setServiceInterface(Class serviceInterface) { - this.serviceInterface = serviceInterface; - } - - public Member getCallbackMember() { - return callbackMember; - } - - public void setCallbackMember(Member callbackMember) { - this.callbackMember = callbackMember; - } - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/PojoComponentType.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/PojoComponentType.java deleted file mode 100644 index 193c18f3dc..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/PojoComponentType.java +++ /dev/null @@ -1,110 +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.spi.implementation.java; - -import java.lang.reflect.Member; -import java.lang.reflect.Method; -import java.util.HashMap; -import java.util.Map; - -import org.apache.tuscany.spi.model.ComponentType; -import org.apache.tuscany.spi.model.Property; -import org.apache.tuscany.spi.model.ReferenceDefinition; -import org.apache.tuscany.spi.model.ServiceDefinition; - -/** - * A component type specialization for POJO implementations - * - * @version $$Rev$$ $$Date$$ - */ -public class PojoComponentType> - extends ComponentType { - private boolean allowsPassByReference; - private ConstructorDefinition constructorDefinition; - private Method initMethod; - private Method destroyMethod; - private final Map resources = new HashMap(); - private Member conversationIDMember; - - /** - * Returns the constructor used to instantiate implementation instances - */ - public ConstructorDefinition getConstructorDefinition() { - return constructorDefinition; - } - - /** - * Sets the constructor used to instantiate implementation instances - */ - public void setConstructorDefinition(ConstructorDefinition definition) { - this.constructorDefinition = definition; - } - - /** - * Returns the component initializer method - */ - public Method getInitMethod() { - return initMethod; - } - - /** - * Sets the component initializer method - */ - public void setInitMethod(Method initMethod) { - this.initMethod = initMethod; - } - - /** - * Returns the component destructor method - */ - public Method getDestroyMethod() { - return destroyMethod; - } - - /** - * Sets the component destructor method - */ - public void setDestroyMethod(Method destroyMethod) { - this.destroyMethod = destroyMethod; - } - - public Map getResources() { - return resources; - } - - public void add(Resource resource) { - resources.put(resource.getName(), resource); - } - - public boolean isAllowsPassByReference() { - return allowsPassByReference; - } - - public void setAllowsPassByReference(boolean allowsPassByReference) { - this.allowsPassByReference = allowsPassByReference; - } - - public Member getConversationIDMember() { - return this.conversationIDMember; - } - - public void setConversationIDMember(Member conversationIDMember) { - this.conversationIDMember = conversationIDMember; - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/ProcessingException.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/ProcessingException.java deleted file mode 100644 index 40fd1dfd15..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/ProcessingException.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.spi.implementation.java; - -import java.lang.reflect.Member; - -import org.apache.tuscany.spi.loader.LoaderException; - -/** - * Denotes a problem processing annotations on a POJO implementation - * - * @version $Rev$ $Date$ - */ -public class ProcessingException extends LoaderException { - private Member member; - - public ProcessingException() { - } - - public ProcessingException(String message) { - super(message); - } - - public ProcessingException(String message, String identifier) { - super(message, identifier); - } - - public ProcessingException(String message, String identifier, Throwable cause) { - super(message, identifier, cause); - } - - public ProcessingException(String message, Throwable cause) { - super(message, cause); - } - - public ProcessingException(Throwable cause) { - super(cause); - } - - - public Member getMemberName() { - return member; - } - - public void setMember(Member member) { - this.member = member; - } - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/Resource.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/Resource.java deleted file mode 100644 index 5df4c3716d..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/Resource.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.spi.implementation.java; - -import java.lang.reflect.Member; - -import org.apache.tuscany.spi.ObjectFactory; - -/** - * A resource dependency declared by a Java component implementation - * - * @version $Rev$ $Date$ - */ -public class Resource { - - private String name; - private String mappedName; - private boolean optional; - private Member member; - private Class type; - private ObjectFactory objectFactory; - - /** - * The name of the resource - * - * @return the name of the resource - */ - public String getName() { - return name; - } - - /** - * Sets the name of the resource - * - * @param name the name of the resource - */ - public void setName(String name) { - this.name = name; - } - - /** - * Returns the URI of the resource - * - * @return the URI of the resource - */ - public String getMappedName() { - return mappedName; - } - - /** - * Sets the resource URI - */ - public void setMappedName(String mappedName) { - this.mappedName = mappedName; - } - - /** - * If true, the resource is optional - * - * @return true if the resource is optional - */ - public boolean isOptional() { - return optional; - } - - /** - * Sets whether the resource is optional - */ - public void setOptional(boolean optional) { - this.optional = optional; - } - - /** - * Returns the Member that this resource is mapped to. - * - * @return the Member that this resource is mapped to - */ - public Member getMember() { - return member; - } - - /** - * Sets the Member that this resource is mapped to - * - * @param member the Member that this resource is mapped to - */ - public void setMember(Member member) { - this.member = member; - } - - /** - * Returns the resource type - * - * @return the resource type - */ - public Class getType() { - return type; - } - - /** - * Sets the resource type - */ - public void setType(Class type) { - this.type = type; - } - - /** - * Returns the obeject factory - * - * @return the object factory - */ - public ObjectFactory getObjectFactory() { - return objectFactory; - } - - /** - * Sets the object factory - */ - public void setObjectFactory(ObjectFactory objectFactory) { - this.objectFactory = objectFactory; - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/ComponentTypeLoader.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/ComponentTypeLoader.java deleted file mode 100644 index 8ad01d8197..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/ComponentTypeLoader.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.spi.loader; - -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.deployer.DeploymentContext; -import org.apache.tuscany.spi.model.Implementation; - -/** - * Loader that will load the ComponentType definition for the supplied implementation. The actual mechanism used to load - * that definition is determined by the Client and Implementation Specification for the implementaion type. In some - * cases the definition may be contained in a XML file related to the implementation artifact in some well defined - * manner; other implementations may obtain this information from introspection of the artifact itself (for example, by - * examining Java annotations). - * - * @version $Rev$ $Date$ - */ -public interface ComponentTypeLoader { - /** - * Load the component type definition for the supplied implementation. - * - * @param parent the parent composite - * @param implementation the implementation whose component type information should be loaded - * @param deploymentContext the current deployment context - * @throws LoaderException if there was a problem loading the configuration type - */ - void load(CompositeComponent parent, I implementation, DeploymentContext deploymentContext) - throws LoaderException; -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/InvalidConfigurationException.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/InvalidConfigurationException.java deleted file mode 100644 index 1c7f3e073d..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/InvalidConfigurationException.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.spi.loader; - -/** - * Denotes an invalid configuration artifact - * - * @version $Rev$ $Date$ - */ -public class InvalidConfigurationException extends LoaderException { - - public InvalidConfigurationException(String message) { - super(message); - } - - public InvalidConfigurationException(String message, String identifier, Throwable cause) { - super(message, identifier, cause); - } - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/InvalidReferenceException.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/InvalidReferenceException.java deleted file mode 100644 index 40ae50bfe5..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/InvalidReferenceException.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.spi.loader; - -/** - * @version $Rev$ $Date$ - */ -public class InvalidReferenceException extends LoaderException { - private static final long serialVersionUID = -4346666572527197558L; - - public InvalidReferenceException(String message) { - super(message); - } - - public InvalidReferenceException(String message, String identifier) { - super(message, identifier); - } - - public InvalidReferenceException(Throwable cause) { - super(cause); - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/InvalidServiceException.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/InvalidServiceException.java deleted file mode 100644 index 1717cae0c3..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/InvalidServiceException.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.spi.loader; - -/** - * @version $Rev: 430937 $ $Date: 2006-08-12 06:47:56 +0530 (Sat, 12 Aug 2006) $ - */ -public class InvalidServiceException extends LoaderException { - - public InvalidServiceException(String message, String identifier) { - super(message, identifier); - } - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/InvalidValueException.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/InvalidValueException.java deleted file mode 100644 index b0ad8594ca..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/InvalidValueException.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.spi.loader; - -/** - * Exception that indicates the loader encountered an invalid value. - * The message should be set to the invalid value. - * - * @version $Rev$ $Date$ - */ -public class InvalidValueException extends LoaderException { - - public InvalidValueException(String message) { - super(message); - } - - public InvalidValueException(String message, Throwable cause) { - super(message, cause); - } - - public InvalidValueException(String message, String identifier, Throwable cause) { - super(message, identifier, cause); - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/InvalidWireException.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/InvalidWireException.java deleted file mode 100644 index b26c81168f..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/InvalidWireException.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.spi.loader; - -/** - * @version $Rev: 430937 $ $Date: 2006-08-12 06:47:56 +0530 (Sat, 12 Aug 2006) $ - */ -public class InvalidWireException extends LoaderException { - - public InvalidWireException() { - } - - public InvalidWireException(String message) { - super(message); - } - - - public InvalidWireException(String message, String identifier) { - super(message, identifier); - } - - public InvalidWireException(String message, Throwable cause) { - super(message, cause); - } - - public InvalidWireException(Throwable cause) { - super(cause); - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/Loader.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/Loader.java deleted file mode 100644 index e890d470a3..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/Loader.java +++ /dev/null @@ -1,92 +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.spi.loader; - -import java.net.URL; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; - -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.deployer.DeploymentContext; -import org.apache.tuscany.spi.model.Implementation; -import org.apache.tuscany.spi.model.ModelObject; - -/** - * System service for loading physical artifacts that represent SCDL configurations and creating the model objects that - * represent them. - * - * @version $Rev$ $Date$ - */ -public interface Loader { - /** - * Parse the supplied XML stream, dispatching to the appropriate registered loader for each element encountered in - * the stream. - *

      - * This method must be called with the XML cursor positioned on a START_ELEMENT event. When this method returns, the - * stream will be positioned on the corresponding END_ELEMENT event. - * - * @param parent the composite in which the model object is contained - * @param object the model object to load configuration data into. If null, the loader dispatched to is - * responsible for creating a model object itself - * @param reader the XML stream to parse - * @param deploymentContext the current deployment context - * @return the model object obtained by parsing the current element on the stream - * @throws XMLStreamException if there was a problem reading the stream - */ - ModelObject load(CompositeComponent parent, - ModelObject object, - XMLStreamReader reader, - DeploymentContext deploymentContext) - throws XMLStreamException, LoaderException; - - /** - * Load a model object from a specified location. - * - * @param parent the composite in which the model object is contained - * @param object the model object to load configuration data into. If null, the loader dispatched to is - * responsible for creating a model object itself - * @param url the location of an XML document to be loaded - * @param type the type of ModelObject that is expected to be in the document - * @param deploymentContext the current deployment context - * @return the model ojbect loaded from the document - * @throws LoaderException if there was a problem loading the document - */ - MO load(CompositeComponent parent, - ModelObject object, - URL url, - Class type, - DeploymentContext deploymentContext) - throws LoaderException; - - /** - * Load the component type definition for a given implementation. How the component type information is located is - * defined by the implementation specification. It may include loading from an XML sidefile, introspection of some - * artifact related to the implementation, some combination of those techniques or any other implementation-defined - * mechanism. - * - * @param parent the parent composite - * @param implementation the implementation whose component type should be loaded - * @param deploymentContext the current deployment context - * @throws LoaderException if there was a problem loading the component type definition - */ - > void loadComponentType(CompositeComponent parent, - I implementation, - DeploymentContext deploymentContext) - throws LoaderException; -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/LoaderException.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/LoaderException.java deleted file mode 100644 index defc6b06c9..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/LoaderException.java +++ /dev/null @@ -1,92 +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.spi.loader; - -import org.apache.tuscany.api.TuscanyException; - -/** - * Base class for Exceptions raised during the loading process. Loader implementations should throw a subclass of this - * to indicate the actual problem. - * - * @version $Rev$ $Date$ - */ -public class LoaderException extends TuscanyException { - public static final int UNDEFINED = -1; - private static final long serialVersionUID = -7459051598906813461L; - private String resourceURI; - private int line = UNDEFINED; - private int column = UNDEFINED; - - public LoaderException() { - } - - public LoaderException(String message) { - super(message); - } - - public LoaderException(String message, String identifier) { - super(message, identifier); - } - - public LoaderException(String message, Throwable cause) { - super(message, cause); - } - - public LoaderException(String message, String identifier, Throwable cause) { - super(message, identifier, cause); - } - - public LoaderException(Throwable cause) { - super(cause); - } - - /** - * Returns the location of the resource that was being loaded. - * - * @return the location of the resource that was being loaded - */ - public String getResourceURI() { - return resourceURI; - } - - /** - * Sets the location of the resource that was being loaded. - * - * @param resourceURI the location of the resource that was being loaded - */ - public void setResourceURI(String resourceURI) { - this.resourceURI = resourceURI; - } - - public int getLine() { - return line; - } - - public void setLine(int line) { - this.line = line; - } - - public int getColumn() { - return column; - } - - public void setColumn(int column) { - this.column = column; - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/LoaderRegistry.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/LoaderRegistry.java deleted file mode 100644 index ea88b99b22..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/LoaderRegistry.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.spi.loader; - -import javax.xml.namespace.QName; - -import org.apache.tuscany.spi.model.Implementation; -import org.apache.tuscany.spi.model.ModelObject; - -/** - * Registry for XML loaders that can parse a StAX input stream and return model objects. - *

      - * Loaders will typically be contributed to the system by any extension that needs to handle extension specific - * information contained in some XML configuration file. The loader can be contributed as a system component with an - * autowire reference to this builderRegistry which is used during initialization to actually register.

      This - * builderRegistry can also be used to parse an input stream, dispatching to the appropriate loader for each element - * accepted. Loaders can call back to the builderRegistry to load sub-elements that they are not able to handle - * directly. - * - * @version $Rev$ $Date$ - */ -public interface LoaderRegistry extends Loader { - /** - * Register a loader. This operation will typically be called by a loader during its initialization. - * - * @param element the element that should be delegated to the contibuted loader - * @param loader a loader that is being contributed to the system - */ - void registerLoader(QName element, StAXElementLoader loader); - - /** - * Unregister a loader. This will typically be called by a loader as it is being destroyed. - * - * @param element the element that was being delegated to the contibuted loader - * @param loader a loader that should no longer be used - */ - void unregisterLoader(QName element, StAXElementLoader loader); - - /** - * Regsiter a component type loader. - * - * @param key a type of implementation this loader can load component types for - * @param loader the loader that is being contributed to the system - */ - > void registerLoader(Class key, ComponentTypeLoader loader); - - /** - * Unregister a component type loader form the system. - * - * @param key a type of implementation whose loader should be unregistered - */ - > void unregisterLoader(Class key); -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/LoaderUtil.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/LoaderUtil.java deleted file mode 100644 index bf48f91a74..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/LoaderUtil.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.spi.loader; - -import javax.xml.stream.XMLStreamReader; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamConstants; - -/** - * Utility functions to support loader implementations. - * - * @version $Rev$ $Date$ - */ -public final class LoaderUtil { - private LoaderUtil() { - } - - /** - * Advance the stream to the next END_ELEMENT event skipping any nested content. - * - * @param reader the reader to advance - * @throws XMLStreamException if there was a problem reading the stream - */ - public static void skipToEndElement(XMLStreamReader reader) throws XMLStreamException { - int depth = 0; - while (true) { - int event = reader.next(); - if (event == XMLStreamConstants.START_ELEMENT) { - depth++; - } else if (event == XMLStreamConstants.END_ELEMENT) { - if (depth == 0) { - return; - } - depth--; - } - } - } - - /** - * Load the class using the supplied ClassLoader. - * The class will be defined so any initializers present will be fired. - * As the class is being loaded, the Thread context ClassLoader will be - * set to the supplied classloader. - * - * @param name the name of the class to load - * @param cl the classloader to use to load it - * @return the class - * @throws MissingResourceException if the class could not be found - */ - public static Class loadClass(String name, ClassLoader cl) throws MissingResourceException { - final Thread thread = Thread.currentThread(); - final ClassLoader oldCL = thread.getContextClassLoader(); - try { - thread.setContextClassLoader(cl); - return Class.forName(name, true, cl); - } catch (ClassNotFoundException e) { - throw new MissingResourceException(name, e); - } finally { - thread.setContextClassLoader(oldCL); - } - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/MissingImplementationException.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/MissingImplementationException.java deleted file mode 100644 index 89a44083cc..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/MissingImplementationException.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.spi.loader; - -/** - * Exception that indicates that an implementation was not provided. - * - * @version $Rev$ $Date$ - */ -public class MissingImplementationException extends LoaderException { - private static final long serialVersionUID = -2917278473974880124L; - - /** - * Default constructor. - */ - public MissingImplementationException() { - super(); - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/MissingIncludeException.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/MissingIncludeException.java deleted file mode 100644 index 10e40f9288..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/MissingIncludeException.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.spi.loader; - -/** - * Exception that indicates that an include was not provided. - * - * @version $Rev$ $Date$ - */ -public class MissingIncludeException extends LoaderException { - private static final long serialVersionUID = -2917278473974880124L; - - public MissingIncludeException(String message, String identifier) { - super(message, identifier); - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/MissingMustOverridePropertyException.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/MissingMustOverridePropertyException.java deleted file mode 100644 index 78856784e5..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/MissingMustOverridePropertyException.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.spi.loader; - -/** - * @version $Rev$ $Date$ - */ -public class MissingMustOverridePropertyException extends LoaderException { - - public MissingMustOverridePropertyException(String name) { - super(name); - } - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/MissingReferenceException.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/MissingReferenceException.java deleted file mode 100644 index 7bc206de34..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/MissingReferenceException.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.spi.loader; - -/** - * Indicates a required reference was not configured - * - * @version $Rev$ $Date$ - */ -public class MissingReferenceException extends LoaderException { - - public MissingReferenceException(String message) { - super(message); - } - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/MissingResourceException.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/MissingResourceException.java deleted file mode 100644 index 3b6a21aa74..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/MissingResourceException.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.spi.loader; - -/** - * Exception that indicates an expected resource could not be found. The message should be set to the name of the - * resource. - * - * @version $Rev$ $Date$ - */ -public class MissingResourceException extends LoaderException { - private static final long serialVersionUID = 3775013318397916445L; - - /** - * Constructor that indicates which resource could not be found. The supplied parameter is also returned as the - * message. - * - * @param resource the resource that could not be found - */ - public MissingResourceException(String resource) { - super("Missing resource", resource); - } - - public MissingResourceException(String message, String identifier) { - super(message, identifier); - } - - /** - * Constructor that indicates which resource could not be found. The supplied parameter is also returned as the - * message. - * - * @param resource the resource that could not be found - * @param cause the error thrown resolving the resource - */ - public MissingResourceException(String resource, Throwable cause) { - super("Missing resource", resource, cause); - } - - - /** - * Constructor that indicates which resource could not be found. The supplied parameter is also returned as the - * message. - * - * @param message the message set on the exception - * @param identifier the resource that could not be found - * @param cause the error thrown resolving the resource - */ - public MissingResourceException(String message, String identifier, Throwable cause) { - super(message, identifier, cause); - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/NotOverridablePropertyException.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/NotOverridablePropertyException.java deleted file mode 100644 index 4672f22a6a..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/NotOverridablePropertyException.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.spi.loader; - -/** - * @version $Rev$ $Date$ - */ -public class NotOverridablePropertyException extends LoaderException { - private static final long serialVersionUID = 1483304023970967982L; - - public NotOverridablePropertyException(String name) { - super(name); - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/PropertyObjectFactory.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/PropertyObjectFactory.java deleted file mode 100644 index 8b569d76fb..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/PropertyObjectFactory.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.spi.loader; - -import org.apache.tuscany.spi.ObjectFactory; -import org.apache.tuscany.spi.model.Property; -import org.apache.tuscany.spi.model.PropertyValue; - -/** - * A factory that will create an ObjectFactory for a property - * - * @version $Rev$ $Date$ - */ -public interface PropertyObjectFactory { - /** - * Return an ObjectFactory for instances of a property defined in an XML. The ObjectFactory must return instances - * that can safely be supplied to component implementations. If the instance is mutable and isolation between - * components is required, then the factory must clone or otherwise protect the implementation from unexpected - * modifications by other implementation instances. - * - * @param property the Property definition that the resulting ObjectFactory must be able to assign to - * @param propertyValue The component configuration of the property - * @return an ObjectFactory that can produce instances that can be assigned to the supplied Property - * @throws LoaderException if there is a problem creating the ObjectFactory - */ - ObjectFactory createObjectFactory(Property property, PropertyValue propertyValue) - throws LoaderException; -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/StAXElementLoader.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/StAXElementLoader.java deleted file mode 100644 index 401e34cb71..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/StAXElementLoader.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.spi.loader; - -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; - -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.deployer.DeploymentContext; -import org.apache.tuscany.spi.model.ModelObject; - -/** - * A loader that creates a model object from a StAX input stream. - * - * @version $Rev$ $Date$ - */ -public interface StAXElementLoader { - /** - * Create the model object for an element in an XML stream. When this method returns the stream will be positioned - * on the corresponding END_ELEMENT. - * - * @param parent the composite the model object being loaded is contained within - * @param object the model object to load configuration data into. An implementation may choose to return - * a different model object than the one passed in, in which case it is responsible for - * copying data. If null, the loader is responsible for creating a model object itself - * @param reader the XML stream reader positioned on the applicable START_ELEMENT - * @param deploymentContext the context for the load operation - * @return the model object for that element - */ - T load(CompositeComponent parent, ModelObject object, XMLStreamReader reader, DeploymentContext deploymentContext) - throws XMLStreamException, LoaderException; -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/UndefinedPropertyException.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/UndefinedPropertyException.java deleted file mode 100644 index bf3aa205d2..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/UndefinedPropertyException.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.spi.loader; - -/** - * @version $Rev$ $Date$ - */ -public class UndefinedPropertyException extends LoaderException { - public UndefinedPropertyException(String name) { - super("Property not found on implementation", name); - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/UndefinedReferenceException.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/UndefinedReferenceException.java deleted file mode 100644 index 2c9d8e66c5..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/UndefinedReferenceException.java +++ /dev/null @@ -1,10 +0,0 @@ -package org.apache.tuscany.spi.loader; - -/** - * @version $Rev$ $Date$ - */ -public class UndefinedReferenceException extends LoaderException { - public UndefinedReferenceException(String name) { - super("Reference not found on implementation", name); - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/UnrecognizedComponentTypeException.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/UnrecognizedComponentTypeException.java deleted file mode 100644 index 750762d839..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/UnrecognizedComponentTypeException.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.spi.loader; - -/** - * Exception that indicates an component type was encountered that could not be handled. - * - * @version $Rev$ $Date$ - */ -public class UnrecognizedComponentTypeException extends LoaderException { - private final Class type; - - /** - * Constructor that indicates which component type loader could not be found. - * - * @param type the component type type that could not be handled - */ - public UnrecognizedComponentTypeException(Class type) { - super("Unrecognized element", type.getName()); - this.type = type; - } - - public Class getType() { - return type; - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/UnrecognizedElementException.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/UnrecognizedElementException.java deleted file mode 100644 index 7991105da8..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/UnrecognizedElementException.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.spi.loader; - -import javax.xml.namespace.QName; - -/** - * Exception that indicates an element was encountered that could not be handled. - * - * @version $Rev$ $Date$ - */ -public class UnrecognizedElementException extends LoaderException { - private static final long serialVersionUID = 2549543622209829032L; - private final QName element; - - /** - * Constructor that indicates which resource could not be found. The supplied parameter is also returned as the - * message. - * - * @param element the element that could not be handled - */ - public UnrecognizedElementException(QName element) { - super("Unrecognized element", element.toString()); - this.element = element; - } - - public QName getElement() { - return element; - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/AtomicImplementation.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/AtomicImplementation.java deleted file mode 100644 index 8e12e970ae..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/AtomicImplementation.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.spi.model; - -/** - * The base representation of an atomic component implementation - * - * @version $Rev$ $Date$ - */ -public abstract class AtomicImplementation extends Implementation { - protected AtomicImplementation() { - } - - protected AtomicImplementation(T componentType) { - super(componentType); - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/BindingDefinition.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/BindingDefinition.java deleted file mode 100644 index 4b17181442..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/BindingDefinition.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.spi.model; - -import java.net.URI; - -/** - * The base representation of a binding specified in an assembly - * - * @version $Rev$ $Date$ - */ -public abstract class BindingDefinition extends ModelObject { - private URI targetUri; - - protected BindingDefinition() { - } - - public BindingDefinition(URI targetUri) { - this.targetUri = targetUri; - } - - public URI getTargetUri() { - return targetUri; - } - - public void setTargetUri(URI targetUri) { - this.targetUri = targetUri; - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/BoundReferenceDefinition.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/BoundReferenceDefinition.java deleted file mode 100644 index 94078696e7..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/BoundReferenceDefinition.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.spi.model; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -/** - * Represents a reference in a composite - * - * @version $Rev$ $Date$ - */ -public class BoundReferenceDefinition extends ReferenceDefinition { - private List bindings; - - public BoundReferenceDefinition(String name, - ServiceContract contract, - List bindings, - Multiplicity multiplicity) { - super(name, contract); - this.bindings = bindings; - setMultiplicity(multiplicity); - } - - public BoundReferenceDefinition() { - bindings = new ArrayList(); - } - - public List getBindings() { - return Collections.unmodifiableList(bindings); - } - - public void addBinding(BindingDefinition binding) { - this.bindings.add(binding); - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/BoundServiceDefinition.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/BoundServiceDefinition.java deleted file mode 100644 index d4d3a54704..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/BoundServiceDefinition.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.spi.model; - -import java.net.URI; -import java.util.Collections; -import java.util.List; -import java.util.ArrayList; - -/** - * Represents a service offered by a component, that has a 1..n bindings associated with it. - * - * @version $Rev$ $Date$ - */ -public class BoundServiceDefinition extends ServiceDefinition { - private List bindings; - private URI target; - - public BoundServiceDefinition(String name, - ServiceContract contract, - List bindings, - boolean remotable, - URI target) { - super(name, contract, remotable); - this.target = target; - this.bindings = bindings; - } - - public BoundServiceDefinition() { - bindings = new ArrayList(); - } - - public List getBindings() { - return Collections.unmodifiableList(bindings); - } - - public void addBinding(BindingDefinition binding) { - this.bindings.add(binding); - } - - public URI getTarget() { - return target; - } - - public void setTarget(URI target) { - this.target = target; - } - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ComponentDefinition.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ComponentDefinition.java deleted file mode 100644 index de4abbd4e8..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ComponentDefinition.java +++ /dev/null @@ -1,154 +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.spi.model; - -import java.util.HashMap; -import java.util.Map; - -/** - * Represents a component. - *

      A component is a configured instance of an implementation. The services provided and consumed - * and the available configuration properties are defined by the implementation (represented by - * its componentType).

      - *

      Every component has a name which uniquely identifies it within the scope of the composite - * that contains it; the name must be different from the names of all other components, services and references - * immediately contained in the composite (directly or through an <include> element).

      - *

      A component may define a {@link PropertyValue} that overrides the default value of a {@link Property} - * defined in the componentType.

      - *

      It may also define a {@link ReferenceTarget} for a {@link ReferenceDefinition} defined in the componentType. - * The ReferenceTarget must resolve to another component or a reference in the enclosing composite.

      - *

      Components may specify an initialization level that will determine the order in which it will be eagerly - * initialized relative to other components from the enclosing composite that are in the same scope. This can be - * used to define a startup sequence for components that are otherwise independent. Any initialization required - * to resolve references between components will override this initialization order.

      - * - * @version $Rev$ $Date$ - */ -public class ComponentDefinition> extends ModelObject { - private String name; - private Integer initLevel; - private final I implementation; - private final Map referenceTargets = new HashMap(); - private final Map> propertyValues = new HashMap>(); - - /** - * Constructor specifying the component's name and implementation. - * - * @param name the name of this component - * @param implementation the implementation of this component - */ - public ComponentDefinition(String name, I implementation) { - this.name = name; - this.implementation = implementation; - } - - /** - * Constructor specifying the implementation of this component. - * - * @param implementation the implementation of this component - */ - public ComponentDefinition(I implementation) { - this.implementation = implementation; - } - - /** - * Returns the {@link Implementation} of this component. - * - * @return the implementation of this component - */ - public I getImplementation() { - return implementation; - } - - /** - * Returns the name of this component. - * - * @return the name of this component - */ - public String getName() { - return name; - } - - /** - * Sets the name of this component. - * - * @param name the name of this component - */ - public void setName(String name) { - this.name = name; - } - - /** - * Returns the initialization level of this component. - * - * @return the initialization level of this component - */ - public Integer getInitLevel() { - return initLevel; - } - - /** - * Sets the initialization level of this component. - * If set to null then the level from the componentType is used. - * If set to zero or a negative value then the component will not be eagerly initialized. - * - * @param initLevel the initialization level of this component - */ - public void setInitLevel(Integer initLevel) { - this.initLevel = initLevel; - } - - /** - * Returns a live Map of the {@link ReferenceTarget targets} configured by this component definition. - * - * @return the reference targets configured by this component - */ - public Map getReferenceTargets() { - return referenceTargets; - } - - /** - * Add a reference target configuration to this component. - * Any existing configuration for the reference named in the target is replaced. - * - * @param target the target to add - */ - public void add(ReferenceTarget target) { - referenceTargets.put(target.getReferenceName(), target); - } - - /** - * Returns a live Map of {@link PropertyValue property values} configured by this component definition. - * - * @return the property values configured by this component - */ - public Map> getPropertyValues() { - return propertyValues; - } - - /** - * Add a property value configuration to this component. - * Any existing configuration for the property names in the property value is replaced. - * - * @param value the property value to add - */ - public void add(PropertyValue value) { - propertyValues.put(value.getName(), value); - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ComponentType.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ComponentType.java deleted file mode 100644 index 2c37f00889..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ComponentType.java +++ /dev/null @@ -1,178 +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.spi.model; - -import java.util.HashMap; -import java.util.Map; - -/** - *

      The definition of the configurable aspects of an implementation in terms of the services it exposes, the services - * it references, and properties that can be used to configure it.

      A service represents an addressable interface - * provided by the implementation. Such a service may be the target of a wire from another component.

      A reference - * represents a requirement that an implementation has on a service provided by another component or by a resource - * outside the SCA system. Such a reference may be the source of a wire to another component.

      A property allows - * the behaviour of the implementation to be configured through externally set values.

      A component type may also - * declare that it wishes to be initialized upon activation of the scope that contains it and may specify an order - * relative to other eagerly initializing components. For example, an implementation that pre-loads some form of cache - * could declare that it should be eagerly initialized at the start of the scope so that the cache load occured on - * startup rather than first use.

      - * - * @version $Rev$ $Date$ - */ -public class ComponentType> - extends ModelObject { - protected Scope implementationScope = Scope.UNDEFINED; - private int initLevel; - private long maxAge = -1; - private long maxIdleTime = -1; - private final Map services = new HashMap(); - private final Map references = new HashMap(); - private final Map properties = new HashMap(); - - /** - * Returns the component implementation scope - */ - public Scope getImplementationScope() { - return implementationScope; - } - - /** - * Sets the component implementation scope - */ - public void setImplementationScope(Scope implementationScope) { - this.implementationScope = implementationScope; - } - - /** - * Returns the default initialization level for components of this type. A value greater than zero indicates that - * components should be eagerly initialized. - * - * @return the default initialization level - */ - public int getInitLevel() { - return initLevel; - } - - /** - * Sets the default initialization level for components of this type. A value greater than zero indicates that - * components should be eagerly initialized. - * - * @param initLevel default initialization level for components of this type - */ - public void setInitLevel(int initLevel) { - this.initLevel = initLevel; - } - - /** - * Returns true if this component should be eagerly initialized. - * - * @return true if this component should be eagerly initialized - */ - public boolean isEagerInit() { - return initLevel > 0; - } - - /** - * Returns the idle time allowed between operations in milliseconds if the implementation is conversational - * - * @return the idle time allowed between operations in milliseconds if the implementation is conversational - */ - public long getMaxIdleTime() { - return maxIdleTime; - } - - /** - * Sets the idle time allowed between operations in milliseconds if the implementation is conversational - */ - public void setMaxIdleTime(long maxIdleTime) { - this.maxIdleTime = maxIdleTime; - } - - /** - * Returns the maximum age a conversation may remain active in milliseconds if the implementation is conversational - * - * @return the maximum age a conversation may remain active in milliseconds if the implementation is conversational - */ - public long getMaxAge() { - return maxAge; - } - - /** - * Sets the maximum age a conversation may remain active in milliseconds if the implementation is conversational - */ - public void setMaxAge(long maxAge) { - this.maxAge = maxAge; - } - - /** - * Returns a live Map of the services provided by the implementation. - * - * @return a live Map of the services provided by the implementation - */ - public Map getServices() { - return services; - } - - /** - * Add a service to those provided by the implementation. Any existing service with the same name is replaced. - * - * @param service a service provided by the implementation - */ - public void add(S service) { - services.put(service.getName(), service); - } - - /** - * Returns a live Map of references to services consumed by the implementation. - * - * @return a live Map of references to services consumed by the implementation - */ - public Map getReferences() { - return references; - } - - /** - * Add a reference to a service consumed by the implementation. Any existing reference with the same name is - * replaced. - * - * @param reference a reference to a service consumed by the implementation - */ - public void add(R reference) { - references.put(reference.getName(), reference); - } - - /** - * Returns a live Map of properties that can be used to configure the implementation. - * - * @return a live Map of properties that can be used to configure the implementation - */ - public Map getProperties() { - return properties; - } - - /** - * Add a property that can be used to configure the implementation. Any existing property with the same name is - * replaced. - * - * @param property a property that can be used to configure the implementation - */ - public void add(P property) { - properties.put(property.getName(), property); - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/CompositeComponentType.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/CompositeComponentType.java deleted file mode 100644 index ffc50b2b7c..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/CompositeComponentType.java +++ /dev/null @@ -1,174 +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.spi.model; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * A specialization of component type for composite components. - * - * @version $Rev$ $Date$ - */ -public class CompositeComponentType> extends ComponentType { - - private String name; - private final Map>> components = - new HashMap>>(); - private final Map includes = new HashMap(); - private final List wires = new ArrayList(); - - public CompositeComponentType() { - implementationScope = Scope.SYSTEM; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - @Override - @SuppressWarnings("unchecked") - /** - * Get all properties including the ones are from included composites - * @return - */ - public Map getProperties() { - Map view = new HashMap(super.getProperties()); - for (Include i : includes.values()) { - view.putAll(i.getIncluded().getProperties()); - } - return Collections.unmodifiableMap(view); - } - - @Override - @SuppressWarnings("unchecked") - /** - * Get all references including the ones are from included composites - * @return - */ - public Map getReferences() { - Map view = new HashMap(super.getReferences()); - for (Include i : includes.values()) { - view.putAll(i.getIncluded().getReferences()); - } - return Collections.unmodifiableMap(view); - } - - @SuppressWarnings("unchecked") - @Override - /** - * Get all services including the ones are from included composites - * @return - */ - public Map getServices() { - Map view = new HashMap(super.getServices()); - for (Include i : includes.values()) { - view.putAll(i.getIncluded().getServices()); - } - return Collections.unmodifiableMap(view); - } - - /** - * Get all components including the ones are from included composites - */ - @SuppressWarnings("unchecked") - public Map>> getComponents() { - Map>> view = - new HashMap>>(components); - for (Include i : includes.values()) { - view.putAll(i.getIncluded().getComponents()); - } - return Collections.unmodifiableMap(view); - } - - - /** - * Get all wires including the ones are from included composites - */ - @SuppressWarnings("unchecked") - public List getWires() { - List view = - new ArrayList(wires); - for (Include i : includes.values()) { - view.addAll(i.getIncluded().getWires()); - } - return Collections.unmodifiableList(view); - } - - /** - * Get declared properties in this composite type, included doesn't count - */ - public Map getDeclaredProperties() { - return super.getProperties(); - } - - /** - * Get declared references in this composite type, included doesn't count - */ - public Map getDeclaredReferences() { - return super.getReferences(); - } - - /** - * Get declared services in this composite type, included doesn't count - */ - public Map getDeclaredServices() { - return super.getServices(); - } - - /** - * Get declared components in this composite type, included doesn't count - */ - public Map>> getDeclaredComponents() { - return components; - } - - /** - * Get declared wires in this composite type, included doesn't count - */ - public List getDeclaredWires() { - return wires; - } - - public void add(WireDefinition wireDefn) { - wires.add(wireDefn); - } - - - public void add(ComponentDefinition> componentDefinition) { - components.put(componentDefinition.getName(), componentDefinition); - } - - public Map getIncludes() { - return includes; - } - - public void add(Include include) { - includes.put(include.getName(), include); - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/CompositeImplementation.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/CompositeImplementation.java deleted file mode 100644 index 6948c52286..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/CompositeImplementation.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.spi.model; - -import java.net.URL; - -/** - * A specialization of an implementation associated with composite components - * - * @version $Rev$ $Date$ - */ -public class CompositeImplementation extends Implementation { - private String name; - private URL scdlLocation; - private ClassLoader classLoader; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public URL getScdlLocation() { - return scdlLocation; - } - - public void setScdlLocation(URL scdlLocation) { - this.scdlLocation = scdlLocation; - } - - public ClassLoader getClassLoader() { - return classLoader; - } - - public void setClassLoader(ClassLoader classLoader) { - this.classLoader = classLoader; - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/DataType.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/DataType.java deleted file mode 100644 index f36f3765ce..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/DataType.java +++ /dev/null @@ -1,242 +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.spi.model; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.Map; - -/** - * Representation of the type of data associated with an operation. Data is represented in two forms: the physical form - * used by the runtime and a logical form used by the assembly. The physical form is a Java Type because the runtime is - * written in Java. This may be the same form used by the application but it may not; for example, an application that - * is performing stream processing may want a physical form such as an {@link java.io.InputStream InputStream} to - * semantially operate on application data such as a purchase order. The logical description is that used by the - * assembly model and is an identifier into some well-known type space; examples may be a Java type represented by its - * Class or an XML type represented by its QName. Every data type may also contain metadata describing the expected - * data; for example, it could specify a preferred data binding technology or the size of a typical instance. - * - * @version $Rev$ $Date$ - */ -public class DataType extends ModelObject implements Cloneable { - private String dataBinding = Object.class.getName(); - - private final Type physical; - - private final L logical; - - private Map metadata = new HashMap(); - - private Operation operation; - - /** - * Construct a data type specifying the physical and logical types. - * - * @param physical the physical class used by the runtime - * @param logical the logical type - * @see #getLogical() - */ - public DataType(Type physical, L logical) { - this.physical = physical; - this.logical = logical; - if (physical instanceof Class) { - this.dataBinding = ((Class) physical).getName(); - } - } - - public DataType(String dataBinding, Type physical, L logical) { - this.dataBinding = dataBinding; - this.physical = physical; - this.logical = logical; - } - - /** - * Returns the physical type used by the runtime. - * - * @return the physical type used by the runtime - */ - public Type getPhysical() { - return physical; - } - - /** - * Returns the logical identifier used by the assembly. The type of this value identifies the logical type system in - * use. Known values are:
      • a java.lang.reflect.Type identifies a Java type by name and ClassLoader; this - * includes Java Classes as they are specializations of Type
      • a javax.xml.namespace.QName identifies an XML - * type by local name and namespace
      - * - * @return the logical type name - */ - public L getLogical() { - return logical; - } - - /** - * Returns all metadata about this type. - * - * @return all metadata about this type - */ - public Map getMetadata() { - return metadata; - } - - /** - * Returns the specified metadata item or null if not present. - * - * @param name the name of the metadata item - * @return the value, or null if not present - */ - public Object getMetadata(String name) { - return metadata.get(name); - } - - /** - * Sets the specified metadata value. A null value undefines it. - * - * @param name the name of the metadata item - * @param value the value, or null to undefine - * @return the old value for the item, or null if not present - */ - public Object setMetadata(String name, Object value) { - if (value == null) { - return metadata.remove(name); - } else { - return metadata.put(name, value); - } - } - - public String getDataBinding() { - if (dataBinding == null) { - // databinding is not set at the DataType level, check the operation - Operation operation = (Operation) getOperation(); - if (operation != null) { - return operation.getDataBinding(); - } - } - return dataBinding; - } - - /** - * @param dataBinding the dataBinding to set - */ - public void setDataBinding(String dataBinding) { - this.dataBinding = dataBinding; - } - - public int hashCode() { - int result; - result = dataBinding != null ? dataBinding.hashCode() : 0; - result = 29 * result + (physical != null ? physical.hashCode() : 0); - result = 29 * result + (logical != null ? logical.hashCode() : 0); - // Commented the following line out since it causes infinite loop from Operation.hashCode() - // if the metadata map contains the Operation - // result = 29 * result + (metadata != null ? metadata.hashCode() : 0); - return result; - } - - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - - final DataType dataType = (DataType) o; - - if (dataBinding != null ? !dataBinding.equals(dataType.dataBinding) : dataType.dataBinding != null) { - return false; - } - if (logical != null ? !logical.equals(dataType.logical) : dataType.logical != null) { - return false; - } - return !(physical != null ? !physical.equals(dataType.physical) : dataType.physical != null); - - } - -// @SuppressWarnings("unchecked") -// public boolean equals(Object o) { -// if (this == o) { -// return true; -// } -// if (o == null || getClass() != o.getClass()) { -// return false; -// } -// -// final DataType dataType = (DataType) o; -// -// if (logical instanceof Class && dataType.logical instanceof Class) { -// Class logicalClass = (Class) logical; -// Class targetLogicalClass = (Class) dataType.logical; -// if (!logicalClass.isAssignableFrom(targetLogicalClass)) { -// return false; -// } -// } else { -// if (logical != null ? !logical.equals(dataType.logical) : dataType.logical != null) { -// return false; -// } -// } -// if (physical instanceof Class && dataType.physical instanceof Class) { -// Class physicalClass = (Class) physical; -// Class physicalTargetClass = (Class) dataType.physical; -// if (dataBinding != null -// && dataType.dataBinding != null -// && dataBinding.equals(physicalClass.getName()) -// && dataType.dataBinding.equals(physicalTargetClass.getName())) { -// return physicalClass.isAssignableFrom(physicalTargetClass); -// } -// if (!physicalClass.isAssignableFrom(physicalTargetClass)) { -// return false; -// } -// return !(dataBinding != null ? !dataBinding.equals(dataType.dataBinding) : dataType.dataBinding != null); -// -// -// } -// -// if (dataBinding != null ? !dataBinding.equals(dataType.dataBinding) : dataType.dataBinding != null) { -// return false; -// } -// -// return !(physical != null ? !physical.equals(dataType.physical) : dataType.physical != null); -// } - - public String toString() { - StringBuffer sb = new StringBuffer(); - sb.append(physical).append(" ").append(dataBinding).append(" ").append(logical); - return sb.toString(); - } - - @SuppressWarnings("unchecked") - @Override - public Object clone() throws CloneNotSupportedException { - DataType copy = (DataType) super.clone(); - assert this.metadata instanceof HashMap; - copy.metadata = (HashMap) ((HashMap) this.metadata).clone(); - return copy; - } - - public Operation getOperation() { - return operation; - } - - public void setOperation(Operation operation) { - this.operation = operation; - } - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Implementation.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Implementation.java deleted file mode 100644 index 8520ab49e8..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Implementation.java +++ /dev/null @@ -1,43 +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.spi.model; - -/** - * Represents a component implementation - * - * @version $Rev$ $Date$ - */ -public abstract class Implementation extends ModelObject { - private T componentType; - - protected Implementation() { - } - - protected Implementation(T componentType) { - this.componentType = componentType; - } - - public T getComponentType() { - return componentType; - } - - public void setComponentType(T componentType) { - this.componentType = componentType; - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Include.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Include.java deleted file mode 100644 index ac320a2b5c..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Include.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.spi.model; - -import java.net.URL; - -/** - * Model object that represents the include of a composite by value. - * - * @version $Rev$ $Date$ - */ -public class Include extends ModelObject { - private String name; - private URL scdlLocation; - private CompositeComponentType included; - - /** - * Returns the name of the composite that is being included. - * @return the name of the composite that is being included - */ - public String getName() { - return name; - } - - /** - * Sets the name of the composite that is being included. - * @param name the name of the composite that is being included - */ - public void setName(String name) { - this.name = name; - } - - /** - * Returns the location of the SCDL for composite being included. - * @return the location of the SCDL for composite being included - */ - public URL getScdlLocation() { - return scdlLocation; - } - - /** - * Sets the location of the SCDL for composite being included. - * @param scdlLocation the location of the SCDL for composite being included - */ - public void setScdlLocation(URL scdlLocation) { - this.scdlLocation = scdlLocation; - } - - /** - * Returns the composite that was included. - * @return the composite that was included - */ - public CompositeComponentType getIncluded() { - return included; - } - - /** - * Sets the composite that was included. - * @param included the composite that was included - */ - public void setIncluded(CompositeComponentType included) { - this.included = included; - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Intent.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Intent.java deleted file mode 100644 index 9f3ee78a23..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Intent.java +++ /dev/null @@ -1,92 +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.spi.model; - -import java.util.ArrayList; -import static java.util.Collections.unmodifiableList; -import java.util.List; -import javax.xml.namespace.QName; - -/** - * Model representation for intent. This class is used by intent loader only, other SCA model classes will not reference - * this class directly. - * - * @version $Rev$ $Date$ - */ -public class Intent { - - /** - * name of intent. - */ - protected IntentName name; - - /** - * Description for this intent - */ - protected String description; - - /** - * QNames of artifacts this intent can apply to - */ - protected List appliedArtifacts = new ArrayList(); - - /** - * intents required by this intent, only useful when this intent is a profile intent - */ - protected List requriedIntents = new ArrayList(); - - /** - * Create a policy intent. - * - * @param name name of the intent. - * @param description description of the intent. - */ - public Intent(IntentName name, String description) { - this.name = name; - this.description = description; - } - - public List getAppliedArtifacts() { - return unmodifiableList(appliedArtifacts); - } - - public String getDescription() { - return description; - } - - public IntentName getName() { - return name; - } - - public List getRequriedIntents() { - return unmodifiableList(requriedIntents); - } - - public void addRequriedIntents(IntentName intent) { - requriedIntents.add(intent); - } - - public void addAppliedArtifacts(QName artifactName) { - appliedArtifacts.add(artifactName); - } - - public boolean isProfileIntent() { - return !requriedIntents.isEmpty(); - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/IntentMap.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/IntentMap.java deleted file mode 100644 index cbfba86dfe..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/IntentMap.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.spi.model; - -import java.util.ArrayList; -import java.util.Collection; -import static java.util.Collections.unmodifiableCollection; - -/** - * Represents an IntentMap within PolicySet. - * - * @version $Rev$ $Date$ - */ -public class IntentMap extends PolicyModel { - - /* Name of default intent provied by this IntentMap */ - private String defaultProvideIntent; - - /* Name of intent provided by this IntentMap */ - private Collection provideIntents = new ArrayList(); - - /* Qualifiers of this IntentMap */ - private Collection qualifiers = new ArrayList(); - - public IntentMap(String defaultProvideIntent, Collection provideIntents) { - super(); - this.defaultProvideIntent = defaultProvideIntent; - this.provideIntents.addAll(provideIntents); - } - - public Collection getProvideIntents() { - return unmodifiableCollection(provideIntents); - } - - public void addQualifier(Qualifier qualifier) { - qualifiers.add(qualifier); - } - - public Collection getQualifiers() { - return unmodifiableCollection(qualifiers); - } - - public String getDefaultProvideIntent() { - return defaultProvideIntent; - } - - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/IntentName.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/IntentName.java deleted file mode 100644 index eb69b44b37..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/IntentName.java +++ /dev/null @@ -1,140 +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.spi.model; - -import java.util.Arrays; - -/** - * Model class represents a name of a intent. An intent name has a domain name and one or more qualified names. For - * example, in "sec.confidentiality/message/body", the domain name is sec, and the qualified names are confidentiality, - * message and body - */ -@SuppressWarnings({"SerializableHasSerializationMethods"}) -public class IntentName implements java.io.Serializable { - private static final String QUALIFIED_SEPARATOR = "/"; - private static final String DOMAIN_SEPARATOR = "."; - private static final long serialVersionUID = -7030021353149084879L; - - /** - * domain of the intent - */ - private String domain; - - private String[] qualifiedNames; - - /** - * Construct a IntentName from a string representation. - * - * @param intent string representation for a intent. - */ - public IntentName(String intent) { - parse(intent); - } - - /** - * Construct a IntentName from domain name and qualified names - * - * @param domain domain name of the intent - * @param qualifiedNames qualified names of the intent - */ - public IntentName(String domain, String[] qualifiedNames) { - this.domain = domain; - this.qualifiedNames = qualifiedNames; - } - - public String getDomain() { - return domain; - } - - public String[] getQualifiedNames() { - String[] results = new String[qualifiedNames.length]; - System.arraycopy(qualifiedNames, 0, results, 0, qualifiedNames.length); - return results; - } - - @Override - public String toString() { - return getName(); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final IntentName other = (IntentName) obj; - if (domain == null) { - if (other.domain != null) { - return false; - } - } else if (!domain.equals(other.domain)) { - return false; - } - return Arrays.equals(qualifiedNames, other.qualifiedNames); - } - - @Override - public int hashCode() { - final int PRIME = 17; - int result = 1; - result = PRIME * result + ((domain == null) ? 0 : domain.hashCode()); - result = PRIME * result + Arrays.hashCode(qualifiedNames); - return result; - } - - private String getName() { - StringBuilder sbd = new StringBuilder(domain); - for (int i = 0; i < qualifiedNames.length; i++) { - if (i == 0) { - sbd.append(DOMAIN_SEPARATOR); - } else { - sbd.append(QUALIFIED_SEPARATOR); - } - sbd.append(qualifiedNames[i]); - } - - return sbd.toString(); - } - - /** - * Parse a string representation of intent. - * - * @param intent string representation of intent - */ - private void parse(String intent) { - String iname = validateFormat(intent); - int domainIdx = iname.indexOf(DOMAIN_SEPARATOR); - domain = iname.substring(0, domainIdx); - String qualifNamesStr = iname.substring(domainIdx + 1); - qualifiedNames = qualifNamesStr.split(QUALIFIED_SEPARATOR); - - } - - private String validateFormat(String intent) { - // TODO validate and canonicalize intent name - return intent; - } - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/InteractionScope.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/InteractionScope.java deleted file mode 100644 index 4e15e353c6..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/InteractionScope.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.spi.model; - -/** - * Represents the interaction scope specifed for a service - * - * @version $Rev$ $Date$ - */ -public enum InteractionScope { - CONVERSATIONAL, - NONCONVERSATIONAL -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ModelObject.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ModelObject.java deleted file mode 100644 index 2d5a0802e6..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ModelObject.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.spi.model; - -import java.util.HashMap; -import java.util.Map; - -/** - * The base class for assembly model subtypes - * - * @version $Rev$ $Date$ - */ -public abstract class ModelObject { - private final Map extensions = new HashMap(); - - protected ModelObject() { - } - - public Map getExtensions() { - return extensions; - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Multiplicity.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Multiplicity.java deleted file mode 100644 index f7ec8759f8..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Multiplicity.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.spi.model; - -/** - * Enumeration for multiplicity. - */ -public enum Multiplicity { - /** - * Indicates a relationship that is optionally connected to the requestor and which, if supplied, must be connected - * to exactly one provider. - */ - ZERO_ONE, - - /** - * Indicates a relationship that must be connected between exactly one requestor and exactly one provider. - */ - ONE_ONE, - - /** - * Indicates a relationship that is optionally connects the requestor to zero to unbounded providers. - */ - ZERO_N, - - /** - * Indicates a relationship that must be connected at the requestor and which connects it to zero to unbounded - * providers. - */ - ONE_N - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Operation.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Operation.java deleted file mode 100644 index 3de0327a20..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Operation.java +++ /dev/null @@ -1,408 +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.spi.model; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * Represents an operation that is part of a service contract. The type paramter of this operation identifies the - * logical type system for all data types. - * - * @version $Rev$ $Date$ - */ -public class Operation extends ModelObject implements Cloneable { - public static final int NO_CONVERSATION = -1; - public static final int CONVERSATION_CONTINUE = 1; - public static final int CONVERSATION_END = 2; - - protected Map metaData; - private final String name; - private ServiceContract contract; - private final DataType outputType; - private final DataType>> inputType; - private final List> faultTypes; - private String dataBinding; - private boolean wrapperStyle; - private WrapperInfo wrapper; - private boolean callback; - private boolean nonBlocking; - private int conversationSequence = NO_CONVERSATION; - - /** - * Construct a minimally-specified operation - * - * @param name the name of the operation - * @param inputType the data types of parameters passed to the operation - * @param outputType the data type returned by the operation - * @param faultTypes the data type of faults raised by the operation - */ - public Operation(String name, - DataType>> inputType, - DataType outputType, - List> faultTypes) { - this(name, inputType, outputType, faultTypes, false, null, NO_CONVERSATION); - } - - /** - * Construct an operation - * - * @param name the name of the operation - * @param inputType the data types of parameters passed to the operation - * @param outputType the data type returned by the operation - * @param faultTypes the data type of faults raised by the operation - * @param nonBlocking if the operation is non-blocking - * @param dataBinding the data-binding type required by the operation - * @param sequence the conversational attributes of the operation, {@link NO_CONVERSATION}, {@link - * CONVERSATION_CONTINUE}, or {@link CONVERSATION_END} - */ - public Operation(final String name, - final DataType>> inputType, - final DataType outputType, - final List> faultTypes, - boolean nonBlocking, - String dataBinding, - int sequence) { - super(); - this.name = name; - List> types = Collections.emptyList(); - this.inputType = (inputType != null) ? inputType : new DataType>>(Object[].class, types); - this.outputType = (outputType != null) ? outputType : new DataType(void.class, null); - this.faultTypes = (faultTypes == null) ? types : faultTypes; - this.nonBlocking = nonBlocking; - this.dataBinding = dataBinding; - this.conversationSequence = sequence; - // Register the operation with the types - this.inputType.setOperation(this); - for (DataType d : this.inputType.getLogical()) { - d.setOperation(this); - } - this.outputType.setOperation(this); - for (DataType d : this.faultTypes) { - d.setOperation(this); - } - } - - /** - * Returns the service contract the operation is part of. - * - * @return the service contract the operation is part of. - */ - public ServiceContract getServiceContract() { - return contract; - } - - /** - * Sets the service contract the operation is part of. - * - * @param contract the service contract the operation is part of. - */ - public void setServiceContract(ServiceContract contract) { - this.contract = contract; - } - - /** - * Returns true if the operation is part of the callback contract. - * - * @return true if the operation is part of the callback contract. - */ - public boolean isCallback() { - return callback; - } - - /** - * Sets whether the operation is part of the callback contract. - * - * @param callback whether the operation is part of the callback contract. - */ - public void setCallback(boolean callback) { - this.callback = callback; - } - - /** - * Returns the name of the operation. - * - * @return the name of the operation - */ - public String getName() { - return name; - } - - /** - * Returns the data type returned by the operation. - * - * @return the data type returned by the operation - */ - public DataType getOutputType() { - return outputType; - } - - /** - * Returns the data types of the parameters passed to the operation. - *

      - * The inputType's logical type is a list of DataTypes which describes the parameter types - * - * @return the data types of the parameters passed to the operation - */ - public DataType>> getInputType() { - return inputType; - } - - /** - * Returns the data types of the faults raised by the operation. - * - * @return the data types of the faults raised by the operation - */ - public List> getFaultTypes() { - if (faultTypes == null) { - return Collections.emptyList(); - } - return faultTypes; - } - - /** - * Returns true if the operation is non-blocking. A non-blocking operation may not have completed execution at the - * time an invocation of the operation returns. - * - * @return true if the operation is non-blocking - */ - public boolean isNonBlocking() { - return nonBlocking; - } - - /** - * Sets if the operation is non-blocking - */ - public void setNonBlocking(boolean nonBlocking) { - this.nonBlocking = nonBlocking; - } - - /** - * Returns the sequence the operation is called in a conversation, {@link NO_CONVERSATION}, {@link - * CONVERSATION_CONTINUE}, or {@link CONVERSATION_END} - * - * @return the sequence the operation is called in a conversation - */ - public int getConversationSequence() { - return conversationSequence; - } - - /** - * Sets the sequence the operation is called in a conversation, {@link NO_CONVERSATION}, {@link - * CONVERSATION_CONTINUE}, or {@link CONVERSATION_END} - */ - public void setConversationSequence(int conversationSequence) { - this.conversationSequence = conversationSequence; - } - - /** - * Returns the data binding type specified for the operation or null. - * - * @return the data binding type specified for the operation or null. - */ - public String getDataBinding() { - return (dataBinding == null && contract != null) ? contract.getDataBinding() : dataBinding; - } - - /** - * Set the databinding for this operation - * - * @param dataBinding The databinding - */ - public void setDataBinding(String dataBinding) { - this.dataBinding = dataBinding; - } - - /** - * Returns a map of metadata key to value mappings for the operation. - * - * @return a map of metadata key to value mappings for the operation. - */ - public Map getMetaData() { - if (metaData == null) { - return Collections.emptyMap(); - } - return metaData; - } - - /** - * Adds metadata associated with the operation. - * - * @param key the metadata key - * @param val the metadata value - */ - public void setMetaData(String key, Object val) { - if (metaData == null) { - metaData = new HashMap(); - } - metaData.put(key, val); - } - - public String toString() { - return name; - } - - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - - final Operation operation = (Operation) o; - - if (name != null ? !name.equals(operation.name) : operation.name != null) { - return false; - } - - // HACK: If the operation is mappable, then the equality test is relaxed - if (isMappable()) { - return true; - } - - if (faultTypes == null && operation.faultTypes != null) { - return false; - } else if (faultTypes != null - && operation.faultTypes != null - && faultTypes.size() != 0 - && operation.faultTypes.size() != 0) { - if (faultTypes.size() < operation.faultTypes.size()) { - return false; - } else { - //noinspection ForLoopReplaceableByForEach - for (int i = 0; i < operation.faultTypes.size(); i++) { - if (!faultTypes.get(i).equals(operation.faultTypes.get(i))) { - return false; - } - } - } - } - - if (inputType != null ? !inputType.equals(operation.inputType) : operation.inputType != null) { - return false; - } - return !(outputType != null ? !outputType.equals(operation.outputType) : operation.outputType != null); - } - - public int hashCode() { - int result; - result = name != null ? name.hashCode() : 0; - // HACK: - if (isMappable()) { - return result; - } - result = 29 * result + (outputType != null ? outputType.hashCode() : 0); - result = 29 * result + (inputType != null ? inputType.hashCode() : 0); - result = 29 * result + (faultTypes != null ? faultTypes.hashCode() : 0); - return result; - } - - /** - * Returns true if the operation may be mapped to another target operation through an mediation - */ - private boolean isMappable() { - if (contract != null) { - return contract.isRemotable(); - } else { - return false; - } - } - - /** - * Returns true if the operation is wrapper style - * - * @return the wrapperStyle - */ - public boolean isWrapperStyle() { - return wrapperStyle; - } - - /** - * Return the Wrapper information for this operation is it's wrapper style - * - * @return The Wrapper - */ - public WrapperInfo getWrapper() { - if (!isWrapperStyle()) { - throw new IllegalStateException("The operation is not wrapper style."); - } else { - return wrapper; - } - } - - /** - * @param wrapper the wrapper to set - */ - public void setWrapper(WrapperInfo wrapper) { - this.wrapper = wrapper; - } - - /** - * @param wrapperStyle the wrapperStyle to set - */ - public void setWrapperStyle(boolean wrapperStyle) { - this.wrapperStyle = wrapperStyle; - } - - @SuppressWarnings({"unchecked", "CloneDoesntCallSuperClone"}) - @Override - public Operation clone() throws CloneNotSupportedException { - final List> clonedFaultTypes = new ArrayList>(this.faultTypes.size()); - for (DataType t : this.faultTypes) { - clonedFaultTypes.add((DataType) t.clone()); - } - - List> clonedTypes = new ArrayList>(); - for (DataType t : inputType.getLogical()) { - DataType type = (DataType) t.clone(); - clonedTypes.add(type); - } - - DataType>> clonedInputType = - new DataType>>(inputType.getPhysical(), clonedTypes); - clonedInputType.setDataBinding(inputType.getDataBinding()); - - DataType outputType = (DataType) this.outputType.clone(); - Operation copy = - new Operation(name, - clonedInputType, - outputType, - clonedFaultTypes, - nonBlocking, - dataBinding, - conversationSequence); - - copy.callback = this.callback; - copy.contract = this.contract; - copy.wrapper = this.wrapper; - copy.wrapperStyle = this.wrapperStyle; - - if (this.metaData != null) { - assert this.metaData instanceof HashMap; - copy.metaData = (HashMap) ((HashMap) this.metaData).clone(); - } - return copy; - } - - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/OverrideOptions.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/OverrideOptions.java deleted file mode 100644 index cc86b2670a..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/OverrideOptions.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.spi.model; - -/** - *

        - *
      • no – the value may not be overridden by the higher composite. In this - * case, a value must be provided for the reference or property as part of its - * declaration. - *
      • may – the value may be overridden by the composite. This is the default - * for references. - *
      • must – no value is specified and the using composite must specify one. - *
      - */ -public enum OverrideOptions { - NO, MAY, MUST -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/PolicyAttachable.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/PolicyAttachable.java deleted file mode 100644 index eae425dca8..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/PolicyAttachable.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.apache.tuscany.spi.model; - -import java.util.Collection; -/** -* -* Represents capability of being attached with Intent and PolicySet. -* -*/ -public interface PolicyAttachable { - /** - * Get the name of PolicySet attached - * @return the name of PolicySet - */ - String getPolicySet(); - /** - * Get collection contains IntentName required. - * @return collection contains IntentName required. - */ - Collection getRequiredIntents(); - -} \ No newline at end of file diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/PolicyAttachableModel.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/PolicyAttachableModel.java deleted file mode 100644 index 3ebbfb16d7..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/PolicyAttachableModel.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.spi.model; - -import java.util.Collection; - -/** - * Base class for model classes which can be associated with Intent and PolicySet by specifing requires and policySet - * attributes on xml element. - */ - -public abstract class PolicyAttachableModel extends ModelObject implements PolicyAttachable { - protected Collection requiredIntent; - protected String policySet; - - public String getPolicySet() { - return policySet; - } - - public void setPolicySet(String policySet) { - this.policySet = policySet; - } - - public Collection getRequiredIntents() { - return requiredIntent; - } - - public void addRequiredIntent(IntentName requiredIntent) { - this.requiredIntent.add(requiredIntent); - } - - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/PolicyContentModel.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/PolicyContentModel.java deleted file mode 100644 index 7d2412ee8d..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/PolicyContentModel.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.spi.model; - -import java.util.ArrayList; -import java.util.Collection; -import static java.util.Collections.unmodifiableCollection; - -/** - * PolicyModel which contains concrete policy content in form of WSPolicyAttachment or other extensions. - */ -public abstract class PolicyContentModel extends PolicyModel { - /* WSPolicyAttachment contained in this Model */ - protected Collection wsPolicyAttachments = new ArrayList(); - /* Any policy model extensions besides standard intentMap, ws-policyattachment, etc. */ - protected Collection extensions = new ArrayList(); - - public Collection getPolicyExtensions() { - return extensions; - } - - public Collection getWsPolicyAttachments() { - return unmodifiableCollection(wsPolicyAttachments); - } - - public void addWsPolicyAttachment(WSPolicyAttachment attachment) { - wsPolicyAttachments.add(attachment); - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/PolicyModel.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/PolicyModel.java deleted file mode 100644 index 17bd8f0b7e..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/PolicyModel.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.spi.model; - - -/** - * An abstract base class for all policy model representations. - *

      - * $Version$ $Date$ - */ -public abstract class PolicyModel extends ModelObject { - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/PolicySet.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/PolicySet.java deleted file mode 100644 index 7545f234e1..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/PolicySet.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.spi.model; - -import java.util.ArrayList; -import java.util.Collection; -import static java.util.Collections.unmodifiableCollection; -import static java.util.Collections.unmodifiableList; -import java.util.List; -import javax.xml.namespace.QName; - -/** - * Model representation for PolicySet. - *

      - * $Rev$ $Date$ - */ -public class PolicySet extends PolicyContentModel { - - /** - * QNames of artifacts to which this Policy can apply - */ - protected List appliedArtifacts = new ArrayList(); - - /** - * IntentMap contained in this PolicySet - */ - private Collection intentMaps = new ArrayList(); - - /** - * Name for PolicySet, corresponding to name attribute of PolicySet element in SCDL - */ - private QName name; - - /** - * References to other PolicySet - */ - private Collection policySetReferences = new ArrayList(); - - /** - * Name of intents provided by this PolicySet - */ - private Collection provideIntents = new ArrayList(); - - public PolicySet(QName name, List providesIntent) { - super(); - this.name = name; - this.provideIntents.addAll(providesIntent); - } - - - public void addPolicySetReference(PolicySetReference ref) { - policySetReferences.add(ref); - } - - public void addAppliedArtifacts(QName artifactName) { - appliedArtifacts.add(artifactName); - } - - public List getAppliedArtifacts() { - return unmodifiableList(appliedArtifacts); - } - - public void addIntentMap(IntentMap intentMap) { - intentMaps.add(intentMap); - } - - public Collection getIntentMaps() { - return unmodifiableCollection(intentMaps); - } - - public QName getName() { - return name; - } - - public Collection getPolicySetReferences() { - return unmodifiableCollection(policySetReferences); - } - - public Collection getProvideIntents() { - return unmodifiableCollection(provideIntents); - } - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/PolicySetReference.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/PolicySetReference.java deleted file mode 100644 index 46924910d0..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/PolicySetReference.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.spi.model; - -import javax.xml.namespace.QName; - -/** - * Presents a PolicySetReference. - */ -public class PolicySetReference extends PolicyModel { - - private QName reference; - - public PolicySetReference(QName reference) { - super(); - this.reference = reference; - } - - public QName getReference() { - return reference; - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Property.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Property.java deleted file mode 100644 index 700b099da7..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Property.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.spi.model; - -import javax.xml.namespace.QName; - -import org.w3c.dom.Document; - -import org.apache.tuscany.spi.ObjectFactory; - -/** - * A component property - * - * @version $Rev$ $Date$ - */ -public class Property extends ModelObject { - private String name; - private ObjectFactory defaultValueFactory; - private QName xmlType; - private Class javaType; - private boolean many; - private OverrideOptions override; - private Document defaultValue; - - public Property() { - } - - public Property(String name, QName xmlType, Class javaType) { - this.name = name; - this.xmlType = xmlType; - this.javaType = javaType; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public ObjectFactory getDefaultValueFactory() { - return defaultValueFactory; - } - - public void setDefaultValueFactory(ObjectFactory factory) { - this.defaultValueFactory = factory; - } - - public QName getXmlType() { - return xmlType; - } - - public void setXmlType(QName xmlType) { - this.xmlType = xmlType; - } - - public Class getJavaType() { - return javaType; - } - - public void setJavaType(Class javaType) { - this.javaType = javaType; - } - - public boolean isMany() { - return many; - } - - public void setMany(boolean many) { - this.many = many; - } - - public OverrideOptions getOverride() { - return override; - } - - public void setOverride(OverrideOptions override) { - this.override = override; - } - - public Document getDefaultValue() { - return defaultValue; - } - - public void setDefaultValue(Document defaultValue) { - this.defaultValue = defaultValue; - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/PropertyValue.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/PropertyValue.java deleted file mode 100644 index 93eaa74f52..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/PropertyValue.java +++ /dev/null @@ -1,128 +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.spi.model; - -import org.apache.tuscany.spi.ObjectFactory; -import org.w3c.dom.Document; - -/** - * Represents a configured component property - * - * @version $Rev$ $Date$ - */ -public class PropertyValue extends ModelObject { - private String name; - private String source; - private String file; - private Document value; - private ObjectFactory valueFactory; - - public PropertyValue() { - } - - /** - * Constructor specifying the name of a property and the XPath source expression. - * - * @param name the name of the property which this value is for - * @param source an XPath expression whose result will be the actual value - * @param file A URI that the property value can be loaded from - */ - public PropertyValue(String name, String source, String file) { - this.name = name; - this.source = source; - this.file = file; - } - - /** - * @param name - * @param value - */ - public PropertyValue(String name, Document value) { - this.name = name; - this.value = value; - } - - public PropertyValue(String name, ObjectFactory valueFactory) { - this.name = name; - this.valueFactory = valueFactory; - } - - /** - * Returns the name of the property that this value is for. - * @return the name of the property that this value is for - */ - public String getName() { - return name; - } - - /** - * Sets the name of the property that this value is for. - * @param name the name of the property that this value is for - */ - public void setName(String name) { - this.name = name; - } - - /** - * Returns an XPath expression that should be evaluated to get the actual property value. - * - * @return an XPath expression that should be evaluated to get the actual property value - */ - public String getSource() { - return source; - } - - /** - * Sets an XPath expression that should be evaluated to get the actual property value. - * @param source an XPath expression that should be evaluated to get the actual property value - */ - public void setSource(String source) { - this.source = source; - } - - public ObjectFactory getValueFactory() { - return valueFactory; - } - - public void setValueFactory(ObjectFactory valueFactory) { - this.valueFactory = valueFactory; - } - - public Document getValue() { - return value; - } - - public void setValue(Document value) { - this.value = value; - } - - /** - * @return the file - */ - public String getFile() { - return file; - } - - /** - * @param file the file to set - */ - public void setFile(String file) { - this.file = file; - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Qualifier.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Qualifier.java deleted file mode 100644 index 8a7d709bd9..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Qualifier.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.spi.model; - -/** - * Model reprentation for qualifier - */ - -public class Qualifier extends PolicyContentModel { - - private String name; - - /** - * IntentMap contained in this Qualifier - */ - private IntentMap intentMap; - - public Qualifier(String name) { - super(); - this.name = name; - } - - public String getName() { - return name; - } - - public IntentMap getIntentMap() { - return intentMap; - } - - public void setIntentMap(IntentMap intentMap) { - this.intentMap = intentMap; - } - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ReferenceDefinition.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ReferenceDefinition.java deleted file mode 100644 index f167272705..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ReferenceDefinition.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.spi.model; - -/** - * Represents a component reference - * - * @version $Rev$ $Date$ - */ -public class ReferenceDefinition extends ModelObject { - private String name; - private ServiceContract serviceContract; - private Multiplicity multiplicity; - private boolean autowire; - private boolean required; - - public ReferenceDefinition() { - } - - public ReferenceDefinition(String name, ServiceContract serviceContract) { - this.name = name; - this.serviceContract = serviceContract; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public ServiceContract getServiceContract() { - return serviceContract; - } - - public void setServiceContract(ServiceContract serviceContract) { - this.serviceContract = serviceContract; - } - - public Multiplicity getMultiplicity() { - return multiplicity; - } - - public void setMultiplicity(Multiplicity multiplicity) { - this.multiplicity = multiplicity; - } - - public boolean isAutowire() { - return autowire; - } - - public void setAutowire(boolean autowire) { - this.autowire = autowire; - } - - public boolean isRequired() { - return required; - } - - public void setRequired(boolean required) { - this.required = required; - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ReferenceTarget.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ReferenceTarget.java deleted file mode 100644 index db0bdb2b22..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ReferenceTarget.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.spi.model; - -import java.net.URI; -import java.util.ArrayList; -import java.util.List; - -/** - * Represents the set of targets configured on a reference - * - * @version $Rev$ $Date$ - */ -public class ReferenceTarget extends ModelObject { - private String referenceName; - private List targets = new ArrayList(); - - public String getReferenceName() { - return referenceName; - } - - public void setReferenceName(String referenceName) { - this.referenceName = referenceName; - } - - public List getTargets() { - return targets; - } - - public void addTarget(URI target) { - targets.add(target); - } - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Scope.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Scope.java deleted file mode 100644 index a53b26d2ba..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Scope.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.spi.model; - -/** - * The default implementation scopes supported by assemblies. - * - * @version $Rev$ $Date$ - */ -public class Scope { - public static final Scope STATELESS = new Scope("STATELESS"); - public static final Scope REQUEST = new Scope("REQUEST"); - public static final Scope SESSION = new Scope("SESSION"); - public static final Scope CONVERSATION = new Scope("CONVERSATION"); - public static final Scope COMPOSITE = new Scope("COMPOSITE"); - public static final Scope SYSTEM = new Scope("SYSTEM"); - public static final Scope UNDEFINED = new Scope("UNDEFINED"); - - private String scope; - - public Scope(String scope) { - this.scope = scope.toUpperCase().intern(); - } - - public String getScope() { - return scope; - } - - @SuppressWarnings({"StringEquality"}) - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - final Scope scope1 = (Scope) o; - return !(scope != null ? scope != scope1.scope.intern() : scope1.scope != null); - } - - public int hashCode() { - return scope != null ? scope.hashCode() : 0; - } - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ServiceContract.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ServiceContract.java deleted file mode 100644 index b199de720c..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ServiceContract.java +++ /dev/null @@ -1,275 +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.spi.model; - -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -/** - * Base class representing service contract information - * - * @version $Rev$ $Date$ - */ -public abstract class ServiceContract extends ModelObject implements Cloneable { - protected InteractionScope interactionScope; - protected boolean remotable; - protected Class interfaceClass; - protected String interfaceName; - protected String callbackName; - protected Class callbackClass; - protected Map> operations; - protected Map> callbackOperations; - protected String dataBinding; - protected Map metaData; - - protected ServiceContract() { - } - - protected ServiceContract(Class interfaceClass) { - this.interfaceClass = interfaceClass; - } - - protected ServiceContract(String interfaceName) { - this.interfaceName = interfaceName; - } - - /** - * Returns the interface name for the contract - * - * @return the interface name for the contract - */ - public String getInterfaceName() { - return interfaceName; - } - - /** - * Sets the interface name for the contract - */ - public void setInterfaceName(String interfaceName) { - this.interfaceName = interfaceName; - } - - /** - * Returns the class used to represent the service contract - */ - public Class getInterfaceClass() { - return interfaceClass; - } - - /** - * Sets the class used to represent the service contract - */ - public void setInterfaceClass(Class interfaceClass) { - this.interfaceClass = interfaceClass; - } - - /** - * Returns the service interaction scope - */ - public InteractionScope getInteractionScope() { - return interactionScope; - } - - /** - * Sets the service interaction scope - */ - public void setInteractionScope(InteractionScope interactionScope) { - this.interactionScope = interactionScope; - } - - /** - * @return the remotable - */ - public boolean isRemotable() { - return remotable; - } - - /** - * @param remotable the remotable to set - */ - public void setRemotable(boolean remotable) { - this.remotable = remotable; - } - - /** - * Returns the name of the callback or null if the contract is unidirectional - */ - public String getCallbackName() { - return callbackName; - } - - /** - * Sets the name of the callback service - */ - public void setCallbackName(String callbackName) { - this.callbackName = callbackName; - } - - /** - * Returns the name of the callback service - */ - public Class getCallbackClass() { - return callbackClass; - } - - public void setCallbackClass(Class callbackClass) { - this.callbackClass = callbackClass; - } - - public Map> getOperations() { - if (operations == null) { - return Collections.emptyMap(); - } - return Collections.unmodifiableMap(operations); - } - - public void setOperations(Map> operations) { - for (Operation operation : operations.values()) { - operation.setServiceContract(this); - } - this.operations = operations; - } - - public Map> getCallbackOperations() { - if (callbackOperations == null) { - return Collections.emptyMap(); - } - return Collections.unmodifiableMap(callbackOperations); - } - - public void setCallbackOperations(Map> callbacksOperations) { - for (Operation operation : callbacksOperations.values()) { - operation.setServiceContract(this); - operation.setCallback(true); - } - this.callbackOperations = callbacksOperations; - } - - public String getDataBinding() { - return dataBinding; - } - - public void setDataBinding(String dataBinding) { - this.dataBinding = dataBinding; - } - - /** - * Returns a map of metadata key to value mappings for the operation. - * - * @return a map of metadata key to value mappings for the operation. - */ - public Map getMetaData() { - if (metaData == null) { - return Collections.emptyMap(); - } - return metaData; - } - - /** - * Adds metadata associated with the operation. - * - * @param key the metadata key - * @param val the metadata value - */ - public void setMetaData(String key, Object val) { - if (metaData == null) { - metaData = new HashMap(); - } - metaData.put(key, val); - } - - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - - final ServiceContract that = (ServiceContract) o; - - if (callbackName != null ? !callbackName.equals(that.callbackName) : that.callbackName != null) { - return false; - } - if (callbackOperations != null ? !callbackOperations.equals(that.callbackOperations) - : that.callbackOperations != null) { - return false; - } - if (interfaceClass != null ? !interfaceClass.equals(that.interfaceClass) : that.interfaceClass != null) { - return false; - } - if (interfaceName != null ? !interfaceName.equals(that.interfaceName) : that.interfaceName != null) { - return false; - } - return !(operations != null ? !operations.equals(that.operations) : that.operations != null); - - } - - public int hashCode() { - int result; - result = interfaceClass != null ? interfaceClass.hashCode() : 0; - result = 29 * result + (interfaceName != null ? interfaceName.hashCode() : 0); - result = 29 * result + (callbackName != null ? callbackName.hashCode() : 0); - result = 29 * result + (operations != null ? operations.hashCode() : 0); - result = 29 * result + (callbackOperations != null ? callbackOperations.hashCode() : 0); - return result; - } - - public String toString() { - if (interfaceName != null) { - return new StringBuilder().append("ServiceContract[").append(interfaceName).append("]").toString(); - } else if (interfaceClass != null) { - return new StringBuilder().append("ServiceContract[").append(interfaceClass.getName()).append("]") - .toString(); - } else { - return super.toString(); - } - - } - - @SuppressWarnings("unchecked") - @Override - public Object clone() throws CloneNotSupportedException { - ServiceContract copy = (ServiceContract) super.clone(); - - if (operations != null) { - Map> clonedOperations = new HashMap>(); - for (Operation o : operations.values()) { - clonedOperations.put(o.getName(), o); - } - copy.setOperations(clonedOperations); - } - - if (callbackOperations != null) { - Map> clonedCallbackOperations = new HashMap>(); - for (Operation o : callbackOperations.values()) { - clonedCallbackOperations.put(o.getName(), (Operation) o.clone()); - } - copy.setCallbackOperations(clonedCallbackOperations); - } - - if (this.metaData != null) { - assert this.metaData instanceof HashMap; - copy.metaData = (HashMap) ((HashMap) this.metaData).clone(); - } - - return copy; - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ServiceDefinition.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ServiceDefinition.java deleted file mode 100644 index aadcef8d4c..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ServiceDefinition.java +++ /dev/null @@ -1,87 +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.spi.model; - -/** - * Represents a service offered by a component - * - * @version $Rev$ $Date$ - */ -public class ServiceDefinition extends ModelObject { - private String name; - private ServiceContract serviceContract; - private boolean remotable; - private String callbackRefName; - - public ServiceDefinition() { - } - - public ServiceDefinition(String name, ServiceContract serviceContract, boolean remotable) { - this.name = name; - this.serviceContract = serviceContract; - this.remotable = remotable; - } - - public ServiceDefinition(String name, ServiceContract serviceContract, boolean remotable, String callbackRefName) { - this.name = name; - this.serviceContract = serviceContract; - this.remotable = remotable; - this.callbackRefName = callbackRefName; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public ServiceContract getServiceContract() { - return serviceContract; - } - - public void setServiceContract(ServiceContract serviceContract) { - this.serviceContract = serviceContract; - } - - public boolean isRemotable() { - return remotable; - } - - public void setRemotable(boolean remotable) { - this.remotable = remotable; - } - - /** - * Returns the callback name. - */ - public String getCallbackReferenceName() { - return callbackRefName; - } - - /** - * Sets the callback name - * @param name - */ - public void setCallbackReferenceName(String name) { - this.callbackRefName = name; - } - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/WSPolicyAttachment.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/WSPolicyAttachment.java deleted file mode 100644 index ff1a6cf791..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/WSPolicyAttachment.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.spi.model; - -/* - * Presents a ws-policy attachment. - */ -public class WSPolicyAttachment extends PolicyModel { - private T content; - - public T getContent() { - return content; - } - - public void setContent(T content) { - this.content = content; - } - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/WireDefinition.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/WireDefinition.java deleted file mode 100644 index 7ae91811b6..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/WireDefinition.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.spi.model; - -import java.net.URI; - -/** - * Represents a wire specified in an assembly - * - * @version $Rev$ $Date$ - */ -public class WireDefinition extends ModelObject { - private URI source; - private URI target; - - public URI getSource() { - return source; - } - - public void setSource(URI source) { - this.source = source; - } - - public URI getTarget() { - return target; - } - - public void setTarget(URI target) { - this.target = target; - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/WrapperInfo.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/WrapperInfo.java deleted file mode 100644 index 50209e045c..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/model/WrapperInfo.java +++ /dev/null @@ -1,111 +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.spi.model; - -import java.util.List; -import javax.xml.namespace.QName; - -import org.apache.tuscany.spi.idl.ElementInfo; - -/** - * The "Wrapper Style" WSDL operation is defined by The Java API for XML-Based Web Services (JAX-WS) 2.0 specification, - * section 2.3.1.2 Wrapper Style. - *

      - * A WSDL operation qualifies for wrapper style mapping only if the following criteria are met:

      • (i) The - * operation’s input and output messages (if present) each contain only a single part
      • (ii) The input message part - * refers to a global element declaration whose localname is equal to the operation name
      • (iii) The output message - * part refers to a global element declaration
      • (iv) The elements referred to by the input and output message parts - * (henceforth referred to as wrapper elements) are both complex types defined using the xsd:sequence compositor
      • (v) - * The wrapper elements only contain child elements, they must not contain other structures such as wildcards (element - * or attribute), xsd:choice, substitution groups (element references are not permitted) or attributes; furthermore, - * they must not be nillable.
      - * - * @version $Rev$ $Date$ - */ -public class WrapperInfo { - private ElementInfo inputWrapperElement; - - private ElementInfo outputWrapperElement; - - private List inputChildElements; - - private List outputChildElements; - - private DataType>> unwrappedInputType; - - private DataType unwrappedOutputType; - - public WrapperInfo(ElementInfo inputWrapperElement, - ElementInfo outputWrapperElement, - List inputElements, - List outputElements, - DataType>> unwrappedInputType, - DataType unwrappedOutputType) { - super(); - this.inputWrapperElement = inputWrapperElement; - this.outputWrapperElement = outputWrapperElement; - this.inputChildElements = inputElements; - this.outputChildElements = outputElements; - this.unwrappedInputType = unwrappedInputType; - this.unwrappedOutputType = unwrappedOutputType; - } - - /** - * @return the inputElements - */ - public List getInputChildElements() { - return inputChildElements; - } - - /** - * @return the inputWrapperElement - */ - public ElementInfo getInputWrapperElement() { - return inputWrapperElement; - } - - /** - * @return the outputElements - */ - public List getOutputChildElements() { - return outputChildElements; - } - - /** - * @return the outputWrapperElement - */ - public ElementInfo getOutputWrapperElement() { - return outputWrapperElement; - } - - /** - * @return the unwrappedInputType - */ - public DataType>> getUnwrappedInputType() { - return unwrappedInputType; - } - - /** - * @return the unwrappedOutputType - */ - public DataType getUnwrappedOutputType() { - return unwrappedOutputType; - } -} \ No newline at end of file diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/policy/IntentRegistry.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/policy/IntentRegistry.java deleted file mode 100644 index 8517977f0d..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/policy/IntentRegistry.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.spi.policy; - -import java.util.Collection; -import javax.xml.namespace.QName; - -import org.apache.tuscany.spi.model.Intent; -import org.apache.tuscany.spi.model.IntentName; - -/** - * The registry for intents. - * - * @version $Rev$ $Date$ - */ -public interface IntentRegistry { - - /** - * Register a intent. - * - * @param intent intent to register - */ - void register(Intent intent); - - /** - * Unregister a intent. - * - * @param intent intent to unregister - */ - void unRegister(Intent intent); - - /** - * Replace the profile intents in intentNameList with the real concrete intent. - * - * @param intentNameList intent list that may contains profile intents - * @param artifact QName of SCA artifact - * @return concrete intents list - */ - Collection inlineProfileIntent(Collection intentNameList, QName artifact); - - /** - * Whether the intent is appplicable for specified SCA artifact. - * - * @param intentName name of intent - * @param artifact QName of SCA artifact - * @return Whether the intent is appplicable for specified SCA artifact - */ - boolean isApplicable(IntentName intentName, QName artifact); - - /** - * Get a list including all qualified intents for a qulifiable intent. - * - * @param qualifiable qualifiable intent - * @param artifact QName of SCA artifact - * @return list including all qualified intents for a qulifiable intent. - */ - Collection getQualifiedIntents(IntentName qualifiable, QName artifact); - - /** - * Whether the intent is a qualified. - * - * @param name intent name. - * @return whether the intent is a qualified - */ - boolean isQualifiedIntent(IntentName name); - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/policy/PolicyBuilderRegistry.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/policy/PolicyBuilderRegistry.java deleted file mode 100644 index 2c85f846ac..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/policy/PolicyBuilderRegistry.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.spi.policy; - -import org.apache.tuscany.spi.builder.BuilderException; -import org.apache.tuscany.spi.model.ReferenceDefinition; -import org.apache.tuscany.spi.model.ServiceDefinition; -import org.apache.tuscany.spi.wire.InboundWire; -import org.apache.tuscany.spi.wire.OutboundWire; - -/** - * A registry for policy builders that dispatches to the appropriate builder when converting an assembly to runtime - * artifacts. Policy builders operate on either a source- or target-side wires. - * - * @version $Rev$ $Date$ - */ -public interface PolicyBuilderRegistry { - - int INITIAL = 0; - int EXTENSION = 1; - int FINAL = 2; - - /** - * Registers a target-side policy builder. Called by extensions to register their builders. - * - * @param phase the phase hwne the builder must be run - * @param builder the builder to register - */ - void registerTargetBuilder(int phase, TargetPolicyBuilder builder); - - /** - * Registers a source-side policy builder. Called by extensions to register their builders. - * - * @param phase the phase hwne the builder must be run - * @param builder the builder to register - */ - void registerSourceBuilder(int phase, SourcePolicyBuilder builder); - - /** - * Evaluates source-side policy metadata for referenceDefinition and updates the curresponding collection of wire - * configurations - * - * @throws BuilderException - */ - void buildSource(ReferenceDefinition referenceDefinition, OutboundWire wire) throws BuilderException; - - /** - * Evaluates target-side policy metadata for configured reference and updates the curresponding collection of wire - * configurations - * - * @throws BuilderException - */ - void buildTarget(ServiceDefinition serviceDefinition, InboundWire wire) throws BuilderException; -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/policy/PolicyEngine.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/policy/PolicyEngine.java deleted file mode 100644 index fd4ba129d5..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/policy/PolicyEngine.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.spi.policy; - -import java.util.Collection; -import javax.xml.namespace.QName; - -import org.apache.tuscany.spi.model.IntentName; -import org.apache.tuscany.spi.model.PolicyModel; - -/** - * Responsible for matching concrete policy artifacts required by abstract intent name. - */ -public interface PolicyEngine { - - /** - * Retrieve policies which match the intents requirement on a SCA artifact. See SCA policy frame spec. 1.4.5 Guided - * Selection of PolicySets using Intents - * - * @param requires Intent names requred by the SCA artifact - * @param policySetName PolicySet names specify on the SCA artifact explicitly - * @param artifactType QName of SCA artifact type, which may be a abstract artifact type - * @return Collection contains all policy matching the intent requirement - */ - Collection getPolicy(IntentName[] requires, QName[] policySetName, QName artifactType); -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/policy/PolicySetContainer.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/policy/PolicySetContainer.java deleted file mode 100644 index f7a9e0922a..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/policy/PolicySetContainer.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.spi.policy; - -import java.util.Collection; -import javax.xml.namespace.QName; - -import org.apache.tuscany.spi.model.PolicySet; - -/** - * The host for PolicySet. - */ -public interface PolicySetContainer { - - /** - * Get all PolicySet of this container - * - * @return Collection contains all PolicySet of this container - */ - Collection getAllPolicySet(); - - /** - * Get PolicySet by name. - * - * @param name QName of PolicySet. - * @return PolicySet with specified name - */ - PolicySet getPolicySet(QName name); - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/policy/SCATypeManager.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/policy/SCATypeManager.java deleted file mode 100644 index 3a5127f014..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/policy/SCATypeManager.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.spi.policy; - -import javax.xml.namespace.QName; - -public interface SCATypeManager { - - /** - * Whether the subType is a sub type of type or the type itself. - */ - boolean isTypeOf(QName subType, QName type); -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/policy/SourcePolicyBuilder.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/policy/SourcePolicyBuilder.java deleted file mode 100644 index b32f52c8ab..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/policy/SourcePolicyBuilder.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.spi.policy; - -import org.apache.tuscany.spi.builder.BuilderException; -import org.apache.tuscany.spi.model.ReferenceDefinition; -import org.apache.tuscany.spi.wire.OutboundWire; - -/** - * Implementations contribute {@link org.apache.tuscany.spi.wire.Interceptor}s to handle source-side policy on a wire. - * - * @version $$Rev$$ $$Date$$ - */ -public interface SourcePolicyBuilder { - - /** - * Callback for attaching policy to a source-side wire - * - * @param definition the service definition - * @param wire the wire to attach policy to - * @throws BuilderException - */ - void build(ReferenceDefinition definition, OutboundWire wire) throws BuilderException; - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/policy/SourcePolicyBuilderExtension.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/policy/SourcePolicyBuilderExtension.java deleted file mode 100644 index 2bb06add8f..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/policy/SourcePolicyBuilderExtension.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.spi.policy; - -import org.osoa.sca.annotations.EagerInit; -import org.osoa.sca.annotations.Init; -import org.osoa.sca.annotations.Property; - -import org.apache.tuscany.spi.annotation.Autowire; - -/** - * A runtime extension point for {@link SourcePolicyBuilder}s - * - * @version $Rev$ $Date$ - */ -@EagerInit -public abstract class SourcePolicyBuilderExtension implements SourcePolicyBuilder { - protected int phase = PolicyBuilderRegistry.EXTENSION; - private PolicyBuilderRegistry registry; - - @Autowire - public void setRegistry(PolicyBuilderRegistry registry) { - this.registry = registry; - } - - @Property - public void setPhase(int phase) { - this.phase = phase; - } - - @Init - public void init() { - registry.registerSourceBuilder(phase, this); - } - - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/policy/TargetPolicyBuilder.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/policy/TargetPolicyBuilder.java deleted file mode 100644 index c4b932fdd8..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/policy/TargetPolicyBuilder.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.spi.policy; - -import org.apache.tuscany.spi.builder.BuilderException; -import org.apache.tuscany.spi.model.ServiceDefinition; -import org.apache.tuscany.spi.wire.InboundWire; - -/** - * Implementations contribute {@link org.apache.tuscany.spi.wire.Interceptor}s to handle target-side policy on a wire. - * - * @version $$Rev$$ $$Date$$ - */ -public interface TargetPolicyBuilder { - - /** - * Callback for attaching policy to a target-side wire - * - * @param definition the service definition - * @param wire the wire to attach policy to - * @throws BuilderException - */ - void build(ServiceDefinition definition, InboundWire wire) throws BuilderException; - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/policy/TargetPolicyBuilderExtension.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/policy/TargetPolicyBuilderExtension.java deleted file mode 100644 index babcce50e9..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/policy/TargetPolicyBuilderExtension.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.spi.policy; - -import org.osoa.sca.annotations.EagerInit; -import org.osoa.sca.annotations.Init; -import org.osoa.sca.annotations.Property; - -import org.apache.tuscany.spi.annotation.Autowire; - -/** - * A runtime extension point for {@link org.apache.tuscany.spi.policy.SourcePolicyBuilder}s - * - * @version $Rev$ $Date$ - */ -@EagerInit -public abstract class TargetPolicyBuilderExtension implements TargetPolicyBuilder { - protected int phase = PolicyBuilderRegistry.EXTENSION; - private PolicyBuilderRegistry registry; - - @Autowire - public void setRegistry(PolicyBuilderRegistry registry) { - this.registry = registry; - } - - @Property - public void setPhase(int phase) { - this.phase = phase; - } - - @Init - public void init() { - registry.registerTargetBuilder(phase, this); - } - - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/services/VoidService.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/services/VoidService.java deleted file mode 100644 index 777cfbd3e9..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/services/VoidService.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.spi.services; - -import org.osoa.sca.annotations.Service; - -/** - * Empty interface for a service component that has no operations. - * This can be used as a default service interface by components that - * do not wish the base class to be used as the interface as specified - * by the defaulting rules. - * - * @version $Rev$ $Date$ - */ -@Service -public interface VoidService { -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/services/artifact/Artifact.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/services/artifact/Artifact.java deleted file mode 100644 index 4da522d196..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/services/artifact/Artifact.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.spi.services.artifact; - -import java.net.URL; -import java.util.HashSet; -import java.util.Set; - -/** - * Description of some packaged artifact such as a JAR file or a Composite. - * - * @version $Rev$ $Date$ - */ -public class Artifact { - - /* Artifact group */ - private String group; - - /* Artifact name */ - private String name; - - /* Artifact version */ - private String version; - - /* Artifact classifier */ - private String classifier; - - /* Artifact type */ - private String type; - - /* Artifact url */ - private URL url; - - /* Transitive dependencies */ - private Set dependencies = new HashSet(); - - /** - * Adds a transitive dependency to the artifact. - * - * @param artifact Dependency to be added. - */ - public void addDependency(Artifact artifact) { - dependencies.add(artifact); - } - - /** - * Gets the URLs for all the transitive dependencies. - * - * @return Sets of URLs for all the transitive dependencies. - */ - public Set getUrls() { - - Set urls = new HashSet(); - - for (Artifact artifact : dependencies) { - urls.add(artifact.getUrl()); - } - urls.add(getUrl()); - - return urls; - - } - - /** - * Returns the name of a logical grouping to which this artifact belongs. For example, this might represent the - * original publisher of the artifact. - * - * @return the name of a logical grouping to which this artifact belongs - */ - public String getGroup() { - return group; - } - - /** - * Sets the name of a logical grouping to which this artifact belongs. - * - * @param group the name of a logical grouping to which this artifact belongs - */ - public void setGroup(String group) { - this.group = group; - } - - /** - * Returns the name of an artifact. - * - * @return the name of an artifact - */ - public String getName() { - return name; - } - - /** - * Sets the name of an artifact. - * - * @param name the name of an artifact - */ - public void setName(String name) { - this.name = name; - } - - /** - * Returns the version of an artifact. - * - * @return the version of an artifact - */ - public String getVersion() { - return version; - } - - /** - * Sets the version of an artifact. - * - * @param version the version of an artifact - */ - public void setVersion(String version) { - this.version = version; - } - - /** - * Returns a way of classifying an artifact. This can be used to distinguish variants of an artifact that provide - * the same function but which may have platform specific requirements. For example, it may contain the name of a - * hardware platform for artifacts that contain native code. - * - * @return a way of classifying an artifact - */ - public String getClassifier() { - return classifier; - } - - /** - * Sets a way of classifying an artifact - * - * @param classifier a way of classifying an artifact - */ - public void setClassifier(String classifier) { - this.classifier = classifier; - } - - /** - * Returns the type of artifact. - * - * @return the type of artifact - */ - public String getType() { - return type; - } - - /** - * Sets the type of artifact. - * - * @param type the type of artifact - */ - public void setType(String type) { - this.type = type; - } - - /** - * Returns a URL from which the artifact can be obtained. - * - * @return a URL from which the artifact can be obtained - */ - public URL getUrl() { - return url; - } - - /** - * Sets a URL from which the artifact can be obtained. - * - * @param url a URL from which the artifact can be obtained - */ - public void setUrl(URL url) { - this.url = url; - } - - - public String toString() { - StringBuilder buf = new StringBuilder(); - buf.append(group).append(':').append(name).append(':').append(version).append(':').append(type); - return buf.toString(); - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/services/artifact/ArtifactRepository.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/services/artifact/ArtifactRepository.java deleted file mode 100644 index b0f590e163..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/services/artifact/ArtifactRepository.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.spi.services.artifact; - -import java.util.Collection; - -/** - * Abstraction for a repository of SCA and other artifacts. - * - * @version $Rev$ $Date$ - */ -public interface ArtifactRepository { - /** - * Resolve an artifact. - * This ensures that the information associated with an artifact is fully populated; - * Specifically, after this operation the URL should contain a location where the artifact can be obtained. - * - * @param artifact the artifact to be resolved - */ - void resolve(Artifact artifact); - - /** - * Resolve a collection of Artifacts. - * - * @param artifacts a collection of artifacts to be resolved - * @see #resolve(Artifact) - */ - void resolve(Collection artifacts); -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/services/discovery/AbstractDiscoveryService.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/services/discovery/AbstractDiscoveryService.java deleted file mode 100644 index 6e309243f3..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/services/discovery/AbstractDiscoveryService.java +++ /dev/null @@ -1,128 +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.spi.services.discovery; - -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -import javax.xml.namespace.QName; - -import org.apache.tuscany.host.RuntimeInfo; -import org.apache.tuscany.spi.annotation.Autowire; -import org.osoa.sca.annotations.Destroy; -import org.osoa.sca.annotations.Init; - -/** - * Abstract implementation of the discovery service. - * - * @version $Revision$ $Date$ - * - */ -public abstract class AbstractDiscoveryService implements DiscoveryService { - - /** Runtime info. */ - private RuntimeInfo runtimeInfo; - - /** Listeners. */ - private Map listenerMap = new ConcurrentHashMap(); - - /** - * Registers a listener for async messages. - * - * @param meesageType Message type that can be handled by the listener. - * @param listener Recipient of the async message. - */ - public void registerListener(QName messageType, MessageListener listener) { - listenerMap.put(messageType, listener); - } - - /** - * Sets the runtime info for the runtime using the discovery service. - * - * @param runtimeInfo Runtime info for the runtime using the discovery service. - */ - @Autowire - public final void setRuntimeInfo(RuntimeInfo runtimeInfo) { - this.runtimeInfo = runtimeInfo; - } - - /** - * Starts the discovery service. - */ - @Init - public final void start() { - - onStart(); - - Runnable shutdownHook = new ShutdownHook(); - Runtime.getRuntime().addShutdownHook(new Thread(shutdownHook)); - - } - - /** - * Stops the discovery service. - */ - @Destroy - public final void stop() { - onStop(); - } - - /** - * Gets the runtime info for the runtime using the discovery service. - * - * @return Runtime info for the runtime using the discovery service. - */ - protected final RuntimeInfo getRuntimeInfo() { - return runtimeInfo; - } - - /** - * Returns the listener for the specified message type. - * - * @param messageType Message type for the incoming message. - * @return Listeners inteersted in the message type. - */ - public final MessageListener getListener(QName messageType) { - return listenerMap.get(messageType); - } - - /** - * Required to be overridden by sub-classes. - * - */ - protected abstract void onStart(); - - /** - * Required to be overridden by sub-classes. - * - */ - protected abstract void onStop(); - - /** - * Shutdown hook. - */ - private class ShutdownHook implements Runnable { - - public void run() { - stop(); - } - - } - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/services/discovery/DiscoveryService.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/services/discovery/DiscoveryService.java deleted file mode 100644 index b54dfc79b5..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/services/discovery/DiscoveryService.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.spi.services.discovery; - -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamReader; - -/** - * Defines the abstraction that allows runtimes participating - * in the domain to discover each other and broadcast liveness - * to the admin server that holds the domain's runtime physical - * model and the domain-wide assembly model.. - * - * @version $Revision$ $Date$ - * - */ -public interface DiscoveryService { - - /** - * Sends a message to the specified runtime. - * - * @param runtimeId Runtime id of recipient. - * @param content Message content. - */ - void sendMessage(String runtimeId, XMLStreamReader content); - - /** - * Registers a listener for async messages. - * - * @param messageType Message type that can be handled by the listener. - * @param listener Recipient of the async message. - */ - void registerListener(QName messageType, MessageListener listener); - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/services/discovery/MessageListener.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/services/discovery/MessageListener.java deleted file mode 100644 index ed354a01a9..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/services/discovery/MessageListener.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.spi.services.discovery; - -import javax.xml.stream.XMLStreamReader; - -/** - * Message listener for propogating callbacks. - * - * @version $Revision$ $Date$ - * - */ -public interface MessageListener { - - /** - * Callback for propogating async messages. - * @param content Message content. - */ - void onMessage(XMLStreamReader content); - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/services/management/TuscanyManagementService.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/services/management/TuscanyManagementService.java deleted file mode 100644 index 10c2215bf6..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/services/management/TuscanyManagementService.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.spi.services.management; - -import org.apache.tuscany.host.management.ManagementService; -import org.apache.tuscany.spi.component.Component; - -/** - * Interface for the management service abstraction. The implementaion - * could be based on a variety of technologies including JMX, WSDM, - * SNMP etc. - * - * @version $Revision$ $Date$ - */ -public interface TuscanyManagementService extends ManagementService { - - /** - * Registers a component for management. - * - * @param name Name of the component. - * @param component Component to be registered. - */ - void registerComponent(String name, Component component); -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/services/store/DuplicateRecordException.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/services/store/DuplicateRecordException.java deleted file mode 100644 index 1210d05f5a..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/services/store/DuplicateRecordException.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.spi.services.store; - -/** - * thrown when a record already exists during an insert operation - * - * @version $Rev$ $Date$ - */ -public class DuplicateRecordException extends StoreWriteException { - - public DuplicateRecordException(String owner, String identifier) { - super(null, owner, identifier); - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/services/store/RecoveryListener.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/services/store/RecoveryListener.java deleted file mode 100644 index 186d741c04..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/services/store/RecoveryListener.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.spi.services.store; - -import java.util.UUID; - -/** - * Implementations receive callback events during a store recovery operation - * - * @version $Rev$ $Date$ - */ -public interface RecoveryListener { - - /** - * Signals the start of a recovery - */ - void onBegin(); - - /** - * Received when a record is recovered - * - * @param id - */ - void onRecord(UUID id); - - /** - * Signals the end of recovery - */ - void onEnd(); -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/services/store/Store.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/services/store/Store.java deleted file mode 100644 index 7a09f90811..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/services/store/Store.java +++ /dev/null @@ -1,96 +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.spi.services.store; - -import org.apache.tuscany.spi.component.SCAObject; -import org.apache.tuscany.spi.event.EventPublisher; - -/** - * Implementations provide a persistent store for runtime data such as conversational state. A persistent store could be - * implemented in a durable fashion using JDBC or a journaling system, or using a non-durable mechanism such as an - * in-memory map. - * - * @version $Rev$ $Date$ - */ -public interface Store extends EventPublisher { - - /* Used to indicate an the default expiration offset for records for the store */ - long DEFAULT_EXPIRATION_OFFSET = -1; - - /* Used to indicate an entry should not expire */ - long NEVER = -2; - - /** - * Adds the given record to the store. Implementations may choose different strategies for writing data such as - * write-through or write-behind. - * - * @param owner the instance owner - * @param id the unique id of the record - * @param object the object representing the data to write - * @param expiration the time in milliseconds when the entry expires - * @throws StoreWriteException if an error occurs during the write operation - */ - void insertRecord(SCAObject owner, String id, Object object, long expiration) throws StoreWriteException; - - /** - * Updates a given record in the store, overwriting previous information. - * - * @param owner the instance owner - * @param id the unique id of the record - * @param object the object representing the data to write - * @param expiration the time in milliseconds when the entry expires - * @throws StoreWriteException - */ - void updateRecord(SCAObject owner, String id, Object object, long expiration) throws StoreWriteException; - - /** - * Returns the deserialized object in the store corresponding to the given id - * - * @param owner the instance owner - * @param id the unique id of the record - * @return the deserialized object or null if one is not found - * @throws StoreReadException - */ - Object readRecord(SCAObject owner, String id) throws StoreReadException; - - /** - * Removes a record from the store - * - * @param owner the instance owner - * @param id the unique id of the record - * @throws StoreWriteException - */ - void removeRecord(SCAObject owner, String id) throws StoreWriteException; - - /** - * Removes all records from the store - * - * @throws StoreWriteException - */ - void removeRecords() throws StoreWriteException; - - /** - * Initiates a recovery operation, for example during restart after a crash - * - * @param listener the listener to receive recovery callback events - * @throws StoreReadException - */ - void recover(RecoveryListener listener) throws StoreReadException; - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/services/store/StoreException.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/services/store/StoreException.java deleted file mode 100644 index 59f1797490..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/services/store/StoreException.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.spi.services.store; - -import org.apache.tuscany.api.TuscanyException; - -/** - * Represents a generic exception thrown by a Store - * - * @version $Rev$ $Date$ - */ -public class StoreException extends TuscanyException { - private final String owner; - - public StoreException(String message, String owner, String identifier) { - super(message, identifier); - this.owner = owner; - } - - public StoreException(String message, String owner, String identifier, Throwable cause) { - super(message, identifier, cause); - this.owner = owner; - } - - public StoreException(String message, String owner, Throwable cause) { - super(message, cause); - this.owner = owner; - } - - public StoreException(Throwable cause) { - super(cause); - owner = null; - } - - public String getOwner() { - return owner; - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/services/store/StoreExpirationEvent.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/services/store/StoreExpirationEvent.java deleted file mode 100644 index fbb38dd362..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/services/store/StoreExpirationEvent.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.spi.services.store; - -import org.apache.tuscany.spi.component.SCAObject; -import org.apache.tuscany.spi.event.Event; - -/** - * Fired when a store implementation expires a resource - * - * @version $Rev$ $Date$ - */ -public class StoreExpirationEvent implements Event { - private Object source; - private SCAObject owner; - private Object instance; - - /** - * Constructor. - * - * @param source the source of the event - * @param owner the owner of the expiring object - * @param instance the expiring object - */ - public StoreExpirationEvent(Object source, SCAObject owner, Object instance) { - assert source != null; - assert owner != null; - assert instance != null; - this.source = source; - this.owner = owner; - this.instance = instance; - } - - public Object getSource() { - return source; - } - - /** - * Returns the owner of the expiring object. - * - * @return the owner of the expiring object. - */ - public SCAObject getOwner() { - return owner; - } - - /** - * Returns the expiring object. - * - * @return the expiring object. - */ - public Object getInstance() { - return instance; - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/services/store/StoreMonitor.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/services/store/StoreMonitor.java deleted file mode 100644 index f3bbbf0b73..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/services/store/StoreMonitor.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.spi.services.store; - -import org.apache.tuscany.api.annotation.LogLevel; - -/** - * A generic monintor interface for services to log events - * - * @version $Rev$ $Date$ - */ -public interface StoreMonitor { - - /** - * Signals the service has started - * - * @param msg - */ - @LogLevel("DEBUG") - void start(String msg); - - /** - * Signals the service has been shutdown - * - * @param msg - */ - @LogLevel("DEBUG") - void stop(String msg); - - /** - * Fired when recovery is started - */ - @LogLevel("DEBUG") - void beginRecover(); - - /** - * Fired when recovery is completed - */ - @LogLevel("DEBUG") - void endRecover(); - - /** - * Fired when a record is processed during recovery - * - * @param recordId the id of the record being recovered - */ - @LogLevel("DEBUG") - void recover(Object recordId); - - /** - * Signals an error event - * - * @param e the error - */ - @LogLevel("ERROR") - void error(Throwable e); - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/services/store/StoreReadException.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/services/store/StoreReadException.java deleted file mode 100644 index 0f46ac6878..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/services/store/StoreReadException.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.spi.services.store; - -/** - * Thrown when an error occurs reading from persistent storage - * - * @version $Rev$ $Date$ - */ -public class StoreReadException extends StoreException { - - public StoreReadException(Throwable cause) { - super(cause); - } - - public StoreReadException(String message, String owner, String identifier) { - super(message, owner, identifier); - } - - public StoreReadException(String owner, String identifier, Throwable throwable) { - super(owner, identifier, throwable); - } - - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/services/store/StoreWriteException.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/services/store/StoreWriteException.java deleted file mode 100644 index 9eef91db9a..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/services/store/StoreWriteException.java +++ /dev/null @@ -1,43 +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.spi.services.store; - -/** - * Thrown when an error occurs writing to persistent storage - * - * @version $Rev$ $Date$ - */ -public class StoreWriteException extends StoreException { - - public StoreWriteException(String message, String owner, String identifier) { - super(message, owner, identifier); - } - - public StoreWriteException(String message, String owner, String identifier, Throwable cause) { - super(message, owner, identifier, cause); - } - - public StoreWriteException(String message, String owner, Throwable cause) { - super(message, owner, cause); - } - - public StoreWriteException(Throwable cause) { - super(cause); - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/services/work/NotificationListener.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/services/work/NotificationListener.java deleted file mode 100644 index 9675cdce53..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/services/work/NotificationListener.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.spi.services.work; - -/** - * A callback inyterface that can be optionally used for registering - * interest in status of asynchronously scheduled unit of work. - * - */ -public interface NotificationListener { - - /** - * Callback method when the unit of work is accepted. - * - * @param work Work that was accepted. - */ - void workAccepted(T work); - - /** - * Callback method when the unit of work is successfully completed. - * - * @param work Work that was succesfully completed. - */ - void workCompleted(T work); - - /** - * Callback when the unit of work is started. - * - * @param work Unit of work that was started. - */ - void workStarted(T work); - - /** - * Callback when the unit of work is rejected. - * - * @param work Unit of work that was rejected. - */ - void workRejected(T work); - - /** - * Callnack when the unit of work fails to complete. - * - * @param work Unit of work that failed to complete. - * @param error Error that caused the unit of work to fail. - */ - void workFailed(T work, Throwable error); - - - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/services/work/WorkScheduler.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/services/work/WorkScheduler.java deleted file mode 100644 index 0824990c93..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/services/work/WorkScheduler.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.spi.services.work; - -/** - * Defines the contract for scheduling asychronous units of work. - * - *

      - * Units of work can be scheduled with an optional NotificationListener. - * If a notification listener is specified, the caller will be notified regarding the - * status of the work. The unit of work can either be completed, rejected or completed - * with an error. If the work completed with an error, the caller is notfied with the - * error details. - *

      - * - */ -public interface WorkScheduler { - - /** - * Schedules a unit of work for future execution. The notification listener - * is used to register interest in callbacks regarding the status of the work. - * - * @param work The unit of work that needs to be asynchronously executed. - * @param listener Notification listener for callbacks. - */ - void scheduleWork(T work, NotificationListener listener); - - /** - * Schedules a unit of work for future execution. The notification listener - * is used to register interest in callbacks regarding the status of the work. - * - * @param work The unit of work that needs to be asynchronously executed. - */ - void scheduleWork(T work); - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/services/work/WorkSchedulerException.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/services/work/WorkSchedulerException.java deleted file mode 100644 index 72dc8ee5d2..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/services/work/WorkSchedulerException.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.spi.services.work; - -/** - * Exception thrown by the work scheduler in case of unexpected exceptions. - * - */ -public class WorkSchedulerException extends RuntimeException { - - /** - * Wraps the root cause. - * - * @param cause Root cause for the exception. - */ - public WorkSchedulerException(Throwable cause) { - super(cause); - } - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/util/SCAObjectInputStream.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/util/SCAObjectInputStream.java deleted file mode 100644 index cf495d7f18..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/util/SCAObjectInputStream.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.spi.util; - -import java.io.IOException; -import java.io.InputStream; -import java.io.ObjectInputStream; -import java.io.ObjectStreamClass; - -import org.apache.tuscany.spi.component.SCAExternalizable; -import org.apache.tuscany.spi.component.WorkContext; - -/** - * Deserializes an object based on the thread context classloader and provides special handling for {@link - * SCAExternalizable} - * - * @version $Rev$ $Date$ - */ -public class SCAObjectInputStream extends ObjectInputStream { - private final ClassLoader classLoader; - private WorkContext context; - - public SCAObjectInputStream(InputStream in, WorkContext context) throws IOException, SecurityException { - super(in); - this.context = context; - this.classLoader = Thread.currentThread().getContextClassLoader(); - enableResolveObject(true); - } - - protected Class resolveClass(ObjectStreamClass streamClass) throws IOException, ClassNotFoundException { - return classLoader.loadClass(streamClass.getName()); - } - - protected Object resolveObject(Object obj) throws IOException { - if (obj instanceof SCAExternalizable) { - SCAExternalizable ext = (SCAExternalizable) obj; - ext.setWorkContext(context); - ext.reactivate(); - } - return obj; - } - - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/AbstractInboundInvocationHandler.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/AbstractInboundInvocationHandler.java deleted file mode 100644 index 77bc189bb2..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/AbstractInboundInvocationHandler.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.spi.wire; - -/** - * Base class for dispatching an invocation through an {@link InboundInvocationChain} - * - * @version $Rev$ $Date$ - */ -public abstract class AbstractInboundInvocationHandler { - - /** - * Dispatches a client request made on a proxy - */ - public Object invoke(InboundInvocationChain chain, TargetInvoker invoker, Object[] args) throws Throwable { - Interceptor headInterceptor = chain.getHeadInterceptor(); - if (headInterceptor == null) { - // short-circuit the dispatch and invoke the target directly - if (chain.getTargetInvoker() == null) { - throw new AssertionError("No target invoker [" + chain.getOperation().getName() + "]"); - } - return chain.getTargetInvoker().invokeTarget(args, TargetInvoker.NONE); - } else { - Message msg = new MessageImpl(); - msg.setTargetInvoker(invoker); - msg.setBody(args); - Message resp; - // dispatch the wire down the chain and get the response - resp = headInterceptor.invoke(msg); - Object body = resp.getBody(); - if (resp.isFault()) { - throw (Throwable) body; - } - return body; - } - } - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/AbstractOutboundInvocationHandler.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/AbstractOutboundInvocationHandler.java deleted file mode 100644 index 2ac99e2a60..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/AbstractOutboundInvocationHandler.java +++ /dev/null @@ -1,104 +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.spi.wire; - -import java.lang.reflect.InvocationTargetException; -import java.util.LinkedList; - -import org.apache.tuscany.spi.model.InteractionScope; -import org.apache.tuscany.spi.model.Operation; -import org.apache.tuscany.spi.model.ServiceContract; - -/** - * Base class for performing invocations on an outbound chain. Subclasses are responsible for retrieving and supplying - * the appropriate chain, target invoker and invocation arguments. - * - * @version $Rev$ $Date$ - */ -public abstract class AbstractOutboundInvocationHandler { - private boolean conversationStarted; - - protected Object invoke(OutboundInvocationChain chain, - TargetInvoker invoker, - Object[] args, - Object correlationId, - LinkedList callbackRoutingChain) - throws Throwable { - Interceptor headInterceptor = chain.getHeadInterceptor(); - if (headInterceptor == null) { - try { - // short-circuit the dispatch and invoke the target directly - TargetInvoker targetInvoker = chain.getTargetInvoker(); - if (targetInvoker == null) { - String name = chain.getOperation().getName(); - throw new AssertionError("No target invoker [" + name + "]"); - } - return targetInvoker.invokeTarget(args, TargetInvoker.NONE); - } catch (InvocationTargetException e) { - // the cause was thrown by the target so throw it - throw e.getCause(); - } - } else { - Message msg = new MessageImpl(); - msg.setTargetInvoker(invoker); - Object fromAddress = getFromAddress(); - if (fromAddress != null && callbackRoutingChain != null) { - throw new AssertionError("Can't use both a from address and callback routing chain"); - } - if (fromAddress != null) { - msg.pushFromAddress(fromAddress); - } - if (correlationId != null) { - msg.setCorrelationId(correlationId); - } - if (callbackRoutingChain != null) { - msg.setCallbackRoutingChain(callbackRoutingChain); - } - Operation operation = chain.getOperation(); - ServiceContract contract = operation.getServiceContract(); - if (InteractionScope.CONVERSATIONAL.equals(contract.getInteractionScope())) { - int sequence = chain.getOperation().getConversationSequence(); - if (sequence == Operation.CONVERSATION_END) { - msg.setConversationSequence(TargetInvoker.END); - conversationStarted = false; - } else if (sequence == Operation.CONVERSATION_CONTINUE) { - if (conversationStarted) { - msg.setConversationSequence(TargetInvoker.CONTINUE); - } else { - conversationStarted = true; - msg.setConversationSequence(TargetInvoker.START); - } - } - } - msg.setBody(args); - // dispatch the wire down the chain and get the response - Message resp = headInterceptor.invoke(msg); - Object body = resp.getBody(); - if (resp.isFault()) { - throw (Throwable) body; - } - return body; - } - } - - protected Object getFromAddress() { - // Default to null, only needed in outbound (forward) direction - return null; - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/InboundInvocationChain.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/InboundInvocationChain.java deleted file mode 100644 index d557fb84a3..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/InboundInvocationChain.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.spi.wire; - -/** - * A set of interceptors associated with the inbound side of a wire for an operation. - * - * @version $$Rev$$ $$Date$$ - */ -public interface InboundInvocationChain extends InvocationChain { - - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/InboundWire.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/InboundWire.java deleted file mode 100644 index ef7e3e2980..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/InboundWire.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.spi.wire; - -import java.util.Map; - -import org.apache.tuscany.spi.model.Operation; - -/** - * Implementations are responsible for managing the inbound side of a wire, including the invocation chains associated - * with each service operation. - * - * @version $$Rev$$ $$Date$$ - */ -public interface InboundWire extends Wire { - - /** - * Returns the name of the target service of the wire - */ - String getServiceName(); - - /** - * Sets the name of the target service of the wire - */ - void setServiceName(String name); - - /** - * Returns the invocation chain for each operation on a service specified by a reference or a target - * service. - */ - Map, InboundInvocationChain> getInvocationChains(); - - /** - * Adds the collection of invocation chains keyed by operation - */ - void addInvocationChains(Map, InboundInvocationChain> chains); - - /** - * Adds the invocation chain associated with the given operation - */ - void addInvocationChain(Operation operation, InboundInvocationChain chain); - - /** - * Returns the callback invocation configuration for each operation on a service specified by a reference or a - * target service. - */ - Map, OutboundInvocationChain> getSourceCallbackInvocationChains(Object targetAddr); - - /** - * Adds the collection of callback invocation chains keyed by operation for a given target addr - */ - void addSourceCallbackInvocationChains(Object targetAddr, Map, OutboundInvocationChain> chains); - - /** - * Adds the callback invocation chain associated with the given operation for a given target addr - */ - void addSourceCallbackInvocationChain(Object targetAddr, Operation operation, OutboundInvocationChain chain); - - /** - * Returns the name of the callback associated with the service of the wire - */ - String getCallbackReferenceName(); - - /** - * Sets the name of the callback associated with the service of the wire - */ - void setCallbackReferenceName(String callbackReferenceName); - - /** - * Set when a wire can be optimized; that is when no handlers or interceptors exist on either end - */ - void setTargetWire(OutboundWire wire); -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/IncompatibleServiceContractException.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/IncompatibleServiceContractException.java deleted file mode 100644 index 114df5a55c..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/IncompatibleServiceContractException.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.spi.wire; - -import org.apache.tuscany.spi.model.Operation; -import org.apache.tuscany.spi.model.ServiceContract; - -import org.apache.tuscany.api.TuscanyException; - -/** - * Denotes imcompatible service contracts for a wire - * - * @version $Rev$ $Date$ - */ -public class IncompatibleServiceContractException extends TuscanyException { - private static final long serialVersionUID = 5127478601823295587L; - private final ServiceContract source; - private final ServiceContract target; - private final Operation sourceOperation; - private final Operation targetOperation; - - public IncompatibleServiceContractException(String message, ServiceContract source, ServiceContract target) { - super(message, (String) null); - this.source = source; - this.target = target; - this.sourceOperation = null; - this.targetOperation = null; - } - - - public IncompatibleServiceContractException(String message, - ServiceContract source, - ServiceContract target, - Operation sourceOperation, Operation targetOperation) { - super(message, (String) null); - this.source = source; - this.target = target; - this.sourceOperation = sourceOperation; - this.targetOperation = targetOperation; - } - - public ServiceContract getTarget() { - return target; - } - - public ServiceContract getSource() { - return source; - } - - public Operation getSourceOperation() { - return sourceOperation; - } - - public Operation getTargetOperation() { - return targetOperation; - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/Interceptor.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/Interceptor.java deleted file mode 100644 index ad38ed1cf1..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/Interceptor.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.spi.wire; - -/** - * Synchronous, around-style mediation associated with a client- or target- side wire. - * - * @version $Rev$ $Date$ - */ -public interface Interceptor { - - /** - * Process a synchronous wire - * - * @param msg the request Message for the wire - * @return the response Message from the wire - */ - Message invoke(Message msg); - - /** - * Sets the next interceptor - */ - void setNext(Interceptor next); - - /** - * Returns the next interceptor or null - */ - Interceptor getNext(); - - /** - * Returns true if the interceptor can be optimized away from a wire - */ - boolean isOptimizable(); -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/InvocationChain.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/InvocationChain.java deleted file mode 100644 index 82e1a52adf..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/InvocationChain.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.spi.wire; - -import org.apache.tuscany.spi.model.Operation; - -/** - * An inbound or outbound invocation pipeline for a service operation. Wires consist of 1..n invocation chains - * associated with the operations of the service contract the wire represents. Invocation chains are associated with the - * outbound or inbound side of a wire are bridged or "connected" when an assembly is processed. Outbound chains are only - * connected to inbound chains and vice versa. - *

      - * Invocation chains contain at least one {@link Interceptor} that process invocations in an around-style manner. In - * some scenarios, a service proxy may only contain inbound invocation chains, for example, when a service is resolved - * through a locate operation by a non-component client. In this case, there will be no outbound invocation chains and - * the target invoker will be held by the target-side and passed down the pipeline. - *

      - * A {@link Message} is used to pass data associated with an invocation through the chain. Messages contain - * a {@link TargetInvoker} responsible for dispatching to a target instance and may be cached on the source-side. - * Caching allows various optimizations such as avoiding target instance resolution when the client-side lifecycle scope - * is a shorter duration than the target. - * - * @version $Rev$ $Date$ - */ -public interface InvocationChain { - /** - * Returns the target operation for this invocation chain - */ - Operation getOperation(); - - /** - * Sets the target invoker to pass down the chain - */ - void setTargetInvoker(TargetInvoker invoker); - - /** - * Returns the target invoker that is passed down the chain - */ - TargetInvoker getTargetInvoker(); - - /** - * Adds an interceptor to the chain - */ - void addInterceptor(Interceptor interceptor); - - /** - * Adds an interceptor at the given position in the interceptor stack - * - * @param index the position in the interceptor stack to add the interceptor - * @param interceptor the interceptor to add - */ - void addInterceptor(int index, Interceptor interceptor); - - /** - * Returns the first interceptor in the chain - */ - Interceptor getHeadInterceptor(); - - /** - * Returns the last interceptor in the chain - */ - Interceptor getTailInterceptor(); - - /** - * Sets the head interceptor of the bridged target-side chain - */ - void setTargetInterceptor(Interceptor interceptor); - - /** - * Returns the head interceptor of the birdged target-side chain - */ - Interceptor getTargetInterceptor(); - - /** - * Signals to the chain that its configuration is complete. Implementations may use this callback to prepare their - * invocation chains. - */ - void prepare(); -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/InvocationRuntimeException.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/InvocationRuntimeException.java deleted file mode 100644 index c2ba19c48a..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/InvocationRuntimeException.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.spi.wire; - -import org.osoa.sca.ServiceRuntimeException; - -/** - * Denotes a runtime exception thrown during an invocation over a wire - * - * @version $Rev$ $Date$ - */ -public class InvocationRuntimeException extends ServiceRuntimeException { - - public InvocationRuntimeException() { - super(); - } - - public InvocationRuntimeException(String message) { - super(message); - } - - public InvocationRuntimeException(String message, Throwable cause) { - super(message, cause); - } - - public InvocationRuntimeException(Throwable cause) { - super(cause); - } - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/Message.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/Message.java deleted file mode 100644 index e6fc43d889..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/Message.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.spi.wire; - -import java.util.LinkedList; - -/** - * Represents a request, response, or exception flowing through a wire - * - * @version $Rev $Date - */ -public interface Message { - - /** - * Returns the body of the message, which will be the payload or parameters associated with the wire - */ - Object getBody(); - - /** - * Sets the body of the message. - */ - void setBody(Object body); - - /** - * Sets the target invoker to dispatch to when the message passes through the request side of the invocation chain - */ - void setTargetInvoker(TargetInvoker invoker); - - /** - * Sets the target invoker to dispatch to when the message passes through the request side of the invocation chain - */ - TargetInvoker getTargetInvoker(); - - /** - * Returns the latest 'address' of the SCAObject where this message originated - */ - Object popFromAddress(); - - /** - * Adds the latest 'address' of the SCAObject where this message originated - */ - void pushFromAddress(Object fromAddress); - - /** - * Returns the chain of SCAObject addresses - */ - LinkedList getCallbackRoutingChain(); - - /** - * Sets the chain of SCAObject addresses - */ - void setCallbackRoutingChain(LinkedList fromAddresses); - - /** - * Returns the id of the message - */ - Object getMessageId(); - - /** - * Sets the id of the message - */ - void setMessageId(Object messageId); - - /** - * Returns the correlation id of the message - */ - Object getCorrelationId(); - - /** - * Sets the correlation id of the message - */ - void setCorrelationId(Object correlationId); - - /** - * Test if the message represents a fault/exception - * - * @return true if the message body is a fault object, false is the body is a normal payload - */ - boolean isFault(); - - /** - * Set the message body with a fault object. After this method is called, isFault() returns true. - * - * @param fault The fault object represents an exception - */ - void setBodyWithFault(Object fault); - - /** - * Returns the conversational sequence the message is associated with, {@link TargetInvoker.NONE}, {@link - * TargetInvoker.START}, {@link TargetInvoker.CONTINUE}, or {@link TargetInvoker.END} - * - * @return the conversational sequence the message is associated with - */ - short getConversationSequence(); - - /** - * Sets the conversational sequence the message is associated with, - * - * @param sequence {@link TargetInvoker.NONE}, {@link TargetInvoker.START}, {@link TargetInvoker.CONTINUE}, or - * {@link TargetInvoker.END} - */ - void setConversationSequence(short sequence); - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/MessageId.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/MessageId.java deleted file mode 100644 index f179eb79b1..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/MessageId.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.spi.wire; - -/** - * A unique identifier for a message flowing on a wire, potentially end-to-end (ie, through more than one SCAObject to - * SCAObject hop). - */ -public class MessageId { - - private long timestamp; - - public MessageId() { - this.timestamp = System.currentTimeMillis(); - } - - public long getTimestamp() { - return timestamp; - } - - public String toString() { - return "MsgId[" + timestamp + "]"; - } - - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - - final MessageId messageId = (MessageId) o; - return timestamp == messageId.timestamp; - } - - public int hashCode() { - return (int) (timestamp ^ (timestamp >>> 32)); - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/MessageImpl.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/MessageImpl.java deleted file mode 100644 index 728be85771..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/MessageImpl.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.spi.wire; - -import java.util.LinkedList; - -/** - * The default implementation of a message flowed through a wire during an invocation - * - * @version $Rev $Date - */ -public class MessageImpl implements Message { - private Object body; - private TargetInvoker invoker; - private LinkedList callbackRoutingChain; - private Object messageId; - private Object correlationId; - private boolean isFault; - private short conversationSequence; - - public MessageImpl() { - } - - public Object getBody() { - return body; - } - - public void setBody(Object body) { - this.isFault = false; - this.body = body; - } - - public void setTargetInvoker(TargetInvoker invoker) { - this.invoker = invoker; - } - - public TargetInvoker getTargetInvoker() { - return invoker; - } - - public Object popFromAddress() { - return callbackRoutingChain.removeFirst(); - } - - public void pushFromAddress(Object fromAddress) { - if (callbackRoutingChain == null) { - callbackRoutingChain = new LinkedList(); - } - callbackRoutingChain.addFirst(fromAddress); - } - - public LinkedList getCallbackRoutingChain() { - return callbackRoutingChain; - } - - public void setCallbackRoutingChain(LinkedList callbackRoutingChain) { - this.callbackRoutingChain = callbackRoutingChain; - } - - public Object getMessageId() { - return messageId; - } - - public void setMessageId(Object messageId) { - this.messageId = messageId; - } - - public Object getCorrelationId() { - return correlationId; - } - - public void setCorrelationId(Object correlationId) { - this.correlationId = correlationId; - } - - public boolean isFault() { - return isFault; - } - - public void setBodyWithFault(Object fault) { - this.isFault = true; - this.body = fault; - } - - public TargetInvoker getInvoker() { - return invoker; - } - - public void setInvoker(TargetInvoker invoker) { - this.invoker = invoker; - } - - public short getConversationSequence() { - return conversationSequence; - } - - public void setConversationSequence(short conversationSequence) { - this.conversationSequence = conversationSequence; - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/OutboundChainHolder.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/OutboundChainHolder.java deleted file mode 100644 index 7c20efeca8..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/OutboundChainHolder.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.apache.tuscany.spi.wire; - -/** - * A holder used to associate an wire chain with a local copy of a target invoker that was previously cloned from the - * chain master - * - * @version $Rev$ $Date$ - */ -public class OutboundChainHolder implements Cloneable { - OutboundInvocationChain chain; - TargetInvoker cachedInvoker; - - public OutboundChainHolder(OutboundInvocationChain config) { - this.chain = config; - } - - public OutboundInvocationChain getChain() { - return chain; - } - - public TargetInvoker getCachedInvoker() { - return cachedInvoker; - } - - public void setCachedInvoker(TargetInvoker invoker) { - this.cachedInvoker = invoker; - } - - @SuppressWarnings({"CloneDoesntDeclareCloneNotSupportedException"}) - @Override - public OutboundChainHolder clone() { - try { - return (OutboundChainHolder) super.clone(); - } catch (CloneNotSupportedException e) { - throw new AssertionError(); - } - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/OutboundInvocationChain.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/OutboundInvocationChain.java deleted file mode 100644 index b15678a4a8..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/OutboundInvocationChain.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.spi.wire; - -/** - * Responsible for flowing a request to a target service and invoking an operation. - * - * @version $$Rev$$ $$Date$$ - */ -public interface OutboundInvocationChain extends InvocationChain { - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/OutboundWire.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/OutboundWire.java deleted file mode 100644 index cf37fe84d7..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/OutboundWire.java +++ /dev/null @@ -1,106 +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.spi.wire; - -import java.util.Map; - -import org.apache.tuscany.spi.QualifiedName; -import org.apache.tuscany.spi.model.Operation; - -/** - * Implementations are responsible for managing the reference side of a wire, including the invocation chains associated - * with each service operation. An OutboundWire is connected to an {@link InboundWire} through their - * invocation chains. - * - * @version $$Rev$$ $$Date$$ - */ -public interface OutboundWire extends Wire { - - /** - * Returns the name of the source reference - */ - String getReferenceName(); - - /** - * Sets the name of the source reference - */ - void setReferenceName(String name); - - /** - * Returns the name of the target - */ - QualifiedName getTargetName(); - - /** - * Sets the name of the target - */ - void setTargetName(QualifiedName name); - - boolean isAutowire(); - - void setAutowire(boolean val); - - /** - * Sets the callback interface type generated proxies implement - */ - void setCallbackInterface(Class interfaze); - - /** - * Returns the callback interface type implemented by generated proxies - */ - Class getCallbackInterface(); - - /** - * Returns the invocation configuration for each operation on a service specified by a reference or a target - * service. - */ - Map, OutboundInvocationChain> getInvocationChains(); - - /** - * Adds the collection of invocation chains keyed by operation - */ - void addInvocationChains(Map, OutboundInvocationChain> chains); - - /** - * Adds the invocation chain associated with the given operation - */ - void addInvocationChain(Operation operation, OutboundInvocationChain chain); - - /** - * Returns the callback invocation configuration for each operation on a service specified by a reference or a - * target service. - */ - Map, InboundInvocationChain> getTargetCallbackInvocationChains(); - - /** - * Adds the collection of callback invocation chains keyed by operation - */ - void addTargetCallbackInvocationChains(Map, InboundInvocationChain> chains); - - /** - * Adds the callback invocation chain associated with the given operation - */ - void addTargetCallbackInvocationChain(Operation operation, InboundInvocationChain chain); - - /** - * Set when a wire can be optimized; that is when no handlers or interceptors exist on either end - */ - void setTargetWire(InboundWire wire); - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/ProxyCreationException.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/ProxyCreationException.java deleted file mode 100644 index 4805c75252..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/ProxyCreationException.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.spi.wire; - -import org.apache.tuscany.spi.CoreRuntimeException; - -/** - * Denotes an error creating a proxy - * - * @version $$Rev$$ $$Date$$ - */ -public class ProxyCreationException extends CoreRuntimeException { - public ProxyCreationException() { - } - - public ProxyCreationException(String message) { - super(message); - } - - public ProxyCreationException(String message, String identifier) { - super(message, identifier); - } - - public ProxyCreationException(String message, Throwable cause) { - super(message, cause); - } - - public ProxyCreationException(String message, String identifier, Throwable cause) { - super(message, identifier, cause); - } - - public ProxyCreationException(Throwable cause) { - super(cause); - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/TargetInvoker.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/TargetInvoker.java deleted file mode 100644 index b2d4648a2e..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/TargetInvoker.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.spi.wire; - -import java.lang.reflect.InvocationTargetException; - -/** - * Implementations are responsible for resolving a target and performing the actual invocation on it, for example, a - * component implementation instance or a service client. - * - * @version $Rev$ $Date$ - */ -public interface TargetInvoker extends Cloneable { - /* indicates that no conversational sequence is associated with the message */ - short NONE = 0; - /* indicates that the message initiates a conversation */ - short START = 1; - /* indicates that the message continues a conversation */ - short CONTINUE = 2; - /* indicates that the message ends a conversation */ - short END = 3; - - /** - * Invokes an operation on a target with the given payload. Used in optmized cases where messages do not need to be - * flowed such as in non-proxied wires. - * - * @param payload the invocation payload, typically an array of parameters - * @param sequence if the invocation is part of a conversation, the sequence. Valid values are {@link NONE} for - * non-conversational, {@link START} to begin a conversation, {@link CONTINUE} to continue a - * conversation, or {@link END} to end a conversation - * @throws InvocationTargetException - */ - Object invokeTarget(final Object payload, final short sequence) throws InvocationTargetException; - - /** - * Invokes an operation on a target with the given message - * - * @throws InvocationRuntimeException - */ - Message invoke(Message msg) throws InvocationRuntimeException; - - /** - * Determines whether the proxy can be cached on the client/source side - */ - boolean isCacheable(); - - /** - * Sets whether the target service instance may be cached by the invoker. This is a possible optimization when a - * wire is configured for a "down-scope" reference, i.e. a reference from a source of a shorter lifetime to a source - * of greater lifetime. - */ - void setCacheable(boolean cacheable); - - /** - * Determines if the target invoker can be discarded during wire optimization - */ - boolean isOptimizable(); - - /** - * Implementations must support deep cloning - */ - Object clone() throws CloneNotSupportedException; -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/Wire.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/Wire.java deleted file mode 100644 index bece953a6e..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/Wire.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.spi.wire; - -import javax.xml.namespace.QName; - -import org.apache.tuscany.spi.component.SCAObject; -import org.apache.tuscany.spi.component.TargetResolutionException; -import org.apache.tuscany.spi.model.ServiceContract; - -/** - * The base wire type used to connect references and serviceBindings - * - * @version $$Rev$$ $$Date$$ - */ -public interface Wire { - QName LOCAL_BINDING = new QName("http://tuscany.apache.org/xmlns/sca/binding/1.0", "binding.local"); - - QName getBindingType(); - - /** - * Returns the non-proxied target instance for this wire - */ - Object getTargetService() throws TargetResolutionException; - - /** - * Returns the service contract associated with the wire - * - * @return the service contract associated with the wire - */ - ServiceContract getServiceContract(); - - /** - * Sets the contract associated with the wire - * - * @param contract the contract associated with the wire - */ - void setServiceContract(ServiceContract contract); - - /** - * Adds an interface type generated proxies implement - */ - void addInterface(Class claz); - - /** - * Returns true if its invocation chains may be bypassed - */ - boolean isOptimizable(); - - /** - * Determines if the wire may be optimized - * - * @param optimizable true if the wire is optimizable - */ - void setOptimizable(boolean optimizable); - - /** - * Returns the SCAObject that contains this wire - */ - SCAObject getContainer(); - - /** - * Sets the name of the SCAObject that contains this wire - */ - void setContainer(SCAObject container); -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/WireInvocationHandler.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/WireInvocationHandler.java deleted file mode 100644 index 325f26ba91..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/WireInvocationHandler.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.spi.wire; - -import java.lang.reflect.Method; - -/** - * Implementations are responsible for dispatching an operation down an invocation chain - * - * @version $$Rev$$ $$Date$$ - */ -public interface WireInvocationHandler { - - Object invoke(Method method, Object[] args) throws Throwable; - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/WirePostProcessor.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/WirePostProcessor.java deleted file mode 100644 index c380d208d8..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/WirePostProcessor.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.spi.wire; - -/** - * Implementations are called after inbound and outbound wires are decorated with policy and before they are connected. - * - * @version $Rev$ $Date$ - */ -public interface WirePostProcessor { - - /** - * @param source - * @param target - */ - void process(OutboundWire source, InboundWire target); - - /** - * @param source - * @param target - */ - void process(InboundWire source, OutboundWire target); - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/WirePostProcessorExtension.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/WirePostProcessorExtension.java deleted file mode 100644 index 605a433590..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/WirePostProcessorExtension.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.spi.wire; - -import org.osoa.sca.annotations.EagerInit; -import org.osoa.sca.annotations.Init; -import org.osoa.sca.annotations.Scope; - -import org.apache.tuscany.spi.annotation.Autowire; - -/** - * @version $Rev$ $Date$ - */ -@Scope("COMPOSITE") -@EagerInit -public abstract class WirePostProcessorExtension implements WirePostProcessor { - protected WirePostProcessorRegistry registry; - - @Autowire - public void setRegistry(WirePostProcessorRegistry registry) { - this.registry = registry; - } - - @Init - public void init() { - registry.register(this); - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/WirePostProcessorRegistry.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/WirePostProcessorRegistry.java deleted file mode 100644 index f012d119c3..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/WirePostProcessorRegistry.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.spi.wire; - -/** - * Acts as a delegating WirePostProcessor, delegating post-processing of wires after policies have been - * applied and source an targets have been matched but before they are connected. - * - * @version $Rev$ $Date$ - */ -public interface WirePostProcessorRegistry extends WirePostProcessor { - - - /** - * Registers a post-processor in the runtime - * - * @param processor the processor to register - */ - void register(WirePostProcessor processor); - - /** - * De-registers a post-processor in the runtime - * - * @param processor the processor to de-register - */ - void unregister(WirePostProcessor processor); - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/WireService.java b/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/WireService.java deleted file mode 100644 index f913b9ed80..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/WireService.java +++ /dev/null @@ -1,157 +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.spi.wire; - -import java.lang.reflect.Method; -import java.util.Map; - -import org.apache.tuscany.spi.QualifiedName; -import org.apache.tuscany.spi.component.AtomicComponent; -import org.apache.tuscany.spi.component.ReferenceBinding; -import org.apache.tuscany.spi.component.ServiceBinding; -import org.apache.tuscany.spi.model.ComponentDefinition; -import org.apache.tuscany.spi.model.Operation; -import org.apache.tuscany.spi.model.ServiceContract; -import org.apache.tuscany.spi.model.ServiceDefinition; - -/** - * Creates proxies that implement Java interfaces and invocation handlers for fronting wires - * - * @version $$Rev$$ $$Date$$ - */ - -public interface WireService { - - /** - * Creates a Java proxy for the given wire - * - * @param interfaze the interface the proxy implements - * @param wire the wire to proxy @return the proxy - * @throws ProxyCreationException - */ - T createProxy(Class interfaze, Wire wire) throws ProxyCreationException; - - /** - * Creates a Java proxy for the given wire - * - * @param interfaze the interface the proxy implements - * @param wire the wire to proxy @return the proxy - * @param mapping the method to chain holder mapping to use in creating the proxy. Clients may cache and resuse - * this mapping for performance. - * @throws ProxyCreationException - */ - T createProxy(Class interfaze, Wire wire, Map mapping) - throws ProxyCreationException; - - /** - * Creates a Java proxy for the service contract callback - * - * @param interfaze the interface the proxy should implement - * @return the proxy - * @throws ProxyCreationException - */ - Object createCallbackProxy(Class interfaze, InboundWire wire) throws ProxyCreationException; - - /** - * Creates an {@link WireInvocationHandler} for the given wire - * - * @param interfaze the client side interface - * @param wire the wire to create the invocation handler for - * @return the invocation handler - */ - WireInvocationHandler createHandler(Class interfaze, Wire wire); - - /** - * Creates an outbound invocation chain for a given operation - * - * @param operation the operation to create the chain for - * @return the outbound invocation chain for a given operation - */ - OutboundInvocationChain createOutboundChain(Operation operation); - - /** - * Creates an inbound invocation chain for a given operation - * - * @param operation the operation to create the chain for - * @return the inbound invocation chain for a given operation - */ - InboundInvocationChain createInboundChain(Operation operation); - - /** - * Creates a wire for flowing inbound invocations to a service. The returned inbound chain will always contain at - * least one interceptor in order for outbound wires to connect to it. - * - * @param service the model representation of the service - * @return the wire for flowing inbound invocations to a service - */ - InboundWire createWire(ServiceDefinition service); - - /** - * Creates and injects wires for an atomic component - * - * @param component the component - * @param definition the model artifact representing the component - */ - void createWires(AtomicComponent component, ComponentDefinition definition); - - /** - * Creates and injects wires for a reference binding - * - * @param referenceBinding the reference - * @param contract the model artifact representing the service contract for the reference - * @param targetName the qualified target name or null if the reference referes to a target outside the SCA - * domain - */ - void createWires(ReferenceBinding referenceBinding, ServiceContract contract, QualifiedName targetName); - - /** - * Creates and injects wires for a service binding - * - * @param serviceBinding the serviceBinding - * @param contract the serviceBinding contract - * @param targetName the target nane - */ - void createWires(ServiceBinding serviceBinding, ServiceContract contract, String targetName); - - /** - * Check the compatiblity of the source and the target service contracts.

      A wire may only connect a source to a - * target if the target implements an interface that is compatible with the interface required by the source. The - * source and the target are compatible if: - *

      - *

      1. the source interface and the target interface MUST either both be remotable or they are both local - *
      2. the methods on the target interface MUST be the same as or be a superset of the methods in the interface - * specified on the source
      3. compatibility for the individual method is defined as compatibility of the signature, - * that is method name, input types, and output types MUST BE the same.
      4. the order of the input and output types - * also MUST BE the same.
      5. the set of Faults and Exceptions expected by the source MUST BE the same or be a - * superset of those specified by the service.
      6. other specified attributes of the two interfaces MUST match, - * including Scope and Callback interface
      - *

      - *

      Please note this test is not symetric: the success of checkCompatibility(A, B) does NOT imply that - * checkCompatibility(B, A) - * - * @param source The source service contract - * @param target The target service contract - * @param ignoreCallback Indicate the callback should be checked - * @throws IncompatibleServiceContractException - * If the source service contract is not compatible with the target one - */ - void checkCompatibility(ServiceContract source, ServiceContract target, boolean ignoreCallback) - throws IncompatibleServiceContractException; - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/AssertionTestCase.java b/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/AssertionTestCase.java deleted file mode 100644 index 72739d56c4..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/AssertionTestCase.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.spi; - -import junit.framework.TestCase; - -/** - * @version $Rev$ $Date$ - */ -public class AssertionTestCase extends TestCase { - /** - * test case that confirms that JRE assertions are enabled - */ - public void testAssertionsAreEnabled() { - try { - assert false; - fail("assertions are not enabled"); - } catch (AssertionError e) { - // ok - } - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/QualifiedNameTestCase.java b/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/QualifiedNameTestCase.java deleted file mode 100644 index 1f5faa5f9e..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/QualifiedNameTestCase.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.spi; - -import junit.framework.TestCase; - -/** - * Tests parsing of naming patters - * - * @version $Rev$ $Date$ - */ -public class QualifiedNameTestCase extends TestCase { - - public void testSimpleName() throws Exception { - QualifiedName name = new QualifiedName("Foo"); - assertEquals("Foo", name.getPartName()); - assertEquals(null, name.getPortName()); - } - - public void testCompoundName() throws Exception { - QualifiedName name = new QualifiedName("Foo/Bar"); - assertEquals("Foo", name.getPartName()); - assertEquals("Bar", name.getPortName()); - } - - public void testCompoundMultiName() throws Exception { - QualifiedName name = new QualifiedName("Foo/Bar/Baz"); - assertEquals("Foo", name.getPartName()); - assertEquals("Bar/Baz", name.getPortName()); - } - - public void testInvalidName() throws Exception { - try { - new QualifiedName("/Foo/Bar"); - fail("Invalid name exception not thrown"); - } catch (InvalidNameException e) { - //expected - } - } - - public void testQualifiedName() throws Exception { - QualifiedName name = new QualifiedName("Foo/Bar"); - assertEquals("Foo/Bar", name.getQualifiedName()); - } - - public void testToString() throws Exception { - QualifiedName name = new QualifiedName("Foo/Bar"); - assertEquals("Foo/Bar", name.toString()); - } - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/TuscanyRuntimeExceptionTestCase.java b/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/TuscanyRuntimeExceptionTestCase.java deleted file mode 100644 index 44e6bd7927..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/TuscanyRuntimeExceptionTestCase.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.spi; - -import junit.framework.TestCase; - -import org.apache.tuscany.api.TuscanyRuntimeException; - -/** - * @version $Rev$ $Date$ - */ -public class TuscanyRuntimeExceptionTestCase extends TestCase { - - public void testIdentifier() throws Exception { - TuscanyRuntimeException e = new TestException("bar", "foo"); - assertEquals("foo", e.getIdentifier()); - } - - public void testAddContext() throws Exception { - TuscanyRuntimeException e = new TestException(); - e.addContextName("foo"); - e.addContextName("bar"); - assertEquals("foo", e.returnContextNames().get(0)); - assertEquals("bar", e.returnContextNames().get(1)); - } - - public void testEmptyContext() throws Exception { - TuscanyRuntimeException e = new TestException(); - assertEquals(0, e.returnContextNames().size()); - } - - public void testEmptyGetMessage() throws Exception { - TuscanyRuntimeException e = new TestException(); - e.getMessage(); - } - - public void testFullMessage() throws Exception { - TuscanyRuntimeException e = new TestException(); - e.addContextName("foo"); - e.getMessage(); - } - - - private class TestException extends TuscanyRuntimeException { - - public TestException() { - } - - public TestException(String message, String identifier) { - super(message, identifier); - } - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/annotation/ConstructorAnnotationTest.java b/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/annotation/ConstructorAnnotationTest.java deleted file mode 100644 index affd52df42..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/annotation/ConstructorAnnotationTest.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.spi.annotation; - -import java.util.Arrays; - -import org.osoa.sca.annotations.Constructor; - -import junit.framework.TestCase; - -/** - * @version $Rev$ $Date$ - */ -public class ConstructorAnnotationTest extends TestCase { - public void testSingleName() throws NoSuchMethodException { - Constructor ann = Foo1.class.getConstructor(String.class).getAnnotation(Constructor.class); - assertNotNull(ann); - String[] names = ann.value(); - assertTrue(Arrays.equals(new String[]{"prop"}, names)); - } - - public void testMultipleNames() throws NoSuchMethodException { - Constructor ann = Foo1.class.getConstructor(String.class, String.class).getAnnotation(Constructor.class); - assertNotNull(ann); - String[] names = ann.value(); - assertTrue(Arrays.equals(new String[]{"prop", "ref"}, names)); - } - - public static class Foo1 { - @Constructor({"prop", "ref"}) - public Foo1(String prop, String ref) { - } - - @Constructor("prop") - public Foo1(String prop) { - } - } - - public static class Foo2 { - public Foo2(@Autowire String prop, - @Autowire String ref) { - } - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/component/AbstractSCAObjectTestCase.java b/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/component/AbstractSCAObjectTestCase.java deleted file mode 100644 index 4f99d3b7ec..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/component/AbstractSCAObjectTestCase.java +++ /dev/null @@ -1,128 +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.spi.component; - -import org.apache.tuscany.spi.event.Event; -import org.apache.tuscany.spi.event.EventFilter; -import org.apache.tuscany.spi.event.RuntimeEventListener; -import org.apache.tuscany.spi.event.TrueFilter; -import org.apache.tuscany.spi.model.Scope; - -import junit.framework.TestCase; -import org.easymock.EasyMock; - -/** - * @version $Rev$ $Date$ - */ -public class AbstractSCAObjectTestCase extends TestCase { - - public void testFireListener() { - SCAObject object = new TestSCAObject("foo", null); - Event event = new TestEvent(); - RuntimeEventListener listener = EasyMock.createMock(RuntimeEventListener.class); - listener.onEvent(EasyMock.same(event)); - EasyMock.expectLastCall(); - EasyMock.replay(listener); - object.addListener(listener); - object.publish(event); - } - - public void testRemoveListener() { - SCAObject object = new TestSCAObject("foo", null); - Event event = new TestEvent(); - RuntimeEventListener listener = EasyMock.createMock(RuntimeEventListener.class); - EasyMock.replay(listener); - object.addListener(listener); - object.removeListener(listener); - object.publish(event); - } - - public void testFalseFilterListener() { - SCAObject object = new TestSCAObject("foo", null); - Event event = new TestEvent(); - RuntimeEventListener listener = EasyMock.createMock(RuntimeEventListener.class); - EasyMock.replay(listener); - object.addListener(new FalseFilter(), listener); - object.publish(event); - } - - public void testTrueFilterListener() { - SCAObject object = new TestSCAObject("foo", null); - Event event = new TestEvent(); - RuntimeEventListener listener = EasyMock.createMock(RuntimeEventListener.class); - listener.onEvent(EasyMock.same(event)); - EasyMock.expectLastCall(); - EasyMock.replay(listener); - object.addListener(new TrueFilter(), listener); - object.publish(event); - } - - public void testToString() { - SCAObject object = new TestSCAObject("foo", null); - assertNotNull(object.toString()); - } - - public void testGetName() { - SCAObject object = new TestSCAObject("foo", null); - assertEquals("foo", object.getName()); - } - - - public void testToPrepare() throws Exception { - SCAObject object = new TestSCAObject("foo", null); - object.prepare(); - } - - public void testCanonicalName() { - CompositeComponent parent = EasyMock.createMock(CompositeComponent.class); - EasyMock.expect(parent.getCanonicalName()).andReturn("foo"); - EasyMock.replay(parent); - TestSCAObject test = new TestSCAObject("bar", parent); - assertEquals("foo/bar", test.getCanonicalName()); - } - - private class TestSCAObject extends AbstractSCAObject { - public TestSCAObject(String name, CompositeComponent parent) { - super(name, parent); - } - - public Scope getScope() { - return null; - } - - } - - private class TestEvent implements Event { - public Object getSource() { - return null; - } - } - - private class FalseFilter implements EventFilter { - - public boolean match(Event event) { - return false; - } - } - - -} - - - diff --git a/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/databinding/extension/DOMHelperTestCase.java b/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/databinding/extension/DOMHelperTestCase.java deleted file mode 100644 index 40843dea94..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/databinding/extension/DOMHelperTestCase.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.spi.databinding.extension; - -import javax.xml.namespace.QName; -import javax.xml.parsers.DocumentBuilder; - -import org.w3c.dom.Document; -import org.w3c.dom.Element; - -import junit.framework.TestCase; - -/** - * - */ -public class DOMHelperTestCase extends TestCase { - private static final QName FOO_NAME = new QName("http://foo", "foo"); - - /** - * @see junit.framework.TestCase#setUp() - */ - protected void setUp() throws Exception { - super.setUp(); - } - - public void testDOM() throws Exception { - DocumentBuilder builder = DOMHelper.newDocumentBuilder(); - assertNotNull(builder); - Document document = DOMHelper.newDocument(); - assertNotNull(document); - Element element = DOMHelper.createElement(document, FOO_NAME); - document.appendChild(element); - QName name = DOMHelper.getQName(element); - assertEquals(FOO_NAME, name); - - } - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/databinding/extension/DataBindingExtensionTestCase.java b/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/databinding/extension/DataBindingExtensionTestCase.java deleted file mode 100644 index b4b5f6a39a..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/databinding/extension/DataBindingExtensionTestCase.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.spi.databinding.extension; - -import junit.framework.TestCase; - -import org.apache.tuscany.spi.databinding.DataBindingRegistry; -import org.easymock.EasyMock; -import org.w3c.dom.Element; -import org.w3c.dom.Node; - -/** - * - */ -public class DataBindingExtensionTestCase extends TestCase { - - /** - * @see junit.framework.TestCase#setUp() - */ - protected void setUp() throws Exception { - super.setUp(); - } - - public void testExtension() { - DataBinding1 binding1 = new DataBinding1(Node.class); - assertEquals(Node.class.getName(), binding1.getName()); - assertNotNull(binding1.introspect(Element.class)); - assertNull(binding1.introspect(String.class)); - assertNull(binding1.getWrapperHandler()); - - DataBindingRegistry registry = EasyMock.createMock(DataBindingRegistry.class); - registry.register(binding1); - EasyMock.expect(registry.getDataBinding(Node.class.getName())).andReturn(binding1); - EasyMock.replay(registry); - - binding1.setDataBindingRegistry(registry); - binding1.init(); - assertNotNull(registry.getDataBinding(Node.class.getName())); - - DataBinding1 binding2 = new DataBinding1("dom", Node.class); - assertEquals("dom", binding2.getName()); - } - - private static class DataBinding1 extends DataBindingExtension { - - /** - * @param baseType - */ - public DataBinding1(Class baseType) { - super(baseType); - } - - /** - * @param name - * @param baseType - */ - public DataBinding1(String name, Class baseType) { - super(name, baseType); - } - - } - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/databinding/extension/SimpleTypeMapperExtensionTestCase.java b/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/databinding/extension/SimpleTypeMapperExtensionTestCase.java deleted file mode 100644 index c955352812..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/databinding/extension/SimpleTypeMapperExtensionTestCase.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.spi.databinding.extension; - -import java.util.HashMap; -import java.util.Map; - -import javax.xml.namespace.NamespaceContext; - -import junit.framework.TestCase; - -import org.apache.tuscany.spi.databinding.TransformationContext; -import org.apache.tuscany.spi.idl.TypeInfo; -import org.easymock.EasyMock; - -/** - * - */ -public class SimpleTypeMapperExtensionTestCase extends TestCase { - - private static final Map SAMPLE_VALUES = new HashMap(); - - static { - SAMPLE_VALUES.put("anyURI", "http://www.w3.com"); - SAMPLE_VALUES.put("boolean", new String[] {"true", "false", "1", "0"}); - SAMPLE_VALUES.put("byte", new String[] {"-128", "127"}); - SAMPLE_VALUES.put("date", new String[] {"2004-03-15", "2002-09-24-06:00"}); - SAMPLE_VALUES.put("dateTime", "2003-12-25T08:30:00"); - SAMPLE_VALUES.put("decimal", "3.1415292"); - SAMPLE_VALUES.put("double", new String[] {"3.1415292", "INF", "NaN"}); - SAMPLE_VALUES.put("duration", new String[] {"P8M3DT7H33M2S", "P5Y2M10DT15H"}); - SAMPLE_VALUES.put("float", new String[] {"3.1415292", "INF", "NaN"}); - SAMPLE_VALUES.put("gDay", "---11"); - SAMPLE_VALUES.put("gMonth", "--02--"); - SAMPLE_VALUES.put("gMonthDay", "--02-14"); - SAMPLE_VALUES.put("gYear", "1999"); - SAMPLE_VALUES.put("gYearMonth", "1972-08"); - SAMPLE_VALUES.put("ID", "id-102"); - SAMPLE_VALUES.put("IDREF", "id-102"); - SAMPLE_VALUES.put("IDREFS", "id-102 id-103 id-100"); - SAMPLE_VALUES.put("int", "77"); - SAMPLE_VALUES.put("integer", "77"); - SAMPLE_VALUES.put("long", "214"); - SAMPLE_VALUES.put("negativeInteger", "-123"); - SAMPLE_VALUES.put("nonNegativeInteger", "2"); - SAMPLE_VALUES.put("nonPositiveInteger", "0"); - SAMPLE_VALUES.put("positiveInteger", "500"); - SAMPLE_VALUES.put("short", "476"); - SAMPLE_VALUES.put("string", "Joeseph"); - SAMPLE_VALUES.put("time", "13:02:00"); - SAMPLE_VALUES.put("base64Binary", "TWFu"); - SAMPLE_VALUES.put("hexBinary", "2CDB5F"); - SAMPLE_VALUES.put("QName", "f:foo"); - SAMPLE_VALUES.put("NOTATION", "f:bar"); - } - - /** - * @see junit.framework.TestCase#setUp() - */ - protected void setUp() throws Exception { - super.setUp(); - } - - public void testMap() throws Exception { - SimpleTypeMapperExtension extension = new SimpleTypeMapperExtension(); - TransformationContext context = EasyMock.createMock(TransformationContext.class); - Map, Object> metaData = new HashMap, Object>(); - EasyMock.expect(context.getMetadata()).andReturn(metaData).anyTimes(); - EasyMock.replay(context); - - NamespaceContext namespaceContext = EasyMock.createMock(NamespaceContext.class); - EasyMock.expect(namespaceContext.getNamespaceURI(EasyMock.eq("f"))).andReturn("http://foo") - .anyTimes(); - EasyMock.expect(namespaceContext.getPrefix(EasyMock.eq("http://foo"))).andReturn("f").anyTimes(); - EasyMock.replay(namespaceContext); - context.getMetadata().put(NamespaceContext.class, namespaceContext); - for (TypeInfo simpleType : SimpleTypeMapperExtension.XSD_SIMPLE_TYPES.values()) { - String name = simpleType.getQName().getLocalPart(); - Object value = SAMPLE_VALUES.get(name); - if (value instanceof String[]) { - for (String s : (String[])value) { - Object obj = extension.toJavaObject(simpleType, s, context); - String str = extension.toXMLLiteral(simpleType, obj, context); - assertNotNull(str); - // assertTrue("[" + name + "] " + s + " " + str, - // str.contains((String) s)); - } - } else if (value instanceof String) { - Object obj = extension.toJavaObject(simpleType, (String)value, context); - String str = extension.toXMLLiteral(simpleType, obj, context); - assertNotNull(str); - // assertTrue("[" + name + "] " + value + " " + str, - // str.contains((String) value)); - } - } - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/databinding/extension/TransformerExtensionTestCase.java b/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/databinding/extension/TransformerExtensionTestCase.java deleted file mode 100644 index 6f5dfc90e2..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/databinding/extension/TransformerExtensionTestCase.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.spi.databinding.extension; - -import javax.xml.stream.XMLStreamReader; - -import junit.framework.TestCase; - -import org.apache.tuscany.spi.databinding.Transformer; -import org.apache.tuscany.spi.databinding.TransformerRegistry; -import org.easymock.EasyMock; -import org.w3c.dom.Node; - -/** - * Test case for TransformerExtension - */ -public class TransformerExtensionTestCase extends TestCase { - - /** - * @see junit.framework.TestCase#setUp() - */ - protected void setUp() throws Exception { - super.setUp(); - } - - public void testExtension() { - MyTransformer transformer = new MyTransformer(); - assertEquals(Node.class.getName(), transformer.getSourceDataBinding()); - assertEquals(XMLStreamReader.class.getName(), transformer.getTargetDataBinding()); - assertEquals(50, transformer.getWeight()); - TransformerRegistry registry = EasyMock.createMock(TransformerRegistry.class); - registry.registerTransformer(EasyMock.isA(Transformer.class)); - EasyMock - .expect(registry.getTransformer(transformer.getSourceDataBinding(), transformer.getTargetDataBinding())) - .andReturn(transformer); - EasyMock.replay(registry); - transformer.setTransformerRegistry(registry); - transformer.init(); - assertSame(transformer, registry.getTransformer(transformer.getSourceDataBinding(), transformer - .getTargetDataBinding())); - } - - private static class MyTransformer extends TransformerExtension { - - @Override - protected Class getSourceType() { - return Node.class; - } - - @Override - protected Class getTargetType() { - return XMLStreamReader.class; - } - - } - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/databinding/extension/XSDDataTypeConverterTestCase.java b/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/databinding/extension/XSDDataTypeConverterTestCase.java deleted file mode 100644 index 4693025c11..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/databinding/extension/XSDDataTypeConverterTestCase.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.spi.databinding.extension; - -import java.math.BigInteger; -import java.util.Calendar; -import java.util.GregorianCalendar; - -import junit.framework.TestCase; - -/** - * - */ -public class XSDDataTypeConverterTestCase extends TestCase { - - /** - * @see junit.framework.TestCase#setUp() - */ - protected void setUp() throws Exception { - super.setUp(); - } - - public void testConvert() throws Exception { - XSDDataTypeConverter c = new XSDDataTypeConverter(); - assertEquals("123", c.parseAnySimpleType(c.printAnySimpleType("123"))); - assertEquals(true, c.parseBoolean(c.printBoolean(true))); - assertEquals(false, c.parseBoolean(c.printBoolean(false))); - assertEquals(123.0, c.parseDouble(c.printDouble(123.0))); - assertEquals(123.0f, c.parseFloat(c.printFloat(123.0f))); - assertEquals(64, c.parseByte(c.printByte((byte)64))); - assertEquals(123, c.parseInt(c.printInt(123))); - assertEquals(new BigInteger("123456"), c.parseInteger(c.printInteger(new BigInteger("123456")))); - assertEquals(123456L, c.parseLong(c.printLong(123456L))); - assertEquals((short)123, c.parseShort(c.printShort((short)123))); - - Calendar calendar = new GregorianCalendar(); - String s = c.printDate(calendar); - calendar = (GregorianCalendar)c.parseDate(s); - assertEquals(s, c.printDate(calendar)); - - } - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/event/AbstractEventPublisherTestCase.java b/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/event/AbstractEventPublisherTestCase.java deleted file mode 100644 index 6efd61bea6..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/event/AbstractEventPublisherTestCase.java +++ /dev/null @@ -1,92 +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.spi.event; - - -import junit.framework.TestCase; -import org.easymock.EasyMock; - -/** - * @version $Rev$ $Date$ - */ -public class AbstractEventPublisherTestCase extends TestCase { - EventPublisher publisher; - - public void testFireListener() { - Event event = new TestEvent(); - RuntimeEventListener listener = EasyMock.createMock(RuntimeEventListener.class); - listener.onEvent(EasyMock.same(event)); - EasyMock.expectLastCall(); - EasyMock.replay(listener); - publisher.addListener(listener); - publisher.publish(event); - EasyMock.verify(publisher); - } - - public void testRemoveListener() { - Event event = new TestEvent(); - RuntimeEventListener listener = EasyMock.createMock(RuntimeEventListener.class); - EasyMock.replay(listener); - publisher.addListener(listener); - publisher.removeListener(listener); - publisher.publish(event); - EasyMock.verify(publisher); - } - - public void testFalseFilterListener() { - Event event = new TestEvent(); - RuntimeEventListener listener = EasyMock.createMock(RuntimeEventListener.class); - EasyMock.replay(listener); - publisher.addListener(new FalseFilter(), listener); - publisher.publish(event); - EasyMock.verify(publisher); - } - - public void testTrueFilterListener() { - Event event = new TestEvent(); - RuntimeEventListener listener = EasyMock.createMock(RuntimeEventListener.class); - listener.onEvent(EasyMock.same(event)); - EasyMock.expectLastCall(); - EasyMock.replay(listener); - publisher.addListener(new TrueFilter(), listener); - publisher.publish(event); - EasyMock.verify(publisher); - } - - protected void setUp() throws Exception { - super.setUp(); - publisher = new AbstractEventPublisher() { - }; - } - - private class TestEvent implements Event { - public Object getSource() { - return null; - } - } - - private class FalseFilter implements EventFilter { - - public boolean match(Event event) { - return false; - } - } - - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/AtomicComponentExtensionTestCase.java b/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/AtomicComponentExtensionTestCase.java deleted file mode 100644 index 1e81311765..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/AtomicComponentExtensionTestCase.java +++ /dev/null @@ -1,148 +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.spi.extension; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.Map; - -import org.apache.tuscany.spi.ObjectCreationException; -import org.apache.tuscany.spi.component.ScopeContainer; -import org.apache.tuscany.spi.component.TargetResolutionException; -import org.apache.tuscany.spi.model.Operation; -import org.apache.tuscany.spi.model.Scope; -import org.apache.tuscany.spi.wire.InboundInvocationChain; -import org.apache.tuscany.spi.wire.InboundWire; -import org.apache.tuscany.spi.wire.InvocationRuntimeException; -import org.apache.tuscany.spi.wire.Message; -import org.apache.tuscany.spi.wire.TargetInvoker; - -import junit.framework.TestCase; -import org.easymock.EasyMock; - -/** - * @version $Rev$ $Date$ - */ -public class AtomicComponentExtensionTestCase extends TestCase { - - public void testIsEagerInit() throws Exception { - TestExtension ext = new TestExtension(); - ext.isEagerInit(); - } - - public void testPrepare() throws Exception { - TestExtension ext = new TestExtension(); - Operation operation = new Operation("foo", null, null, null); - InboundInvocationChain chain = EasyMock.createMock(InboundInvocationChain.class); - EasyMock.expect(chain.getOperation()).andReturn(operation); - chain.prepare(); - chain.setTargetInvoker(EasyMock.isA(TargetInvoker.class)); - EasyMock.replay(chain); - - Map, InboundInvocationChain> chains = new HashMap, InboundInvocationChain>(); - chains.put(operation, chain); - InboundWire wire = EasyMock.createMock(InboundWire.class); - EasyMock.expect(wire.getInvocationChains()).andReturn(chains); - EasyMock.expect(wire.getServiceName()).andReturn("Service").atLeastOnce(); - EasyMock.replay(wire); - - ext.addInboundWire(wire); - ext.prepare(); - - EasyMock.verify(chain); - EasyMock.verify(wire); - - } - - public void testInit() throws Exception { - TestExtension ext = new TestExtension(); - ext.init(null); - } - - public void testDestroy() throws Exception { - TestExtension ext = new TestExtension(); - ext.destroy(null); - } - - public void testInboundWire() throws Exception { - TestExtension ext = new TestExtension(); - ext.getInboundWire(null); - } - - public void testRemoveInstance() throws Exception { - ScopeContainer container = EasyMock.createMock(ScopeContainer.class); - EasyMock.expect(container.getScope()).andReturn(Scope.COMPOSITE); - container.remove(EasyMock.isA(AtomicComponentExtension.class)); - EasyMock.replay(container); - TestExtension ext = new TestExtension(container); - ext.removeInstance(); - EasyMock.verify(container); - } - - private class TestExtension extends AtomicComponentExtension { - public TestExtension() { - super(null, null, null, null, null, null, 0); - } - - public TestExtension(ScopeContainer scopeContainer) { - super(null, null, null, null, null, null, 0); - setScopeContainer(scopeContainer); - } - - public Object createInstance() throws ObjectCreationException { - return null; - } - - public Object getTargetInstance() throws TargetResolutionException { - return null; - } - - public TargetInvoker createTargetInvoker(String targetName, Operation operation, InboundWire callbackWire) { - return new TargetInvoker() { - - public Object invokeTarget(final Object payload, final short sequence) - throws InvocationTargetException { - return null; - } - - public Message invoke(Message msg) throws InvocationRuntimeException { - return null; - } - - public boolean isCacheable() { - return false; - } - - public void setCacheable(boolean cacheable) { - - } - - public boolean isOptimizable() { - return false; - } - - public Object clone() throws CloneNotSupportedException { - return super.clone(); - } - }; - } - - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/ComponentTypeLoaderExtensionTestCase.java b/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/ComponentTypeLoaderExtensionTestCase.java deleted file mode 100644 index 54229633eb..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/ComponentTypeLoaderExtensionTestCase.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.spi.extension; - -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.deployer.DeploymentContext; -import org.apache.tuscany.spi.loader.LoaderException; -import org.apache.tuscany.spi.loader.LoaderRegistry; -import org.apache.tuscany.spi.model.Implementation; - -import junit.framework.TestCase; -import org.easymock.EasyMock; -import static org.easymock.EasyMock.createMock; -import static org.easymock.EasyMock.eq; - -/** - * @version $Rev$ $Date$ - */ -public class ComponentTypeLoaderExtensionTestCase extends TestCase { - - public void testRegistrationDeregistration() throws Exception { - Extension loader = new Extension(); - LoaderRegistry registry = createMock(LoaderRegistry.class); - registry.registerLoader(eq(Implementation.class), eq(loader)); - registry.unregisterLoader(eq(Implementation.class)); - EasyMock.replay(registry); - loader.setLoaderRegistry(registry); - loader.start(); - loader.stop(); - } - - - private class Extension extends ComponentTypeLoaderExtension { - - protected Class getImplementationClass() { - return Implementation.class; - } - - public void load(CompositeComponent parent, Implementation implementation, - DeploymentContext deploymentContext) throws LoaderException { - - } - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/CompositeComponentExtensionAutowireTestCase.java b/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/CompositeComponentExtensionAutowireTestCase.java deleted file mode 100644 index 9d9df81104..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/CompositeComponentExtensionAutowireTestCase.java +++ /dev/null @@ -1,302 +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.spi.extension; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.tuscany.spi.component.AtomicComponent; -import org.apache.tuscany.spi.component.CompositeComponent; -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.Service; -import org.apache.tuscany.spi.component.ServiceBinding; -import org.apache.tuscany.spi.component.TargetInvokerCreationException; -import org.apache.tuscany.spi.model.Operation; -import org.apache.tuscany.spi.model.ServiceContract; -import org.apache.tuscany.spi.wire.InboundWire; -import org.apache.tuscany.spi.wire.TargetInvoker; -import org.apache.tuscany.spi.wire.Wire; - -import junit.framework.TestCase; -import org.easymock.EasyMock; - -/** - * @version $Rev$ $Date$ - */ -public class CompositeComponentExtensionAutowireTestCase extends TestCase { - private CompositeComponent composite; - private ServiceContract contract; - private ServiceContract contract2; - - public void testAutowireAtomicComponent() throws Exception { - InboundWire wire = EasyMock.createMock(InboundWire.class); - EasyMock.expect(wire.getServiceContract()).andReturn(contract).atLeastOnce(); - EasyMock.expect(wire.getBindingType()).andReturn(Wire.LOCAL_BINDING).atLeastOnce(); - EasyMock.replay(wire); - ServiceBinding binding = EasyMock.createMock(ServiceBinding.class); - EasyMock.expect(binding.getInboundWire()).andReturn(wire).atLeastOnce(); - EasyMock.replay(binding); - List wires = new ArrayList(); - wires.add(wire); - AtomicComponent component = EasyMock.createMock(AtomicComponent.class); - EasyMock.expect(component.getInboundWires()).andReturn(wires).atLeastOnce(); - EasyMock.expect(component.isSystem()).andReturn(false).atLeastOnce(); - EasyMock.expect(component.getName()).andReturn("foo").atLeastOnce(); - EasyMock.replay(component); - composite.register(component); - assertEquals(wire, composite.resolveAutowire(Foo.class)); - } - - public void testAutowireSystemAtomicComponent() throws Exception { - InboundWire wire = EasyMock.createMock(InboundWire.class); - EasyMock.expect(wire.getServiceContract()).andReturn(contract).atLeastOnce(); - EasyMock.expect(wire.getBindingType()).andReturn(Wire.LOCAL_BINDING).atLeastOnce(); - EasyMock.replay(wire); - ServiceBinding binding = EasyMock.createMock(ServiceBinding.class); - EasyMock.expect(binding.getInboundWire()).andReturn(wire).atLeastOnce(); - EasyMock.replay(binding); - List wires = new ArrayList(); - wires.add(wire); - AtomicComponent component = EasyMock.createMock(AtomicComponent.class); - EasyMock.expect(component.getInboundWires()).andReturn(wires).atLeastOnce(); - EasyMock.expect(component.isSystem()).andReturn(true).atLeastOnce(); - EasyMock.expect(component.getName()).andReturn("foo").atLeastOnce(); - EasyMock.replay(component); - composite.register(component); - assertEquals(wire, composite.resolveSystemAutowire(Foo.class)); - } - - public void testAutowireSystemCompositeComponent() throws Exception { - // configure service - InboundWire wire = EasyMock.createMock(InboundWire.class); - EasyMock.expect(wire.getServiceContract()).andReturn(contract).atLeastOnce(); - EasyMock.expect(wire.getBindingType()).andReturn(Wire.LOCAL_BINDING).atLeastOnce(); - EasyMock.replay(wire); - ServiceBinding binding = EasyMock.createMock(ServiceBinding.class); - EasyMock.expect(binding.getInboundWire()).andReturn(wire).atLeastOnce(); - EasyMock.replay(binding); - Service service = EasyMock.createMock(Service.class); - EasyMock.expect(service.getName()).andReturn("service").atLeastOnce(); - EasyMock.expect(service.isSystem()).andReturn(false).atLeastOnce(); - service.getServiceBindings(); - List bindings = new ArrayList(); - bindings.add(binding); - EasyMock.expectLastCall().andReturn(bindings).atLeastOnce(); - EasyMock.replay(service); - - // configure system service - InboundWire systemWire = EasyMock.createMock(InboundWire.class); - EasyMock.expect(systemWire.getServiceContract()).andReturn(contract2).atLeastOnce(); - EasyMock.expect(systemWire.getBindingType()).andReturn(Wire.LOCAL_BINDING).atLeastOnce(); - EasyMock.replay(systemWire); - ServiceBinding systemBinding = EasyMock.createMock(ServiceBinding.class); - EasyMock.expect(systemBinding.getInboundWire()).andReturn(systemWire).atLeastOnce(); - EasyMock.replay(systemBinding); - Service systemService = EasyMock.createMock(Service.class); - EasyMock.expect(systemService.getName()).andReturn("systemService").atLeastOnce(); - EasyMock.expect(systemService.isSystem()).andReturn(true).atLeastOnce(); - systemService.getServiceBindings(); - List systemBindings = new ArrayList(); - systemBindings.add(systemBinding); - EasyMock.expectLastCall().andReturn(systemBindings).atLeastOnce(); - EasyMock.replay(systemService); - - CompositeComponent child = new MockComposite(true); - child.register(service); - child.register(systemService); - composite.register(child); - // since the child is registered under the system hierarchy, its services should not be visible from the - // applicaiton hierarchy - assertNull(composite.resolveAutowire(Foo.class)); - assertEquals(systemWire, composite.resolveSystemAutowire(Bar.class)); - } - - public void testAutowireCompositeComponent() throws Exception { - // configure service - InboundWire wire = EasyMock.createMock(InboundWire.class); - EasyMock.expect(wire.getServiceContract()).andReturn(contract).atLeastOnce(); - EasyMock.expect(wire.getBindingType()).andReturn(Wire.LOCAL_BINDING).atLeastOnce(); - EasyMock.replay(wire); - ServiceBinding binding = EasyMock.createMock(ServiceBinding.class); - EasyMock.expect(binding.getInboundWire()).andReturn(wire).atLeastOnce(); - EasyMock.replay(binding); - Service service = EasyMock.createMock(Service.class); - EasyMock.expect(service.getName()).andReturn("service").atLeastOnce(); - EasyMock.expect(service.isSystem()).andReturn(false).atLeastOnce(); - service.getServiceBindings(); - List bindings = new ArrayList(); - bindings.add(binding); - EasyMock.expectLastCall().andReturn(bindings).atLeastOnce(); - EasyMock.replay(service); - - // configure system service - InboundWire systemWire = EasyMock.createMock(InboundWire.class); - EasyMock.expect(systemWire.getServiceContract()).andReturn(contract2).atLeastOnce(); - EasyMock.expect(systemWire.getBindingType()).andReturn(Wire.LOCAL_BINDING).atLeastOnce(); - EasyMock.replay(systemWire); - ServiceBinding systemBinding = EasyMock.createMock(ServiceBinding.class); - EasyMock.expect(systemBinding.getInboundWire()).andReturn(systemWire).atLeastOnce(); - EasyMock.replay(systemBinding); - Service systemService = EasyMock.createMock(Service.class); - EasyMock.expect(systemService.getName()).andReturn("systemService").atLeastOnce(); - EasyMock.expect(systemService.isSystem()).andReturn(true).atLeastOnce(); - systemService.getServiceBindings(); - List systemBindings = new ArrayList(); - systemBindings.add(systemBinding); - EasyMock.expectLastCall().andReturn(systemBindings).atLeastOnce(); - EasyMock.replay(systemService); - - CompositeComponent child = new MockComposite(); - child.register(service); - child.register(systemService); - composite.register(child); - // since the child is registered under the application hierarchy, its services should not be visible from the - // system hierarchy - assertEquals(wire, composite.resolveAutowire(Foo.class)); - assertNull(composite.resolveSystemAutowire(Bar.class)); - } - - public void testAutowireSystemService() throws Exception { - InboundWire wire = EasyMock.createMock(InboundWire.class); - EasyMock.expect(wire.getServiceContract()).andReturn(contract).atLeastOnce(); - EasyMock.expect(wire.getBindingType()).andReturn(Wire.LOCAL_BINDING).atLeastOnce(); - EasyMock.replay(wire); - ServiceBinding binding = EasyMock.createMock(ServiceBinding.class); - EasyMock.expect(binding.getInboundWire()).andReturn(wire).atLeastOnce(); - EasyMock.replay(binding); - Service service = EasyMock.createMock(Service.class); - EasyMock.expect(service.getName()).andReturn("service").atLeastOnce(); - EasyMock.expect(service.isSystem()).andReturn(true).atLeastOnce(); - service.getServiceBindings(); - List bindings = new ArrayList(); - bindings.add(binding); - EasyMock.expectLastCall().andReturn(bindings).atLeastOnce(); - EasyMock.replay(service); - composite.register(service); - assertEquals(wire, composite.resolveSystemExternalAutowire(Foo.class)); - } - - public void testAutowireService() throws Exception { - InboundWire wire = EasyMock.createMock(InboundWire.class); - EasyMock.expect(wire.getServiceContract()).andReturn(contract).atLeastOnce(); - EasyMock.expect(wire.getBindingType()).andReturn(Wire.LOCAL_BINDING).atLeastOnce(); - EasyMock.replay(wire); - ServiceBinding binding = EasyMock.createMock(ServiceBinding.class); - EasyMock.expect(binding.getInboundWire()).andReturn(wire).atLeastOnce(); - EasyMock.replay(binding); - Service service = EasyMock.createMock(Service.class); - EasyMock.expect(service.getName()).andReturn("service").atLeastOnce(); - EasyMock.expect(service.isSystem()).andReturn(false).atLeastOnce(); - service.getServiceBindings(); - List bindings = new ArrayList(); - bindings.add(binding); - EasyMock.expectLastCall().andReturn(bindings).atLeastOnce(); - EasyMock.replay(service); - composite.register(service); - assertEquals(wire, composite.resolveExternalAutowire(Foo.class)); - } - - public void testAutowireReference() throws Exception { - InboundWire wire = EasyMock.createMock(InboundWire.class); - EasyMock.expect(wire.getServiceContract()).andReturn(contract).atLeastOnce(); - EasyMock.expect(wire.getBindingType()).andReturn(Wire.LOCAL_BINDING).atLeastOnce(); - EasyMock.replay(wire); - ReferenceBinding binding = EasyMock.createMock(ReferenceBinding.class); - EasyMock.expect(binding.getInboundWire()).andReturn(wire).atLeastOnce(); - EasyMock.replay(binding); - Reference reference = EasyMock.createMock(Reference.class); - EasyMock.expect(reference.getName()).andReturn("service").atLeastOnce(); - EasyMock.expect(reference.isSystem()).andReturn(false).atLeastOnce(); - reference.getReferenceBindings(); - List bindings = new ArrayList(); - bindings.add(binding); - EasyMock.expectLastCall().andReturn(bindings).atLeastOnce(); - EasyMock.replay(reference); - composite.register(reference); - assertEquals(wire, composite.resolveAutowire(Foo.class)); - } - - public void testAutowireSystemReference() throws Exception { - InboundWire wire = EasyMock.createMock(InboundWire.class); - EasyMock.expect(wire.getServiceContract()).andReturn(contract).atLeastOnce(); - EasyMock.expect(wire.getBindingType()).andReturn(Wire.LOCAL_BINDING).atLeastOnce(); - EasyMock.replay(wire); - ReferenceBinding binding = EasyMock.createMock(ReferenceBinding.class); - EasyMock.expect(binding.getInboundWire()).andReturn(wire).atLeastOnce(); - EasyMock.replay(binding); - Reference reference = EasyMock.createMock(Reference.class); - EasyMock.expect(reference.getName()).andReturn("service").atLeastOnce(); - EasyMock.expect(reference.isSystem()).andReturn(true).atLeastOnce(); - reference.getReferenceBindings(); - List bindings = new ArrayList(); - bindings.add(binding); - EasyMock.expectLastCall().andReturn(bindings).atLeastOnce(); - EasyMock.replay(reference); - composite.register(reference); - assertEquals(wire, composite.resolveSystemAutowire(Foo.class)); - } - - - protected void setUp() throws Exception { - super.setUp(); - contract = new ServiceContract(Foo.class) { - - }; - contract2 = new ServiceContract(Bar.class) { - - }; - composite = new MockComposite(); - } - - private interface Foo { - - } - - private interface Bar { - - } - - private static class MockComposite extends CompositeComponentExtension { - private boolean system; - - public MockComposite() { - super("foo", null, null, null); - } - - public MockComposite(boolean system) { - super("foo", null, null, null); - this.system = system; - } - - public boolean isSystem() { - return system; - } - - public TargetInvoker createTargetInvoker(String targetName, Operation operation, InboundWire callbackWire) - throws TargetInvokerCreationException { - throw new UnsupportedOperationException(); - } - - public void setScopeContainer(ScopeContainer scopeContainer) { - throw new UnsupportedOperationException(); - } - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/CompositeComponentExtensionTestCase.java b/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/CompositeComponentExtensionTestCase.java deleted file mode 100644 index 9eaedb04f4..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/CompositeComponentExtensionTestCase.java +++ /dev/null @@ -1,332 +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.spi.extension; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import javax.xml.namespace.QName; - -import org.apache.tuscany.spi.component.CompositeComponent; -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.Service; -import org.apache.tuscany.spi.component.ServiceBinding; -import org.apache.tuscany.spi.component.TargetInvokerCreationException; -import org.apache.tuscany.spi.model.Operation; -import org.apache.tuscany.spi.model.ServiceContract; -import org.apache.tuscany.spi.wire.InboundWire; -import org.apache.tuscany.spi.wire.OutboundWire; -import org.apache.tuscany.spi.wire.TargetInvoker; -import org.apache.tuscany.spi.wire.Wire; - -import junit.framework.TestCase; -import org.easymock.EasyMock; - -/** - * @version $Rev$ $Date$ - */ -public class CompositeComponentExtensionTestCase extends TestCase { - private CompositeComponent composite; - private ServiceContract contract; - - public void testDefaultInboundWire() throws Exception { - InboundWire wire = EasyMock.createMock(InboundWire.class); - EasyMock.expect(wire.getServiceContract()).andReturn(contract).atLeastOnce(); - EasyMock.expect(wire.getBindingType()).andReturn(Wire.LOCAL_BINDING).atLeastOnce(); - EasyMock.replay(wire); - ServiceBinding binding = EasyMock.createMock(ServiceBinding.class); - EasyMock.expect(binding.getInboundWire()).andReturn(wire).atLeastOnce(); - EasyMock.replay(binding); - Service service = EasyMock.createMock(Service.class); - EasyMock.expect(service.getName()).andReturn("service").atLeastOnce(); - EasyMock.expect(service.isSystem()).andReturn(false).atLeastOnce(); - service.getServiceBindings(); - List bindings = new ArrayList(); - bindings.add(binding); - EasyMock.expectLastCall().andReturn(bindings).atLeastOnce(); - EasyMock.replay(service); - composite.register(service); - assertEquals(wire, composite.getInboundWire(null)); - } - - public void testNoLocalBinding() throws Exception { - InboundWire wire = EasyMock.createMock(InboundWire.class); - EasyMock.expect(wire.getServiceContract()).andReturn(contract).atLeastOnce(); - EasyMock.expect(wire.getBindingType()).andReturn(new QName("foo", "foo")).atLeastOnce(); - EasyMock.replay(wire); - ServiceBinding binding = EasyMock.createMock(ServiceBinding.class); - EasyMock.expect(binding.getInboundWire()).andReturn(wire).atLeastOnce(); - EasyMock.replay(binding); - Service service = EasyMock.createMock(Service.class); - EasyMock.expect(service.getName()).andReturn("service").atLeastOnce(); - EasyMock.expect(service.isSystem()).andReturn(false).atLeastOnce(); - service.getServiceBindings(); - List bindings = new ArrayList(); - bindings.add(binding); - EasyMock.expectLastCall().andReturn(bindings).atLeastOnce(); - EasyMock.replay(service); - composite.register(service); - assertNull(composite.getInboundWire("service")); - } - - public void testDefaultSystemInboundWire() throws Exception { - InboundWire wire = EasyMock.createMock(InboundWire.class); - EasyMock.expect(wire.getServiceContract()).andReturn(contract).atLeastOnce(); - EasyMock.expect(wire.getBindingType()).andReturn(Wire.LOCAL_BINDING).atLeastOnce(); - EasyMock.replay(wire); - ServiceBinding binding = EasyMock.createMock(ServiceBinding.class); - EasyMock.expect(binding.getInboundWire()).andReturn(wire).atLeastOnce(); - EasyMock.replay(binding); - Service service = EasyMock.createMock(Service.class); - EasyMock.expect(service.getName()).andReturn("service").atLeastOnce(); - EasyMock.expect(service.isSystem()).andReturn(true).atLeastOnce(); - service.getServiceBindings(); - List bindings = new ArrayList(); - bindings.add(binding); - EasyMock.expectLastCall().andReturn(bindings).atLeastOnce(); - EasyMock.replay(service); - composite.register(service); - assertEquals(wire, composite.getInboundSystemWire(null)); - } - - public void testMoreThanOneServiceGetDefault() throws Exception { - Service service1 = EasyMock.createMock(Service.class); - EasyMock.expect(service1.getName()).andReturn("service1").atLeastOnce(); - EasyMock.expect(service1.isSystem()).andReturn(false).atLeastOnce(); - service1.getServiceBindings(); - EasyMock.expectLastCall().andReturn(Collections.emptyList()).atLeastOnce(); - EasyMock.replay(service1); - - Service service2 = EasyMock.createMock(Service.class); - EasyMock.expect(service2.getName()).andReturn("service2").atLeastOnce(); - EasyMock.expect(service2.isSystem()).andReturn(false).atLeastOnce(); - service2.getServiceBindings(); - EasyMock.expectLastCall().andReturn(Collections.emptyList()).atLeastOnce(); - EasyMock.replay(service2); - - composite.register(service1); - composite.register(service2); - assertNull(composite.getInboundWire(null)); - assertNull(composite.getInboundSystemWire(null)); - } - - public void testInboundWire() throws Exception { - ServiceContract contract = new ServiceContract(Object.class) { - }; - InboundWire wire = EasyMock.createMock(InboundWire.class); - EasyMock.expect(wire.getBindingType()).andReturn(Wire.LOCAL_BINDING); - wire.getServiceContract(); - EasyMock.expectLastCall().andReturn(contract).atLeastOnce(); - EasyMock.replay(wire); - ServiceBinding binding = EasyMock.createMock(ServiceBinding.class); - EasyMock.expect(binding.getInboundWire()).andReturn(wire).atLeastOnce(); - EasyMock.replay(binding); - - Service service = EasyMock.createMock(Service.class); - EasyMock.expect(service.getName()).andReturn("service").atLeastOnce(); - EasyMock.expect(service.isSystem()).andReturn(false).atLeastOnce(); - List bindings = new ArrayList(); - bindings.add(binding); - service.getServiceBindings(); - EasyMock.expectLastCall().andReturn(bindings).atLeastOnce(); - EasyMock.replay(service); - composite.register(service); - assertNotNull(composite.getInboundWire("service")); - } - - public void testInboundWires() throws Exception { - ServiceContract contract = new ServiceContract(Object.class) { - }; - InboundWire wire = EasyMock.createMock(InboundWire.class); - EasyMock.expect(wire.getBindingType()).andReturn(Wire.LOCAL_BINDING); - wire.getServiceContract(); - EasyMock.expectLastCall().andReturn(contract).atLeastOnce(); - EasyMock.replay(wire); - ServiceBinding binding = EasyMock.createMock(ServiceBinding.class); - EasyMock.expect(binding.getInboundWire()).andReturn(wire).atLeastOnce(); - EasyMock.replay(binding); - - Service service = EasyMock.createMock(Service.class); - EasyMock.expect(service.getName()).andReturn("service").atLeastOnce(); - EasyMock.expect(service.isSystem()).andReturn(false).atLeastOnce(); - List bindings = new ArrayList(); - bindings.add(binding); - service.getServiceBindings(); - EasyMock.expectLastCall().andReturn(bindings).atLeastOnce(); - EasyMock.replay(service); - composite.register(service); - assertEquals(1, composite.getInboundWires().size()); - } - - public void testInboundWiresNonLocalBinding() throws Exception { - ServiceContract contract = new ServiceContract(Object.class) { - }; - InboundWire wire = EasyMock.createMock(InboundWire.class); - EasyMock.expect(wire.getBindingType()).andReturn(new QName("foo", "foo")); - wire.getServiceContract(); - EasyMock.expectLastCall().andReturn(contract).atLeastOnce(); - EasyMock.replay(wire); - ServiceBinding binding = EasyMock.createMock(ServiceBinding.class); - EasyMock.expect(binding.getInboundWire()).andReturn(wire).atLeastOnce(); - EasyMock.replay(binding); - - Service service = EasyMock.createMock(Service.class); - EasyMock.expect(service.getName()).andReturn("service").atLeastOnce(); - EasyMock.expect(service.isSystem()).andReturn(false).atLeastOnce(); - List bindings = new ArrayList(); - bindings.add(binding); - service.getServiceBindings(); - EasyMock.expectLastCall().andReturn(bindings).atLeastOnce(); - EasyMock.replay(service); - composite.register(service); - assertEquals(0, composite.getInboundWires().size()); - } - - - public void testGetOutboundWires() throws Exception { - ServiceContract contract = new ServiceContract(Object.class) { - }; - InboundWire inboundWire = EasyMock.createMock(InboundWire.class); - inboundWire.getServiceContract(); - EasyMock.expectLastCall().andReturn(contract).atLeastOnce(); - EasyMock.replay(inboundWire); - - OutboundWire outboundWire = EasyMock.createMock(OutboundWire.class); - outboundWire.getServiceContract(); - EasyMock.expectLastCall().andReturn(contract).atLeastOnce(); - EasyMock.expect(outboundWire.getBindingType()).andReturn(Wire.LOCAL_BINDING); - EasyMock.replay(outboundWire); - - ReferenceBinding binding = EasyMock.createMock(ReferenceBinding.class); - EasyMock.expect(binding.getInboundWire()).andReturn(inboundWire).atLeastOnce(); - EasyMock.expect(binding.getOutboundWire()).andReturn(outboundWire).atLeastOnce(); - EasyMock.replay(binding); - Reference reference = EasyMock.createMock(Reference.class); - EasyMock.expect(reference.getName()).andReturn("reference").atLeastOnce(); - EasyMock.expect(reference.isSystem()).andReturn(false).atLeastOnce(); - List bindings = new ArrayList(); - bindings.add(binding); - EasyMock.expect(reference.getReferenceBindings()).andReturn(bindings).atLeastOnce(); - EasyMock.replay(reference); - composite.register(reference); - Map> wires = composite.getOutboundWires(); - assertEquals(1, wires.get("reference").size()); - } - - public void testGetOutboundWiresWithNonLocalBinding() throws Exception { - ServiceContract contract = new ServiceContract(Object.class) { - }; - QName qName = new QName("foo", "foo"); - InboundWire inboundWire = EasyMock.createMock(InboundWire.class); - EasyMock.expect(inboundWire.getBindingType()).andReturn(qName); - inboundWire.getServiceContract(); - EasyMock.expectLastCall().andReturn(contract).atLeastOnce(); - EasyMock.replay(inboundWire); - - OutboundWire outboundWire = EasyMock.createMock(OutboundWire.class); - outboundWire.getServiceContract(); - EasyMock.expectLastCall().andReturn(contract).atLeastOnce(); - EasyMock.expect(outboundWire.getBindingType()).andReturn(qName); - EasyMock.replay(outboundWire); - - ReferenceBinding binding = EasyMock.createMock(ReferenceBinding.class); - EasyMock.expect(binding.getInboundWire()).andReturn(inboundWire).atLeastOnce(); - EasyMock.expect(binding.getOutboundWire()).andReturn(outboundWire).atLeastOnce(); - EasyMock.replay(binding); - Reference reference = EasyMock.createMock(Reference.class); - EasyMock.expect(reference.getName()).andReturn("reference").atLeastOnce(); - EasyMock.expect(reference.isSystem()).andReturn(false).atLeastOnce(); - List bindings = new ArrayList(); - bindings.add(binding); - EasyMock.expect(reference.getReferenceBindings()).andReturn(bindings).atLeastOnce(); - EasyMock.replay(reference); - composite.register(reference); - Map> wires = composite.getOutboundWires(); - assertEquals(0, wires.get("reference").size()); - } - - public void testInboundSystemWire() throws Exception { - ServiceContract contract = new ServiceContract(Object.class) { - }; - InboundWire wire = EasyMock.createMock(InboundWire.class); - EasyMock.expect(wire.getBindingType()).andReturn(Wire.LOCAL_BINDING); - wire.getServiceContract(); - EasyMock.expectLastCall().andReturn(contract).atLeastOnce(); - EasyMock.replay(wire); - ServiceBinding binding = EasyMock.createMock(ServiceBinding.class); - EasyMock.expect(binding.getInboundWire()).andReturn(wire).atLeastOnce(); - EasyMock.replay(binding); - - Service service = EasyMock.createMock(Service.class); - EasyMock.expect(service.getName()).andReturn("service").atLeastOnce(); - EasyMock.expect(service.isSystem()).andReturn(true).atLeastOnce(); - List bindings = new ArrayList(); - bindings.add(binding); - service.getServiceBindings(); - EasyMock.expectLastCall().andReturn(bindings).atLeastOnce(); - EasyMock.replay(service); - composite.register(service); - assertNotNull(composite.getInboundSystemWire("service")); - } - - public void testInboundSystemWires() throws Exception { - ServiceContract contract = new ServiceContract(Object.class) { - }; - InboundWire wire = EasyMock.createMock(InboundWire.class); - EasyMock.expect(wire.getBindingType()).andReturn(Wire.LOCAL_BINDING); - wire.getServiceContract(); - EasyMock.expectLastCall().andReturn(contract).atLeastOnce(); - EasyMock.replay(wire); - ServiceBinding binding = EasyMock.createMock(ServiceBinding.class); - EasyMock.expect(binding.getInboundWire()).andReturn(wire).atLeastOnce(); - EasyMock.replay(binding); - - Service service = EasyMock.createMock(Service.class); - EasyMock.expect(service.getName()).andReturn("service").atLeastOnce(); - EasyMock.expect(service.isSystem()).andReturn(true).atLeastOnce(); - List bindings = new ArrayList(); - bindings.add(binding); - service.getServiceBindings(); - EasyMock.expectLastCall().andReturn(bindings).atLeastOnce(); - EasyMock.replay(service); - composite.register(service); - assertEquals(wire, composite.getInboundSystemWires().iterator().next()); - } - - protected void setUp() throws Exception { - super.setUp(); - contract = new ServiceContract(Object.class) { - - }; - composite = new CompositeComponentExtension("foo", null, null, null) { - - public TargetInvoker createTargetInvoker(String targetName, Operation operation, InboundWire callbackWire) - throws TargetInvokerCreationException { - throw new UnsupportedOperationException(); - } - - public void setScopeContainer(ScopeContainer scopeContainer) { - throw new UnsupportedOperationException(); - } - }; - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/LoaderExtensionTestCase.java b/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/LoaderExtensionTestCase.java deleted file mode 100644 index 84175d8578..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/LoaderExtensionTestCase.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.spi.extension; - -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; - -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.deployer.DeploymentContext; -import org.apache.tuscany.spi.loader.LoaderException; -import org.apache.tuscany.spi.loader.LoaderRegistry; -import org.apache.tuscany.spi.model.ModelObject; - -import junit.framework.TestCase; -import org.easymock.EasyMock; -import static org.easymock.EasyMock.expectLastCall; -import static org.easymock.EasyMock.isA; - -/** - * @version $Rev$ $Date$ - */ -public class LoaderExtensionTestCase extends TestCase { - - @SuppressWarnings("unchecked") - public void testRegistrationDeregistration() throws Exception { - LoaderRegistry registry = EasyMock.createMock(LoaderRegistry.class); - registry.registerLoader(isA(QName.class), isA(Extension.class)); - expectLastCall(); - registry.unregisterLoader(isA(QName.class), isA(Extension.class)); - expectLastCall(); - EasyMock.replay(registry); - Extension loader = new Extension(registry); - loader.start(); - loader.stop(); - } - - - private static class Extension extends LoaderExtension { - - public Extension(LoaderRegistry registry) { - super(registry); - } - - public QName getXMLType() { - return new QName(""); - } - - public ModelObject load(CompositeComponent parent, - ModelObject object, XMLStreamReader reader, - DeploymentContext deploymentContext) throws XMLStreamException, LoaderException { - throw new AssertionError(); - } - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/ReferenceBindingExtensionTestCase.java b/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/ReferenceBindingExtensionTestCase.java deleted file mode 100644 index e48d72e7fb..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/ReferenceBindingExtensionTestCase.java +++ /dev/null @@ -1,67 +0,0 @@ -package org.apache.tuscany.spi.extension; - -import javax.xml.namespace.QName; - -import org.apache.tuscany.spi.component.Reference; -import org.apache.tuscany.spi.component.TargetInvokerCreationException; -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.wire.TargetInvoker; - -import junit.framework.TestCase; -import org.easymock.EasyMock; - -/** - * @version $Rev$ $Date$ - */ -public class ReferenceBindingExtensionTestCase extends TestCase { - - public void testScope() throws Exception { - ReferenceBindingExtension binding = new MockBindingExtension(); - assertEquals(Scope.SYSTEM, binding.getScope()); - } - - public void testPrepare() throws Exception { - ReferenceBindingExtension binding = new MockBindingExtension(); - binding.prepare(); - } - - public void testIsSystemNoParent() throws Exception { - ReferenceBindingExtension binding = new MockBindingExtension(); - assertFalse(binding.isSystem()); - } - - public void testIsSystem() throws Exception { - Reference reference = EasyMock.createMock(Reference.class); - EasyMock.expect(reference.isSystem()).andReturn(true); - EasyMock.replay(reference); - ReferenceBindingExtension binding = new MockBindingExtension(); - binding.setReference(reference); - assertTrue(binding.isSystem()); - } - - public void testIsNotSystem() throws Exception { - Reference reference = EasyMock.createMock(Reference.class); - EasyMock.expect(reference.isSystem()).andReturn(false); - EasyMock.replay(reference); - ReferenceBindingExtension binding = new MockBindingExtension(); - binding.setReference(reference); - assertFalse(binding.isSystem()); - } - - private static class MockBindingExtension extends ReferenceBindingExtension { - public MockBindingExtension() { - super(null, null); - } - - public QName getBindingType() { - return null; - } - - public TargetInvoker createTargetInvoker(ServiceContract contract, Operation operation) - throws TargetInvokerCreationException { - return null; - } - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/ReferenceTestCase.java b/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/ReferenceTestCase.java deleted file mode 100644 index 60d7a4d908..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/ReferenceTestCase.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.spi.extension; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.Map; - -import javax.xml.namespace.QName; - -import org.apache.tuscany.spi.QualifiedName; -import org.apache.tuscany.spi.model.Operation; -import static org.apache.tuscany.spi.model.Operation.NO_CONVERSATION; -import org.apache.tuscany.spi.model.Scope; -import org.apache.tuscany.spi.model.ServiceContract; -import org.apache.tuscany.spi.wire.InboundInvocationChain; -import org.apache.tuscany.spi.wire.InboundWire; -import org.apache.tuscany.spi.wire.InvocationChain; -import org.apache.tuscany.spi.wire.OutboundWire; -import org.apache.tuscany.spi.wire.TargetInvoker; - -import junit.framework.TestCase; -import static org.easymock.EasyMock.createMock; -import static org.easymock.EasyMock.expectLastCall; -import static org.easymock.EasyMock.replay; - -/** - * @version $Rev$ $Date$ - */ -public class ReferenceTestCase extends TestCase { - - public void testScope() throws Exception { - TestReferenceBinding ref = new TestReferenceBinding(); - assertEquals(Scope.SYSTEM, ref.getScope()); - } - - public void testPrepare() throws Exception { - InboundInvocationChain chain = createMock(InboundInvocationChain.class); - Operation operation = new Operation("test", null, null, null, false, null, NO_CONVERSATION); - chain.setTargetInvoker(null); - expectLastCall(); - chain.getOperation(); - expectLastCall().andReturn(operation); - chain.prepare(); - expectLastCall(); - InboundWire wire = createMock(InboundWire.class); - wire.getInvocationChains(); - Map chains = new HashMap(); - chains.put(operation, chain); - expectLastCall().andReturn(chains); - OutboundWire outboundWire = createMock(OutboundWire.class); - outboundWire.getTargetName(); - expectLastCall().andReturn(new QualifiedName("foo/bar")); - replay(chain); - replay(wire); - replay(outboundWire); - TestReferenceBinding ref = new TestReferenceBinding(); - ref.setInboundWire(wire); - ref.setOutboundWire(outboundWire); - ref.prepare(); - } - - private class TestReferenceBinding extends ReferenceBindingExtension { - public TestReferenceBinding() { - super(null, null); - } - - public QName getBindingType() { - return null; - } - - public TargetInvoker createTargetInvoker(ServiceContract contract, Operation operation) { - return null; - } - - - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/ServiceBindingExtensionTestCase.java b/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/ServiceBindingExtensionTestCase.java deleted file mode 100644 index 5570ee1fbb..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/ServiceBindingExtensionTestCase.java +++ /dev/null @@ -1,87 +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.spi.extension; - -import javax.xml.namespace.QName; - -import org.apache.tuscany.spi.component.Service; -import org.apache.tuscany.spi.model.Scope; - -import junit.framework.TestCase; -import org.easymock.EasyMock; - -/** - * @version $Rev$ $Date$ - */ -public class ServiceBindingExtensionTestCase extends TestCase { - - public void testScope() throws Exception { - ServiceBindingExtension binding = new ServiceBindingExtension(null, null) { - public QName getBindingType() { - return null; - } - }; - assertEquals(Scope.SYSTEM, binding.getScope()); - } - - public void testPrepare() throws Exception { - ServiceBindingExtension binding = new ServiceBindingExtension(null, null) { - public QName getBindingType() { - return null; - } - }; - binding.prepare(); - } - - public void testIsSystemNoParent() throws Exception { - ServiceBindingExtension binding = new ServiceBindingExtension(null, null) { - public QName getBindingType() { - return null; - } - }; - assertFalse(binding.isSystem()); - } - - public void testIsSystem() throws Exception { - Service service = EasyMock.createMock(Service.class); - EasyMock.expect(service.isSystem()).andReturn(true); - EasyMock.replay(service); - ServiceBindingExtension binding = new ServiceBindingExtension(null, null) { - public QName getBindingType() { - return null; - } - }; - binding.setService(service); - assertTrue(binding.isSystem()); - } - - public void testIsNotSystem() throws Exception { - Service service = EasyMock.createMock(Service.class); - EasyMock.expect(service.isSystem()).andReturn(false); - EasyMock.replay(service); - ServiceBindingExtension binding = new ServiceBindingExtension(null, null) { - public QName getBindingType() { - return null; - } - }; - binding.setService(service); - assertFalse(binding.isSystem()); - } - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/TargetInvokerExtensionSequenceTestCase.java b/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/TargetInvokerExtensionSequenceTestCase.java deleted file mode 100644 index 21d5ee763c..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/TargetInvokerExtensionSequenceTestCase.java +++ /dev/null @@ -1,169 +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.spi.extension; - -import java.lang.reflect.InvocationTargetException; -import java.util.LinkedList; - -import org.apache.tuscany.spi.component.WorkContext; -import org.apache.tuscany.spi.wire.InboundWire; -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 TargetInvokerExtensionSequenceTestCase extends TestCase { - - @SuppressWarnings("unchecked") - public void testStart() { - Object from = new Object(); - InboundWire wire = EasyMock.createMock(InboundWire.class); - EasyMock.replay(wire); - WorkContext context; - context = EasyMock.createMock(WorkContext.class); - context.setCurrentCallbackRoutingChain(EasyMock.isA(LinkedList.class)); - EasyMock.replay(context); - ExecutionMonitor monitor = EasyMock.createNiceMock(ExecutionMonitor.class); - Target target = EasyMock.createMock(Target.class); - target.invokeStart("test"); - EasyMock.replay(target); - Invoker invoker = new Invoker(wire, context, monitor, target); - Message msg = new MessageImpl(); - msg.pushFromAddress(from); - msg.setBody("test"); - msg.setConversationSequence(Invoker.START); - invoker.invoke(msg); - EasyMock.verify(wire); - EasyMock.verify(context); - EasyMock.verify(target); - } - - @SuppressWarnings("unchecked") - public void testContinue() { - Object from = new Object(); - InboundWire wire = EasyMock.createMock(InboundWire.class); - EasyMock.replay(wire); - WorkContext context; - context = EasyMock.createMock(WorkContext.class); - context.setCurrentCallbackRoutingChain(EasyMock.isA(LinkedList.class)); - EasyMock.replay(context); - ExecutionMonitor monitor = EasyMock.createNiceMock(ExecutionMonitor.class); - Target target = EasyMock.createMock(Target.class); - target.invokeContinue("test"); - EasyMock.replay(target); - Invoker invoker = new Invoker(wire, context, monitor, target); - Message msg = new MessageImpl(); - msg.pushFromAddress(from); - msg.setBody("test"); - msg.setConversationSequence(Invoker.CONTINUE); - invoker.invoke(msg); - EasyMock.verify(wire); - EasyMock.verify(context); - EasyMock.verify(target); - } - - @SuppressWarnings("unchecked") - public void testEnd() { - Object from = new Object(); - InboundWire wire = EasyMock.createMock(InboundWire.class); - EasyMock.replay(wire); - WorkContext context; - context = EasyMock.createMock(WorkContext.class); - context.setCurrentCallbackRoutingChain(EasyMock.isA(LinkedList.class)); - EasyMock.replay(context); - ExecutionMonitor monitor = EasyMock.createNiceMock(ExecutionMonitor.class); - Target target = EasyMock.createMock(Target.class); - target.invokeEnd("test"); - EasyMock.replay(target); - Invoker invoker = new Invoker(wire, context, monitor, target); - Message msg = new MessageImpl(); - msg.pushFromAddress(from); - msg.setBody("test"); - msg.setConversationSequence(Invoker.END); - invoker.invoke(msg); - EasyMock.verify(wire); - EasyMock.verify(context); - EasyMock.verify(target); - } - - @SuppressWarnings("unchecked") - public void testNone() { - Object from = new Object(); - InboundWire wire = EasyMock.createMock(InboundWire.class); - EasyMock.replay(wire); - WorkContext context; - context = EasyMock.createMock(WorkContext.class); - context.setCurrentCallbackRoutingChain(EasyMock.isA(LinkedList.class)); - EasyMock.replay(context); - ExecutionMonitor monitor = EasyMock.createNiceMock(ExecutionMonitor.class); - Target target = EasyMock.createMock(Target.class); - target.invokeNone("test"); - EasyMock.replay(target); - Invoker invoker = new Invoker(wire, context, monitor, target); - Message msg = new MessageImpl(); - msg.pushFromAddress(from); - msg.setBody("test"); - invoker.invoke(msg); - EasyMock.verify(wire); - EasyMock.verify(context); - EasyMock.verify(target); - } - - protected void setUp() throws Exception { - super.setUp(); - - } - - private class Invoker extends TargetInvokerExtension { - private Target target; - - public Invoker(InboundWire wire, WorkContext workContext, ExecutionMonitor monitor, - TargetInvokerExtensionSequenceTestCase.Target target) { - super(wire, workContext, monitor); - this.target = target; - } - - public Object invokeTarget(final Object payload, final short sequence) throws InvocationTargetException { - if (sequence == NONE) { - target.invokeNone((String) payload); - } else if (sequence == START) { - target.invokeStart((String) payload); - } else if (sequence == CONTINUE) { - target.invokeContinue((String) payload); - } else if (sequence == END) { - target.invokeEnd((String) payload); - } - return null; - } - } - - private interface Target { - void invokeStart(String msg); - - void invokeContinue(String msg); - - void invokeEnd(String msg); - - void invokeNone(String msg); - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/TargetInvokerExtensionTestCase.java b/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/TargetInvokerExtensionTestCase.java deleted file mode 100644 index 56d069005d..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/TargetInvokerExtensionTestCase.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.spi.extension; - -import java.lang.reflect.InvocationTargetException; -import java.util.LinkedList; - -import org.apache.tuscany.spi.component.WorkContext; -import org.apache.tuscany.spi.wire.InboundWire; -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 TargetInvokerExtensionTestCase extends TestCase { - - @SuppressWarnings("unchecked") - public void testNonBlockingDispatch() { - Object from = new Object(); - InboundWire wire = EasyMock.createMock(InboundWire.class); - EasyMock.replay(wire); - WorkContext context; - context = EasyMock.createMock(WorkContext.class); - context.setCurrentCallbackRoutingChain(EasyMock.isA(LinkedList.class)); - EasyMock.replay(context); - ExecutionMonitor monitor = EasyMock.createNiceMock(ExecutionMonitor.class); - Target target = EasyMock.createMock(Target.class); - target.invoke("test"); - EasyMock.replay(target); - Invoker invoker = new Invoker(wire, context, monitor, target); - Message msg = new MessageImpl(); - msg.pushFromAddress(from); - msg.setBody("test"); - invoker.invoke(msg); - EasyMock.verify(wire); - EasyMock.verify(context); - EasyMock.verify(target); - } - - protected void setUp() throws Exception { - super.setUp(); - - } - - private class Invoker extends TargetInvokerExtension { - private Target target; - - public Invoker(InboundWire wire, WorkContext workContext, ExecutionMonitor monitor, Target target) { - super(wire, workContext, monitor); - this.target = target; - } - - public Object invokeTarget(final Object payload, final short sequence) throws InvocationTargetException { - target.invoke((String) payload); - return null; - } - } - - private interface Target { - void invoke(String msg); - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/idl/java/JavaIDLUtilsTestCase.java b/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/idl/java/JavaIDLUtilsTestCase.java deleted file mode 100644 index e50c1e32a2..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/idl/java/JavaIDLUtilsTestCase.java +++ /dev/null @@ -1,178 +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.spi.idl.java; - -import java.lang.reflect.Method; -import java.lang.reflect.Type; -import java.util.ArrayList; -import java.util.List; - -import static org.apache.tuscany.spi.idl.java.JavaIDLUtils.findMethod; -import static org.apache.tuscany.spi.idl.java.JavaIDLUtils.findOperation; -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 junit.framework.TestCase; - -/** - * @version $Rev$ $Date$ - */ -public class JavaIDLUtilsTestCase extends TestCase { - private Method[] methods; - private List> operations; - - public void testNoParamsFindMethod() { - List> types = new ArrayList>(); - DataType>> inputType = new DataType>>(Object[].class, types); - Operation operation = new Operation("foo", inputType, null, null, false, null, NO_CONVERSATION); - Method method = findMethod(operation, methods); - assertEquals("foo", method.getName()); - assertEquals(0, method.getParameterTypes().length); - } - - public void testNoParamsFindOperation() throws Exception { - Method method = Foo.class.getMethod("foo"); - Operation ret = findOperation(method, operations); - assertEquals("foo", ret.getName()); - assertEquals(0, method.getParameterTypes().length); - } - - public void testParamsFindMethod() { - List> types = new ArrayList>(); - DataType type = new DataType(String.class, Object.class); - types.add(type); - DataType>> inputType = new DataType>>(Object[].class, types); - Operation operation = new Operation("foo", inputType, null, null, false, null, NO_CONVERSATION); - Method method = findMethod(operation, methods); - assertEquals("foo", method.getName()); - assertEquals(String.class, method.getParameterTypes()[0]); - } - - public void testParamsFindOperation() throws Exception { - Method method = Foo.class.getMethod("foo", String.class); - Operation ret = findOperation(method, operations); - assertEquals("foo", ret.getName()); - assertEquals(String.class, method.getParameterTypes()[0]); - } - - - public void testTooManyParamsFindMethod() { - List> types = new ArrayList>(); - DataType type = new DataType(String.class, Object.class); - DataType type2 = new DataType(String.class, Object.class); - types.add(type); - types.add(type2); - DataType>> inputType = new DataType>>(Object[].class, types); - Operation operation = new Operation("foo", inputType, null, null, false, null, NO_CONVERSATION); - Method method = findMethod(operation, methods); - assertNull(method); - } - - public void testDifferentParamsFindMethod() { - List> types = new ArrayList>(); - DataType type = new DataType(Integer.class, Object.class); - types.add(type); - DataType>> inputType = new DataType>>(Object[].class, types); - Operation operation = new Operation("foo", inputType, null, null, false, null, NO_CONVERSATION); - Method method = findMethod(operation, methods); - assertNull(method); - } - - public void testPrimitiveParamNoFindMethod() { - List> types = new ArrayList>(); - DataType type = new DataType(Integer.class, Object.class); - types.add(type); - DataType>> inputType = new DataType>>(Object[].class, types); - Operation operation = new Operation("foo", inputType, null, null, false, null, NO_CONVERSATION); - Method method = findMethod(operation, methods); - assertNull(method); - } - - public void testPrimitiveParamFindMethod() { - List> types = new ArrayList>(); - DataType type = new DataType(Integer.TYPE, Object.class); - types.add(type); - DataType>> inputType = new DataType>>(Object[].class, types); - Operation operation = new Operation("foo", inputType, null, null, false, null, NO_CONVERSATION); - Method method = findMethod(operation, methods); - assertEquals("foo", method.getName()); - assertEquals(Integer.TYPE, method.getParameterTypes()[0]); - } - - public void testPrimitiveParamFindOperation() throws NoSuchMethodException { - Method method = Foo.class.getMethod("foo", Integer.TYPE); - Operation operation = findOperation(method, operations); - assertEquals(Integer.TYPE, operation.getInputType().getLogical().get(0).getPhysical()); - } - - - public void testNotFoundMethod() { - Operation operation = new Operation("not there", null, null, null, false, null, NO_CONVERSATION); - assertNull(findMethod(operation, methods)); - } - - protected void setUp() throws Exception { - super.setUp(); - methods = Foo.class.getMethods(); - - Operation operation = new Operation("foo", null, null, null, false, null, NO_CONVERSATION); - operations = new ArrayList>(); - operations.add(operation); - - List> types = new ArrayList>(); - DataType>> inputType = new DataType>>(Object[].class, types); - DataType type = new DataType(String.class, Object.class); - types.add(type); - operation = new Operation("foo", inputType, null, null, false, null, NO_CONVERSATION); - operations.add(operation); - - types = new ArrayList>(); - type = new DataType(String.class, Object.class); - DataType type2 = new DataType(String.class, Object.class); - types.add(type); - types.add(type2); - inputType = new DataType>>(Object[].class, types); - operation = new Operation("foo", inputType, null, null, false, null, NO_CONVERSATION); - operations.add(operation); - - types = new ArrayList>(); - type = new DataType(Integer.class, Object.class); - types.add(type); - inputType = new DataType>>(Object[].class, types); - operation = new Operation("foo", inputType, null, null, false, null, NO_CONVERSATION); - operations.add(operation); - - types = new ArrayList>(); - type = new DataType(Integer.TYPE, Object.class); - types.add(type); - inputType = new DataType>>(Object[].class, types); - operation = new Operation("foo", inputType, null, null, false, null, NO_CONVERSATION); - operations.add(operation); - - } - - private interface Foo { - void foo(); - - void foo(String foo); - - void foo(int b); - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/implementation/java/AbstractPropertyProcessorTestCase.java b/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/implementation/java/AbstractPropertyProcessorTestCase.java deleted file mode 100644 index 18887880fe..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/implementation/java/AbstractPropertyProcessorTestCase.java +++ /dev/null @@ -1,176 +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.spi.implementation.java; - -import java.lang.annotation.Retention; -import static java.lang.annotation.RetentionPolicy.RUNTIME; -import java.lang.reflect.Constructor; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.util.List; - -import org.apache.tuscany.spi.ObjectFactory; -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.deployer.DeploymentContext; - -import junit.framework.TestCase; -import org.easymock.EasyMock; -import org.easymock.IAnswer; - -/** - * @version $Rev$ $Date$ - */ -public class AbstractPropertyProcessorTestCase extends TestCase { - - private ImplementationProcessor processor; - - - public void testVisitMethod() throws Exception { - Method method = Foo.class.getMethod("setBar", String.class); - PojoComponentType> type = - new PojoComponentType>(); - processor.visitMethod(null, method, type, null); - JavaMappedProperty prop = type.getProperties().get("test"); - assertNotNull(prop.getDefaultValueFactory()); - } - - public void testVisitNoParamsMethod() throws Exception { - Method method = Foo.class.getMethod("setNoParamsBar"); - PojoComponentType> type = - new PojoComponentType>(); - try { - processor.visitMethod(null, method, type, null); - fail(); - } catch (IllegalPropertyException e) { - //expected - } - } - - public void testVisitNonVoidMethod() throws Exception { - Method method = Foo.class.getMethod("setBadBar", String.class); - PojoComponentType> type = - new PojoComponentType>(); - try { - processor.visitMethod(null, method, type, null); - fail(); - } catch (IllegalPropertyException e) { - //expected - } - } - - public void testDuplicateMethod() throws Exception { - Method method = Foo.class.getMethod("setBar", String.class); - PojoComponentType> type = - new PojoComponentType>(); - processor.visitMethod(null, method, type, null); - try { - processor.visitMethod(null, method, type, null); - fail(); - } catch (DuplicatePropertyException e) { - //expected - } - } - - public void testVisitField() throws Exception { - Field field = Foo.class.getDeclaredField("d"); - PojoComponentType> type = - new PojoComponentType>(); - processor.visitField(null, field, type, null); - JavaMappedProperty prop = type.getProperties().get("test"); - assertNotNull(prop.getDefaultValueFactory()); - } - - public void testVisitConstructor() throws Exception { - Constructor ctor = Foo.class.getConstructor(String.class); - PojoComponentType> type = - new PojoComponentType>(); - processor.visitConstructor(null, ctor, type, null); - ConstructorDefinition def = type.getConstructorDefinition(); - assertEquals("test", def.getInjectionNames().get(0)); - assertNotNull(type.getProperties().get("test")); - } - - @SuppressWarnings("unchecked") - protected void setUp() throws Exception { - super.setUp(); - ImplementationProcessorService service = EasyMock.createMock(ImplementationProcessorService.class); - service.addName(EasyMock.isA(List.class), EasyMock.eq(0), EasyMock.eq("test")); - EasyMock.expectLastCall().andStubAnswer(new IAnswer() { - public Object answer() throws Throwable { - ((List) EasyMock.getCurrentArguments()[0]).add("test"); - return null; - } - }); - EasyMock.replay(service); - processor = new TestProcessor(service); - } - - @Retention(RUNTIME) - private @interface Bar { - - } - - private class TestProcessor extends AbstractPropertyProcessor { - - public TestProcessor(ImplementationProcessorService service) { - super(Bar.class, service); - } - - @SuppressWarnings("unchecked") - protected void initProperty(JavaMappedProperty property, - Bar annotation, - CompositeComponent parent, - DeploymentContext context) { - property.setDefaultValueFactory(EasyMock.createMock(ObjectFactory.class)); - property.setName("test"); - } - - protected String getName(Bar annotation) { - return "test"; - } - } - - - private static class Foo { - - @Bar - protected String d; - - public Foo(String a, @Bar String b) { - } - - public Foo(@Bar String d) { - this.d = d; - } - - @Bar - public void setBar(String d) { - this.d = d; - } - - @Bar - public void setNoParamsBar() { - } - - @Bar - public String setBadBar(String d) { - return null; - } - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/loader/LoaderExceptionTestCase.java b/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/loader/LoaderExceptionTestCase.java deleted file mode 100644 index f8c991f7d4..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/loader/LoaderExceptionTestCase.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.spi.loader; - -import junit.framework.TestCase; - -/** - * @version $Rev$ $Date$ - */ -public class LoaderExceptionTestCase extends TestCase { - - public void testResourceURI() throws Exception { - LoaderException e = new LoaderException(); - e.setResourceURI("test"); - assertEquals("test", e.getResourceURI()); - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/model/CompositeComponentTypeTestCase.java b/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/model/CompositeComponentTypeTestCase.java deleted file mode 100644 index d348d2b3c8..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/model/CompositeComponentTypeTestCase.java +++ /dev/null @@ -1,43 +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.spi.model; - -import junit.framework.TestCase; - -public class CompositeComponentTypeTestCase extends TestCase { - - public void testWireCreationAndRetrieval() throws Exception { - WireDefinition wire1 = new WireDefinition(); - WireDefinition wire2 = new WireDefinition(); - - CompositeComponentType composite = new CompositeComponentType(); - CompositeComponentType includedComposite = new CompositeComponentType(); - includedComposite.add(wire1); - Include compositeInclude = new Include(); - compositeInclude.setIncluded(includedComposite); - - composite.add(compositeInclude); - composite.add(wire1); - - assertEquals(1, composite.getDeclaredWires().size()); - assertEquals(wire1, composite.getDeclaredWires().get(0)); - assertEquals(2, composite.getWires().size()); - } - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/model/IntentNameTestCase.java b/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/model/IntentNameTestCase.java deleted file mode 100644 index 7bd2e61ba4..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/model/IntentNameTestCase.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.apache.tuscany.spi.model; - -import java.util.Arrays; - -import junit.framework.TestCase; - -public class IntentNameTestCase extends TestCase { - - public void testConstructor() throws Exception { - String case1 = "sec.confidentiality/message/body"; - IntentName intentName = new IntentName(case1); - assertEquals("sec", intentName.getDomain()); - assertEquals(case1, intentName.toString()); - assertTrue(Arrays.equals(new String[]{"confidentiality", "message", "body"}, intentName.getQualifiedNames())); - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/model/OperationTestCase.java b/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/model/OperationTestCase.java deleted file mode 100644 index de5f1719b0..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/model/OperationTestCase.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.spi.model; - -import java.util.ArrayList; -import java.util.List; - -import static org.apache.tuscany.spi.model.Operation.NO_CONVERSATION; - -import junit.framework.TestCase; - -/** - * @version $Rev$ $Date$ - */ -public class OperationTestCase extends TestCase { - - public void testClone() throws Exception { - DataType stringType = new DataType("xml:string", String.class, String.class); - List> inputTypes = new ArrayList>(); - inputTypes.add(stringType); - DataType>> inputType = - new DataType>>("xml:string", Object[].class, inputTypes); - - DataType faultType = new DataType("xml:foo", String.class, String.class); - List> faultTypes = new ArrayList>(); - faultTypes.add(faultType); - - Operation operation1 = - new Operation("call", inputType, stringType, faultTypes, true, "xml:string", NO_CONVERSATION); - Operation operation2 = operation1.clone(); - assertEquals(operation1, operation2); - assertEquals(NO_CONVERSATION, operation2.getConversationSequence()); - assertEquals("call", operation2.getName()); - } - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/model/ScopeTestCase.java b/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/model/ScopeTestCase.java deleted file mode 100644 index a8a88626ec..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/model/ScopeTestCase.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.spi.model; - -import junit.framework.TestCase; - -/** - * @version $Rev$ $Date$ - */ -public class ScopeTestCase extends TestCase { - - public void testEquals() throws Exception { - Scope scope = new Scope("COMPOSITE"); - assertTrue(scope.equals(Scope.COMPOSITE)); - } - - public void testEqualsNew() throws Exception { - Scope foo = new Scope("foo"); - Scope foo2 = new Scope("FOO"); - assertTrue(foo.equals(foo2)); - } - - public void testNotEquals() throws Exception { - Scope foo = new Scope("BAR"); - Scope foo2 = new Scope("FOO"); - assertFalse(foo.equals(foo2)); - } - - public void testNotEqualsDifferent() throws Exception { - Scope foo = new Scope("FOO"); - assertFalse(foo.equals(new Bar("FOO"))); - } - - public class Bar { - private String scope; - - public Bar(String scope) { - this.scope = scope; - } - } - - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/model/ServiceContractTestCase.java b/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/model/ServiceContractTestCase.java deleted file mode 100644 index 4cf98d1542..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/model/ServiceContractTestCase.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.spi.model; - -import static org.apache.tuscany.spi.model.Operation.NO_CONVERSATION; - -import java.util.Map; -import java.util.HashMap; -import java.lang.reflect.Type; - -import junit.framework.TestCase; - -/** - * @version $Rev$ $Date$ - */ -public class ServiceContractTestCase extends TestCase { - - @SuppressWarnings("unchecked") - public void testAddOperation() throws Exception { - ServiceContract contract = new TestContract(); - Operation operation = new Operation("foo", null, null, null, false, null, NO_CONVERSATION); - Map> ops = new HashMap>(); - ops.put("foo", operation); - contract.setOperations(ops); - assertEquals(contract, operation.getServiceContract()); - assertFalse(operation.isCallback()); - } - - public void testAddCallbackOperation() throws Exception { - ServiceContract contract = new TestContract(); - Operation operation = new Operation("foo", null, null, null, false, null, NO_CONVERSATION); - Map> ops = new HashMap>(); - ops.put("foo", operation); - contract.setCallbackOperations(ops); - assertEquals(contract, operation.getServiceContract()); - assertTrue(operation.isCallback()); - } - - @SuppressWarnings("unchecked") - public void testClone() throws Exception { - ServiceContract contract = new TestContract(); - Operation operation = new Operation("foo", null, null, null, false, null, NO_CONVERSATION); - Map> ops = new HashMap>(); - ops.put("foo", operation); - contract.setOperations(ops); - - operation = new Operation("bar", null, null, null, false, null, NO_CONVERSATION); - Map> callbackOps = new HashMap>(); - ops.put("bar", operation); - contract.setCallbackOperations(callbackOps); - - ServiceContract copy = (ServiceContract) contract.clone(); - assertEquals(contract, copy); - } - - - private class TestContract extends ServiceContract { - - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/policy/SourcePolicyBuilderExtensionTestCase.java b/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/policy/SourcePolicyBuilderExtensionTestCase.java deleted file mode 100644 index 38f432ffac..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/policy/SourcePolicyBuilderExtensionTestCase.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.spi.policy; - -import org.apache.tuscany.spi.builder.BuilderException; -import org.apache.tuscany.spi.model.ReferenceDefinition; -import static org.apache.tuscany.spi.policy.PolicyBuilderRegistry.EXTENSION; -import org.apache.tuscany.spi.wire.OutboundWire; - -import junit.framework.TestCase; -import org.easymock.EasyMock; - -/** - * @version $Rev$ $Date$ - */ -public class SourcePolicyBuilderExtensionTestCase extends TestCase { - - public void testRegister() throws Exception { - PolicyBuilderRegistry registry = EasyMock.createMock(PolicyBuilderRegistry.class); - registry.registerSourceBuilder(EasyMock.eq(EXTENSION), EasyMock.isA(MockPolicyBuilderExtension.class)); - EasyMock.replay(registry); - SourcePolicyBuilderExtension extension = new MockPolicyBuilderExtension(); - extension.setRegistry(registry); - extension.init(); - EasyMock.verify(registry); - } - - private static class MockPolicyBuilderExtension extends SourcePolicyBuilderExtension { - - public void build(ReferenceDefinition definition, OutboundWire wire) throws BuilderException { - - } - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/policy/TargetPolicyBuilderExtensionTestCase.java b/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/policy/TargetPolicyBuilderExtensionTestCase.java deleted file mode 100644 index 58488236e2..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/policy/TargetPolicyBuilderExtensionTestCase.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.spi.policy; - -import org.apache.tuscany.spi.builder.BuilderException; -import org.apache.tuscany.spi.model.ServiceDefinition; -import static org.apache.tuscany.spi.policy.PolicyBuilderRegistry.EXTENSION; -import org.apache.tuscany.spi.wire.InboundWire; - -import junit.framework.TestCase; -import org.easymock.EasyMock; - -/** - * @version $Rev$ $Date$ - */ -public class TargetPolicyBuilderExtensionTestCase extends TestCase { - - public void testRegister() throws Exception { - PolicyBuilderRegistry registry = EasyMock.createMock(PolicyBuilderRegistry.class); - registry.registerTargetBuilder(EasyMock.eq(EXTENSION), EasyMock.isA(MockPolicyBuilderExtension.class)); - EasyMock.replay(registry); - TargetPolicyBuilderExtension extension = new MockPolicyBuilderExtension(); - extension.setRegistry(registry); - extension.init(); - EasyMock.verify(registry); - } - - private static class MockPolicyBuilderExtension extends TargetPolicyBuilderExtension { - - public void build(ServiceDefinition definition, InboundWire wire) throws BuilderException { - - } - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/util/MockSCAExternalizable.java b/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/util/MockSCAExternalizable.java deleted file mode 100644 index 8c85d4eb95..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/util/MockSCAExternalizable.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.spi.util; - -import java.io.Serializable; - -import org.apache.tuscany.spi.component.ReactivationException; -import org.apache.tuscany.spi.component.SCAExternalizable; -import org.apache.tuscany.spi.component.WorkContext; - -/** - * @version $Rev$ $Date$ - */ -@SuppressWarnings({"SerializableHasSerializationMethods"}) -public class MockSCAExternalizable implements Serializable, SCAExternalizable { - private static final long serialVersionUID = 5071815222959279772L; - - private WorkContext context; - private boolean activated; - - public void setWorkContext(WorkContext context) { - this.context = context; - } - - public WorkContext getContext() { - return context; - } - - public void reactivate() throws ReactivationException { - activated = true; - } - - public boolean isActivated() { - return activated; - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/util/MockSerializable.java b/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/util/MockSerializable.java deleted file mode 100644 index 3f34e1d0c7..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/util/MockSerializable.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.spi.util; - -import java.io.Serializable; - -/** - * @version $Rev$ $Date$ - */ -@SuppressWarnings({"SerializableHasSerializationMethods"}) -public class MockSerializable implements Serializable { - private static final long serialVersionUID = 4013396228070042469L; - - private MockSCAExternalizable externalizable; - - public MockSerializable() { - } - - public MockSCAExternalizable getExternalizable() { - return externalizable; - } - - public void setExternalizable(MockSCAExternalizable externalizable) { - this.externalizable = externalizable; - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/util/SCAObjectInputStreamTestCase.java b/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/util/SCAObjectInputStreamTestCase.java deleted file mode 100644 index 0a34210b6c..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/util/SCAObjectInputStreamTestCase.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.spi.util; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.ObjectOutputStream; - -import org.apache.tuscany.spi.component.WorkContext; - -import junit.framework.TestCase; -import org.easymock.EasyMock; - -/** - * @version $Rev$ $Date$ - */ -public class SCAObjectInputStreamTestCase extends TestCase { - - public void testSCAExternalizable() throws Exception { - WorkContext context = EasyMock.createMock(WorkContext.class); - MockSCAExternalizable ext = new MockSCAExternalizable(); - MockSerializable serializable = new MockSerializable(); - serializable.setExternalizable(ext); - ByteArrayOutputStream bas = new ByteArrayOutputStream(); - ObjectOutputStream o = new ObjectOutputStream(bas); - o.writeObject(serializable); - o.close(); - ByteArrayInputStream bytes = new ByteArrayInputStream(bas.toByteArray()); - SCAObjectInputStream stream = new SCAObjectInputStream(bytes, context); - MockSerializable deserialized = (MockSerializable) stream.readObject(); - MockSCAExternalizable deserializedExt = deserialized.getExternalizable(); - assertTrue(deserializedExt.isActivated()); - assertEquals(context, deserializedExt.getContext()); - } -} diff --git a/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/wire/AbstractInboundInvocationHandlerTestCase.java b/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/wire/AbstractInboundInvocationHandlerTestCase.java deleted file mode 100644 index 39611054e8..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/wire/AbstractInboundInvocationHandlerTestCase.java +++ /dev/null @@ -1,55 +0,0 @@ -package org.apache.tuscany.spi.wire; - -import java.lang.reflect.Array; - -import junit.framework.TestCase; -import org.easymock.EasyMock; - -/** - * @version $Rev$ $Date$ - */ -public class AbstractInboundInvocationHandlerTestCase extends TestCase { - - public void testInvocation() throws Throwable { - InvocationHandler handler = new InvocationHandler(); - Interceptor interceptor = new MockInterceptor(); - TargetInvoker invoker = EasyMock.createMock(TargetInvoker.class); - EasyMock.replay(invoker); - InboundInvocationChain chain = EasyMock.createMock(InboundInvocationChain.class); - EasyMock.expect(chain.getHeadInterceptor()).andReturn(interceptor); - EasyMock.replay(chain); - Object resp = handler.invoke(chain, invoker, new String[]{"foo"}); - assertEquals("response", resp); - } - - - private class InvocationHandler extends AbstractInboundInvocationHandler { - - } - - private class MockInterceptor implements Interceptor { - - public Message invoke(Message msg) { - assertNotNull(msg.getCorrelationId()); - assertNotNull(msg.getTargetInvoker()); - assertNotNull(msg.getMessageId()); - assertEquals("foo", Array.get(msg.getBody(), 0)); - msg.setBody("response"); - return msg; - } - - public void setNext(Interceptor next) { - - } - - public Interceptor getNext() { - return null; - } - - public boolean isOptimizable() { - return false; - } - } - - -} \ No newline at end of file diff --git a/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/wire/AbstractOutboundInvocationHandlerTestCase.java b/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/wire/AbstractOutboundInvocationHandlerTestCase.java deleted file mode 100644 index 617a055e78..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/wire/AbstractOutboundInvocationHandlerTestCase.java +++ /dev/null @@ -1,102 +0,0 @@ -package org.apache.tuscany.spi.wire; - -import java.lang.reflect.Array; -import java.lang.reflect.InvocationTargetException; -import java.util.LinkedList; - -import junit.framework.TestCase; -import org.easymock.EasyMock; - -/** - * @version $Rev$ $Date$ - */ -public class AbstractOutboundInvocationHandlerTestCase extends TestCase { - - public void testInvocation() throws Throwable { - InvocationHandler handler = new InvocationHandler(); - Interceptor interceptor = new MockInterceptor(); - TargetInvoker invoker = EasyMock.createMock(TargetInvoker.class); - EasyMock.replay(invoker); - OutboundInvocationChain chain = EasyMock.createMock(OutboundInvocationChain.class); - EasyMock.expect(chain.getHeadInterceptor()).andReturn(interceptor); - EasyMock.replay(chain); - Object resp = handler.invoke(chain, invoker, new String[]{"foo"}, null, new LinkedList()); - assertEquals("response", resp); - } - - public void testShortCircuitInvocation() throws Throwable { - InvocationHandler handler = new InvocationHandler(); - TargetInvoker invoker = new MockInvoker(); - OutboundInvocationChain chain = EasyMock.createMock(OutboundInvocationChain.class); - EasyMock.expect(chain.getHeadInterceptor()).andReturn(null); - EasyMock.expect(chain.getTargetInvoker()).andReturn(invoker); - EasyMock.replay(chain); - Object resp = handler.invoke(chain, invoker, new String[]{"foo"}, null, new LinkedList()); - assertEquals("response", resp); - } - - - private class MockInvoker implements TargetInvoker { - - public Object invokeTarget(final Object payload, final short sequence) throws InvocationTargetException { - assertEquals("foo", Array.get(payload, 0)); - return "response"; - } - - public Message invoke(Message msg) throws InvocationRuntimeException { - fail(); - return null; - } - - public boolean isCacheable() { - return false; - } - - public void setCacheable(boolean cacheable) { - - } - - public boolean isOptimizable() { - return false; - } - - public Object clone() throws CloneNotSupportedException { - return super.clone(); - } - } - - private class InvocationHandler extends AbstractOutboundInvocationHandler { - - protected Object getFromAddress() { - return new Object(); - } - - } - - private class MockInterceptor implements Interceptor { - - public Message invoke(Message msg) { - assertNotNull(msg.getCorrelationId()); - assertNotNull(msg.getTargetInvoker()); - assertNotNull(msg.getMessageId()); - assertNotNull(msg.getCallbackRoutingChain()); - assertEquals("foo", Array.get(msg.getBody(), 0)); - msg.setBody("response"); - return msg; - } - - public void setNext(Interceptor next) { - - } - - public Interceptor getNext() { - return null; - } - - public boolean isOptimizable() { - return false; - } - } - - -} diff --git a/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/wire/OutboundChainHolderTestCase.java b/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/wire/OutboundChainHolderTestCase.java deleted file mode 100644 index cbce805151..0000000000 --- a/branches/pre-spec-changes/kernel/spi/src/test/java/org/apache/tuscany/spi/wire/OutboundChainHolderTestCase.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.spi.wire; - -import junit.framework.TestCase; -import org.easymock.EasyMock; - -/** - * @version $Rev$ $Date$ - */ -public class OutboundChainHolderTestCase extends TestCase { - - public void testClone() { - OutboundInvocationChain chain = EasyMock.createMock(OutboundInvocationChain.class); - EasyMock.replay(chain); - OutboundChainHolder holder = new OutboundChainHolder(chain); - assertNotNull(holder.clone()); - } -} -- cgit v1.2.3