summaryrefslogtreecommitdiffstats
path: root/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime
diff options
context:
space:
mode:
authorlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2009-11-11 23:06:42 +0000
committerlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2009-11-11 23:06:42 +0000
commitf860c2f35b2f94e379d2ff7d5c13f54cd4a3132a (patch)
tree5808b087a5eb9f5d251932d6828565f6c5d4ed9e /sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime
parent587877fcbd358e233f653e01c4b3ed3354203626 (diff)
Moving 1.x branches
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@835119 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime')
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/.checkstyle24
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/.pmd20
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/.ruleset190
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/DISCLAIMER8
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/LICENSE205
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/NOTICE6
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/pom.xml68
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/InstanceFactory.java43
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/InstanceFactoryProvider.java49
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/JavaPropertyValueObjectFactory.java204
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceFactory.java86
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceWrapper.java56
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/TargetMethodNotFoundException.java45
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ArrayMultiplicityObjectFactory.java54
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ContextInjector.java32
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ConversationIDObjectFactory.java32
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/EventInvoker.java34
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/FieldInjector.java57
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/InjectionRuntimeException.java45
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/Injector.java35
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/InvalidAccessorException.java42
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/InvalidResourceTypeException.java46
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/JNDIObjectFactory.java50
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ListMultiplicityObjectFactory.java50
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/MethodEventInvoker.java55
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/MethodInjector.java55
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/NoAccessorException.java39
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/NoMultiplicityTypeException.java42
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ObjectCallbackException.java44
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/PojoObjectFactory.java120
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/RequestContextObjectFactory.java40
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ResourceHost.java46
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ResourceNotFoundException.java46
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ResourceObjectFactory.java87
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ResourceResolutionException.java43
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/SingletonObjectFactory.java39
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/InvalidConversationSequenceException.java45
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentInfo.java414
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProvider.java174
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProviderFactory.java56
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaTargetInvoker.java159
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/NoConversationalContractException.java34
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/PassByValueInvoker.java117
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/PojoComponentContextFactory.java40
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/PojoConfiguration.java218
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/TargetInvoker.java69
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/TargetInvokerInvoker.java49
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/module/JavaRuntimeModuleActivator.java136
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/monitor/ExceptionFormatter.java34
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/monitor/ExceptionFormatterImpl.java43
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/monitor/FormatterRegistry.java42
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/monitor/InvalidLevelException.java64
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/monitor/JavaLoggingMonitorFactory.java118
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/monitor/MonitorFactory.java51
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/monitor/MonitorFactoryUtil.java77
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/monitor/NullMonitorFactory.java66
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/monitor/ProxyMonitorFactory.java231
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator18
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/context/ModelHelper.java99
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/context/MultiplicityTestCase.java34
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceWrapperTestCase.java83
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/CallbackWireObjectFactoryTestCase.java54
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/FieldInjectorTestCase.java48
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/JNDIObjectFactoryTestCase.java61
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/MethodEventInvokerTestCase.java72
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/MethodInjectorTestCase.java79
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/PojoObjectFactoryTestCase.java76
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/RequestContextObjectFactoryTestCase.java33
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/ResourceObjectFactoryTestCase.java89
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/SingletonObjectFactoryTestCase.java33
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration/AbstractConversationTestCase.java51
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration/ConversationIdleExpireTestCase.java.FIXME149
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration/ConversationMaxAgeExpireTestCase.java.FIXME153
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration/ConversationStartStopEndTestCase.java.FIXME147
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration/ReferenceInjectionTestCase.java.FIXME79
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/AsyncTarget.java31
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/BadContextPojo.java28
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/BadNamePojo.java26
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/BasicInterface.java30
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/BasicInterfaceImpl.java66
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/CompositeScopeComponent.java31
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/CompositeScopeComponentImpl.java40
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/CompositeScopeDestroyOnlyComponent.java36
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/CompositeScopeInitDestroyComponent.java39
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/CompositeScopeInitOnlyComponent.java42
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/ConversationalScopeComponent.java29
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/ConversationalScopeComponentImpl.java29
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/ConversationalScopeDestroyOnlyComponent.java37
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/ConversationalScopeInitDestroyComponent.java38
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/ConversationalScopeInitOnlyComponent.java38
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/MockFactory.java.FIXME214
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/MockStaticInvoker.java94
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/MockSyncInterceptor.java52
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OrderException.java40
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OrderedDependentPojo.java29
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OrderedDependentPojoImpl.java36
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OrderedEagerInitPojo.java60
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OrderedInitPojo.java28
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OrderedInitPojoImpl.java61
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OtherTarget.java31
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OtherTargetImpl.java39
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/RequestScopeComponent.java30
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/RequestScopeDestroyOnlyComponent.java38
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/RequestScopeInitDestroyComponent.java38
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/RequestScopeInitOnlyComponent.java39
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SessionScopeComponent.java30
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SessionScopeComponentImpl.java30
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SessionScopeInitDestroyComponent.java36
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SessionScopeInitOnlyComponent.java37
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SimpleTarget.java30
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SimpleTargetImpl.java41
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/Source.java37
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SourceImpl.java63
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/StatelessComponent.java30
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/StatelessComponentImpl.java27
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/Target.java32
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/TargetImpl.java38
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/monitor/ExceptionFormatterTestCase.java57
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/monitor/JavaLoggingTestCase.java152
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/Bean1.java45
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/Bean2.java47
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/JavaIntrospectionHelperTestCase.java182
-rw-r--r--sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/SuperBean.java48
123 files changed, 8063 insertions, 0 deletions
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/.checkstyle b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/.checkstyle
new file mode 100644
index 0000000000..3e57539570
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/.checkstyle
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<fileset-config file-format-version="1.2.0" simple-config="true">
+ <fileset name="all" enabled="true" check-config-name="Tuscany Checks" local="false">
+ <file-match-pattern match-pattern="." include-pattern="true"/>
+ </fileset>
+</fileset-config>
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/.pmd b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/.pmd
new file mode 100644
index 0000000000..4abfdec2b5
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/.pmd
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<pmd><useProjectRuleSet>true</useProjectRuleSet><rules/><includeDerivedFiles>false</includeDerivedFiles></pmd> \ No newline at end of file
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/.ruleset b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/.ruleset
new file mode 100644
index 0000000000..ba9b5ce886
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/.ruleset
@@ -0,0 +1,190 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<ruleset name="pmd-eclipse">
+ <description>PMD Plugin preferences rule set</description>
+
+
+ <rule ref="rulesets/basic.xml/BooleanInstantiation"/>
+ <rule ref="rulesets/basic.xml/CollapsibleIfStatements"/>
+ <rule ref="rulesets/basic.xml/DoubleCheckedLocking"/>
+<!--<rule ref="rulesets/basic.xml/EmptyCatchBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyFinallyBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyIfStmt"/>-->
+ <rule ref="rulesets/basic.xml/EmptyStatementNotInLoop"/>
+<!--<rule ref="rulesets/basic.xml/EmptyStaticInitializer"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptySwitchStatements"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptySynchronizedBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyTryBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyWhileStmt"/>-->
+ <rule ref="rulesets/basic.xml/ForLoopShouldBeWhileLoop"/>
+ <rule ref="rulesets/basic.xml/JumbledIncrementer"/>
+<!--<rule ref="rulesets/basic.xml/OverrideBothEqualsAndHashcode"/>-->
+ <rule ref="rulesets/basic.xml/ReturnFromFinallyBlock"/>
+ <rule ref="rulesets/basic.xml/UnconditionalIfStatement"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryConversionTemporary"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryFinalModifier"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryReturn"/>
+<!--<rule ref="rulesets/basic.xml/UselessOverridingMethod"/>-->
+
+<!--<rule ref="rulesets/braces.xml/ForLoopsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/IfElseStmtsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/IfStmtsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/WhileLoopsMustUseBraces"/>-->
+
+<!--<rule ref="rulesets/clone.xml/CloneMethodMustImplementCloneable"/>-->
+<!--<rule ref="rulesets/clone.xml/CloneThrowsCloneNotSupportedException"/>-->
+<!--<rule ref="rulesets/clone.xml/ProperCloneImplementation"/>-->
+
+<!--<rule ref="rulesets/codesize.xml/CyclomaticComplexity"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveClassLength"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveMethodLength"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveParameterList"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessivePublicCount"/>-->
+<!--<rule ref="rulesets/codesize.xml/TooManyFields"/>-->
+
+<rule ref="rulesets/controversial.xml/AssignmentInOperand"/>
+<!--<rule ref="rulesets/controversial.xml/AtLeastOneConstructor"/>-->
+<!--<rule ref="rulesets/controversial.xml/CallSuperInConstructor"/>-->
+<!--<rule ref="rulesets/controversial.xml/DontImportSun"/>-->
+<!--<rule ref="rulesets/controversial.xml/NullAssignment"/>-->
+<!--<rule ref="rulesets/controversial.xml/OnlyOneReturn"/>-->
+<!--<rule ref="rulesets/controversial.xml/SingularField"/>-->
+<!--<rule ref="rulesets/controversial.xml/SuspiciousOctalEscape"/>-->
+<!--<rule ref="rulesets/controversial.xml/UnnecessaryConstructor"/>-->
+<rule ref="rulesets/controversial.xml/UnnecessaryParentheses"/>
+<!--<rule ref="rulesets/controversial.xml/UnusedModifier"/>-->
+
+<!--<rule ref="rulesets/coupling.xml/CouplingBetweenObjects"/>-->
+<!--<rule ref="rulesets/coupling.xml/ExcessiveImports"/>-->
+<!--<rule ref="rulesets/coupling.xml/LooseCoupling"/>-->
+
+<!--<rule ref="rulesets/design.xml/AbstractClassWithoutAbstractMethod"/>-->
+<!--<rule ref="rulesets/design.xml/AccessorClassGeneration"/>-->
+<!--<rule ref="rulesets/design.xml/AssignmentToNonFinalStatic"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidDeeplyNestedIfStmts"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidInstanceofChecksInCatchClause"/>-->
+<rule ref="rulesets/design.xml/AvoidProtectedFieldInFinalClass"/>
+<!--<rule ref="rulesets/design.xml/AvoidReassigningParameters"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidSynchronizedAtMethodLevel"/>-->
+<!--<rule ref="rulesets/design.xml/BadComparison"/>-->
+<!--<rule ref="rulesets/design.xml/CloseConnection"/>-->
+<!--<rule ref="rulesets/design.xml/CompareObjectsWithEquals"/>-->
+<!--<rule ref="rulesets/design.xml/ConfusingTernary"/>-->
+<rule ref="rulesets/design.xml/ConstructorCallsOverridableMethod"/>
+<!--<rule ref="rulesets/design.xml/DefaultLabelNotLastInSwitchStmt"/>-->
+<!--<rule ref="rulesets/design.xml/FinalFieldCouldBeStatic"/>-->
+<rule ref="rulesets/design.xml/IdempotentOperations"/>
+<!--<rule ref="rulesets/design.xml/ImmutableField"/>-->
+<!--<rule ref="rulesets/design.xml/InstantiationToGetClass"/>-->
+<!--<rule ref="rulesets/design.xml/MissingBreakInSwitch"/>-->
+<!--<rule ref="rulesets/design.xml/MissingStaticMethodInNonInstantiatableClass"/>-->
+<!--<rule ref="rulesets/design.xml/NonCaseLabelInSwitchStatement"/>-->
+<!--<rule ref="rulesets/design.xml/NonStaticInitializer"/>-->
+<rule ref="rulesets/design.xml/OptimizableToArrayCall"/>
+<rule ref="rulesets/design.xml/PositionLiteralsFirstInComparisons"/>
+<rule ref="rulesets/design.xml/SimplifyBooleanExpressions"/>
+<rule ref="rulesets/design.xml/SimplifyBooleanReturns"/>
+<rule ref="rulesets/design.xml/SimplifyConditional"/>
+<!--<rule ref="rulesets/design.xml/SwitchDensity"/>-->
+<!--<rule ref="rulesets/design.xml/SwitchStmtsShouldHaveDefault"/>-->
+<!--<rule ref="rulesets/design.xml/UnnecessaryLocalBeforeReturn"/>-->
+<!--<rule ref="rulesets/design.xml/UseLocaleWithCaseConversions"/>-->
+<!--<rule ref="rulesets/design.xml/UseNotifyAllInsteadOfNotify"/>-->
+<!--<rule ref="rulesets/design.xml/UseSingleton"/>-->
+
+<!--<rule ref="rulesets/finalizers.xml/EmptyFinalizer"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeOnlyCallsSuperFinalize"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeOverloaded"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeDoesNotCallSuperFinalize"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeShouldBeProtected"/>-->
+<!--<rule ref="rulesets/finalizers.xml/AvoidCallingFinalize"/>-->
+
+<!--<rule ref="rulesets/imports.xml/DuplicateImports"/>-->
+<!--<rule ref="rulesets/imports.xml/DontImportJavaLang"/>-->
+<!--<rule ref="rulesets/imports.xml/UnusedImports"/>-->
+<!--<rule ref="rulesets/imports.xml/ImportFromSamePackage"/>-->
+
+<!--<rule ref="rulesets/javabeans.xml/BeanMembersShouldSerialize"/>-->
+<!--<rule ref="rulesets/javabeans.xml/MissingSerialVersionUID"/>-->
+
+<!--<rule ref="rulesets/junit.xml/JUnitStaticSuite"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitSpelling"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitAssertionsShouldIncludeMessage"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitTestsShouldIncludeAssert"/>-->
+<!--<rule ref="rulesets/junit.xml/TestClassWithoutTestCases"/>-->
+<!--<rule ref="rulesets/junit.xml/UnnecessaryBooleanAssertion"/>-->
+<!--<rule ref="rulesets/junit.xml/UseAssertEqualsInsteadOfAssertTrue"/>-->
+<!--<rule ref="rulesets/junit.xml/UseAssertSameInsteadOfAssertTrue"/>-->
+
+ <!--<rule ref="rulesets/logging-java.xml/AvoidPrintStackTrace"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LoggerIsNotStaticFinal"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/MoreThanOneLogger"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LoggerIsNotStaticFinal"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LogBlockWithoutIf"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/SystemPrintln"/>-->
+ <!--<rule ref="rulesets/logging-jakarta-commons.xml/UseCorrectExceptionLogging"/>-->
+ <!--<rule ref="rulesets/logging-jakarta-commons.xml/ProperLogger"/>-->
+
+ <!--<rule ref="rulesets/naming.xml/ShortVariable"/>-->
+ <!--<rule ref="rulesets/naming.xml/LongVariable"/>-->
+ <!--<rule ref="rulesets/naming.xml/ShortMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/VariableNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/MethodNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/ClassNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/AbstractNaming"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidDollarSigns"/>-->
+ <!--<rule ref="rulesets/naming.xml/MethodWithSameNameAsEnclosingClass"/>-->
+ <!--<rule ref="rulesets/naming.xml/SuspiciousHashcodeMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/SuspiciousConstantFieldName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidFieldNameMatchingTypeName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidFieldNameMatchingMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidNonConstructorMethodsWithClassName"/>-->
+ <!--<rule ref="rulesets/naming.xml/NoPackage"/>-->
+ <!--<rule ref="rulesets/naming.xml/PackageCase"/>-->
+
+ <!--<rule ref="rulesets/optimizations.xml/LocalVariableCouldBeFinal"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/MethodArgumentCouldBeFinal"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/AvoidInstantiatingObjectsInLoops"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/UseArrayListInsteadOfVector"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/SimplifyStartsWith"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/UseStringBufferForStringAppends"/>-->
+
+ <!--<rule ref="rulesets/strictexception.xml/AvoidCatchingThrowable"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/SignatureDeclareThrowsException"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/ExceptionAsFlowControl"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidCatchingNPE"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidThrowingRawExceptionTypes"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidThrowingNullPointerException"/>-->
+
+ <!--<rule ref="rulesets/strings.xml/AvoidDuplicateLiterals"/>-->
+ <!--<rule ref="rulesets/strings.xml/StringInstantiation"/>-->
+ <!--<rule ref="rulesets/strings.xml/StringToString"/>-->
+ <!--<rule ref="rulesets/strings.xml/AvoidConcatenatingNonLiteralsInStringBuffer"/>-->
+ <!--<rule ref="rulesets/strings.xml/UnnecessaryCaseChange"/>-->
+
+ <!--<rule ref="rulesets/sunsecure.xml/MethodReturnsInternalArray"/>-->
+ <!--<rule ref="rulesets/sunsecure.xml/ArrayIsStoredDirectly"/>-->
+
+ <rule ref="rulesets/unusedcode.xml/UnusedLocalVariable"/>
+ <rule ref="rulesets/unusedcode.xml/UnusedPrivateField"/>
+ <rule ref="rulesets/unusedcode.xml/UnusedPrivateMethod"/>
+ <!--<rule ref="rulesets/unusedcode.xml/UnusedFormalParameter"/>-->
+
+</ruleset>
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/DISCLAIMER b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/DISCLAIMER
new file mode 100644
index 0000000000..d68a410903
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/DISCLAIMER
@@ -0,0 +1,8 @@
+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.
+
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/LICENSE b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/LICENSE
@@ -0,0 +1,205 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+
+
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/NOTICE b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/NOTICE
new file mode 100644
index 0000000000..94481d6cfa
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2007 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/pom.xml b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/pom.xml
new file mode 100644
index 0000000000..35401a54ad
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/pom.xml
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-modules</artifactId>
+ <version>0.90-incubating-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <name>Apache Tuscany Java Implementation Runtime</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core</artifactId>
+ <version>0.90-incubating-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface</artifactId>
+ <version>0.90-incubating-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ <version>0.90-incubating-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java</artifactId>
+ <version>0.90-incubating-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-xml</artifactId>
+ <version>0.90-incubating-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution-impl</artifactId>
+ <version>0.90-incubating-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding</artifactId>
+ <version>0.90-incubating-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/InstanceFactory.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/InstanceFactory.java
new file mode 100644
index 0000000000..a803311a78
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/InstanceFactory.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.context;
+
+import org.apache.tuscany.sca.scope.InstanceWrapper;
+
+/**
+ * Interface for a factory that returns an injected component instance.
+ * This is used by a Component implementation to create new instances of
+ * application implementation objects as determined by the component scope's
+ * lifecycle.
+ * <p/>
+ * The implementation of this interface may be supplied by the user,
+ * may be generated during deployment, or may be dynamic.
+ *
+ * @version $Rev$ $Date$
+ * @param <T> Type of the instance generated by the factory.
+ */
+public interface InstanceFactory<T> {
+ /**
+ * Creates a new instance of the component.
+ * All injected values must be set but any @Init methods must not have been invoked.
+ *
+ * @return A wrapper for the created component instance.
+ */
+ InstanceWrapper<T> newInstance();
+}
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/InstanceFactoryProvider.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/InstanceFactoryProvider.java
new file mode 100644
index 0000000000..07f0f93690
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/InstanceFactoryProvider.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.context;
+
+import org.apache.tuscany.sca.factory.ObjectFactory;
+import org.apache.tuscany.sca.implementation.java.impl.JavaElementImpl;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface InstanceFactoryProvider<T> {
+ /**
+ * Return the implementation class.
+ *
+ * @return the implementation class.
+ */
+ Class<T> getImplementationClass();
+
+ /**
+ * Sets an object factory for an injection site
+ *
+ * @param element the injection site name
+ * @param objectFactory the object factory
+ */
+ void setObjectFactory(JavaElementImpl element, ObjectFactory<?> objectFactory);
+
+ /**
+ * Create an instance factory that can be used to create component instances.
+ *
+ * @return a new instance factory
+ */
+ InstanceFactory<T> createFactory();
+}
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/JavaPropertyValueObjectFactory.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/JavaPropertyValueObjectFactory.java
new file mode 100644
index 0000000000..e6176503f7
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/JavaPropertyValueObjectFactory.java
@@ -0,0 +1,204 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.context;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import org.apache.tuscany.sca.assembly.Property;
+import org.apache.tuscany.sca.databinding.Mediator;
+import org.apache.tuscany.sca.databinding.SimpleTypeMapper;
+import org.apache.tuscany.sca.databinding.impl.SimpleTypeMapperImpl;
+import org.apache.tuscany.sca.databinding.xml.DOMDataBinding;
+import org.apache.tuscany.sca.factory.ObjectCreationException;
+import org.apache.tuscany.sca.factory.ObjectFactory;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
+import org.apache.tuscany.sca.interfacedef.util.TypeInfo;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+public class JavaPropertyValueObjectFactory {
+ // protected DataBindingRegistry dbRegistry = new DataBindingRegistryImpl();
+ protected Mediator mediator = null;
+ protected SimpleTypeMapper simpleTypeMapper = new SimpleTypeMapperImpl();
+ boolean isSimpleType;
+
+ public JavaPropertyValueObjectFactory(Mediator mediator) {
+ this.mediator = mediator;
+ }
+
+ public ObjectFactory createValueFactory(Property property, Object propertyValue, Class javaType) {
+ isSimpleType = isSimpleType(property);
+ Document doc = (Document)propertyValue;
+ Element rootElement = doc.getDocumentElement();
+ if (property.isMany()) {
+ if (isSimpleType) {
+ String value = "";
+ if (rootElement.getChildNodes().getLength() > 0) {
+ value = rootElement.getChildNodes().item(0).getTextContent();
+ }
+ List<String> values = getSimplePropertyValues(value, javaType);
+ return new ListObjectFactoryImpl(property, values, isSimpleType, javaType);
+ } else {
+ return new ListObjectFactoryImpl(property, getComplexPropertyValues(doc), isSimpleType, javaType);
+ }
+ } else {
+ if (isSimpleType) {
+ String value = "";
+ if (rootElement.getChildNodes().getLength() > 0) {
+ value = rootElement.getChildNodes().item(0).getTextContent();
+ }
+ return new ObjectFactoryImpl(property, value, isSimpleType, javaType);
+ } else {
+ List<Node> nodes = getComplexPropertyValues(doc);
+ Object value = null;
+ if (!nodes.isEmpty()) {
+ value = nodes.get(0);
+ }
+ return new ObjectFactoryImpl(property, value, isSimpleType, javaType);
+ }
+
+ }
+ }
+
+ private boolean isSimpleType(Property property) {
+ if (property.getXSDType() != null) {
+ return SimpleTypeMapperImpl.isSimpleXSDType(property.getXSDType());
+ } else {
+ if (property instanceof Document) {
+ Document doc = (Document)property;
+ Element element = doc.getDocumentElement();
+ if (element.getChildNodes().getLength() == 1 && element.getChildNodes().item(0).getNodeType() == Element.TEXT_NODE) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ private List<String> getSimplePropertyValues(String concatenatedValue, Class javaType) {
+ List<String> propValues = new ArrayList<String>();
+ StringTokenizer st = null;
+ if (javaType.getName().equals("java.lang.String")) {
+ st = new StringTokenizer(concatenatedValue, "\"");
+ } else {
+ st = new StringTokenizer(concatenatedValue);
+ }
+ String aToken = null;
+ while (st.hasMoreTokens()) {
+ aToken = st.nextToken();
+ if (aToken.trim().length() > 0) {
+ propValues.add(aToken);
+ }
+ }
+ return propValues;
+ }
+
+ private List<Node> getComplexPropertyValues(Document document) {
+ Element rootElement = document.getDocumentElement();
+ List<Node> propValues = new ArrayList<Node>();
+ for (int count = 0; count < rootElement.getChildNodes().getLength(); ++count) {
+ if (rootElement.getChildNodes().item(count).getNodeType() == Document.ELEMENT_NODE) {
+ propValues.add(rootElement.getChildNodes().item(count));
+ }
+ }
+ return propValues;
+ }
+
+ public abstract class ObjectFactoryImplBase implements ObjectFactory {
+ protected SimpleTypeMapper simpleTypeMapper = new SimpleTypeMapperImpl();
+ protected Property property;
+ protected Object propertyValue;
+ protected Class javaType;
+ protected DataType<XMLType> sourceDataType;
+ protected DataType<?> targetDataType;
+ boolean isSimpleType;
+
+ public ObjectFactoryImplBase(Property property, Object propertyValue, boolean isSimpleType, Class javaType) {
+ this.isSimpleType = isSimpleType;
+ this.property = property;
+ this.propertyValue = propertyValue;
+ this.javaType = javaType;
+ sourceDataType = new DataTypeImpl<XMLType>(DOMDataBinding.NAME, Node.class, new XMLType(null, this.property
+ .getXSDType()));
+ TypeInfo typeInfo = null;
+ if (this.property.getXSDType() != null) {
+ if (SimpleTypeMapperImpl.isSimpleXSDType(this.property.getXSDType())) {
+ typeInfo = new TypeInfo(property.getXSDType(), true, null);
+ } else {
+ typeInfo = new TypeInfo(property.getXSDType(), false, null);
+ }
+ } else {
+ typeInfo = new TypeInfo(property.getXSDType(), false, null);
+ }
+
+ XMLType xmlType = new XMLType(typeInfo);
+ String dataBinding = null; // (String)property.getExtensions().get(DataBinding.class.getName());
+ if (dataBinding != null) {
+ targetDataType = new DataTypeImpl<XMLType>(dataBinding, javaType, xmlType);
+ } else {
+ targetDataType = new DataTypeImpl<XMLType>(dataBinding, javaType, xmlType);
+ mediator.getDataBindings().introspectType(targetDataType, null);
+ }
+ }
+ }
+
+ public class ObjectFactoryImpl extends ObjectFactoryImplBase {
+ public ObjectFactoryImpl(Property property, Object propertyValue, boolean isSimpleType, Class javaType) {
+ super(property, propertyValue, isSimpleType, javaType);
+ }
+
+ @SuppressWarnings("unchecked")
+ public Object getInstance() throws ObjectCreationException {
+ if (isSimpleType) {
+ return simpleTypeMapper.toJavaObject(property.getXSDType(), (String)propertyValue, null);
+ } else {
+ return mediator.mediate(propertyValue, sourceDataType, targetDataType, null);
+ // return null;
+ }
+ }
+ }
+
+ public class ListObjectFactoryImpl extends ObjectFactoryImplBase {
+ public ListObjectFactoryImpl(Property property, List<?> propertyValues, boolean isSimpleType, Class javaType) {
+ super(property, propertyValues, isSimpleType, javaType);
+ }
+
+ @SuppressWarnings("unchecked")
+ public List<?> getInstance() throws ObjectCreationException {
+ if (isSimpleType) {
+ List<Object> values = new ArrayList<Object>();
+ for (String aValue : (List<String>)propertyValue) {
+ values.add(simpleTypeMapper.toJavaObject(property.getXSDType(), aValue, null));
+ }
+ return values;
+ } else {
+ List instances = new ArrayList();
+ for (Node aValue : (List<Node>)propertyValue) {
+ instances.add(mediator.mediate(aValue, sourceDataType, targetDataType, null));
+ }
+ return instances;
+ }
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceFactory.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceFactory.java
new file mode 100644
index 0000000000..d763c03545
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceFactory.java
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.context;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+
+import org.apache.tuscany.sca.factory.ObjectCreationException;
+import org.apache.tuscany.sca.factory.ObjectFactory;
+import org.apache.tuscany.sca.implementation.java.injection.EventInvoker;
+import org.apache.tuscany.sca.implementation.java.injection.Injector;
+import org.apache.tuscany.sca.scope.InstanceWrapper;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ReflectiveInstanceFactory<T> implements InstanceFactory<T> {
+ private final Constructor<T> ctr;
+ private final ObjectFactory<?>[] ctrArgs;
+ private final Injector<T>[] injectors;
+ private final EventInvoker<T> initInvoker;
+ private final EventInvoker<T> destroyInvoker;
+
+ public ReflectiveInstanceFactory(Constructor<T> ctr,
+ ObjectFactory<?>[] ctrArgs,
+ Injector<T>[] injectors,
+ EventInvoker<T> initInvoker,
+ EventInvoker<T> destroyInvoker) {
+ this.ctr = ctr;
+ this.ctrArgs = ctrArgs;
+ this.injectors = injectors;
+ this.initInvoker = initInvoker;
+ this.destroyInvoker = destroyInvoker;
+ }
+
+ public InstanceWrapper<T> newInstance() {
+ T instance;
+ try {
+ if (ctrArgs != null) {
+ Object[] args = new Object[ctrArgs.length];
+ for (int i = 0; i < args.length; i++) {
+ args[i] = ctrArgs[i].getInstance();
+ }
+ instance = ctr.newInstance(args);
+ } else {
+ instance = ctr.newInstance();
+ }
+ } 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);
+ }
+
+ if (injectors != null) {
+ for (Injector<T> injector : injectors) {
+ //FIXME Injectors should never be null
+ if (injector != null)
+ injector.inject(instance);
+ }
+ }
+
+ return new ReflectiveInstanceWrapper<T>(instance, initInvoker, destroyInvoker);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceWrapper.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceWrapper.java
new file mode 100644
index 0000000000..31547b3e18
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceWrapper.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.context;
+
+import org.apache.tuscany.sca.implementation.java.injection.EventInvoker;
+import org.apache.tuscany.sca.scope.InstanceWrapper;
+import org.apache.tuscany.sca.scope.TargetDestructionException;
+import org.apache.tuscany.sca.scope.TargetInitializationException;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ReflectiveInstanceWrapper<T> implements InstanceWrapper<T> {
+ private final EventInvoker<T> initInvoker;
+ private final EventInvoker<T> destroyInvoker;
+ private final T instance;
+
+ public ReflectiveInstanceWrapper(T instance, EventInvoker<T> initInvoker, EventInvoker<T> destroyInvoker) {
+ this.instance = instance;
+ this.initInvoker = initInvoker;
+ this.destroyInvoker = destroyInvoker;
+ }
+
+ public T getInstance() {
+ return instance;
+ }
+
+ public void start() throws TargetInitializationException {
+ if (initInvoker != null) {
+ initInvoker.invokeEvent(instance);
+ }
+ }
+
+
+ public void stop() throws TargetDestructionException {
+ if (destroyInvoker != null) {
+ destroyInvoker.invokeEvent(instance);
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/TargetMethodNotFoundException.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/TargetMethodNotFoundException.java
new file mode 100644
index 0000000000..d987489114
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/TargetMethodNotFoundException.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.context;
+
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.scope.TargetInvokerCreationException;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class TargetMethodNotFoundException extends TargetInvokerCreationException {
+ /**
+ *
+ */
+ private static final long serialVersionUID = -8565552977647191863L;
+ private Operation operation;
+
+ /**
+ * @param operation
+ */
+ public TargetMethodNotFoundException(Operation operation) {
+ super("Target method not found for operation");
+ this.operation = operation;
+ }
+
+ public Operation getOperation() {
+ return operation;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ArrayMultiplicityObjectFactory.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ArrayMultiplicityObjectFactory.java
new file mode 100644
index 0000000000..963e5f6e7a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ArrayMultiplicityObjectFactory.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.injection;
+
+import java.lang.reflect.Array;
+import java.util.List;
+
+import org.apache.tuscany.sca.factory.ObjectCreationException;
+import org.apache.tuscany.sca.factory.ObjectFactory;
+
+/**
+ * Resolves targets configured in a multiplicity by delegating to object factories and returning an <code>Array</code>
+ * containing object instances
+ *
+ * @version $Rev$ $Date$
+ */
+public class ArrayMultiplicityObjectFactory implements ObjectFactory<Object> {
+
+ private ObjectFactory[] factories;
+
+ private Class interfaceType;
+
+ public ArrayMultiplicityObjectFactory(Class interfaceType, List<ObjectFactory<?>> 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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ContextInjector.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ContextInjector.java
new file mode 100644
index 0000000000..aba8f1a901
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ContextInjector.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.injection;
+
+import org.apache.tuscany.sca.factory.ObjectCreationException;
+
+/**
+ * Implementations inject a pre-configured context type (interface) on an instance.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ContextInjector<S, T> extends Injector<T> {
+
+ void setContext(S context) throws ObjectCreationException;
+
+}
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ConversationIDObjectFactory.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ConversationIDObjectFactory.java
new file mode 100644
index 0000000000..62958c81de
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ConversationIDObjectFactory.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.injection;
+
+import org.apache.tuscany.sca.core.invocation.ThreadMessageContext;
+import org.apache.tuscany.sca.factory.ObjectFactory;
+
+public class ConversationIDObjectFactory implements ObjectFactory<String> {
+
+ public ConversationIDObjectFactory() {
+ }
+
+ public String getInstance() {
+ return (String)ThreadMessageContext.getMessageContext().getConversationID();
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/EventInvoker.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/EventInvoker.java
new file mode 100644
index 0000000000..c2335163d6
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/EventInvoker.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.injection;
+
+/**
+ * Performs an invocation on an instance
+ *
+ * @version $Rev$ $Date$
+ */
+public interface EventInvoker<T> {
+
+ /**
+ * Performs the invocation on a given instance
+ *
+ * @throws ObjectCallbackException
+ */
+ void invokeEvent(T instance) throws ObjectCallbackException;
+}
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/FieldInjector.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/FieldInjector.java
new file mode 100644
index 0000000000..85caad103f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/FieldInjector.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.injection;
+
+import java.lang.reflect.Field;
+
+import org.apache.tuscany.sca.factory.ObjectCreationException;
+import org.apache.tuscany.sca.factory.ObjectFactory;
+
+/**
+ * Injects a value created by an {@link org.apache.tuscany.sca.factory.ObjectFactory} on a given field
+ *
+ * @version $Rev$ $Date$
+ */
+public class FieldInjector<T> implements Injector<T> {
+
+ private final Field field;
+
+ private final ObjectFactory<?> objectFactory;
+
+ /**
+ * Create an injector and have it use the given <code>ObjectFactory</code> to inject a value on the instance using
+ * the reflected <code>Field</code>
+ */
+ public FieldInjector(Field field, ObjectFactory<?> objectFactory) {
+ this.field = field;
+ this.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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/InjectionRuntimeException.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/InjectionRuntimeException.java
new file mode 100644
index 0000000000..4a8c8f31b8
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/InjectionRuntimeException.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.injection;
+
+
+/**
+ * Root unchecked exception for the injection package
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class InjectionRuntimeException extends RuntimeException {
+
+ public InjectionRuntimeException() {
+ super();
+ }
+
+ public InjectionRuntimeException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public InjectionRuntimeException(String message) {
+ super(message);
+ }
+
+ public InjectionRuntimeException(Throwable cause) {
+ super(cause);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/Injector.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/Injector.java
new file mode 100644
index 0000000000..e580f5c2c4
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/Injector.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.injection;
+
+import org.apache.tuscany.sca.factory.ObjectCreationException;
+
+/**
+ * Implementations inject a pre-configured value on an instance
+ *
+ * @version $Rev$ $Date$
+ */
+public interface Injector<T> {
+
+ /**
+ * Inject a value on the given instance
+ */
+ void inject(T instance) throws ObjectCreationException;
+
+}
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/InvalidAccessorException.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/InvalidAccessorException.java
new file mode 100644
index 0000000000..d157a1319f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/InvalidAccessorException.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.injection;
+
+/**
+ * @version $$Rev$$ $$Date$$
+ */
+public class InvalidAccessorException extends InjectionRuntimeException {
+
+ public InvalidAccessorException() {
+ super();
+ }
+
+ public InvalidAccessorException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public InvalidAccessorException(String message) {
+ super(message);
+ }
+
+ public InvalidAccessorException(Throwable cause) {
+ super(cause);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/InvalidResourceTypeException.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/InvalidResourceTypeException.java
new file mode 100644
index 0000000000..382925ed30
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/InvalidResourceTypeException.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.injection;
+
+import org.apache.tuscany.sca.factory.ObjectCreationException;
+
+/**
+ * Denotes an invalid resource type, i.e. that is not a component
+ *
+ * @version $Rev$ $Date$
+ */
+public class InvalidResourceTypeException extends ObjectCreationException {
+
+ public InvalidResourceTypeException() {
+ super();
+ }
+
+ public InvalidResourceTypeException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public InvalidResourceTypeException(String message) {
+ super(message);
+ }
+
+ public InvalidResourceTypeException(Throwable cause) {
+ super(cause);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/JNDIObjectFactory.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/JNDIObjectFactory.java
new file mode 100644
index 0000000000..750e9202a4
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/JNDIObjectFactory.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.injection;
+
+import javax.naming.Context;
+import javax.naming.NamingException;
+
+import org.apache.tuscany.sca.factory.ObjectCreationException;
+import org.apache.tuscany.sca.factory.ObjectFactory;
+
+/**
+ * An implementation of ObjectFactory that creates instances by looking them up in a JNDI context.
+ *
+ * @version $Rev$ $Date$
+ */
+public class JNDIObjectFactory<T> implements ObjectFactory<T> {
+ 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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ListMultiplicityObjectFactory.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ListMultiplicityObjectFactory.java
new file mode 100644
index 0000000000..d474d9e781
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ListMultiplicityObjectFactory.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.injection;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.factory.ObjectCreationException;
+import org.apache.tuscany.sca.factory.ObjectFactory;
+
+/**
+ * Resolves targets configured in a multiplicity by delegating to object factories and returning an <code>List</code>
+ * containing object instances
+ *
+ * @version $Rev$ $Date$
+ */
+public class ListMultiplicityObjectFactory implements ObjectFactory<List> {
+
+ private ObjectFactory[] factories;
+
+ public ListMultiplicityObjectFactory(List<ObjectFactory<?>> factories) {
+ assert factories != null : "Object factories were null";
+ this.factories = factories.toArray(new ObjectFactory[factories.size()]);
+ }
+
+ public List getInstance() throws ObjectCreationException {
+ List<Object> list = new ArrayList<Object>();
+ for (ObjectFactory factory : factories) {
+ list.add(factory.getInstance());
+ }
+ return list;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/MethodEventInvoker.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/MethodEventInvoker.java
new file mode 100644
index 0000000000..0072d12a60
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/MethodEventInvoker.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.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<T> implements EventInvoker<T> {
+ 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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/MethodInjector.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/MethodInjector.java
new file mode 100644
index 0000000000..1e22a0adce
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/MethodInjector.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.injection;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.sca.factory.ObjectCreationException;
+import org.apache.tuscany.sca.factory.ObjectFactory;
+
+/**
+ * Injects a value created by an {@link org.apache.tuscany.sca.factory.ObjectFactory} using a given method
+ *
+ * @version $Rev$ $Date$
+ */
+public class MethodInjector<T> implements Injector<T> {
+ private final Method method;
+ private final ObjectFactory<?> objectFactory;
+
+ public MethodInjector(Method method, ObjectFactory<?> objectFactory) {
+ 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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/NoAccessorException.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/NoAccessorException.java
new file mode 100644
index 0000000000..f45faa8b52
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/NoAccessorException.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/NoMultiplicityTypeException.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/NoMultiplicityTypeException.java
new file mode 100644
index 0000000000..c1d998e811
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/NoMultiplicityTypeException.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.injection;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class NoMultiplicityTypeException extends InjectionRuntimeException {
+
+ public NoMultiplicityTypeException() {
+ super();
+ }
+
+ public NoMultiplicityTypeException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public NoMultiplicityTypeException(String message) {
+ super(message);
+ }
+
+ public NoMultiplicityTypeException(Throwable cause) {
+ super(cause);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ObjectCallbackException.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ObjectCallbackException.java
new file mode 100644
index 0000000000..7d9e4e6615
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ObjectCallbackException.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.injection;
+
+/**
+ * Denotes an error when invoking on an object
+ *
+ * @version $Rev$ $Date$
+ */
+public class ObjectCallbackException extends InjectionRuntimeException {
+
+ public ObjectCallbackException() {
+ super();
+ }
+
+ public ObjectCallbackException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public ObjectCallbackException(String message) {
+ super(message);
+ }
+
+ public ObjectCallbackException(Throwable cause) {
+ super(cause);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/PojoObjectFactory.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/PojoObjectFactory.java
new file mode 100644
index 0000000000..ccf06cf569
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/PojoObjectFactory.java
@@ -0,0 +1,120 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.injection;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.util.List;
+
+import org.apache.tuscany.sca.factory.ObjectCreationException;
+import org.apache.tuscany.sca.factory.ObjectFactory;
+
+/**
+ * Creates new instances of a Java class
+ *
+ * @version $Rev$ $Date$
+ * @see org.apache.tuscany.sca.implementation.java.injection.Injector
+ */
+public class PojoObjectFactory<T> implements ObjectFactory<T> {
+
+ private final Constructor<T> ctr;
+ private ObjectFactory[] initializerFactories;
+
+ /**
+ * Creates the object factory
+ *
+ * @param ctr the constructor to use when instantiating a new object
+ */
+ public PojoObjectFactory(Constructor<T> 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 <code>ObjectFactory</code>s to use for returning constructor parameters
+ */
+ public PojoObjectFactory(Constructor<T> ctr, List<ObjectFactory> 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 <code>ObjectFactory</code>s use in creating constructor parameters
+ */
+ public ObjectFactory[] getInitializerFactories() {
+ return initializerFactories;
+ }
+
+ /**
+ * Sets an <code>ObjectFactory</code>s 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) {
+ // this can happen if a reference is optional
+ initargs[i] = null;
+ } else {
+ 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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/RequestContextObjectFactory.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/RequestContextObjectFactory.java
new file mode 100644
index 0000000000..49424bb1d6
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/RequestContextObjectFactory.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.injection;
+
+import org.apache.tuscany.sca.core.component.RequestContextImpl;
+import org.apache.tuscany.sca.factory.ObjectCreationException;
+import org.apache.tuscany.sca.factory.ObjectFactory;
+import org.osoa.sca.RequestContext;
+
+/**
+ * Creates instances of {@link org.apache.tuscany.sca.core.component.RequestContextImpl} for injection on
+ * component implementation instances
+ *
+ * @version $Rev$ $Date$
+ */
+public class RequestContextObjectFactory implements ObjectFactory<RequestContext> {
+
+ public RequestContextObjectFactory() {
+ }
+
+ public RequestContext getInstance() throws ObjectCreationException {
+ return new RequestContextImpl();
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ResourceHost.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ResourceHost.java
new file mode 100644
index 0000000000..70c368a0e6
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ResourceHost.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.injection;
+
+/**
+ * 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> T resolveResource(Class<T> 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> T resolveResource(Class<T> type, String mappedName) throws ResourceResolutionException;
+
+}
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ResourceNotFoundException.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ResourceNotFoundException.java
new file mode 100644
index 0000000000..c124f278da
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ResourceNotFoundException.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.injection;
+
+import org.apache.tuscany.sca.factory.ObjectCreationException;
+
+/**
+ * Denotes an exception thrown when a runtime resource is not found
+ *
+ * @version $Rev$ $Date$
+ */
+public class ResourceNotFoundException extends ObjectCreationException {
+
+ public ResourceNotFoundException() {
+ super();
+ }
+
+ public ResourceNotFoundException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public ResourceNotFoundException(String message) {
+ super(message);
+ }
+
+ public ResourceNotFoundException(Throwable cause) {
+ super(cause);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ResourceObjectFactory.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ResourceObjectFactory.java
new file mode 100644
index 0000000000..000b1eb533
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ResourceObjectFactory.java
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.injection;
+
+import org.apache.tuscany.sca.factory.ObjectCreationException;
+import org.apache.tuscany.sca.factory.ObjectFactory;
+
+/**
+ * Resolves a runtime resource to be injected on a field or method of a Java component type marked with {@link
+ * org.apache.tuscany.api.annotation.Resource}. If the mapped name of the resource is an absolute URI such as
+ * <code>sca://localhost</code> or <code>jndi://localhost</code> 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<T> implements ObjectFactory<T> {
+
+ private Class<T> type;
+ private String mappedName;
+ private ResourceHost host;
+ 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 host the runtime resource provider
+ */
+ public ResourceObjectFactory(Class<T> type, boolean optional, ResourceHost host) {
+ this(type, null, optional, host);
+ }
+
+ /**
+ * 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 host the runtime resource provider
+ */
+ public ResourceObjectFactory(Class<T> type, String mappedName, boolean optional, ResourceHost host) {
+ this.type = type;
+ this.host = host;
+ this.mappedName = mappedName;
+ this.optional = optional;
+ }
+
+ @SuppressWarnings({"unchecked"})
+ public T getInstance() throws ObjectCreationException {
+ try {
+ T resource;
+ if (mappedName == null) {
+ resource = host.resolveResource(type);
+ if (!optional && resource == null) {
+ throw new ResourceNotFoundException("Resource not found: " + type.getName());
+ }
+ } else {
+ resource = host.resolveResource(type, mappedName);
+ if (!optional && resource == null) {
+ throw new ResourceNotFoundException("Resource not found: " + mappedName);
+ }
+ }
+ return resource;
+ } catch (ResourceResolutionException e) {
+ throw new ObjectCreationException(e);
+ }
+
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ResourceResolutionException.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ResourceResolutionException.java
new file mode 100644
index 0000000000..f94b24762a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ResourceResolutionException.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.injection;
+
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ResourceResolutionException extends Exception {
+ private static final long serialVersionUID = 13421352711315479L;
+
+ public ResourceResolutionException() {
+ super();
+ }
+
+ public ResourceResolutionException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public ResourceResolutionException(String message) {
+ super(message);
+ }
+
+ public ResourceResolutionException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/SingletonObjectFactory.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/SingletonObjectFactory.java
new file mode 100644
index 0000000000..cc9e59b16d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/SingletonObjectFactory.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.injection;
+
+import org.apache.tuscany.sca.factory.ObjectFactory;
+
+/**
+ * Implementation of ObjectFactory that returns a single instance, typically an immutable type.
+ *
+ * @version $Rev$ $Date$
+ */
+public class SingletonObjectFactory<T> implements ObjectFactory<T> {
+ private final T instance;
+
+ public SingletonObjectFactory(T instance) {
+ this.instance = instance;
+ }
+
+ public T getInstance() {
+ return instance;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/InvalidConversationSequenceException.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/InvalidConversationSequenceException.java
new file mode 100644
index 0000000000..eb8bf8d0c9
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/InvalidConversationSequenceException.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.invocation;
+
+import org.apache.tuscany.sca.scope.TargetInvocationException;
+
+/**
+ * Denotes an unknown operation sequence in a conversation
+ *
+ * @version $Rev$ $Date$
+ */
+public class InvalidConversationSequenceException extends TargetInvocationException {
+
+ public InvalidConversationSequenceException() {
+ super();
+ }
+
+ public InvalidConversationSequenceException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public InvalidConversationSequenceException(String message) {
+ super(message);
+ }
+
+ public InvalidConversationSequenceException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentInfo.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentInfo.java
new file mode 100644
index 0000000000..c544f90af7
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentInfo.java
@@ -0,0 +1,414 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.invocation;
+
+import java.lang.reflect.Array;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.sca.assembly.ComponentProperty;
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.Multiplicity;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.core.component.ComponentContextImpl;
+import org.apache.tuscany.sca.core.component.ComponentContextProvider;
+import org.apache.tuscany.sca.core.component.ServiceReferenceImpl;
+import org.apache.tuscany.sca.core.invocation.CallbackWireObjectFactory;
+import org.apache.tuscany.sca.core.invocation.ProxyFactory;
+import org.apache.tuscany.sca.core.invocation.WireObjectFactory;
+import org.apache.tuscany.sca.databinding.DataBindingExtensionPoint;
+import org.apache.tuscany.sca.factory.ObjectCreationException;
+import org.apache.tuscany.sca.factory.ObjectFactory;
+import org.apache.tuscany.sca.implementation.java.context.JavaPropertyValueObjectFactory;
+import org.apache.tuscany.sca.implementation.java.context.TargetMethodNotFoundException;
+import org.apache.tuscany.sca.implementation.java.impl.JavaElementImpl;
+import org.apache.tuscany.sca.implementation.java.impl.JavaResourceImpl;
+import org.apache.tuscany.sca.implementation.java.injection.ArrayMultiplicityObjectFactory;
+import org.apache.tuscany.sca.implementation.java.injection.ConversationIDObjectFactory;
+import org.apache.tuscany.sca.implementation.java.injection.FieldInjector;
+import org.apache.tuscany.sca.implementation.java.injection.Injector;
+import org.apache.tuscany.sca.implementation.java.injection.InvalidAccessorException;
+import org.apache.tuscany.sca.implementation.java.injection.ListMultiplicityObjectFactory;
+import org.apache.tuscany.sca.implementation.java.injection.MethodInjector;
+import org.apache.tuscany.sca.implementation.java.injection.ObjectCallbackException;
+import org.apache.tuscany.sca.implementation.java.introspect.impl.JavaIntrospectionHelper;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.java.impl.JavaInterfaceUtil;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+import org.apache.tuscany.sca.runtime.RuntimeWire;
+import org.apache.tuscany.sca.scope.InstanceWrapper;
+import org.apache.tuscany.sca.scope.PersistenceException;
+import org.apache.tuscany.sca.scope.Scope;
+import org.apache.tuscany.sca.scope.ScopedRuntimeComponent;
+import org.apache.tuscany.sca.scope.TargetDestructionException;
+import org.apache.tuscany.sca.scope.TargetInvokerCreationException;
+import org.osoa.sca.CallableReference;
+import org.osoa.sca.ComponentContext;
+import org.osoa.sca.ServiceReference;
+import org.osoa.sca.annotations.ConversationID;
+
+/**
+ * The runtime instantiation of Java component implementations
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaComponentInfo implements ComponentContextProvider {
+ private JavaPropertyValueObjectFactory propertyValueFactory;
+ private DataBindingExtensionPoint dataBindingRegistry;
+
+ protected RuntimeComponent component;
+ protected PojoConfiguration<?> configuration;
+ protected Scope scope;
+ protected ProxyFactory proxyService;
+ protected URI groupId;
+
+ private final ComponentContext componentContext;
+
+ public JavaComponentInfo(RuntimeComponent component, PojoConfiguration configuration,
+ DataBindingExtensionPoint dataBindingExtensionPoint,
+ JavaPropertyValueObjectFactory propertyValueObjectFactory) {
+ super();
+ this.configuration = configuration;
+ componentContext = new ComponentContextImpl(this);
+ this.groupId = configuration.getGroupId();
+ this.component = component;
+ this.proxyService = configuration.getProxyFactory();
+ this.dataBindingRegistry = dataBindingExtensionPoint;
+ this.propertyValueFactory = propertyValueObjectFactory;
+ }
+
+ public void destroy(Object instance) throws TargetDestructionException {
+ if (configuration.getDestroyInvoker() != null) {
+ try {
+ configuration.getDestroyInvoker().invokeEvent(instance);
+ } catch (ObjectCallbackException e) {
+ throw new TargetDestructionException("Error destroying component instance : " + getUri().toString(), e);
+ }
+ }
+ }
+
+ public InstanceWrapper<?> createInstanceWrapper() throws ObjectCreationException {
+ return configuration.createFactory().newInstance();
+ }
+
+ public void configureProperties(List<ComponentProperty> definedProperties) {
+ for (ComponentProperty p : definedProperties) {
+ configureProperty(p);
+ }
+ }
+
+ public void configureProperty(ComponentProperty configuredProperty) {
+ JavaElementImpl element = configuration.getDefinition().getPropertyMembers().get(configuredProperty.getName());
+
+ if (element != null && !(element.getAnchor() instanceof Constructor) && configuredProperty.getValue() != null) {
+ configuration.getInjectionSites().add(element);
+
+ Class propertyJavaType = JavaIntrospectionHelper.getBaseType(element.getType(), element.getGenericType());
+ ObjectFactory<?> propertyObjectFactory = createPropertyValueFactory(configuredProperty, configuredProperty
+ .getValue(), propertyJavaType);
+ configuration.setObjectFactory(element, propertyObjectFactory);
+ }
+ }
+
+ public void start() {
+ if (!configuration.getDefinition().getCallbackMembers().isEmpty()) {
+ Map<String, List<RuntimeWire>> callbackWires = new HashMap<String, List<RuntimeWire>>();
+ for (ComponentService service : component.getServices()) {
+
+ RuntimeComponentService componentService = (RuntimeComponentService)service;
+ if (!componentService.getCallbackWires().isEmpty()) {
+ callbackWires.put(componentService.getCallbackWires().get(0).getTarget().getInterfaceContract()
+ .getCallbackInterface().toString(), componentService.getCallbackWires());
+ }
+ }
+
+ for (Map.Entry<String, JavaElementImpl> entry : configuration.getDefinition().getCallbackMembers()
+ .entrySet()) {
+ List<RuntimeWire> wires = callbackWires.get(entry.getKey());
+ if (wires == null) {
+ // this can happen when there are no client wires to a
+ // component that has a callback
+ continue;
+ }
+ JavaElementImpl element = entry.getValue();
+ ObjectFactory<?> factory = new CallbackWireObjectFactory(element.getType(), proxyService, wires);
+ if (!(element.getAnchor() instanceof Constructor)) {
+ configuration.getInjectionSites().add(element);
+ }
+ configuration.setObjectFactory(element, factory);
+ }
+ }
+ for (Reference ref : configuration.getDefinition().getReferences()) {
+ JavaElementImpl element = configuration.getDefinition().getReferenceMembers().get(ref.getName());
+ if (element != null) {
+ if (!(element.getAnchor() instanceof Constructor)) {
+ configuration.getInjectionSites().add(element);
+ }
+ List<RuntimeWire> wireList = null;
+ for (ComponentReference reference : component.getReferences()) {
+ if (reference.getName().equals(ref.getName())) {
+ wireList = ((RuntimeComponentReference)reference).getRuntimeWires();
+ break;
+ }
+ }
+ if (ref.getMultiplicity() == Multiplicity.ONE_N || ref.getMultiplicity() == Multiplicity.ZERO_N) {
+ List<ObjectFactory<?>> factories = new ArrayList<ObjectFactory<?>>();
+ for (int i = 0; i < wireList.size(); i++) {
+ ObjectFactory<?> factory = createWireFactory(element.getType(), wireList.get(i));
+ factories.add(factory);
+ }
+ configuration.setObjectFactories(element, factories);
+ } else {
+ if (wireList == null && ref.getMultiplicity() == Multiplicity.ONE_ONE) {
+ throw new IllegalStateException("Required reference is missing: " + ref.getName());
+ }
+ if (wireList != null && !wireList.isEmpty()) {
+ ObjectFactory<?> factory = createWireFactory(element.getType(), wireList.get(0));
+ configuration.setObjectFactory(element, factory);
+ }
+ }
+ }
+ }
+ }
+
+ public void addPropertyFactory(String name, ObjectFactory<?> factory) {
+ JavaElementImpl element = configuration.getDefinition().getPropertyMembers().get(name);
+
+ if (element != null && !(element.getAnchor() instanceof Constructor)) {
+ configuration.getInjectionSites().add(element);
+ }
+
+ configuration.setObjectFactory(element, factory);
+ }
+
+ public void addResourceFactory(String name, ObjectFactory<?> factory) {
+ JavaResourceImpl resource = configuration.getDefinition()
+ .getResources().get(name);
+
+ if (resource != null && !(resource.getElement().getAnchor() instanceof Constructor)) {
+ configuration.getInjectionSites().add(resource.getElement());
+ }
+
+ configuration.setObjectFactory(resource.getElement(), factory);
+ }
+
+ public void addConversationIDFactory(Member member) {
+ ObjectFactory<String> factory = new ConversationIDObjectFactory();
+
+ if (member instanceof Field) {
+ JavaElementImpl element = new JavaElementImpl((Field)member);
+ element.setClassifer(ConversationID.class);
+ configuration.setObjectFactory(element, factory);
+ } else if (member instanceof Method) {
+ JavaElementImpl element = new JavaElementImpl((Method)member, 0);
+ element.setName(JavaIntrospectionHelper.toPropertyName(member.getName()));
+ element.setClassifer(ConversationID.class);
+ configuration.setObjectFactory(element, factory);
+ } else {
+ throw new InvalidAccessorException("Member must be a field or method: " + member.getName());
+ }
+ }
+
+ public boolean implementsCallback(Class callbackClass) {
+ Class<?>[] implementedInterfaces = configuration.getDefinition().getJavaClass().getInterfaces();
+ for (Class<?> implementedInterface : implementedInterfaces) {
+ if (implementedInterface.isAssignableFrom(callbackClass)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ protected Injector<Object> createInjector(Member member, RuntimeWire wire) {
+ if (member instanceof Field) {
+ Class<?> type = ((Field)member).getType();
+ ObjectFactory<?> factory = createWireFactory(type, wire);
+ return new FieldInjector<Object>((Field)member, factory);
+ } else if (member instanceof Method) {
+ Class<?> type = ((Method)member).getParameterTypes()[0];
+ ObjectFactory<?> factory = createWireFactory(type, wire);
+ return new MethodInjector<Object>((Method)member, factory);
+ } else if (member instanceof Constructor) {
+ return null;
+ } else {
+ throw new InvalidAccessorException("Member must be a field or method: " + member.getName());
+ }
+ }
+
+ protected Injector<Object> createMultiplicityInjector(Member member,
+ Class<?> interfaceType,
+ List<RuntimeWire> wireFactories) {
+ List<ObjectFactory<?>> factories = new ArrayList<ObjectFactory<?>>();
+ for (RuntimeWire wire : wireFactories) {
+ factories.add(createWireFactory(interfaceType, wire));
+ }
+ if (member instanceof Field) {
+ Field field = (Field)member;
+ if (field.getType().isArray()) {
+ return new FieldInjector<Object>(field, new ArrayMultiplicityObjectFactory(interfaceType, factories));
+ } else {
+ return new FieldInjector<Object>(field, new ListMultiplicityObjectFactory(factories));
+ }
+ } else if (member instanceof Method) {
+ Method method = (Method)member;
+ if (method.getParameterTypes()[0].isArray()) {
+ return new MethodInjector<Object>(method, new ArrayMultiplicityObjectFactory(interfaceType, factories));
+ } else {
+ return new MethodInjector<Object>(method, new ListMultiplicityObjectFactory(factories));
+ }
+ } else {
+ throw new InvalidAccessorException("Member must be a field or method: " + member.getName());
+ }
+ }
+
+ public ComponentContext getComponentContext() {
+ return componentContext;
+ }
+
+ public <B> B getProperty(Class<B> type, String propertyName) {
+ JavaElementImpl element = configuration.getDefinition().getPropertyMembers().get(propertyName);
+ Object obj = configuration.getFactories().get(element);
+ if (obj instanceof ObjectFactory) {
+ return type.cast(((ObjectFactory<?>)obj).getInstance());
+ } else if (obj instanceof List) {
+ List<ObjectFactory<?>> factories = (List<ObjectFactory<?>>)obj;
+ if (type.isArray()) {
+ Object array = Array.newInstance(type, factories.size());
+ for (int i = 0; i < factories.size(); i++) {
+ Array.set(array, i, factories.get(i).getInstance());
+ }
+ return type.cast(array);
+ } else {
+ List<Object> list = new ArrayList<Object>();
+ for (ObjectFactory factory : factories) {
+ list.add(factory.getInstance());
+ }
+ return type.cast(list);
+ }
+ }
+ return null;
+
+ }
+
+ public <B> B getService(Class<B> type, String name) {
+ List<RuntimeWire> referenceWires = getWiresForReference(name);
+ if (referenceWires == null || referenceWires.size() < 1) {
+ return null;
+ } else {
+ // TODO support multiplicity
+ RuntimeWire wire = referenceWires.get(0);
+ ObjectFactory<B> factory = createWireFactory(type, wire);
+ return factory.getInstance();
+ }
+ }
+
+ public <B> ServiceReference<B> getServiceReference(Class<B> type, String name) {
+ List<RuntimeWire> referenceWires = getWiresForReference(name);
+ if (referenceWires == null || referenceWires.size() < 1) {
+ return null;
+ } else {
+ // TODO support multiplicity
+ RuntimeWire wire = referenceWires.get(0);
+ ObjectFactory<B> factory = createWireFactory(type, wire);
+ return new ServiceReferenceImpl<B>(type, factory);
+ }
+ }
+
+ private List<RuntimeWire> getWiresForReference(String name) {
+ for (ComponentReference ref : component.getReferences()) {
+ if (ref.getName().equals(name) || (name.equals("$self$.") && ref.getName().startsWith(name))) {
+ return ((RuntimeComponentReference)ref).getRuntimeWires();
+ }
+ }
+ return null;
+ }
+
+ public <B, R extends CallableReference<B>> R cast(B target) {
+ return (R)proxyService.cast(target);
+ }
+
+ public <B> ServiceReference<B> createSelfReference(Class<B> businessInterface, String serviceName) {
+ return null;
+ }
+
+ public <B> ServiceReference<B> createSelfReference(Class<B> businessInterface) {
+ return null;
+ }
+
+ public Object createInstance() throws ObjectCreationException {
+ return createInstanceWrapper().getInstance();
+ }
+
+ public PojoConfiguration<?> getConfiguration() {
+ return configuration;
+ }
+
+ public void stop() {
+ }
+
+ public void removeInstance() throws PersistenceException {
+ ((ScopedRuntimeComponent) component).getScopeContainer().remove();
+ }
+
+ public URI getUri() {
+ return URI.create(component.getURI());
+ }
+
+ public TargetInvoker createTargetInvoker(Operation operation) throws TargetInvokerCreationException {
+ Class<?> implClass = configuration.getImplementationClass();
+
+ try {
+ Method method = JavaInterfaceUtil.findMethod(implClass, operation);
+ boolean passByValue = operation.getInterface().isRemotable() && (!configuration.getDefinition()
+ .isAllowsPassByReference(method));
+
+ TargetInvoker invoker = new JavaTargetInvoker(method, component);
+ if (passByValue) {
+ return new PassByValueInvoker(dataBindingRegistry, operation, method, component);
+ } else {
+ return invoker;
+ }
+ } catch (NoSuchMethodException e) {
+ throw new TargetMethodNotFoundException(operation);
+ }
+
+ }
+
+ protected <B> ObjectFactory<B> createWireFactory(Class<B> interfaze, RuntimeWire wire) {
+ return new WireObjectFactory<B>(interfaze, wire, proxyService);
+ }
+
+ protected ObjectFactory<?> createPropertyValueFactory(ComponentProperty property,
+ Object propertyValue,
+ Class javaType) {
+ return propertyValueFactory.createValueFactory(property, propertyValue, javaType);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProvider.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProvider.java
new file mode 100644
index 0000000000..61f44dd9b9
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProvider.java
@@ -0,0 +1,174 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.implementation.java.invocation;
+
+import java.net.URI;
+
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.core.invocation.ProxyFactory;
+import org.apache.tuscany.sca.databinding.DataBindingExtensionPoint;
+import org.apache.tuscany.sca.factory.ObjectFactory;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.context.JavaPropertyValueObjectFactory;
+import org.apache.tuscany.sca.implementation.java.impl.JavaResourceImpl;
+import org.apache.tuscany.sca.implementation.java.injection.ResourceHost;
+import org.apache.tuscany.sca.implementation.java.injection.ResourceObjectFactory;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+import org.apache.tuscany.sca.scope.InstanceWrapper;
+import org.apache.tuscany.sca.scope.Scope;
+import org.apache.tuscany.sca.scope.ScopedImplementationProvider;
+import org.apache.tuscany.sca.scope.TargetInvokerCreationException;
+import org.osoa.sca.ComponentContext;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JavaImplementationProvider implements ScopedImplementationProvider {
+ private JavaImplementation implementation;
+ private JavaComponentInfo atomicComponent;
+
+ public JavaImplementationProvider(
+ RuntimeComponent component,
+ JavaImplementation implementation,
+ ProxyFactory proxyService,
+ DataBindingExtensionPoint dataBindingRegistry,
+ JavaPropertyValueObjectFactory propertyValueObjectFactory) {
+ super();
+ this.implementation = implementation;
+
+ try {
+ PojoConfiguration configuration = new PojoConfiguration(implementation);
+ configuration.setProxyFactory(proxyService);
+ // FIXME: Group id to be removed
+ configuration.setGroupId(URI.create("/"));
+ atomicComponent = new JavaComponentInfo(component, configuration, dataBindingRegistry,
+ propertyValueObjectFactory);
+
+ Scope scope = getScope();
+
+ if (scope == Scope.SYSTEM || scope == Scope.COMPOSITE) {
+ // Nothing
+ } else {
+ // Check for conversational contract if conversational scope
+ if (scope == Scope.CONVERSATION) {
+ boolean hasConversationalContract = false;
+ for (Service serviceDef : implementation.getServices()) {
+ if (serviceDef.getInterfaceContract().getInterface().isConversational()) {
+ hasConversationalContract = true;
+ break;
+ }
+ }
+ if (!hasConversationalContract) {
+ String name = implementation.getJavaClass().getName();
+ throw new NoConversationalContractException(name);
+ }
+ }
+ }
+
+ if (implementation.getConversationIDMember() != null) {
+ atomicComponent.addConversationIDFactory(implementation.getConversationIDMember());
+ }
+
+ atomicComponent.configureProperties(component.getProperties());
+ handleResources(implementation, atomicComponent);
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+
+ }
+
+ private void handleResources(JavaImplementation componentType, JavaComponentInfo component) {
+ for (JavaResourceImpl resource : componentType.getResources().values()) {
+ String name = resource.getName();
+
+ ObjectFactory<?> objectFactory = (ObjectFactory<?>)component.getConfiguration().getFactories().get(resource
+ .getElement());
+ Class<?> type = resource.getElement().getType();
+ if (ComponentContext.class.equals(type)) {
+ objectFactory = new PojoComponentContextFactory(component);
+ } else {
+ boolean optional = resource.isOptional();
+ String mappedName = resource.getMappedName();
+ objectFactory = createResourceObjectFactory(type, mappedName, optional, null);
+ }
+ component.addResourceFactory(name, objectFactory);
+ }
+ }
+
+ private <T> ResourceObjectFactory<T> createResourceObjectFactory(Class<T> type,
+ String mappedName,
+ boolean optional,
+ ResourceHost host) {
+ return new ResourceObjectFactory<T>(type, mappedName, optional, host);
+ }
+
+ public Object createInstance(RuntimeComponent component, ComponentService service) {
+ return atomicComponent.createInstance();
+ }
+
+ public Invoker createInvoker(RuntimeComponentService service, Operation operation) {
+ try {
+ return new TargetInvokerInvoker(atomicComponent.createTargetInvoker(operation));
+ } catch (TargetInvokerCreationException e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+ public Invoker createCallbackInvoker(Operation operation) {
+ try {
+ return new TargetInvokerInvoker(atomicComponent.createTargetInvoker(operation));
+ } catch (TargetInvokerCreationException e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+ public Scope getScope() {
+ return new Scope(implementation.getJavaScope().getScope());
+ }
+
+ public void start() {
+ atomicComponent.start();
+ }
+
+ public void stop() {
+ atomicComponent.stop();
+ }
+
+ public InstanceWrapper createInstanceWrapper() {
+ return atomicComponent.createInstanceWrapper();
+ }
+
+ public boolean isEagerInit() {
+ return implementation.isEagerInit();
+ }
+
+ public long getMaxAge() {
+ return implementation.getMaxAge();
+ }
+
+ public long getMaxIdleTime() {
+ return implementation.getMaxIdleTime();
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProviderFactory.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProviderFactory.java
new file mode 100644
index 0000000000..1be465cc51
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProviderFactory.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.implementation.java.invocation;
+
+import org.apache.tuscany.sca.core.invocation.ProxyFactory;
+import org.apache.tuscany.sca.databinding.DataBindingExtensionPoint;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.context.JavaPropertyValueObjectFactory;
+import org.apache.tuscany.sca.provider.ImplementationProvider;
+import org.apache.tuscany.sca.provider.ImplementationProviderFactory;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JavaImplementationProviderFactory implements ImplementationProviderFactory<JavaImplementation> {
+ private JavaPropertyValueObjectFactory propertyValueObjectFactory;
+ private DataBindingExtensionPoint dataBindingRegistry;
+ private ProxyFactory proxyService;
+
+ public JavaImplementationProviderFactory(ProxyFactory proxyService,
+ DataBindingExtensionPoint dataBindingRegistry,
+ JavaPropertyValueObjectFactory propertyValueObjectFactory) {
+ super();
+ this.proxyService = proxyService;
+ this.dataBindingRegistry = dataBindingRegistry;
+ this.propertyValueObjectFactory = propertyValueObjectFactory;
+ }
+
+ public ImplementationProvider createImplementationProvider(RuntimeComponent component,
+ JavaImplementation implementation) {
+ return new JavaImplementationProvider(component, implementation, proxyService, dataBindingRegistry,
+ propertyValueObjectFactory);
+ }
+
+ public Class<JavaImplementation> getModelType() {
+ return JavaImplementation.class;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaTargetInvoker.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaTargetInvoker.java
new file mode 100644
index 0000000000..03eca2ff6b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaTargetInvoker.java
@@ -0,0 +1,159 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.invocation;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.List;
+
+import org.apache.tuscany.sca.core.invocation.ThreadMessageContext;
+import org.apache.tuscany.sca.interfacedef.ConversationSequence;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.InvocationChain;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.scope.InstanceWrapper;
+import org.apache.tuscany.sca.scope.Scope;
+import org.apache.tuscany.sca.scope.ScopeContainer;
+import org.apache.tuscany.sca.scope.ScopedRuntimeComponent;
+import org.apache.tuscany.sca.scope.TargetResolutionException;
+
+/**
+ * Responsible for synchronously dispatching an invocation to a Java component
+ * implementation instance
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaTargetInvoker implements TargetInvoker {
+ protected Method operation;
+ protected boolean stateless;
+ protected InstanceWrapper target;
+ protected boolean cacheable;
+
+ private final RuntimeComponent component;
+ private final ScopeContainer scopeContainer;
+
+ public JavaTargetInvoker(Method operation, RuntimeComponent component) {
+ assert operation != null : "Operation method cannot be null";
+ this.operation = operation;
+ this.component = component;
+ this.scopeContainer = ((ScopedRuntimeComponent) component).getScopeContainer();
+ stateless = Scope.STATELESS == this.scopeContainer.getScope();
+ }
+
+ @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 InstanceWrapper getInstance(ConversationSequence sequence, Object contextId)
+ throws TargetResolutionException, InvalidConversationSequenceException {
+ if (sequence == null) {
+ if (cacheable) {
+ if (target == null) {
+ target = scopeContainer.getWrapper(contextId);
+ }
+ return target;
+ } else {
+ return scopeContainer.getWrapper(contextId);
+ }
+ } else {
+ switch (sequence) {
+ case CONVERSATION_START:
+ assert !cacheable;
+ return scopeContainer.getWrapper(contextId);
+ case CONVERSATION_CONTINUE:
+ case CONVERSATION_END:
+ assert !cacheable;
+ return scopeContainer.getAssociatedWrapper(contextId);
+ default:
+ throw new InvalidConversationSequenceException("Unknown sequence type: " + String.valueOf(sequence));
+ }
+ }
+ }
+
+ public Object invokeTarget(final Object payload, final ConversationSequence sequence)
+ throws InvocationTargetException {
+
+ // FIXME: How to deal with other scopes
+ Object contextId = ThreadMessageContext.getMessageContext().getConversationID();
+ try {
+ InstanceWrapper wrapper = getInstance(sequence, contextId);
+ Object instance = wrapper.getInstance();
+ Object ret;
+ if (payload != null && !payload.getClass().isArray()) {
+ ret = operation.invoke(instance, payload);
+ } else {
+ ret = operation.invoke(instance, (Object[])payload);
+ }
+ scopeContainer.returnWrapper(wrapper, contextId);
+ if (sequence == ConversationSequence.CONVERSATION_END) {
+ // if end conversation, remove resource
+ scopeContainer.remove();
+ }
+ return ret;
+ } catch (InvocationTargetException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new InvocationTargetException(e);
+ }
+ }
+
+ public Message invoke(Message msg) {
+ try {
+ Object messageId = msg.getMessageID();
+ Message workContext = ThreadMessageContext.getMessageContext();
+ if (messageId != null) {
+ workContext.setCorrelationID(messageId);
+ }
+ Object resp = invokeTarget(msg.getBody(), msg.getConversationSequence());
+ msg.setBody(resp);
+ } catch (InvocationTargetException e) {
+ msg.setFaultBody(e.getCause());
+ }
+ return msg;
+ }
+
+ public boolean isCacheable() {
+ return cacheable;
+ }
+
+ public void setCacheable(boolean cacheable) {
+ this.cacheable = cacheable;
+ }
+
+ protected InvocationChain getInvocationChain(List<InvocationChain> chains, Operation targetOperation) {
+ for (InvocationChain chain : chains) {
+ if (chain.getTargetOperation().equals(targetOperation)) {
+ return chain;
+ }
+ }
+ return null;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/NoConversationalContractException.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/NoConversationalContractException.java
new file mode 100644
index 0000000000..a7b175cf9b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/NoConversationalContractException.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.invocation;
+
+
+/**
+ * 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 Exception {
+
+ private static final long serialVersionUID = -1157790036638157539L;
+
+ public NoConversationalContractException(String message) {
+ super(message);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/PassByValueInvoker.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/PassByValueInvoker.java
new file mode 100644
index 0000000000..e9e12b9b7b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/PassByValueInvoker.java
@@ -0,0 +1,117 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.implementation.java.invocation;
+
+import java.lang.reflect.Method;
+import java.util.IdentityHashMap;
+import java.util.Map;
+
+import org.apache.tuscany.sca.databinding.DataBinding;
+import org.apache.tuscany.sca.databinding.DataBindingExtensionPoint;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+/**
+ * An interceptor to enforce pass-by-value semantics for remotable interfaces
+ *
+ * @version $Rev$ $Date$
+ */
+public class PassByValueInvoker extends JavaTargetInvoker {
+ private DataBindingExtensionPoint registry;
+ private Operation operation;
+
+ /**
+ * @param registry
+ * @param operation
+ * @param method
+ * @param component
+ */
+ public PassByValueInvoker(DataBindingExtensionPoint registry,
+ Operation operation,
+ Method method,
+ RuntimeComponent component) {
+ super(method, component);
+ this.registry = registry;
+ this.operation = operation;
+ }
+
+ public Message invoke(Message msg) {
+ Object obj = msg.getBody();
+ msg.setBody(copy((Object[])obj));
+
+ Message result = super.invoke(msg);
+
+ if (!result.isFault() && operation.getOutputType() != null) {
+ String dataBindingId = operation.getOutputType().getDataBinding();
+ DataBinding dataBinding = registry.getDataBinding(dataBindingId);
+ result.setBody(copy(result.getBody(), dataBinding));
+ }
+ return result;
+ }
+
+ public Object[] copy(Object[] args) {
+ if (args == null) {
+ return null;
+ }
+ Object[] copiedArgs = new Object[args.length];
+ Map<Object, Object> map = new IdentityHashMap<Object, Object>();
+ 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 {
+ String dataBindingId = operation.getInputType().getLogical().get(i).getDataBinding();
+ DataBinding dataBinding = registry.getDataBinding(dataBindingId);
+ 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 (argDataBinding != null) {
+ copiedArg = argDataBinding.copy(arg);
+ } else {
+ copiedArg = arg;
+ DataType<?> dataType = registry.introspectType(arg);
+ if (dataType != null) {
+ DataBinding binding = registry.getDataBinding(dataType.getDataBinding());
+ if (binding != null) {
+ copiedArg = binding.copy(arg);
+ }
+ }
+ // FIXME: What to do if it's not recognized?
+ }
+ return copiedArg;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/PojoComponentContextFactory.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/PojoComponentContextFactory.java
new file mode 100644
index 0000000000..612262ffb4
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/PojoComponentContextFactory.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.invocation;
+
+import org.apache.tuscany.sca.factory.ObjectCreationException;
+import org.apache.tuscany.sca.factory.ObjectFactory;
+import org.osoa.sca.ComponentContext;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class PojoComponentContextFactory implements ObjectFactory<ComponentContext> {
+ private final JavaComponentInfo component;
+
+
+ public PojoComponentContextFactory(JavaComponentInfo component) {
+ this.component = component;
+ }
+
+
+ public ComponentContext getInstance() throws ObjectCreationException {
+ return component.getComponentContext();
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/PojoConfiguration.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/PojoConfiguration.java
new file mode 100644
index 0000000000..bd8c66f914
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/PojoConfiguration.java
@@ -0,0 +1,218 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.invocation;
+
+import java.lang.annotation.ElementType;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.sca.core.invocation.ProxyFactory;
+import org.apache.tuscany.sca.factory.ObjectFactory;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.context.InstanceFactory;
+import org.apache.tuscany.sca.implementation.java.context.InstanceFactoryProvider;
+import org.apache.tuscany.sca.implementation.java.context.ReflectiveInstanceFactory;
+import org.apache.tuscany.sca.implementation.java.impl.JavaConstructorImpl;
+import org.apache.tuscany.sca.implementation.java.impl.JavaElementImpl;
+import org.apache.tuscany.sca.implementation.java.injection.ArrayMultiplicityObjectFactory;
+import org.apache.tuscany.sca.implementation.java.injection.EventInvoker;
+import org.apache.tuscany.sca.implementation.java.injection.FieldInjector;
+import org.apache.tuscany.sca.implementation.java.injection.Injector;
+import org.apache.tuscany.sca.implementation.java.injection.InvalidAccessorException;
+import org.apache.tuscany.sca.implementation.java.injection.ListMultiplicityObjectFactory;
+import org.apache.tuscany.sca.implementation.java.injection.MethodEventInvoker;
+import org.apache.tuscany.sca.implementation.java.injection.MethodInjector;
+import org.apache.tuscany.sca.implementation.java.introspect.impl.JavaIntrospectionHelper;
+
+/**
+ * Encapsulates confuration for a Java-based atomic component
+ *
+ * @version $Rev$ $Date$
+ */
+public class PojoConfiguration<T> implements InstanceFactoryProvider<T> {
+ private JavaImplementation definition;
+ private ProxyFactory proxyService;
+ private URI groupId;
+ private URI name;
+
+ private final List<JavaElementImpl> injectionSites;
+ private final EventInvoker<T> initInvoker;
+ private final EventInvoker<T> destroyInvoker;
+ private final Map<JavaElementImpl, Object> factories = new HashMap<JavaElementImpl, Object>();
+
+ public PojoConfiguration(JavaImplementation definition) {
+ this.definition = definition;
+ this.initInvoker = definition.getInitMethod() == null ? null : new MethodEventInvoker<T>(definition
+ .getInitMethod());
+ this.destroyInvoker = definition.getDestroyMethod() == null ? null : new MethodEventInvoker<T>(definition
+ .getDestroyMethod());
+ injectionSites = new ArrayList<JavaElementImpl>();
+ }
+
+ public URI getGroupId() {
+ return groupId;
+ }
+
+ public void setGroupId(URI groupId) {
+ this.groupId = groupId;
+ }
+
+ public EventInvoker<Object> getInitInvoker() {
+ if (definition.getInitMethod() != null) {
+ return new MethodEventInvoker<Object>(definition.getInitMethod());
+ } else {
+ return null;
+ }
+ }
+
+ public EventInvoker<Object> getDestroyInvoker() {
+ if (definition.getDestroyMethod() != null) {
+ return new MethodEventInvoker<Object>(definition.getDestroyMethod());
+ } else {
+ return null;
+ }
+ }
+
+ public ProxyFactory getProxyFactory() {
+ return proxyService;
+ }
+
+ public void setProxyFactory(ProxyFactory proxyService) {
+ this.proxyService = proxyService;
+ }
+
+ /**
+ * @return the constructor
+ */
+ public JavaConstructorImpl<?> getConstructor() {
+ return definition.getConstructor();
+ }
+
+ /**
+ * @return the definition
+ */
+ public JavaImplementation getDefinition() {
+ return definition;
+ }
+
+ @SuppressWarnings("unchecked")
+ public InstanceFactory<T> createFactory() {
+ ObjectFactory<?>[] initArgs = getConstructorArgs();
+ Injector<T>[] injectors = getInjectors();
+ return new ReflectiveInstanceFactory<T>((Constructor<T>)definition.getConstructor().getConstructor(),
+ initArgs, injectors, initInvoker, destroyInvoker);
+ }
+
+ protected ObjectFactory<?>[] getConstructorArgs() {
+ JavaConstructorImpl<?> constructor = definition.getConstructor();
+ ObjectFactory<?>[] initArgs = new ObjectFactory<?>[constructor.getParameters().length];
+ for (int i = 0; i < initArgs.length; i++) {
+ ObjectFactory<?> factory = (ObjectFactory<?>)factories.get(constructor.getParameters()[i]);
+ assert factory != null;
+ initArgs[i] = factory;
+ }
+ return initArgs;
+ }
+
+ protected Injector<T>[] getInjectors() {
+ // work around JDK1.5 issue with allocating generic arrays
+ @SuppressWarnings("unchecked")
+ Injector<T>[] injectors = (Injector<T>[])new Injector[injectionSites.size()];
+
+ int i = 0;
+ for (JavaElementImpl element : injectionSites) {
+ Object obj = factories.get(element);
+ if (obj != null) {
+ if (obj instanceof ObjectFactory) {
+ ObjectFactory<?> factory = (ObjectFactory<?>)obj;
+ Member member = (Member)element.getAnchor();
+ if (element.getElementType() == ElementType.FIELD) {
+ injectors[i++] = new FieldInjector<T>((Field)member, factory);
+ } else if (element.getElementType() == ElementType.PARAMETER && member instanceof Method) {
+ injectors[i++] = new MethodInjector<T>((Method)member, factory);
+ } else if (member instanceof Constructor) {
+ // Ignore
+ } else {
+ throw new AssertionError(String.valueOf(element));
+ }
+ } else {
+ injectors[i++] = createMultiplicityInjector(element, (List<ObjectFactory<?>>)obj);
+ }
+ }
+ }
+ return injectors;
+ }
+
+ protected Injector<T> createMultiplicityInjector(JavaElementImpl element, List<ObjectFactory<?>> factories) {
+ Class<?> interfaceType = JavaIntrospectionHelper.getBaseType(element.getType(), element.getGenericType());
+
+ if (element.getAnchor() instanceof Field) {
+ Field field = (Field)element.getAnchor();
+ if (field.getType().isArray()) {
+ return new FieldInjector<T>(field, new ArrayMultiplicityObjectFactory(interfaceType, factories));
+ } else {
+ return new FieldInjector<T>(field, new ListMultiplicityObjectFactory(factories));
+ }
+ } else if (element.getAnchor() instanceof Method) {
+ Method method = (Method)element.getAnchor();
+ if (method.getParameterTypes()[0].isArray()) {
+ return new MethodInjector<T>(method, new ArrayMultiplicityObjectFactory(interfaceType, factories));
+ } else {
+ return new MethodInjector<T>(method, new ListMultiplicityObjectFactory(factories));
+ }
+ } else {
+ throw new InvalidAccessorException("Member must be a field or method: " + element.getName());
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public Class<T> getImplementationClass() {
+ return (Class<T>)definition.getJavaClass();
+ }
+
+ public void setObjectFactory(JavaElementImpl element, ObjectFactory<?> objectFactory) {
+ factories.put(element, objectFactory);
+ }
+
+ public void setObjectFactories(JavaElementImpl element, List<ObjectFactory<?>> objectFactory) {
+ factories.put(element, objectFactory);
+ }
+
+ /**
+ * @return the injectionSites
+ */
+ public List<JavaElementImpl> getInjectionSites() {
+ return injectionSites;
+ }
+
+ /**
+ * @return the factories
+ */
+ public Map<JavaElementImpl, Object> getFactories() {
+ return factories;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/TargetInvoker.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/TargetInvoker.java
new file mode 100644
index 0000000000..5e390f1c45
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/TargetInvoker.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.invocation;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.apache.tuscany.sca.interfacedef.ConversationSequence;
+import org.apache.tuscany.sca.invocation.Message;
+
+/**
+ * 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$
+ * @Deprecated
+ */
+public interface TargetInvoker extends Cloneable {
+
+ /**
+ * 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
+ * @return the result of the invocation
+ * @throws InvocationTargetException if there was a problem invoking the target
+ */
+ Object invokeTarget(final Object payload, final ConversationSequence sequence) throws InvocationTargetException;
+
+ /**
+ * Invokes an operation on a target with the given message
+ */
+ Message invoke(Message msg);
+
+ /**
+ * 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);
+
+ /**
+ * Implementations must support deep cloning
+ */
+ Object clone() throws CloneNotSupportedException;
+}
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/TargetInvokerInvoker.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/TargetInvokerInvoker.java
new file mode 100644
index 0000000000..3842f0ba52
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/TargetInvokerInvoker.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.invocation;
+
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.osoa.sca.ServiceRuntimeException;
+
+
+/**
+ * Serves as a tail interceptor on a target wire chain. This implementation dispatches to the target invoker passed
+ * inside the wire message. Target invokers are passed from the source in order to allow for caching of target
+ * instances.
+ *
+ * @version $Rev$ $Date$
+ * @Deprecated
+ * @see org.apache.tuscany.sca.implementation.java.invocation.TargetInvoker
+ */
+public class TargetInvokerInvoker implements Invoker {
+ private TargetInvoker invoker;
+
+ public TargetInvokerInvoker(TargetInvoker invoker) {
+ this.invoker = invoker;
+ }
+
+ public Message invoke(Message msg) {
+ if (invoker == null) {
+ throw new ServiceRuntimeException("No target invoker specified on message");
+ }
+ return invoker.invoke(msg);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/module/JavaRuntimeModuleActivator.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/module/JavaRuntimeModuleActivator.java
new file mode 100644
index 0000000000..626737ceb7
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/module/JavaRuntimeModuleActivator.java
@@ -0,0 +1,136 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.implementation.java.module;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ModelFactoryExtensionPoint;
+import org.apache.tuscany.sca.core.ModuleActivator;
+import org.apache.tuscany.sca.core.invocation.JDKProxyService;
+import org.apache.tuscany.sca.core.invocation.ProxyFactory;
+import org.apache.tuscany.sca.databinding.DataBindingExtensionPoint;
+import org.apache.tuscany.sca.databinding.TransformerExtensionPoint;
+import org.apache.tuscany.sca.databinding.impl.MediatorImpl;
+import org.apache.tuscany.sca.implementation.java.DefaultJavaImplementationFactory;
+import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory;
+import org.apache.tuscany.sca.implementation.java.context.JavaPropertyValueObjectFactory;
+import org.apache.tuscany.sca.implementation.java.introspect.DefaultJavaClassIntrospectorExtensionPoint;
+import org.apache.tuscany.sca.implementation.java.introspect.ExtensibleJavaClassIntrospector;
+import org.apache.tuscany.sca.implementation.java.introspect.JavaClassIntrospector;
+import org.apache.tuscany.sca.implementation.java.introspect.JavaClassIntrospectorExtensionPoint;
+import org.apache.tuscany.sca.implementation.java.introspect.JavaClassVisitor;
+import org.apache.tuscany.sca.implementation.java.introspect.impl.AllowsPassByReferenceProcessor;
+import org.apache.tuscany.sca.implementation.java.introspect.impl.BaseJavaClassVisitor;
+import org.apache.tuscany.sca.implementation.java.introspect.impl.ConstructorProcessor;
+import org.apache.tuscany.sca.implementation.java.introspect.impl.ContextProcessor;
+import org.apache.tuscany.sca.implementation.java.introspect.impl.ConversationProcessor;
+import org.apache.tuscany.sca.implementation.java.introspect.impl.DestroyProcessor;
+import org.apache.tuscany.sca.implementation.java.introspect.impl.EagerInitProcessor;
+import org.apache.tuscany.sca.implementation.java.introspect.impl.HeuristicPojoProcessor;
+import org.apache.tuscany.sca.implementation.java.introspect.impl.InitProcessor;
+import org.apache.tuscany.sca.implementation.java.introspect.impl.PolicyProcessor;
+import org.apache.tuscany.sca.implementation.java.introspect.impl.PropertyProcessor;
+import org.apache.tuscany.sca.implementation.java.introspect.impl.ReferenceProcessor;
+import org.apache.tuscany.sca.implementation.java.introspect.impl.ResourceProcessor;
+import org.apache.tuscany.sca.implementation.java.introspect.impl.ScopeProcessor;
+import org.apache.tuscany.sca.implementation.java.introspect.impl.ServiceProcessor;
+import org.apache.tuscany.sca.implementation.java.invocation.JavaImplementationProviderFactory;
+import org.apache.tuscany.sca.implementation.java.xml.JavaImplementationProcessor;
+import org.apache.tuscany.sca.interfacedef.java.DefaultJavaInterfaceFactory;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+import org.apache.tuscany.sca.interfacedef.java.introspect.ExtensibleJavaInterfaceIntrospector;
+import org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceIntrospector;
+import org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceIntrospectorExtensionPoint;
+import org.apache.tuscany.sca.policy.PolicyFactory;
+import org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JavaRuntimeModuleActivator implements ModuleActivator {
+
+ private JavaClassIntrospectorExtensionPoint classVisitors;
+
+ public JavaRuntimeModuleActivator() {
+ }
+
+
+ public Object[] getExtensionPoints() {
+ classVisitors = new DefaultJavaClassIntrospectorExtensionPoint();
+ return new Object[] { classVisitors };
+ }
+
+ public void start(ExtensionPointRegistry registry) {
+
+ ModelFactoryExtensionPoint factories = registry.getExtensionPoint(ModelFactoryExtensionPoint.class);
+ AssemblyFactory assemblyFactory = factories.getFactory(AssemblyFactory.class);
+ PolicyFactory policyFactory = factories.getFactory(PolicyFactory.class);
+
+ JavaInterfaceFactory javaFactory = new DefaultJavaInterfaceFactory();
+
+ JDKProxyService proxyFactory = (JDKProxyService) registry.getExtensionPoint(ProxyFactory.class);
+
+ JavaInterfaceIntrospectorExtensionPoint interfaceVisitors = registry.getExtensionPoint(JavaInterfaceIntrospectorExtensionPoint.class);
+ JavaInterfaceIntrospector interfaceIntrospector = new ExtensibleJavaInterfaceIntrospector(javaFactory, interfaceVisitors);
+ BaseJavaClassVisitor[] extensions = new BaseJavaClassVisitor[] {
+ new ConstructorProcessor(assemblyFactory),
+ new AllowsPassByReferenceProcessor(assemblyFactory),
+ new ContextProcessor(assemblyFactory),
+ new ConversationProcessor(assemblyFactory),
+ new DestroyProcessor(assemblyFactory),
+ new EagerInitProcessor(assemblyFactory),
+ new InitProcessor(assemblyFactory),
+ new PropertyProcessor(assemblyFactory),
+ new ReferenceProcessor(assemblyFactory, javaFactory, interfaceIntrospector),
+ new ResourceProcessor(assemblyFactory),
+ new ScopeProcessor(assemblyFactory),
+ new ServiceProcessor(assemblyFactory, javaFactory, interfaceIntrospector),
+ new HeuristicPojoProcessor(assemblyFactory, javaFactory, interfaceIntrospector),
+ new PolicyProcessor(assemblyFactory, policyFactory)
+ };
+ for (JavaClassVisitor extension : extensions) {
+ classVisitors.addClassVisitor(extension);
+ }
+ JavaClassIntrospector classIntrospector = new ExtensibleJavaClassIntrospector(classVisitors);
+
+ DataBindingExtensionPoint dataBindings = registry.getExtensionPoint(DataBindingExtensionPoint.class);
+ TransformerExtensionPoint transformers = registry.getExtensionPoint(TransformerExtensionPoint.class);
+ MediatorImpl mediator =new MediatorImpl(dataBindings, transformers);
+ JavaPropertyValueObjectFactory factory = new JavaPropertyValueObjectFactory(mediator);
+
+ StAXArtifactProcessorExtensionPoint processors = registry.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+
+ JavaImplementationFactory javaImplementationFactory = new DefaultJavaImplementationFactory();
+ JavaImplementationProcessor javaImplementationProcessor =
+ new JavaImplementationProcessor(assemblyFactory, policyFactory, javaImplementationFactory, classIntrospector);
+ processors.addArtifactProcessor(javaImplementationProcessor);
+
+ JavaImplementationProviderFactory javaImplementationProviderFactory =
+ new JavaImplementationProviderFactory(proxyFactory, dataBindings, factory);
+
+ ProviderFactoryExtensionPoint providerFactories = registry.getExtensionPoint(ProviderFactoryExtensionPoint.class);
+ providerFactories.addProviderFactory(javaImplementationProviderFactory);
+ }
+
+ public void stop(ExtensionPointRegistry registry) {
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/monitor/ExceptionFormatter.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/monitor/ExceptionFormatter.java
new file mode 100644
index 0000000000..dc34153389
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/monitor/ExceptionFormatter.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/monitor/ExceptionFormatterImpl.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/monitor/ExceptionFormatterImpl.java
new file mode 100644
index 0000000000..3fa86109a0
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/monitor/ExceptionFormatterImpl.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.monitor;
+
+import java.io.PrintWriter;
+
+/**
+ * Performs basics formatting of exceptions for JDK logging
+ *
+ * @version $Rev$ $Date$
+ */
+public class ExceptionFormatterImpl implements ExceptionFormatter {
+
+ public ExceptionFormatterImpl() {
+ }
+
+ public boolean canFormat(Class<?> type) {
+ return Throwable.class.isAssignableFrom(type);
+ }
+
+ public PrintWriter write(PrintWriter writer, Throwable exception) {
+ writer.append(exception.getMessage());
+ writer.append("\n");
+ return writer;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/monitor/FormatterRegistry.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/monitor/FormatterRegistry.java
new file mode 100644
index 0000000000..91a8223385
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/monitor/FormatterRegistry.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/monitor/InvalidLevelException.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/monitor/InvalidLevelException.java
new file mode 100644
index 0000000000..636451bc36
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/monitor/InvalidLevelException.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/monitor/JavaLoggingMonitorFactory.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/monitor/JavaLoggingMonitorFactory.java
new file mode 100644
index 0000000000..fdfd43be95
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/monitor/JavaLoggingMonitorFactory.java
@@ -0,0 +1,118 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.monitor;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+import java.util.ResourceBundle;
+import java.util.logging.Level;
+import java.util.logging.LogRecord;
+import java.util.logging.Logger;
+
+import org.osoa.sca.annotations.Service;
+
+
+/**
+ * A factory for monitors that forwards events to a {@link java.util.logging.Logger Java Logging (JSR47) Logger}.
+ *
+ * @version $Rev$ $Date$
+ * @see java.util.logging
+ */
+@Service(interfaces = {MonitorFactory.class, FormatterRegistry.class})
+public class JavaLoggingMonitorFactory extends ProxyMonitorFactory {
+
+ /**
+ * Construct a MonitorFactory that will monitor the specified methods at the specified levels and generate messages
+ * using java.util.logging.
+ * <p/>
+ * 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 <code>Class.getName() + '#' + Method.getName()</code> 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<String, Object> configProperties = new HashMap<String, Object>();
+ configProperties.put("levels", levels);
+ configProperties.put("defaultLevel", defaultLevel);
+ configProperties.put("bundleName", bundleName);
+ initInternal(configProperties);
+ }
+
+ /**
+ * Constructs a MonitorFactory that needs to be subsequently configured via a call to {@link #initialize}.
+ */
+ public JavaLoggingMonitorFactory() {
+ }
+
+ protected <T> InvocationHandler createInvocationHandler(Class<T> monitorInterface,
+ Map<String, Level> levels) {
+ ResourceBundle bundle = locateBundle(monitorInterface, bundleName);
+ Logger logger = Logger.getLogger(monitorInterface.getName());
+ return new LoggingHandler(logger, levels, bundle);
+ }
+
+ private class LoggingHandler implements InvocationHandler {
+ private final Logger logger;
+ private final Map<String, Level> methodLevels;
+ private final ResourceBundle bundle;
+
+ public LoggingHandler(Logger logger,
+ Map<String, Level> methodLevels,
+ ResourceBundle bundle
+ ) {
+ this.logger = logger;
+ this.methodLevels = methodLevels;
+ this.bundle = bundle;
+ }
+
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+ String sourceMethod = method.getName();
+ Level level = methodLevels.get(sourceMethod);
+ if (level != null && logger.isLoggable(level)) {
+ // construct the key for the resource bundle
+ String className = logger.getName();
+ String key = className + '#' + sourceMethod;
+
+ LogRecord logRecord = new LogRecord(level, key);
+ logRecord.setLoggerName(className);
+ logRecord.setSourceClassName(className);
+ logRecord.setSourceMethodName(sourceMethod);
+ logRecord.setParameters(args);
+ if (args != null) {
+ for (Object o : args) {
+ if (o instanceof Throwable) {
+ logRecord.setMessage(formatException((Throwable) o));
+ break;
+ }
+ }
+ }
+ logRecord.setResourceBundle(bundle);
+ logger.log(logRecord);
+ }
+ return null;
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/monitor/MonitorFactory.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/monitor/MonitorFactory.java
new file mode 100644
index 0000000000..9337e72dcb
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/monitor/MonitorFactory.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.monitor;
+
+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.
+ * <p/>
+ * 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 extends FormatterRegistry {
+ /**
+ * 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<String, Object> 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> T getMonitor(Class<T> monitorInterface);
+}
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/monitor/MonitorFactoryUtil.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/monitor/MonitorFactoryUtil.java
new file mode 100644
index 0000000000..529ceee5ec
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/monitor/MonitorFactoryUtil.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.monitor;
+
+
+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<String, Object> props) {
+ Class<? extends MonitorFactory> clazz;
+ try {
+ clazz = (Class<? extends MonitorFactory>) 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<? extends MonitorFactory> mfc, Map<String, Object> 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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/monitor/NullMonitorFactory.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/monitor/NullMonitorFactory.java
new file mode 100644
index 0000000000..efabb2ef9c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/monitor/NullMonitorFactory.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.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;
+
+
+/**
+ * Implementation of a {@link MonitorFactory} that produces implementations that simply return.
+ *
+ * @version $Rev$ $Date$
+ */
+@EagerInit
+public class NullMonitorFactory implements MonitorFactory {
+
+ /**
+ * Singleton hander that does nothing.
+ */
+ private static final InvocationHandler NULL_MONITOR = new InvocationHandler() {
+ public Object invoke(Object proxy, Method method, Object[] args) {
+ return null;
+ }
+ };
+
+ public void initialize(Map<String, Object> configProperties) {
+ }
+
+ public <T> T getMonitor(Class<T> monitorInterface) {
+ /*
+ * This uses a reflection proxy to implement the monitor interface which
+ * is a simple but perhaps not very performant solution. Performance
+ * might be improved by code generating an implementation with empty methods.
+ */
+ return monitorInterface.cast(
+ Proxy.newProxyInstance(monitorInterface.getClassLoader(), new Class<?>[]{monitorInterface}, NULL_MONITOR));
+ }
+
+ public void register(ExceptionFormatter formatter) {
+
+ }
+
+ public void unregister(ExceptionFormatter formatter) {
+
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/monitor/ProxyMonitorFactory.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/monitor/ProxyMonitorFactory.java
new file mode 100644
index 0000000000..b26ba6ca8b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/monitor/ProxyMonitorFactory.java
@@ -0,0 +1,231 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.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 org.apache.tuscany.api.annotation.LogLevel;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public abstract class ProxyMonitorFactory implements MonitorFactory, FormatterRegistry {
+ protected String bundleName;
+ protected final List<ExceptionFormatter> formatters = new ArrayList<ExceptionFormatter>();
+ protected final ExceptionFormatter defaultFormatter = new ExceptionFormatterImpl();
+ protected Level defaultLevel;
+ protected Map<String, Level> levels;
+ private final Map<Class<?>, WeakReference<?>> proxies = new WeakHashMap<Class<?>, WeakReference<?>>();
+
+ public void initialize(Map<String, Object> configProperties) {
+ if (configProperties == null) {
+ return;
+ }
+ initInternal(configProperties);
+ }
+
+ protected void initInternal(Map<String, Object> configProperties) {
+ try {
+ this.defaultLevel = (Level) configProperties.get("defaultLevel");
+ this.bundleName = (String) configProperties.get("bundleName");
+ Properties levels = (Properties) configProperties.get("levels");
+
+ this.levels = new HashMap<String, Level>();
+ if (levels != null) {
+ for (Map.Entry<Object, Object> 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> T getMonitor(Class<T> monitorInterface) {
+ T proxy = getCachedMonitor(monitorInterface);
+ if (proxy == null) {
+ proxy = createMonitor(monitorInterface);
+ proxies.put(monitorInterface, new WeakReference<T>(proxy));
+ }
+ return proxy;
+ }
+
+ protected <T> T getCachedMonitor(Class<T> monitorInterface) {
+ WeakReference<?> ref = proxies.get(monitorInterface);
+ return (ref != null) ? monitorInterface.cast(ref.get()) : null;
+ }
+
+ protected <T> T createMonitor(Class<T> monitorInterface) {
+ String className = monitorInterface.getName();
+ Method[] methods = monitorInterface.getMethods();
+ Map<String, Level> levels = new HashMap<String, Level>(methods.length);
+ for (Method method : methods) {
+ String key = className + '#' + method.getName();
+ Level level = null;
+ if (this.levels != null) {
+ this.levels.get(key);
+ }
+ // if not specified the in config properties, look for an annotation on the method
+ if (level == null) {
+ LogLevel annotation = method.getAnnotation(LogLevel.class);
+ if (annotation != null && annotation.value() != null) {
+ try {
+ level = Level.parse(annotation.value());
+ } catch (IllegalArgumentException e) {
+ // bad value, just use the default
+ level = defaultLevel;
+ }
+ }
+ }
+ if (level == null) {
+ level = defaultLevel;
+ }
+ levels.put(method.getName(), level);
+ }
+
+ InvocationHandler handler = createInvocationHandler(monitorInterface, levels);
+ Object proxy = Proxy.newProxyInstance(monitorInterface.getClassLoader(),
+ new Class<?>[]{monitorInterface},
+ handler);
+ return monitorInterface.cast(proxy);
+ }
+
+ protected <T> ResourceBundle locateBundle(Class<T> monitorInterface, String bundleName) {
+ Locale locale = Locale.getDefault();
+ ClassLoader cl = monitorInterface.getClassLoader();
+ String packageName = monitorInterface.getPackage().getName();
+ while (true) {
+ try {
+ return ResourceBundle.getBundle(packageName + '.' + bundleName, locale, cl);
+ } catch (MissingResourceException e) {
+ //ok
+ }
+ int index = packageName.lastIndexOf('.');
+ if (index == -1) {
+ break;
+ }
+ packageName = packageName.substring(0, index);
+ }
+ try {
+ return ResourceBundle.getBundle(bundleName, locale, cl);
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
+ public void register(ExceptionFormatter formatter) {
+ formatters.add(formatter);
+ }
+
+ public void unregister(ExceptionFormatter formatter) {
+ formatters.remove(formatter);
+ }
+
+ protected abstract <T> InvocationHandler createInvocationHandler(Class<T> monitorInterface,
+ Map<String, Level> levels);
+
+ protected String formatException(Throwable e) {
+ ExceptionFormatter formatter = defaultFormatter;
+ for (ExceptionFormatter candidate : formatters) {
+ if (candidate.canFormat(e.getClass())) {
+ formatter = candidate;
+ break;
+ }
+ }
+ StringWriter writer = new StringWriter();
+ PrintWriter pw = new PrintWriter(writer);
+ formatter.write(pw, e);
+ format(pw, e);
+ pw.close();
+ return writer.toString();
+ }
+
+ protected void format(PrintWriter writer, Throwable throwable) {
+ writer.println(throwable.getClass().getName());
+ StackTraceElement[] trace = throwable.getStackTrace();
+ for (StackTraceElement aTrace : trace) {
+ writer.println("\tat " + aTrace);
+ }
+ Throwable ourCause = throwable.getCause();
+
+ if (ourCause != null) {
+ printStackTraceAsCause(writer, ourCause, trace);
+ }
+ }
+
+ protected void printStackTraceAsCause(PrintWriter pw,
+ Throwable throwable,
+ StackTraceElement[] causedTrace) {
+
+ // Compute number of frames in common between this and caused
+ StackTraceElement[] trace = throwable.getStackTrace();
+ int m = trace.length - 1;
+ int n = causedTrace.length - 1;
+ while (m >= 0 && n >= 0 && trace[m].equals(causedTrace[n])) {
+ m--;
+ n--;
+ }
+ int framesInCommon = trace.length - 1 - m;
+
+ pw.println("Caused by: " + throwable.getClass().getName());
+
+ ExceptionFormatter formatter = defaultFormatter;
+ for (ExceptionFormatter candidate : formatters) {
+ if (candidate.canFormat(throwable.getClass())) {
+ formatter = candidate;
+ break;
+ }
+ }
+ formatter.write(pw, throwable);
+
+ for (int i = 0; i <= m; i++) {
+ pw.println("\tat " + trace[i]);
+ }
+ if (framesInCommon != 0) {
+ pw.println("\t... " + framesInCommon + " more");
+ }
+
+ // Recurse if we have a cause
+ Throwable ourCause = throwable.getCause();
+ if (ourCause != null) {
+ printStackTraceAsCause(pw, ourCause, trace);
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator
new file mode 100644
index 0000000000..0871ddf4be
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator
@@ -0,0 +1,18 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+# Implementation class for the ModuleActivator
+org.apache.tuscany.sca.implementation.java.module.JavaRuntimeModuleActivator
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/context/ModelHelper.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/context/ModelHelper.java
new file mode 100644
index 0000000000..9b65af0ab1
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/context/ModelHelper.java
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.implementation.java.context;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.Contract;
+import org.apache.tuscany.sca.assembly.Property;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ModelHelper {
+
+ public static Property getProperty(JavaImplementation type, String name) {
+ for (Property prop : type.getProperties()) {
+ if (prop.getName().equals(name)) {
+ return prop;
+ }
+ }
+ return null;
+ }
+
+ public static Reference getReference(JavaImplementation type, String name) {
+ for (Reference ref : type.getReferences()) {
+ if (ref.getName().equals(name)) {
+ return ref;
+ }
+ }
+ return null;
+ }
+
+ public static Service getService(JavaImplementation type, String name) {
+ for (Service svc : type.getServices()) {
+ if (svc.getName().equals(name)) {
+ return svc;
+ }
+ }
+ return null;
+ }
+
+ public static boolean matches(Contract contract, Class<?> type) {
+ Interface interface1 = contract.getInterfaceContract().getInterface();
+ if (interface1 instanceof JavaInterface) {
+ return type == ((JavaInterface)interface1).getJavaClass();
+ } else {
+ return false;
+ }
+ }
+
+ public static ComponentService createService(AssemblyFactory factory,
+ JavaInterfaceFactory javaFactory, Class<?> type) {
+ org.apache.tuscany.sca.assembly.ComponentService ref = factory.createComponentService();
+ ref.setName(type.getSimpleName());
+ JavaInterface i = javaFactory.createJavaInterface();
+ i.setJavaClass(type);
+ JavaInterfaceContract ic = javaFactory.createJavaInterfaceContract();
+ ic.setInterface(i);
+ ref.setInterfaceContract(ic);
+ return ref;
+ }
+
+ public static Reference createReference(AssemblyFactory factory,
+ JavaInterfaceFactory javaFactory, String name, Class<?> type) {
+ org.apache.tuscany.sca.assembly.Reference ref = factory.createReference();
+ ref.setName(name);
+ JavaInterface i = javaFactory.createJavaInterface();
+ i.setJavaClass(type);
+ JavaInterfaceContract ic = javaFactory.createJavaInterfaceContract();
+ ic.setInterface(i);
+ ref.setInterfaceContract(ic);
+ return ref;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/context/MultiplicityTestCase.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/context/MultiplicityTestCase.java
new file mode 100644
index 0000000000..ba8da101c6
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/context/MultiplicityTestCase.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.context;
+
+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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceWrapperTestCase.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceWrapperTestCase.java
new file mode 100644
index 0000000000..c098062bc8
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceWrapperTestCase.java
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.context;
+
+import static org.easymock.EasyMock.createMock;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.implementation.java.injection.EventInvoker;
+import org.apache.tuscany.sca.scope.TargetDestructionException;
+import org.apache.tuscany.sca.scope.TargetInitializationException;
+import org.easymock.EasyMock;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ReflectiveInstanceWrapperTestCase extends TestCase {
+ private ReflectiveInstanceWrapper<Object> wrapper;
+ private Object instance;
+ private EventInvoker<Object> initInvoker;
+ private EventInvoker<Object> destroyInvoker;
+
+ public void testWithNoCallbacks() {
+ wrapper = new ReflectiveInstanceWrapper<Object>(instance, null, null);
+ try {
+ wrapper.start();
+ } catch (TargetInitializationException e) {
+ fail();
+ }
+ try {
+ wrapper.stop();
+ } catch (TargetDestructionException e) {
+ fail();
+ }
+ }
+
+ public void testWithStartCallback() {
+ initInvoker.invokeEvent(instance);
+ EasyMock.replay(initInvoker);
+ wrapper = new ReflectiveInstanceWrapper<Object>(instance, initInvoker, null);
+ try {
+ wrapper.start();
+ } catch (TargetInitializationException e) {
+ fail();
+ }
+ EasyMock.verify(initInvoker);
+ }
+
+ public void testWithStopCallback() {
+ destroyInvoker.invokeEvent(instance);
+ EasyMock.replay(destroyInvoker);
+ wrapper = new ReflectiveInstanceWrapper<Object>(instance, null, destroyInvoker);
+ try {
+ wrapper.stop();
+ } catch (TargetDestructionException e) {
+ fail();
+ }
+ EasyMock.verify(destroyInvoker);
+ }
+
+ @SuppressWarnings("unchecked")
+ protected void setUp() throws Exception {
+ super.setUp();
+ instance = new Object();
+ initInvoker = createMock(EventInvoker.class);
+ destroyInvoker = createMock(EventInvoker.class);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/CallbackWireObjectFactoryTestCase.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/CallbackWireObjectFactoryTestCase.java
new file mode 100644
index 0000000000..29dcfa8169
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/CallbackWireObjectFactoryTestCase.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.injection;
+
+import static org.easymock.EasyMock.createMock;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.core.invocation.CallbackWireObjectFactory;
+import org.apache.tuscany.sca.core.invocation.ProxyFactory;
+import org.apache.tuscany.sca.runtime.RuntimeWire;
+import org.easymock.EasyMock;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class CallbackWireObjectFactoryTestCase extends TestCase {
+
+ @SuppressWarnings({"unchecked"})
+ public void testCreateInstance() throws Exception {
+ ProxyFactory service = createMock(ProxyFactory.class);
+ Foo foo = new Foo() {
+ };
+ EasyMock.expect(service.createCallbackProxy(EasyMock.eq(Foo.class), EasyMock.isA(List.class))).andReturn(foo);
+ EasyMock.replay(service);
+ List<RuntimeWire> wires = new ArrayList<RuntimeWire>();
+ CallbackWireObjectFactory factory = new CallbackWireObjectFactory(Foo.class, service, wires);
+ assertEquals(foo, factory.getInstance());
+ EasyMock.verify(service);
+ }
+
+ private interface Foo {
+
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/FieldInjectorTestCase.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/FieldInjectorTestCase.java
new file mode 100644
index 0000000000..cef5cd4788
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/FieldInjectorTestCase.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.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<Foo> injector = new FieldInjector<Foo>(protectedField, new SingletonObjectFactory<String>("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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/JNDIObjectFactoryTestCase.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/JNDIObjectFactoryTestCase.java
new file mode 100644
index 0000000000..69d2696944
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/JNDIObjectFactoryTestCase.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.injection;
+
+import javax.naming.Context;
+import javax.naming.NamingException;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.factory.ObjectCreationException;
+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<Foo> factory = new JNDIObjectFactory<Foo>(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<Foo> factory = new JNDIObjectFactory<Foo>(ctx, "foo");
+ try {
+ factory.getInstance();
+ fail();
+ } catch (ObjectCreationException e) {
+ //expected
+ }
+ EasyMock.verify(ctx);
+ }
+
+
+ private class Foo {
+
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/MethodEventInvokerTestCase.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/MethodEventInvokerTestCase.java
new file mode 100644
index 0000000000..47fb224c1e
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/MethodEventInvokerTestCase.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.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<MethodEventInvokerTestCase.Foo> injector = new MethodEventInvoker<Foo>(privateMethod);
+ try {
+ injector.invokeEvent(new Foo());
+ fail();
+ } catch (AssertionError e) {
+ // expected
+ }
+ }
+
+ public void testException() throws Exception {
+ MethodEventInvoker<MethodEventInvokerTestCase.Foo> injector = new MethodEventInvoker<Foo>(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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/MethodInjectorTestCase.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/MethodInjectorTestCase.java
new file mode 100644
index 0000000000..f2b8b97e5a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/MethodInjectorTestCase.java
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.injection;
+
+import java.lang.reflect.Method;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.factory.ObjectCreationException;
+import org.apache.tuscany.sca.factory.ObjectFactory;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class MethodInjectorTestCase extends TestCase {
+ private Method fooMethod;
+ private Method privateMethod;
+ private Method exceptionMethod;
+
+ public void testIllegalArgument() throws Exception {
+ ObjectFactory<Object> factory = new SingletonObjectFactory<Object>(new Object());
+ MethodInjector<Foo> injector = new MethodInjector<Foo>(fooMethod, factory);
+ try {
+ injector.inject(new Foo());
+ fail();
+ } catch (ObjectCreationException e) {
+ // expected
+ }
+ }
+
+ public void testException() throws Exception {
+ ObjectFactory<Object> factory = new SingletonObjectFactory<Object>("foo");
+ MethodInjector<Foo> injector = new MethodInjector<Foo>(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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/PojoObjectFactoryTestCase.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/PojoObjectFactoryTestCase.java
new file mode 100644
index 0000000000..6bf0658284
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/PojoObjectFactoryTestCase.java
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.injection;
+
+import java.lang.reflect.Constructor;
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.factory.ObjectFactory;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class PojoObjectFactoryTestCase extends TestCase {
+
+ private Constructor<Foo> ctor;
+
+ public void testConstructorInjection() throws Exception {
+ List<ObjectFactory> initializers = new ArrayList<ObjectFactory>();
+ initializers.add(new SingletonObjectFactory<String>("foo"));
+ PojoObjectFactory<Foo> factory = new PojoObjectFactory<Foo>(ctor, initializers);
+ Foo foo = factory.getInstance();
+ assertEquals("foo", foo.foo);
+ }
+
+ /**
+ * Verifies null parameters can be passed to a constructor. This is valid when a reference is optional during
+ * constructor injection
+ */
+ public void testConstructorInjectionOptionalParam() throws Exception {
+ List<ObjectFactory> initializers = new ArrayList<ObjectFactory>();
+ initializers.add(null);
+ PojoObjectFactory<Foo> factory = new PojoObjectFactory<Foo>(ctor, initializers);
+ Foo foo = factory.getInstance();
+ assertNull(foo.foo);
+ }
+
+ public void testConstructorInitializerInjection() throws Exception {
+ PojoObjectFactory<Foo> factory = new PojoObjectFactory<Foo>(ctor);
+ factory.setInitializerFactory(0, new SingletonObjectFactory<String>("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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/RequestContextObjectFactoryTestCase.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/RequestContextObjectFactoryTestCase.java
new file mode 100644
index 0000000000..d8b981e952
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/RequestContextObjectFactoryTestCase.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.injection;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class RequestContextObjectFactoryTestCase extends TestCase {
+
+ public void testInstanceCreate() {
+ RequestContextObjectFactory factory = new RequestContextObjectFactory();
+ assertNotNull(factory.getInstance());
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/ResourceObjectFactoryTestCase.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/ResourceObjectFactoryTestCase.java
new file mode 100644
index 0000000000..ed7a0e7d03
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/ResourceObjectFactoryTestCase.java
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.injection;
+
+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);
+ ResourceObjectFactory<String> factory = new ResourceObjectFactory<String>(String.class, false, host);
+ assertEquals("foo", factory.getInstance());
+ EasyMock.verify(host);
+ }
+
+ 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<String> factory =
+ new ResourceObjectFactory<String>(String.class, "sca://localhost/bar", false, host);
+ assertEquals("foo", factory.getInstance());
+ 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);
+ ResourceObjectFactory<String> factory = new ResourceObjectFactory<String>(String.class, true, host);
+ assertNull(factory.getInstance());
+ 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);
+//
+// RuntimeWire wire = EasyMock.createMock(RuntimeWire.class);
+// EasyMock.expect(wire.getTargetInstance()).andReturn(null);
+// EasyMock.replay(wire);
+//
+// ResourceObjectFactory<String> factory = new ResourceObjectFactory<String>(String.class, false, host);
+// try {
+// factory.getInstance();
+// fail();
+// } catch (ResourceNotFoundException e) {
+// //expected
+// }
+// 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);
+ ResourceObjectFactory<String> factory = new ResourceObjectFactory<String>(String.class, true, host);
+ assertNull(factory.getInstance());
+ EasyMock.verify(host);
+ }
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/SingletonObjectFactoryTestCase.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/SingletonObjectFactoryTestCase.java
new file mode 100644
index 0000000000..40ad1b1e95
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/SingletonObjectFactoryTestCase.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.injection;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class SingletonObjectFactoryTestCase extends TestCase {
+
+ public void testSingleton() throws Exception {
+ Object o = new Object();
+ SingletonObjectFactory<Object> factory = new SingletonObjectFactory<Object>(o);
+ assertEquals(o, factory.getInstance());
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration/AbstractConversationTestCase.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration/AbstractConversationTestCase.java
new file mode 100644
index 0000000000..738775b9a3
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration/AbstractConversationTestCase.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.integration;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.core.scope.ConversationalScopeContainer;
+import org.apache.tuscany.sca.core.store.MemoryStore;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.scope.ScopeContainer;
+import org.apache.tuscany.sca.store.StoreMonitor;
+import org.easymock.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 RuntimeComponent component;
+
+ protected void createRuntime() {
+ store = new MemoryStore(EasyMock.createNiceMock(StoreMonitor.class));
+ component = EasyMock.createMock(RuntimeComponent.class);
+ container = new ConversationalScopeContainer(store, component);
+ }
+
+ protected void initializeRuntime() {
+ store.init();
+ container.start();
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration/ConversationIdleExpireTestCase.java.FIXME b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration/ConversationIdleExpireTestCase.java.FIXME
new file mode 100644
index 0000000000..47fa0f0bc5
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration/ConversationIdleExpireTestCase.java.FIXME
@@ -0,0 +1,149 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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 java.net.URI;
+
+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.JDKInvocationHandler;
+import org.apache.tuscany.spi.ObjectCreationException;
+import org.apache.tuscany.spi.Scope;
+import org.apache.tuscany.spi.component.AtomicComponent;
+import org.apache.tuscany.spi.component.InstanceWrapper;
+import org.apache.tuscany.spi.component.TargetNotFoundException;
+import org.apache.tuscany.spi.wire.InvocationChain;
+import org.apache.tuscany.spi.wire.Wire;
+import org.easymock.EasyMock;
+import org.osoa.sca.annotations.Conversational;
+import org.osoa.sca.annotations.EndsConversation;
+
+/**
+ * Verifies conversational resources are cleaned up if the maximum idle time is exceeded
+ *
+ * @version $Rev: 526852 $ $Date: 2007-04-09 10:47:45 -0700 (Mon, 09 Apr 2007) $
+ */
+public abstract class ConversationIdleExpireTestCase extends AbstractConversationTestCase {
+ protected AtomicComponent target;
+ private JDKInvocationHandler handler;
+ private FooImpl targetInstance;
+ private Method operation1;
+ private Method operation2;
+ private final Object mutex = new Object();
+
+ public void testConversationExpire() throws Throwable {
+ workContext.setIdentifier(Scope.CONVERSATION, "12345A");
+ // start the conversation
+ handler.invoke(operation1, null);
+ // verify the instance was persisted
+ assertEquals(targetInstance, ((InstanceWrapper)store.readRecord(target, "12345A")).getInstance());
+ 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(FooImpl.class);
+ targetInstance.operation1();
+ targetInstance.operation2();
+ targetInstance.end();
+ EasyMock.replay(targetInstance);
+ target = createTarget();
+
+ Wire wire = MockFactory.createWire("foo", Foo.class);
+ for (InvocationChain chain : wire.getInvocationChains().values()) {
+ chain.setTargetInvoker(target.createTargetInvoker("target", chain.getOperation(), false));
+ }
+ handler = new JDKInvocationHandler(Foo.class, wire, workContext);
+ operation1 = Foo.class.getMethod("operation1");
+ operation2 = Foo.class.getMethod("operation2");
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ container.stop();
+ store.destroy();
+ }
+
+ private JavaAtomicComponent createTarget() throws Exception {
+ PojoConfiguration configuration = new PojoConfiguration();
+ configuration.setName(new URI("target"));
+ configuration.setMaxIdleTime(50);
+ configuration.setInstanceFactory(new MockPojoFactory(FooImpl.class.getConstructor()));
+ configuration.setImplementationClass(FooImpl.class);
+ JavaAtomicComponent component = new JavaAtomicComponent(configuration);
+ component.setScopeContainer(container);
+ component.start();
+ return component;
+ }
+
+ private class MockPojoFactory extends PojoObjectFactory<FooImpl> {
+ public MockPojoFactory(Constructor<FooImpl> ctr) {
+ super(ctr);
+ }
+
+ public FooImpl getInstance() throws ObjectCreationException {
+ return targetInstance;
+ }
+ }
+
+ @Conversational
+ public static interface Foo {
+
+ void operation1();
+
+ void operation2();
+
+ @EndsConversation
+ void end();
+
+ }
+
+ public static class FooImpl implements Foo {
+
+ public void operation1() {
+ }
+
+ public void operation2() {
+ }
+
+ @EndsConversation
+ public void end() {
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration/ConversationMaxAgeExpireTestCase.java.FIXME b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration/ConversationMaxAgeExpireTestCase.java.FIXME
new file mode 100644
index 0000000000..36e221a1e9
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration/ConversationMaxAgeExpireTestCase.java.FIXME
@@ -0,0 +1,153 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.integration.conversation;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+import java.net.URI;
+
+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.JDKInvocationHandler;
+import org.apache.tuscany.spi.ObjectCreationException;
+import org.apache.tuscany.spi.component.AtomicComponent;
+import org.apache.tuscany.spi.wire.InvocationChain;
+import org.apache.tuscany.spi.wire.Wire;
+import org.easymock.EasyMock;
+import org.osoa.sca.annotations.Conversational;
+import org.osoa.sca.annotations.EndsConversation;
+
+/**
+ * Verifies conversational resources are cleaned up if the maximum age is exceeded
+ *
+ * @version $Rev: 526852 $ $Date: 2007-04-09 10:47:45 -0700 (Mon, 09 Apr 2007) $
+ */
+public abstract class ConversationMaxAgeExpireTestCase extends AbstractConversationTestCase {
+ protected AtomicComponent target;
+ private JDKInvocationHandler handler;
+ private FooImpl 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, ((InstanceWrapper)store.readRecord(target, "12345A")).getInstance());
+ 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(FooImpl.class);
+ targetInstance.operation1();
+ targetInstance.operation2();
+ targetInstance.end();
+ EasyMock.replay(targetInstance);
+ target = createTarget();
+ // create source component mock
+ JavaAtomicComponent source = EasyMock.createMock(JavaAtomicComponent.class);
+ EasyMock.expect(source.getUri()).andReturn(URI.create("source")).atLeastOnce();
+ EasyMock.replay(source);
+
+ Wire wire = MockFactory.createWire("foo", Foo.class);
+ for (InvocationChain chain : wire.getInvocationChains().values()) {
+ chain.setTargetInvoker(target.createTargetInvoker("target", chain.getOperation(), false));
+ }
+ handler = new JDKInvocationHandler(Foo.class, wire, workContext);
+ operation1 = Foo.class.getMethod("operation1");
+ operation2 = Foo.class.getMethod("operation2");
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ container.stop();
+ store.destroy();
+ }
+
+ private AtomicComponent createTarget() throws Exception {
+ PojoConfiguration configuration = new PojoConfiguration();
+ configuration.setName(new URI("target"));
+ configuration.setMaxAge(50);
+ Constructor<FooImpl> ctor = FooImpl.class.getConstructor();
+ configuration.setInstanceFactory(new MockPojoFactory(ctor));
+ configuration.setImplementationClass(FooImpl.class);
+ JavaAtomicComponent component = new JavaAtomicComponent(configuration);
+ component.setScopeContainer(container);
+ component.start();
+ return component;
+ }
+
+ private class MockPojoFactory extends PojoObjectFactory<FooImpl> {
+ public MockPojoFactory(Constructor<FooImpl> ctr) {
+ super(ctr);
+ }
+
+ public FooImpl getInstance() throws ObjectCreationException {
+ return targetInstance;
+ }
+ }
+
+ @Conversational
+ public static interface Foo {
+
+ void operation1();
+
+ void operation2();
+
+ @EndsConversation
+ void end();
+
+ }
+
+ public static class FooImpl implements Foo {
+
+ public void operation1() {
+ }
+
+ public void operation2() {
+ }
+
+ @EndsConversation
+ public void end() {
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration/ConversationStartStopEndTestCase.java.FIXME b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration/ConversationStartStopEndTestCase.java.FIXME
new file mode 100644
index 0000000000..1872eea709
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration/ConversationStartStopEndTestCase.java.FIXME
@@ -0,0 +1,147 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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 java.net.URI;
+
+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.JDKInvocationHandler;
+import org.apache.tuscany.spi.ObjectCreationException;
+import org.apache.tuscany.spi.Scope;
+import org.apache.tuscany.spi.component.AtomicComponent;
+import org.apache.tuscany.spi.component.InstanceWrapper;
+import org.apache.tuscany.spi.wire.InvocationChain;
+import org.apache.tuscany.spi.wire.Wire;
+import org.easymock.EasyMock;
+import org.osoa.sca.annotations.Conversational;
+import org.osoa.sca.annotations.EndsConversation;
+
+/**
+ * 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: 526852 $ $Date: 2007-04-09 10:47:45 -0700 (Mon, 09 Apr 2007) $
+ */
+public abstract class ConversationStartStopEndTestCase extends AbstractConversationTestCase {
+ protected AtomicComponent target;
+ private FooImpl targetInstance;
+ private JDKInvocationHandler handler;
+ private Method operation1;
+ private Method operation2;
+ private Method endOperation;
+
+ public void testConversationStartContinueEnd() throws Throwable {
+ workContext.setIdentifier(Scope.CONVERSATION, "12345A");
+ // start the conversation
+ handler.invoke(operation1, null);
+ // verify the instance was persisted
+ assertEquals(targetInstance, ((InstanceWrapper)store.readRecord(target, "12345A")).getInstance());
+ // continue the conversation
+ handler.invoke(operation2, null);
+ // verify the instance was persisted
+ assertEquals(targetInstance, ((InstanceWrapper)store.readRecord(target, "12345A")).getInstance());
+ // end the conversation
+ handler.invoke(endOperation, null);
+ workContext.clearIdentifier(Scope.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(FooImpl.class);
+ targetInstance.operation1();
+ targetInstance.operation2();
+ targetInstance.end();
+ EasyMock.replay(targetInstance);
+ // create target component mock
+ target = createAtomicComponent();
+ Wire wire = MockFactory.createWire("foo", Foo.class);
+ for (InvocationChain chain : wire.getInvocationChains().values()) {
+ chain.setTargetInvoker(target.createTargetInvoker("foo", chain.getOperation(), false));
+ }
+ handler = new JDKInvocationHandler(Foo.class, wire, 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(new URI("target"));
+ configuration.setInstanceFactory(new MockPojoFactory(FooImpl.class.getConstructor()));
+ configuration.setImplementationClass(FooImpl.class);
+ JavaAtomicComponent component = new JavaAtomicComponent(configuration);
+ component.setScopeContainer(container);
+ component.start();
+ return component;
+ }
+
+ private class MockPojoFactory extends PojoObjectFactory<FooImpl> {
+ public MockPojoFactory(Constructor<FooImpl> ctr) {
+ super(ctr);
+ }
+
+ public FooImpl getInstance() throws ObjectCreationException {
+ return targetInstance;
+ }
+ }
+
+ @Conversational
+ public static interface Foo {
+
+ void operation1();
+
+ void operation2();
+
+ @EndsConversation
+ void end();
+
+ }
+
+ public static class FooImpl implements Foo {
+
+ public void operation1() {
+ }
+
+ public void operation2() {
+ }
+
+ @EndsConversation
+ public void end() {
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration/ReferenceInjectionTestCase.java.FIXME b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration/ReferenceInjectionTestCase.java.FIXME
new file mode 100644
index 0000000000..17a832b117
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration/ReferenceInjectionTestCase.java.FIXME
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.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 java.net.URI;
+
+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.Target;
+import org.apache.tuscany.core.mock.component.TargetImpl;
+
+/**
+ * @version $$Rev: 526399 $$ $$Date: 2007-04-07 01:14:49 -0700 (Sat, 07 Apr 2007) $$
+ */
+public class ReferenceInjectionTestCase extends TestCase {
+ private Map<String, Member> members;
+
+ public void testProxiedReferenceInjection() throws Exception {
+ ScopeContainer scope = new CompositeScopeContainer(null);
+ scope.start();
+ URI groupId = URI.create("composite");
+ scope.startContext(groupId, groupId);
+ Map<String, AtomicComponent> 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<String, Member>();
+ Method m = SourceImpl.class.getMethod("setTarget", Target.class);
+ members.put("target", m);
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/AsyncTarget.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/AsyncTarget.java
new file mode 100644
index 0000000000..65681550c0
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/AsyncTarget.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.mock;
+
+import org.osoa.sca.annotations.OneWay;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface AsyncTarget {
+ @OneWay
+ void invoke();
+
+ int getCount();
+}
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/BadContextPojo.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/BadContextPojo.java
new file mode 100644
index 0000000000..319d965960
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/BadContextPojo.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.mock;
+
+import org.osoa.sca.annotations.Context;
+
+public class BadContextPojo {
+
+ @Context
+ String context;
+
+}
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/BadNamePojo.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/BadNamePojo.java
new file mode 100644
index 0000000000..1a93254f2b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/BadNamePojo.java
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.mock;
+
+import org.osoa.sca.annotations.ComponentName;
+
+public class BadNamePojo {
+ @ComponentName
+ private int name;
+}
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/BasicInterface.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/BasicInterface.java
new file mode 100644
index 0000000000..716a70b007
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/BasicInterface.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.mock;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface BasicInterface {
+ String returnsProperty();
+
+ BasicInterface returnsReference();
+
+ int returnsInt();
+}
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/BasicInterfaceImpl.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/BasicInterfaceImpl.java
new file mode 100644
index 0000000000..5f3dc8e5fb
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/BasicInterfaceImpl.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.mock;
+
+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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/CompositeScopeComponent.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/CompositeScopeComponent.java
new file mode 100644
index 0000000000..1014dd3e1f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/CompositeScopeComponent.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.mock;
+
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * @version $Rev$ $Date$
+ */
+@Scope("COMPOSITE")
+public interface CompositeScopeComponent {
+
+ //public boolean isInit();
+}
+
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/CompositeScopeComponentImpl.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/CompositeScopeComponentImpl.java
new file mode 100644
index 0000000000..2b654111f3
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/CompositeScopeComponentImpl.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.mock;
+
+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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/CompositeScopeDestroyOnlyComponent.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/CompositeScopeDestroyOnlyComponent.java
new file mode 100644
index 0000000000..7c5751578a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/CompositeScopeDestroyOnlyComponent.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.mock;
+
+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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/CompositeScopeInitDestroyComponent.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/CompositeScopeInitDestroyComponent.java
new file mode 100644
index 0000000000..4e08b7157b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/CompositeScopeInitDestroyComponent.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.mock;
+
+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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/CompositeScopeInitOnlyComponent.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/CompositeScopeInitOnlyComponent.java
new file mode 100644
index 0000000000..a9c8bf1566
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/CompositeScopeInitOnlyComponent.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.mock;
+
+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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/ConversationalScopeComponent.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/ConversationalScopeComponent.java
new file mode 100644
index 0000000000..39e8c4ca11
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/ConversationalScopeComponent.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.mock;
+
+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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/ConversationalScopeComponentImpl.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/ConversationalScopeComponentImpl.java
new file mode 100644
index 0000000000..caf5b292f6
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/ConversationalScopeComponentImpl.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.mock;
+
+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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/ConversationalScopeDestroyOnlyComponent.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/ConversationalScopeDestroyOnlyComponent.java
new file mode 100644
index 0000000000..9fe019010d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/ConversationalScopeDestroyOnlyComponent.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.mock;
+
+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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/ConversationalScopeInitDestroyComponent.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/ConversationalScopeInitDestroyComponent.java
new file mode 100644
index 0000000000..77f9855fe0
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/ConversationalScopeInitDestroyComponent.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.mock;
+
+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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/ConversationalScopeInitOnlyComponent.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/ConversationalScopeInitOnlyComponent.java
new file mode 100644
index 0000000000..d45d1a3def
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/ConversationalScopeInitOnlyComponent.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.mock;
+
+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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/MockFactory.java.FIXME b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/MockFactory.java.FIXME
new file mode 100644
index 0000000000..56bccd8f09
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/MockFactory.java.FIXME
@@ -0,0 +1,214 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.integration.mock;
+
+import java.lang.reflect.Member;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.assembly.Contract;
+import org.apache.tuscany.assembly.impl.DefaultAssemblyFactory;
+import org.apache.tuscany.core.component.WorkContextImpl;
+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.InvocationChainImpl;
+import org.apache.tuscany.core.wire.InvokerInterceptor;
+import org.apache.tuscany.core.wire.WireImpl;
+import org.apache.tuscany.core.wire.jdk.JDKProxyService;
+import org.apache.tuscany.interfacedef.InvalidInterfaceException;
+import org.apache.tuscany.interfacedef.Operation;
+import org.apache.tuscany.interfacedef.java.introspection.JavaInterfaceProcessorRegistry;
+import org.apache.tuscany.interfacedef.java.introspection.impl.JavaInterfaceProcessorRegistryImpl;
+import org.apache.tuscany.spi.component.AtomicComponent;
+import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.spi.wire.Interceptor;
+import org.apache.tuscany.spi.wire.InvocationChain;
+import org.apache.tuscany.spi.wire.ProxyService;
+import org.apache.tuscany.spi.wire.Wire;
+
+/**
+ * @version $$Rev: 526852 $$ $$Date: 2007-04-09 10:47:45 -0700 (Mon, 09 Apr 2007) $$
+ */
+public final class MockFactory {
+
+ private static final ProxyService PROXY_SERVICE = new JDKProxyService(new WorkContextImpl());
+ private static final JavaInterfaceProcessorRegistry REGISTRY = new JavaInterfaceProcessorRegistryImpl();
+
+ private MockFactory() {
+ }
+
+ /**
+ * Wires two components together where the reference interface is the same as target service
+ */
+ public static Map<String, AtomicComponent> createWiredComponents(String sourceName,
+ Class<?> sourceClass,
+ ScopeContainer sourceScope,
+ Map<String, Member> members,
+ String targetName,
+ Class<?> targetService,
+ Class<?> targetClass,
+ ScopeContainer targetScope) throws Exception {
+ return createWiredComponents(sourceName,
+ sourceClass,
+ targetService,
+ sourceScope,
+ null,
+ members,
+ targetName,
+ targetClass,
+ targetScope
+ );
+
+ }
+
+ @SuppressWarnings("unchecked")
+ public static Map<String, AtomicComponent> createWiredComponents(String sourceName, Class<?> sourceClass,
+ Class<?> sourceReferenceClass,
+ ScopeContainer sourceScope,
+ Interceptor sourceHeadInterceptor,
+ Map<String, Member> members,
+ String targetName,
+ Class<?> targetClass,
+ ScopeContainer targetScope
+ )
+ throws Exception {
+
+ JavaAtomicComponent targetComponent =
+ createJavaComponent(targetName, targetScope, targetClass);
+ PojoConfiguration configuration = new PojoConfiguration();
+ configuration.setInstanceFactory(new PojoObjectFactory(sourceClass.getConstructor()));
+ configuration.setProxyService(PROXY_SERVICE);
+ for (Map.Entry<String, Member> entry : members.entrySet()) {
+ configuration.addReferenceSite(entry.getKey(), entry.getValue());
+ }
+ configuration.setWorkContext(new WorkContextImpl());
+ configuration.setName(new URI(sourceName));
+ configuration.setGroupId(URI.create("composite"));
+ JavaAtomicComponent sourceComponent = new JavaAtomicComponent(configuration);
+ sourceComponent.setScopeContainer(sourceScope);
+ Wire wire = createWire(targetName, sourceReferenceClass, sourceHeadInterceptor);
+ for (InvocationChain chain : wire.getInvocationChains().values()) {
+ chain.setTargetInvoker(targetComponent.createTargetInvoker(targetName, chain.getOperation(), false));
+ }
+ sourceComponent.attachWire(wire);
+ targetScope.register(targetComponent, configuration.getGroupId());
+ sourceScope.register(sourceComponent, configuration.getGroupId());
+ Map<String, AtomicComponent> components = new HashMap<String, AtomicComponent>();
+ components.put(sourceName, sourceComponent);
+ components.put(targetName, targetComponent);
+ return components;
+ }
+
+
+ /**
+ * Wires two components using a multiplicity reference
+ */
+ @SuppressWarnings("unchecked")
+ public static Map<String, AtomicComponent> createWiredMultiplicity(String sourceName, Class<?> sourceClass,
+ Class<?> sourceReferenceClass,
+ ScopeContainer sourceScope,
+ String targetName, Class<?> targetService,
+ Class<?> targetClass,
+ Map<String, Member> members,
+ ScopeContainer targetScope) throws Exception {
+ JavaAtomicComponent targetComponent =
+ createJavaComponent(targetName, targetScope, targetClass);
+ String serviceName = targetService.getName().substring(targetService.getName().lastIndexOf('.') + 1);
+ PojoConfiguration configuration = new PojoConfiguration();
+ configuration.setInstanceFactory(new PojoObjectFactory(sourceClass.getConstructor()));
+ configuration.setProxyService(PROXY_SERVICE);
+ for (Map.Entry<String, Member> entry : members.entrySet()) {
+ configuration.addReferenceSite(entry.getKey(), entry.getValue());
+ }
+ configuration.setWorkContext(new WorkContextImpl());
+ configuration.setName(new URI(sourceName));
+ configuration.setGroupId(URI.create("composite"));
+
+ JavaAtomicComponent sourceComponent = new JavaAtomicComponent(configuration);
+ sourceComponent.setScopeContainer(sourceScope);
+ Wire wire = createWire(targetName, sourceReferenceClass, null);
+ wire.setTargetUri(URI.create(targetName + "#" + serviceName));
+ for (InvocationChain chain : wire.getInvocationChains().values()) {
+ chain.setTargetInvoker(targetComponent.createTargetInvoker("target", chain.getOperation(), false));
+ }
+ List<Wire> wires = new ArrayList<Wire>();
+ wires.add(wire);
+ sourceComponent.attachWires(wires);
+ targetScope.register(targetComponent, configuration.getGroupId());
+ sourceScope.register(sourceComponent, configuration.getGroupId());
+
+ Map<String, AtomicComponent> components = new HashMap<String, AtomicComponent>();
+ components.put(sourceName, sourceComponent);
+ components.put(targetName, targetComponent);
+ return components;
+ }
+
+ public static <T> Wire createWire(String serviceName, Class<T> interfaze)
+ throws InvalidInterfaceException {
+ return createWire(serviceName, interfaze, null);
+ }
+
+ public static <T> Wire createWire(String serviceName, Class<T> interfaze, Interceptor interceptor)
+ throws InvalidInterfaceException {
+ Wire wire = new WireImpl();
+ Contract contract = new DefaultAssemblyFactory().createComponentService();
+ REGISTRY.introspect(contract, interfaze);
+ wire.setSourceContract(contract);
+ wire.setSourceUri(URI.create("#" + serviceName));
+ createChains(interfaze, interceptor, wire);
+ return wire;
+ }
+
+ @SuppressWarnings("unchecked")
+ private static <T> JavaAtomicComponent createJavaComponent(String name, ScopeContainer scope, Class<T> clazz)
+ throws NoSuchMethodException, URISyntaxException {
+ PojoConfiguration configuration = new PojoConfiguration();
+ configuration.setImplementationClass(clazz);
+ configuration.setInstanceFactory(new PojoObjectFactory(clazz.getConstructor()));
+ configuration.setProxyService(PROXY_SERVICE);
+ configuration.setWorkContext(new WorkContextImpl());
+ configuration.setName(new URI(name));
+ configuration.setGroupId(URI.create("composite"));
+ JavaAtomicComponent component = new JavaAtomicComponent(configuration);
+ component.setScopeContainer(scope);
+ return component;
+ }
+
+ private static void createChains(Class<?> interfaze, Interceptor interceptor, Wire wire)
+ throws InvalidInterfaceException {
+
+ Contract contract = new DefaultAssemblyFactory().createComponentService();
+ REGISTRY.introspect(contract, interfaze);
+ for (Operation method : contract.getInterface().getOperations()) {
+ InvocationChain chain = new InvocationChainImpl(method);
+ if (interceptor != null) {
+ chain.addInterceptor(interceptor);
+ }
+ // add tail interceptor
+ chain.addInterceptor(new InvokerInterceptor());
+ wire.addInvocationChain(method, chain);
+ }
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/MockStaticInvoker.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/MockStaticInvoker.java
new file mode 100644
index 0000000000..23822bec74
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/MockStaticInvoker.java
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.mock;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.sca.implementation.java.invocation.TargetInvoker;
+import org.apache.tuscany.sca.interfacedef.ConversationSequence;
+import org.apache.tuscany.sca.invocation.Interceptor;
+import org.apache.tuscany.sca.invocation.Message;
+import org.osoa.sca.ServiceRuntimeException;
+
+/**
+ * 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 Object invokeTarget(final Object payload, final ConversationSequence 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 ServiceRuntimeException(e);
+ }
+ }
+
+ public Message invoke(Message msg) {
+ try {
+ Object resp = invokeTarget(msg.getBody(), null);
+ msg.setBody(resp);
+ } catch (InvocationTargetException e) {
+ msg.setFaultBody(e.getCause());
+ } catch (Throwable e) {
+ msg.setFaultBody(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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/MockSyncInterceptor.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/MockSyncInterceptor.java
new file mode 100644
index 0000000000..1e2f89cdf6
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/MockSyncInterceptor.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.mock;
+
+import org.apache.tuscany.sca.invocation.Interceptor;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+
+public class MockSyncInterceptor implements Interceptor {
+
+ private int count;
+
+ private Invoker next;
+
+ public MockSyncInterceptor() {
+ }
+
+ public Message invoke(Message msg) {
+ ++count;
+ return next.invoke(msg);
+ }
+
+ public int getCount() {
+ return count;
+ }
+
+ public void setNext(Invoker next) {
+ this.next = next;
+ }
+
+ public Invoker getNext() {
+ return next;
+ }
+
+}
+
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OrderException.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OrderException.java
new file mode 100644
index 0000000000..1d337de93f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OrderException.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.mock;
+
+public class OrderException extends Exception {
+
+ public OrderException() {
+ super();
+ }
+
+ public OrderException(String message) {
+ super(message);
+ }
+
+ public OrderException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public OrderException(Throwable cause) {
+ super(cause);
+ }
+
+}
+
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OrderedDependentPojo.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OrderedDependentPojo.java
new file mode 100644
index 0000000000..09b58497fe
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OrderedDependentPojo.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.mock;
+
+/**
+ * @version $$Rev$$ $$Date$$
+ */
+public interface OrderedDependentPojo extends OrderedInitPojo {
+
+ OrderedInitPojo getPojo();
+
+ void setPojo(OrderedInitPojo pojo);
+}
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OrderedDependentPojoImpl.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OrderedDependentPojoImpl.java
new file mode 100644
index 0000000000..0fc5a88925
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OrderedDependentPojoImpl.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.mock;
+
+/**
+ * @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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OrderedEagerInitPojo.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OrderedEagerInitPojo.java
new file mode 100644
index 0000000000..0907bf3e8b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OrderedEagerInitPojo.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.mock;
+
+import org.osoa.sca.annotations.Destroy;
+import org.osoa.sca.annotations.EagerInit;
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Scope;
+
+@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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OrderedInitPojo.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OrderedInitPojo.java
new file mode 100644
index 0000000000..0c4f65e904
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OrderedInitPojo.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.mock;
+
+/**
+ * @version $$Rev$$ $$Date$$
+ */
+public interface OrderedInitPojo {
+ int getNumberInstantiated();
+
+ int getInitOrder();
+}
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OrderedInitPojoImpl.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OrderedInitPojoImpl.java
new file mode 100644
index 0000000000..e67a1b807b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OrderedInitPojoImpl.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.mock;
+
+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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OtherTarget.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OtherTarget.java
new file mode 100644
index 0000000000..61802beaea
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OtherTarget.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.mock;
+
+/**
+ * Implementations are used in wiring tests
+ *
+ * @version $Rev$ $Date$
+ */
+public interface OtherTarget {
+
+ String getString();
+
+ void setString(String val);
+}
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OtherTargetImpl.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OtherTargetImpl.java
new file mode 100644
index 0000000000..3b8c4842f1
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OtherTargetImpl.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.mock;
+
+/**
+ * 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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/RequestScopeComponent.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/RequestScopeComponent.java
new file mode 100644
index 0000000000..b10b1e7648
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/RequestScopeComponent.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.mock;
+
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * @version $Rev$ $Date$
+ */
+@Scope("REQUEST")
+public interface RequestScopeComponent {
+
+}
+
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/RequestScopeDestroyOnlyComponent.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/RequestScopeDestroyOnlyComponent.java
new file mode 100644
index 0000000000..f504e284ab
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/RequestScopeDestroyOnlyComponent.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.mock;
+
+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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/RequestScopeInitDestroyComponent.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/RequestScopeInitDestroyComponent.java
new file mode 100644
index 0000000000..5a0f15a54f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/RequestScopeInitDestroyComponent.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.mock;
+
+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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/RequestScopeInitOnlyComponent.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/RequestScopeInitOnlyComponent.java
new file mode 100644
index 0000000000..b72cf2f1a3
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/RequestScopeInitOnlyComponent.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.mock;
+
+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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SessionScopeComponent.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SessionScopeComponent.java
new file mode 100644
index 0000000000..7dcfd4acda
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SessionScopeComponent.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.mock;
+
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * @version $Rev$ $Date$
+ */
+@Scope("SESSION")
+public interface SessionScopeComponent {
+
+}
+
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SessionScopeComponentImpl.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SessionScopeComponentImpl.java
new file mode 100644
index 0000000000..bb0da51475
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SessionScopeComponentImpl.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.mock;
+
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * @version $Rev$ $Date$
+ */
+@Scope("SESSION")
+public class SessionScopeComponentImpl implements
+ SessionScopeComponent {
+
+}
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SessionScopeInitDestroyComponent.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SessionScopeInitDestroyComponent.java
new file mode 100644
index 0000000000..5dc7d82a8d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SessionScopeInitDestroyComponent.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.mock;
+
+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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SessionScopeInitOnlyComponent.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SessionScopeInitOnlyComponent.java
new file mode 100644
index 0000000000..9a212c927f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SessionScopeInitOnlyComponent.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.mock;
+
+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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SimpleTarget.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SimpleTarget.java
new file mode 100644
index 0000000000..d8b6be1de0
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SimpleTarget.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.mock;
+
+public interface SimpleTarget {
+
+ String hello(String message) throws Exception;
+
+ String goodbye(String message) throws Exception;
+
+ String echo(String message) throws Exception;
+
+}
+
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SimpleTargetImpl.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SimpleTargetImpl.java
new file mode 100644
index 0000000000..27cb9a7617
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SimpleTargetImpl.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.mock;
+
+public class SimpleTargetImpl implements SimpleTarget {
+
+ public SimpleTargetImpl() {
+ super();
+ }
+
+ public String hello(String message) throws Exception {
+ return message;
+ }
+
+ public String goodbye(String message) throws Exception {
+ return message;
+ }
+
+ public String echo(String message) throws Exception {
+ return message;
+ }
+
+
+}
+
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/Source.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/Source.java
new file mode 100644
index 0000000000..630809bcad
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/Source.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.mock;
+
+import java.util.List;
+
+/**
+ * Implementations are used in wiring tests
+ *
+ * @version $Rev$ $Date$
+ */
+public interface Source {
+
+ Target getTarget();
+
+ List<Target> getTargets();
+
+ List<Target> getTargetsThroughField();
+
+}
+
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SourceImpl.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SourceImpl.java
new file mode 100644
index 0000000000..bd1abf6577
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SourceImpl.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.mock;
+
+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<Target> targets;
+ private List<Target> targetsThroughField;
+ private Target[] targetsArray;
+
+ public void setTarget(Target target) {
+ this.target = target;
+ }
+
+ public Target getTarget() {
+ return target;
+ }
+
+ public List<Target> getTargets() {
+ return targets;
+ }
+
+ public void setTargets(List<Target> targets) {
+ this.targets = targets;
+ }
+
+ public List<Target> getTargetsThroughField() {
+ return targetsThroughField;
+ }
+
+ public Target[] getArrayOfTargets() {
+ return targetsArray;
+ }
+
+ public void setArrayOfTargets(Target[] targets) {
+ targetsArray = targets;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/StatelessComponent.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/StatelessComponent.java
new file mode 100644
index 0000000000..7eb9172f28
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/StatelessComponent.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.mock;
+
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * @version $Rev$ $Date$
+ */
+@Scope("STATELESS")
+public interface StatelessComponent {
+
+}
+
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/StatelessComponentImpl.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/StatelessComponentImpl.java
new file mode 100644
index 0000000000..b1e0d33b63
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/StatelessComponentImpl.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.mock;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class StatelessComponentImpl implements
+ StatelessComponent {
+
+}
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/Target.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/Target.java
new file mode 100644
index 0000000000..fd175bdbc5
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/Target.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.mock;
+
+/**
+ * Implementations are used in wiring tests
+ *
+ * @version $Rev$ $Date$
+ */
+public interface Target {
+
+ String getString();
+
+ void setString(String val);
+}
+
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/TargetImpl.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/TargetImpl.java
new file mode 100644
index 0000000000..5f5a11028f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/TargetImpl.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.mock;
+
+/**
+ * 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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/monitor/ExceptionFormatterTestCase.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/monitor/ExceptionFormatterTestCase.java
new file mode 100644
index 0000000000..7598b4f968
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/monitor/ExceptionFormatterTestCase.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.monitor;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ExceptionFormatterTestCase extends TestCase {
+ private ExceptionFormatterImpl formatter = new ExceptionFormatterImpl();
+
+ public void testTuscanyExceptionFormat() throws Exception {
+ StringWriter writer = new StringWriter();
+ PrintWriter pw = new PrintWriter(writer);
+ Exception e = new Exception("somemessage") {
+ };
+ formatter.write(pw, e);
+ assertTrue(writer.toString().indexOf("somemessage") >= 0);
+ }
+
+ public void testTuscanyRuntimeExceptionFormat() throws Exception {
+ StringWriter writer = new StringWriter();
+ PrintWriter pw = new PrintWriter(writer);
+ RuntimeException e = new RuntimeException("somemessage") {
+ };
+ formatter.write(pw, e);
+ assertTrue(writer.toString().indexOf("somemessage") >= 0);
+ }
+
+ public void testNormalExceptionFormat() throws Exception {
+ StringWriter writer = new StringWriter();
+ PrintWriter pw = new PrintWriter(writer);
+ Exception e = new Exception();
+ formatter.write(pw, e); // just verify there are no errors since no formatting needs to be doen
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/monitor/JavaLoggingTestCase.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/monitor/JavaLoggingTestCase.java
new file mode 100644
index 0000000000..2f7ed80030
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/monitor/JavaLoggingTestCase.java
@@ -0,0 +1,152 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.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 junit.framework.TestCase;
+
+import org.apache.tuscany.api.annotation.LogLevel;
+
+/**
+ * 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<LogRecord> logs = new ArrayList<LogRecord>();
+
+ 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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/Bean1.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/Bean1.java
new file mode 100644
index 0000000000..40cf2e27cf
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/Bean1.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/Bean2.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/Bean2.java
new file mode 100644
index 0000000000..a00b9e7109
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/Bean2.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/JavaIntrospectionHelperTestCase.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/JavaIntrospectionHelperTestCase.java
new file mode 100644
index 0000000000..1c8f1caa93
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/JavaIntrospectionHelperTestCase.java
@@ -0,0 +1,182 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.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.sca.implementation.java.introspect.impl.JavaIntrospectionHelper;
+import org.apache.tuscany.sca.implementation.java.mock.Target;
+
+public class JavaIntrospectionHelperTestCase extends TestCase {
+
+ private List testNoGenericsList;
+ private List<String> testList;
+ private Map<String, Bean1> testMap;
+ private Target[] testArray;
+ private String[] testStringArray;
+
+ public JavaIntrospectionHelperTestCase() {
+ super();
+ }
+
+ public JavaIntrospectionHelperTestCase(String arg0) {
+ super(arg0);
+ }
+
+ public void testBean1AllPublicProtectedFields() throws Exception {
+ Set<Field> beanFields = JavaIntrospectionHelper.getAllPublicAndProtectedFields(Bean1.class);
+ assertEquals(4, beanFields.size()); //Bean1.ALL_BEAN1_PUBLIC_PROTECTED_FIELDS
+ }
+
+ public void testGetSuperAllMethods() throws Exception {
+ Set<Method> superBeanMethods = JavaIntrospectionHelper.getAllUniquePublicProtectedMethods(SuperBean.class);
+ assertEquals(SuperBean.ALL_SUPER_METHODS, superBeanMethods.size());
+ }
+
+ public void testGetBean1AllMethods() throws Exception {
+ Set<Method> beanMethods = JavaIntrospectionHelper.getAllUniquePublicProtectedMethods(Bean1.class);
+ assertEquals(Bean1.ALL_BEAN1_METHODS, beanMethods.size());
+ }
+
+ public void testOverrideMethod() throws Exception {
+ Set<Method> 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<Method> 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<Class> interfaces = JavaIntrospectionHelper.getAllInterfaces(Z.class);
+ assertEquals(2, interfaces.size());
+ assertTrue(interfaces.contains(W.class));
+ assertTrue(interfaces.contains(W2.class));
+ }
+
+
+ public void testGetAllInterfacesObject() {
+ Set<Class> interfaces = JavaIntrospectionHelper.getAllInterfaces(Object.class);
+ assertEquals(0, interfaces.size());
+ }
+
+ public void testGetAllInterfacesNoInterfaces() {
+ Set<Class> 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<String> foo) {
+
+ }
+
+ private void fooMethod(Map<String, Bean1> 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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/SuperBean.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/SuperBean.java
new file mode 100644
index 0000000000..408cedb8be
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/SuperBean.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.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 {
+ }
+
+}